show-branch: mark active branch with a '*' again
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Thu, 21 Sep 2006 22:07:01 +0000 (00:07 +0200)
committerJunio C Hamano <junkio@cox.net>
Fri, 22 Sep 2006 03:54:43 +0000 (20:54 -0700)
This was lost in the packed-ref updates. The original test was a bit
dubious, so I cleaned that up, too. It fixes the case when the current HEAD
is refs/heads/bla/master: the original test was true for both bla/master
_and_ master.

However, it shares a hard-to-fix bug with the original test: if the current
HEAD is refs/heads/master, and there is a branch refs/heads/heads/master,
then both are marked active.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-show-branch.c

index 5d6ce568360629f3844513b81f97e4412002b88b..fb1a4000d98e27389904578309b935cbda2a85fe 100644 (file)
@@ -443,6 +443,12 @@ static int rev_is_head(char *head, int headlen, char *name,
        if ((!head[0]) ||
            (head_sha1 && sha1 && hashcmp(head_sha1, sha1)))
                return 0;
+       if (!strncmp(head, "refs/heads/", 11))
+               head += 11;
+       if (!strncmp(name, "refs/heads/", 11))
+               name += 11;
+       else if (!strncmp(name, "heads/", 6))
+               name += 6;
        return !strcmp(head, name);
 }