init-db, rev-parse --git-dir: do not append redundant slash
[git/dkf.git] / t / t7610-mergetool.sh
blobe768c3eb2d48a9af2fc92729a6c20126f67ec866
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 echo master >file1 &&
18 mkdir subdir &&
19 echo master sub >subdir/file3 &&
20 git add file1 subdir/file3 &&
21 git commit -m "added file1" &&
23 git checkout -b branch1 master &&
24 echo branch1 change >file1 &&
25 echo branch1 newfile >file2 &&
26 echo branch1 sub >subdir/file3 &&
27 git add file1 file2 subdir/file3 &&
28 git commit -m "branch1 changes" &&
30 git checkout master &&
31 echo master updated >file1 &&
32 echo master new >file2 &&
33 echo master new sub >subdir/file3 &&
34 git add file1 file2 subdir/file3 &&
35 git commit -m "master updates" &&
37 git config merge.tool mytool &&
38 git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
39 git config mergetool.mytool.trustExitCode true
42 test_expect_success 'custom mergetool' '
43 git checkout -b test1 branch1 &&
44 test_must_fail git merge master >/dev/null 2>&1 &&
45 ( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
46 ( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
47 ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
48 test "$(cat file1)" = "master updated" &&
49 test "$(cat file2)" = "master new" &&
50 test "$(cat subdir/file3)" = "master new sub" &&
51 git commit -m "branch1 resolved with mergetool"
54 test_expect_success 'mergetool crlf' '
55 git config core.autocrlf true &&
56 git checkout -b test2 branch1
57 test_must_fail git merge master >/dev/null 2>&1 &&
58 ( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
59 ( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
60 ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
61 test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
62 test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
63 test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" &&
64 git commit -m "branch1 resolved with mergetool - autocrlf" &&
65 git config core.autocrlf false &&
66 git reset --hard
69 test_expect_success 'mergetool in subdir' '
70 git checkout -b test3 branch1
71 cd subdir && (
72 test_must_fail git merge master >/dev/null 2>&1 &&
73 ( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
74 test "$(cat file3)" = "master new sub" )
77 # We can't merge files from parent directories when running mergetool
78 # from a subdir. Is this a bug?
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" )
89 test_done