diff.c: return filepair from diff_unmerge()
[git/mjg.git] / t / t7610-mergetool.sh
blob3bd74042ef46ee8b4e4477d1c23ba0914963de33
1 #!/bin/sh
3 # Copyright (c) 2008 Charles Bailey
6 test_description='git mergetool
8 Testing basic merge tool invocation'
10 . ./test-lib.sh
12 # All the mergetool test work by checking out a temporary branch based
13 # off 'branch1' and then merging in master and checking the results of
14 # running mergetool
16 test_expect_success 'setup' '
17 git config rerere.enabled true &&
18 echo master >file1 &&
19 mkdir subdir &&
20 echo master sub >subdir/file3 &&
21 git add file1 subdir/file3 &&
22 git commit -m "added file1" &&
24 git checkout -b branch1 master &&
25 echo branch1 change >file1 &&
26 echo branch1 newfile >file2 &&
27 echo branch1 sub >subdir/file3 &&
28 git add file1 file2 subdir/file3 &&
29 git commit -m "branch1 changes" &&
31 git checkout master &&
32 echo master updated >file1 &&
33 echo master new >file2 &&
34 echo master new sub >subdir/file3 &&
35 git add file1 file2 subdir/file3 &&
36 git commit -m "master updates" &&
38 git config merge.tool mytool &&
39 git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
40 git config mergetool.mytool.trustExitCode true
43 test_expect_success 'custom mergetool' '
44 git checkout -b test1 branch1 &&
45 test_must_fail git merge master >/dev/null 2>&1 &&
46 ( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
47 ( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
48 ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
49 test "$(cat file1)" = "master updated" &&
50 test "$(cat file2)" = "master new" &&
51 test "$(cat subdir/file3)" = "master new sub" &&
52 git commit -m "branch1 resolved with mergetool"
55 test_expect_success 'mergetool crlf' '
56 git config core.autocrlf true &&
57 git checkout -b test2 branch1
58 test_must_fail git merge master >/dev/null 2>&1 &&
59 ( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
60 ( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
61 ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
62 test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
63 test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
64 test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" &&
65 git commit -m "branch1 resolved with mergetool - autocrlf" &&
66 git config core.autocrlf false &&
67 git reset --hard
70 test_expect_success 'mergetool in subdir' '
71 git checkout -b test3 branch1 &&
73 cd subdir &&
74 test_must_fail git merge master >/dev/null 2>&1 &&
75 ( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
76 test "$(cat file3)" = "master new sub"
80 test_expect_success 'mergetool on file in parent dir' '
82 cd subdir &&
83 ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
84 ( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) &&
85 test "$(cat ../file1)" = "master updated" &&
86 test "$(cat ../file2)" = "master new" &&
87 git commit -m "branch1 resolved with mergetool - subdir"
91 test_expect_success 'mergetool skips autoresolved' '
92 git checkout -b test4 branch1 &&
93 test_must_fail git merge master &&
94 test -n "$(git ls-files -u)" &&
95 output="$(git mergetool --no-prompt)" &&
96 test "$output" = "No files need merging" &&
97 git reset --hard
100 test_expect_success 'mergetool merges all from subdir' '
102 cd subdir &&
103 git config rerere.enabled false &&
104 test_must_fail git merge master &&
105 git mergetool --no-prompt &&
106 test "$(cat ../file1)" = "master updated" &&
107 test "$(cat ../file2)" = "master new" &&
108 test "$(cat file3)" = "master new sub" &&
109 git add ../file1 ../file2 file3 &&
110 git commit -m "branch2 resolved by mergetool from subdir"
114 test_done