Merge branch 'jn/merge-custom-no-trivial'
* jn/merge-custom-no-trivial: t7606: Avoid using head as a file name merge: let custom strategies intervene in trivial merges t7606 (merge-theirs): modernize style
This commit is contained in:
commit
460645a8c3
@ -132,6 +132,7 @@ static struct strategy *get_strategy(const char *name)
|
|||||||
|
|
||||||
ret = xcalloc(1, sizeof(struct strategy));
|
ret = xcalloc(1, sizeof(struct strategy));
|
||||||
ret->name = xstrdup(name);
|
ret->name = xstrdup(name);
|
||||||
|
ret->attr = NO_TRIVIAL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,49 +1,93 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
test_description='git merge
|
test_description="git merge
|
||||||
|
|
||||||
Testing a custom strategy.'
|
Testing a custom strategy.
|
||||||
|
|
||||||
|
* (HEAD, master) Merge commit 'c3'
|
||||||
|
|\
|
||||||
|
| * (tag: c3) c3
|
||||||
|
* | (tag: c1) c1
|
||||||
|
|/
|
||||||
|
| * tag: c2) c2
|
||||||
|
|/
|
||||||
|
* (tag: c0) c0
|
||||||
|
"
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
cat >git-merge-theirs <<EOF
|
test_expect_success 'set up custom strategy' '
|
||||||
#!$SHELL_PATH
|
cat >git-merge-theirs <<-EOF &&
|
||||||
eval git read-tree --reset -u \\\$\$#
|
#!$SHELL_PATH
|
||||||
EOF
|
eval git read-tree --reset -u \\\$\$#
|
||||||
chmod +x git-merge-theirs
|
EOF
|
||||||
PATH=.:$PATH
|
|
||||||
export PATH
|
chmod +x git-merge-theirs &&
|
||||||
|
PATH=.:$PATH &&
|
||||||
|
export PATH
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'setup' '
|
test_expect_success 'setup' '
|
||||||
echo c0 >c0.c &&
|
test_commit c0 c0.c &&
|
||||||
git add c0.c &&
|
test_commit c1 c1.c &&
|
||||||
git commit -m c0 &&
|
git reset --keep c0 &&
|
||||||
git tag c0 &&
|
|
||||||
echo c1 >c1.c &&
|
|
||||||
git add c1.c &&
|
|
||||||
git commit -m c1 &&
|
|
||||||
git tag c1 &&
|
|
||||||
git reset --hard c0 &&
|
|
||||||
echo c1c1 >c1.c &&
|
echo c1c1 >c1.c &&
|
||||||
echo c2 >c2.c &&
|
git add c1.c &&
|
||||||
git add c1.c c2.c &&
|
test_commit c2 c2.c &&
|
||||||
git commit -m c2 &&
|
git reset --keep c0 &&
|
||||||
git tag c2
|
test_commit c3 c3.c
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'merge c2 with a custom strategy' '
|
test_expect_success 'merge c2 with a custom strategy' '
|
||||||
git reset --hard c1 &&
|
git reset --hard c1 &&
|
||||||
|
|
||||||
|
git rev-parse c1 >head.old &&
|
||||||
|
git rev-parse c2 >second-parent.expected &&
|
||||||
|
git rev-parse c2^{tree} >tree.expected &&
|
||||||
git merge -s theirs c2 &&
|
git merge -s theirs c2 &&
|
||||||
test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
|
|
||||||
test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
|
git rev-parse HEAD >head.new &&
|
||||||
test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
|
git rev-parse HEAD^1 >first-parent &&
|
||||||
test "$(git rev-parse c2^{tree})" = "$(git rev-parse HEAD^{tree})" &&
|
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 &&
|
||||||
git diff --exit-code c2 HEAD &&
|
git diff --exit-code c2 HEAD &&
|
||||||
git diff --exit-code c2 &&
|
git diff --exit-code c2 &&
|
||||||
|
|
||||||
|
! test_cmp head.old head.new &&
|
||||||
|
test_cmp head.old first-parent &&
|
||||||
|
test_cmp second-parent.expected second-parent &&
|
||||||
|
test_cmp tree.expected tree &&
|
||||||
test -f c0.c &&
|
test -f c0.c &&
|
||||||
grep c1c1 c1.c &&
|
grep c1c1 c1.c &&
|
||||||
test -f c2.c
|
test -f c2.c
|
||||||
'
|
'
|
||||||
|
|
||||||
|
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 &&
|
||||||
|
|
||||||
|
git rev-parse HEAD >head.new &&
|
||||||
|
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 &&
|
||||||
|
|
||||||
|
! test_cmp head.old head.new &&
|
||||||
|
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
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user