From: Junio C Hamano Date: Tue, 3 May 2016 21:08:17 +0000 (-0700) Subject: Merge branch 'nf/mergetool-prompt' X-Git-Tag: v2.9.0-rc0~74 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b97414352746967c72e5b87cce39efea4b93e2bf?ds=inline;hp=-c Merge branch 'nf/mergetool-prompt' UI consistency improvements. * nf/mergetool-prompt: difftool/mergetool: make the form of yes/no questions consistent --- b97414352746967c72e5b87cce39efea4b93e2bf diff --combined git-mergetool--lib.sh index 302c56de5b,92adcc0d07..9abd00be21 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@@ -100,7 -100,7 +100,7 @@@ check_unchanged () while true do echo "$MERGED seems unchanged." - printf "Was the merge successful? [y/n] " + printf "Was the merge successful [y/n]? " read answer || return 1 case "$answer" in y*|Y*) return 0 ;; @@@ -372,28 -372,3 +372,28 @@@ get_merge_tool () fi echo "$merge_tool" } + +mergetool_find_win32_cmd () { + executable=$1 + sub_directory=$2 + + # Use $executable if it exists in $PATH + if type -p "$executable" >/dev/null 2>&1 + then + printf '%s' "$executable" + return + fi + + # Look for executable in the typical locations + for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' | + cut -d '=' -f 2- | sort -u) + do + if test -n "$directory" && test -x "$directory/$sub_directory/$executable" + then + printf '%s' "$directory/$sub_directory/$executable" + return + fi + done + + printf '%s' "$executable" +} 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 &&