]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7610-mergetool.sh
test-lib: Remove 3 year old no-op --no-python option
[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
b9b5078e
CB
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
05e934bb
CB
16test_expect_success 'setup' '
17 echo master >file1 &&
b9b5078e
CB
18 mkdir subdir &&
19 echo master sub >subdir/file3 &&
20 git add file1 subdir/file3 &&
05e934bb 21 git commit -m "added file1" &&
b9b5078e 22
05e934bb
CB
23 git checkout -b branch1 master &&
24 echo branch1 change >file1 &&
25 echo branch1 newfile >file2 &&
b9b5078e
CB
26 echo branch1 sub >subdir/file3 &&
27 git add file1 file2 subdir/file3 &&
05e934bb 28 git commit -m "branch1 changes" &&
b9b5078e 29
05e934bb
CB
30 git checkout master &&
31 echo master updated >file1 &&
32 echo master new >file2 &&
b9b5078e
CB
33 echo master new sub >subdir/file3 &&
34 git add file1 file2 subdir/file3 &&
35 git commit -m "master updates" &&
05e934bb 36
05e934bb
CB
37 git config merge.tool mytool &&
38 git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
b9b5078e
CB
39 git config mergetool.mytool.trustExitCode true
40'
41
42test_expect_success 'custom mergetool' '
43 git checkout -b test1 branch1 &&
d492b31c 44 test_must_fail git merge master >/dev/null 2>&1 &&
b9b5078e
CB
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 ) &&
05e934bb
CB
48 test "$(cat file1)" = "master updated" &&
49 test "$(cat file2)" = "master new" &&
b9b5078e 50 test "$(cat subdir/file3)" = "master new sub" &&
0ec7b6c2
CB
51 git commit -m "branch1 resolved with mergetool"
52'
53
54test_expect_success 'mergetool crlf' '
55 git config core.autocrlf true &&
b9b5078e 56 git checkout -b test2 branch1
0ec7b6c2 57 test_must_fail git merge master >/dev/null 2>&1 &&
b9b5078e
CB
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 ) &&
0ec7b6c2
CB
61 test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
62 test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
b9b5078e
CB
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
ff4a1855 69test_expect_success 'mergetool in subdir' '
b9b5078e
CB
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" )
05e934bb
CB
75'
76
b9b5078e
CB
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
05e934bb 89test_done