t7606 (merge-theirs): modernize style
Guard setup commands with test_expect_success, so they are easier to visually skip over and get to the good part. While at it: - use test_commit for brevity and reproducible object names; - use test_cmp instead of using the test builtin to compare the result of command substitution, for better output with -v on failure. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Nieder committed
Aug 15, 2010 at 20:08 UTC
6209036c7843f4095c04b5ecc13199cc4eccaf3f
1 file changed
+40
-26
t/t7606-merge-custom.sh
+40
-26
@@ -1,46 +1,60 @@
1
#!/bin/sh
2
3
-test_description='git merge
3
+test_description="git merge
4
5
-Testing a custom strategy.'
5
+Testing a custom strategy.
6
+
7
+* (HEAD, master) Merge commit 'c2'
8
+|\
9
+| * (tag: c2) c2
10
+* | (tag: c1) c1
11
+|/
12
+* (tag: c0) c0
13
+"
14
15
. ./test-lib.sh
16
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
17
+test_expect_success 'set up custom strategy' '
18
+ cat >git-merge-theirs <<-EOF &&
19
+ #!$SHELL_PATH
20
+ eval git read-tree --reset -u \\\$\$#
21
+ EOF
22
+
23
+ chmod +x git-merge-theirs &&
24
+ PATH=.:$PATH &&
25
+ export PATH
26
+'
27
28
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 &&
29
+ test_commit c0 c0.c &&
30
+ test_commit c1 c1.c &&
31
+ git reset --keep c0 &&
32
echo c1c1 >c1.c &&
28
- echo c2 >c2.c &&
29
- git add c1.c c2.c &&
30
- git commit -m c2 &&
31
- git tag c2
33
+ git add c1.c &&
34
+ test_commit c2 c2.c
35
'
36
37
test_expect_success 'merge c2 with a custom strategy' '
38
git reset --hard c1 &&
39
+
40
+ git rev-parse c1 >head.old &&
41
+ git rev-parse c2 >second-parent.expected &&
42
+ git rev-parse c2^{tree} >tree.expected &&
43
git merge -s theirs c2 &&
37
- test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
38
- test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
39
- test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
40
- test "$(git rev-parse c2^{tree})" = "$(git rev-parse HEAD^{tree})" &&
44
+
45
+ git rev-parse HEAD >head &&
46
+ git rev-parse HEAD^1 >first-parent &&
47
+ git rev-parse HEAD^2 >second-parent &&
48
+ git rev-parse HEAD^{tree} >tree &&
49
+ git update-index --refresh &&
50
git diff --exit-code &&
51
git diff --exit-code c2 HEAD &&
52
git diff --exit-code c2 &&
53
+
54
+ ! test_cmp head.old head &&
55
+ test_cmp head.old first-parent &&
56
+ test_cmp second-parent.expected second-parent &&
57
+ test_cmp tree.expected tree &&
58
test -f c0.c &&
59
grep c1c1 c1.c &&
60
test -f c2.c