aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xdiff/xpatience.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/xdiff/xpatience.c b/xdiff/xpatience.c
index 77dc411d19..d4094e6acf 100644
--- a/xdiff/xpatience.c
+++ b/xdiff/xpatience.c
@@ -211,7 +211,10 @@ static int find_longest_common_sequence(struct hashmap *map, struct entry **res)
for (entry = map->first; entry; entry = entry->next) {
if (!entry->line2 || entry->line2 == NON_UNIQUE)
continue;
- i = binary_search(sequence, longest, entry);
+ if (longest == 0 || entry->line2 > sequence[longest - 1]->line2)
+ i = longest - 1;
+ else
+ i = binary_search(sequence, longest, entry);
entry->previous = i < 0 ? NULL : sequence[i];
++i;
if (i <= anchor_i)