Merge branch 'rh/mergetool-regression-fix'

"git mergetool" without any pathspec on the command line that is
run from a subdirectory became no-op in Git v2.11 by mistake, which
has been fixed.

* rh/mergetool-regression-fix:
  mergetool: fix running in subdir when rerere enabled
  mergetool: take the "-O" out of $orderfile
  t7610: add test case for rerere+mergetool+subdir bug
  t7610: spell 'git reset --hard' consistently
  t7610: don't assume the checked-out commit
  t7610: always work on a test-specific branch
  t7610: delete some now-unnecessary 'git reset --hard' lines
  t7610: run 'git reset --hard' after each test to clean up
  t7610: don't rely on state from previous test
  t7610: use test_when_finished for cleanup tasks
  t7610: move setup code to the 'setup' test case
  t7610: update branch names to match test number
  rev-parse doc: pass "--" to rev-parse in the --prefix example
  .mailmap: record canonical email for Richard Hansen
This commit is contained in:
Junio C Hamano 2017-01-18 15:12:16 -08:00
Родитель 1c16df23b1 d0e0cfe745
Коммит 7cef7fadab
4 изменённых файлов: 187 добавлений и 120 удалений

Просмотреть файл

@ -192,6 +192,8 @@ Philippe Bruhat <book@cpan.org>
Ralf Thielow <ralf.thielow@gmail.com> <ralf.thielow@googlemail.com> Ralf Thielow <ralf.thielow@gmail.com> <ralf.thielow@googlemail.com>
Ramsay Jones <ramsay@ramsayjones.plus.com> <ramsay@ramsay1.demon.co.uk> Ramsay Jones <ramsay@ramsayjones.plus.com> <ramsay@ramsay1.demon.co.uk>
René Scharfe <l.s.r@web.de> <rene.scharfe@lsrfire.ath.cx> René Scharfe <l.s.r@web.de> <rene.scharfe@lsrfire.ath.cx>
Richard Hansen <rhansen@rhansen.org> <hansenr@google.com>
Richard Hansen <rhansen@rhansen.org> <rhansen@bbn.com>
Robert Fitzsimons <robfitz@273k.net> Robert Fitzsimons <robfitz@273k.net>
Robert Shearman <robertshearman@gmail.com> <rob@codeweavers.com> Robert Shearman <robertshearman@gmail.com> <rob@codeweavers.com>
Robert Zeh <robert.a.zeh@gmail.com> Robert Zeh <robert.a.zeh@gmail.com>

Просмотреть файл

@ -91,7 +91,8 @@ repository. For example:
---- ----
prefix=$(git rev-parse --show-prefix) prefix=$(git rev-parse --show-prefix)
cd "$(git rev-parse --show-toplevel)" cd "$(git rev-parse --show-toplevel)"
eval "set -- $(git rev-parse --sq --prefix "$prefix" "$@")" # rev-parse provides the -- needed for 'set'
eval "set $(git rev-parse --sq --prefix "$prefix" -- "$@")"
---- ----
--verify:: --verify::

Просмотреть файл

@ -421,7 +421,7 @@ main () {
prompt=true prompt=true
;; ;;
-O*) -O*)
orderfile="$1" orderfile="${1#-O}"
;; ;;
--) --)
shift shift
@ -454,6 +454,17 @@ main () {
merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)" merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)" merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
prefix=$(git rev-parse --show-prefix) || exit 1
cd_to_toplevel
if test -n "$orderfile"
then
orderfile=$(
git rev-parse --prefix "$prefix" -- "$orderfile" |
sed -e 1d
)
fi
if test $# -eq 0 && test -e "$GIT_DIR/MERGE_RR" if test $# -eq 0 && test -e "$GIT_DIR/MERGE_RR"
then then
set -- $(git rerere remaining) set -- $(git rerere remaining)
@ -461,13 +472,15 @@ main () {
then then
print_noop_and_exit print_noop_and_exit
fi fi
elif test $# -ge 0
then
# rev-parse provides the -- needed for 'set'
eval "set $(git rev-parse --sq --prefix "$prefix" -- "$@")"
fi fi
files=$(git -c core.quotePath=false \ files=$(git -c core.quotePath=false \
diff --name-only --diff-filter=U \ diff --name-only --diff-filter=U \
${orderfile:+"$orderfile"} -- "$@") ${orderfile:+"-O$orderfile"} -- "$@")
cd_to_toplevel
if test -z "$files" if test -z "$files"
then then

Просмотреть файл

@ -55,6 +55,22 @@ test_expect_success 'setup' '
git rm file12 && git rm file12 &&
git commit -m "branch1 changes" && git commit -m "branch1 changes" &&
git checkout -b delete-base branch1 &&
mkdir -p a/a &&
(echo one; echo two; echo 3; echo 4) >a/a/file.txt &&
git add a/a/file.txt &&
git commit -m"base file" &&
git checkout -b move-to-b delete-base &&
mkdir -p b/b &&
git mv a/a/file.txt b/b/file.txt &&
(echo one; echo two; echo 4) >b/b/file.txt &&
git commit -a -m"move to b" &&
git checkout -b move-to-c delete-base &&
mkdir -p c/c &&
git mv a/a/file.txt c/c/file.txt &&
(echo one; echo two; echo 3) >c/c/file.txt &&
git commit -a -m"move to c" &&
git checkout -b stash1 master && git checkout -b stash1 master &&
echo stash1 change file11 >file11 && echo stash1 change file11 >file11 &&
git add file11 && git add file11 &&
@ -86,6 +102,23 @@ test_expect_success 'setup' '
git rm file11 && git rm file11 &&
git commit -m "master updates" && git commit -m "master updates" &&
git clean -fdx &&
git checkout -b order-file-start master &&
echo start >a &&
echo start >b &&
git add a b &&
git commit -m start &&
git checkout -b order-file-side1 order-file-start &&
echo side1 >a &&
echo side1 >b &&
git add a b &&
git commit -m side1 &&
git checkout -b order-file-side2 order-file-start &&
echo side2 >a &&
echo side2 >b &&
git add a b &&
git commit -m side2 &&
git config merge.tool mytool && git config merge.tool mytool &&
git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
git config mergetool.mytool.trustExitCode true && git config mergetool.mytool.trustExitCode true &&
@ -94,7 +127,8 @@ test_expect_success 'setup' '
' '
test_expect_success 'custom mergetool' ' test_expect_success 'custom mergetool' '
git checkout -b test1 branch1 && test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge master >/dev/null 2>&1 && test_must_fail git merge master >/dev/null 2>&1 &&
( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
@ -112,8 +146,13 @@ test_expect_success 'custom mergetool' '
' '
test_expect_success 'mergetool crlf' ' test_expect_success 'mergetool crlf' '
test_when_finished "git reset --hard" &&
# This test_config line must go after the above reset line so that
# core.autocrlf is unconfigured before reset runs. (The
# test_config command uses test_when_finished internally and
# test_when_finished is LIFO.)
test_config core.autocrlf true && test_config core.autocrlf true &&
git checkout -b test2 branch1 && git checkout -b test$test_count branch1 &&
test_must_fail git merge master >/dev/null 2>&1 && test_must_fail git merge master >/dev/null 2>&1 &&
( yes "" | git mergetool file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
( yes "" | git mergetool file2 >/dev/null 2>&1 ) && ( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
@ -128,13 +167,12 @@ test_expect_success 'mergetool crlf' '
test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" && test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" &&
git submodule update -N && git submodule update -N &&
test "$(cat submod/bar)" = "master submodule" && test "$(cat submod/bar)" = "master submodule" &&
git commit -m "branch1 resolved with mergetool - autocrlf" && git commit -m "branch1 resolved with mergetool - autocrlf"
test_config core.autocrlf false &&
git reset --hard
' '
test_expect_success 'mergetool in subdir' ' test_expect_success 'mergetool in subdir' '
git checkout -b test3 branch1 && test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
git submodule update -N && git submodule update -N &&
( (
cd subdir && cd subdir &&
@ -145,8 +183,13 @@ test_expect_success 'mergetool in subdir' '
' '
test_expect_success 'mergetool on file in parent dir' ' test_expect_success 'mergetool on file in parent dir' '
test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
git submodule update -N &&
( (
cd subdir && cd subdir &&
test_must_fail git merge master >/dev/null 2>&1 &&
( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) && ( yes "" | git mergetool ../file2 ../spaced\ name >/dev/null 2>&1 ) &&
( yes "" | git mergetool ../both >/dev/null 2>&1 ) && ( yes "" | git mergetool ../both >/dev/null 2>&1 ) &&
@ -161,7 +204,8 @@ test_expect_success 'mergetool on file in parent dir' '
' '
test_expect_success 'mergetool skips autoresolved' ' test_expect_success 'mergetool skips autoresolved' '
git checkout -b test4 branch1 && test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge master && test_must_fail git merge master &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
@ -169,11 +213,12 @@ test_expect_success 'mergetool skips autoresolved' '
( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
( yes "l" | git mergetool submod >/dev/null 2>&1 ) && ( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
output="$(git mergetool --no-prompt)" && output="$(git mergetool --no-prompt)" &&
test "$output" = "No files need merging" && test "$output" = "No files need merging"
git reset --hard
' '
test_expect_success 'mergetool merges all from subdir' ' test_expect_success 'mergetool merges all from subdir (rerere disabled)' '
test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
test_config rerere.enabled false && test_config rerere.enabled false &&
( (
cd subdir && cd subdir &&
@ -189,21 +234,41 @@ test_expect_success 'mergetool merges all from subdir' '
) )
' '
test_expect_success 'mergetool skips resolved paths when rerere is active' ' test_expect_success 'mergetool merges all from subdir (rerere enabled)' '
test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
test_config rerere.enabled true && test_config rerere.enabled true &&
rm -rf .git/rr-cache && rm -rf .git/rr-cache &&
git checkout -b test5 branch1 && (
cd subdir &&
test_must_fail git merge master &&
( yes "r" | git mergetool ../submod ) &&
( yes "d" "d" | git mergetool --no-prompt ) &&
test "$(cat ../file1)" = "master updated" &&
test "$(cat ../file2)" = "master new" &&
test "$(cat file3)" = "master new sub" &&
( cd .. && git submodule update -N ) &&
test "$(cat ../submod/bar)" = "master submodule" &&
git commit -m "branch2 resolved by mergetool from subdir"
)
'
test_expect_success 'mergetool skips resolved paths when rerere is active' '
test_when_finished "git reset --hard" &&
test_config rerere.enabled true &&
rm -rf .git/rr-cache &&
git checkout -b test$test_count branch1 &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge master >/dev/null 2>&1 && test_must_fail git merge master >/dev/null 2>&1 &&
( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) && ( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) &&
( yes "d" "d" | git mergetool --no-prompt >/dev/null 2>&1 ) && ( yes "d" "d" | git mergetool --no-prompt >/dev/null 2>&1 ) &&
git submodule update -N && git submodule update -N &&
output="$(yes "n" | git mergetool --no-prompt)" && output="$(yes "n" | git mergetool --no-prompt)" &&
test "$output" = "No files need merging" && test "$output" = "No files need merging"
git reset --hard
' '
test_expect_success 'conflicted stash sets up rerere' ' test_expect_success 'conflicted stash sets up rerere' '
test_when_finished "git reset --hard" &&
test_config rerere.enabled true && test_config rerere.enabled true &&
git checkout stash1 && git checkout stash1 &&
echo "Conflicting stash content" >file11 && echo "Conflicting stash content" >file11 &&
@ -231,67 +296,57 @@ test_expect_success 'conflicted stash sets up rerere' '
' '
test_expect_success 'mergetool takes partial path' ' test_expect_success 'mergetool takes partial path' '
git reset --hard && test_when_finished "git reset --hard" &&
test_config rerere.enabled false && test_config rerere.enabled false &&
git checkout -b test12 branch1 && git checkout -b test$test_count branch1 &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge master && test_must_fail git merge master &&
( yes "" | git mergetool subdir ) && ( yes "" | git mergetool subdir ) &&
test "$(cat subdir/file3)" = "master new sub" && test "$(cat subdir/file3)" = "master new sub"
git reset --hard
' '
test_expect_success 'mergetool delete/delete conflict' ' test_expect_success 'mergetool delete/delete conflict' '
git checkout -b delete-base branch1 && test_when_finished "git reset --hard" &&
mkdir -p a/a && git checkout -b test$test_count move-to-c &&
(echo one; echo two; echo 3; echo 4) >a/a/file.txt &&
git add a/a/file.txt &&
git commit -m"base file" &&
git checkout -b move-to-b delete-base &&
mkdir -p b/b &&
git mv a/a/file.txt b/b/file.txt &&
(echo one; echo two; echo 4) >b/b/file.txt &&
git commit -a -m"move to b" &&
git checkout -b move-to-c delete-base &&
mkdir -p c/c &&
git mv a/a/file.txt c/c/file.txt &&
(echo one; echo two; echo 3) >c/c/file.txt &&
git commit -a -m"move to c" &&
test_must_fail git merge move-to-b && test_must_fail git merge move-to-b &&
echo d | git mergetool a/a/file.txt && echo d | git mergetool a/a/file.txt &&
! test -f a/a/file.txt && ! test -f a/a/file.txt &&
git reset --hard HEAD && git reset --hard &&
test_must_fail git merge move-to-b && test_must_fail git merge move-to-b &&
echo m | git mergetool a/a/file.txt && echo m | git mergetool a/a/file.txt &&
test -f b/b/file.txt && test -f b/b/file.txt &&
git reset --hard HEAD && git reset --hard &&
test_must_fail git merge move-to-b && test_must_fail git merge move-to-b &&
! echo a | git mergetool a/a/file.txt && ! echo a | git mergetool a/a/file.txt &&
! test -f a/a/file.txt && ! test -f a/a/file.txt
git reset --hard HEAD
' '
test_expect_success 'mergetool produces no errors when keepBackup is used' ' test_expect_success 'mergetool produces no errors when keepBackup is used' '
test_when_finished "git reset --hard" &&
git checkout -b test$test_count move-to-c &&
test_config mergetool.keepBackup true && test_config mergetool.keepBackup true &&
test_must_fail git merge move-to-b && test_must_fail git merge move-to-b &&
: >expect && : >expect &&
echo d | git mergetool a/a/file.txt 2>actual && echo d | git mergetool a/a/file.txt 2>actual &&
test_cmp expect actual && test_cmp expect actual &&
! test -d a && ! test -d a
git reset --hard HEAD
' '
test_expect_success 'mergetool honors tempfile config for deleted files' ' test_expect_success 'mergetool honors tempfile config for deleted files' '
test_when_finished "git reset --hard" &&
git checkout -b test$test_count move-to-c &&
test_config mergetool.keepTemporaries false && test_config mergetool.keepTemporaries false &&
test_must_fail git merge move-to-b && test_must_fail git merge move-to-b &&
echo d | git mergetool a/a/file.txt && echo d | git mergetool a/a/file.txt &&
! test -d a && ! test -d a
git reset --hard HEAD
' '
test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' ' test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' '
test_when_finished "git reset --hard" &&
test_when_finished "git clean -fdx" &&
git checkout -b test$test_count move-to-c &&
test_config mergetool.keepTemporaries true && test_config mergetool.keepTemporaries true &&
test_must_fail git merge move-to-b && test_must_fail git merge move-to-b &&
! (echo a; echo n) | git mergetool a/a/file.txt && ! (echo a; echo n) | git mergetool a/a/file.txt &&
@ -302,18 +357,17 @@ test_expect_success 'mergetool keeps tempfiles when aborting delete/delete' '
file_REMOTE_.txt file_REMOTE_.txt
EOF EOF
ls -1 a/a | sed -e "s/[0-9]*//g" >actual && ls -1 a/a | sed -e "s/[0-9]*//g" >actual &&
test_cmp expect actual && test_cmp expect actual
git clean -fdx &&
git reset --hard HEAD
' '
test_expect_success 'deleted vs modified submodule' ' test_expect_success 'deleted vs modified submodule' '
git checkout -b test6 branch1 && test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
git submodule update -N && git submodule update -N &&
mv submod submod-movedaside && mv submod submod-movedaside &&
git rm --cached submod && git rm --cached submod &&
git commit -m "Submodule deleted from branch" && git commit -m "Submodule deleted from branch" &&
git checkout -b test6.a test6 && git checkout -b test$test_count.a test$test_count &&
test_must_fail git merge master && test_must_fail git merge master &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
@ -329,7 +383,7 @@ test_expect_success 'deleted vs modified submodule' '
git commit -m "Merge resolved by keeping module" && git commit -m "Merge resolved by keeping module" &&
mv submod submod-movedaside && mv submod submod-movedaside &&
git checkout -b test6.b test6 && git checkout -b test$test_count.b test$test_count &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge master && test_must_fail git merge master &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
@ -343,9 +397,9 @@ test_expect_success 'deleted vs modified submodule' '
git commit -m "Merge resolved by deleting module" && git commit -m "Merge resolved by deleting module" &&
mv submod-movedaside submod && mv submod-movedaside submod &&
git checkout -b test6.c master && git checkout -b test$test_count.c master &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge test6 && test_must_fail git merge test$test_count &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
@ -359,9 +413,9 @@ test_expect_success 'deleted vs modified submodule' '
git commit -m "Merge resolved by deleting module" && git commit -m "Merge resolved by deleting module" &&
mv submod.orig submod && mv submod.orig submod &&
git checkout -b test6.d master && git checkout -b test$test_count.d master &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge test6 && test_must_fail git merge test$test_count &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
@ -372,19 +426,19 @@ test_expect_success 'deleted vs modified submodule' '
test "$(cat submod/bar)" = "master submodule" && test "$(cat submod/bar)" = "master submodule" &&
output="$(git mergetool --no-prompt)" && output="$(git mergetool --no-prompt)" &&
test "$output" = "No files need merging" && test "$output" = "No files need merging" &&
git commit -m "Merge resolved by keeping module" && git commit -m "Merge resolved by keeping module"
git reset --hard HEAD
' '
test_expect_success 'file vs modified submodule' ' test_expect_success 'file vs modified submodule' '
git checkout -b test7 branch1 && test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
git submodule update -N && git submodule update -N &&
mv submod submod-movedaside && mv submod submod-movedaside &&
git rm --cached submod && git rm --cached submod &&
echo not a submodule >submod && echo not a submodule >submod &&
git add submod && git add submod &&
git commit -m "Submodule path becomes file" && git commit -m "Submodule path becomes file" &&
git checkout -b test7.a branch1 && git checkout -b test$test_count.a branch1 &&
test_must_fail git merge master && test_must_fail git merge master &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
@ -400,7 +454,7 @@ test_expect_success 'file vs modified submodule' '
git commit -m "Merge resolved by keeping module" && git commit -m "Merge resolved by keeping module" &&
mv submod submod-movedaside && mv submod submod-movedaside &&
git checkout -b test7.b test7 && git checkout -b test$test_count.b test$test_count &&
test_must_fail git merge master && test_must_fail git merge master &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
@ -413,11 +467,11 @@ test_expect_success 'file vs modified submodule' '
test "$output" = "No files need merging" && test "$output" = "No files need merging" &&
git commit -m "Merge resolved by keeping file" && git commit -m "Merge resolved by keeping file" &&
git checkout -b test7.c master && git checkout -b test$test_count.c master &&
rmdir submod && mv submod-movedaside submod && rmdir submod && mv submod-movedaside submod &&
test ! -e submod.orig && test ! -e submod.orig &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge test7 && test_must_fail git merge test$test_count &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
( yes "" | git mergetool both >/dev/null 2>&1 ) && ( yes "" | git mergetool both >/dev/null 2>&1 ) &&
@ -430,10 +484,10 @@ test_expect_success 'file vs modified submodule' '
test "$output" = "No files need merging" && test "$output" = "No files need merging" &&
git commit -m "Merge resolved by keeping file" && git commit -m "Merge resolved by keeping file" &&
git checkout -b test7.d master && git checkout -b test$test_count.d master &&
rmdir submod && mv submod.orig submod && rmdir submod && mv submod.orig submod &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge test7 && test_must_fail git merge test$test_count &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) && ( yes "" | git mergetool file1 file2 spaced\ name subdir/file3 >/dev/null 2>&1 ) &&
( yes "" | git mergetool both>/dev/null 2>&1 ) && ( yes "" | git mergetool both>/dev/null 2>&1 ) &&
@ -448,7 +502,8 @@ test_expect_success 'file vs modified submodule' '
' '
test_expect_success 'submodule in subdirectory' ' test_expect_success 'submodule in subdirectory' '
git checkout -b test10 branch1 && test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
git submodule update -N && git submodule update -N &&
( (
cd subdir && cd subdir &&
@ -460,56 +515,57 @@ test_expect_success 'submodule in subdirectory' '
git commit -m "add initial versions" git commit -m "add initial versions"
) )
) && ) &&
test_when_finished "rm -rf subdir/subdir_module" &&
git submodule add git://example.com/subsubmodule subdir/subdir_module && git submodule add git://example.com/subsubmodule subdir/subdir_module &&
git add subdir/subdir_module && git add subdir/subdir_module &&
git commit -m "add submodule in subdirectory" && git commit -m "add submodule in subdirectory" &&
git checkout -b test10.a test10 && git checkout -b test$test_count.a test$test_count &&
git submodule update -N && git submodule update -N &&
( (
cd subdir/subdir_module && cd subdir/subdir_module &&
git checkout -b super10.a && git checkout -b super10.a &&
echo test10.a >file15 && echo test$test_count.a >file15 &&
git add file15 && git add file15 &&
git commit -m "on branch 10.a" git commit -m "on branch 10.a"
) && ) &&
git add subdir/subdir_module && git add subdir/subdir_module &&
git commit -m "change submodule in subdirectory on test10.a" && git commit -m "change submodule in subdirectory on test$test_count.a" &&
git checkout -b test10.b test10 && git checkout -b test$test_count.b test$test_count &&
git submodule update -N && git submodule update -N &&
( (
cd subdir/subdir_module && cd subdir/subdir_module &&
git checkout -b super10.b && git checkout -b super10.b &&
echo test10.b >file15 && echo test$test_count.b >file15 &&
git add file15 && git add file15 &&
git commit -m "on branch 10.b" git commit -m "on branch 10.b"
) && ) &&
git add subdir/subdir_module && git add subdir/subdir_module &&
git commit -m "change submodule in subdirectory on test10.b" && git commit -m "change submodule in subdirectory on test$test_count.b" &&
test_must_fail git merge test10.a >/dev/null 2>&1 && test_must_fail git merge test$test_count.a >/dev/null 2>&1 &&
( (
cd subdir && cd subdir &&
( yes "l" | git mergetool subdir_module ) ( yes "l" | git mergetool subdir_module )
) && ) &&
test "$(cat subdir/subdir_module/file15)" = "test10.b" && test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
git submodule update -N && git submodule update -N &&
test "$(cat subdir/subdir_module/file15)" = "test10.b" && test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
git reset --hard && git reset --hard &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge test10.a >/dev/null 2>&1 && test_must_fail git merge test$test_count.a >/dev/null 2>&1 &&
( yes "r" | git mergetool subdir/subdir_module ) && ( yes "r" | git mergetool subdir/subdir_module ) &&
test "$(cat subdir/subdir_module/file15)" = "test10.b" && test "$(cat subdir/subdir_module/file15)" = "test$test_count.b" &&
git submodule update -N && git submodule update -N &&
test "$(cat subdir/subdir_module/file15)" = "test10.a" && test "$(cat subdir/subdir_module/file15)" = "test$test_count.a" &&
git commit -m "branch1 resolved with mergetool" && git commit -m "branch1 resolved with mergetool"
rm -rf subdir/subdir_module
' '
test_expect_success 'directory vs modified submodule' ' test_expect_success 'directory vs modified submodule' '
git checkout -b test11 branch1 && test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
mv submod submod-movedaside && mv submod submod-movedaside &&
git rm --cached submod && git rm --cached submod &&
mkdir submod && mkdir submod &&
@ -523,7 +579,7 @@ test_expect_success 'directory vs modified submodule' '
test "$(cat submod/file16)" = "not a submodule" && test "$(cat submod/file16)" = "not a submodule" &&
rm -rf submod.orig && rm -rf submod.orig &&
git reset --hard >/dev/null 2>&1 && git reset --hard &&
test_must_fail git merge master && test_must_fail git merge master &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
test ! -e submod.orig && test ! -e submod.orig &&
@ -535,58 +591,59 @@ test_expect_success 'directory vs modified submodule' '
( cd submod && git clean -f && git reset --hard ) && ( cd submod && git clean -f && git reset --hard ) &&
git submodule update -N && git submodule update -N &&
test "$(cat submod/bar)" = "master submodule" && test "$(cat submod/bar)" = "master submodule" &&
git reset --hard >/dev/null 2>&1 && rm -rf submod-movedaside && git reset --hard &&
rm -rf submod-movedaside &&
git checkout -b test11.c master && git checkout -b test$test_count.c master &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge test11 && test_must_fail git merge test$test_count &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
( yes "l" | git mergetool submod ) && ( yes "l" | git mergetool submod ) &&
git submodule update -N && git submodule update -N &&
test "$(cat submod/bar)" = "master submodule" && test "$(cat submod/bar)" = "master submodule" &&
git reset --hard >/dev/null 2>&1 && git reset --hard &&
git submodule update -N && git submodule update -N &&
test_must_fail git merge test11 && test_must_fail git merge test$test_count &&
test -n "$(git ls-files -u)" && test -n "$(git ls-files -u)" &&
test ! -e submod.orig && test ! -e submod.orig &&
( yes "r" | git mergetool submod ) && ( yes "r" | git mergetool submod ) &&
test "$(cat submod/file16)" = "not a submodule" && test "$(cat submod/file16)" = "not a submodule" &&
git reset --hard master >/dev/null 2>&1 && git reset --hard master &&
( cd submod && git clean -f && git reset --hard ) && ( cd submod && git clean -f && git reset --hard ) &&
git submodule update -N git submodule update -N
' '
test_expect_success 'file with no base' ' test_expect_success 'file with no base' '
git checkout -b test13 branch1 && test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
test_must_fail git merge master && test_must_fail git merge master &&
git mergetool --no-prompt --tool mybase -- both && git mergetool --no-prompt --tool mybase -- both &&
>expected && >expected &&
test_cmp both expected && test_cmp both expected
git reset --hard master >/dev/null 2>&1
' '
test_expect_success 'custom commands override built-ins' ' test_expect_success 'custom commands override built-ins' '
git checkout -b test14 branch1 && test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
test_config mergetool.defaults.trustExitCode true && test_config mergetool.defaults.trustExitCode true &&
test_must_fail git merge master && test_must_fail git merge master &&
git mergetool --no-prompt --tool defaults -- both && git mergetool --no-prompt --tool defaults -- both &&
echo master both added >expected && echo master both added >expected &&
test_cmp both expected && test_cmp both expected
git reset --hard master >/dev/null 2>&1
' '
test_expect_success 'filenames seen by tools start with ./' ' test_expect_success 'filenames seen by tools start with ./' '
git checkout -b test15 branch1 && test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
test_config mergetool.writeToTemp false && test_config mergetool.writeToTemp false &&
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
test_config mergetool.myecho.trustExitCode true && test_config mergetool.myecho.trustExitCode true &&
test_must_fail git merge master && test_must_fail git merge master &&
git mergetool --no-prompt --tool myecho -- both >actual && git mergetool --no-prompt --tool myecho -- both >actual &&
grep ^\./both_LOCAL_ actual >/dev/null && grep ^\./both_LOCAL_ actual >/dev/null
git reset --hard master >/dev/null 2>&1
' '
test_lazy_prereq MKTEMP ' test_lazy_prereq MKTEMP '
@ -596,53 +653,48 @@ test_lazy_prereq MKTEMP '
' '
test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToTemp' ' test_expect_success MKTEMP 'temporary filenames are used with mergetool.writeToTemp' '
git checkout -b test16 branch1 && test_when_finished "git reset --hard" &&
git checkout -b test$test_count branch1 &&
test_config mergetool.writeToTemp true && test_config mergetool.writeToTemp true &&
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
test_config mergetool.myecho.trustExitCode true && test_config mergetool.myecho.trustExitCode true &&
test_must_fail git merge master && test_must_fail git merge master &&
git mergetool --no-prompt --tool myecho -- both >actual && git mergetool --no-prompt --tool myecho -- both >actual &&
! grep ^\./both_LOCAL_ actual >/dev/null && ! grep ^\./both_LOCAL_ actual >/dev/null &&
grep /both_LOCAL_ actual >/dev/null && grep /both_LOCAL_ actual >/dev/null
git reset --hard master >/dev/null 2>&1
' '
test_expect_success 'diff.orderFile configuration is honored' ' test_expect_success 'diff.orderFile configuration is honored' '
test_when_finished "git reset --hard" &&
git checkout -b test$test_count order-file-side2 &&
test_config diff.orderFile order-file && test_config diff.orderFile order-file &&
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
test_config mergetool.myecho.trustExitCode true && test_config mergetool.myecho.trustExitCode true &&
echo b >order-file && echo b >order-file &&
echo a >>order-file && echo a >>order-file &&
git checkout -b order-file-start master &&
echo start >a &&
echo start >b &&
git add a b &&
git commit -m start &&
git checkout -b order-file-side1 order-file-start &&
echo side1 >a &&
echo side1 >b &&
git add a b &&
git commit -m side1 &&
git checkout -b order-file-side2 order-file-start &&
echo side2 >a &&
echo side2 >b &&
git add a b &&
git commit -m side2 &&
test_must_fail git merge order-file-side1 && test_must_fail git merge order-file-side1 &&
cat >expect <<-\EOF && cat >expect <<-\EOF &&
Merging: Merging:
b b
a a
EOF EOF
# make sure "order-file" that is ambiguous between
# rev and path is understood correctly.
git branch order-file HEAD &&
git mergetool --no-prompt --tool myecho >output && git mergetool --no-prompt --tool myecho >output &&
git grep --no-index -h -A2 Merging: output >actual && git grep --no-index -h -A2 Merging: output >actual &&
test_cmp expect actual && test_cmp expect actual
git reset --hard >/dev/null
' '
test_expect_success 'mergetool -Oorder-file is honored' ' test_expect_success 'mergetool -Oorder-file is honored' '
test_when_finished "git reset --hard" &&
git checkout -b test$test_count order-file-side2 &&
test_config diff.orderFile order-file && test_config diff.orderFile order-file &&
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" && test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
test_config mergetool.myecho.trustExitCode true && test_config mergetool.myecho.trustExitCode true &&
echo b >order-file &&
echo a >>order-file &&
test_must_fail git merge order-file-side1 && test_must_fail git merge order-file-side1 &&
cat >expect <<-\EOF && cat >expect <<-\EOF &&
Merging: Merging:
@ -652,7 +704,7 @@ test_expect_success 'mergetool -Oorder-file is honored' '
git mergetool -O/dev/null --no-prompt --tool myecho >output && git mergetool -O/dev/null --no-prompt --tool myecho >output &&
git grep --no-index -h -A2 Merging: output >actual && git grep --no-index -h -A2 Merging: output >actual &&
test_cmp expect actual && test_cmp expect actual &&
git reset --hard >/dev/null 2>&1 && git reset --hard &&
git config --unset diff.orderFile && git config --unset diff.orderFile &&
test_must_fail git merge order-file-side1 && test_must_fail git merge order-file-side1 &&
@ -663,8 +715,7 @@ test_expect_success 'mergetool -Oorder-file is honored' '
EOF EOF
git mergetool -Oorder-file --no-prompt --tool myecho >output && git mergetool -Oorder-file --no-prompt --tool myecho >output &&
git grep --no-index -h -A2 Merging: output >actual && git grep --no-index -h -A2 Merging: output >actual &&
test_cmp expect actual && test_cmp expect actual
git reset --hard >/dev/null 2>&1
' '
test_done test_done