2009-08-09 18:01:48 +08:00
|
|
|
#!/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 &&
|
2020-06-24 06:33:23 +08:00
|
|
|
check_oneline "Merge branch Qlocal-branchQ into master"
|
2009-08-09 18:01:48 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
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 &&
|
2020-06-24 06:33:23 +08:00
|
|
|
check_oneline "Merge branches Qoctopus-aQ and Qoctopus-bQ into master"
|
2009-08-09 18:01:48 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
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 &&
|
2020-06-24 06:33:23 +08:00
|
|
|
check_oneline "Merge tag Qtag-1Q into master"
|
2009-08-09 18:01:48 +08:00
|
|
|
'
|
|
|
|
|
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 18:02:24 +08:00
|
|
|
test_expect_success 'ambiguous tag' '
|
2009-08-09 18:01:48 +08:00
|
|
|
git checkout -b ambiguous master &&
|
|
|
|
test_commit ambiguous &&
|
|
|
|
git checkout master &&
|
|
|
|
test_commit master-4 &&
|
|
|
|
git merge ambiguous &&
|
2020-06-24 06:33:23 +08:00
|
|
|
check_oneline "Merge tag QambiguousQ into master"
|
2009-08-09 18:01:48 +08:00
|
|
|
'
|
|
|
|
|
2010-11-02 23:31:25 +08:00
|
|
|
test_expect_success 'remote-tracking branch' '
|
2009-08-09 18:02:51 +08:00
|
|
|
git checkout -b remote master &&
|
|
|
|
test_commit remote-1 &&
|
|
|
|
git update-ref refs/remotes/origin/master remote &&
|
|
|
|
git checkout master &&
|
|
|
|
test_commit master-5 &&
|
|
|
|
git merge origin/master &&
|
2020-06-24 06:33:23 +08:00
|
|
|
check_oneline "Merge remote-tracking branch Qorigin/masterQ into master"
|
2009-08-09 18:02:51 +08:00
|
|
|
'
|
|
|
|
|
2009-08-09 18:01:48 +08:00
|
|
|
test_done
|