summaryrefslogtreecommitdiff
path: root/builtin-apply.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin-apply.c')
-rw-r--r--builtin-apply.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/builtin-apply.c b/builtin-apply.c
index e046e87..dc650f1 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1579,6 +1579,16 @@ static int find_pos(struct image *img,
if (preimage->nr > img->nr)
return -1;
+ /*
+ * If match_begining 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.
+ */
+ if (match_beginning)
+ line = 0;
+ else if (match_end)
+ line = img->nr - preimage->nr;
+
try = 0;
for (i = 0; i < line; i++)
try += img->line[i].len;