Merge branch 'jk/add-i-patch-do-prompt'
authorJunio C Hamano <gitster@pobox.com>
Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Mar 2017 06:21:33 +0000 (23:21 -0700)
The patch subcommand of "git add -i" was meant to have paths
selection prompt just like other subcommand, unlike "git add -p"
directly jumps to hunk selection. Recently, this was broken and
"add -i" lost the paths selection dialog, but it now has been
fixed.

* jk/add-i-patch-do-prompt:
add--interactive: fix missing file prompt for patch mode with "-i"

git-add--interactive.perl
t/t3701-add-interactive.sh
index 982593c89e2f253c2fa4d626c0c00fde7935aead..f5c816e273318709e90a9f5e9a47143a3842f8e3 100755 (executable)
@@ -92,7 +92,7 @@ sub colored {
 }
 
 # command line options
-my $cmd;
+my $patch_mode_only;
 my $patch_mode;
 my $patch_mode_revision;
 
@@ -1299,7 +1299,7 @@ sub patch_update_cmd {
                }
                return 0;
        }
-       if ($patch_mode) {
+       if ($patch_mode_only) {
                @them = @mods;
        }
        else {
@@ -1721,7 +1721,7 @@ sub process_args {
                die sprintf(__("invalid argument %s, expecting --"),
                               $arg) unless $arg eq "--";
                %patch_mode_flavour = %{$patch_modes{$patch_mode}};
-               $cmd = 1;
+               $patch_mode_only = 1;
        }
        elsif ($arg ne "--") {
                die sprintf(__("invalid argument %s, expecting --"), $arg);
@@ -1758,7 +1758,7 @@ sub main_loop {
 
 process_args();
 refresh();
-if ($cmd) {
+if ($patch_mode_only) {
        patch_update_cmd();
 }
 else {
index 5ffe78e920c4aa292a6c16e2aa8078ede4ab065c..aaa258daa376ab6d18d71a04a517840e1b55d094 100755 (executable)
@@ -394,4 +394,22 @@ test_expect_success 'diffs can be colorized' '
        grep "$(printf "\\033")" output
 '
 
+test_expect_success 'patch-mode via -i prompts for files' '
+       git reset --hard &&
+
+       echo one >file &&
+       echo two >test &&
+       git add -i <<-\EOF &&
+       patch
+       test
+
+       y
+       quit
+       EOF
+
+       echo test >expect &&
+       git diff --cached --name-only >actual &&
+       test_cmp expect actual
+'
+
 test_done