@matheusbsbs / matheus-bagliano / commits / b9b5078ece
Fork 0

mergetool: Add a test for running mergetool in a sub-directory

Signed-off-by: Charles Bailey <charles@hashpling.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Charles Bailey committed Jan 30, 2009 at 23:20 UTC b9b5078ece4b22c14a36f20bd9dce88d2f350a36
1 file changed +51 -19
t/t7610-mergetool.sh
+51 -19
@@ -9,49 +9,81 @@ Testing basic merge tool invocation'
9
10 . ./test-lib.sh
11
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
15 +
16 test_expect_success 'setup' '
17 echo master >file1 &&
14 - git add file1 &&
18 + mkdir subdir &&
19 + echo master sub >subdir/file3 &&
20 + git add file1 subdir/file3 &&
21 git commit -m "added file1" &&
22 +
23 git checkout -b branch1 master &&
24 echo branch1 change >file1 &&
25 echo branch1 newfile >file2 &&
19 - git add file1 file2 &&
26 + echo branch1 sub >subdir/file3 &&
27 + git add file1 file2 subdir/file3 &&
28 git commit -m "branch1 changes" &&
21 - git checkout -b branch2 master &&
22 - echo branch2 change >file1 &&
23 - echo branch2 newfile >file2 &&
24 - git add file1 file2 &&
25 - git commit -m "branch2 changes" &&
29 +
30 git checkout master &&
31 echo master updated >file1 &&
32 echo master new >file2 &&
29 - git add file1 file2 &&
30 - git commit -m "master updates"
31 -'
33 + echo master new sub >subdir/file3 &&
34 + git add file1 file2 subdir/file3 &&
35 + git commit -m "master updates" &&
36
33 -test_expect_success 'custom mergetool' '
37 git config merge.tool mytool &&
38 git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
36 - git config mergetool.mytool.trustExitCode true &&
37 - git checkout branch1 &&
39 + git config mergetool.mytool.trustExitCode true
40 +'
41 +
42 +test_expect_success 'custom mergetool' '
43 + git checkout -b test1 branch1 &&
44 test_must_fail git merge master >/dev/null 2>&1 &&
39 - ( yes "" | git mergetool file1>/dev/null 2>&1 ) &&
40 - ( yes "" | git mergetool file2>/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"
52 '
53
54 test_expect_success 'mergetool crlf' '
55 git config core.autocrlf true &&
48 - git reset --hard HEAD^
56 + git checkout -b test2 branch1
57 test_must_fail git merge master >/dev/null 2>&1 &&
50 - ( yes "" | git mergetool file1>/dev/null 2>&1 ) &&
51 - ( yes "" | git mergetool file2>/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")" &&
54 - git commit -m "branch1 resolved with mergetool - autocrlf"
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
67 +'
68 +
69 +test_expect_failure '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" )
75 '
76
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 +#'
88 +
89 test_done