summaryrefslogtreecommitdiffstats
path: root/apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-12-16 22:08:47 +0100
committerJunio C Hamano <gitster@pobox.com>2019-12-16 22:08:47 +0100
commit011fc2e88e9ab13760c571330737ffaf0986e4ef (patch)
treed3a9036fdd1c30284ca1bd6829dfdeef9201b093 /apply.c
parentMerge branch 'dl/range-diff-with-notes' (diff)
parentapply --allow-overlap: fix a corner case (diff)
downloadgit-011fc2e88e9ab13760c571330737ffaf0986e4ef.tar.xz
git-011fc2e88e9ab13760c571330737ffaf0986e4ef.zip
Merge branch 'js/add-i-a-bit-more-tests'
Test coverage update in preparation for further work on "git add -i". * js/add-i-a-bit-more-tests: apply --allow-overlap: fix a corner case git add -p: use non-zero exit code when the diff generation failed t3701: verify that the diff.algorithm config setting is handled t3701: verify the shown messages when nothing can be added t3701: add a test for the different `add -p` prompts t3701: avoid depending on the TTY prerequisite t3701: add a test for advanced split-hunk editing
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/apply.c b/apply.c
index b5485ef6c9..fab44322c5 100644
--- a/apply.c
+++ b/apply.c
@@ -2662,6 +2662,16 @@ static int find_pos(struct apply_state *state,
int backwards_lno, forwards_lno, current_lno;
/*
+ * When running with --allow-overlap, it is possible that a hunk is
+ * seen that pretends to start at the beginning (but no longer does),
+ * and that *still* needs to match the end. So trust `match_end` more
+ * than `match_beginning`.
+ */
+ if (state->allow_overlap && match_beginning && match_end &&
+ img->nr - preimage->nr != 0)
+ match_beginning = 0;
+
+ /*
* If match_beginning or match_end is specified, there is no
* point starting from a wrong line that will never match and
* wander around and wait for a match at the specified end.