[PATCH 2/3] git-show-branch: sha1 based branch head determination
Any ref that points to the same object as the one that is
currently pointed at by HEAD, is recognized as head, which is
then marked with a '*' in the corresponding column.
---
builtin-show-branch.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index df83491..96ae3cb 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -460,9 +460,16 @@ static void snarf_refs(int head, int remotes)
static int rev_is_head(char *head, int headlen, char *name,
unsigned char *head_sha1, unsigned char *sha1)
{
- if ((!head[0]) ||
- (head_sha1 && sha1 && hashcmp(head_sha1, sha1)))
+ if (!head[0])
return 0;
+ if (head_sha1 && sha1) {
+ if (hashcmp(head_sha1, sha1)) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+
if (!prefixcmp(head, "refs/heads/"))
head += 11;
if (!prefixcmp(name, "refs/heads/"))
--
1.6.1