]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 weeks agobuiltin/repack.c: pass "packtmp" to `generated_pack_populate()`
Taylor Blau [Wed, 15 Oct 2025 22:28:23 +0000 (18:28 -0400)] 
builtin/repack.c: pass "packtmp" to `generated_pack_populate()`

In a similar spirit as previous commits, this function needs to know the
temporary pack prefix, which it currently accesses through the static
"packtmp" variable within builtin/repack.c.

Pass it explicitly as a function parameter to facilitate moving this
function out of builtin/repack.c entirely.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: factor out "generated_pack_install"
Taylor Blau [Wed, 15 Oct 2025 22:28:20 +0000 (18:28 -0400)] 
builtin/repack.c: factor out "generated_pack_install"

Once all new packs are known to exist, 'repack' installs their contents
from their temporary location into their permanent one. This is a
semi-involved procedure for each pack, since for each extension (e.g.,
".idx", ".pack", ".mtimes", and so on) we have to either:

 - adjust the filemode of the temporary file before renaming it into
   place, or

 - die() if we are missing a non-optional extension, or

 - unlink() any existing file for extensions that we did not generate
   (e.g., if a non-cruft pack we generated was identical to, say, a
   cruft pack which existed at the beginning of the process, we have to
   remove the ".mtimes" file).

Extract this procedure into its own function, and call it
"generated_pack_install"(). This will set us up for pulling this
function out of the builtin entirely and making it part of the repack.h
API, which will be done in a future commit.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: rename "struct generated_pack_data"
Taylor Blau [Wed, 15 Oct 2025 22:28:18 +0000 (18:28 -0400)] 
builtin/repack.c: rename "struct generated_pack_data"

The name "generated_pack_data" is somewhat redundant, since the contents
of the struct *is* the data associated with the generated pack.

Rename the structure to just "generated_pack", resulting in less awkward
function names, like "generated_pack_has_ext()" which is preferable to
"generated_pack_data_has_ext()".

Rename a few related functions to align with the convention that
functions to do with a struct "S" should be prefixed with "S_".

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agorepack: remove 'existing_packs' API from the builtin
Taylor Blau [Wed, 15 Oct 2025 22:28:15 +0000 (18:28 -0400)] 
repack: remove 'existing_packs' API from the builtin

The repack builtin defines an API for keeping track of which packs
were found in the repository at the beginning of the repack operation.
This is used to classify what state a pack was in (kept, non-kept, or
cruft), and is also used to mark which packs to delete (or keep) at the
end of a repack operation.

Now that the prerequisite refactoring is complete, this API is isolated
enough that it can be moved out to repack.[ch] and removed from the
builtin entirely.

As a result, some of its functions become static within repack.c,
cleaning up the visible API.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: avoid unnecessary numeric casts in existing_packs
Taylor Blau [Wed, 15 Oct 2025 22:28:12 +0000 (18:28 -0400)] 
builtin/repack.c: avoid unnecessary numeric casts in existing_packs

There are a couple of spots that cause warnings within the
existing_packs API without DISABLE_SIGN_COMPARE_WARNINGS under
DEVELOPER=1 mode.

In both cases, we have int values that are being compared against size_t
ones. Neither of these two cases are incorrect, and the cast is
completely OK in practice. But both are unnecessary, since:

 - in existing_packs_mark_for_deletion_1(), 'hexsz' should be defined as
   a size_t anyway, since algop->hexsz is.

 - in existing_packs_collect(), 'i' should be defined as a size_t since
   it is counting up to the value of a string_list's 'nr' field.

(This patch is a little bit of noise, but I would rather see us squelch
these warnings ahead of moving the existing_packs API into a separate
compilation unit to avoid having to define DISABLE_SIGN_COMPARE_WARNINGS
in repack.c.)

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: pass "packdir" when removing packs
Taylor Blau [Wed, 15 Oct 2025 22:28:10 +0000 (18:28 -0400)] 
builtin/repack.c: pass "packdir" when removing packs

builtin/repack.c defines a static "packdir" to instruct pack-objects on
where to write any new packfiles. This is also the directory scanned
when removing any packfiles which were made redundant by the latest
repack.

Prepare to move the "existing_packs_remove_redundant" function to its
own compilation unit by passing in this information as a parameter to
that function.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agorepack: remove 'remove_redundant_pack' from the builtin
Taylor Blau [Wed, 15 Oct 2025 22:28:07 +0000 (18:28 -0400)] 
repack: remove 'remove_redundant_pack' from the builtin

Extract "remove_redundant_pack()" as generic repack-related
functionality by moving its implementation to the repack.[ch]
compilation unit.

This is a prerequisite to moving the "existing_packs" API, which is one
of the callers of this function. (The remaining caller in the pack
geometry code will eventually move to its own compilation unit as well,
and will likewise rely on this function.)

While moving it over, prefix the function name with "repack_" to
indicate that it belongs to the repack-subsystem.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: rename many 'struct existing_packs' functions
Taylor Blau [Wed, 15 Oct 2025 22:28:04 +0000 (18:28 -0400)] 
builtin/repack.c: rename many 'struct existing_packs' functions

Rename many of the 'struct existing_packs'-related functions according
to the convention introduced in and described by 541204aabe
(Documentation: document naming schema for structs and their functions,
2024-07-30).

Note that some functions which operate over an individual entry in the
list of existing packs are prefixed with "existing_pack_" instead of the
plural form.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agorepack: remove 'prepare_pack_objects' from the builtin
Taylor Blau [Wed, 15 Oct 2025 22:28:01 +0000 (18:28 -0400)] 
repack: remove 'prepare_pack_objects' from the builtin

Now that the 'prepare_pack_objects' function no longer refers to
external, static variables, move it out to repack.h as generic
functionality.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agorepack: move 'delta_base_offset' to 'struct pack_objects_args'
Taylor Blau [Wed, 15 Oct 2025 22:27:58 +0000 (18:27 -0400)] 
repack: move 'delta_base_offset' to 'struct pack_objects_args'

The static variable 'delta_base_offset' determines whether or not we
pass the "--delta-base-offset" command-line argument when spawning
pack-objects as a child process. Its introduction dates back to when
repack was rewritten in C, all the way back in a1bbc6c017 (repack:
rewrite the shell script in C, 2013-09-15).

'struct pack_objects_args' was introduced much later on in 4571324b99
(builtin/repack.c: allow configuring cruft pack generation, 2022-05-20),
but did not move the 'delta_base_offset' variable.

Since the 'delta_base_offset' is a property of an individual
pack-objects command, re-introduce that variable as a member of 'struct
pack_objects_args', which will enable further code movement in the
subsequent commits.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: pass both pack_objects args to repack_config
Taylor Blau [Wed, 15 Oct 2025 22:27:56 +0000 (18:27 -0400)] 
builtin/repack.c: pass both pack_objects args to repack_config

A subsequent commit will remove 'delta_base_offset' as a static variable
within builtin/repack.c, and reintroduce it as a member of the 'struct
pack_objects_args'.

As a result, the repack_config callback will need to have both the
cruft- and non-cruft 'struct pack_objects_args's in scope. Introduce a
new 'struct repack_config_ctx' to allow the callee to provide both
pointers to the callback.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agorepack: introduce new compilation unit
Taylor Blau [Wed, 15 Oct 2025 22:27:53 +0000 (18:27 -0400)] 
repack: introduce new compilation unit

Over the years, builtin/repack.c has turned into a grab-bag of
functionality powering the 'git repack' builtin. Among its many
capabilities, it:

 - can build and spawn 'git pack-objects' commands, which in turn
   generate new packs
 - has infrastructure to manage the set of existing packs in a
   repository
 - has infrastructure to split a sequence of packs into a geometric
   progression based on object size
 - can manage both generating and combining cruft packs together
 - can write new MIDXs

to name a few.

As a result, this builtin has accumulated a lot of code, making adding
new functionality difficult. In the future, 'repack' will learn how to
manage a chain of incremental MIDXs, adding yet more functionality into
the builtin.

As a prerequisite step, let's first move some of the functionality in
the builtin into its own repack.[ch].

This will be done over the course of many steps, since there are many
individual components, some of which will end up in other, yet-to-exist
compilation units of their own. Some of the code movement here is also
non-trivial, so performing it in individual steps will make it easier to
verify.

Let's start by migrating 'struct pack_objects_args' (and the related
corresponding pack_objects_args_release() function) into repack.h, and
teach both the Makefile and Meson how to build the new compilation unit.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: avoid using `hash_to_hex()` in pack geometry
Taylor Blau [Wed, 15 Oct 2025 22:27:50 +0000 (18:27 -0400)] 
builtin/repack.c: avoid using `hash_to_hex()` in pack geometry

In previous commits, we started passing either repository or
git_hash_algo pointers around to various spots within builtin/repack.c
to reduce our dependency on the_repository in the hope of undef'ing
USE_THE_REPOSITORY_VARIABLE.

This commit takes us as far as we can (easily) go in that direction by
removing the only use of a convenience function that only exists when
USE_THE_REPOSITORY_VARIABLE is defined.

Unfortunately, the only other such function is "is_bare_repository()",
which is less than straightforward to convert into, say,
"repo_is_bare()", the latter of the two accepting a repository pointer.

Punt on that for now, and declare this commit as the stopping point for
our efforts in the direction of undef'ing USE_THE_REPOSITORY_VARIABLE.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: avoid "the_hash_algo" in `finish_pack_objects_cmd()`
Taylor Blau [Wed, 15 Oct 2025 22:27:41 +0000 (18:27 -0400)] 
builtin/repack.c: avoid "the_hash_algo" in `finish_pack_objects_cmd()`

In a similar spirit as previous commits, avoid referring directly to
"the_hash_algo" in builtin/repack.c::finish_pack_objects_cmd() and
instead accept one as a parameter to the function.

Since this function has a number of callers throughout the builtin, the
diff is a little noisier than previous commits. However, each hunk is
limited to passing the hash_algo parameter from a repository pointer
that is already in scope.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack: avoid "the_hash_algo" in `repack_promisor_objects()`
Taylor Blau [Wed, 15 Oct 2025 22:27:38 +0000 (18:27 -0400)] 
builtin/repack: avoid "the_hash_algo" in `repack_promisor_objects()`

In a similar spirit as the previous commits, avoid referring directly to
"the_hash_algo" within builtin/repack.c::repack_promisor_objects().

Since there is already a repository pointer in scope, use its hash_algo
value instead.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: avoid "the_hash_algo" in `write_oid()`
Taylor Blau [Wed, 15 Oct 2025 22:27:36 +0000 (18:27 -0400)] 
builtin/repack.c: avoid "the_hash_algo" in `write_oid()`

In a similar spirit as the previous commit, avoid referring directly to
"the_hash_algo" within builtin/repack.c::write_oid().

Unlike the previous commit, we are within a callback function, so must
introduce a new struct to pass additional data through its "data"
pointer.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: avoid "the_hash_algo" when deleting packs
Taylor Blau [Wed, 15 Oct 2025 22:27:33 +0000 (18:27 -0400)] 
builtin/repack.c: avoid "the_hash_algo" when deleting packs

The "mark_packs_for_deletion_1" function uses "the_hash_algo->hexsz" to
isolate a pack's checksum before deleting it to avoid deleting a newly
written pack having the same checksum (that is, some generated pack
wound up identical to an existing pack).

Avoid this by passing down a "struct git_hash_algo" pointer, and refer to
the hash algorithm through it instead.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: avoid "the_repository" when repacking promisor objects
Taylor Blau [Wed, 15 Oct 2025 22:27:30 +0000 (18:27 -0400)] 
builtin/repack.c: avoid "the_repository" when repacking promisor objects

Pass a "struct repository" pointer to the 'repack_promisor_objects()'
function to avoid using "the_repository".

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: avoid "the_repository" when removing packs
Taylor Blau [Wed, 15 Oct 2025 22:27:27 +0000 (18:27 -0400)] 
builtin/repack.c: avoid "the_repository" when removing packs

The 'remove_redundant_pack()' function uses "the_repository" to obtain,
and optionally remove, the repository's MIDX. Instead of relying on
"the_repository", pass around a "struct repository *" parameter through
its callers, and use that instead.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: avoid "the_repository" when taking a ref snapshot
Taylor Blau [Wed, 15 Oct 2025 22:27:24 +0000 (18:27 -0400)] 
builtin/repack.c: avoid "the_repository" when taking a ref snapshot

Avoid using "the_repository" in various MIDX-related ref snapshotting
functions.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: avoid "the_repository" in existing packs API
Taylor Blau [Wed, 15 Oct 2025 22:27:21 +0000 (18:27 -0400)] 
builtin/repack.c: avoid "the_repository" in existing packs API

There are a number of spots within builtin/repack.c which refer to
"the_repository", and either make use of the "existing packs" API
or otherwise have a 'struct existing_packs *' in scope.

Add a "repo" member to "struct existing_packs" and use that instead of
"the_repository" in such locations.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 weeks agobuiltin/repack.c: avoid "the_repository" in `cmd_repack()`
Taylor Blau [Wed, 15 Oct 2025 22:27:18 +0000 (18:27 -0400)] 
builtin/repack.c: avoid "the_repository" in `cmd_repack()`

Reduce builtin/repack.c's reliance on `the_repository` by using the
currently-UNUSED "repo" parameter within cmd_repack().

The following commits will continue to reduce the usage of
the_repository in other places within builtin/repack.c.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 weeks agoMerge branch 'ps/packfile-store' into tb/incremental-midx-part-3.1
Junio C Hamano [Mon, 29 Sep 2025 16:31:08 +0000 (09:31 -0700)] 
Merge branch 'ps/packfile-store' into tb/incremental-midx-part-3.1

* ps/packfile-store:
  packfile: refactor `get_packed_git_mru()` to work on packfile store
  packfile: refactor `get_all_packs()` to work on packfile store
  packfile: refactor `get_packed_git()` to work on packfile store
  packfile: move `get_multi_pack_index()` into "midx.c"
  packfile: introduce function to load and add packfiles
  packfile: refactor `install_packed_git()` to work on packfile store
  packfile: split up responsibilities of `reprepare_packed_git()`
  packfile: refactor `prepare_packed_git()` to work on packfile store
  packfile: reorder functions to avoid function declaration
  odb: move kept cache into `struct packfile_store`
  odb: move MRU list of packfiles into `struct packfile_store`
  odb: move packfile map into `struct packfile_store`
  odb: move initialization bit into `struct packfile_store`
  odb: move list of packfiles into `struct packfile_store`
  packfile: introduce a new `struct packfile_store`

6 weeks agopackfile: refactor `get_packed_git_mru()` to work on packfile store
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:14 +0000 (12:17 +0200)] 
packfile: refactor `get_packed_git_mru()` to work on packfile store

The `get_packed_git_mru()` function prepares the packfile store and then
returns its packfiles in most-recently-used order. Refactor it to accept
a packfile store instead of a repository to clarify its scope.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agopackfile: refactor `get_all_packs()` to work on packfile store
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:13 +0000 (12:17 +0200)] 
packfile: refactor `get_all_packs()` to work on packfile store

The `get_all_packs()` function prepares the packfile store and then
returns its packfiles. Refactor it to accept a packfile store instead of
a repository to clarify its scope.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agopackfile: refactor `get_packed_git()` to work on packfile store
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:12 +0000 (12:17 +0200)] 
packfile: refactor `get_packed_git()` to work on packfile store

The `get_packed_git()` function prepares the packfile store and then
returns its packfiles. Refactor it to accept a packfile store instead of
a repository to clarify its scope.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agopackfile: move `get_multi_pack_index()` into "midx.c"
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:11 +0000 (12:17 +0200)] 
packfile: move `get_multi_pack_index()` into "midx.c"

The `get_multi_pack_index()` function is declared and implemented in the
packfile subsystem, even though it really belongs into the multi-pack
index subsystem. The reason for this is likely that it needs to call
`packfile_store_prepare()`, which is not exposed by the packfile system.
In a subsequent commit we're about to add another caller outside of the
packfile system though, so we'll have to expose the function anyway.

Do so now already and move `get_multi_pack_index()` into the MIDX
subsystem.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agopackfile: introduce function to load and add packfiles
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:10 +0000 (12:17 +0200)] 
packfile: introduce function to load and add packfiles

We have a recurring pattern where we essentially perform an upsert of a
packfile in case it isn't yet known by the packfile store. The logic to
do so is non-trivial as we have to reconstruct the packfile's key, check
the map of packfiles, then create the new packfile and finally add it to
the store.

Introduce a new function that does this dance for us. Refactor callsites
to use it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agopackfile: refactor `install_packed_git()` to work on packfile store
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:09 +0000 (12:17 +0200)] 
packfile: refactor `install_packed_git()` to work on packfile store

The `install_packed_git()` functions adds a packfile to a specific
object store. Refactor it to accept a packfile store instead of a
repository to clarify its scope.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agopackfile: split up responsibilities of `reprepare_packed_git()`
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:08 +0000 (12:17 +0200)] 
packfile: split up responsibilities of `reprepare_packed_git()`

In `reprepare_packed_git()` we perform a couple of operations:

  - We reload alternate object directories.

  - We clear the loose object cache.

  - We reprepare packfiles.

While the logic is hosted in "packfile.c", it clearly reaches into other
subsystems that aren't related to packfiles.

Split up the responsibility and introduce `odb_reprepare()` which now
becomes responsible for repreparing the whole object database. The
existing `reprepare_packed_git()` function is refactored accordingly and
only cares about reloading the packfile store now.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agopackfile: refactor `prepare_packed_git()` to work on packfile store
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:07 +0000 (12:17 +0200)] 
packfile: refactor `prepare_packed_git()` to work on packfile store

The `prepare_packed_git()` function and its friends are responsible for
loading packfiles as well as the multi-pack index for a given object
database. Refactor these functions to accept a packfile store instead of
a repository to clarify their scope.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agopackfile: reorder functions to avoid function declaration
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:06 +0000 (12:17 +0200)] 
packfile: reorder functions to avoid function declaration

Reorder functions so that we can avoid a forward declaration of
`prepare_packed_git()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agoodb: move kept cache into `struct packfile_store`
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:05 +0000 (12:17 +0200)] 
odb: move kept cache into `struct packfile_store`

The object database tracks a cache of "kept" packfiles, which is used by
git-pack-objects(1) to handle cruft objects. With the introduction of
the `struct packfile_store` we have a better place to host this cache
though.

Move the cache accordingly.

This moves the last bit of packfile-related state from the object
database into the packfile store. Adapt the comment for the `packfiles`
pointer in `struct object_database` to reflect this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agoodb: move MRU list of packfiles into `struct packfile_store`
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:04 +0000 (12:17 +0200)] 
odb: move MRU list of packfiles into `struct packfile_store`

The object database tracks the list of packfiles in most-recently-used
order, which is mostly used to favor reading from packfiles that contain
most of the objects that we're currently accessing. With the
introduction of the `struct packfile_store` we have a better place to
host this list though.

Move the list accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agoodb: move packfile map into `struct packfile_store`
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:03 +0000 (12:17 +0200)] 
odb: move packfile map into `struct packfile_store`

The object database tracks a map of packfiles by their respective paths,
which is used to figure out whether a given packfile has already been
loaded. With the introduction of the `struct packfile_store` we have a
better place to host this list though.

Move the map accordingly.

`pack_map_entry_cmp()` isn't used anywhere but in "packfile.c" anymore
after this change, so we convert it to a static function, as well. Note
that we also drop the `inline` hint: the function is used as a callback
function exclusively, and callbacks cannot be inlined.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agoodb: move initialization bit into `struct packfile_store`
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:02 +0000 (12:17 +0200)] 
odb: move initialization bit into `struct packfile_store`

The object database knows to skip re-initializing the list of packfiles
in case it's already been initialized. Whether or not that is the case
is tracked via a separate `initialized` bit that is stored in the object
database. With the introduction of the `struct packfile_store` we have a
better place to host this bit though.

Move it accordingly. While at it, convert the field into a boolean now
that we're allowed to use them in our code base.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agoodb: move list of packfiles into `struct packfile_store`
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:01 +0000 (12:17 +0200)] 
odb: move list of packfiles into `struct packfile_store`

The object database tracks the list of packfiles it currently knows
about. With the introduction of the `struct packfile_store` we have a
better place to host this list though.

Move the list accordingly. Extract the logic from `odb_clear()` that
knows to close all such packfiles and move it into the new subsystem, as
well.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agopackfile: introduce a new `struct packfile_store`
Patrick Steinhardt [Tue, 23 Sep 2025 10:17:00 +0000 (12:17 +0200)] 
packfile: introduce a new `struct packfile_store`

Information about an object database's packfiles is currently
distributed across two different structures:

  - `struct packed_git` contains the `next` pointer as well as the
    `mru_head`, both of which serve to store the list of packfiles.

  - `struct object_database` contains several fields that relate to the
    packfiles.

So we don't really have a central data structure that tracks our
packfiles, and consequently responsibilities aren't always clear cut.
A consequence for the upcoming pluggable object databases is that this
makes it very hard to move management of packfiles from the object
database level down into the object database source.

Introduce a new `struct packfile_store` which is about to become the
single source of truth for managing packfiles. Right now this data
structure doesn't yet contain anything, but in subsequent patches we
will move all data structures that relate to packfiles and that are
currently contained in `struct object_database` into this new home.

Note that this is only a first step: most importantly, we won't (yet)
move the `struct packed_git::next` pointer around. This will happen in a
subsequent patch series though so that `struct packed_git` will really
only host information about the specific packfile it represents.

Further note that the new structure still sits at the wrong level at the
end of this patch series: as mentioned, it should eventually sit at the
level of the object database source, not at the object database level.
But introducing the packfile store now already makes it way easier to
eventually push down the now-selfcontained data structure by one level.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agoThe twelfth batch
Junio C Hamano [Tue, 23 Sep 2025 18:53:31 +0000 (11:53 -0700)] 
The twelfth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 weeks agoMerge branch 'cs/subtree-squash-split-fix'
Junio C Hamano [Tue, 23 Sep 2025 18:53:40 +0000 (11:53 -0700)] 
Merge branch 'cs/subtree-squash-split-fix'

"git subtree" (in contrib/) did not work correctly when splitting
squashed subtrees, which has been improved.

* cs/subtree-squash-split-fix:
  contrib/subtree: fix split with squashed subtrees

6 weeks agoMerge branch 'rs/get-oid-with-flags-cleanup'
Junio C Hamano [Tue, 23 Sep 2025 18:53:40 +0000 (11:53 -0700)] 
Merge branch 'rs/get-oid-with-flags-cleanup'

Code clean-up.

* rs/get-oid-with-flags-cleanup:
  use repo_get_oid_with_flags()

6 weeks agoMerge branch 'jk/add-i-color'
Junio C Hamano [Tue, 23 Sep 2025 18:53:40 +0000 (11:53 -0700)] 
Merge branch 'jk/add-i-color'

Some among "git add -p" and friends ignored color.diff and/or
color.ui configuration variables, which is an old regression, which
has been corrected.

* jk/add-i-color:
  contrib/diff-highlight: mention interactive.diffFilter
  add-interactive: manually fall back color config to color.ui
  add-interactive: respect color.diff for diff coloring
  stash: pass --no-color to diff plumbing child processes

6 weeks agoMerge branch 'cc/promisor-remote-capability'
Junio C Hamano [Tue, 23 Sep 2025 18:53:39 +0000 (11:53 -0700)] 
Merge branch 'cc/promisor-remote-capability'

The "promisor-remote" capability mechanism has been updated to
allow the "partialCloneFilter" settings and the "token" value to be
communicated from the server side.

* cc/promisor-remote-capability:
  promisor-remote: use string_list_split() in mark_remotes_as_accepted()
  promisor-remote: allow a client to check fields
  promisor-remote: use string_list_split() in filter_promisor_remote()
  promisor-remote: refactor how we parse advertised fields
  promisor-remote: use string constants for 'name' and 'url' too
  promisor-remote: allow a server to advertise more fields
  promisor-remote: refactor to get rid of 'struct strvec'

7 weeks agoThe tenth batch
Junio C Hamano [Thu, 18 Sep 2025 17:06:32 +0000 (10:06 -0700)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoMerge branch 'pc/range-diff-memory-limit'
Junio C Hamano [Thu, 18 Sep 2025 17:07:02 +0000 (10:07 -0700)] 
Merge branch 'pc/range-diff-memory-limit'

"git range-diff" learned a way to limit the memory consumed by
O(N*N) cost matrix.

* pc/range-diff-memory-limit:
  range-diff: add configurable memory limit for cost matrix

7 weeks agoMerge branch 'ne/alloc-free-and-null'
Junio C Hamano [Thu, 18 Sep 2025 17:07:02 +0000 (10:07 -0700)] 
Merge branch 'ne/alloc-free-and-null'

The clear_alloc_state() API function was not fully clearing the
structure for reuse, but since nobody reuses it, replace it with a
variant that frees the structure as well, making the callers simpler.

* ne/alloc-free-and-null:
  alloc: fix dangling pointer in alloc_state cleanup

7 weeks agoMerge branch 'jk/curl-global-trace-components'
Junio C Hamano [Thu, 18 Sep 2025 17:07:02 +0000 (10:07 -0700)] 
Merge branch 'jk/curl-global-trace-components'

Adjust to the way newer versions of cURL selectivel enables tracing
options, so that our tests can continue to work.

* jk/curl-global-trace-components:
  curl: add support for curl_global_trace() components

7 weeks agoMerge branch 'ag/doc-sendmail-gmail-example-update'
Junio C Hamano [Thu, 18 Sep 2025 17:07:01 +0000 (10:07 -0700)] 
Merge branch 'ag/doc-sendmail-gmail-example-update'

Doc update.

* ag/doc-sendmail-gmail-example-update:
  docs: update sendmail docs to use more secure SMTP server for Gmail

7 weeks agoMerge branch 'kn/clang-format-bitfields'
Junio C Hamano [Thu, 18 Sep 2025 17:07:01 +0000 (10:07 -0700)] 
Merge branch 'kn/clang-format-bitfields'

CodingGuidelines now spells out how bitfields are to be written.

* kn/clang-format-bitfields:
  Documentation: note styling for bit fields

7 weeks agoMerge branch 'jc/longer-disambiguation-fix'
Junio C Hamano [Thu, 18 Sep 2025 17:07:01 +0000 (10:07 -0700)] 
Merge branch 'jc/longer-disambiguation-fix'

"git rev-parse --short" and friends failed to disambiguate two
objects with object names that share common prefix longer than 32
characters, which has been fixed.

* jc/longer-disambiguation-fix:
  abbrev: allow extending beyond 32 chars to disambiguate

7 weeks agoMerge branch 'sg/line-log-boundary-fixes'
Junio C Hamano [Thu, 18 Sep 2025 17:07:01 +0000 (10:07 -0700)] 
Merge branch 'sg/line-log-boundary-fixes'

A corner case bug in "git log -L..." has been corrected.

* sg/line-log-boundary-fixes:
  line-log: show all line ranges touched by the same diff range
  line-log: fix assertion error

7 weeks agoMerge branch 'jc/doc-includeif-hasconfig-remote-url-fix'
Junio C Hamano [Thu, 18 Sep 2025 17:07:00 +0000 (10:07 -0700)] 
Merge branch 'jc/doc-includeif-hasconfig-remote-url-fix'

Doc mark-up fix.

* jc/doc-includeif-hasconfig-remote-url-fix:
  config: document includeIf conditions consistently

7 weeks agoMerge branch 'ag/send-email-imap-sent'
Junio C Hamano [Thu, 18 Sep 2025 17:07:00 +0000 (10:07 -0700)] 
Merge branch 'ag/send-email-imap-sent'

"git send-email" learned to drive "git imap-send" to store already
sent e-mails in an IMAP folder.

* ag/send-email-imap-sent:
  send-email: enable copying emails to an IMAP folder without actually sending them
  send-email: add ability to send a copy of sent emails to an IMAP folder

7 weeks agoMerge branch 'pw/3.0-commentchar-auto-deprecation'
Junio C Hamano [Thu, 18 Sep 2025 17:07:00 +0000 (10:07 -0700)] 
Merge branch 'pw/3.0-commentchar-auto-deprecation'

"core.commentChar=auto" that attempts to dynamically pick a
suitable comment character is non-workable, as it is too much
trouble to support for little benefit, and is marked as deprecated.

* pw/3.0-commentchar-auto-deprecation:
  commit: print advice when core.commentString=auto
  config: warn on core.commentString=auto
  breaking-changes: deprecate support for core.commentString=auto

7 weeks agoMerge branch 'kh/doc-fast-import-markup-fix'
Junio C Hamano [Thu, 18 Sep 2025 17:07:00 +0000 (10:07 -0700)] 
Merge branch 'kh/doc-fast-import-markup-fix'

Doc mark-up fix.

* kh/doc-fast-import-markup-fix:
  doc: fast-import: replace literal block with paragraph

7 weeks agomailmap: consolidate multiple addresses into one
Greg Hurrell [Tue, 2 Sep 2025 12:30:58 +0000 (12:30 +0000)] 
mailmap: consolidate multiple addresses into one

Merges contributions made from three different addresses:

- win@wincent.com (old address, initial contributions in 2007–2009)
- greg@hurrell.net (personal address matching full name, so this one is
  the "forever" address; contributions made starting in 2018)
- greg.hurrell@datadoghq.com (current work address, used for recent
  contributions)

Signed-off-by: Greg Hurrell <greg.hurrell@datadoghq.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoThe ninth batch
Junio C Hamano [Mon, 15 Sep 2025 15:51:09 +0000 (08:51 -0700)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 weeks agoMerge branch 'mm/worktree-doc-typofix'
Junio C Hamano [Mon, 15 Sep 2025 15:52:07 +0000 (08:52 -0700)] 
Merge branch 'mm/worktree-doc-typofix'

Docfix.

* mm/worktree-doc-typofix:
  docs: fix typo in worktree.adoc 'extension'

7 weeks agoMerge branch 'rs/object-name-extend-abbrev-len-update'
Junio C Hamano [Mon, 15 Sep 2025 15:52:07 +0000 (08:52 -0700)] 
Merge branch 'rs/object-name-extend-abbrev-len-update'

Code clean-up.

* rs/object-name-extend-abbrev-len-update:
  object-name: declare pointer type of extend_abbrev_len()'s 2nd parameter

7 weeks agoMerge branch 'ps/upload-pack-oom-protection'
Junio C Hamano [Mon, 15 Sep 2025 15:52:06 +0000 (08:52 -0700)] 
Merge branch 'ps/upload-pack-oom-protection'

A broken or malicious "git fetch" can say that it has the same
object for many many times, and the upload-pack serving it can
exhaust memory storing them redundantly, which has been corrected.

* ps/upload-pack-oom-protection:
  upload-pack: don't ACK non-commits repeatedly in protocol v2
  t5530: modernize tests

7 weeks agoMerge branch 'ds/midx-write-fixes'
Junio C Hamano [Mon, 15 Sep 2025 15:52:06 +0000 (08:52 -0700)] 
Merge branch 'ds/midx-write-fixes'

Fixes multiple crashes around midx write-out codepaths.

* ds/midx-write-fixes:
  midx-write: simplify error cases
  midx-write: reenable signed comparison errors
  midx-write: use uint32_t for preferred_pack_idx
  midx-write: use cleanup when incremental midx fails
  midx-write: put failing response value back
  midx-write: only load initialized packs

7 weeks agoMerge branch 'lo/repo-info-step-2'
Junio C Hamano [Mon, 15 Sep 2025 15:52:05 +0000 (08:52 -0700)] 
Merge branch 'lo/repo-info-step-2'

"repo info" learns a short-hand option "-z" that is the same as
"--format=nul", and learns to report the objects format used in the
repository.

* lo/repo-info-step-2:
  repo: add the field objects.format
  repo: add the flag -z as an alias for --format=nul

7 weeks agoMerge branch 'jt/de-global-bulk-checkin'
Junio C Hamano [Mon, 15 Sep 2025 15:52:05 +0000 (08:52 -0700)] 
Merge branch 'jt/de-global-bulk-checkin'

The bulk-checkin code used to depend on a file-scope static
singleton variable, which has been updated to pass an instance
throughout the callchain.

* jt/de-global-bulk-checkin:
  bulk-checkin: use repository variable from transaction
  bulk-checkin: require transaction for index_blob_bulk_checkin()
  bulk-checkin: remove global transaction state
  bulk-checkin: introduce object database transaction structure

8 weeks agoThe eighth batch
Junio C Hamano [Fri, 12 Sep 2025 17:41:02 +0000 (10:41 -0700)] 
The eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoMerge branch 'rs/describe-with-lazy-queue-and-oidset'
Junio C Hamano [Fri, 12 Sep 2025 17:41:21 +0000 (10:41 -0700)] 
Merge branch 'rs/describe-with-lazy-queue-and-oidset'

Instead of scanning for the remaining items to see if there are
still commits to be explored in the queue, use khash to remember
which items are still on the queue (an unacceptable alternative is
to reserve one object flag bits).

* rs/describe-with-lazy-queue-and-oidset:
  describe: use oidset in finish_depth_computation()

8 weeks agoMerge branch 'tc/t0450-harden'
Junio C Hamano [Fri, 12 Sep 2025 17:41:21 +0000 (10:41 -0700)] 
Merge branch 'tc/t0450-harden'

Test updates.

* tc/t0450-harden:
  t0450: add allowlist for builtins with missing .adoc
  t0450: fix test for out-of-tree builds

8 weeks agoMerge branch 'kh/doc-markup-fixes'
Junio C Hamano [Fri, 12 Sep 2025 17:41:20 +0000 (10:41 -0700)] 
Merge branch 'kh/doc-markup-fixes'

Doc markup fixes.

* kh/doc-markup-fixes:
  doc: remove extra backtick for inline-verbatim
  doc: add missing backtick for inline-verbatim

8 weeks agoMerge branch 'km/alias-doc-markup-fix'
Junio C Hamano [Fri, 12 Sep 2025 17:41:20 +0000 (10:41 -0700)] 
Merge branch 'km/alias-doc-markup-fix'

Docfix.

* km/alias-doc-markup-fix:
  doc: fix formatting of function-wrap shell alias

8 weeks agoMerge branch 'ps/gitlab-ci-disable-windows-monitoring'
Junio C Hamano [Fri, 12 Sep 2025 17:41:19 +0000 (10:41 -0700)] 
Merge branch 'ps/gitlab-ci-disable-windows-monitoring'

Windows "real-time monitoring" interferes with the execution of
tests and affects negatively in both correctness and performance,
which has been disabled in Gitlab CI.

* ps/gitlab-ci-disable-windows-monitoring:
  gitlab-ci: disable realtime monitoring to unbreak Windows jobs

8 weeks agoMerge branch 'ms/refs-exists'
Junio C Hamano [Fri, 12 Sep 2025 17:41:19 +0000 (10:41 -0700)] 
Merge branch 'ms/refs-exists'

"git refs exists" that works like "git show-ref --exists" has been
added.

* ms/refs-exists:
  t: add test for git refs exists subcommand
  t1422: refactor tests to be shareable
  t1403: split 'show-ref --exists' tests into a separate file
  builtin/refs: add 'exists' subcommand

8 weeks agoMerge branch 'ps/object-store-midx-dedup-info'
Junio C Hamano [Fri, 12 Sep 2025 17:41:18 +0000 (10:41 -0700)] 
Merge branch 'ps/object-store-midx-dedup-info'

Further code clean-up for multi-pack-index code paths.

* ps/object-store-midx-dedup-info:
  midx: compute paths via their source
  midx: stop duplicating info redundant with its owning source
  midx: write multi-pack indices via their source
  midx: load multi-pack indices via their source
  midx: drop redundant `struct repository` parameter
  odb: simplify calling `link_alt_odb_entry()`
  odb: return newly created in-memory sources
  odb: consistently use "dir" to refer to alternate's directory
  odb: allow `odb_find_source()` to fail
  odb: store locality in object database sources

8 weeks agoMerge branch 'je/doc-add'
Junio C Hamano [Fri, 12 Sep 2025 17:41:18 +0000 (10:41 -0700)] 
Merge branch 'je/doc-add'

Documentation for "git add" has been updated.

* je/doc-add:
  doc: rephrase the purpose of the staging area
  doc: git-add: simplify discussion of ignored files
  doc: git-add: clarify intro & add an example

8 weeks agocontrib/subtree: fix split with squashed subtrees
Colin Stagner [Wed, 10 Sep 2025 03:11:24 +0000 (22:11 -0500)] 
contrib/subtree: fix split with squashed subtrees

98ba49ccc2 (subtree: fix split processing with multiple subtrees
present, 2023-12-01) increases the performance of

    git subtree split --prefix=subA

by ignoring subtree merges which are outside of `subA/`. It also
introduces a regression. Subtree merges that should be retained
are incorrectly ignored if they:

1. are nested under `subA/`; and
2. are merged with `--squash`.

For example, a subtree merged like:

    git subtree merge --squash --prefix=subA/subB "$rev"
    #                 ^^^^^^^^          ^^^^

is erroneously ignored during a split of `subA`. This causes
missing tree files and different commit hashes starting in
git v2.44.0-rc0.

The method:

    should_ignore_subtree_split_commit REV

should test only a single commit REV, but the combination of

    git log -1 --grep=...

actually searches all *parent* commits until a `--grep` match is
discovered.

Rewrite this method to test only one REV at a time. Extract commit
information with a single `git` call as opposed to three. The
`test` conditions for rejecting a commit remain unchanged.

Unit tests now cover nested subtrees.

Signed-off-by: Colin Stagner <ask+git@howdoi.land>
Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agodoc: fast-import: replace literal block with paragraph
Kristoffer Haugsbakk [Mon, 8 Sep 2025 20:28:45 +0000 (22:28 +0200)] 
doc: fast-import: replace literal block with paragraph

68061e34702 (fast-import: disallow "feature export-marks" by default,
2019-08-29) added the documentation for this option.  The second
paragraph is a literal block but it looks like it should just be
a regular paragraph.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agouse repo_get_oid_with_flags()
René Scharfe [Wed, 10 Sep 2025 17:16:30 +0000 (19:16 +0200)] 
use repo_get_oid_with_flags()

get_oid_with_context() allows specifying flags and reports object
details via a passed-in struct object_context.  Some callers just want
to specify flags, but don't need any details back.  Convert them to
repo_get_oid_with_flags(), which provides just that and frees them from
dealing with the context structure.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoMerge branch 'master' of https://github.com/j6t/git-gui
Junio C Hamano [Wed, 10 Sep 2025 21:28:23 +0000 (14:28 -0700)] 
Merge branch 'master' of https://github.com/j6t/git-gui

* 'master' of https://github.com/j6t/git-gui:
  git-gui: sync Makefiles with git.git
  git-gui: fix error handling of Revert Changes command
  git-gui--askyesno (mingw): use Git for Windows' icon, if available
  git-gui--askyesno: allow overriding the window title
  git gui: set GIT_ASKPASS=git-gui--askpass if not set yet
  git-gui: provide question helper for retry fallback on Windows
  git-gui: simplify using nice(1)
  git-gui: simplify PATH de-duplication

8 weeks agoMerge branch 'master' of https://github.com/j6t/gitk
Junio C Hamano [Wed, 10 Sep 2025 21:27:52 +0000 (14:27 -0700)] 
Merge branch 'master' of https://github.com/j6t/gitk

* 'master' of https://github.com/j6t/gitk:
  gitk: add README with usage, build, and contribution details
  gitk: fix trackpad scrolling for Tcl/Tk 8.7+
  gitk: use <Button-3> for ctx menus on macOS with Tcl 8.7+

8 weeks agoThe seventh batch
Junio C Hamano [Mon, 8 Sep 2025 21:54:20 +0000 (14:54 -0700)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoMerge branch 'tc/last-modified'
Junio C Hamano [Mon, 8 Sep 2025 21:54:35 +0000 (14:54 -0700)] 
Merge branch 'tc/last-modified'

A new command "git last-modified" has been added to show the closest
ancestor commit that touched each path.

* tc/last-modified:
  last-modified: use Bloom filters when available
  t/perf: add last-modified perf script
  last-modified: new subcommand to show when files were last modified

8 weeks agoMerge branch 'ds/ls-files-lazy-unsparse'
Junio C Hamano [Mon, 8 Sep 2025 21:54:34 +0000 (14:54 -0700)] 
Merge branch 'ds/ls-files-lazy-unsparse'

"git ls-files <pathspec>..." should not necessarily have to expand
the index fully if a sparsified directory is excluded by the
pathspec; the code is taught to expand the index on demand to avoid
this.

* ds/ls-files-lazy-unsparse:
  ls-files: conditionally leave index sparse

8 weeks agoMerge branch 'ds/path-walk-repack-fix'
Junio C Hamano [Mon, 8 Sep 2025 21:54:34 +0000 (14:54 -0700)] 
Merge branch 'ds/path-walk-repack-fix'

"git repack --path-walk" lost objects in some corner cases, which
has been corrected.

* ds/path-walk-repack-fix:
  path-walk: create initializer for path lists
  path-walk: fix setup of pending objects

8 weeks agoMerge branch 'am/xdiff-hash-tweak'
Junio C Hamano [Mon, 8 Sep 2025 21:54:34 +0000 (14:54 -0700)] 
Merge branch 'am/xdiff-hash-tweak'

Inspired by Ezekiel's recent effort to showcase Rust interface, the
hash function implementation used to hash lines have been updated
to the one used for ELF symbol lookup by Glibc.

* am/xdiff-hash-tweak:
  xdiff: optimize xdl_hash_record_verbatim
  xdiff: refactor xdl_hash_record()

8 weeks agoMerge branch 'da/cargo-serialize'
Junio C Hamano [Mon, 8 Sep 2025 21:54:33 +0000 (14:54 -0700)] 
Merge branch 'da/cargo-serialize'

Makefile tried to run multiple "cargo build" which would not work
very well; serialize their execution to work it around.

* da/cargo-serialize:
  Makefile: build libgit-rs and libgit-sys serially

8 weeks agocontrib/diff-highlight: mention interactive.diffFilter
Jeff King [Mon, 8 Sep 2025 16:42:42 +0000 (12:42 -0400)] 
contrib/diff-highlight: mention interactive.diffFilter

When the README for diff-highlight was written, there was no way to
trigger it for the `add -p` interactive patch mode. We've since grown a
feature to support that, but it was documented only on the Git side.
Let's also let people coming the other direction, from diff-highlight,
know that it's an option.

Suggested-by: Isaac Oscar Gariano <IsaacOscar@live.com.au>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoadd-interactive: manually fall back color config to color.ui
Jeff King [Mon, 8 Sep 2025 16:42:39 +0000 (12:42 -0400)] 
add-interactive: manually fall back color config to color.ui

Color options like color.interactive and color.diff should fall back to
the value of color.ui if they aren't set. In add-interactive, we check
the specific options (e.g., color.diff) via repo_config_get_value(),
which does not depend on the main command having loaded any color config
via the git_config() callback mechanism.

But then we call want_color() on the result; if our specific config is
unset then that function uses the value of git_use_color_default. That
variable is typically set from color.ui by the git_color_config()
callback, which is called by the main command in its own git_config()
callback function.

This works fine for "add -p", whose add_config() callback calls into
git_color_config(). But it doesn't work for other commands like
"checkout -p", which is otherwise unaware of color at all. People tend
not to notice because the default is "auto", and that's what they'd set
color.ui to as well. But something like:

  git -c color.ui=false checkout -p

should disable color, and it doesn't.

This regression goes back to 0527ccb1b5 (add -i: default to the built-in
implementation, 2021-11-30). In the perl version we got the color config
from "git config --get-colorbool", which did the full lookup for us.

The obvious fix is for git-checkout to add a call to git_color_config()
to its own config callback. But we'd have to do so for every command
with this problem, which is error-prone. Let's see if we can fix it more
centrally.

It is tempting to teach want_color() to look up the value of
repo_config_get_value("color.ui") itself. But I think that would have
disastrous consequences. Plumbing commands, especially older ones, avoid
porcelain config like "color.*" by simply not parsing it in their config
callbacks. Looking up the value of color.ui under the hood would
undermine that.

Instead, let's do that lookup in the add-interactive setup code. We're
already demand-loading other color config there, which is probably fine
(even in a plumbing command like "git reset", the interactive mode is
inherently porcelain-ish). That catches all commands that use the
interactive code, whether they were calling git_color_config()
themselves or not.

Reported-by: Isaac Oscar Gariano <isaacoscar@live.com.au>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoadd-interactive: respect color.diff for diff coloring
Jeff King [Mon, 8 Sep 2025 16:42:36 +0000 (12:42 -0400)] 
add-interactive: respect color.diff for diff coloring

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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agostash: pass --no-color to diff plumbing child processes
Jeff King [Mon, 8 Sep 2025 16:42:32 +0000 (12:42 -0400)] 
stash: pass --no-color to diff plumbing child processes

After a partial stash, we may clear out the working tree by capturing
the output of diff-tree and piping it into git-apply (and likewise we
may use diff-index to restore the index). So we most definitely do not
want color diff output from that diff-tree process.  And it normally
would not produce any, since its stdout is not going to a tty, and the
default value of color.ui is "auto".

However, if GIT_PAGER_IN_USE is set in the environment, that overrides
the tty check, and we'll produce a colorized diff that chokes git-apply:

  $ echo y | GIT_PAGER_IN_USE=1 git stash -p
  [...]
  Saved working directory and index state WIP on main: 4f2e2bb foo
  error: No valid patches in input (allow with "--allow-empty")
  Cannot remove worktree changes

Setting this variable is a relatively silly thing to do, and not
something most users would run into. But we sometimes do it in our tests
to stimulate color. And it is a user-visible bug, so let's fix it rather
than work around it in the tests.

The root issue here is that diff-tree (and other diff plumbing) should
probably not ever produce color by default. It does so not by parsing
color.ui, but because of the baked-in "auto" default from 4c7f1819b3
(make color.ui default to 'auto', 2013-06-10). But changing that is
risky; we've had discussions back and forth on the topic over the years.
E.g.:

  https://lore.kernel.org/git/86D0A377-8AFD-460D-A90E-6327C6934DFC@gmail.com/.

So let's accept that as the status quo for now and protect ourselves by
passing --no-color to the child processes. This is the same thing we did
for add-interactive itself in 1c6ffb546b (add--interactive.perl: specify
--no-color explicitly, 2020-09-07).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agopromisor-remote: use string_list_split() in mark_remotes_as_accepted()
Christian Couder [Mon, 8 Sep 2025 05:30:53 +0000 (07:30 +0200)] 
promisor-remote: use string_list_split() in mark_remotes_as_accepted()

Previous commits replaced some strbuf_split*() calls with calls to
string_list_split*() in "promisor-remote.c".

For consistency, let's also replace the strbuf_split_str() call in
mark_remotes_as_accepted() with a call to string_list_split(), as we
don't need the splitted strings to be managed by a `struct strbuf`.
Using the lighter-weight `string_list` API is enough for our needs.

While at it let's remove a useless call to `strbuf_strip_suffix()`.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agopromisor-remote: allow a client to check fields
Christian Couder [Mon, 8 Sep 2025 05:30:52 +0000 (07:30 +0200)] 
promisor-remote: allow a client to check fields

A previous commit allowed a server to pass additional fields through
the "promisor-remote" protocol capability after the "name" and "url"
fields, specifically the "partialCloneFilter" and "token" fields.

Let's make it possible for a client to check if these fields match
what it expects before accepting a promisor remote.

We allow this by introducing a new "promisor.checkFields"
configuration variable. It should contain a comma or space separated
list of fields that will be checked.

By limiting the protocol to specific well-defined fields, we ensure
both server and client have a shared understanding of field
semantics and usage.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agopromisor-remote: use string_list_split() in filter_promisor_remote()
Christian Couder [Mon, 8 Sep 2025 05:30:51 +0000 (07:30 +0200)] 
promisor-remote: use string_list_split() in filter_promisor_remote()

A previous commit introduced a new parse_one_advertised_remote()
function that takes a `const char *` argument. This function is called
from filter_promisor_remote() and parses all the fields for one remote.

This means that in filter_promisor_remote() we no longer need to split
the remote information that will be passed to
parse_one_advertised_remote() into an array of relatively heavy and
complex `struct strbuf`.

To use something lighter, let's then replace strbuf_split_str() with
string_list_split() in filter_promisor_remote() to parse the remote
information that is passed to parse_one_advertised_remote().

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agopromisor-remote: refactor how we parse advertised fields
Christian Couder [Mon, 8 Sep 2025 05:30:50 +0000 (07:30 +0200)] 
promisor-remote: refactor how we parse advertised fields

In a follow up commit we are going to parse more fields, like a filter
and a token, coming from the server when it advertises promisor remotes
using the "promisor-remote" capability.

To prepare for this, let's refactor the code that parses the advertised
fields coming from the server into a new parse_one_advertised_remote()
function that will populate a `struct promisor_info` with the content
of the fields it parsed.

While at it, let's also pass this `struct promisor_info` to the
should_accept_remote() function, instead of passing it the parsed name
and url.

These changes will make it simpler to both parse more fields and access
the content of these parsed fields in follow up commits.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agopromisor-remote: use string constants for 'name' and 'url' too
Christian Couder [Mon, 8 Sep 2025 05:30:49 +0000 (07:30 +0200)] 
promisor-remote: use string constants for 'name' and 'url' too

A previous commit started to define `promisor_field_filter` and
`promisor_field_token`, and used them instead of the
"partialCloneFilter" and "token" string literals.

Let's do the same for "name" and "url" to avoid repeating them
several times and for consistency with the other fields.

For skipping "name=" or "url=" in advertisements, let's introduce
a skip_field_name_prefix() helper function to keep parsing clean
and easy to understand.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agopromisor-remote: allow a server to advertise more fields
Christian Couder [Mon, 8 Sep 2025 05:30:48 +0000 (07:30 +0200)] 
promisor-remote: allow a server to advertise more fields

For now the "promisor-remote" protocol capability can only pass "name"
and "url" information from a server to a client in the form
"name=<remote_name>,url=<remote_url>".

To allow clients to make more informed decisions about which promisor
remotes they accept, let's make it possible to pass more information
by introducing a new "promisor.sendFields" configuration variable.

On the server side, information about a remote `foo` is stored in
configuration variables named `remote.foo.<variable-name>`. To make
it clearer and simpler, we use `field` and `field name` like this:

  * `field name` refers to the <variable-name> part of such a
    configuration variable, and

  * `field` refers to both the `field name` and the value of such a
    configuration variable.

The "promisor.sendFields" configuration variable should contain a
comma or space separated list of field names that will be looked up
in the configuration of the remote on the server to find the values
that will be passed to the client.

Only a set of predefined field names are allowed. The only field
names in this set are "partialCloneFilter" and "token". The
"partialCloneFilter" field name specifies the filter definition used
by the promisor remote, and the "token" field name can provide an
authentication credential for accessing it.

For example, if "promisor.sendFields" is set to "partialCloneFilter",
and the server has the "remote.foo.partialCloneFilter" config
variable set to a value, then that value will be passed in the
"partialCloneFilter" field in the form "partialCloneFilter=<value>"
after the "name" and "url" fields.

A following commit will allow the client to use the information to
decide if it accepts the remote or not. For now the client doesn't do
anything with the additional information it receives.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agopromisor-remote: refactor to get rid of 'struct strvec'
Christian Couder [Mon, 8 Sep 2025 05:30:47 +0000 (07:30 +0200)] 
promisor-remote: refactor to get rid of 'struct strvec'

In a following commit, we will use the new 'promisor-remote' protocol
capability introduced by d460267613 (Add 'promisor-remote' capability
to protocol v2, 2025-02-18) to pass and process more information
about promisor remotes than just their name and url.

For that purpose, we will need to store information about other
fields, especially information that might or might not be available
for different promisor remotes. Unfortunately using 'struct strvec',
as we currently do, to store information about the promisor remotes
with one 'struct strvec' for each field like "name" or "url" does not
scale easily in that case. We would need one 'struct strvec' for each
new field, and then we would have to pass all these 'struct strvec'
around.

Let's refactor this and introduce a new 'struct promisor_info'.

It will only store promisor remote information in its members. For now
it has only a 'name' member for the promisor remote name and an 'url'
member for its URL. We will use a 'struct string_list' to store the
instances of 'struct promisor_info'. For each 'item' in the
string_list, 'item->string' will point to the promisor remote name and
'item->util' will point to the corresponding 'struct promisor_info'
instance.

Explicit members are used within 'struct promisor_info' for type
safety and clarity regarding the specific information being handled,
rather than a generic key-value store. We want to specify and document
each field and its content, so adding new members to the struct as
more fields are supported is fine.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agogit-gui: sync Makefiles with git.git
Adam Dinwoodie [Sat, 15 Feb 2025 21:19:03 +0000 (21:19 +0000)] 
git-gui: sync Makefiles with git.git

In git.git, commit 5309c1e9fb39 (Makefile: set default goals in
makefiles, 2025-02-15) touched two Makefiles in the git-git/ directory.
Import these changes, so that the trees can converge again with the
next merge of this repository into git.git.

Reported-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2 months agoMerge branch 'ml/misc-simplifications'
Johannes Sixt [Sat, 6 Sep 2025 09:59:19 +0000 (11:59 +0200)] 
Merge branch 'ml/misc-simplifications'

* ml/misc-simplifications:
  git-gui: simplify using nice(1)
  git-gui: simplify PATH de-duplication

2 months agoMerge branch 'js/ask-yesno'
Johannes Sixt [Sat, 6 Sep 2025 09:59:09 +0000 (11:59 +0200)] 
Merge branch 'js/ask-yesno'

* js/ask-yesno:
  git-gui--askyesno (mingw): use Git for Windows' icon, if available
  git-gui--askyesno: allow overriding the window title
  git gui: set GIT_ASKPASS=git-gui--askpass if not set yet
  git-gui: provide question helper for retry fallback on Windows

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2 months agoupload-pack: don't ACK non-commits repeatedly in protocol v2
Patrick Steinhardt [Fri, 5 Sep 2025 06:18:02 +0000 (08:18 +0200)] 
upload-pack: don't ACK non-commits repeatedly in protocol v2

When a client performs a fetch or clone they can optionally send "have"
lines to tell the server which objects they already have available
locally. These object IDs are stored by the server in an object array so
that it can remember any objects it doesn't have to include in the pack
sent to the client.

While there isn't any reason to do so, clients are free to send the same
"have" line repeatedly. git-upload-pack(1) already knows to handle this
well: every commit it has seen via a "have" line gets marked with the
`THEY_HAVE` flag, and if such a commit is seen repeatedly we know to not
process it another time. This also has the effect that we only store the
object ID once, only, in the `have_obj` array.

There is an edge case though: if the client sends an object ID that does
not refer to a commit we neither store nor check the `THEY_HAVE` flag.
This means that we repeatedly store the same object ID in our `have_obj`
array, with two consequences:

  - In protocol v2 we deduplicate ACKs for commits, but not for any
    other objects as we send ACKs for every object ID in the `have_obj`
    array.

  - The `have_obj` array can grow in size indefinitely with both
    protocols.

The potentially-more-serious issue is the second one, as we basically
have a way for an adversary to allocate arbitrarily large buffers now.
Ultimately, this doesn't seem to be all that serious though: on my
machine, the growth of that array is at around 4MB/s, and after roughly
five minutes I was only at 1GB RSS. So this is concerning, but only
mildly so.

Fix this bug by storing the `THEY_HAVE` flag independent of the object
type so that we don't store duplicate object IDs in `have_obj` anymore.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot5530: modernize tests
Patrick Steinhardt [Fri, 5 Sep 2025 06:18:01 +0000 (08:18 +0200)] 
t5530: modernize tests

Refactor tests to follow modern best practices:

  - Merge together tests that set up and verify a single use case.

  - Drop empty newlines at the beginning and end of test bodies.

  - Don't change directories in the main test body.

  - Remove an unused `D` variable.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomidx-write: simplify error cases
Derrick Stolee [Fri, 5 Sep 2025 19:26:18 +0000 (19:26 +0000)] 
midx-write: simplify error cases

The write_midx_internal() method uses gotos to jump to a cleanup section to
clear memory before returning 'result'. Since these jumps are more common
for error conditions, initialize 'result' to -1 and then only set it to 0
before returning with success. There are a couple places where we return
with success via a jump.

This has the added benefit that the method now returns -1 on error instead
of an inconsistent 1 or -1.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>