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

Re: [PATCH 4/5] wt-status: don't skip a magical number of characters blindly

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 1, 2015, 17:51 UTC
Message-ID
<xmqq7fm1ip51.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<5634FC48.7070609@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 19 quoted lines
> 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);
Previous: René ScharfeNext: Junio C Hamano
Message 8 of 10 in “wt-status: fix an invalid memory read, clean up”
  1. 0/5 wt-status: fix an invalid memory read, clean upRené Scharfe, Oct 31, 2015
  2. 1/5 t7060: add test for status --branch on a detached HEADRené Scharfe, Oct 31, 2015
  3. 2/5 wt-status: exit early using goto in wt_shortstatus_print_tracking()René Scharfe, Oct 31, 2015
  4. 3/5 wt-status: avoid building bogus branch name with detached HEADRené Scharfe, Oct 31, 2015
  5. Junio C HamanoNov 1, 2015
  6. René ScharfeNov 1, 2015
  7. 4/5 wt-status: don't skip a magical number of characters blindlyRené Scharfe, Oct 31, 2015
  8. Junio C HamanoNov 1, 2015
  9. Junio C HamanoNov 1, 2015
  10. 5/5 wt-status: use skip_prefix() to get rid of magic string length constantsRené Scharfe, Oct 31, 2015

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.