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

From: Junio C Hamano <[email-masked]>
Date: Wed, 30 Jul 2014 12:53:35 -0700

Eric Sunshine <[email-masked]> 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 (!resolve_ref(ref, &buf, sha1, reading, flag))
>> +               return buf.buf;
>
> return strbuf_detach(&buf, NULL);

Yeah, the end result is the same, but it is a very good discipline.