]> git.ipfire.org Git - thirdparty/git.git/commit
checkout: cleanup --conflict=<style> parsing
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Thu, 14 Mar 2024 17:05:06 +0000 (17:05 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Mar 2024 17:08:53 +0000 (10:08 -0700)
commitdbeaf8e8c0ada5ba6a8c379e2ad7bab7e815ba79
tree745aa54b762f090041e445896e7410d66506af38
parent135cc712c39fa7ccf25b9b2b55d1d07fc85c85a4
checkout: cleanup --conflict=<style> parsing

Passing an invalid conflict style name such as "--conflict=bad" gives
the error message

    error: unknown style 'bad' given for 'merge.conflictstyle'

which is unfortunate as it talks about a config setting rather than
the option given on the command line. This happens because the
implementation calls git_xmerge_config() to set the conflict style
using the value given on the command line. Use the newly added
parse_conflict_style_name() instead and pass the value down the call
chain to override the config setting. This also means we can avoid
setting up a struct config_context required for calling
git_xmerge_config().

The option is now parsed in a callback to avoid having to store the
option name. This is a change in behavior as now

    git checkout --conflict=bad --conflict=diff3

will error out when parsing "--conflict=bad" whereas before this change
it would succeed because it would only try to parse the value of the
last "--conflict" option given on the command line.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c
t/t7201-co.sh