Charles Bailey | 05e934b | 2008-02-21 23:31:56 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2008 Charles Bailey |
| 4 | # |
| 5 | |
Nanako Shiraishi | 47a528a | 2008-09-03 17:59:33 +0900 | [diff] [blame] | 6 | test_description='git mergetool |
Charles Bailey | 05e934b | 2008-02-21 23:31:56 +0000 | [diff] [blame] | 7 | |
| 8 | Testing basic merge tool invocation' |
| 9 | |
| 10 | . ./test-lib.sh |
| 11 | |
Charles Bailey | b9b5078 | 2009-01-30 23:20:10 +0000 | [diff] [blame] | 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 | |
Charles Bailey | 05e934b | 2008-02-21 23:31:56 +0000 | [diff] [blame] | 16 | test_expect_success 'setup' ' |
David Aguilar | f9e4308 | 2014-10-15 01:35:20 -0700 | [diff] [blame] | 17 | test_config rerere.enabled true && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 18 | echo master >file1 && |
| 19 | echo master spaced >"spaced name" && |
| 20 | echo master file11 >file11 && |
| 21 | echo master file12 >file12 && |
| 22 | echo master file13 >file13 && |
| 23 | echo master file14 >file14 && |
| 24 | mkdir subdir && |
| 25 | echo master sub >subdir/file3 && |
| 26 | test_create_repo submod && |
| 27 | ( |
| 28 | cd submod && |
| 29 | : >foo && |
| 30 | git add foo && |
| 31 | git commit -m "Add foo" |
| 32 | ) && |
| 33 | git submodule add git://example.com/submod submod && |
| 34 | git add file1 "spaced name" file1[1-4] subdir/file3 .gitmodules submod && |
| 35 | git commit -m "add initial versions" && |
Charles Bailey | b9b5078 | 2009-01-30 23:20:10 +0000 | [diff] [blame] | 36 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 37 | git checkout -b branch1 master && |
| 38 | git submodule update -N && |
| 39 | echo branch1 change >file1 && |
| 40 | echo branch1 newfile >file2 && |
| 41 | echo branch1 spaced >"spaced name" && |
| 42 | echo branch1 both added >both && |
| 43 | echo branch1 change file11 >file11 && |
| 44 | echo branch1 change file13 >file13 && |
| 45 | echo branch1 sub >subdir/file3 && |
| 46 | ( |
| 47 | cd submod && |
| 48 | echo branch1 submodule >bar && |
| 49 | git add bar && |
| 50 | git commit -m "Add bar on branch1" && |
| 51 | git checkout -b submod-branch1 |
| 52 | ) && |
| 53 | git add file1 "spaced name" file11 file13 file2 subdir/file3 submod && |
| 54 | git add both && |
| 55 | git rm file12 && |
| 56 | git commit -m "branch1 changes" && |
Charles Bailey | b9b5078 | 2009-01-30 23:20:10 +0000 | [diff] [blame] | 57 | |
Richard Hansen | 157acfc | 2017-01-10 15:41:52 -0500 | [diff] [blame] | 58 | git checkout -b delete-base branch1 && |
| 59 | mkdir -p a/a && |
Eric Sunshine | 0590ff2 | 2018-07-01 20:23:42 -0400 | [diff] [blame] | 60 | test_write_lines one two 3 4 >a/a/file.txt && |
Richard Hansen | 157acfc | 2017-01-10 15:41:52 -0500 | [diff] [blame] | 61 | git add a/a/file.txt && |
| 62 | git commit -m"base file" && |
| 63 | git checkout -b move-to-b delete-base && |
| 64 | mkdir -p b/b && |
| 65 | git mv a/a/file.txt b/b/file.txt && |
Eric Sunshine | 0590ff2 | 2018-07-01 20:23:42 -0400 | [diff] [blame] | 66 | test_write_lines one two 4 >b/b/file.txt && |
Richard Hansen | 157acfc | 2017-01-10 15:41:52 -0500 | [diff] [blame] | 67 | git commit -a -m"move to b" && |
| 68 | git checkout -b move-to-c delete-base && |
| 69 | mkdir -p c/c && |
| 70 | git mv a/a/file.txt c/c/file.txt && |
Eric Sunshine | 0590ff2 | 2018-07-01 20:23:42 -0400 | [diff] [blame] | 71 | test_write_lines one two 3 >c/c/file.txt && |
Richard Hansen | 157acfc | 2017-01-10 15:41:52 -0500 | [diff] [blame] | 72 | git commit -a -m"move to c" && |
| 73 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 74 | git checkout -b stash1 master && |
| 75 | echo stash1 change file11 >file11 && |
| 76 | git add file11 && |
| 77 | git commit -m "stash1 changes" && |
Phil Hord | 79dc2d0 | 2012-07-10 18:52:27 -0400 | [diff] [blame] | 78 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 79 | git checkout -b stash2 master && |
| 80 | echo stash2 change file11 >file11 && |
| 81 | git add file11 && |
| 82 | git commit -m "stash2 changes" && |
Phil Hord | 79dc2d0 | 2012-07-10 18:52:27 -0400 | [diff] [blame] | 83 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 84 | git checkout master && |
| 85 | git submodule update -N && |
| 86 | echo master updated >file1 && |
| 87 | echo master new >file2 && |
| 88 | echo master updated spaced >"spaced name" && |
| 89 | echo master both added >both && |
| 90 | echo master updated file12 >file12 && |
| 91 | echo master updated file14 >file14 && |
| 92 | echo master new sub >subdir/file3 && |
| 93 | ( |
| 94 | cd submod && |
| 95 | echo master submodule >bar && |
| 96 | git add bar && |
| 97 | git commit -m "Add bar on master" && |
| 98 | git checkout -b submod-master |
| 99 | ) && |
| 100 | git add file1 "spaced name" file12 file14 file2 subdir/file3 submod && |
| 101 | git add both && |
| 102 | git rm file11 && |
| 103 | git commit -m "master updates" && |
Charles Bailey | b9b5078 | 2009-01-30 23:20:10 +0000 | [diff] [blame] | 104 | |
Richard Hansen | 157acfc | 2017-01-10 15:41:52 -0500 | [diff] [blame] | 105 | git clean -fdx && |
| 106 | git checkout -b order-file-start master && |
| 107 | echo start >a && |
| 108 | echo start >b && |
| 109 | git add a b && |
| 110 | git commit -m start && |
| 111 | git checkout -b order-file-side1 order-file-start && |
| 112 | echo side1 >a && |
| 113 | echo side1 >b && |
| 114 | git add a b && |
| 115 | git commit -m side1 && |
| 116 | git checkout -b order-file-side2 order-file-start && |
| 117 | echo side2 >a && |
| 118 | echo side2 >b && |
| 119 | git add a b && |
| 120 | git commit -m side2 && |
| 121 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 122 | git config merge.tool mytool && |
| 123 | git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && |
| 124 | git config mergetool.mytool.trustExitCode true && |
| 125 | git config mergetool.mybase.cmd "cat \"\$BASE\" >\"\$MERGED\"" && |
| 126 | git config mergetool.mybase.trustExitCode true |
Charles Bailey | 05e934b | 2008-02-21 23:31:56 +0000 | [diff] [blame] | 127 | ' |
| 128 | |
| 129 | test_expect_success 'custom mergetool' ' |
Richard Hansen | c3ad312 | 2017-01-10 15:41:55 -0500 | [diff] [blame] | 130 | test_when_finished "git reset --hard" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 131 | git checkout -b test$test_count branch1 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 132 | git submodule update -N && |
Denton Liu | e9d309e | 2019-04-24 15:46:57 -0700 | [diff] [blame] | 133 | test_must_fail git merge master && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 134 | yes "" | git mergetool both && |
| 135 | yes "" | git mergetool file1 file1 && |
| 136 | yes "" | git mergetool file2 "spaced name" && |
| 137 | yes "" | git mergetool subdir/file3 && |
| 138 | yes "d" | git mergetool file11 && |
| 139 | yes "d" | git mergetool file12 && |
| 140 | yes "l" | git mergetool submod && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 141 | echo "master updated" >expect && |
| 142 | test_cmp expect file1 && |
| 143 | echo "master new" >expect && |
| 144 | test_cmp expect file2 && |
| 145 | echo "master new sub" >expect && |
| 146 | test_cmp expect subdir/file3 && |
| 147 | echo "branch1 submodule" >expect && |
| 148 | test_cmp expect submod/bar && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 149 | git commit -m "branch1 resolved with mergetool" |
Charles Bailey | 0ec7b6c | 2009-01-21 22:57:48 +0000 | [diff] [blame] | 150 | ' |
| 151 | |
Denton Liu | 57d93c1 | 2019-04-24 15:46:59 -0700 | [diff] [blame] | 152 | test_expect_success 'gui mergetool' ' |
| 153 | test_config merge.guitool myguitool && |
| 154 | test_config mergetool.myguitool.cmd "(printf \"gui \" && cat \"\$REMOTE\") >\"\$MERGED\"" && |
| 155 | test_config mergetool.myguitool.trustExitCode true && |
| 156 | test_when_finished "git reset --hard" && |
| 157 | git checkout -b test$test_count branch1 && |
| 158 | git submodule update -N && |
| 159 | test_must_fail git merge master && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 160 | yes "" | git mergetool --gui both && |
| 161 | yes "" | git mergetool -g file1 file1 && |
| 162 | yes "" | git mergetool --gui file2 "spaced name" && |
| 163 | yes "" | git mergetool --gui subdir/file3 && |
| 164 | yes "d" | git mergetool --gui file11 && |
| 165 | yes "d" | git mergetool --gui file12 && |
| 166 | yes "l" | git mergetool --gui submod && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 167 | echo "gui master updated" >expect && |
| 168 | test_cmp expect file1 && |
| 169 | echo "gui master new" >expect && |
| 170 | test_cmp expect file2 && |
| 171 | echo "gui master new sub" >expect && |
| 172 | test_cmp expect subdir/file3 && |
| 173 | echo "branch1 submodule" >expect && |
| 174 | test_cmp expect submod/bar && |
Denton Liu | 57d93c1 | 2019-04-24 15:46:59 -0700 | [diff] [blame] | 175 | git commit -m "branch1 resolved with mergetool" |
| 176 | ' |
| 177 | |
Denton Liu | 60aced3 | 2019-04-29 02:21:14 -0400 | [diff] [blame] | 178 | test_expect_success 'gui mergetool without merge.guitool set falls back to merge.tool' ' |
| 179 | test_when_finished "git reset --hard" && |
| 180 | git checkout -b test$test_count branch1 && |
| 181 | git submodule update -N && |
| 182 | test_must_fail git merge master && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 183 | yes "" | git mergetool --gui both && |
| 184 | yes "" | git mergetool -g file1 file1 && |
| 185 | yes "" | git mergetool --gui file2 "spaced name" && |
| 186 | yes "" | git mergetool --gui subdir/file3 && |
| 187 | yes "d" | git mergetool --gui file11 && |
| 188 | yes "d" | git mergetool --gui file12 && |
| 189 | yes "l" | git mergetool --gui submod && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 190 | echo "master updated" >expect && |
| 191 | test_cmp expect file1 && |
| 192 | echo "master new" >expect && |
| 193 | test_cmp expect file2 && |
| 194 | echo "master new sub" >expect && |
| 195 | test_cmp expect subdir/file3 && |
| 196 | echo "branch1 submodule" >expect && |
| 197 | test_cmp expect submod/bar && |
Denton Liu | 60aced3 | 2019-04-29 02:21:14 -0400 | [diff] [blame] | 198 | git commit -m "branch1 resolved with mergetool" |
| 199 | ' |
| 200 | |
Charles Bailey | 0ec7b6c | 2009-01-21 22:57:48 +0000 | [diff] [blame] | 201 | test_expect_success 'mergetool crlf' ' |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 202 | test_when_finished "git reset --hard" && |
| 203 | # This test_config line must go after the above reset line so that |
| 204 | # core.autocrlf is unconfigured before reset runs. (The |
| 205 | # test_config command uses test_when_finished internally and |
| 206 | # test_when_finished is LIFO.) |
David Aguilar | f9e4308 | 2014-10-15 01:35:20 -0700 | [diff] [blame] | 207 | test_config core.autocrlf true && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 208 | git checkout -b test$test_count branch1 && |
Denton Liu | e9d309e | 2019-04-24 15:46:57 -0700 | [diff] [blame] | 209 | test_must_fail git merge master && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 210 | yes "" | git mergetool file1 && |
| 211 | yes "" | git mergetool file2 && |
| 212 | yes "" | git mergetool "spaced name" && |
| 213 | yes "" | git mergetool both && |
| 214 | yes "" | git mergetool subdir/file3 && |
| 215 | yes "d" | git mergetool file11 && |
| 216 | yes "d" | git mergetool file12 && |
| 217 | yes "r" | git mergetool submod && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 218 | test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" && |
| 219 | test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" && |
| 220 | test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" && |
| 221 | git submodule update -N && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 222 | echo "master submodule" >expect && |
| 223 | test_cmp expect submod/bar && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 224 | git commit -m "branch1 resolved with mergetool - autocrlf" |
Charles Bailey | 05e934b | 2008-02-21 23:31:56 +0000 | [diff] [blame] | 225 | ' |
| 226 | |
Charles Bailey | ff4a185 | 2009-01-30 23:20:11 +0000 | [diff] [blame] | 227 | test_expect_success 'mergetool in subdir' ' |
Richard Hansen | c3ad312 | 2017-01-10 15:41:55 -0500 | [diff] [blame] | 228 | test_when_finished "git reset --hard" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 229 | git checkout -b test$test_count branch1 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 230 | git submodule update -N && |
| 231 | ( |
| 232 | cd subdir && |
Denton Liu | e9d309e | 2019-04-24 15:46:57 -0700 | [diff] [blame] | 233 | test_must_fail git merge master && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 234 | yes "" | git mergetool file3 && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 235 | echo "master new sub" >expect && |
| 236 | test_cmp expect file3 |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 237 | ) |
Charles Bailey | b9b5078 | 2009-01-30 23:20:10 +0000 | [diff] [blame] | 238 | ' |
| 239 | |
David Aguilar | bb0a484 | 2010-08-17 02:22:46 -0700 | [diff] [blame] | 240 | test_expect_success 'mergetool on file in parent dir' ' |
Richard Hansen | c3ad312 | 2017-01-10 15:41:55 -0500 | [diff] [blame] | 241 | test_when_finished "git reset --hard" && |
Richard Hansen | fef6c06 | 2017-01-10 15:41:58 -0500 | [diff] [blame] | 242 | git checkout -b test$test_count branch1 && |
Richard Hansen | b696ac9 | 2017-01-10 15:41:54 -0500 | [diff] [blame] | 243 | git submodule update -N && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 244 | ( |
| 245 | cd subdir && |
Denton Liu | e9d309e | 2019-04-24 15:46:57 -0700 | [diff] [blame] | 246 | test_must_fail git merge master && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 247 | yes "" | git mergetool file3 && |
| 248 | yes "" | git mergetool ../file1 && |
| 249 | yes "" | git mergetool ../file2 ../spaced\ name && |
| 250 | yes "" | git mergetool ../both && |
| 251 | yes "d" | git mergetool ../file11 && |
| 252 | yes "d" | git mergetool ../file12 && |
| 253 | yes "l" | git mergetool ../submod && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 254 | echo "master updated" >expect && |
| 255 | test_cmp expect ../file1 && |
| 256 | echo "master new" >expect && |
| 257 | test_cmp expect ../file2 && |
| 258 | echo "branch1 submodule" >expect && |
| 259 | test_cmp expect ../submod/bar && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 260 | git commit -m "branch1 resolved with mergetool - subdir" |
| 261 | ) |
David Aguilar | bb0a484 | 2010-08-17 02:22:46 -0700 | [diff] [blame] | 262 | ' |
| 263 | |
| 264 | test_expect_success 'mergetool skips autoresolved' ' |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 265 | test_when_finished "git reset --hard" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 266 | git checkout -b test$test_count branch1 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 267 | git submodule update -N && |
| 268 | test_must_fail git merge master && |
| 269 | test -n "$(git ls-files -u)" && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 270 | yes "d" | git mergetool file11 && |
| 271 | yes "d" | git mergetool file12 && |
| 272 | yes "l" | git mergetool submod && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 273 | output="$(git mergetool --no-prompt)" && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 274 | test "$output" = "No files need merging" |
David Aguilar | bb0a484 | 2010-08-17 02:22:46 -0700 | [diff] [blame] | 275 | ' |
| 276 | |
Richard Hansen | b9ebb65 | 2017-01-10 15:42:00 -0500 | [diff] [blame] | 277 | test_expect_success 'mergetool merges all from subdir (rerere disabled)' ' |
Richard Hansen | c3ad312 | 2017-01-10 15:41:55 -0500 | [diff] [blame] | 278 | test_when_finished "git reset --hard" && |
Richard Hansen | fef6c06 | 2017-01-10 15:41:58 -0500 | [diff] [blame] | 279 | git checkout -b test$test_count branch1 && |
John Keeping | 1a9a23e | 2015-09-05 14:12:45 +0100 | [diff] [blame] | 280 | test_config rerere.enabled false && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 281 | ( |
| 282 | cd subdir && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 283 | test_must_fail git merge master && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 284 | yes "r" | git mergetool ../submod && |
| 285 | yes "d" "d" | git mergetool --no-prompt && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 286 | echo "master updated" >expect && |
| 287 | test_cmp expect ../file1 && |
| 288 | echo "master new" >expect && |
| 289 | test_cmp expect ../file2 && |
| 290 | echo "master new sub" >expect && |
| 291 | test_cmp expect file3 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 292 | ( cd .. && git submodule update -N ) && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 293 | echo "master submodule" >expect && |
| 294 | test_cmp expect ../submod/bar && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 295 | git commit -m "branch2 resolved by mergetool from subdir" |
| 296 | ) |
David Aguilar | bb0a484 | 2010-08-17 02:22:46 -0700 | [diff] [blame] | 297 | ' |
Charles Bailey | b9b5078 | 2009-01-30 23:20:10 +0000 | [diff] [blame] | 298 | |
Richard Hansen | d0e0cfe | 2017-01-10 15:42:02 -0500 | [diff] [blame] | 299 | test_expect_success 'mergetool merges all from subdir (rerere enabled)' ' |
Richard Hansen | b9ebb65 | 2017-01-10 15:42:00 -0500 | [diff] [blame] | 300 | test_when_finished "git reset --hard" && |
| 301 | git checkout -b test$test_count branch1 && |
David Aguilar | f9e4308 | 2014-10-15 01:35:20 -0700 | [diff] [blame] | 302 | test_config rerere.enabled true && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 303 | rm -rf .git/rr-cache && |
Richard Hansen | b9ebb65 | 2017-01-10 15:42:00 -0500 | [diff] [blame] | 304 | ( |
| 305 | cd subdir && |
| 306 | test_must_fail git merge master && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 307 | yes "r" | git mergetool ../submod && |
| 308 | yes "d" "d" | git mergetool --no-prompt && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 309 | echo "master updated" >expect && |
| 310 | test_cmp expect ../file1 && |
| 311 | echo "master new" >expect && |
| 312 | test_cmp expect ../file2 && |
| 313 | echo "master new sub" >expect && |
| 314 | test_cmp expect file3 && |
Richard Hansen | b9ebb65 | 2017-01-10 15:42:00 -0500 | [diff] [blame] | 315 | ( cd .. && git submodule update -N ) && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 316 | echo "master submodule" >expect && |
| 317 | test_cmp expect ../submod/bar && |
Richard Hansen | b9ebb65 | 2017-01-10 15:42:00 -0500 | [diff] [blame] | 318 | git commit -m "branch2 resolved by mergetool from subdir" |
| 319 | ) |
| 320 | ' |
| 321 | |
Martin von Zweigbergk | 2f59c94 | 2011-02-16 05:47:45 -0500 | [diff] [blame] | 322 | test_expect_success 'mergetool skips resolved paths when rerere is active' ' |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 323 | test_when_finished "git reset --hard" && |
David Aguilar | f9e4308 | 2014-10-15 01:35:20 -0700 | [diff] [blame] | 324 | test_config rerere.enabled true && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 325 | rm -rf .git/rr-cache && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 326 | git checkout -b test$test_count branch1 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 327 | git submodule update -N && |
Denton Liu | e9d309e | 2019-04-24 15:46:57 -0700 | [diff] [blame] | 328 | test_must_fail git merge master && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 329 | yes "l" | git mergetool --no-prompt submod && |
| 330 | yes "d" "d" | git mergetool --no-prompt && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 331 | git submodule update -N && |
| 332 | output="$(yes "n" | git mergetool --no-prompt)" && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 333 | test "$output" = "No files need merging" |
Martin von Zweigbergk | 2f59c94 | 2011-02-16 05:47:45 -0500 | [diff] [blame] | 334 | ' |
| 335 | |
Phil Hord | 743bf6d | 2012-07-10 18:52:28 -0400 | [diff] [blame] | 336 | test_expect_success 'conflicted stash sets up rerere' ' |
Richard Hansen | c3ad312 | 2017-01-10 15:41:55 -0500 | [diff] [blame] | 337 | test_when_finished "git reset --hard" && |
David Aguilar | f9e4308 | 2014-10-15 01:35:20 -0700 | [diff] [blame] | 338 | test_config rerere.enabled true && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 339 | git checkout stash1 && |
| 340 | echo "Conflicting stash content" >file11 && |
| 341 | git stash && |
Phil Hord | 79dc2d0 | 2012-07-10 18:52:27 -0400 | [diff] [blame] | 342 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 343 | git checkout --detach stash2 && |
| 344 | test_must_fail git stash apply && |
Phil Hord | 79dc2d0 | 2012-07-10 18:52:27 -0400 | [diff] [blame] | 345 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 346 | test -n "$(git ls-files -u)" && |
| 347 | conflicts="$(git rerere remaining)" && |
| 348 | test "$conflicts" = "file11" && |
| 349 | output="$(git mergetool --no-prompt)" && |
| 350 | test "$output" != "No files need merging" && |
Phil Hord | 79dc2d0 | 2012-07-10 18:52:27 -0400 | [diff] [blame] | 351 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 352 | git commit -am "save the stash resolution" && |
Phil Hord | 79dc2d0 | 2012-07-10 18:52:27 -0400 | [diff] [blame] | 353 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 354 | git reset --hard stash2 && |
| 355 | test_must_fail git stash apply && |
Phil Hord | 79dc2d0 | 2012-07-10 18:52:27 -0400 | [diff] [blame] | 356 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 357 | test -n "$(git ls-files -u)" && |
| 358 | conflicts="$(git rerere remaining)" && |
| 359 | test -z "$conflicts" && |
| 360 | output="$(git mergetool --no-prompt)" && |
| 361 | test "$output" = "No files need merging" |
Phil Hord | 79dc2d0 | 2012-07-10 18:52:27 -0400 | [diff] [blame] | 362 | ' |
| 363 | |
Jonathon Mah | 3e8e691 | 2011-09-15 19:12:10 -0700 | [diff] [blame] | 364 | test_expect_success 'mergetool takes partial path' ' |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 365 | test_when_finished "git reset --hard" && |
David Aguilar | f9e4308 | 2014-10-15 01:35:20 -0700 | [diff] [blame] | 366 | test_config rerere.enabled false && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 367 | git checkout -b test$test_count branch1 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 368 | git submodule update -N && |
| 369 | test_must_fail git merge master && |
Jonathon Mah | 3e8e691 | 2011-09-15 19:12:10 -0700 | [diff] [blame] | 370 | |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 371 | yes "" | git mergetool subdir && |
Jonathon Mah | 3e8e691 | 2011-09-15 19:12:10 -0700 | [diff] [blame] | 372 | |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 373 | echo "master new sub" >expect && |
| 374 | test_cmp expect subdir/file3 |
Jonathon Mah | 3e8e691 | 2011-09-15 19:12:10 -0700 | [diff] [blame] | 375 | ' |
| 376 | |
David Aguilar | faaab8d | 2016-03-09 23:13:58 -0800 | [diff] [blame] | 377 | test_expect_success 'mergetool delete/delete conflict' ' |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 378 | test_when_finished "git reset --hard" && |
Richard Hansen | 61b76d2 | 2017-01-10 15:41:57 -0500 | [diff] [blame] | 379 | git checkout -b test$test_count move-to-c && |
David Aguilar | faaab8d | 2016-03-09 23:13:58 -0800 | [diff] [blame] | 380 | test_must_fail git merge move-to-b && |
| 381 | echo d | git mergetool a/a/file.txt && |
| 382 | ! test -f a/a/file.txt && |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 383 | git reset --hard && |
David Aguilar | faaab8d | 2016-03-09 23:13:58 -0800 | [diff] [blame] | 384 | test_must_fail git merge move-to-b && |
| 385 | echo m | git mergetool a/a/file.txt && |
| 386 | test -f b/b/file.txt && |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 387 | git reset --hard && |
David Aguilar | faaab8d | 2016-03-09 23:13:58 -0800 | [diff] [blame] | 388 | test_must_fail git merge move-to-b && |
| 389 | ! echo a | git mergetool a/a/file.txt && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 390 | ! test -f a/a/file.txt |
David Aguilar | faaab8d | 2016-03-09 23:13:58 -0800 | [diff] [blame] | 391 | ' |
| 392 | |
| 393 | test_expect_success 'mergetool produces no errors when keepBackup is used' ' |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 394 | test_when_finished "git reset --hard" && |
Richard Hansen | fef6c06 | 2017-01-10 15:41:58 -0500 | [diff] [blame] | 395 | git checkout -b test$test_count move-to-c && |
David Aguilar | faaab8d | 2016-03-09 23:13:58 -0800 | [diff] [blame] | 396 | test_config mergetool.keepBackup true && |
| 397 | test_must_fail git merge move-to-b && |
David Aguilar | faaab8d | 2016-03-09 23:13:58 -0800 | [diff] [blame] | 398 | echo d | git mergetool a/a/file.txt 2>actual && |
SZEDER Gábor | 1c5e94f | 2018-08-19 23:57:25 +0200 | [diff] [blame] | 399 | test_must_be_empty actual && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 400 | ! test -d a |
David Aguilar | a298604 | 2016-03-09 23:13:59 -0800 | [diff] [blame] | 401 | ' |
| 402 | |
| 403 | test_expect_success 'mergetool honors tempfile config for deleted files' ' |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 404 | test_when_finished "git reset --hard" && |
Richard Hansen | fef6c06 | 2017-01-10 15:41:58 -0500 | [diff] [blame] | 405 | git checkout -b test$test_count move-to-c && |
David Aguilar | a298604 | 2016-03-09 23:13:59 -0800 | [diff] [blame] | 406 | test_config mergetool.keepTemporaries false && |
| 407 | test_must_fail git merge move-to-b && |
| 408 | echo d | git mergetool a/a/file.txt && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 409 | ! test -d a |
David Aguilar | a298604 | 2016-03-09 23:13:59 -0800 | [diff] [blame] | 410 | ' |
| 411 | |
| 412 | test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' ' |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 413 | test_when_finished "git reset --hard" && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 414 | test_when_finished "git clean -fdx" && |
Richard Hansen | fef6c06 | 2017-01-10 15:41:58 -0500 | [diff] [blame] | 415 | git checkout -b test$test_count move-to-c && |
David Aguilar | a298604 | 2016-03-09 23:13:59 -0800 | [diff] [blame] | 416 | test_config mergetool.keepTemporaries true && |
| 417 | test_must_fail git merge move-to-b && |
Eric Sunshine | 0590ff2 | 2018-07-01 20:23:42 -0400 | [diff] [blame] | 418 | ! test_write_lines a n | git mergetool a/a/file.txt && |
David Aguilar | a298604 | 2016-03-09 23:13:59 -0800 | [diff] [blame] | 419 | test -d a/a && |
| 420 | cat >expect <<-\EOF && |
| 421 | file_BASE_.txt |
| 422 | file_LOCAL_.txt |
| 423 | file_REMOTE_.txt |
| 424 | EOF |
| 425 | ls -1 a/a | sed -e "s/[0-9]*//g" >actual && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 426 | test_cmp expect actual |
David Aguilar | faaab8d | 2016-03-09 23:13:58 -0800 | [diff] [blame] | 427 | ' |
| 428 | |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 429 | test_expect_success 'deleted vs modified submodule' ' |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 430 | test_when_finished "git reset --hard" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 431 | git checkout -b test$test_count branch1 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 432 | git submodule update -N && |
| 433 | mv submod submod-movedaside && |
| 434 | git rm --cached submod && |
| 435 | git commit -m "Submodule deleted from branch" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 436 | git checkout -b test$test_count.a test$test_count && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 437 | test_must_fail git merge master && |
| 438 | test -n "$(git ls-files -u)" && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 439 | yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && |
| 440 | yes "" | git mergetool both && |
| 441 | yes "d" | git mergetool file11 file12 && |
| 442 | yes "r" | git mergetool submod && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 443 | rmdir submod && mv submod-movedaside submod && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 444 | echo "branch1 submodule" >expect && |
| 445 | test_cmp expect submod/bar && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 446 | git submodule update -N && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 447 | echo "master submodule" >expect && |
| 448 | test_cmp expect submod/bar && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 449 | output="$(git mergetool --no-prompt)" && |
| 450 | test "$output" = "No files need merging" && |
| 451 | git commit -m "Merge resolved by keeping module" && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 452 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 453 | mv submod submod-movedaside && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 454 | git checkout -b test$test_count.b test$test_count && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 455 | git submodule update -N && |
| 456 | test_must_fail git merge master && |
| 457 | test -n "$(git ls-files -u)" && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 458 | yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && |
| 459 | yes "" | git mergetool both && |
| 460 | yes "d" | git mergetool file11 file12 && |
| 461 | yes "l" | git mergetool submod && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 462 | test ! -e submod && |
| 463 | output="$(git mergetool --no-prompt)" && |
| 464 | test "$output" = "No files need merging" && |
| 465 | git commit -m "Merge resolved by deleting module" && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 466 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 467 | mv submod-movedaside submod && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 468 | git checkout -b test$test_count.c master && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 469 | git submodule update -N && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 470 | test_must_fail git merge test$test_count && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 471 | test -n "$(git ls-files -u)" && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 472 | yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && |
| 473 | yes "" | git mergetool both && |
| 474 | yes "d" | git mergetool file11 file12 && |
| 475 | yes "r" | git mergetool submod && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 476 | test ! -e submod && |
| 477 | test -d submod.orig && |
| 478 | git submodule update -N && |
| 479 | output="$(git mergetool --no-prompt)" && |
| 480 | test "$output" = "No files need merging" && |
| 481 | git commit -m "Merge resolved by deleting module" && |
| 482 | mv submod.orig submod && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 483 | |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 484 | git checkout -b test$test_count.d master && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 485 | git submodule update -N && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 486 | test_must_fail git merge test$test_count && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 487 | test -n "$(git ls-files -u)" && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 488 | yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && |
| 489 | yes "" | git mergetool both && |
| 490 | yes "d" | git mergetool file11 file12 && |
| 491 | yes "l" | git mergetool submod && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 492 | echo "master submodule" >expect && |
| 493 | test_cmp expect submod/bar && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 494 | git submodule update -N && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 495 | echo "master submodule" >expect && |
| 496 | test_cmp expect submod/bar && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 497 | output="$(git mergetool --no-prompt)" && |
| 498 | test "$output" = "No files need merging" && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 499 | git commit -m "Merge resolved by keeping module" |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 500 | ' |
| 501 | |
| 502 | test_expect_success 'file vs modified submodule' ' |
Richard Hansen | c3ad312 | 2017-01-10 15:41:55 -0500 | [diff] [blame] | 503 | test_when_finished "git reset --hard" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 504 | git checkout -b test$test_count branch1 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 505 | git submodule update -N && |
| 506 | mv submod submod-movedaside && |
| 507 | git rm --cached submod && |
| 508 | echo not a submodule >submod && |
| 509 | git add submod && |
| 510 | git commit -m "Submodule path becomes file" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 511 | git checkout -b test$test_count.a branch1 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 512 | test_must_fail git merge master && |
| 513 | test -n "$(git ls-files -u)" && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 514 | yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && |
| 515 | yes "" | git mergetool both && |
| 516 | yes "d" | git mergetool file11 file12 && |
| 517 | yes "r" | git mergetool submod && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 518 | rmdir submod && mv submod-movedaside submod && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 519 | echo "branch1 submodule" >expect && |
| 520 | test_cmp expect submod/bar && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 521 | git submodule update -N && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 522 | echo "master submodule" >expect && |
| 523 | test_cmp expect submod/bar && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 524 | output="$(git mergetool --no-prompt)" && |
| 525 | test "$output" = "No files need merging" && |
| 526 | git commit -m "Merge resolved by keeping module" && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 527 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 528 | mv submod submod-movedaside && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 529 | git checkout -b test$test_count.b test$test_count && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 530 | test_must_fail git merge master && |
| 531 | test -n "$(git ls-files -u)" && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 532 | yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && |
| 533 | yes "" | git mergetool both && |
| 534 | yes "d" | git mergetool file11 file12 && |
Elijah Newren | ef52778 | 2020-10-26 17:01:37 +0000 | [diff] [blame] | 535 | if test "$GIT_TEST_MERGE_ALGORITHM" = ort |
| 536 | then |
| 537 | yes "c" | git mergetool submod~HEAD && |
| 538 | git rm submod && |
| 539 | git mv submod~HEAD submod |
| 540 | else |
| 541 | yes "l" | git mergetool submod |
| 542 | fi && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 543 | git submodule update -N && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 544 | echo "not a submodule" >expect && |
| 545 | test_cmp expect submod && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 546 | output="$(git mergetool --no-prompt)" && |
| 547 | test "$output" = "No files need merging" && |
| 548 | git commit -m "Merge resolved by keeping file" && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 549 | |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 550 | git checkout -b test$test_count.c master && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 551 | rmdir submod && mv submod-movedaside submod && |
| 552 | test ! -e submod.orig && |
| 553 | git submodule update -N && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 554 | test_must_fail git merge test$test_count && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 555 | test -n "$(git ls-files -u)" && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 556 | yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && |
| 557 | yes "" | git mergetool both && |
| 558 | yes "d" | git mergetool file11 file12 && |
Elijah Newren | ef52778 | 2020-10-26 17:01:37 +0000 | [diff] [blame] | 559 | if test "$GIT_TEST_MERGE_ALGORITHM" = ort |
| 560 | then |
| 561 | mv submod submod.orig && |
| 562 | git rm --cached submod && |
| 563 | yes "c" | git mergetool submod~test19 && |
| 564 | git mv submod~test19 submod |
| 565 | else |
| 566 | yes "r" | git mergetool submod |
| 567 | fi && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 568 | test -d submod.orig && |
| 569 | git submodule update -N && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 570 | echo "not a submodule" >expect && |
| 571 | test_cmp expect submod && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 572 | output="$(git mergetool --no-prompt)" && |
| 573 | test "$output" = "No files need merging" && |
| 574 | git commit -m "Merge resolved by keeping file" && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 575 | |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 576 | git checkout -b test$test_count.d master && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 577 | rmdir submod && mv submod.orig submod && |
| 578 | git submodule update -N && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 579 | test_must_fail git merge test$test_count && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 580 | test -n "$(git ls-files -u)" && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 581 | yes "" | git mergetool file1 file2 spaced\ name subdir/file3 && |
| 582 | yes "" | git mergetool both && |
| 583 | yes "d" | git mergetool file11 file12 && |
| 584 | yes "l" | git mergetool submod && |
Elijah Newren | ef52778 | 2020-10-26 17:01:37 +0000 | [diff] [blame] | 585 | if test "$GIT_TEST_MERGE_ALGORITHM" = ort |
| 586 | then |
| 587 | yes "d" | git mergetool submod~test19 |
| 588 | fi && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 589 | echo "master submodule" >expect && |
| 590 | test_cmp expect submod/bar && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 591 | git submodule update -N && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 592 | echo "master submodule" >expect && |
| 593 | test_cmp expect submod/bar && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 594 | output="$(git mergetool --no-prompt)" && |
| 595 | test "$output" = "No files need merging" && |
| 596 | git commit -m "Merge resolved by keeping module" |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 597 | ' |
| 598 | |
| 599 | test_expect_success 'submodule in subdirectory' ' |
Richard Hansen | c3ad312 | 2017-01-10 15:41:55 -0500 | [diff] [blame] | 600 | test_when_finished "git reset --hard" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 601 | git checkout -b test$test_count branch1 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 602 | git submodule update -N && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 603 | ( |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 604 | cd subdir && |
| 605 | test_create_repo subdir_module && |
| 606 | ( |
| 607 | cd subdir_module && |
| 608 | : >file15 && |
| 609 | git add file15 && |
| 610 | git commit -m "add initial versions" |
| 611 | ) |
| 612 | ) && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 613 | test_when_finished "rm -rf subdir/subdir_module" && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 614 | git submodule add git://example.com/subsubmodule subdir/subdir_module && |
| 615 | git add subdir/subdir_module && |
| 616 | git commit -m "add submodule in subdirectory" && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 617 | |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 618 | git checkout -b test$test_count.a test$test_count && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 619 | git submodule update -N && |
| 620 | ( |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 621 | cd subdir/subdir_module && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 622 | git checkout -b super10.a && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 623 | echo test$test_count.a >file15 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 624 | git add file15 && |
| 625 | git commit -m "on branch 10.a" |
| 626 | ) && |
| 627 | git add subdir/subdir_module && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 628 | git commit -m "change submodule in subdirectory on test$test_count.a" && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 629 | |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 630 | git checkout -b test$test_count.b test$test_count && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 631 | git submodule update -N && |
| 632 | ( |
| 633 | cd subdir/subdir_module && |
| 634 | git checkout -b super10.b && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 635 | echo test$test_count.b >file15 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 636 | git add file15 && |
| 637 | git commit -m "on branch 10.b" |
| 638 | ) && |
| 639 | git add subdir/subdir_module && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 640 | git commit -m "change submodule in subdirectory on test$test_count.b" && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 641 | |
Denton Liu | e9d309e | 2019-04-24 15:46:57 -0700 | [diff] [blame] | 642 | test_must_fail git merge test$test_count.a && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 643 | ( |
| 644 | cd subdir && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 645 | yes "l" | git mergetool subdir_module |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 646 | ) && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 647 | echo "test$test_count.b" >expect && |
| 648 | test_cmp expect subdir/subdir_module/file15 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 649 | git submodule update -N && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 650 | echo "test$test_count.b" >expect && |
| 651 | test_cmp expect subdir/subdir_module/file15 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 652 | git reset --hard && |
| 653 | git submodule update -N && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 654 | |
Denton Liu | e9d309e | 2019-04-24 15:46:57 -0700 | [diff] [blame] | 655 | test_must_fail git merge test$test_count.a && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 656 | yes "r" | git mergetool subdir/subdir_module && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 657 | echo "test$test_count.b" >expect && |
| 658 | test_cmp expect subdir/subdir_module/file15 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 659 | git submodule update -N && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 660 | echo "test$test_count.a" >expect && |
| 661 | test_cmp expect subdir/subdir_module/file15 && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 662 | git commit -m "branch1 resolved with mergetool" |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 663 | ' |
| 664 | |
| 665 | test_expect_success 'directory vs modified submodule' ' |
Richard Hansen | c3ad312 | 2017-01-10 15:41:55 -0500 | [diff] [blame] | 666 | test_when_finished "git reset --hard" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 667 | git checkout -b test$test_count branch1 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 668 | mv submod submod-movedaside && |
| 669 | git rm --cached submod && |
| 670 | mkdir submod && |
| 671 | echo not a submodule >submod/file16 && |
| 672 | git add submod/file16 && |
| 673 | git commit -m "Submodule path becomes directory" && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 674 | |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 675 | test_must_fail git merge master && |
| 676 | test -n "$(git ls-files -u)" && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 677 | yes "l" | git mergetool submod && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 678 | echo "not a submodule" >expect && |
| 679 | test_cmp expect submod/file16 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 680 | rm -rf submod.orig && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 681 | |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 682 | git reset --hard && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 683 | test_must_fail git merge master && |
| 684 | test -n "$(git ls-files -u)" && |
| 685 | test ! -e submod.orig && |
Elijah Newren | ef52778 | 2020-10-26 17:01:37 +0000 | [diff] [blame] | 686 | if test "$GIT_TEST_MERGE_ALGORITHM" = ort |
| 687 | then |
| 688 | yes "r" | git mergetool submod~master && |
| 689 | git mv submod submod.orig && |
| 690 | git mv submod~master submod |
| 691 | else |
| 692 | yes "r" | git mergetool submod |
| 693 | fi && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 694 | test -d submod.orig && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 695 | echo "not a submodule" >expect && |
| 696 | test_cmp expect submod.orig/file16 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 697 | rm -r submod.orig && |
| 698 | mv submod-movedaside/.git submod && |
| 699 | ( cd submod && git clean -f && git reset --hard ) && |
| 700 | git submodule update -N && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 701 | echo "master submodule" >expect && |
| 702 | test_cmp expect submod/bar && |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 703 | git reset --hard && |
| 704 | rm -rf submod-movedaside && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 705 | |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 706 | git checkout -b test$test_count.c master && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 707 | git submodule update -N && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 708 | test_must_fail git merge test$test_count && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 709 | test -n "$(git ls-files -u)" && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 710 | yes "l" | git mergetool submod && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 711 | git submodule update -N && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 712 | echo "master submodule" >expect && |
| 713 | test_cmp expect submod/bar && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 714 | |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 715 | git reset --hard && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 716 | git submodule update -N && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 717 | test_must_fail git merge test$test_count && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 718 | test -n "$(git ls-files -u)" && |
| 719 | test ! -e submod.orig && |
Johannes Sixt | b4a04c8 | 2019-06-10 10:58:58 +0200 | [diff] [blame] | 720 | yes "r" | git mergetool submod && |
Johannes Sixt | e10dffd | 2019-06-12 18:33:46 +0200 | [diff] [blame] | 721 | echo "not a submodule" >expect && |
| 722 | test_cmp expect submod/file16 && |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 723 | |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 724 | git reset --hard master && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 725 | ( cd submod && git clean -f && git reset --hard ) && |
| 726 | git submodule update -N |
Jonathon Mah | ff7f089 | 2011-04-13 03:00:48 -0700 | [diff] [blame] | 727 | ' |
| 728 | |
David Aguilar | ec245ba | 2012-01-19 23:47:35 -0800 | [diff] [blame] | 729 | test_expect_success 'file with no base' ' |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 730 | test_when_finished "git reset --hard" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 731 | git checkout -b test$test_count branch1 && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 732 | test_must_fail git merge master && |
| 733 | git mergetool --no-prompt --tool mybase -- both && |
Ævar Arnfjörð Bjarmason | d3c6751 | 2018-07-27 17:48:11 +0000 | [diff] [blame] | 734 | test_must_be_empty both |
David Aguilar | ec245ba | 2012-01-19 23:47:35 -0800 | [diff] [blame] | 735 | ' |
| 736 | |
David Aguilar | a427ef7 | 2012-09-25 00:48:11 -0700 | [diff] [blame] | 737 | test_expect_success 'custom commands override built-ins' ' |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 738 | test_when_finished "git reset --hard" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 739 | git checkout -b test$test_count branch1 && |
David Aguilar | f9e4308 | 2014-10-15 01:35:20 -0700 | [diff] [blame] | 740 | test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && |
| 741 | test_config mergetool.defaults.trustExitCode true && |
David Aguilar | 7457861 | 2014-10-15 01:35:17 -0700 | [diff] [blame] | 742 | test_must_fail git merge master && |
| 743 | git mergetool --no-prompt --tool defaults -- both && |
| 744 | echo master both added >expected && |
Stefan Beller | 9c5b2fa | 2017-10-06 12:00:06 -0700 | [diff] [blame] | 745 | test_cmp expected both |
David Aguilar | a427ef7 | 2012-09-25 00:48:11 -0700 | [diff] [blame] | 746 | ' |
| 747 | |
David Aguilar | 688684e | 2014-10-15 01:35:19 -0700 | [diff] [blame] | 748 | test_expect_success 'filenames seen by tools start with ./' ' |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 749 | test_when_finished "git reset --hard" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 750 | git checkout -b test$test_count branch1 && |
David Aguilar | 688684e | 2014-10-15 01:35:19 -0700 | [diff] [blame] | 751 | test_config mergetool.writeToTemp false && |
| 752 | test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && |
| 753 | test_config mergetool.myecho.trustExitCode true && |
| 754 | test_must_fail git merge master && |
| 755 | git mergetool --no-prompt --tool myecho -- both >actual && |
Denton Liu | e9d309e | 2019-04-24 15:46:57 -0700 | [diff] [blame] | 756 | grep ^\./both_LOCAL_ actual |
David Aguilar | 688684e | 2014-10-15 01:35:19 -0700 | [diff] [blame] | 757 | ' |
| 758 | |
Armin Kunaschik | c578a09 | 2016-07-02 21:01:51 +0200 | [diff] [blame] | 759 | test_lazy_prereq MKTEMP ' |
| 760 | tempdir=$(mktemp -d -t foo.XXXXXX) && |
Jeff King | fa3142c | 2016-11-27 01:34:45 -0500 | [diff] [blame] | 761 | test -d "$tempdir" && |
| 762 | rmdir "$tempdir" |
Armin Kunaschik | c578a09 | 2016-07-02 21:01:51 +0200 | [diff] [blame] | 763 | ' |
| 764 | |
| 765 | test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToTemp' ' |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 766 | test_when_finished "git reset --hard" && |
Richard Hansen | ecfdf0b | 2017-01-10 15:41:51 -0500 | [diff] [blame] | 767 | git checkout -b test$test_count branch1 && |
David Aguilar | 688684e | 2014-10-15 01:35:19 -0700 | [diff] [blame] | 768 | test_config mergetool.writeToTemp true && |
| 769 | test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && |
| 770 | test_config mergetool.myecho.trustExitCode true && |
| 771 | test_must_fail git merge master && |
| 772 | git mergetool --no-prompt --tool myecho -- both >actual && |
Denton Liu | e9d309e | 2019-04-24 15:46:57 -0700 | [diff] [blame] | 773 | ! grep ^\./both_LOCAL_ actual && |
| 774 | grep /both_LOCAL_ actual |
David Aguilar | 688684e | 2014-10-15 01:35:19 -0700 | [diff] [blame] | 775 | ' |
| 776 | |
David Aguilar | 57937f7 | 2016-10-07 16:58:05 -0700 | [diff] [blame] | 777 | test_expect_success 'diff.orderFile configuration is honored' ' |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 778 | test_when_finished "git reset --hard" && |
Richard Hansen | 61b76d2 | 2017-01-10 15:41:57 -0500 | [diff] [blame] | 779 | git checkout -b test$test_count order-file-side2 && |
David Aguilar | 57937f7 | 2016-10-07 16:58:05 -0700 | [diff] [blame] | 780 | test_config diff.orderFile order-file && |
| 781 | test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && |
| 782 | test_config mergetool.myecho.trustExitCode true && |
| 783 | echo b >order-file && |
| 784 | echo a >>order-file && |
David Aguilar | 57937f7 | 2016-10-07 16:58:05 -0700 | [diff] [blame] | 785 | test_must_fail git merge order-file-side1 && |
| 786 | cat >expect <<-\EOF && |
| 787 | Merging: |
| 788 | b |
| 789 | a |
| 790 | EOF |
Richard Hansen | d0e0cfe | 2017-01-10 15:42:02 -0500 | [diff] [blame] | 791 | |
| 792 | # make sure "order-file" that is ambiguous between |
| 793 | # rev and path is understood correctly. |
| 794 | git branch order-file HEAD && |
| 795 | |
David Aguilar | 57937f7 | 2016-10-07 16:58:05 -0700 | [diff] [blame] | 796 | git mergetool --no-prompt --tool myecho >output && |
| 797 | git grep --no-index -h -A2 Merging: output >actual && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 798 | test_cmp expect actual |
David Aguilar | 57937f7 | 2016-10-07 16:58:05 -0700 | [diff] [blame] | 799 | ' |
David Aguilar | 654311b | 2016-10-07 17:01:30 -0700 | [diff] [blame] | 800 | test_expect_success 'mergetool -Oorder-file is honored' ' |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 801 | test_when_finished "git reset --hard" && |
Richard Hansen | fef6c06 | 2017-01-10 15:41:58 -0500 | [diff] [blame] | 802 | git checkout -b test$test_count order-file-side2 && |
David Aguilar | 654311b | 2016-10-07 17:01:30 -0700 | [diff] [blame] | 803 | test_config diff.orderFile order-file && |
| 804 | test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && |
| 805 | test_config mergetool.myecho.trustExitCode true && |
Richard Hansen | b696ac9 | 2017-01-10 15:41:54 -0500 | [diff] [blame] | 806 | echo b >order-file && |
| 807 | echo a >>order-file && |
David Aguilar | 654311b | 2016-10-07 17:01:30 -0700 | [diff] [blame] | 808 | test_must_fail git merge order-file-side1 && |
| 809 | cat >expect <<-\EOF && |
| 810 | Merging: |
| 811 | a |
| 812 | b |
| 813 | EOF |
| 814 | git mergetool -O/dev/null --no-prompt --tool myecho >output && |
| 815 | git grep --no-index -h -A2 Merging: output >actual && |
| 816 | test_cmp expect actual && |
Richard Hansen | bd9714f | 2017-01-10 15:41:59 -0500 | [diff] [blame] | 817 | git reset --hard && |
David Aguilar | 654311b | 2016-10-07 17:01:30 -0700 | [diff] [blame] | 818 | |
| 819 | git config --unset diff.orderFile && |
| 820 | test_must_fail git merge order-file-side1 && |
| 821 | cat >expect <<-\EOF && |
| 822 | Merging: |
| 823 | b |
| 824 | a |
| 825 | EOF |
| 826 | git mergetool -Oorder-file --no-prompt --tool myecho >output && |
| 827 | git grep --no-index -h -A2 Merging: output >actual && |
Richard Hansen | 614eb27 | 2017-01-10 15:41:53 -0500 | [diff] [blame] | 828 | test_cmp expect actual |
David Aguilar | 654311b | 2016-10-07 17:01:30 -0700 | [diff] [blame] | 829 | ' |
David Aguilar | 57937f7 | 2016-10-07 16:58:05 -0700 | [diff] [blame] | 830 | |
Seth House | 98ea309 | 2021-02-09 13:07:10 -0700 | [diff] [blame^] | 831 | test_expect_success 'mergetool hideResolved' ' |
| 832 | test_config mergetool.hideResolved true && |
| 833 | test_when_finished "git reset --hard" && |
| 834 | git checkout -b test${test_count}_b master && |
| 835 | test_write_lines >file1 base "" a && |
| 836 | git commit -a -m "base" && |
| 837 | test_write_lines >file1 base "" c && |
| 838 | git commit -a -m "remote update" && |
| 839 | git checkout -b test${test_count}_a HEAD~ && |
| 840 | test_write_lines >file1 local "" b && |
| 841 | git commit -a -m "local update" && |
| 842 | test_must_fail git merge test${test_count}_b && |
| 843 | yes "" | git mergetool file1 && |
| 844 | test_write_lines >expect local "" c && |
| 845 | test_cmp expect file1 && |
| 846 | git commit -m "test resolved with mergetool" |
| 847 | ' |
| 848 | |
Charles Bailey | 05e934b | 2008-02-21 23:31:56 +0000 | [diff] [blame] | 849 | test_done |