Re: [PATCH 2/4] refs.c: refactor resolve_ref_unsafe() to use strbuf internally

2014-07-30 Thread Junio C Hamano
Eric Sunshine writes: >> char *resolve_refdup(const char *ref, unsigned char *sha1, int reading, int >> *flag) >> { >> - const char *ret = resolve_ref_unsafe(ref, sha1, reading, flag); >> - return ret ? xstrdup(ret) : NULL; >> + struct strbuf buf = STRBUF_INIT; >> + if

Re: [PATCH 2/4] refs.c: refactor resolve_ref_unsafe() to use strbuf internally

2014-07-25 Thread Eric Sunshine
On Fri, Jul 25, 2014 at 6:43 AM, Nguyễn Thái Ngọc Duy wrote: > In the beginning, we had resolve_ref() that returns a buffer owned by > this function. Then we started to move away from that direction because > the buffer could be overwritten by the next resolve_ref() call and > introduced two new f

[PATCH 2/4] refs.c: refactor resolve_ref_unsafe() to use strbuf internally

2014-07-25 Thread Nguyễn Thái Ngọc Duy
In the beginning, we had resolve_ref() that returns a buffer owned by this function. Then we started to move away from that direction because the buffer could be overwritten by the next resolve_ref() call and introduced two new functions: resolve_ref_unsafe() and resolve_refdup(). The static buffer