mergetool: respect autocrlf by using checkout-index
[git/mingw.git] / t / t7610-mergetool.sh
blobedb6a57b7beb13c6e853fd40aa51a052937ca51a
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 test_expect_success 'setup' '
13 echo master >file1 &&
14 git add file1 &&
15 git commit -m "added file1" &&
16 git checkout -b branch1 master &&
17 echo branch1 change >file1 &&
18 echo branch1 newfile >file2 &&
19 git add file1 file2 &&
20 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" &&
26 git checkout master &&
27 echo master updated >file1 &&
28 echo master new >file2 &&
29 git add file1 file2 &&
30 git commit -m "master updates"
33 test_expect_success 'custom mergetool' '
34 git config merge.tool mytool &&
35 git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
36 git config mergetool.mytool.trustExitCode true &&
37 git checkout branch1 &&
38 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 ) &&
41 test "$(cat file1)" = "master updated" &&
42 test "$(cat file2)" = "master new" &&
43 git commit -m "branch1 resolved with mergetool"
46 test_expect_success 'mergetool crlf' '
47 git config core.autocrlf true &&
48 git reset --hard HEAD^
49 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 ) &&
52 test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
53 test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
54 git commit -m "branch1 resolved with mergetool - autocrlf"
57 test_done