summaryrefslogtreecommitdiff
path: root/t/t3701-add-interactive.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-04-29 12:41:16 -0700
committerJunio C Hamano <gitster@pobox.com>2011-04-29 15:26:41 -0700
commitf3217e2b1791580ce6499b800e93989d312f9718 (patch)
tree90427075ad932ea9d69b5e6c8749c77b83a30405 /t/t3701-add-interactive.sh
parentf5ea3f2bb30bf912d0021ef6a77e772ccdb4f8fd (diff)
downloadgit-f3217e2b1791580ce6499b800e93989d312f9718.tar.gz
t3701: Editing a split hunk in an "add -p" session
Arnaud Lacombe reported that with the recent change to reject overlapping hunks fed to "git apply", the edit mode of an "add -p" session that lazily feeds overlapping hunks without coalescing adjacent ones claim that the patch does not apply. Expose the problem to be fixed. Cf. http://thread.gmane.org/gmane.comp.version-control.git/170685/focus=171000 Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3701-add-interactive.sh')
-rwxr-xr-xt/t3701-add-interactive.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index d6327e7c74..72559e1b01 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -295,4 +295,40 @@ test_expect_success PERL 'deleting an empty file' '
test_cmp expected diff
'
+test_expect_success PERL 'split hunk setup' '
+ git reset --hard &&
+ for i in 10 20 30 40 50 60
+ do
+ echo $i
+ done >test &&
+ git add test &&
+ test_tick &&
+ git commit -m test &&
+
+ for i in 10 15 20 21 22 23 24 30 40 50 60
+ do
+ echo $i
+ done >test
+'
+
+test_expect_failure PERL 'split hunk "add -p (edit)"' '
+ # Split, say Edit and do nothing. Then:
+ #
+ # 1. Broken version results in a patch that does not apply and
+ # only takes [y/n] (edit again) so the first q is discarded
+ # and then n attempts to discard the edit. Repeat q enough
+ # times to get out.
+ #
+ # 2. Correct version applies the (not)edited version, and asks
+ # about the next hunk, against wich we say q and program
+ # exits.
+ for a in s e q n q q
+ do
+ echo $a
+ done |
+ EDITOR=: git add -p &&
+ git diff >actual &&
+ ! grep "^+15" actual
+'
+
test_done