<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/add-interactive.h, branch main</title>
<subtitle>Fork of git SCM with my patches.</subtitle>
<id>http://git.kilabit.info/git/atom?h=main</id>
<link rel='self' href='http://git.kilabit.info/git/atom?h=main'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/'/>
<updated>2026-03-03T23:09:35Z</updated>
<entry>
<title>add-patch: split out `struct interactive_options`</title>
<updated>2026-03-03T23:09:35Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-02T12:13:06Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=e3d4d7787cc3b2f0281e808042ceaa08e05c281b'/>
<id>urn:sha1:e3d4d7787cc3b2f0281e808042ceaa08e05c281b</id>
<content type='text'>
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 &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>add-patch: split out header from "add-interactive.h"</title>
<updated>2026-03-03T23:09:34Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-02T12:13:05Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=6e4d923267ca80dd1392bf7e0673c74711e8cb68'/>
<id>urn:sha1:6e4d923267ca80dd1392bf7e0673c74711e8cb68</id>
<content type='text'>
While we have a "add-patch.c" code file, its declarations are part of
"add-interactive.h". This makes it somewhat harder than necessary to
find relevant code and to identify clear boundaries between the two
subsystems.

Split up concerns and move declarations that relate to "add-patch.c"
into a new "add-patch.h" header.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>interactive -p: add new `--auto-advance` flag</title>
<updated>2026-02-17T18:48:36Z</updated>
<author>
<name>Abraham Samuel Adekunle</name>
<email>abrahamadekunle50@gmail.com</email>
</author>
<published>2026-02-14T11:03:54Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=06c81a1118a6c9a77505b0ae3092576fa4c01763'/>
<id>urn:sha1:06c81a1118a6c9a77505b0ae3092576fa4c01763</id>
<content type='text'>
When using the interactive add, reset, stash or checkout machinery,
we do not have the option of reworking with a file when selecting
hunks, because the session automatically advances to the next file
or ends if we have just one file.

Introduce the flag `--auto-advance` which auto advances by default,
when interactively selecting patches with the '--patch' option.
However, the `--no-auto-advance` option does not auto advance, thereby
allowing users the option to rework with files.

Signed-off-by: Abraham Samuel Adekunle &lt;abrahamadekunle50@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>add-interactive: retain colorbool values longer</title>
<updated>2025-09-17T01:00:25Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2025-09-16T20:26:24Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=9d241b01132c17a44adda2d762b37adf3625bdd7'/>
<id>urn:sha1:9d241b01132c17a44adda2d762b37adf3625bdd7</id>
<content type='text'>
Most of the diff code stores the decision about whether to show color as
a git_colorbool, and evaluates it at point-of-use with want_color().
This timing is important for reasons explained in daa0c3d971 (color:
delay auto-color decision until point of use, 2011-08-17).

The add-interactive code instead converts immediately to strict boolean
values using want_color(), and then evaluates those. This isn't wrong.
Even though we pass the bool values to diff_use_color(), which expects a
colorbool, the values are compatible. But it is unlike the rest of the
color code, and is questionable from a type-system perspective (but C's
typing between enums, ints, and bools is weak enough that the compiler
does not complain).

Let's switch it to the more usual way of calling want_color() at the
point of use.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>add-interactive: respect color.diff for diff coloring</title>
<updated>2025-09-08T21:00:32Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2025-09-08T16:42:36Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=8c78b5c8bc42728dcc8a527401955b7d1089e667'/>
<id>urn:sha1:8c78b5c8bc42728dcc8a527401955b7d1089e667</id>
<content type='text'>
The old perl git-add--interactive.perl script used the color.diff config
option to decide whether to color diffs (and if not set, it fell back to
the value of color.ui via git-config's --get-colorbool option). When we
switched to the builtin version, this was lost: we respect only
color.ui. So for example:

  git -c color.diff=false add -p

would color the diff, even when it should not.

The culprit is this line in add-interactive.c's parse_diff():

  if (want_color_fd(1, -1))

That "-1" means "no config has been set", which causes it to fall back
to the color.ui setting. We should instead be passing the value of
color.diff. But the problem is that we never even parse that config
option!

Instead the builtin interactive code parses only the value of
color.interactive, which is used for prompts and other messages. One
could perhaps argue that this should cover interactive diff coloring,
too, but historically it did not. The perl script treated
color.interactive and color.diff separately. So we should grab the
values for both, keeping separate fields in our add_i_state variable,
rather than a single use_color field.

We also load individual color slots (e.g., color.interactive.prompt),
leaving them as the empty string when color is disabled. This happens
via the init_color() helper in add-interactive, which checks that
use_color field. Now that there are two such fields, we need to pass the
appropriate one for each color.

The colors are mostly easy to divide up; color.interactive.* follows
color.interactive, and color.diff.* follows color.diff. But the "reset"
color is tricky. It is used for both types of coloring, but the two can
be configured independently. So we introduce two separate reset colors,
and use each in the appropriate spot.

There are two new tests. The first enables interactive prompt colors but
disables color.diff. We should see a colored prompt but not a colored
diff, showing that we are now respecting color.diff (and not
color.interactive or color.ui).

The second does the opposite. We disable color.interactive but turn on
color.diff with a custom fragment color. When we split a hunk, the
interactive code has to re-color the hunk header, which lets us check
that we correctly loaded the color.diff.frag config based on color.diff,
not color.interactive.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>add-patch: add diff.context command line overrides</title>
<updated>2025-07-29T15:52:45Z</updated>
<author>
<name>Leon Michalak</name>
<email>leonmichalak6@gmail.com</email>
</author>
<published>2025-07-29T07:01:51Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=2b3ae04011c3d679ba601c7ef9e20b9dec125ebb'/>
<id>urn:sha1:2b3ae04011c3d679ba601c7ef9e20b9dec125ebb</id>
<content type='text'>
This patch compliments the previous commit, where builtins that use
add-patch infrastructure now respect diff.context and
diff.interHunkContext file configurations.

In particular, this patch helps users who don't want to set persistent
context configurations or just want a way to override them on a one-time
basis, by allowing the relevant builtins to accept corresponding command
line options that override the file configurations.

This mimics commands such as diff and log, which allow for both context
file configuration and command line overrides.

Signed-off-by: Leon Michalak &lt;leonmichalak6@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>add-patch: respect diff.context configuration</title>
<updated>2025-07-29T15:52:45Z</updated>
<author>
<name>Leon Michalak</name>
<email>leonmichalak6@gmail.com</email>
</author>
<published>2025-07-29T07:01:50Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=2b0a2db2c0bf4870592656e8f50876957db8660c'/>
<id>urn:sha1:2b0a2db2c0bf4870592656e8f50876957db8660c</id>
<content type='text'>
Various builtins that use add-patch infrastructure do not respect
the user's diff.context and diff.interHunkContext file configurations.

The user may be used to seeing their diffs with customized context size,
but not in the patches "git add -p" shows them to pick from.

Teach add-patch infrastructure to read these configuration variables and
pass their values when spawning the underlying plumbing commands as
their command line option.

Signed-off-by: Leon Michalak &lt;leonmichalak6@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>built-in add -p: respect the `interactive.singlekey` config setting</title>
<updated>2020-01-15T20:06:17Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-01-14T18:43:50Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=04f816b125dc2649e70aad686d79b05bdc1d1c61'/>
<id>urn:sha1:04f816b125dc2649e70aad686d79b05bdc1d1c61</id>
<content type='text'>
The Perl version of `git add -p` supports this config setting to allow
users to input commands via single characters (as opposed to having to
press the &lt;Enter&gt; key afterwards).

This is an opt-in feature because it requires Perl packages
(Term::ReadKey and Term::Cap, where it tries to handle an absence of the
latter package gracefully) to work. Note that at least on Ubuntu, that
Perl package is not installed by default (it needs to be installed via
`sudo apt-get install libterm-readkey-perl`), so this feature is
probably not used a whole lot.

In C, we obviously do not have these packages available, but we just
introduced `read_single_keystroke()` that is similar to what
Term::ReadKey provides, and we use that here.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>built-in add -p: handle diff.algorithm</title>
<updated>2020-01-15T20:06:16Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-01-14T18:43:46Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=08b1ea4c39b08b76fe2d1240ccbf6077ef19226a'/>
<id>urn:sha1:08b1ea4c39b08b76fe2d1240ccbf6077ef19226a</id>
<content type='text'>
The Perl version of `git add -p` reads the config setting
`diff.algorithm` and if set, uses it to generate the diff using the
specified algorithm.

This patch ports that functionality to the C version.

Note: just like `git-add--interactive.perl`, we do _not_ respect this
config setting in `git add -i`'s `diff` command, but _only_ in the
`patch` command.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>built-in add -p: support interactive.diffFilter</title>
<updated>2020-01-15T20:06:16Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-01-14T18:43:45Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=180f48df69d8e7a1a413d7c11907ecf975f09cf7'/>
<id>urn:sha1:180f48df69d8e7a1a413d7c11907ecf975f09cf7</id>
<content type='text'>
The Perl version supports post-processing the colored diff (that is
generated in addition to the uncolored diff, intended to offer a
prettier user experience) by a command configured via that config
setting, and now the built-in version does that, too.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
