builtin: patch-id: add --verbatim as a command mode
commit2871f4d447214874e13cf764ab3a170c9d844ca2
authorJerry Zhang <jerry@skydio.com>
Mon, 24 Oct 2022 20:07:43 +0000 (24 20:07 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Oct 2022 22:44:20 +0000 (24 15:44 -0700)
treea39a34152a3d1fd6732132fc602c191ef360ea99
parent93105aba6c4c8608b10c8ebe14b2313b3d347124
builtin: patch-id: add --verbatim as a command mode

There are situations where the user might not want the default
setting where patch-id strips all whitespace. They might be working
in a language where white space is syntactically important, or they
might have CI testing that enforces strict whitespace linting. In
these cases, a whitespace change would result in the patch
fundamentally changing, and thus deserving of a different id.

Add a new mode that is exclusive of --stable and --unstable called
--verbatim. It also corresponds to the config
patchid.verbatim = true. In this mode, the stable algorithm is
used and whitespace is not stripped from the patch text.

Users of --unstable mainly care about compatibility with old git
versions, which unstripping the whitespace would break. Thus there
isn't a usecase for the combination of --verbatim and --unstable,
and we don't expose this so as to not add maintainence burden.

Signed-off-by: Jerry Zhang <jerry@skydio.com>
fixes https://github.com/Skydio/revup/issues/2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-patch-id.txt
builtin/patch-id.c
t/t4204-patch-id.sh