From: Duy Nguyen <pclouds@gmail.com>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] branch: colour upstream branches
Date: Mon, 15 Apr 2013 10:55:02 +1000 [thread overview]
Message-ID: <CACsJy8CTmh2eMDqBpr0agiTGcHkP_AQBLLg2A4HM203u9G1v9g@mail.gmail.com> (raw)
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:
> 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
next prev parent reply other threads:[~2013-04-15 0:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-14 1:46 [PATCH] branch: colour upstream branches Felipe Contreras
2013-04-14 19:07 ` Thomas Rast
2013-04-14 22:31 ` Duy Nguyen
2013-04-14 23:22 ` Felipe Contreras
2013-04-14 23:46 ` Duy Nguyen
2013-04-14 23:54 ` Felipe Contreras
2013-04-15 0:55 ` Duy Nguyen [this message]
2013-04-15 1:24 ` Felipe Contreras
2013-04-15 1:31 ` Duy Nguyen
2013-04-15 1:35 ` Felipe Contreras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACsJy8CTmh2eMDqBpr0agiTGcHkP_AQBLLg2A4HM203u9G1v9g@mail.gmail.com \
--to=pclouds@gmail.com \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).