From: Junio C Hamano Date: Wed, 18 May 2016 21:40:07 +0000 (-0700) Subject: Merge branch 'nf/mergetool-prompt' into HEAD X-Git-Tag: v2.8.3~16 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f735a50ffdf0e1734438f0c0e6d70c4a81eea09e?hp=-c Merge branch 'nf/mergetool-prompt' into HEAD UI consistency improvements. * nf/mergetool-prompt: difftool/mergetool: make the form of yes/no questions consistent --- f735a50ffdf0e1734438f0c0e6d70c4a81eea09e diff --combined git-mergetool.sh index f67bab55e8,2e0635a15c..bf862705d8 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@@ -126,12 -126,7 +126,12 @@@ resolve_deleted_merge () case "$ans" in [mMcC]*) git add -- "$MERGED" - cleanup_temp_files --save-backup + if test "$merge_keep_backup" = "true" + then + cleanup_temp_files --save-backup + else + cleanup_temp_files + fi return 0 ;; [dD]*) @@@ -140,10 -135,6 +140,10 @@@ return 0 ;; [aA]*) + if test "$merge_keep_temporaries" = "false" + then + cleanup_temp_files + fi return 1 ;; esac @@@ -291,14 -282,8 +291,14 @@@ merge_file () return fi - mv -- "$MERGED" "$BACKUP" - cp -- "$BACKUP" "$MERGED" + if test -f "$MERGED" + then + mv -- "$MERGED" "$BACKUP" + cp -- "$BACKUP" "$MERGED" + fi + # Create a parent directory to handle delete/delete conflicts + # where the base's directory no longer exists. + mkdir -p "$(dirname "$MERGED")" checkout_staged_file 1 "$MERGED" "$BASE" checkout_staged_file 2 "$MERGED" "$LOCAL" @@@ -310,9 -295,7 +310,9 @@@ describe_file "$local_mode" "local" "$LOCAL" describe_file "$remote_mode" "remote" "$REMOTE" resolve_deleted_merge - return + status=$? + rmdir -p "$(dirname "$MERGED")" 2>/dev/null + return $status fi if is_symlink "$local_mode" || is_symlink "$remote_mode" @@@ -413,7 -396,7 +413,7 @@@ don prompt_after_failed_merge () { while true do - printf "Continue merging other unresolved paths (y/n) ? " + printf "Continue merging other unresolved paths [y/n]? " read ans || return 1 case "$ans" in [yY]*) diff --combined t/t7800-difftool.sh index 4e713f7aa5,df9050f4ef..ff7a9e968f --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@@ -20,7 -20,7 +20,7 @@@ difftool_test_setup ( prompt_given () { prompt="$1" - test "$prompt" = "Launch 'test-tool' [Y/n]: branch" + test "$prompt" = "Launch 'test-tool' [Y/n]? branch" } # Create a file on master and change it on branch @@@ -430,11 -430,11 +430,11 @@@ EO test_expect_success PERL,SYMLINKS 'difftool --dir-diff --symlink without unstaged changes' ' cat >expect <<-EOF && file - $(pwd)/file + $PWD/file file2 - $(pwd)/file2 + $PWD/file2 sub/sub - $(pwd)/sub/sub + $PWD/sub/sub EOF git difftool --dir-diff --symlink \ --extcmd "./.git/CHECK_SYMLINKS" branch HEAD && @@@ -448,14 -448,14 +448,14 @@@ EO run_dir_diff_test 'difftool --dir-diff syncs worktree with unstaged change' ' test_when_finished git reset --hard && echo "orig content" >file && - git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch && + git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch && echo "new content" >expect && test_cmp expect file ' run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' ' test_when_finished git reset --hard && - git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch && + git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch && echo "new content" >expect && test_cmp expect file ' @@@ -466,7 -466,7 +466,7 @@@ EO test_expect_success PERL 'difftool --no-symlinks does not overwrite working tree file ' ' echo "orig content" >file && - git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-file" branch && + git difftool --dir-diff --no-symlinks --extcmd "$PWD/modify-file" branch && echo "new content" >expect && test_cmp expect file ' @@@ -482,7 -482,7 +482,7 @@@ test_expect_success PERL 'difftool --no TMPDIR=$TRASH_DIRECTORY && export TMPDIR && echo "orig content" >file && - test_must_fail git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-both-files" branch && + test_must_fail git difftool --dir-diff --no-symlinks --extcmd "$PWD/modify-both-files" branch && echo "wt content" >expect && test_cmp expect file && echo "tmp content" >expect &&