summaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2015-09-27 15:13:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-10-02 18:29:46 (GMT)
commit0eb8548f45cc51bff9b70f551f4c472af353a814 (patch)
tree81f190e382217a4f05aa16d0230c4e886ec50f21 /wt-status.c
parent9cb07d81b3b268dc5f88f7048f54ce51d363d2d5 (diff)
downloadgit-0eb8548f45cc51bff9b70f551f4c472af353a814.zip
git-0eb8548f45cc51bff9b70f551f4c472af353a814.tar.gz
git-0eb8548f45cc51bff9b70f551f4c472af353a814.tar.bz2
status: don't say 'HEAD detached at HEAD'
After using "git checkout --detach", the reflog is left with an entry like checkout: moving from ... to HEAD This message is parsed to generate the 'HEAD detached at' message in 'git branch' and 'git status', which leads to the not-so-useful message 'HEAD detached at HEAD'. Instead, when parsing such reflog entry, resolve HEAD to the corresponding commit in the reflog, so that the message becomes 'HEAD detached at $sha1'. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/wt-status.c b/wt-status.c
index 078a472..fd9d98b 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;
}