From: Junio C Hamano Date: Fri, 16 Oct 2015 21:32:44 +0000 (-0700) Subject: Merge branch 'mm/detach-at-HEAD-reflog' into maint X-Git-Tag: v2.6.2~12 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/df64186f63fef8daef0fb4aedfa76aaf22b70b75?hp=19d11d43fddd7535c93a616984c3815d5a444f99 Merge branch 'mm/detach-at-HEAD-reflog' into maint After "git checkout --detach", "git status" reported a fairly useless "HEAD detached at HEAD", instead of saying at which exact commit. * mm/detach-at-HEAD-reflog: status: don't say 'HEAD detached at HEAD' t3203: test 'detached at' after checkout --detach --- diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh index f51d0f3cad..16efe7af03 100755 --- a/t/t3203-branch-output.sh +++ b/t/t3203-branch-output.sh @@ -106,6 +106,19 @@ EOF test_i18ncmp expect actual ' +test_expect_success 'git branch shows detached HEAD properly after checkout --detach' ' + git checkout master && + cat >expect <actual && + test_i18ncmp expect actual +' + test_expect_success 'git branch shows detached HEAD properly after moving' ' cat >expect <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; }