merge: do not mistake (ancestor of) tag for branch
If no branch 'foo' exists but a tag 'foo' does, then git merge foo^ results in Merge branch 'foo' (early part) as a commit message, because the relevant code path checks that refs/heads/foo is a valid refname for writing rather than for reading. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
64fdc08dac
commit
b81f925f70
@ -437,7 +437,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
|
|||||||
strbuf_addstr(&truname, "refs/heads/");
|
strbuf_addstr(&truname, "refs/heads/");
|
||||||
strbuf_addstr(&truname, remote);
|
strbuf_addstr(&truname, remote);
|
||||||
strbuf_setlen(&truname, truname.len - len);
|
strbuf_setlen(&truname, truname.len - len);
|
||||||
if (resolve_ref(truname.buf, buf_sha, 0, NULL)) {
|
if (resolve_ref(truname.buf, buf_sha, 1, NULL)) {
|
||||||
strbuf_addf(msg,
|
strbuf_addf(msg,
|
||||||
"%s\t\tbranch '%s'%s of .\n",
|
"%s\t\tbranch '%s'%s of .\n",
|
||||||
sha1_to_hex(remote_head->sha1),
|
sha1_to_hex(remote_head->sha1),
|
||||||
|
@ -558,8 +558,11 @@ test_expect_success 'refresh the index before merging' '
|
|||||||
git merge c3
|
git merge c3
|
||||||
'
|
'
|
||||||
|
|
||||||
cat >expected <<EOF
|
cat >expected.branch <<\EOF
|
||||||
Merge branch 'c5' (early part)
|
Merge branch 'c5-branch' (early part)
|
||||||
|
EOF
|
||||||
|
cat >expected.tag <<\EOF
|
||||||
|
Merge commit 'c5~1'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success 'merge early part of c2' '
|
test_expect_success 'merge early part of c2' '
|
||||||
@ -577,9 +580,14 @@ test_expect_success 'merge early part of c2' '
|
|||||||
git add c6.c &&
|
git add c6.c &&
|
||||||
git commit -m c6 &&
|
git commit -m c6 &&
|
||||||
git tag c6 &&
|
git tag c6 &&
|
||||||
|
git branch -f c5-branch c5 &&
|
||||||
|
git merge c5-branch~1 &&
|
||||||
|
git show -s --pretty=format:%s HEAD >actual.branch &&
|
||||||
|
git reset --keep HEAD^ &&
|
||||||
git merge c5~1 &&
|
git merge c5~1 &&
|
||||||
git show -s --pretty=format:%s HEAD > actual &&
|
git show -s --pretty=format:%s HEAD >actual.tag &&
|
||||||
test_cmp actual expected
|
test_cmp expected.branch actual.branch &&
|
||||||
|
test_cmp expected.tag actual.tag
|
||||||
'
|
'
|
||||||
|
|
||||||
test_debug 'gitk --all'
|
test_debug 'gitk --all'
|
||||||
|
Loading…
Reference in New Issue
Block a user