зеркало из https://github.com/microsoft/git.git
Merge branch 'jk/maint-add--interactive-delete'
* jk/maint-add--interactive-delete: add-interactive: fix bogus diff header line ordering
This commit is contained in:
Коммит
9382587467
|
@ -957,6 +957,28 @@ sub coalesce_overlapping_hunks {
|
||||||
return @out;
|
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 {
|
sub color_diff {
|
||||||
return map {
|
return map {
|
||||||
colored((/^@/ ? $fraginfo_color :
|
colored((/^@/ ? $fraginfo_color :
|
||||||
|
@ -1453,7 +1475,7 @@ sub patch_update_file {
|
||||||
|
|
||||||
if (@result) {
|
if (@result) {
|
||||||
my $fh;
|
my $fh;
|
||||||
my @patch = (@{$head->{TEXT}}, @result);
|
my @patch = reassemble_patch($head->{TEXT}, @result);
|
||||||
my $apply_routine = $patch_mode_flavour{APPLY};
|
my $apply_routine = $patch_mode_flavour{APPLY};
|
||||||
&$apply_routine(@patch);
|
&$apply_routine(@patch);
|
||||||
refresh();
|
refresh();
|
||||||
|
|
|
@ -66,6 +66,14 @@ test_expect_success 'git checkout -p HEAD^' '
|
||||||
verify_state dir/foo parent parent
|
verify_state dir/foo parent parent
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git checkout -p handles deletion' '
|
||||||
|
set_state dir/foo work index &&
|
||||||
|
rm dir/foo &&
|
||||||
|
(echo n; echo y) | git checkout -p &&
|
||||||
|
verify_saved_state bar &&
|
||||||
|
verify_state dir/foo index index
|
||||||
|
'
|
||||||
|
|
||||||
# The idea in the rest is that bar sorts first, so we always say 'y'
|
# The idea in the rest is that bar sorts first, so we always say 'y'
|
||||||
# first and if the path limiter fails it'll apply to bar instead of
|
# first and if the path limiter fails it'll apply to bar instead of
|
||||||
# dir/foo. There's always an extra 'n' to reject edits to dir/foo in
|
# dir/foo. There's always an extra 'n' to reject edits to dir/foo in
|
||||||
|
|
Загрузка…
Ссылка в новой задаче