fixup! built-in add -p: implement the hunk splitting feature

A recently-reported bug had its root cause in the `splittable_into`
variable overcounting the number of potential hunks (the symptom was
misleading, it said that there was an unhandled diff marker).

Let's make sure to catch these things earlier, with a less misleading
error message.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2019-10-24 12:13:52 +02:00
parent c59445a882
commit 098aa7740b

View File

@@ -853,6 +853,10 @@ static int split_hunk(struct add_p_state *s, struct file_diff *file_diff,
while (splittable_into > 1) {
ch = s->plain.buf[current];
if (!ch)
BUG("buffer overrun while splitting hunks");
if ((marker == '-' || marker == '+') && ch == ' ') {
first = 0;
hunk[1].start = current;