summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xt/t3203-branch-output.sh2
-rw-r--r--wt-status.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
index bf24dbf831..16efe7af03 100755
--- a/t/t3203-branch-output.sh
+++ b/t/t3203-branch-output.sh
@@ -106,7 +106,7 @@ EOF
test_i18ncmp expect actual
'
-test_expect_failure 'git branch shows detached HEAD properly after checkout --detach' '
+test_expect_success 'git branch shows detached HEAD properly after checkout --detach' '
git checkout master &&
cat >expect <<EOF &&
* (HEAD detached at $(git rev-parse --short HEAD^0))
diff --git a/wt-status.c b/wt-status.c
index 078a472743..fd9d98b399 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1204,6 +1204,12 @@ static int grab_1st_switch(unsigned char *osha1, unsigned char *nsha1,
hashcpy(cb->nsha1, nsha1);
for (end = target; *end && *end != '\n'; end++)
;
+ if (!memcmp(target, "HEAD", end - target)) {
+ /* HEAD is relative. Resolve it to the right reflog entry. */
+ strbuf_addstr(&cb->buf,
+ find_unique_abbrev(nsha1, DEFAULT_ABBREV));
+ return 1;
+ }
strbuf_add(&cb->buf, target, end - target);
return 1;
}