Merge branch 'pw/add-p-select' into next
authorJunio C Hamano <gitster@pobox.com>
Fri, 30 Mar 2018 19:42:06 +0000 (12:42 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 Mar 2018 19:42:06 +0000 (12:42 -0700)
"git add -p" interactive interface learned to let users choose
individual added/removed lines to be used in the operation, instead
of accepting or rejecting a whole hunk.

* pw/add-p-select:
add -p: optimize line selection for short hunks
add -p: allow line selection to be inverted
add -p: select individual hunk lines

1  2 
git-add--interactive.perl
t/t3701-add-interactive.sh
index d190469cd8b5e1dc427b4029d0d1fb937faef584,86e373a1011e012c2fd349fca2b85866ef599dfb..cb48fc3e8e1e046a1076826bddc04ae298a9a9e5
@@@ -1632,11 -1779,19 +1801,23 @@@ sub patch_update_file 
                                        next;
                                }
                        }
 -                      elsif ($other =~ /s/ && $line =~ /^s/) {
+                       elsif ($line =~ /^l/) {
+                               unless ($other =~ /l/) {
+                                       error_msg __("Cannot select line by line\n");
+                                       next;
+                               }
+                               my $newhunk = select_lines_loop($hunk[$ix]);
+                               if ($newhunk) {
+                                       splice @hunk, $ix, 1, $newhunk;
+                               } else {
+                                       next;
+                               }
+                       }
 +                      elsif ($line =~ /^s/) {
 +                              unless ($other =~ /s/) {
 +                                      error_msg __("Sorry, cannot split this hunk\n");
 +                                      next;
 +                              }
                                my @split = split_hunk($hunk[$ix]{TEXT}, $hunk[$ix]{DISPLAY});
                                if (1 < @split) {
                                        print colored $header_color, sprintf(
Simple merge