14
# running mergetool
15
16
test_expect_success 'setup' '
17
+ git config rerere.enabled true &&
18
echo master >file1 &&
19
mkdir subdir &&
20
echo master sub >subdir/file3 &&
72
cd subdir && (
73
test_must_fail git merge master >/dev/null 2>&1 &&
74
( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
74
- test "$(cat file3)" = "master new sub" )
75
+ test "$(cat file3)" = "master new sub") &&
76
+ cd ..
77
'
78
77
-# We can't merge files from parent directories when running mergetool
78
-# from a subdir. Is this a bug?
79
-#
80
-#test_expect_failure 'mergetool in subdir' '
81
-# cd subdir && (
82
-# ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
83
-# ( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) &&
84
-# test "$(cat ../file1)" = "master updated" &&
85
-# test "$(cat ../file2)" = "master new" &&
86
-# git commit -m "branch1 resolved with mergetool - subdir" )
87
-#'
79
+test_expect_success 'mergetool on file in parent dir' '
80
+ cd subdir && (
81
+ ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
82
+ ( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) &&
83
+ test "$(cat ../file1)" = "master updated" &&
84
+ test "$(cat ../file2)" = "master new" &&
85
+ git commit -m "branch1 resolved with mergetool - subdir") &&
86
+ cd ..
87
+'
88
+
89
+test_expect_success 'mergetool skips autoresolved' '
90
+ git checkout -b test4 branch1 &&
91
+ test_must_fail git merge master &&
92
+ test -n "$(git ls-files -u)" &&
93
+ output="$(git mergetool --no-prompt)" &&
94
+ test "$output" = "No files need merging" &&
95
+ git reset --hard
96
+'
97
+
98
+test_expect_success 'mergetool merges all from subdir' '
99
+ cd subdir && (
100
+ git config rerere.enabled false &&
101
+ test_must_fail git merge master &&
102
+ git mergetool --no-prompt &&
103
+ test "$(cat ../file1)" = "master updated" &&
104
+ test "$(cat ../file2)" = "master new" &&
105
+ test "$(cat file3)" = "master new sub" &&
106
+ git add ../file1 ../file2 file3 &&
107
+ git commit -m "branch2 resolved by mergetool from subdir") &&
108
+ cd ..
109
+'
110
111
test_done