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

Re: [PATCH] Fix git-show-branch --current when not on a branch

From
Stephan Beyer <s-beyer@gmx.net>
Date
May 27, 2008, 00:20 UTC
Message-ID
<20080527002051.GA13683@leksak.fem-net>
In-Reply-To
<7vhcck4t6z.fsf@gitster.siamese.dyndns.org>
Hi,
Show 16 quoted lines
> >  builtin-show-branch.c |    3 +--
> >  1 files changed, 1 insertions(+), 2 deletions(-)
> >
> > diff --git a/builtin-show-branch.c b/builtin-show-branch.c
> > index 019abd3..412eba0 100644
> > --- a/builtin-show-branch.c
> > +++ b/builtin-show-branch.c
> > @@ -782,8 +782,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
> >  				has_head++;
> >  		}
> >  		if (!has_head) {
> > -			int pfxlen = strlen("refs/heads/");
> > -			append_one_rev(head + pfxlen);
> > +			append_one_rev(head);
> 
> This changes the output for normal case.
It does?  How?
I cite my commit message:
> [...] So append_one_rev() operates
> on "refs/heads/foo" instead of "foo", which still works.
> But now it also operates correctly on "HEAD".
And I still think it's true.
I diff'ed the outputs of
	git-show-branch --current
AND (just to go sure)
	git-show-branch
on git.next
before and after the patch:
	No difference.
> +			int offset = !prefixcmp(head, "refs/heads/") ? 11 : 0;

Your version is the intuitive change and, of course, right, but I don't see why we should do the prefixcmp() when it does not change the resulting behavior in any way.

Regards,
  Stephan
-- 
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F
Previous: Junio C Hamano
Message 4 of 4 in “Fix git-show-branch --current when not on a branch”
  1. Fix git-show-branch --current when not on a branchStephan Beyer, May 23, 2008
  2. Stephan BeyerMay 26, 2008
  3. Junio C HamanoMay 26, 2008
  4. Stephan BeyerMay 27, 2008

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.