Skip to content

Commit fb070d2

Browse files
committed
Merge branch 'jk/add-i-patch-do-prompt'
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"
2 parents 033328a + c852bd5 commit fb070d2

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

git-add--interactive.perl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ sub colored {
9292
}
9393

9494
# command line options
95-
my $cmd;
95+
my $patch_mode_only;
9696
my $patch_mode;
9797
my $patch_mode_revision;
9898

@@ -1299,7 +1299,7 @@ sub patch_update_cmd {
12991299
}
13001300
return 0;
13011301
}
1302-
if ($patch_mode) {
1302+
if ($patch_mode_only) {
13031303
@them = @mods;
13041304
}
13051305
else {
@@ -1721,7 +1721,7 @@ sub process_args {
17211721
die sprintf(__("invalid argument %s, expecting --"),
17221722
$arg) unless $arg eq "--";
17231723
%patch_mode_flavour = %{$patch_modes{$patch_mode}};
1724-
$cmd = 1;
1724+
$patch_mode_only = 1;
17251725
}
17261726
elsif ($arg ne "--") {
17271727
die sprintf(__("invalid argument %s, expecting --"), $arg);
@@ -1758,7 +1758,7 @@ sub main_loop {
17581758

17591759
process_args();
17601760
refresh();
1761-
if ($cmd) {
1761+
if ($patch_mode_only) {
17621762
patch_update_cmd();
17631763
}
17641764
else {

t/t3701-add-interactive.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,4 +394,22 @@ test_expect_success 'diffs can be colorized' '
394394
grep "$(printf "\\033")" output
395395
'
396396

397+
test_expect_success 'patch-mode via -i prompts for files' '
398+
git reset --hard &&
399+
400+
echo one >file &&
401+
echo two >test &&
402+
git add -i <<-\EOF &&
403+
patch
404+
test
405+
406+
y
407+
quit
408+
EOF
409+
410+
echo test >expect &&
411+
git diff --cached --name-only >actual &&
412+
test_cmp expect actual
413+
'
414+
397415
test_done

0 commit comments

Comments
 (0)