]> Kevux Git Server - rit/commit
add-patch: split out `struct interactive_options`
authorPatrick Steinhardt <ps@pks.im>
Mon, 2 Mar 2026 12:13:06 +0000 (13:13 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Mar 2026 23:09:35 +0000 (15:09 -0800)
commite3d4d7787cc3b2f0281e808042ceaa08e05c281b
tree040acc1ed301c750b52ee06c4e8b1259579af153
parent6e4d923267ca80dd1392bf7e0673c74711e8cb68
add-patch: split out `struct interactive_options`

The `struct add_p_opt` is reused both by our infra for "git add -p" and
"git add -i". Users of `run_add_i()` for example are expected to pass
`struct add_p_opt`. This is somewhat confusing and raises the question
of which options apply to what part of the stack.

But things are even more confusing than that: while callers are expected
to pass in `struct add_p_opt`, these options ultimately get used to
initialize a `struct add_i_state` that is used by both subsystems. So we
are basically going full circle here.

Refactor the code and split out a new `struct interactive_options` that
hosts common options used by both. These options are then applied to a
`struct interactive_config` that hosts common configuration.

This refactoring doesn't yet fully detangle the two subsystems from one
another, as we still end up calling `init_add_i_state()` in the "git add
-p" subsystem. This will be fixed in a subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
add-interactive.c
add-interactive.h
add-patch.c
add-patch.h
builtin/add.c
builtin/checkout.c
builtin/commit.c
builtin/reset.c
builtin/stash.c
commit.h