]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
8 weeks agot0213: add trace2 cmd_ancestry tests
Matthew John Cheetham [Fri, 13 Feb 2026 19:55:00 +0000 (19:55 +0000)] 
t0213: add trace2 cmd_ancestry tests

Add a new test script t0213-trace2-ancestry.sh that verifies
cmd_ancestry events across all three trace2 output formats (normal,
perf, and event).

The tests use the "400ancestry" test helper to spawn child processes
with controlled trace2 environments. Git alias resolution (which
spawns a child git process) creates a predictable multi-level process
tree. Filter functions extract cmd_ancestry events from each format,
truncating the ancestor list at the outermost "test-tool" so that only
the controlled portion of the tree is verified, regardless of the test
runner environment.

A runtime prerequisite (TRACE2_ANCESTRY) is used to detect whether the
platform has a real procinfo implementation; platforms with only the
stub are skipped.

We must pay attention to an extra ancestor on Windows (MINGW) when
running without the bin-wrappers (such as we do in CI). In this
situation we see an extra "sh.exe" ancestor after "test-tool.exe".

Also update the comment in t0210-trace2-normal.sh to reflect that
ancestry testing now has its own dedicated test script.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agotest-tool: extend trace2 helper with 400ancestry
Matthew John Cheetham [Fri, 13 Feb 2026 19:54:59 +0000 (19:54 +0000)] 
test-tool: extend trace2 helper with 400ancestry

Add a new test helper "400ancestry" to the trace2 test-tool that
spawns a child process with a controlled trace2 environment, capturing
only the child's trace2 output (including cmd_ancestry events) in
isolation.

The helper clears all inherited GIT_TRACE2* variables in the child
and enables only the requested target (normal, perf, or event),
directing output to a specified file. This gives the test suite a
reliable way to capture cmd_ancestry events: the child always sees
"test-tool" as its immediate parent in the process ancestry, providing
a predictable value to verify in tests.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agotrace2: emit cmd_ancestry data for Windows
Matthew John Cheetham [Fri, 13 Feb 2026 19:54:58 +0000 (19:54 +0000)] 
trace2: emit cmd_ancestry data for Windows

Since 2f732bf15e (tr2: log parent process name, 2021-07-21) it is now
now possible to emit a specific process ancestry event in TRACE2. We
should emit the Windows process ancestry data with the correct event
type.

To not break existing consumers of the data_json "windows/ancestry"
event, we continue to emit the ancestry data as a JSON event.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agotrace2: refactor Windows process ancestry trace2 event
Matthew John Cheetham [Fri, 13 Feb 2026 19:54:57 +0000 (19:54 +0000)] 
trace2: refactor Windows process ancestry trace2 event

In 353d3d77f4 (trace2: collect Windows-specific process information,
2019-02-22) we added process ancestry information for Windows to TRACE2
via a data_json event. It was only later in 2f732bf15e (tr2: log parent
process name, 2021-07-21) that the specific cmd_ancestry event was
added to TRACE2.

In a future commit we will emit the ancestry information with the newer
cmd_ancestry TRACE2 event. Right now, we rework this implementation of
trace2_collect_process_info to separate the calculation of ancestors
from building and emiting the JSON array via a data_json event.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agobuild: include procinfo.c impl for macOS
Matthew John Cheetham [Fri, 13 Feb 2026 19:54:56 +0000 (19:54 +0000)] 
build: include procinfo.c impl for macOS

Include an implementation of trace2_collect_process_info for macOS.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agotrace2: add macOS process ancestry tracing
Matthew John Cheetham [Fri, 13 Feb 2026 19:54:55 +0000 (19:54 +0000)] 
trace2: add macOS process ancestry tracing

In 353d3d77f4 (trace2: collect Windows-specific process information,
2019-02-22) Windows-specific process ancestry information was added as
a data_json event to TRACE2. Furthermore in 2f732bf15e (tr2: log
parent process name, 2021-07-21) similar functionality was added for
Linux-based systems, using procfs.

Teach Git to also log process ancestry on macOS using the sysctl with
KERN_PROC to get process information (PPID and process name).
Like the Linux implementation, we use the cmd_ancestry TRACE2 event
rather than using a data_json event and creating another custom data
point.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agotemplates: detect commit messages containing diffs
Phillip Wood [Fri, 13 Feb 2026 14:34:49 +0000 (14:34 +0000)] 
templates: detect commit messages containing diffs

If the body of a commit message contains a diff that is not indented
then "git am" will treat that diff as part of the patch rather than
as part of the commit message. This allows it to apply email messages
that were created by adding a commit message in front of a regular diff
without adding the "---" separator used by "git format-patch". This
often surprises users [1-4] so add a check to the sample "commit-msg"
hook to reject messages that would confuse "git am". Even if a project
does not use an email based workflow it is not uncommon for people
to generate patches from it and apply them with "git am". Therefore
it is still worth discouraging the creation of commit messages that
would not be applied correctly.

A further source of confusion when applying patches with "git am" is
the "---" separator that is added by "git format patch". If a commit
message body contains that line then it will be truncated by "git am".
As this is often used by patch authors to add some commentary that
they do not want to end up in the commit message when the patch is
applied, the hook does not complain about the presence of "---" lines
in the message.

Detecting if the message contains a diff is complicated by the
hook being passed the message before it is cleaned up so we need to
ignore any diffs below the scissors line. There are also two possible
config keys to check to find the comment character at the start of
the scissors line. The first paragraph of the commit message becomes
the email subject header which beings "Subject: " and so does not
need to be checked. The trailing ".*" when matching commented lines
ensures that if the comment string ends with a "$" it is not treated
as an anchor.

[1] https://lore.kernel.org/git/bcqvh7ahjjgzpgxwnr4kh3hfkksfruf54refyry3ha7qk7dldf@fij5calmscvm
[2] https://lore.kernel.org/git/ca13705ae4817ffba16f97530637411b59c9eb19.camel@scientia.org/
[3] https://lore.kernel.org/git/d0b577825124ac684ab304d3a1395f3d2d0708e8.1662333027.git.matheus.bernardino@usp.br/
[4] https://lore.kernel.org/git/CAFOYHZC6Qd9wkoWPcTJDxAs9u=FGpHQTkjE-guhwkya0DRVA6g@mail.gmail.com/

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agotemplates: add .gitattributes entry for sample hooks
Phillip Wood [Fri, 13 Feb 2026 14:34:48 +0000 (14:34 +0000)] 
templates: add .gitattributes entry for sample hooks

The sample hooks are shell scripts but the filenames end with ".sample"
so they need their own .gitattributes rule. Update our editorconfig
settings to match the attributes as well.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agosparse-checkout: use string_list_sort_u
Amisha Chhajed [Fri, 13 Feb 2026 03:37:28 +0000 (09:07 +0530)] 
sparse-checkout: use string_list_sort_u

sparse_checkout_list() uses string_list_sort and
string_list_remove_duplicates instead of string_list_sort_u.

use string_list_sort_u at that place.

Signed-off-by: Amisha Chhajed <136238836+amishhaa@users.noreply.github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agodoc: add caveat about round-tripping format-patch
Kristoffer Haugsbakk [Thu, 12 Feb 2026 22:28:23 +0000 (23:28 +0100)] 
doc: add caveat about round-tripping format-patch

git-format-patch(1) and git-am(1) deal with formatting commits as
patches and applying them, respectively. Naturally they use a few
delimiters to mark where the commit message ends. This can lead to
surprising behavior when these delimiters are used in the commit
message itself.

git-format-patch(1) will accept any commit message and not warn or error
about these delimiters being used.[1]

Especially problematic is the presence of unindented diffs in the commit
message; the patch machinery will naturally (since the commit message
has ended) try to apply that diff and everything after it.[2]

It is unclear whether any commands in this chain will learn to warn
about this. One concern could be that users have learned to rely on
the three-dash line rule to conveniently add extra-commit message
information in the commit message, knowing that git-am(1) will
ignore it.[4]

All of this is covered already, technically. However, we should spell
out the implications.

† 1: There is also git-commit(1) to consider. However, making that
     command warn or error out over such delimiters would be disruptive
     to all Git users who never use email in their workflow.
† 2: Recently patch(1) caused this issue for a project, but it was noted
     that git-am(1) has the same behavior[3]
† 3: https://github.com/i3/i3/pull/6564#issuecomment-3858381425
† 4: https://lore.kernel.org/git/xmqqldh4b5y2.fsf@gitster.g/
     https://lore.kernel.org/git/V3_format-patch_caveats.354@msgid.xyz/

Reported-by: Matthias Beyer <mail@beyermatthias.de>
Reported-by: Christoph Anton Mitterer <calestyo@scientia.org>
Reported-by: Matheus Tavares <matheus.tavb@gmail.com>
Reported-by: Chris Packham <judge.packham@gmail.com>
Helped-by: Jakob Haufe <sur5r@sur5r.net>
Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agot9812: modernize test path helpers
Ashwani Kumar Kamal [Thu, 12 Feb 2026 05:45:30 +0000 (11:15 +0530)] 
t9812: modernize test path helpers

Replace assertion-style 'test -f' checks with Git's
test_path_is_file() helper for clearer failures and
consistency.

Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoodb: convert `odb_has_object()` flags into an enum
Patrick Steinhardt [Thu, 12 Feb 2026 06:59:41 +0000 (07:59 +0100)] 
odb: convert `odb_has_object()` flags into an enum

Following the reason in the preceding commit, convert the
`odb_has_object()` flags into an enum.

With this change, we would have catched the misuse of `odb_has_object()`
that was fixed in a preceding commit as the compiler would have
generated a warning:

  ../builtin/backfill.c:71:9: error: implicit conversion from enumeration type 'enum odb_object_info_flag' to different enumeration type 'enum odb_has_object_flag' [-Werror,-Wenum-conversion]
     70 |                 if (!odb_has_object(ctx->repo->objects, &list->oid[i],
        |                      ~~~~~~~~~~~~~~
     71 |                                     OBJECT_INFO_FOR_PREFETCH))
        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoodb: convert object info flags into an enum
Patrick Steinhardt [Thu, 12 Feb 2026 06:59:40 +0000 (07:59 +0100)] 
odb: convert object info flags into an enum

Convert the object info flags into an enum and adapt all functions that
receive these flags as parameters to use the enum instead of an integer.
This serves two purposes:

  - The function signatures become more self-documenting, as callers
    don't have to wonder which flags they expect.

  - The compiler can warn when a wrong flag type is passed.

Note that the second benefit is somewhat limited. For example, when
or-ing multiple enum flags together the result will be an integer, and
the compiler will not warn about such use cases. But where it does help
is when a single flag of the wrong type is passed, as the compiler would
generate a warning in that case.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoodb: drop gaps in object info flag values
Patrick Steinhardt [Thu, 12 Feb 2026 06:59:39 +0000 (07:59 +0100)] 
odb: drop gaps in object info flag values

The object info flag values have a two gaps in their definitions, where
some bits are skipped over. These gaps don't really hurt, but it makes
one wonder whether anything is going on and whether a subset of flags
might be defined somewhere else.

That's not the case though. Instead, this is a case of flags that have
been dropped in the past:

  - The value 4 was used by `OBJECT_INFO_SKIP_CACHED`, removed in
    9c8a294a1a (sha1-file: remove OBJECT_INFO_SKIP_CACHED, 2020-01-02).

  - The value 8 was used by `OBJECT_INFO_ALLOW_UNKNOWN_TYPE`, removed in
    ae24b032a0 (object-file: drop OBJECT_INFO_ALLOW_UNKNOWN_TYPE flag,
    2025-05-16).

Close those gaps to avoid any more confusion.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agobuiltin/fsck: fix flags passed to `odb_has_object()`
Patrick Steinhardt [Thu, 12 Feb 2026 06:59:38 +0000 (07:59 +0100)] 
builtin/fsck: fix flags passed to `odb_has_object()`

In `mark_object()` we invoke `has_object()` with a value of 1. This is
somewhat fishy given that the function expects a bitset of flags, so any
behaviour that this results in is purely coincidental and may break at
any point in time.

The call to `has_object()` was originally introduced in 9eb86f41de
(fsck: do not lazy fetch known non-promisor object, 2020-08-05). The
intent here was to skip lazy fetches of promisor objects: we have
already verified that the object is not a promisor object, so if the
object is missing it indicates a corrupt repository.

The hardcoded value that we pass maps to `HAS_OBJECT_RECHECK_PACKED`,
which is probably the intended behaviour: `odb_has_object()` will not
fetch promisor objects unless `HAS_OBJECT_FETCH_PROMISOR` is passed, but
we may want to verify that no concurrent process has written the object
that we're trying to read.

Convert the code to use the named flag instead of the the hardcoded
value.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agobuiltin/backfill: fix flags passed to `odb_has_object()`
Patrick Steinhardt [Thu, 12 Feb 2026 06:59:37 +0000 (07:59 +0100)] 
builtin/backfill: fix flags passed to `odb_has_object()`

The function `fill_missing_blobs()` receives an array of object IDs and
verifies for each of them whether the corresponding object exists. If it
doesn't exist, we add it to a set of objects and then batch-fetch all of
the objects at once.

The check for whether or not we already have the object is broken
though: we pass `OBJECT_INFO_FOR_PREFETCH`, but `odb_has_object()`
expects us to pass `HAS_OBJECT_*` flags. The flag expands to:

  - `OBJECT_INFO_QUICK`, which asks the object database to not reprepare
    in case the object wasn't found. This makes sense, as we'd otherwise
    reprepare the object database as many times as we have missing
    objects.

  - `OBJECT_INFO_SKIP_FETCH_OBJECT`, which asks the object database to
    not fetch the object in case it's missing. Again, this makes sense,
    as we want to batch-fetch the objects.

This shows that we indeed want the equivalent of this flag, but of
course represented as `HAS_OBJECT_*` flags.

Luckily, the code is already working correctly. The `OBJECT_INFO` flag
expands to `(1 << 3) | (1 << 4)`, none of which are valid `HAS_OBJECT`
flags. And if no flags are passed, `odb_has_object()` ends up calling
`odb_read_object_info_extended()` with exactly the above two flags that
we wanted to set in the first place.

Of course, this is pure luck, and this can break any moment. So let's
fix this and correct the code to not pass any flags at all.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agodiff --anchored: avoid checking unmatched lines
Phillip Wood [Thu, 12 Feb 2026 15:53:50 +0000 (15:53 +0000)] 
diff --anchored: avoid checking unmatched lines

For a line to be an anchor it has to appear in each of the files being
diffed exactly once. With that in mind lets delay checking whether
a line is an anchor until we know there is exactly one instance of
the line in each file. As each line is checked at most once, there
is no need to cache the result of is_anchor() and we can drop that
field from the hashmap entries. When diffing 5000 recent commits in
git.git this gives a modest speedup of ~2%. In the (rather extreme)
example below that consists largely of deletions the speedup is ~16%.

    seq 0 10000000 >old
    printf '%s\n' 300000 100000 200000 >new
    git diff --no-index --anchored=300000 old new

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoMerge branch 'master' of https://github.com/j6t/gitk
Junio C Hamano [Wed, 11 Feb 2026 22:49:53 +0000 (14:49 -0800)] 
Merge branch 'master' of https://github.com/j6t/gitk

* 'master' of https://github.com/j6t/gitk:
  gitk: fix msgfmt being required
  gitk: fix highlighted remote prefix of branches with directories

8 weeks agoCodingGuidelines: document // comments
Junio C Hamano [Wed, 11 Feb 2026 19:17:48 +0000 (11:17 -0800)] 
CodingGuidelines: document // comments

We do not use // comments in our C code, which is implied by the
description of multi-line comment rule and its examples, but is not
explicitly spelled out.  Spell it out.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoThe 3rd batch
Junio C Hamano [Wed, 11 Feb 2026 19:53:49 +0000 (11:53 -0800)] 
The 3rd batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoMerge branch 'rs/blame-ignore-colors-fix'
Junio C Hamano [Wed, 11 Feb 2026 20:29:08 +0000 (12:29 -0800)] 
Merge branch 'rs/blame-ignore-colors-fix'

"git blame --ignore-revs=... --color-lines" did not account for
ignored revisions passing blame to the same commit an adjacent line
gets blamed for.

* rs/blame-ignore-colors-fix:
  blame: fix coloring for repeated suspects

8 weeks agoMerge branch 'hs/t9160-test-paths'
Junio C Hamano [Wed, 11 Feb 2026 20:29:07 +0000 (12:29 -0800)] 
Merge branch 'hs/t9160-test-paths'

Test update.

* hs/t9160-test-paths:
  t9160:modernize test path checking

8 weeks agoMerge branch 'am/doc-github-contributiong-link-to-submittingpatches'
Junio C Hamano [Wed, 11 Feb 2026 20:29:07 +0000 (12:29 -0800)] 
Merge branch 'am/doc-github-contributiong-link-to-submittingpatches'

GitHub repository banner update.

* am/doc-github-contributiong-link-to-submittingpatches:
  .github/CONTRIBUTING.md: link to SubmittingPatches on git-scm.com

8 weeks agoMerge branch 'kh/doc-shortlog-fix'
Junio C Hamano [Wed, 11 Feb 2026 20:29:07 +0000 (12:29 -0800)] 
Merge branch 'kh/doc-shortlog-fix'

Doc fix.

* kh/doc-shortlog-fix:
  doc: shortlog: put back trailer paragraphs

8 weeks agoMerge branch 'sp/show-index-warn-fallback'
Junio C Hamano [Wed, 11 Feb 2026 20:29:06 +0000 (12:29 -0800)] 
Merge branch 'sp/show-index-warn-fallback'

When "git show-index" is run outside a repository, it silently
defaults to SHA-1; the tool now warns when this happens.

* sp/show-index-warn-fallback:
  show-index: use gettext wrapping in user facing error messages
  show-index: warn when falling back to SHA-1 outside a repository

8 weeks agobuiltin/pack-objects: don't fetch objects when merging packs
Patrick Steinhardt [Wed, 11 Feb 2026 12:44:59 +0000 (13:44 +0100)] 
builtin/pack-objects: don't fetch objects when merging packs

The "--stdin-packs" option can be used to merge objects from multiple
packfiles given via stdin into a new packfile. One big upside of this
option is that we don't have to perform a complete rev walk to enumerate
objects. Instead, we can simply enumerate all objects that are part of
the specified packfiles, which can be significantly faster in very large
repositories.

There is one downside though: when we don't perform a rev walk we also
don't have a good way to learn about the respective object's names. As a
consequence, we cannot use the name hashes as a heuristic to get better
delta selection.

We try to offset this downside though by performing a localized rev
walk: we queue all objects that we're about to repack as interesting,
and all objects from excluded packfiles as uninteresting. We then
perform a best-effort rev walk that allows us to fill in object names.

There is one gotcha here though: when "--exclude-promisor-objects" has
not been given we will perform backfill fetches for any promised objects
that are missing. This used to not be an issue though as this option was
mutually exclusive with "--stdin-packs". But that has changed recently,
and starting with dcc9c7ef47 (builtin/repack: handle promisor packs with
geometric repacking, 2026-01-05) we will now repack promisor packs
during geometric compaction. The consequence is that a geometric repack
may now perform a bunch of backfill fetches.

We of course cannot pass "--exclude-promisor-objects" to fix this
issue -- after all, the whole intent is to repack objects part of a
promisor pack. But arguably we don't have to: the rev walk is intended
as best effort, and we already configure it to ignore missing links to
other objects. So we can adapt the walk to unconditionally disable
fetching any missing objects.

Do so and add a test that verifies we don't backfill any objects.

Reported-by: Lukas Wanko <lwanko@gitlab.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agodoc: rerere-options.adoc: link to git-rerere(1)
Kristoffer Haugsbakk [Tue, 10 Feb 2026 19:56:49 +0000 (20:56 +0100)] 
doc: rerere-options.adoc: link to git-rerere(1)

Five commands include these options. Let’s link to the command so that
the curious user can learn more about what “rerere” is about.

It’s also better to consistently refer to things like
e.g. “git-subcommand(1)” over `git subcommand` or `subcommand`.

Also apply the same treatment to git-add(1).

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoxdiff-interface: stop using the_repository
René Scharfe [Mon, 9 Feb 2026 19:24:52 +0000 (20:24 +0100)] 
xdiff-interface: stop using the_repository

Use the algorithm-agnostic is_null_oid() and push the dependency of
read_mmblob() on the_repository->objects to its callers.  This allows it
to be used with arbitrary object databases.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoThe second batch
Junio C Hamano [Mon, 9 Feb 2026 20:08:48 +0000 (12:08 -0800)] 
The second batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agoMerge branch 'ty/perf-3400-optim'
Junio C Hamano [Mon, 9 Feb 2026 20:09:10 +0000 (12:09 -0800)] 
Merge branch 'ty/perf-3400-optim'

Improve set-up time of a perf test.

* ty/perf-3400-optim:
  t/perf/p3400: speed up setup using fast-import

8 weeks agoMerge branch 'ac/string-list-sort-u-and-tests'
Junio C Hamano [Mon, 9 Feb 2026 20:09:10 +0000 (12:09 -0800)] 
Merge branch 'ac/string-list-sort-u-and-tests'

The string_list API gains a new helper, string_list_sort_u(), and
new unit tests to extend coverage.

* ac/string-list-sort-u-and-tests:
  string-list: add string_list_sort_u() that mimics "sort -u"
  u-string-list: add unit tests for string-list methods

8 weeks agoMerge branch 'sb/doc-worktree-prune-expire-improvement'
Junio C Hamano [Mon, 9 Feb 2026 20:09:10 +0000 (12:09 -0800)] 
Merge branch 'sb/doc-worktree-prune-expire-improvement'

The help text and the documentation for the "--expire" option of
"git worktree [list|prune]" have been improved.

* sb/doc-worktree-prune-expire-improvement:
  worktree: clarify that --expire only affects missing worktrees

8 weeks agoMerge branch 'kn/ref-batch-output-error-reporting-fix'
Junio C Hamano [Mon, 9 Feb 2026 20:09:10 +0000 (12:09 -0800)] 
Merge branch 'kn/ref-batch-output-error-reporting-fix'

A handful of code paths that started using batched ref update API
(after Git 2.51 or so) lost detailed error output, which have been
corrected.

* kn/ref-batch-output-error-reporting-fix:
  fetch: delay user information post committing of transaction
  receive-pack: utilize rejected ref error details
  fetch: utilize rejected ref error details
  update-ref: utilize rejected error details if available
  refs: add rejection detail to the callback function
  refs: skip to next ref when current ref is rejected

8 weeks agoMerge branch 'pw/replay-drop-empty'
Junio C Hamano [Mon, 9 Feb 2026 20:09:09 +0000 (12:09 -0800)] 
Merge branch 'pw/replay-drop-empty'

"git replay" is taught to drop commits that become empty (not the
ones that are empty in the original).

* pw/replay-drop-empty:
  replay: drop commits that become empty

8 weeks agoMerge branch 'ps/history'
Junio C Hamano [Mon, 9 Feb 2026 20:09:09 +0000 (12:09 -0800)] 
Merge branch 'ps/history'

"git history" history rewriting UI.

* ps/history:
  builtin/history: implement "reword" subcommand
  builtin: add new "history" command
  wt-status: provide function to expose status for trees
  replay: support updating detached HEAD
  replay: support empty commit ranges
  replay: small set of cleanups
  builtin/replay: move core logic into "libgit.a"
  builtin/replay: extract core logic to replay revisions

8 weeks agorerere: minor documantation update
Junio C Hamano [Mon, 9 Feb 2026 18:27:29 +0000 (10:27 -0800)] 
rerere: minor documantation update

Let's not call our users "it".  Also "rerere forget \*.c" does not
forget resolutions for just '*.c'; it forgets for all the files
whose filenames end with ".c".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agodoc: am: fill out hook discussion
Kristoffer Haugsbakk [Mon, 9 Feb 2026 17:34:37 +0000 (18:34 +0100)] 
doc: am: fill out hook discussion

Document `--verify` and rephrase the `--[no-]verify` section to lead
with the default, in imperative mood.[1]

Historically it makes sense that only the negated forms are documented;
they are all run by default and thus you only need to use hook options
if you want to turn some of them off. But, beyond just desiring uniform
documentation,[2] it’s very much possible to have, say, a Git alias with
`--no-verify` that you might sometimes want to turn back on with
the *positive* form.

Also mention the options in the “Hooks” section and mention that
`post-applypatch` cannot be skipped.

† 1: See e.g. acffc5e9 (doc: convert git-remote to synopsis style,
     2025-12-20)
† 2: https://lore.kernel.org/git/xmqqcyct1mtq.fsf@gitster.g/

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agodoc: am: add missing config am.messageId
Kristoffer Haugsbakk [Mon, 9 Feb 2026 17:34:36 +0000 (18:34 +0100)] 
doc: am: add missing config am.messageId

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agodoc: am: say that --message-id adds a trailer
Kristoffer Haugsbakk [Mon, 9 Feb 2026 17:34:35 +0000 (18:34 +0100)] 
doc: am: say that --message-id adds a trailer

The option `--message-id` was added in a078f732 (git-am: add
--message-id/--no-message-id, 2014-11-25) back when git-interpret-
trailers(1) was relatively new. Let’s spell out that it is a trailer
and link to the dedicated trailer command.

Also use inline-verbatim for `Message-ID`.

Also link to git-interpret-trailers(1) on `--signoff`.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agodoc: am: normalize git(1) command links
Kristoffer Haugsbakk [Mon, 9 Feb 2026 17:34:34 +0000 (18:34 +0100)] 
doc: am: normalize git(1) command links

There are many mentions of commands using inline-verbatim or
emphasis ('). We just mention the command themselves, not specific
invocations like `git am <opts>`. Let’s link to them instead.

There are also many such mentions which then link to the command right
afterwards. Simplify to just using a link.

Also remove “see <gitlink>” phrases where they have now already
been mentioned.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agot7003: modernize path existence checks using test helpers
SoutrikDas [Mon, 9 Feb 2026 17:24:45 +0000 (22:54 +0530)] 
t7003: modernize path existence checks using test helpers

Replace direct uses of 'test -f' and 'test -d' with
git's helper functions 'test_path_is_file' ,
'test_path_is_missing' and 'test_path_is_dir'

Signed-off-by: SoutrikDas <valusoutrik@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agot2003: modernize path existence checks using test helpers
Burak Kaan Karaçay [Mon, 9 Feb 2026 11:24:44 +0000 (14:24 +0300)] 
t2003: modernize path existence checks using test helpers

The old style 'test -f' and 'test -d' checks are silent on failure,
which makes debugging difficult.

Replace them with the 'test_path_is_*' helpers which provide verbose
error messages when a test fails.

Signed-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agomeson: fix building mergetool docs
Phillip Wood [Mon, 9 Feb 2026 10:08:43 +0000 (10:08 +0000)] 
meson: fix building mergetool docs

Building the documentation with meson when the build directory is
not an immediate subdirectory of the source directory prints the
following error

[2/1349] Generating Documentation/mer... command (wrapped by meson to set env)
../../Documentation/generate-mergetool-list.sh: line 15: ../git-mergetool--lib.sh: No such file or directory

The build does not fail because the failure is upstream of a pipe. Fix
the error by passing the correct source directory when meson runs
"generate-mergetool-list.sh". As that script sets $MERGE_TOOLS_DIR
we do not need to set it in the environment when running the script.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agocheckout: tell "parse_remote_branch" which command is calling it
Junio C Hamano [Thu, 29 Jan 2026 19:06:16 +0000 (11:06 -0800)] 
checkout: tell "parse_remote_branch" which command is calling it

When "git checkout <dwim>" and "git switch <dwim>" need to error out
due to ambiguity of the branch name <dwim>, these two commands give
an advise message with a sample command that tells the user how to
disambiguate from the parse_remote_branch() function.  The sample
command hardcodes "git checkout", since this feature predates "git
switch" by a large margin.  To a user who said "git switch <dwim>"
and got this message, it is confusing.

Pass the "enum checkout_command", which was invented in the previous
step for this exact purpose, down the call chain leading to
parse_remote_branch() function to change the sample command shown to
the user in this advise message.

Also add a bit more test coverage for this "fail to DWIM under
ambiguity" that we lack, as well as the message we produce when we
fail.

Reported-by: Simon Cheng <cyqsimon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
8 weeks agocheckout: pass program-readable token to unified "main"
Junio C Hamano [Thu, 29 Jan 2026 19:06:15 +0000 (11:06 -0800)] 
checkout: pass program-readable token to unified "main"

The "git checkout", "git switch", and "git restore" commands share a
single implementation, checkout_main(), which switches error message
it gives using the usage string passed by each of these three
front-ends.

In order to be able to tweak behaviours of the commands based on
which one we are executing, invent an enum that denotes which one of
these three commands is currently executing, and pass that to
checkout_main() instead.  With this step, there is no externally
visible behaviour change, as this enum parameter is only used to
choose among the three usage strings.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoversion: stop using the_repository
René Scharfe [Sun, 8 Feb 2026 17:01:24 +0000 (18:01 +0100)] 
version: stop using the_repository

Actually it has never been used in version.c since cf7ee481902 (agent:
advertise OS name via agent capability, 2025-02-15) added the dependency
macro.  Remove it, along with the also unused struct declaration.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoremove duplicate includes
René Scharfe [Sun, 8 Feb 2026 12:32:22 +0000 (13:32 +0100)] 
remove duplicate includes

The following command reports that some header files are included twice:

   $ git grep '#include' '*.c' | sort | uniq -cd

Remove the second #include line in each case, as it has no effect.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocommit: use commit_stack
René Scharfe [Sun, 8 Feb 2026 11:37:38 +0000 (12:37 +0100)] 
commit: use commit_stack

Use commit_stack instead of open-coding it.  Also convert the loop
counter i to size_t to match the type of the nr member of struct
commit_stack.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoobject-file-convert: always make sure object ID algo is valid
brian m. carlson [Sat, 7 Feb 2026 20:04:46 +0000 (20:04 +0000)] 
object-file-convert: always make sure object ID algo is valid

In some cases, we zero-initialize our object IDs, which sets the algo
member to zero as well, which is not a valid algorithm number.  This is
a bad practice, but we typically paper over it in many cases by simply
substituting the repository's hash algorithm.

However, our new Rust loose object map code doesn't handle this
gracefully and can't find object IDs when the algorithm is zero because
they don't compare equal to those with the correct algo field.  In
addition, the comparison code doesn't have any knowledge of what the
main algorithm is because that's global state, so we can't adjust the
comparison.

To make our code function properly and to avoid propagating these bad
entries, if we get a source object ID with a zero algo, just make a copy
of it with the fixed algorithm.  This has the benefit of also fixing the
object IDs if we're in a single algorithm mode as well.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorust: add a small wrapper around the hashfile code
brian m. carlson [Sat, 7 Feb 2026 20:04:45 +0000 (20:04 +0000)] 
rust: add a small wrapper around the hashfile code

Our new binary object map code avoids needing to be intimately involved
with file handling by simply writing data to an object implement Write.
This makes it very easy to test by writing to a Cursor wrapping a Vec
for tests, and thus decouples it from intimate knowledge about how we
handle files.

However, we will actually want to write our data to an actual file,
since that's the most practical way to persist data.  Implement a
wrapper around the hashfile code that implements the Write trait so that
we can write our object map into a file.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorust: add a new binary object map format
brian m. carlson [Sat, 7 Feb 2026 20:04:44 +0000 (20:04 +0000)] 
rust: add a new binary object map format

Our current loose object format has a few problems.  First, it is not
efficient: the list of object IDs is not sorted and even if it were,
there would not be an efficient way to look up objects in both
algorithms.

Second, we need to store mappings for things which are not technically
loose objects but are not packed objects, either, and so cannot be
stored in a pack index.  These kinds of things include shallows, their
parents, and their trees, as well as submodules. Yet we also need to
implement a sensible way to store the kind of object so that we can
prune unneeded entries.  For instance, if the user has updated the
shallows, we can remove the old values.

For these reasons, introduce a new binary object map format.  The
careful reader will notice that it resembles very closely the pack index
v3 format.  Add an in-memory object map as well, and allow writing to a
batched map, which can then be written later as one of the binary object
maps.  Include several tests for round tripping and data lookup across
algorithms.

Note that the use of this code elsewhere in Git will involve some C code
and some C-compatible code in Rust that will be introduced in a future
commit.  Thus, for example, we ignore the fact that if there is no
current batch and the caller asks for data to be written, this code does
nothing, mostly because this code also does not involve itself with
opening or manipulating files.  The C code that we will add later will
implement this functionality at a higher level and take care of this,
since the code which is necessary for writing to the object store is
deeply involved with our C abstractions and it would require extensive
work (which would not be especially valuable at this point) to port
those to Rust.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorust: add functionality to hash an object
brian m. carlson [Sat, 7 Feb 2026 20:04:43 +0000 (20:04 +0000)] 
rust: add functionality to hash an object

In a future commit, we'll want to hash some data when dealing with an
object map.  Let's make this easy by creating a structure to hash
objects and calling into the C functions as necessary to perform the
hashing.  For now, we only implement safe hashing, but in the future we
could add unsafe hashing if we want.  Implement Clone and Drop to
appropriately manage our memory.  Additionally implement Write to make
it easy to use with other formats that implement this trait.

While we're at it, add some tests for the various hashing cases.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorust: add a build.rs script for tests
brian m. carlson [Sat, 7 Feb 2026 20:04:42 +0000 (20:04 +0000)] 
rust: add a build.rs script for tests

Cargo uses the build.rs script to determine how to compile and link a
binary.  The only binary we're generating, however, is for our tests,
but in a future commit, we're going to link against libgit.a for some
functionality and we'll need to make sure the test binaries are
complete.

Add a build.rs file for this case and specify the files we're going to
be linking against.  Because we cannot specify different dependencies
when building our static library versus our tests, update the Makefile
to specify these dependencies for our static library to avoid race
conditions during build.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorust: fix linking binaries with cargo
brian m. carlson [Sat, 7 Feb 2026 20:04:41 +0000 (20:04 +0000)] 
rust: fix linking binaries with cargo

When Cargo links binaries with MSVC, it uses the link.exe linker from
PATH to do so.  However, when running under a shell from MSYS, such as
when building with the Git for Windows SDK, which we do in CI, the
/ming64/bin and /usr/bin entries are first in PATH.  That means that the
Unix link binary shows up first, which obviously does not work for
linking binaries in any useful way.

To solve this problem, adjust PATH to place those binaries at the end of
the list instead of the beginning.  This allows access to the normal
Unix tools, but link.exe will be the compiler's linker.  Make sure to
export PATH explicitly: while this should be the default, it's more
robust to not rely on the shell operating in a certain way.

The reason this has not shown up before is that we typically link our
binaries from the C compiler.  However, now that we're about to
introduce a Rust build script (build.rs file), Rust will end up linking
that script to further drive Cargo, in which case we'll invoke the
linker from it.  There are other solutions, such as using LLD, but this
one is simple and reliable and is most likely to work with existing
systems.

Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com>
Signed-off-by: brian m. carlson <bk2204@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agohash: expose hash context functions to Rust
brian m. carlson [Sat, 7 Feb 2026 20:04:40 +0000 (20:04 +0000)] 
hash: expose hash context functions to Rust

We'd like to be able to hash our data in Rust using the same contexts as
in C.  However, we need our helper functions to not be inline so they
can be linked into the binary appropriately.  In addition, to avoid
managing memory manually and since we don't know the size of the hash
context structure, we want to have simple alloc and free functions we
can use to make sure a context can be easily dynamically created.

Expose the helper functions and create alloc, free, and init functions
we can call.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agowrite-or-die: add an fsync component for the object map
brian m. carlson [Sat, 7 Feb 2026 20:04:39 +0000 (20:04 +0000)] 
write-or-die: add an fsync component for the object map

We'll soon be writing out an object map using the hashfile code. Add an
fsync component to allow us to handle fsyncing it correctly.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocsum-file: define hashwrite's count as a uint32_t
brian m. carlson [Sat, 7 Feb 2026 20:04:38 +0000 (20:04 +0000)] 
csum-file: define hashwrite's count as a uint32_t

We want to call this code from Rust and ensure that the types are the
same for compatibility, which is easiest to do if the type is a fixed
size.  Since unsigned int is 32 bits on all the platforms we care about,
define it as a uint32_t instead.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorust: add additional helpers for ObjectID
brian m. carlson [Sat, 7 Feb 2026 20:04:37 +0000 (20:04 +0000)] 
rust: add additional helpers for ObjectID

Right now, users can internally access the contents of the ObjectID
struct, which can lead to data that is not valid, such as invalid
algorithms or non-zero-padded hash values.  These can cause problems
down the line as we use them more.

Add a constructor for ObjectID that allows us to set these values and
also provide an accessor for the algorithm so that we can access it.  In
addition, provide useful Display and Debug implementations that can
format our data in a useful way.

Now that we have the ability to work with these various components in a
nice way, add some tests as well to make sure that ObjectID and
HashAlgorithm work together as expected.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agohash: add a function to look up hash algo structs
brian m. carlson [Sat, 7 Feb 2026 20:04:36 +0000 (20:04 +0000)] 
hash: add a function to look up hash algo structs

In C, it's easy for us to look up a hash algorithm structure by its
offset by simply indexing the hash_algos array.  However, in Rust, we
sometimes need a pointer to pass to a C function, but we have our own
hash algorithm abstraction.

To get one from the other, let's provide a simple function that looks up
the C structure from the offset and expose it in Rust.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorust: add a hash algorithm abstraction
brian m. carlson [Sat, 7 Feb 2026 20:04:35 +0000 (20:04 +0000)] 
rust: add a hash algorithm abstraction

This works very similarly to the existing one in C except that it
doesn't provide any functionality to hash an object.  We don't currently
need that right now, but the use of those function pointers do make it
substantially more difficult to write a bit-for-bit identical structure
across the C/Rust interface, so omit them for now.

Instead of the more customary "&self", use "self", because the former is
the size of a pointer and the latter is the size of an integer on most
systems.  Don't define an unknown value but use an Option for that
instead.

Update the object ID structure to allow slicing the data appropriately
for the algorithm.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorust: add a ObjectID struct
brian m. carlson [Sat, 7 Feb 2026 20:04:34 +0000 (20:04 +0000)] 
rust: add a ObjectID struct

We'd like to be able to write some Rust code that can work with object
IDs.  Add a structure here that's identical to struct object_id in C,
for easy use in sharing across the FFI boundary.  We will use this
structure in several places in hot paths, such as index-pack or
pack-objects when converting between algorithms, so prioritize efficient
interchange over a more idiomatic Rust approach.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agohash: use uint32_t for object_id algorithm
brian m. carlson [Sat, 7 Feb 2026 20:04:33 +0000 (20:04 +0000)] 
hash: use uint32_t for object_id algorithm

We currently use an int for this value, but we'll define this structure
from Rust in a future commit and we want to ensure that our data types
are exactly identical.  To make that possible, use a uint32_t for the
hash algorithm.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoconversion: don't crash when no destination algo
brian m. carlson [Sat, 7 Feb 2026 20:04:32 +0000 (20:04 +0000)] 
conversion: don't crash when no destination algo

When we set up a repository that doesn't have a compatibility hash
algorithm, we set the destination algorithm object to NULL.  In such a
case, we want to silently do nothing instead of crashing, so simply
treat the operation as a no-op and copy the object ID.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorepository: require Rust support for interoperability
brian m. carlson [Sat, 7 Feb 2026 20:04:31 +0000 (20:04 +0000)] 
repository: require Rust support for interoperability

We'll be implementing some of our interoperability code, like the loose
object map, in Rust.  While the code currently compiles with the old
loose object map format, which is written entirely in C, we'll soon
replace that with the Rust-based implementation.

Require the use of Rust for compatibility mode and die if it is not
supported.  Because the repo argument is not used when Rust is missing,
cast it to void to silence the compiler warning, which we do not care
about.

Add a prerequisite in our tests, RUST, that checks if Rust functionality
is available and use it in the tests that handle interoperability.

This is technically a regression in functionality compared to our
existing state, but pack index v3 is not yet implemented and thus the
functionality is mostly quite broken, which is why we've recently marked
this functionality as experimental.  We don't believe anyone is getting
useful use out of the interoperability code in its current state, so no
actual users should be negatively impacted by this change.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocompletion: add stash import, export
D. Ben Knoble [Sat, 7 Feb 2026 21:59:16 +0000 (16:59 -0500)] 
completion: add stash import, export

These newer commands lack completion; implement basic support for
options and arguments.

Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomerge-file: honor merge.conflictStyle outside of a repository
Yannik Tausch [Sat, 7 Feb 2026 21:37:48 +0000 (22:37 +0100)] 
merge-file: honor merge.conflictStyle outside of a repository

When running outside a repository, git merge-file ignores the
merge.conflictStyle configuration variable entirely. Since the
function receives `repo` from the caller (which is NULL outside a
repository), and repo_config() falls back to reading system and user
configuration when passed NULL, pass `repo` to repo_config()
unconditionally.

Also document that merge.conflictStyle is honored.

Signed-off-by: Yannik Tausch <dev@ytausch.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoci: ubuntu: use GNU coreutils for dirname
Colin Stagner [Sat, 7 Feb 2026 04:27:03 +0000 (22:27 -0600)] 
ci: ubuntu: use GNU coreutils for dirname

The uutils version of `dirname` has output that is inconsistent
with GNU coreutils. Prefer the GNU implementation of this command.

Signed-off-by: Colin Stagner <ask+git@howdoi.land>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomerge-ours: integrate with sparse-index
Sam Bostock [Fri, 6 Feb 2026 19:16:23 +0000 (19:16 +0000)] 
merge-ours: integrate with sparse-index

The merge-ours built-in opens the index to compare it against HEAD.
The machinery used to do this (i.e. run_diff_index()) is capable of
working with a sparse index, but the start-up sequence of this
command does not take the necessary steps, so we end up expanding the
index fully before doing the comparison.

In order to convince sparse-index.c:is_sparse_index_allowed() to
return true, we need to:

 - Read basic configuration with git_default_config so that global
   variables like core_apply_sparse_checkout are populated.
   merge-ours currently does not read configuration at all.

 - Set command_requires_full_index to 0.

With that, the command can work without expanding the index fully
before doing its work.

Signed-off-by: Sam Bostock <sam@sambostock.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomerge-ours: drop USE_THE_REPOSITORY_VARIABLE
Sam Bostock [Fri, 6 Feb 2026 19:16:22 +0000 (19:16 +0000)] 
merge-ours: drop USE_THE_REPOSITORY_VARIABLE

The merge-ours built-in uses the `the_repository` global to access
the repository. The project is moving away from this global in favor
of the `repo` parameter that is passed to each built-in command.
Since merge-ours is registered with RUN_SETUP, `repo` is guaranteed
to be non-NULL and can be used directly.

Drop the USE_THE_REPOSITORY_VARIABLE macro and use `repo` throughout.

While at it, remove a stray double blank line between the #include
block and the usage string.

Signed-off-by: Sam Bostock <sam@sambostock.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoDocumentation: update add --force option + ignore=all config
Claus Schneider(Eficode) [Fri, 6 Feb 2026 13:23:00 +0000 (13:23 +0000)] 
Documentation: update add --force option + ignore=all config

- git-add.adoc: Update the --force documentation for submodule behaviour
  to be added even the given configuration ignore=all.
- gitmodules.adoc and config/submodule.adoc: The submodule config
  ignore=all now need --force in order to update the index.

Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agotests: fix existing tests when add an ignore=all submodule
Claus Schneider(Eficode) [Fri, 6 Feb 2026 13:22:59 +0000 (13:22 +0000)] 
tests: fix existing tests when add an ignore=all submodule

There are tests that rely on "git add <submodule>" to update the in the
reference in the parent repository which have been updated to use the
--force option.

Updated tests:
- t1013-read-tree-submodule.sh ( fixed in: t/lib-submodule-update.sh )
- t2013-checkout-submodule.sh ( fixed in: t/lib-submodule-update.sh )
- t7406-submodule-update.sh
- t7508-status.sh

Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agotests: t2206-add-submodule-ignored: ignore=all and add --force tests
Claus Schneider(Eficode) [Fri, 6 Feb 2026 13:22:58 +0000 (13:22 +0000)] 
tests: t2206-add-submodule-ignored: ignore=all and add --force tests

The tests verify that the submodule behavior is intact and updating the
config with ignore=all also behaves as intended with configuration in
.gitmodules and configuration given on the command line.

The usage of --force is showcased and tested in the test suite.

The test file is added to meson.build for execution.

Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoread-cache: submodule add need --force given ignore=all configuration
Claus Schneider(Eficode) [Fri, 6 Feb 2026 13:22:57 +0000 (13:22 +0000)] 
read-cache: submodule add need --force given ignore=all configuration

Submodules configured with ignore=all are now skipped during add operations
unless overridden by --force and the submodule path is explicitly specified.

A message is printed (like ignored files) guiding the user to use the
--force flag if the user explicitly wants to update the submodule reference.

The reason for the change is to support branch tracking in submodules
with configuration `submdule.<name>.branch` or similar workflows where the
user is not interested in tracking each update of the sha1 in the submdule.
You can additionally set `submodule.<name>.ignore=all` and the `git status`
will state nothing and, with this patch, the `git add` does not either - as
the default behaviour. This patch changes the workflow to a more logical
behaviour and similar to workflow for ignored files.

The patch gives more scenarios for submodules to be used effectively with
less friction similar to the "repo" tool. A submodule can be added for many
different reasons than a hard dependency. It can be added as loosely
coupled dependencies whereas the user wants the latest based on the
configuration `submoule.<name>.branch`, but are not interested to track
each commit in the `super-repo`. Currently it gives friction of handling
conflicts between branches even the sha1's are fast-forward and the user
just wants the latest in any way. The user can still add a sha1 explicitly
to track updates.

Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoread-cache: update add_files_to_cache take param ignored_too
Claus Schneider(Eficode) [Fri, 6 Feb 2026 13:22:56 +0000 (13:22 +0000)] 
read-cache: update add_files_to_cache take param ignored_too

The ignored_too parameter is added to the function
add_files_to_cache for usage of explicit updating the index for the updated
submodule using the explicit patchspec to the submodule.

Signed-off-by: Claus Schneider(Eficode) <claus.schneider@eficode.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: fix repo_config documentation reference
SoutrikDas [Fri, 6 Feb 2026 06:21:08 +0000 (11:51 +0530)] 
doc: fix repo_config documentation reference

In MyFirstContribution.adoc, the link to the repo_config()
documentation is invalid because the related documentation was moved
to a different file.

Replace the path for the repo_config() documentation from
'Documentation/technical/api-config.h' to 'config.h'.

Signed-off-by: SoutrikDas <valusoutrik@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: convert git-show to synopsis style
Jean-Noël Avila [Fri, 6 Feb 2026 04:12:26 +0000 (04:12 +0000)] 
doc: convert git-show to synopsis style

 * add synopsis block definition in asciidoc.conf.in
 * convert commands to synopsis style
 * use _<placeholder>_ for arguments
 * minor formatting fixes

Reviewed-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: fix some style issues in git-clone and for-each-ref-options
Jean-Noël Avila [Fri, 6 Feb 2026 04:12:25 +0000 (04:12 +0000)] 
doc: fix some style issues in git-clone and for-each-ref-options

 * spell out all forms of --[no-]reject-shallow in git-clone
 * use imperative mood for the first line of options
 * Use asciidoc NOTE macro
 * fix markups

Reviewed-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: finalize git-clone documentation conversion to synopsis style
Jean-Noël Avila [Fri, 6 Feb 2026 04:12:24 +0000 (04:12 +0000)] 
doc: finalize git-clone documentation conversion to synopsis style

Use backticks where appropriate for command-line options

Reviewed-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: convert git-submodule to synopsis style
Jean-Noël Avila [Fri, 6 Feb 2026 04:12:23 +0000 (04:12 +0000)] 
doc: convert git-submodule to synopsis style

 * convert commands to synopsis style
 * use _<placeholder>_ for arguments
 * convert inline lists into proper definition lists
 * minor formatting fixes

Reviewed-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agowhitespace: symbolic links usually lack LF at the end
Junio C Hamano [Wed, 4 Feb 2026 21:23:06 +0000 (13:23 -0800)] 
whitespace: symbolic links usually lack LF at the end

For a patch that touches a symbolic link, it is perfectly normal
that the contents ends with "\ No newline at end of file".  The
checks introduced recently to detect incomplete lines (i.e., a text
file that lack the newline on its final line) should not trigger.

Disable the check early for symbolic links, both in "git apply" and
"git diff" and test them.  For "git apply", we check only when the
postimage is a symbolic link regardless of the preimage, and we only
care about preimage when applying in reverse.  Similarly, "git diff"
would warn only when the postimage is a symbolic link, or the
preimage when running "git diff -R".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agogpg-interface: remove an unnecessary NULL initialization
Collin Funk [Fri, 6 Feb 2026 01:46:10 +0000 (17:46 -0800)] 
gpg-interface: remove an unnecessary NULL initialization

We assign this variable unconditionally, so we do not need to
initialize it to NULL where it is defined.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoglobal: constify some pointers that are not written to
Collin Funk [Fri, 6 Feb 2026 01:46:09 +0000 (17:46 -0800)] 
global: constify some pointers that are not written to

The recent glibc 2.43 release had the following change listed in its
NEWS file:

    For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
    strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return
    pointers into their input arrays now have definitions as macros that
    return a pointer to a const-qualified type when the input argument is
    a pointer to a const-qualified type.

When compiling with GCC 15, which defaults to -std=gnu23, this causes
many warnings like this:

    merge-ort.c: In function ‘apply_directory_rename_modifications’:
    merge-ort.c:2734:36: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     2734 |                 char *last_slash = strrchr(cur_path, '/');
          |                                    ^~~~~~~

This patch fixes the more obvious ones by making them const when we do
not write to the returned pointer.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoStart 2.54 cycle
Junio C Hamano [Thu, 5 Feb 2026 23:07:22 +0000 (15:07 -0800)] 
Start 2.54 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'sp/t5500-cleanup'
Junio C Hamano [Thu, 5 Feb 2026 23:42:01 +0000 (15:42 -0800)] 
Merge branch 'sp/t5500-cleanup'

Test clean-up.

* sp/t5500-cleanup:
  t5500: simplify test implementation and fix git exit code suppression

2 months agoMerge branch 'tc/last-modified-options-cleanup'
Junio C Hamano [Thu, 5 Feb 2026 23:42:01 +0000 (15:42 -0800)] 
Merge branch 'tc/last-modified-options-cleanup'

The "-z" and "--max-depth" documentation (and implementation of
"-z") in the "git last-modified" command have been updated.

* tc/last-modified-options-cleanup:
  last-modified: change default max-depth to 0
  last-modified: document option '--max-depth'
  last-modified: document option '-z'
  last-modified: clarify in the docs the command takes a pathspec

2 months agoMerge branch 'lp/diff-stat-utf8-display-width-fix'
Junio C Hamano [Thu, 5 Feb 2026 23:42:01 +0000 (15:42 -0800)] 
Merge branch 'lp/diff-stat-utf8-display-width-fix'

The computation of column width made by "git diff --stat" was
confused when pathnames contain non-ASCII characters.

* lp/diff-stat-utf8-display-width-fix:
  t4073: add test for diffstat paths length when containing UTF-8 chars
  diff: improve scaling of filenames in diffstat to handle UTF-8 chars

2 months agoMerge branch 'ac/sparse-checkout-string-list-cleanup'
Junio C Hamano [Thu, 5 Feb 2026 23:42:00 +0000 (15:42 -0800)] 
Merge branch 'ac/sparse-checkout-string-list-cleanup'

Code clean-up.

* ac/sparse-checkout-string-list-cleanup:
  sparse-checkout: optimize string_list construction and add tests to verify deduplication.

2 months agoMerge branch 'sp/myfirstcontribution-include-update'
Junio C Hamano [Thu, 5 Feb 2026 23:42:00 +0000 (15:42 -0800)] 
Merge branch 'sp/myfirstcontribution-include-update'

Doc update.

* sp/myfirstcontribution-include-update:
  doc: MyFirstContribution: fix missing dependencies and clarify build steps

2 months agoMerge branch 'dd/t5403-modernise'
Junio C Hamano [Thu, 5 Feb 2026 23:42:00 +0000 (15:42 -0800)] 
Merge branch 'dd/t5403-modernise'

Test clean-up.

* dd/t5403-modernise:
  t5403: use test_cmp for post-checkout argument checks
  t5403: introduce check_post_checkout helper function

2 months agoMerge branch 'ap/http-probe-rpc-use-auth'
Junio C Hamano [Thu, 5 Feb 2026 23:41:58 +0000 (15:41 -0800)] 
Merge branch 'ap/http-probe-rpc-use-auth'

HTTP transport failed to authenticate in some code paths, which has
been corrected.

* ap/http-probe-rpc-use-auth:
  remote-curl: use auth for probe_rpc() requests too

2 months agoMerge branch 'ar/submodule-gitdir-tweak'
Junio C Hamano [Thu, 5 Feb 2026 23:41:58 +0000 (15:41 -0800)] 
Merge branch 'ar/submodule-gitdir-tweak'

Avoid local submodule repository directory paths overlapping with
each other by encoding submodule names before using them as path
components.

* ar/submodule-gitdir-tweak:
  submodule: detect conflicts with existing gitdir configs
  submodule: hash the submodule name for the gitdir path
  submodule: fix case-folding gitdir filesystem collisions
  submodule--helper: fix filesystem collisions by encoding gitdir paths
  builtin/credential-store: move is_rfc3986_unreserved to url.[ch]
  submodule--helper: add gitdir migration command
  submodule: allow runtime enabling extensions.submodulePathConfig
  submodule: introduce extensions.submodulePathConfig
  builtin/submodule--helper: add gitdir command
  submodule: always validate gitdirs inside submodule_name_to_gitdir
  submodule--helper: use submodule_name_to_gitdir in add_submodule

2 months agoMerge branch 'aa/add-p-previous-decisions'
Junio C Hamano [Thu, 5 Feb 2026 23:41:58 +0000 (15:41 -0800)] 
Merge branch 'aa/add-p-previous-decisions'

"git add -p" and friends note what the current status of the hunk
being shown is.

* aa/add-p-previous-decisions:
  add -p: show user's hunk decision when selecting hunks

2 months agoMerge branch 'jk/remote-tracking-ref-leakfix'
Junio C Hamano [Thu, 5 Feb 2026 23:41:57 +0000 (15:41 -0800)] 
Merge branch 'jk/remote-tracking-ref-leakfix'

Leakfix.

* jk/remote-tracking-ref-leakfix:
  remote: always allocate branch.push_tracking_ref
  remote: fix leak in branch_get_push_1() with invalid "simple" config
  remote: drop const return of tracking_for_push_dest()
  remote: return non-const pointer from error_buf()

2 months agodoc: send-email: correct --no-signed-off-by-cc misspelling
Matěj Cepl [Thu, 5 Feb 2026 16:24:01 +0000 (17:24 +0100)] 
doc: send-email: correct --no-signed-off-by-cc misspelling

There is no option --signed-off-cc (without -by) for git send-email.

Signed-off-by: Matěj Cepl <mcepl@cepl.eu>
[kh: rebased and changed subject to house style]
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
[jc: minor copyedit in the commit message]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agotest: optionally test contrib in CI
Junio C Hamano [Mon, 2 Feb 2026 21:07:58 +0000 (13:07 -0800)] 
test: optionally test contrib in CI

Recently it was reported that a topic merged to 'next' broke build
and test for contrib/subtree part of the system.

Instead of having those who run 'next' or 'master' to hit the build
and test breakage and report to us, make sure we notice breakages in
contrib/ area before they hit my tree at all, during their own
presubmit testing.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'pks-meson-fix-missing-msgfmt' of https://github.com/pks-gitlab/gitk
Johannes Sixt [Thu, 5 Feb 2026 12:45:51 +0000 (13:45 +0100)] 
Merge branch 'pks-meson-fix-missing-msgfmt' of https://github.com/pks-gitlab/gitk

* 'pks-meson-fix-missing-msgfmt' of https://github.com/pks-gitlab/gitk:
  gitk: fix msgfmt being required

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2 months agogitk: fix msgfmt being required
Patrick Steinhardt [Thu, 5 Feb 2026 11:50:13 +0000 (12:50 +0100)] 
gitk: fix msgfmt being required

While the Meson build instructions already handle the case where msgfmt
wasn't found, we forgot to mark the dependency itself as optional. This
causes an error in case the executable could not be found:

  Project name: gitk
  Project version: undefined
  Program sh found: YES (C:\Program Files\Git\bin\sh.EXE)
  Program wish found: YES (C:\Program Files\Git\mingw64\bin\wish.EXE)
  Program chmod found: YES (C:\Program Files\Git\usr\bin\chmod.EXE)
  Program mv found: YES (C:\Program Files\Git\usr\bin\mv.EXE)
  Program sed found: YES (C:\Program Files\Git\usr\bin\sed.EXE)
  Program msgfmt found: NO

  subprojects\gitk\meson.build:28:3: ERROR: Program 'msgfmt' not found or not executable

Fix the issue by adding the `required: false` parameter.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2 months agomeson: wire up gitk and git-gui
Patrick Steinhardt [Wed, 4 Feb 2026 08:38:11 +0000 (09:38 +0100)] 
meson: wire up gitk and git-gui

Wire up both gitk and git-gui in Meson as subprojects. These two
programs should be the last missing pieces for feature compatibility
with our Makefile for distributors.

Note that Meson expects subprojects to live in the "subprojects/"
directory. Create symlinks to fulfill this requirement.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocontrib/subtree: fix tests with reftable backend
Colin Stagner [Wed, 4 Feb 2026 04:38:11 +0000 (22:38 -0600)] 
contrib/subtree: fix tests with reftable backend

One git-subtree test-case relies on git internals to infer the
default branch name. This test fails with the new reftable
backend.

    GIT_TEST_DEFAULT_REF_FORMAT=reftable \
      meson test t7900-subtree

This test script already sets

    GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main

which eliminates the need to infer a branch name at runtime.
Hardcode the branch name.

Signed-off-by: Colin Stagner <ask+git@howdoi.land>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agogpg-interface: signatures by expired keys are fine
Uwe Kleine-König [Wed, 4 Feb 2026 15:23:06 +0000 (16:23 +0100)] 
gpg-interface: signatures by expired keys are fine

If a signature is made with a valid key and that key later expires, the
signature should still be considered good.

GnuPG emits in this case something like:

[GNUPG:] NEWSIG
gpg: Signature made Wed 26 Nov 2014 05:56:50 AM CET
gpg:                using RSA key FE3958F9067BC667
[GNUPG:] KEYEXPIRED 1478449622
[GNUPG:] KEY_CONSIDERED D783920D6D4F0C06AA4C25F3FE3958F9067BC667 0
[GNUPG:] KEYEXPIRED 1478449622
[GNUPG:] SIG_ID 8tAN3Fx6XB2NAoH5U8neoguQ9MI 2014-11-26 1416977810
[GNUPG:] EXPKEYSIG FE3958F9067BC667 Jason Cooper <jason@lakedaemon.net>
gpg: Good signature from "Jason Cooper <jason@lakedaemon.net>" [expired]
[GNUPG:] VALIDSIG D783920D6D4F0C06AA4C25F3FE3958F9067BC667 2014-11-26 1416977810 0 4 0 1 2 00 D783920D6D4F0C06AA4C25F3FE3958F9067BC667
gpg: Note: This key has expired!
      D783920D6D4F0C06AA4C25F3FE3958F9067BC667

(signature and signed data in this example is taken from Linux commit
756f80cee766574ae282baa97fdcf9cc). So GnuPG is relaxed and the fact that
the key is expired is only worth a "Note" which is weaker than e.g.

gpg: WARNING: The key's User ID is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.

which git still considers ok.

So stop coloring the signature by an expired key red and handle it like
any other good signature.

Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>