1. Stefan Saasen
  2. git

Commits

Junio C Hamano  committed f8fcb57

show-branch --current: do not barf on detached HEAD

The code assumed that there always is the current branch, but the result
from resolve_ref() on detached HEAD does not even start with "refs/heads/".

Originally noticed and fixed by Stephan Beyer.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

  • Participants
  • Parent commits a2f5be5
  • Branches master

Comments (0)

Files changed (1)

File builtin-show-branch.c

View file
 				has_head++;
 		}
 		if (!has_head) {
-			int pfxlen = strlen("refs/heads/");
-			append_one_rev(head + pfxlen);
+			int offset = !prefixcmp(head, "refs/heads/") ? 11 : 0;
+			append_one_rev(head + offset);
 		}
 	}