Merge branch 'mm/detach-at-HEAD-reflog'
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
This commit is contained in:
commit
a394b39726
@ -106,6 +106,19 @@ EOF
|
|||||||
test_i18ncmp expect actual
|
test_i18ncmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
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))
|
||||||
|
branch-one
|
||||||
|
branch-two
|
||||||
|
master
|
||||||
|
EOF
|
||||||
|
git checkout --detach &&
|
||||||
|
git branch >actual &&
|
||||||
|
test_i18ncmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'git branch shows detached HEAD properly after moving' '
|
test_expect_success 'git branch shows detached HEAD properly after moving' '
|
||||||
cat >expect <<EOF &&
|
cat >expect <<EOF &&
|
||||||
* (HEAD detached from $(git rev-parse --short HEAD))
|
* (HEAD detached from $(git rev-parse --short HEAD))
|
||||||
|
@ -1319,6 +1319,12 @@ static int grab_1st_switch(unsigned char *osha1, unsigned char *nsha1,
|
|||||||
hashcpy(cb->nsha1, nsha1);
|
hashcpy(cb->nsha1, nsha1);
|
||||||
for (end = target; *end && *end != '\n'; end++)
|
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);
|
strbuf_add(&cb->buf, target, end - target);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user