From: Junio C Hamano Date: Fri, 30 Mar 2018 19:42:06 +0000 (-0700) Subject: Merge branch 'pw/add-p-select' into next X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/eae69f5ded514f6c7a961372f0dd67e6429e861c Merge branch 'pw/add-p-select' into next "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 --- eae69f5ded514f6c7a961372f0dd67e6429e861c diff --cc git-add--interactive.perl index d190469cd8,86e373a101..cb48fc3e8e --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@@ -1632,11 -1779,19 +1801,23 @@@ sub patch_update_file next; } } + 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 ($other =~ /s/ && $line =~ /^s/) { + 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(