]> git.ipfire.org Git - thirdparty/git.git/commit
add -p: gracefully handle unparseable hunk headers in colored diffs
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 1 Sep 2022 15:42:18 +0000 (15:42 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Sep 2022 16:55:21 +0000 (09:55 -0700)
commitfd3f7f619aa97ce577b29a19cfd056e20680f62a
tree7ee7aa26e653844ec8bfd24f662d2d50cc1d810e
parentb6633a005384a8c120d34a8a79a5a5fe9d8719d7
add -p: gracefully handle unparseable hunk headers in colored diffs

In
https://lore.kernel.org/git/ecf6f5be-22ca-299f-a8f1-bda38e5ca246@gmail.com,
Phillipe Blain reported that the built-in `git add -p` command fails
when asked to use [`diff-so-fancy`][diff-so-fancy] to colorize the diff.

The reason is that this tool produces colored diffs with a hunk header
that does not contain any parseable `@@ ... @@` line range information,
and therefore we cannot detect any part in that header that comes after
the line range.

As proposed by Phillip Wood, let's take that for a clear indicator that
we should show the hunk headers verbatim. This is what the Perl version
of the interactive `add` command did, too.

[diff-so-fancy]: https://github.com/so-fancy/diff-so-fancy

Reported-by: Philippe Blain <levraiphilippeblain@gmail.com>
Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
add-patch.c
t/t3701-add-interactive.sh