public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: "René Scharfe" <l.s.r@web•de>
Cc: Git List <git@vger•kernel.org>
Subject: Re: [PATCH 4/5] wt-status: don't skip a magical number of characters blindly
Date: Sun, 01 Nov 2015 09:51:54 -0800	[thread overview]
Message-ID: <xmqq7fm1ip51.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <5634FC48.7070609@web.de> ("René Scharfe"'s message of "Sat, 31 Oct 2015 18:37:12 +0100")

René Scharfe <l.s.r@web•de> writes:

> Use the variable branch_name, which already has "refs/heads/" removed,
> instead of blindly advancing in the ->branch string by 11 bytes.  This
> is safer and less magical.
>
> Signed-off-by: Rene Scharfe <l.s.r@web•de>
> ---
>  wt-status.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/wt-status.c b/wt-status.c
> index e206cc9..42ea15e 100644
> --- a/wt-status.c
> +++ b/wt-status.c
> @@ -1656,7 +1656,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
>  	if (starts_with(branch_name, "refs/heads/"))
>  		branch_name += 11;
>  
> -	branch = branch_get(s->branch + 11);
> +	branch = branch_get(branch_name);

Is this correct?  s->branch is the refname that is l10n independent;
branch_name is the localized variant for human consumption.

>  	color_fprintf(s->fp, branch_color_local, "%s", branch_name);

  reply	other threads:[~2015-11-01 17:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-31 17:33 [PATCH 0/5] wt-status: fix an invalid memory read, clean up René Scharfe
2015-10-31 17:35 ` [PATCH 1/5] t7060: add test for status --branch on a detached HEAD René Scharfe
2015-10-31 17:36 ` [PATCH 2/5] wt-status: exit early using goto in wt_shortstatus_print_tracking() René Scharfe
2015-10-31 17:36 ` [PATCH 3/5] wt-status: avoid building bogus branch name with detached HEAD René Scharfe
2015-11-01 17:50   ` Junio C Hamano
2015-11-01 18:11     ` René Scharfe
2015-10-31 17:37 ` [PATCH 4/5] wt-status: don't skip a magical number of characters blindly René Scharfe
2015-11-01 17:51   ` Junio C Hamano [this message]
2015-11-01 17:55     ` Junio C Hamano
2015-10-31 17:37 ` [PATCH 5/5] wt-status: use skip_prefix() to get rid of magic string length constants René Scharfe

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=xmqq7fm1ip51.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=l.s.r@web$(echo .)de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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