2008-07-30 07:17:00 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-08-16 09:08:46 +08:00
|
|
|
test_description="git merge
|
2008-07-30 07:17:00 +08:00
|
|
|
|
2010-08-16 09:08:46 +08:00
|
|
|
Testing a custom strategy.
|
|
|
|
|
2010-08-16 09:11:06 +08:00
|
|
|
* (HEAD, master) Merge commit 'c3'
|
2010-08-16 09:08:46 +08:00
|
|
|
|\
|
2010-08-16 09:11:06 +08:00
|
|
|
| * (tag: c3) c3
|
2010-08-16 09:08:46 +08:00
|
|
|
* | (tag: c1) c1
|
|
|
|
|/
|
2010-08-16 09:11:06 +08:00
|
|
|
| * tag: c2) c2
|
|
|
|
|/
|
2010-08-16 09:08:46 +08:00
|
|
|
* (tag: c0) c0
|
|
|
|
"
|
2008-07-30 07:17:00 +08:00
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2010-08-16 09:08:46 +08:00
|
|
|
test_expect_success 'set up custom strategy' '
|
|
|
|
cat >git-merge-theirs <<-EOF &&
|
|
|
|
#!$SHELL_PATH
|
|
|
|
eval git read-tree --reset -u \\\$\$#
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x git-merge-theirs &&
|
|
|
|
PATH=.:$PATH &&
|
|
|
|
export PATH
|
|
|
|
'
|
2008-07-30 07:17:00 +08:00
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
2010-08-16 09:08:46 +08:00
|
|
|
test_commit c0 c0.c &&
|
|
|
|
test_commit c1 c1.c &&
|
|
|
|
git reset --keep c0 &&
|
2008-08-24 10:23:22 +08:00
|
|
|
echo c1c1 >c1.c &&
|
2010-08-16 09:08:46 +08:00
|
|
|
git add c1.c &&
|
2010-08-16 09:11:06 +08:00
|
|
|
test_commit c2 c2.c &&
|
|
|
|
git reset --keep c0 &&
|
|
|
|
test_commit c3 c3.c
|
2008-07-30 07:17:00 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'merge c2 with a custom strategy' '
|
|
|
|
git reset --hard c1 &&
|
2010-08-16 09:08:46 +08:00
|
|
|
|
|
|
|
git rev-parse c1 >head.old &&
|
|
|
|
git rev-parse c2 >second-parent.expected &&
|
|
|
|
git rev-parse c2^{tree} >tree.expected &&
|
2008-07-30 07:17:00 +08:00
|
|
|
git merge -s theirs c2 &&
|
2010-08-16 09:08:46 +08:00
|
|
|
|
2010-08-24 04:15:47 +08:00
|
|
|
git rev-parse HEAD >head.new &&
|
2010-08-16 09:08:46 +08:00
|
|
|
git rev-parse HEAD^1 >first-parent &&
|
|
|
|
git rev-parse HEAD^2 >second-parent &&
|
|
|
|
git rev-parse HEAD^{tree} >tree &&
|
|
|
|
git update-index --refresh &&
|
2008-07-30 07:17:00 +08:00
|
|
|
git diff --exit-code &&
|
2008-08-24 10:23:22 +08:00
|
|
|
git diff --exit-code c2 HEAD &&
|
|
|
|
git diff --exit-code c2 &&
|
2010-08-16 09:08:46 +08:00
|
|
|
|
2010-08-24 04:15:47 +08:00
|
|
|
! test_cmp head.old head.new &&
|
2010-08-16 09:08:46 +08:00
|
|
|
test_cmp head.old first-parent &&
|
|
|
|
test_cmp second-parent.expected second-parent &&
|
|
|
|
test_cmp tree.expected tree &&
|
2008-07-30 07:17:00 +08:00
|
|
|
test -f c0.c &&
|
2008-08-24 10:23:22 +08:00
|
|
|
grep c1c1 c1.c &&
|
2008-07-30 07:17:00 +08:00
|
|
|
test -f c2.c
|
|
|
|
'
|
|
|
|
|
2010-08-16 09:11:06 +08:00
|
|
|
test_expect_success 'trivial merge with custom strategy' '
|
|
|
|
git reset --hard c1 &&
|
|
|
|
|
|
|
|
git rev-parse c1 >head.old &&
|
|
|
|
git rev-parse c3 >second-parent.expected &&
|
|
|
|
git rev-parse c3^{tree} >tree.expected &&
|
|
|
|
git merge -s theirs c3 &&
|
|
|
|
|
2010-08-24 04:15:47 +08:00
|
|
|
git rev-parse HEAD >head.new &&
|
2010-08-16 09:11:06 +08:00
|
|
|
git rev-parse HEAD^1 >first-parent &&
|
|
|
|
git rev-parse HEAD^2 >second-parent &&
|
|
|
|
git rev-parse HEAD^{tree} >tree &&
|
|
|
|
git update-index --refresh &&
|
|
|
|
git diff --exit-code &&
|
|
|
|
git diff --exit-code c3 HEAD &&
|
|
|
|
git diff --exit-code c3 &&
|
|
|
|
|
2010-08-24 04:15:47 +08:00
|
|
|
! test_cmp head.old head.new &&
|
2010-08-16 09:11:06 +08:00
|
|
|
test_cmp head.old first-parent &&
|
|
|
|
test_cmp second-parent.expected second-parent &&
|
|
|
|
test_cmp tree.expected tree &&
|
|
|
|
test -f c0.c &&
|
|
|
|
! test -e c1.c &&
|
|
|
|
test -f c3.c
|
|
|
|
'
|
|
|
|
|
2008-07-30 07:17:00 +08:00
|
|
|
test_done
|