<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/add-patch.c, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2026-04-07T21:59:26Z</updated>
<entry>
<title>Merge branch 'sp/add-patch-with-fewer-the-repository'</title>
<updated>2026-04-07T21:59:26Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2026-04-07T21:59:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fb5516997ef3f882d8e53ce70ba6077533683621'/>
<id>urn:sha1:fb5516997ef3f882d8e53ce70ba6077533683621</id>
<content type='text'>
Reduce dependency on `the_repository` in add-patch.c file.

* sp/add-patch-with-fewer-the-repository:
  add-patch: use repository instance from add_i_state instead of the_repository
</content>
</entry>
<entry>
<title>add-patch: use repository instance from add_i_state instead of the_repository</title>
<updated>2026-03-17T16:27:13Z</updated>
<author>
<name>Shreyansh Paliwal</name>
<email>shreyanshpaliwalcmsmn@gmail.com</email>
</author>
<published>2026-03-17T15:50:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3cfe355ca74aae5cf90a4eca73a341732b0eb456'/>
<id>urn:sha1:3cfe355ca74aae5cf90a4eca73a341732b0eb456</id>
<content type='text'>
Functions parse_diff(), edit_hunk_manually() and patch_update_file() use
the_repository even though a repository instance is already available via
struct add_i_state s which is defined in struct add_p_state *s.

Use 's-&gt;s.r' instead of the_repository to avoid relying on global state. All
callers pass a valid add_p_state and this does not change any behavior.

This aligns with the ongoing effort to reduce usage of the_repository global
state.

Signed-off-by: Shreyansh Paliwal &lt;shreyanshpaliwalcmsmn@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>add-patch: allow disabling editing of hunks</title>
<updated>2026-03-03T23:09:36Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-02T12:13:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=48f6d9232834be661f0d1dc4f187b324124ccbe0'/>
<id>urn:sha1:48f6d9232834be661f0d1dc4f187b324124ccbe0</id>
<content type='text'>
The "add-patch" mode allows the user to edit hunks to apply custom
changes. This is incompatible with a new `git history split` command
that we're about to introduce in a subsequent commit, so we need a way
to disable this mode.

Add a new flag to disable editing hunks.

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: add support for in-memory index patching</title>
<updated>2026-03-03T23:09:35Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-02T12:13:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0c5583a57d618db191afceeff54e8cafbee89f41'/>
<id>urn:sha1:0c5583a57d618db191afceeff54e8cafbee89f41</id>
<content type='text'>
With `run_add_p()` callers have the ability to apply changes from a
specific revision to a repository's index. This infra supports several
different modes, like for example applying changes to the index,
working tree or both.

One feature that is missing though is the ability to apply changes to an
in-memory index different from the repository's index. Add a new
function `run_add_p_index()` to plug this gap.

This new function will be used 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: remove dependency on "add-interactive" subsystem</title>
<updated>2026-03-03T23:09:35Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2026-03-02T12:13:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d51b61f5dab9c8e715fa792f31d572bc96fb5687'/>
<id>urn:sha1:d51b61f5dab9c8e715fa792f31d572bc96fb5687</id>
<content type='text'>
With the preceding commit we have split out interactive configuration
that is used by both "git add -p" and "git add -i". But we still
initialize that configuration in the "add -p" subsystem by calling
`init_add_i_state()`, even though we only do so to initialize the
interactive configuration as well as a repository pointer.

Stop doing so and instead store and initialize the interactive
configuration in `struct add_p_state` directly.

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 `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='https://git.shady.money/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='https://git.shady.money/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>Merge branch 'aa/add-p-no-auto-advance'</title>
<updated>2026-03-03T19:08:13Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2026-03-03T19:08:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a751e79acaf5a02cc24fa6b0b2656e13c57ad803'/>
<id>urn:sha1:a751e79acaf5a02cc24fa6b0b2656e13c57ad803</id>
<content type='text'>
"git add -p" learned a new mode that allows the user to revisit a
file that was already dealt with.

* aa/add-p-no-auto-advance:
  add-patch: allow interfile navigation when selecting hunks
  add-patch: allow all-or-none application of patches
  add-patch: modify patch_update_file() signature
  interactive -p: add new `--auto-advance` flag
</content>
</entry>
<entry>
<title>add-patch: allow interfile navigation when selecting hunks</title>
<updated>2026-02-17T18:48:37Z</updated>
<author>
<name>Abraham Samuel Adekunle</name>
<email>abrahamadekunle50@gmail.com</email>
</author>
<published>2026-02-14T11:06:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=417b181f99ce53f50dea6541430cfe1f1f359a6a'/>
<id>urn:sha1:417b181f99ce53f50dea6541430cfe1f1f359a6a</id>
<content type='text'>
After deciding on all hunks in a file, the interactive session
advances automatically to the next file if there is another,
or the process ends.

Now using the `--no-auto-advance` flag with `--patch`, the process
does not advance automatically. A user can choose to go to the next
file by pressing '&gt;' or the previous file by pressing '&lt;', before or
after deciding on all hunks in the current file.

After all hunks have been decided in a file, the user can still
rework with the file by applying the options available in the permit
set for that hunk, and after all the decisions, the user presses 'q'
to submit.
After all hunks have been decided, the user can press '?' which will
show the hunk selection summary in the help patch remainder text
including the total hunks, number of hunks marked for use and number
of hunks marked for skip.

This feature is enabled by passing the `--no-auto-advance` flag
to `--patch` option of the subcommands add, stash, reset,
and checkout.

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-patch: allow all-or-none application of patches</title>
<updated>2026-02-17T18:48:37Z</updated>
<author>
<name>Abraham Samuel Adekunle</name>
<email>abrahamadekunle50@gmail.com</email>
</author>
<published>2026-02-14T11:06:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d3cce5e76fcbce00d33013424bece954f11fa2f3'/>
<id>urn:sha1:d3cce5e76fcbce00d33013424bece954f11fa2f3</id>
<content type='text'>
When the flag `--no-auto-advance` is used with `--patch`,
if the user has decided `USE` on a hunk in a file, goes to another
file, and then returns to this file and changes the previous
decision on the hunk to `SKIP`, because the patch has already
been applied, the last decision is not registered and the now
SKIPPED hunk is still applied.

Move the logic for applying patches into a function so that we can
reuse this logic to implement the all or non application of the patches
after the user is done with the hunk selection.

Signed-off-by: Abraham Samuel Adekunle &lt;abrahamadekunle50@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
