git/t/t7608-merge-messages.sh
Jeff King 751c59746c merge: fix incorrect merge message for ambiguous tag/branch
If we have both a tag and a branch named "foo", then calling
"git merge foo" will warn about the ambiguous ref, but merge
the tag.

When generating the commit message, though, we simply
checked whether "refs/heads/foo" existed, and if it did,
assumed it was a branch. This led to the statement "Merge
branch 'foo'" in the commit message, which is quite wrong.

Instead, we should use dwim_ref to find the actual ref used,
and describe it appropriately.

In addition to the test in t7608, we must also tweak the
expected output of t4202, which was accidentally triggering
this bug.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-09 12:34:20 -07:00

50 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
test_description='test auto-generated merge messages'
. ./test-lib.sh
check_oneline() {
echo "$1" | sed "s/Q/'/g" >expect &&
git log -1 --pretty=tformat:%s >actual &&
test_cmp expect actual
}
test_expect_success 'merge local branch' '
test_commit master-1 &&
git checkout -b local-branch &&
test_commit branch-1 &&
git checkout master &&
test_commit master-2 &&
git merge local-branch &&
check_oneline "Merge branch Qlocal-branchQ"
'
test_expect_success 'merge octopus branches' '
git checkout -b octopus-a master &&
test_commit octopus-1 &&
git checkout -b octopus-b master &&
test_commit octopus-2 &&
git checkout master &&
git merge octopus-a octopus-b &&
check_oneline "Merge branches Qoctopus-aQ and Qoctopus-bQ"
'
test_expect_success 'merge tag' '
git checkout -b tag-branch master &&
test_commit tag-1 &&
git checkout master &&
test_commit master-3 &&
git merge tag-1 &&
check_oneline "Merge commit Qtag-1Q"
'
test_expect_success 'ambiguous tag' '
git checkout -b ambiguous master &&
test_commit ambiguous &&
git checkout master &&
test_commit master-4 &&
git merge ambiguous &&
check_oneline "Merge commit QambiguousQ"
'
test_done