Merge branch 'nf/mergetool-prompt'
authorJunio C Hamano <gitster@pobox.com>
Tue, 3 May 2016 21:08:17 +0000 (14:08 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 May 2016 21:08:17 +0000 (14:08 -0700)
UI consistency improvements.

* nf/mergetool-prompt:
difftool/mergetool: make the form of yes/no questions consistent

1  2 
git-mergetool--lib.sh
git-mergetool.sh
t/t7800-difftool.sh
diff --combined git-mergetool--lib.sh
index 302c56de5b6ceb96e1eb075f9e208a655dcb9c9e,92adcc0d0785f8b78fce2c49bbcc40e49020ee24..9abd00be212b3e55883c0f9fa0487c7b31a6039f
@@@ -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 f67bab55e85d00b06601fa488ba01975eb865359,2e0635a15cd34911df948ad1b228b5a5f800a4cc..bf862705d8c654a5dd58ec70d6781583b7dbefc3
@@@ -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]*)
                        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"
                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 4e713f7aa54d4713cfd74978460ec9aa144fc773,df9050f4ef09dcc423e7c8c996541b38932e3691..ff7a9e968f4dde078a131ee65306ae6784e8faa5
@@@ -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 &&