summaryrefslogtreecommitdiff
path: root/git-add--interactive.perl
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-11-15 16:40:46 -0800
committerJunio C Hamano <gitster@pobox.com>2009-11-15 16:40:46 -0800
commit3176bd0b0da232207df99802bd714f51bc10f153 (patch)
tree9fb8a4d8c2a905dbb6811814c01feb11e5d6e082 /git-add--interactive.perl
parent578e5efd46efdacd4b48cb2e72b007f72de3cd9b (diff)
parent24ab81ae4d12c81076da256b3f9cdde45277f126 (diff)
downloadgit-3176bd0b0da232207df99802bd714f51bc10f153.tar.gz
Merge branch 'jk/maint-add-p-empty'
* jk/maint-add-p-empty: add-interactive: handle deletion of empty files
Diffstat (limited to 'git-add--interactive.perl')
-rwxr-xr-xgit-add--interactive.perl18
1 files changed, 13 insertions, 5 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 69aeaf03ec..8ce1ec92c2 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -731,14 +731,17 @@ sub parse_diff_header {
my $head = { TEXT => [], DISPLAY => [], TYPE => 'header' };
my $mode = { TEXT => [], DISPLAY => [], TYPE => 'mode' };
+ my $deletion = { TEXT => [], DISPLAY => [], TYPE => 'deletion' };
for (my $i = 0; $i < @{$src->{TEXT}}; $i++) {
- my $dest = $src->{TEXT}->[$i] =~ /^(old|new) mode (\d+)$/ ?
- $mode : $head;
+ my $dest =
+ $src->{TEXT}->[$i] =~ /^(old|new) mode (\d+)$/ ? $mode :
+ $src->{TEXT}->[$i] =~ /^deleted file/ ? $deletion :
+ $head;
push @{$dest->{TEXT}}, $src->{TEXT}->[$i];
push @{$dest->{DISPLAY}}, $src->{DISPLAY}->[$i];
}
- return ($head, $mode);
+ return ($head, $mode, $deletion);
}
sub hunk_splittable {
@@ -1206,7 +1209,7 @@ sub patch_update_file {
my ($ix, $num);
my $path = shift;
my ($head, @hunk) = parse_diff($path);
- ($head, my $mode) = parse_diff_header($head);
+ ($head, my $mode, my $deletion) = parse_diff_header($head);
for (@{$head->{DISPLAY}}) {
print;
}
@@ -1214,6 +1217,9 @@ sub patch_update_file {
if (@{$mode->{TEXT}}) {
unshift @hunk, $mode;
}
+ if (@{$deletion->{TEXT}} && !@hunk) {
+ @hunk = ($deletion);
+ }
$num = scalar @hunk;
$ix = 0;
@@ -1267,7 +1273,9 @@ sub patch_update_file {
print;
}
print colored $prompt_color, $patch_mode_flavour{VERB},
- ($hunk[$ix]{TYPE} eq 'mode' ? ' mode change' : ' this hunk'),
+ ($hunk[$ix]{TYPE} eq 'mode' ? ' mode change' :
+ $hunk[$ix]{TYPE} eq 'deletion' ? ' deletion' :
+ ' this hunk'),
$patch_mode_flavour{TARGET},
" [y,n,q,a,d,/$other,?]? ";
my $line = prompt_single_character;