]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7610-mergetool.sh
mergetool: respect autocrlf by using checkout-index
[thirdparty/git.git] / t / t7610-mergetool.sh
CommitLineData
05e934bb
CB
1#!/bin/sh
2#
3# Copyright (c) 2008 Charles Bailey
4#
5
47a528ad 6test_description='git mergetool
05e934bb
CB
7
8Testing basic merge tool invocation'
9
10. ./test-lib.sh
11
12test_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"
31'
32
33test_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 &&
0ec7b6c2 37 git checkout branch1 &&
d492b31c 38 test_must_fail git merge master >/dev/null 2>&1 &&
05e934bb
CB
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" &&
0ec7b6c2
CB
43 git commit -m "branch1 resolved with mergetool"
44'
45
46test_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"
05e934bb
CB
55'
56
57test_done