Re: [PATCH] branch: colour upstream branches
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Apr 14, 2013, 23:46 UTC
- Message-ID
- <CACsJy8AGFEEkS2qQygnbZOorGv=DKc2OgC-nZ47+k2oYGBBD2Q@mail.gmail.com>
- In-Reply-To
- <CAMP44s2j-Cqksu29fJRTqDNGBNi1tZkE0gfgj69K-ckFwVgnRg@mail.gmail.com>
On Mon, Apr 15, 2013 at 9:22 AM, Felipe Contreras <felipe.contreras@gmail.com> wrote:
Show 19 quoted lines
> On Sun, Apr 14, 2013 at 5:31 PM, Duy Nguyen <pclouds@gmail.com> wrote:
>> On Sun, Apr 14, 2013 at 11:46 AM, Felipe Contreras
>> <felipe.contreras@gmail.com> wrote:
>>> + char fancy[80];
>>>
>>> - if (show_upstream_ref)
>>> + if (show_upstream_ref) {
>>> ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
>>> + if (want_color(branch_use_color))
>>> + snprintf(fancy, sizeof(fancy), "%s%s%s",
>>> + GIT_COLOR_BLUE, ref, GIT_COLOR_RESET);
>>> + else
>>> + strncpy(fancy, ref, sizeof(fancy));
>>> + }
>>> +
>>
>> Please use strbuf for "fancy".
>
> Why? We would need to initialize and free it. What's the advantage?>From a quick glance, I don't see any gurantee that "ref" (plus ansi
codes) will always fit in 80 bytes. -- Duy