aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-12-08 22:37:50 -0800
committerJunio C Hamano <gitster@pobox.com>2009-12-08 22:37:50 -0800
commita876433c5fc27cc14860dea3d608ab4e0ff62380 (patch)
treecfe391565fbf9c93b86ebd53f2d6b63bb99b6a74
parentaa031314bf8189a15290d5bd0d85fa2a0307ceb7 (diff)
parent8947fdd598848b8ceb2cea9ff42e906c946eae5c (diff)
downloadgit-a876433c5fc27cc14860dea3d608ab4e0ff62380.tar.gz
git-a876433c5fc27cc14860dea3d608ab4e0ff62380.tar.xz
Merge branch 'jk/maint-add-p-delete-fix' into maint
* jk/maint-add-p-delete-fix: add-interactive: fix deletion of non-empty files
-rwxr-xr-xgit-add--interactive.perl6
-rwxr-xr-xt/t3701-add-interactive.sh20
2 files changed, 25 insertions, 1 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 8ce1ec92c..75b71967a 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1217,7 +1217,11 @@ sub patch_update_file {
if (@{$mode->{TEXT}}) {
unshift @hunk, $mode;
}
- if (@{$deletion->{TEXT}} && !@hunk) {
+ if (@{$deletion->{TEXT}}) {
+ foreach my $hunk (@hunk) {
+ push @{$deletion->{TEXT}}, @{$hunk->{TEXT}};
+ push @{$deletion->{DISPLAY}}, @{$hunk->{DISPLAY}};
+ }
@hunk = ($deletion);
}
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index d86bc81ab..b6eba6a83 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -229,6 +229,26 @@ test_expect_success 'add first line works' '
'
cat >expected <<EOF
+diff --git a/non-empty b/non-empty
+deleted file mode 100644
+index d95f3ad..0000000
+--- a/non-empty
++++ /dev/null
+@@ -1 +0,0 @@
+-content
+EOF
+test_expect_success 'deleting a non-empty file' '
+ git reset --hard &&
+ echo content >non-empty &&
+ git add non-empty &&
+ git commit -m non-empty &&
+ rm non-empty &&
+ echo y | git add -p non-empty &&
+ git diff --cached >diff &&
+ test_cmp expected diff
+'
+
+cat >expected <<EOF
diff --git a/empty b/empty
deleted file mode 100644
index e69de29..0000000