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