author | Junio C Hamano <gitster@pobox.com> | |
Mon, 8 Mar 2010 08:36:00 +0000 (00:36 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 8 Mar 2010 08:36:00 +0000 (00:36 -0800) |
* jk/maint-add--interactive-delete:
add-interactive: fix bogus diff header line ordering
add-interactive: fix bogus diff header line ordering
1 | 2 | |||
---|---|---|---|---|
git-add--interactive.perl | patch | | diff1 | | diff2 | | blob | history |
diff --combined git-add--interactive.perl
index cd43c3491260cb2aa51f0d19fd18ab66e4ad8217,7493e68b8430c2dc3e3c707a5db59179e69a11d8..21f1330a5bf26c955051ce9cf263289d90c7667b
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 :
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) {
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();