X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=git-add--interactive.perl;h=27fc79347af428dd39daa5b550814cc6cf980510;hb=7e7db5e4520388d3a6f1efbe2f7a29d43bd06a2b;hp=cd43c3491260cb2aa51f0d19fd18ab66e4ad8217;hpb=ad336054068074ed614d0bb54bb169e5263499d7;p=git.git diff --git a/git-add--interactive.perl b/git-add--interactive.perl index cd43c3491..27fc79347 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -957,6 +957,28 @@ sub coalesce_overlapping_hunks { return @out; } +sub reassemble_patch { + my $head = shift; + my @patch; + + # Include everything in the header except the beginning of the diff. + push @patch, (grep { !/^[-+]{3}/ } @$head); + + # Then include any headers from the hunk lines, which must + # come before any actual hunk. + while (@_ && $_[0] !~ /^@/) { + push @patch, shift; + } + + # Then begin the diff. + push @patch, grep { /^[-+]{3}/ } @$head; + + # And then the actual hunks. + push @patch, @_; + + return @patch; +} + sub color_diff { return map { colored((/^@/ ? $fraginfo_color : @@ -1089,9 +1111,9 @@ sub help_patch_cmd { print colored $help_color, <{TEXT}}, @result); + my @patch = reassemble_patch($head->{TEXT}, @result); my $apply_routine = $patch_mode_flavour{APPLY}; &$apply_routine(@patch); refresh();