@matheusbsbs / matheus-bagliano / commits / 1b1d78fe77
Fork 0

Add a new test for using a custom merge strategy

Testing is done by creating a simple git-merge-theirs strategy which is the opposite of ours. Using this in real merges is not recommended but it's perfect for our testing needs. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Miklos Vajna committed Jul 30, 2008 at 01:17 UTC 1b1d78fe77d676bb79a9272ff6f3517697811990
1 file changed +46
t/t7606-merge-custom.sh new
+46
@@ -0,0 +1,46 @@
1 +#!/bin/sh
2 +
3 +test_description='git-merge
4 +
5 +Testing a custom strategy.'
6 +
7 +. ./test-lib.sh
8 +
9 +cat >git-merge-theirs <<EOF
10 +#!$SHELL_PATH
11 +eval git read-tree --reset -u \\\$\$#
12 +EOF
13 +chmod +x git-merge-theirs
14 +PATH=.:$PATH
15 +export PATH
16 +
17 +test_expect_success 'setup' '
18 + echo c0 >c0.c &&
19 + git add c0.c &&
20 + git commit -m c0 &&
21 + git tag c0 &&
22 + echo c1 >c1.c &&
23 + git add c1.c &&
24 + git commit -m c1 &&
25 + git tag c1 &&
26 + git reset --hard c0 &&
27 + echo c2 >c2.c &&
28 + git add c2.c &&
29 + git commit -m c2 &&
30 + git tag c2
31 +'
32 +
33 +test_expect_success 'merge c2 with a custom strategy' '
34 + git reset --hard c1 &&
35 + git merge -s theirs c2 &&
36 + test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
37 + test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
38 + test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
39 + test "$(git rev-parse c2^{tree})" = "$(git rev-parse HEAD^{tree})" &&
40 + git diff --exit-code &&
41 + test -f c0.c &&
42 + test ! -f c1.c &&
43 + test -f c2.c
44 +'
45 +
46 +test_done