<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/add-patch.c, branch v2.51.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.51.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.51.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2025-09-08T21:00:32Z</updated>
<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='https://git.shady.money/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='https://git.shady.money/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='https://git.shady.money/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>pager: stop using `the_repository`</title>
<updated>2024-12-18T18:44:30Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-12-17T06:43:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=59b6131a677b0b45fb7fd54ba60dbf689b0a1797'/>
<id>urn:sha1:59b6131a677b0b45fb7fd54ba60dbf689b0a1797</id>
<content type='text'>
Stop using `the_repository` in the "pager" subsystem by passing in a
repository when setting up the pager and when configuring it.

Adjust callers accordingly by using `the_repository`. While there may be
some callers that have a repository available in their context, this
trivial conversion allows for easier verification and bubbles up the use
of `the_repository` by one level.

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>global: mark code units that generate warnings with `-Wsign-compare`</title>
<updated>2024-12-06T11:20:02Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-12-06T10:27:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=41f43b8243f42b9df2e98be8460646d4c0100ad3'/>
<id>urn:sha1:41f43b8243f42b9df2e98be8460646d4c0100ad3</id>
<content type='text'>
Mark code units that generate warnings with `-Wsign-compare`. This
allows for a structured approach to get rid of all such warnings over
time in a way that can be easily measured.

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 'ps/config-wo-the-repository'</title>
<updated>2024-08-23T16:02:34Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-08-23T16:02:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5e56a39e6a9b8621e62f7a18ed027777a095dba7'/>
<id>urn:sha1:5e56a39e6a9b8621e62f7a18ed027777a095dba7</id>
<content type='text'>
Use of API functions that implicitly depend on the_repository
object in the config subsystem has been rewritten to pass a
repository object through the callchain.

* ps/config-wo-the-repository:
  config: hide functions using `the_repository` by default
  global: prepare for hiding away repo-less config functions
  config: don't depend on `the_repository` with branch conditions
  config: don't have setters depend on `the_repository`
  config: pass repo to functions that rename or copy sections
  config: pass repo to `git_die_config()`
  config: pass repo to `git_config_get_expiry_in_days()`
  config: pass repo to `git_config_get_expiry()`
  config: pass repo to `git_config_get_max_percent_split_change()`
  config: pass repo to `git_config_get_split_index()`
  config: pass repo to `git_config_get_index_threads()`
  config: expose `repo_config_clear()`
  config: introduce missing setters that take repo as parameter
  path: hide functions using `the_repository` by default
  path: stop relying on `the_repository` in `worktree_git_path()`
  path: stop relying on `the_repository` when reporting garbage
  hooks: remove implicit dependency on `the_repository`
  editor: do not rely on `the_repository` for interactive edits
  path: expose `do_git_common_path()` as `repo_common_pathv()`
  path: expose `do_git_path()` as `repo_git_pathv()`
</content>
</entry>
<entry>
<title>editor: do not rely on `the_repository` for interactive edits</title>
<updated>2024-08-13T17:01:00Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-08-13T09:13:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=419dbb29d82b78bcaf0ff22ac7d5db7d1c327575'/>
<id>urn:sha1:419dbb29d82b78bcaf0ff22ac7d5db7d1c327575</id>
<content type='text'>
We implicitly rely on `the_repository` when editing a file interactively
because we call `git_path()`. Adapt the function to instead take a
`struct repository` as a parameter so that we can remove this hidden
dependency.

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 'rj/add-p-pager'</title>
<updated>2024-08-08T17:41:18Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-08-08T17:41:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d70f3208bc77a4daf3d269cd9579a1df135b7dc6'/>
<id>urn:sha1:d70f3208bc77a4daf3d269cd9579a1df135b7dc6</id>
<content type='text'>
A 'P' command to "git add -p" that passes the patch hunk to the
pager has been added.

* rj/add-p-pager:
  add-patch: render hunks through the pager
  pager: introduce wait_for_pager
  pager: do not close fd 2 unnecessarily
  add-patch: test for 'p' command
</content>
</entry>
<entry>
<title>Merge branch 'pw/add-patch-with-suppress-blank-empty'</title>
<updated>2024-07-31T20:34:17Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-07-31T20:34:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d71121c060dc1a76cb5be1674e4f719f5c58136e'/>
<id>urn:sha1:d71121c060dc1a76cb5be1674e4f719f5c58136e</id>
<content type='text'>
"git add -p" by users with diff.suppressBlankEmpty set to true
failed to parse the patch that represents an unmodified empty line
with an empty line (not a line with a single space on it), which
has been corrected.

* pw/add-patch-with-suppress-blank-empty:
  add-patch: use normalize_marker() when recounting edited hunk
  add-patch: handle splitting hunks with diff.suppressBlankEmpty
</content>
</entry>
<entry>
<title>add-patch: render hunks through the pager</title>
<updated>2024-07-25T16:03:00Z</updated>
<author>
<name>Rubén Justo</name>
<email>rjusto@gmail.com</email>
</author>
<published>2024-07-25T13:44:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fc87b2f7c18d0a097c80e4d9ef1f84da687636ab'/>
<id>urn:sha1:fc87b2f7c18d0a097c80e4d9ef1f84da687636ab</id>
<content type='text'>
Make the print command trigger the pager when invoked using a capital
'P', to make it easier for the user to review long hunks.

Note that if the PAGER ends unexpectedly before we've been able to send
the payload, perhaps because the user is not interested in the whole
thing, we might receive a SIGPIPE, which would abruptly and unexpectedly
terminate the interactive session for the user.

Therefore, we need to ignore a possible SIGPIPE signal.  Add a test for
this, in addition to the test for normal operation.

For the SIGPIPE test, we need to make sure that we completely fill the
operating system's buffer, otherwise we might not trigger the SIGPIPE
signal.  The normal size of this buffer in different OSs varies from a
few KBs to 1MB.  Use a payload large enough to guarantee that we exceed
this limit.

Signed-off-by: Rubén Justo &lt;rjusto@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
