From: Junio C Hamano Date: Mon, 8 Mar 2010 08:36:00 +0000 (-0800) Subject: Merge branch 'jk/maint-add--interactive-delete' into maint X-Git-Tag: v1.7.0.3~28 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/919451330b55366ac207e575c1982bc8fa5220ed?ds=inline;hp=-c Merge branch 'jk/maint-add--interactive-delete' into maint * jk/maint-add--interactive-delete: add-interactive: fix bogus diff header line ordering --- 919451330b55366ac207e575c1982bc8fa5220ed diff --combined git-add--interactive.perl index cd43c34912,7493e68b84..21f1330a5b --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@@ -957,6 -957,28 +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 : @@@ -990,7 -1012,8 +1012,7 @@@ sub edit_hunk_manually EOF close $fh; - my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor") - || $ENV{VISUAL} || $ENV{EDITOR} || "vi"; + chomp(my $editor = run_cmd_pipe(qw(git var GIT_EDITOR))); system('sh', '-c', $editor.' "$@"', $editor, $hunkfile); if ($? != 0) { @@@ -1453,7 -1476,7 +1475,7 @@@ sub patch_update_file if (@result) { my $fh; - my @patch = (@{$head->{TEXT}}, @result); + my @patch = reassemble_patch($head->{TEXT}, @result); my $apply_routine = $patch_mode_flavour{APPLY}; &$apply_routine(@patch); refresh();