git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] branch: colour upstream branches

From
Duy Nguyen <pclouds@gmail.com>
Date
Apr 15, 2013, 00:55 UTC
Message-ID
<CACsJy8CTmh2eMDqBpr0agiTGcHkP_AQBLLg2A4HM203u9G1v9g@mail.gmail.com>
In-Reply-To
<CAMP44s38e4n_jKC-f973JJUXuxkD2dqP+ECwzxvUMWxit2P2PA@mail.gmail.com>

On Mon, Apr 15, 2013 at 9:54 AM, Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 27 quoted lines
> On Sun, Apr 14, 2013 at 6:46 PM, Duy Nguyen <pclouds@gmail.com> wrote:
>> On Mon, Apr 15, 2013 at 9:22 AM, Felipe Contreras
>> <felipe.contreras@gmail.com> wrote:
>>> 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.
>
> Would changing it to 1024 (MAXREFLEN) fix it?

You still need to take ansi codes into account. I think it's easier to just use strbuf. -- Duy

Previous: Felipe ContrerasNext: Felipe Contreras
Message 7 of 10 in “branch: colour upstream branches”
  1. branch: colour upstream branchesFelipe Contreras, Apr 14, 2013
  2. Thomas RastApr 14, 2013
  3. Duy NguyenApr 14, 2013
  4. Felipe ContrerasApr 14, 2013
  5. Duy NguyenApr 14, 2013
  6. Felipe ContrerasApr 14, 2013
  7. Duy NguyenApr 15, 2013
  8. Felipe ContrerasApr 15, 2013
  9. Duy NguyenApr 15, 2013
  10. Felipe ContrerasApr 15, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.