diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2024-07-20 16:01:59 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-07-20 16:29:14 -0700 |
commit | 39bdd84eaf646aa73a3709b0eb8be3f47378708f (patch) | |
tree | c08b998aceb46bf881b76ed23525f262a1b4801d /builtin/commit.c | |
parent | 337b4d400023d22207bcc3c29e9ebab31bf96fc2 (diff) |
add-patch: handle splitting hunks with diff.suppressBlankEmpty
When "add -p" parses diffs, it looks for context lines starting with a
single space. But when diff.suppressBlankEmpty is in effect, an empty
context line will omit the space, giving us a true empty line. This
confuses the parser, which is unable to split based on such a line.
It's tempting to say that we should just make sure that we generate a
diff without that option. However, although we do not parse hunks that
the user has manually edited with parse_diff() we do allow the user
to split such hunks. As POSIX calls the decision of whether to print the
space here "implementation-defined" we need to handle edited hunks where
empty context lines omit the space.
So let's handle both cases: a context line either starts with a space or
consists of a totally empty line by normalizing the first character to a
space when we parse them. Normalizing the first character rather than
changing the code to check for a space or newline will hopefully future
proof against introducing similar bugs if the code is changed.
Reported-by: Ilya Tumaykin <itumaykin@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
0 files changed, 0 insertions, 0 deletions