]> git.99rst.org Git - git.git/log
git.git
3 weeks agoshallow: give write_one_shallow() its own hex buffer
Johannes Schindelin [Fri, 10 Jul 2026 11:39:36 +0000 (11:39 +0000)]
shallow: give write_one_shallow() its own hex buffer

The previous fix reuses the local `hex` variable that is already
computed at the top of `write_one_shallow()`. That works today, but
`oid_to_hex()` returns a pointer into a small rotating buffer, so it is
not stable across an unrelated call to `oid_to_hex()` from the same
thread. A future edit that adds such a call between the assignment and
the last user of `hex` would silently corrupt the output.

Move `write_one_shallow()` off the rotating buffer entirely by using a
local buffer instead. The current users of that `hex` variable are
unchanged.

Suggested-by: Junio C Hamano <redacted>
Assisted-by: Claude Opus 4.7
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
3 weeks agoshallow: fix NULL dereference
Johannes Schindelin [Fri, 10 Jul 2026 11:39:35 +0000 (11:39 +0000)]
shallow: fix NULL dereference

After `write_one_shallow()` calls `lookup_commit()` to find the commit
object for a shallow graft entry, it then checks `if (!c || ...)`.
Inside that block, when the VERBOSE flag is set, it prints the OID being
removed, via `c->object.oid`. But `c` can be NULL (the first condition
in the `||` check).

This happens when a shallow graft entry references a commit object that
is not in the object store (e.g., after a partial fetch or in a
corrupted repository). In that case, `lookup_commit()` returns NULL
because the object cannot be found, the SEEN_ONLY check correctly
decides to remove this entry from .git/shallow, but the verbose message
crashes before the removal can complete.

Use `graft->oid` instead of `c->object.oid` for the message. The graft
entry's OID is the same value (it was used as the lookup key) and is
always available regardless of whether the commit object exists.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
3 weeks agobisect: ensure non-NULL `head` before using it
Johannes Schindelin [Fri, 10 Jul 2026 11:39:34 +0000 (11:39 +0000)]
bisect: ensure non-NULL `head` before using it

When `refs_resolve_ref_unsafe()` is called to resolve HEAD, and returns
NULL (e.g., HEAD does not exist as a proper ref), the code falls back to
`repo_get_oid("HEAD")` to try to resolve the OID directly. If that
succeeds, execution continues with `head` still set to NULL.

Later, that variable is passed to `repo_get_oid()` and `starts_with()`,
both of which would dereference the NULL pointer.

A concrete trigger for `refs_resolve_ref_unsafe()` returning NULL while
`repo_get_oid()` succeeds could not be constructed against the ref
backends currently in the tree; the naive case (a symbolic HEAD pointing
at a nonexistent branch, in either the files or the reftable backend)
fails in both calls consistently and returns via the existing
`error(_("bad HEAD - I need a HEAD"))` path.  Coverity, however, flags
the leftover use of `head` after the outer `if (!head)` on a formal
reading: `head` is still NULL at that point, and both `starts_with(head,
...)` and the second `repo_get_oid(..., head, ...)` in the else-branch
would dereference it if that state were ever reached.

Removing the outer check would risk regressing to a crash if a future
ref backend ever manages to hit the "returns NULL for HEAD but has a
valid OID for HEAD" state.  Assigning the literal string "HEAD" as a
safe fallback documents the intent and satisfies the analyzer without
changing behavior in any code path we can currently reach.

Assisted-by: Claude Opus 4.7
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
3 weeks agopack-bitmap: handle missing bitmap for base MIDX
Johannes Schindelin [Fri, 10 Jul 2026 11:39:33 +0000 (11:39 +0000)]
pack-bitmap: handle missing bitmap for base MIDX

When `prepare_midx_bitmap_git()` is called to load the bitmap for a
chained MIDX's base layer, if the base MIDX does not have an associated
bitmap file (e.g., it was not generated, or was deleted by gc), the
return value is NULL. It is then stored in `bitmap_git->base` and
immediately dereferenced on the next line.

This can happen in practice with incremental MIDX chains: the base MIDX
may have been written without `--write-bitmap-index`, or the bitmap may
have been pruned while the incremental layer's bitmap still references
it.

Check the return value and go to the cleanup label (which unmaps the
current bitmap and returns -1) so the caller falls back to non-bitmap
object enumeration, matching the handling of other bitmap loading
failures in the same function.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
3 weeks agorevision: avoid dereferencing NULL in `add_parents_only()`
Johannes Schindelin [Fri, 10 Jul 2026 11:39:32 +0000 (11:39 +0000)]
revision: avoid dereferencing NULL in `add_parents_only()`

This function resolves revision suffixes like commit^@ (all parents),
commit^! (commit minus parents), and commit^-N (exclude Nth parent). It
calls `get_reference()` in a loop to peel through tag objects until it
reaches a commit.

The existing NULL check after `get_reference()` only handles the
ignore_missing case, but get_reference() can return NULL through three
distinct paths:

  1. revs->ignore_missing: the caller asked to silently skip missing
     objects.

  2. revs->exclude_promisor_objects: the object is a lazy promisor
     object that should be excluded from the walk.

  3. revs->do_not_die_on_missing_objects: the caller wants to record
     missing OIDs for later reporting (used by `git rev-list
     --missing=print`) rather than dying.

In the latter two instances, the code falls through to dereference the
NULL pointer.

Handle all three cases explicitly:

  - ignore_missing: return 0, matching the existing behavior and
    the pattern in `handle_revision_arg()`.

  - do_not_die_on_missing_objects: return 0. The missing OID has already
    been recorded in `revs->missing_commits` by `get_reference()`.
    Returning 0 is consistent with `handle_revision_arg()` and
    `process_parents()`, both of which continue without error when this flag
    is set. The broader codebase pattern for this flag is "record and
    continue": list-objects.c, builtin/rev-list.c, and process_parents
    all skip the die/error and keep walking.

  - everything else (only the `exclude_promisor_objects` case in
    practice): return -1, consistent with `handle_revision_arg()` where
    the condition only matches `ignore_missing` or
    `do_not_die_on_missing_objects`, falling through to ret = -1 for the
    promisor case.

Note: the callers of `add_parents_only()` in
`handle_revision_pseudo_opt()` treat any nonzero return as "handled"
(`if (add_parents_only(...)) { ret = 0; }`), so the -1 for the promisor
case is indistinguishable from success there. This means a
promisor-excluded tag target referenced via commit^@ would be silently
skipped rather than producing an error.  This is a pre-existing
limitation of the caller's return value handling and not made worse by
this change; the alternative (a NULL dereference crash) _would be_
strictly worse.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
3 weeks agoreplay: die when --onto does not peel to a commit
Johannes Schindelin [Fri, 10 Jul 2026 11:39:31 +0000 (11:39 +0000)]
replay: die when --onto does not peel to a commit

The `peel_committish()` function calls `repo_peel_to_type()` to convert
the given object to a commit, but does not check the return value. When
the object exists but cannot be peeled to a commit (e.g., a tree or blob
OID is passed as --onto), the return value is NULL. Add an explicit NULL
check and die with a descriptive message in that case.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
3 weeks agobisect: handle NULL commit in `bisect_successful()`
Johannes Schindelin [Fri, 10 Jul 2026 11:39:30 +0000 (11:39 +0000)]
bisect: handle NULL commit in `bisect_successful()`

When `lookup_commit_reference_by_name()` is called to find the first bad
commit, the result is passed to `repo_format_commit_message()`
immediately, which dereferences commit without checking for NULL.

However, the commit could be NULL, even though in practice this is
unlikely because `bisect_successful()` is only called after a successful
bisect run has identified the bad commit, but the ref could still become
dangling due to a concurrent gc or repository corruption.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
3 weeks agomailsplit: move NULL check before first use of file handle
Johannes Schindelin [Fri, 10 Jul 2026 11:39:29 +0000 (11:39 +0000)]
mailsplit: move NULL check before first use of file handle

The `split_mbox()` function calls fileno(f) to check whether the input
is a terminal, but the NULL check for f (from `fopen()`) does not happen
until later. When the file cannot be opened, f is NULL, and
`fileno(NULL)` is undefined behavior, typically crashing with a
segmentation fault.

Move the NULL check above the `isatty()`/`fileno()` call so the error
path is taken before any use of the potentially-NULL handle.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
3 weeks agoreftable/stack: guard against NULL list_file in stack_destroy
Johannes Schindelin [Fri, 10 Jul 2026 11:39:28 +0000 (11:39 +0000)]
reftable/stack: guard against NULL list_file in stack_destroy

When reftable_new_stack() fails partway through initialization
(e.g., reftable_buf_addstr returns an OOM error before
reftable_buf_detach assigns p->list_file), it jumps to the error
path which calls reftable_stack_destroy(p). At that point,
p->list_file is still NULL because the detach never happened.

reftable_stack_destroy() passes st->list_file unconditionally to
read_lines(), which calls open(filename, O_RDONLY). Passing NULL
to open() is undefined behavior and will typically crash.

Guard the read_lines() call with a NULL check on st->list_file.
When list_file is NULL, there are no table files to clean up
anyway, so skipping read_lines is the correct behavior.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
3 weeks agoremote: guard `remote_tracking()` against NULL remote
Johannes Schindelin [Fri, 10 Jul 2026 11:39:27 +0000 (11:39 +0000)]
remote: guard `remote_tracking()` against NULL remote

The `remote_tracking()` function unconditionally dereferences
`remote->fetch` without checking whether remote is NULL.

In practice, this never happens because the only caller (`apply_cas()`)
guards the calls to this function by checking the `use_tracking` and
`use_tracking_for_rest` attributes.

However, it requires quite involved reasoning to reach that conclusion,
and is therefore fragile. Just return -1 ("no tracking ref") when there
is no remote to work with.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
3 weeks agodiff: handle NULL return from repo_get_commit_tree()
Johannes Schindelin [Fri, 10 Jul 2026 11:39:26 +0000 (11:39 +0000)]
diff: handle NULL return from repo_get_commit_tree()

The `repo_get_commit_tree()` function can return NULL when a commit's
tree object is not available (e.g., the commit was parsed but its
maybe_tree field is unset and the commit is not in the commit-graph). In
cmd_diff(), the return value is immediately dereferenced via ->object
without a NULL check, which would crash if the tree cannot be loaded.

Add an explicit NULL check and die with a descriptive message.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
3 weeks agodiffcore-break: guard against NULLed queue entries in merge loop
Johannes Schindelin [Fri, 10 Jul 2026 11:39:25 +0000 (11:39 +0000)]
diffcore-break: guard against NULLed queue entries in merge loop

The outer loop in `diffcore_merge_broken()` sets `q->queue[j]` to NULL
when it merges a broken pair back together, and has a NULL check to skip
such entries on subsequent iterations. The inner loop, however, lacks
this guard: when it scans forward looking for a matching peer, it can
encounter a slot that was NULLed by a previous outer-loop iteration and
dereference it unconditionally.

In practice this requires at least two broken pairs whose peers
both survive rename/copy detection and appear later in the queue,
which is rare but not impossible.

Add the same `if (!pp) continue` guard to the inner loop.

Pointed out by Coverity.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
4 weeks agoStart Git 2.56 cycle
Junio C Hamano [Mon, 6 Jul 2026 22:49:17 +0000 (15:49 -0700)]
Start Git 2.56 cycle

This time, do not forget to update GIT-VERSION-GEN to say 2.55.GIT

Signed-off-by: Junio C Hamano <redacted>
4 weeks agoMerge branch 'sg/t3420-do-not-grep-in-missing-file'
Junio C Hamano [Mon, 6 Jul 2026 22:50:25 +0000 (15:50 -0700)]
Merge branch 'sg/t3420-do-not-grep-in-missing-file'

A test checking interactions between git rebase --quit and
autostash in t3420-rebase-autostash.sh has been corrected to use
test_path_is_missing instead of ! grep on a file that shouldn't
exist in the conflicted state.

* sg/t3420-do-not-grep-in-missing-file:
  t3420-rebase-autostash: don't try to grep non-existing files

4 weeks agoMerge branch 'ps/connected-generic-promisor-checks'
Junio C Hamano [Mon, 6 Jul 2026 22:50:24 +0000 (15:50 -0700)]
Merge branch 'ps/connected-generic-promisor-checks'

The connectivity check has been refactored to search for promisor
objects in a generic way using the object database interface,
rather than iterating packfiles directly. This allows connectivity
checks to work properly in repositories that do not use packfiles.

* ps/connected-generic-promisor-checks:
  connected: search promisor objects generically
  connected: split out promisor-based connectivity check
  odb/source-packed: support flags when iterating an object prefix
  odb/source-packed: extract logic to skip certain packs

4 weeks agoMerge branch 'ps/refs-onbranch-fixes'
Junio C Hamano [Mon, 6 Jul 2026 22:50:24 +0000 (15:50 -0700)]
Merge branch 'ps/refs-onbranch-fixes'

Reference backend configuration has been updated to load lazily to
avoid recursive calls during repository initialization when 'onbranch'
configuration conditions are evaluated. This has also fixed a memory
leak and allowed the unused `chdir_notify_reparent()` machinery to be
dropped.

* ps/refs-onbranch-fixes:
  refs: protect against chicken-and-egg recursion
  refs/reftable: lazy-load configuration to fix chicken-and-egg
  reftable: split up write options
  refs/files: lazy-load configuration to fix chicken-and-egg
  refs: move parsing of "core.logAllRefUpdates" back into ref stores
  repository: free main reference database
  chdir-notify: drop unused `chdir_notify_reparent()`
  refs: unregister reference stores from "chdir_notify"
  setup: don't apply "GIT_REFERENCE_BACKEND" without a repository
  setup: stop applying repository format twice
  setup: inline `check_and_apply_repository_format()`

4 weeks agoMerge branch 'wy/doc-clarify-review-replies'
Junio C Hamano [Mon, 6 Jul 2026 22:50:23 +0000 (15:50 -0700)]
Merge branch 'wy/doc-clarify-review-replies'

Documentation on community contribution guidelines has been updated to
encourage replying to review comments before rerolling, and to advise
a default limit of at most one reroll per day to give reviewers across
different time zones enough time to participate.

* wy/doc-clarify-review-replies:
  doc: advise batching patch rerolls
  doc: encourage review replies before rerolling

4 weeks agoMerge branch 'jk/repo-info-path-keys'
Junio C Hamano [Mon, 6 Jul 2026 22:50:23 +0000 (15:50 -0700)]
Merge branch 'jk/repo-info-path-keys'

The "git repo info" command has been taught new keys to output both
absolute and relative paths for "gitdir" and "commondir", supported by
a new path-formatting helper extracted from "git rev-parse".

* jk/repo-info-path-keys:
  repo: add path.gitdir with absolute and relative suffix formatting
  repo: add path.commondir with absolute and relative suffix formatting
  path: extract format_path() and use in rev-parse

4 weeks agoMerge branch 'mv/log-follow-mergy'
Junio C Hamano [Mon, 6 Jul 2026 22:50:23 +0000 (15:50 -0700)]
Merge branch 'mv/log-follow-mergy'

"git log --follow" has been updated to better handle non-linear
history, in which the path being tracked gets renamed differently in
multiple history lines.

* mv/log-follow-mergy:
  log: improve --follow following renames for non-linear history

4 weeks agoMerge branch 'pw/status-rebase-todo'
Junio C Hamano [Mon, 6 Jul 2026 22:50:23 +0000 (15:50 -0700)]
Merge branch 'pw/status-rebase-todo'

The display of the rebase todo list in "git status" has been
improved to correctly abbreviate object IDs for more commands and
avoid misinterpreting refs as object IDs.

* pw/status-rebase-todo:
  status: improve rebase todo list parsing
  sequencer: factor out parsing of todo commands

4 weeks agoMerge branch 'tb/pack-path-walk-bitmap-delta-islands'
Junio C Hamano [Mon, 6 Jul 2026 22:50:22 +0000 (15:50 -0700)]
Merge branch 'tb/pack-path-walk-bitmap-delta-islands'

The pack-objects command has been updated to support reachability
bitmaps and delta-islands concurrently with the `--path-walk` option,
allowing faster packaging by falling back to path-walk when bitmaps
cannot fully satisfy the request.

* tb/pack-path-walk-bitmap-delta-islands:
  pack-objects: support `--delta-islands` with `--path-walk`
  pack-objects: extract `record_tree_depth()` helper
  pack-objects: support reachability bitmaps with `--path-walk`
  t/perf: drop p5311's lookup-table permutation

4 weeks agoMerge branch 'jc/submittingpatches-design-critiques'
Junio C Hamano [Mon, 6 Jul 2026 22:50:22 +0000 (15:50 -0700)]
Merge branch 'jc/submittingpatches-design-critiques'

The documentation in SubmittingPatches has been updated to clarify how
patch contributors should respond to design and viability critiques,
and how the resolution of such critiques should be recorded in the
final commit messages.

* jc/submittingpatches-design-critiques:
  SubmittingPatches: address design critiques

4 weeks agoMerge branch 'kh/submittingpatches-trailers'
Junio C Hamano [Mon, 6 Jul 2026 22:50:22 +0000 (15:50 -0700)]
Merge branch 'kh/submittingpatches-trailers'

The trailer sections in SubmittingPatches have been updated to
encourage use of standard trailers.

* kh/submittingpatches-trailers:
  SubmittingPatches: note that trailer order matters
  SubmittingPatches: be consistent with trailer markup
  SubmittingPatches: document Based-on-patch-by trailer
  SubmittingPatches: discourage common Linux trailers
  SubmittingPatches: encourage trailer use for substantial help

4 weeks agoMerge branch 'mh/fetch-follow-remote-head-config'
Junio C Hamano [Mon, 6 Jul 2026 22:50:22 +0000 (15:50 -0700)]
Merge branch 'mh/fetch-follow-remote-head-config'

The `fetch.followRemoteHEAD` configuration variable has been added to
provide a default for the per-remote `remote.<name>.followRemoteHEAD`
setting.

* mh/fetch-follow-remote-head-config:
  fetch: fixup a misaligned comment
  fetch: add configuration variable fetch.followRemoteHEAD
  fetch: refactor do_fetch handling of followRemoteHEAD
  fetch: return 0 on known git_fetch_config
  fetch: rename function report_set_head
  t5510: cleanup remote in followRemoteHEAD dangling ref test
  doc: explain fetchRemoteHEADWarn advice
  fetch: fixup set_head advice for warn-if-not-branch

4 weeks agoMerge branch 'po/hash-object-size-t'
Junio C Hamano [Mon, 6 Jul 2026 22:50:21 +0000 (15:50 -0700)]
Merge branch 'po/hash-object-size-t'

Support for hashing loose or packed objects larger than 4GB on Windows
and other LLP64 platforms has been improved by converting object header
buffers and data-handling functions from 'unsigned long' to 'size_t'.

* po/hash-object-size-t:
  hash-object: add a >4GB/LLP64 test case using filtered input
  hash-object: add another >4GB/LLP64 test case
  hash-object --stdin: verify that it works with >4GB/LLP64
  hash algorithms: use size_t for section lengths
  object-file.c: use size_t for header lengths
  hash-object: demonstrate a >4GB/LLP64 problem

4 weeks agoMerge branch 'ty/move-protect-hfs-ntfs'
Junio C Hamano [Mon, 6 Jul 2026 22:50:21 +0000 (15:50 -0700)]
Merge branch 'ty/move-protect-hfs-ntfs'

The global configuration variables protect_hfs and protect_ntfs have
been migrated into struct repo_config_values to tie them to
per-repository configuration state.

* ty/move-protect-hfs-ntfs:
  environment: use 'repo->initialized' for repo_protect_hfs() and repo_protect_ntfs()
  environment: move 'protect_hfs' and 'protect_ntfs' into 'repo_config_values'

4 weeks agoMerge branch 'ps/odb-source-packed'
Junio C Hamano [Mon, 6 Jul 2026 22:50:21 +0000 (15:50 -0700)]
Merge branch 'ps/odb-source-packed'

The packed object source has been refactored into a proper struct
odb_source.

* ps/odb-source-packed:
  odb/source-packed: drop pointer to "files" parent source
  midx: refactor interfaces to work on "packed" source
  odb/source-packed: stub out remaining functions
  odb/source-packed: wire up `freshen_object()` callback
  odb/source-packed: wire up `find_abbrev_len()` callback
  odb/source-packed: wire up `count_objects()` callback
  odb/source-packed: wire up `for_each_object()` callback
  odb/source-packed: wire up `read_object_stream()` callback
  odb/source-packed: wire up `read_object_info()` callback
  packfile: use higher-level interface to implement `has_object_pack()`
  odb/source-packed: wire up `reprepare()` callback
  odb/source-packed: wire up `close()` callback
  odb/source-packed: start converting to a proper `struct odb_source`
  odb/source-packed: store pointer to "files" instead of generic source
  packfile: move packed source into "odb/" subsystem
  packfile: split out packfile list logic
  packfile: rename `struct packfile_store` to `odb_source_packed`

4 weeks agoMerge branch 'td/ref-filter-restore-prefix-iteration'
Junio C Hamano [Mon, 6 Jul 2026 22:50:20 +0000 (15:50 -0700)]
Merge branch 'td/ref-filter-restore-prefix-iteration'

Commands that list branches and tags (like git branch and git tag)
have been optimized to pass the namespace prefix when initializing
their ref iterator, avoiding a loose-ref scaling regression in
repositories with many unrelated loose references.

* td/ref-filter-restore-prefix-iteration:
  ref-filter: restore prefix-scoped iteration

4 weeks agoMerge branch 'en/ort-harden-against-corrupt-trees'
Junio C Hamano [Mon, 6 Jul 2026 22:50:20 +0000 (15:50 -0700)]
Merge branch 'en/ort-harden-against-corrupt-trees'

The 'ort' merge backend has been hardened against corrupt trees by
ensuring it aborts under appropriate error conditions.

* en/ort-harden-against-corrupt-trees:
  cache-tree: fix verify_cache() to catch non-adjacent D/F conflicts
  merge-ort: abort merge when trees have duplicate entries
  merge-ort: free diff pairs queue in clear_or_reinit_internal_opts()
  merge-ort: drop unnecessary show_all_errors from collect_merge_info()
  merge-ort: propagate callback errors from traverse_trees_wrapper()

4 weeks agoMerge branch 'jk/setup-gitfile-diag-fix'
Junio C Hamano [Mon, 6 Jul 2026 22:50:20 +0000 (15:50 -0700)]
Merge branch 'jk/setup-gitfile-diag-fix'

A regression in the error diagnosis code for invalid .git files has
been fixed, avoiding a potential NULL-pointer crash when reporting
that a .git file does not point to a valid repository.

* jk/setup-gitfile-diag-fix:
  read_gitfile(): simplify NOT_A_REPO error message

4 weeks agoMerge branch 'rs/cat-file-default-format-optim'
Junio C Hamano [Mon, 6 Jul 2026 22:50:20 +0000 (15:50 -0700)]
Merge branch 'rs/cat-file-default-format-optim'

The default format path of git cat-file --batch has been optimized
to use strbuf_add_oid_hex() and strbuf_add_uint() instead of
strbuf_addf(), yielding a noticeable speedup.

* rs/cat-file-default-format-optim:
  cat-file: speed up default format

4 weeks agoMerge branch 'ps/doc-recommend-b4'
Junio C Hamano [Mon, 6 Jul 2026 22:50:19 +0000 (15:50 -0700)]
Merge branch 'ps/doc-recommend-b4'

Project-specific configuration for b4 has been introduced, and the
documentation has been updated to recommend using it as a
streamlined method for submitting patches.

* ps/doc-recommend-b4:
  b4: introduce configuration for the Git project
  MyFirstContribution: recommend the use of b4
  MyFirstContribution: recommend shallow threading of cover letters

4 weeks agoMerge branch 'ps/setup-drop-global-state'
Junio C Hamano [Mon, 6 Jul 2026 22:50:19 +0000 (15:50 -0700)]
Merge branch 'ps/setup-drop-global-state'

The refactoring of 'setup.c' has been continued to drop remaining
global state (`git_work_tree_cfg`, `is_bare_repository_cfg`), updating
`is_bare_repository()` to no longer implicitly rely on
`the_repository`.

* ps/setup-drop-global-state:
  treewide: drop USE_THE_REPOSITORY_VARIABLE
  environment: stop using `the_repository` in `is_bare_repository()`
  environment: split up concerns of `is_bare_repository_cfg`
  builtin/init: stop modifying `is_bare_repository_cfg`
  setup: remove global `git_work_tree_cfg` variable
  builtin/init: simplify logic to configure worktree
  builtin/init: stop modifying global `git_work_tree_cfg` variable

4 weeks agoMerge branch 'cc/promisor-auto-config-url-more'
Junio C Hamano [Mon, 6 Jul 2026 22:50:19 +0000 (15:50 -0700)]
Merge branch 'cc/promisor-auto-config-url-more'

The handling of promisor-remote protocol capability has been updated
to allow the other side to add to the list of promisor remotes via the
'promisor.acceptFromServerURL' configuration variable.

* cc/promisor-auto-config-url-more:
  doc: promisor: improve acceptFromServer entry
  promisor-remote: auto-configure unknown remotes
  promisor-remote: trust known remotes matching acceptFromServerUrl
  promisor-remote: introduce promisor.acceptFromServerUrl
  promisor-remote: add 'local_name' to 'struct promisor_info'
  urlmatch: add url_normalize_pattern() helper
  urlmatch: change 'allow_globs' arg to bool
  t5710: simplify 'mkdir X' followed by 'git -C X init'

4 weeks agoMerge branch 'hn/status-pull-advice-qualified'
Junio C Hamano [Mon, 6 Jul 2026 22:50:18 +0000 (15:50 -0700)]
Merge branch 'hn/status-pull-advice-qualified'

Advice shown by "git status" when the local branch is behind or has
diverged from its push branch has been updated to suggest "git pull
<remote> <branch>".

* hn/status-pull-advice-qualified:
  remote: qualify "git pull" advice for non-upstream compareBranches

5 weeks agoGit 2.55 v2.55.0
Junio C Hamano [Mon, 29 Jun 2026 14:58:39 +0000 (07:58 -0700)]
Git 2.55

Signed-off-by: Junio C Hamano <redacted>
5 weeks agoMerge branch 'jk/t5551-expensive-test-timeouts-fix'
Junio C Hamano [Mon, 29 Jun 2026 14:56:22 +0000 (07:56 -0700)]
Merge branch 'jk/t5551-expensive-test-timeouts-fix'

The Apache timeout in HTTP tests has been increased to prevent test
failures on heavily loaded CI runners. The tests creating an
enormous number of refs have been isolated to their own repositories
to avoid slowing down subsequent tests.

* jk/t5551-expensive-test-timeouts-fix:
  t5551: put many-tags case into its own repo
  t/lib-httpd: bump apache timeout

5 weeks agot5551: put many-tags case into its own repo
Jeff King [Sun, 28 Jun 2026 08:03:45 +0000 (04:03 -0400)]
t5551: put many-tags case into its own repo

Most of the t5551 http fetch tests use a handful of refs. But there are
a few test cases which check our handling of large numbers of refs.
These tests use the same server-side repo, so all subsequent tests end
up having to consider those extra refs, too.

The result is that the test script is a bit slower than it needs to be.
In a normal run, moving the "2,000 tags" test into its own repo drops my
runtime for the whole script from ~2.7s to ~1.9s.

This is a modest gain, but when we add the "--long" flag it gets much
bigger. There we trigger a test (marked with EXPENSIVE) that adds
100,000 tags, and the script runtime jumps to ~95s. But if we use the
same "many tags" repo for that, our runtime drops to just ~37s.

This is a pretty easy win to drop the cost of the script. It may even be
a larger gain on a heavily loaded system, since one of the main costs
here is unpacked refs, which are heavy on system time and I/O costs.

It's possible we are reducing test coverage, since all of those other
tests were inadvertently using large ref advertisements (and thus could
have uncovered some unexpected interaction). But that seems somewhat
unlikely; the tests targeted at the large number of refs are doing
roughly similar things to the other tests.

Note that the real performance culprit is the 100k-tag --long test, not
the 2k-tag one. So we could just let the 100k one use its own repo, and
keep the 2k tags in the main repo. But since these two tests are
somewhat interlinked, it's easier to just move them both (and it does
provide a small gain even for the 2000-tag test). I also notice that the
2000-tag test is gated on the CMDLINE_LIMIT prereq, and without that the
later EXPENSIVE test will fail (since we won't have a too-many-refs
clone). Nobody seems to have noticed or complained after many years, and
I left it alone for this patch.

Signed-off-by: Jeff King <redacted>
[jc: made the new "many-tags.git" bare to match the original "repo.git"]
Signed-off-by: Junio C Hamano <redacted>
5 weeks agoMerge branch 'js/http-https-proxy-fix'
Junio C Hamano [Sun, 28 Jun 2026 22:18:24 +0000 (15:18 -0700)]
Merge branch 'js/http-https-proxy-fix'

We lost ability to use https:// proxies during this cycle; this is
a hotfix for the regression.

* js/http-https-proxy-fix:
  http: accept https:// proxies again

5 weeks agot/lib-httpd: bump apache timeout
Jeff King [Sun, 28 Jun 2026 08:00:09 +0000 (04:00 -0400)]
t/lib-httpd: bump apache timeout

Since enabling more tests with 7a094d68a2 (ci: run expensive tests on
push builds to integration branches, 2026-05-08), we sometimes see test
failures or timeouts in GitHub CI. The culprit seems to be the "enormous
ref negotiation" test in t5551, which creates ~100k tag refs in our http
server-side repo.

Iterating through the loose refs of this repo to generate a ref
advertisement can take a long time, especially on a platform with slow
I/O. On my otherwise unloaded local machine, a cold cache ref
advertisement takes ~10s. On a busy CI machine running tests in
parallel, it can presumably top 60s, which runs afoul of Apache's
default CGI timeout.

The result in t5551 is a test failure, where Apache simply hangs up the
connection and the client reports an error. But worse, t5559 runs the
same test with HTTP/2, and a bug in Apache causes the connection to hang
indefinitely! We eventually see this as a CI timeout after 6 hours.

Let's bump Apache's timeout to something much larger: 600 seconds. This
doesn't eliminate the possibility of a timeout, but it makes it much
less likely. It should eliminate both the test failures and the CI
timeouts in practice, and it protects us from running into similar
problems with other tests in the future.

There are two counter-arguments to consider.

One, could/should we just make the test faster? Probably yes. The
biggest mistake here is having such an absurd number of unpacked refs on
a system which is bottle-necked on I/O. But I think it's worth bumping
the timeout so that we can fix this (and possibly other) correctness
issues, and then consider performance separately (which we'll do in
subsequent patches).

And two, is this just papering over a problem that users might see in
the real world? We could teach Git to handle this case more gracefully
with optimizations or keep-alives. But I think it's really an artificial
situation. You need a combination of this silly number of loose refs,
plus a very heavily loaded system. If you were trying to run a real
server and it took more than 60s to generate the ref advertisement, I
don't think the timeout is your biggest problem. Your crappy service is,
and you should adjust your resources to match your load. I.e., it is
probably reasonable for Git to assume that advertisements happen
fast-ish and don't need protocol-level keepalives.

Though the patch here is small, tons of work went into analyzing the
problem. Many thanks to the contributors credited below.

Helped-by: Michael Montalbo <redacted>
Helped-by: Patrick Steinhardt <redacted>
Signed-off-by: Jeff King <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agohttp: accept https:// proxies again
Johannes Schindelin [Sat, 27 Jun 2026 17:17:56 +0000 (17:17 +0000)]
http: accept https:// proxies again

Since 663d7abe07ea (http: reject unsupported proxy URL schemes,
2026-05-05), set_curl_proxy_type() returns 0 only for the "http"
and SOCKS variants via dedicated early returns, and -1 for
everything else. The "https" branch configures the CURL handle for
HTTPS proxying but then falls through to the trailing `return -1`
intended for unknown schemes, so the caller in get_curl_handle()
treats a perfectly valid https:// proxy URL as unsupported and
refuses to use it.

Noticed while looking into a Coverity report against the same
function; the unchecked curl_easy_setopt() return values it flags
are orthogonal to this fix.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agoMerge tag 'l10n-2.55.0-v1' of https://github.com/git-l10n/git-po
Junio C Hamano [Sun, 28 Jun 2026 15:28:08 +0000 (08:28 -0700)]
Merge tag 'l10n-2.55.0-v1' of https://github.com/git-l10n/git-po

l10n-2.55.0-v1

* tag 'l10n-2.55.0-v1' of https://github.com/git-l10n/git-po:
  l10n: zh-TW.po: Update Chinese (Traditional) translation
  l10n: uk: add 2.55 translation
  l10n: ga.po: update for Git 2.55
  l10n: fr: mass fix of typos
  l10n: fr: version 2.55
  l10n: po-id for 2.55
  l10n: AGENTS.md: add quotation mark preservation guidelines
  l10n: zh_CN: updated translation for 2.55
  l10n: TEAMS: change Simplified Chinese team leader
  l10n: sv.po: Update Swedish translation
  l10n: ca.po: update Catalan translation
  l10n: tr: Update Turkish translations
  l10n: bg.po: Updated Bulgarian translation (6322t)
  l10n: it: fix italian usage messages alignment

5 weeks agoMerge branch '2.55-uk-pr' of github.com:arkid15r/git-ukrainian-l10n
Jiang Xin [Sun, 28 Jun 2026 11:25:08 +0000 (19:25 +0800)]
Merge branch '2.55-uk-pr' of github.com:arkid15r/git-ukrainian-l10n

* '2.55-uk-pr' of github.com:arkid15r/git-ukrainian-l10n:
  l10n: uk: add 2.55 translation

5 weeks agoMerge branch 'l10n-ga-2.55' of github.com:aindriu80/git-po
Jiang Xin [Sun, 28 Jun 2026 08:49:15 +0000 (16:49 +0800)]
Merge branch 'l10n-ga-2.55' of github.com:aindriu80/git-po

* 'l10n-ga-2.55' of github.com:aindriu80/git-po:
  l10n: ga.po: update for Git 2.55

5 weeks agoMerge branch 'l10n/zh-TW/2026-06-26' of github.com:l10n-tw/git-po
Jiang Xin [Sun, 28 Jun 2026 08:20:41 +0000 (16:20 +0800)]
Merge branch 'l10n/zh-TW/2026-06-26' of github.com:l10n-tw/git-po

* 'l10n/zh-TW/2026-06-26' of github.com:l10n-tw/git-po:
  l10n: zh-TW.po: Update Chinese (Traditional) translation

5 weeks agoMerge branch 'ca-20260624-b' of github.com:Softcatala/git-po
Jiang Xin [Sun, 28 Jun 2026 08:17:45 +0000 (16:17 +0800)]
Merge branch 'ca-20260624-b' of github.com:Softcatala/git-po

* 'ca-20260624-b' of github.com:Softcatala/git-po:
  l10n: ca.po: update Catalan translation

5 weeks agoMerge branch 'zh_CN-2.55' of github.com:lilydjwg/git-po
Jiang Xin [Sun, 28 Jun 2026 08:15:39 +0000 (16:15 +0800)]
Merge branch 'zh_CN-2.55' of github.com:lilydjwg/git-po

* 'zh_CN-2.55' of github.com:lilydjwg/git-po:
  l10n: zh_CN: updated translation for 2.55
  l10n: TEAMS: change Simplified Chinese team leader

5 weeks agoMerge branch 'tr-l10n' of github.com:bitigchi/git-po
Jiang Xin [Sun, 28 Jun 2026 08:14:13 +0000 (16:14 +0800)]
Merge branch 'tr-l10n' of github.com:bitigchi/git-po

* 'tr-l10n' of github.com:bitigchi/git-po:
  l10n: tr: Update Turkish translations

5 weeks agoMerge branch 'po-id' of github.com:bagasme/git-po
Jiang Xin [Sun, 28 Jun 2026 08:12:30 +0000 (16:12 +0800)]
Merge branch 'po-id' of github.com:bagasme/git-po

* 'po-id' of github.com:bagasme/git-po:
  l10n: po-id for 2.55

5 weeks agoMerge branch 'master' of github.com:alshopov/git-po
Jiang Xin [Sun, 28 Jun 2026 08:11:24 +0000 (16:11 +0800)]
Merge branch 'master' of github.com:alshopov/git-po

* 'master' of github.com:alshopov/git-po:
  l10n: bg.po: Updated Bulgarian translation (6322t)

5 weeks agoMerge branch 'fr_v2.55' of github.com:jnavila/git
Jiang Xin [Sun, 28 Jun 2026 08:09:26 +0000 (16:09 +0800)]
Merge branch 'fr_v2.55' of github.com:jnavila/git

* 'fr_v2.55' of github.com:jnavila/git:
  l10n: fr: mass fix of typos
  l10n: fr: version 2.55

5 weeks agoMerge branch 'master' of github.com:nafmo/git-l10n-sv
Jiang Xin [Sun, 28 Jun 2026 08:07:00 +0000 (16:07 +0800)]
Merge branch 'master' of github.com:nafmo/git-l10n-sv

* 'master' of github.com:nafmo/git-l10n-sv:
  l10n: sv.po: Update Swedish translation

5 weeks agol10n: zh-TW.po: Update Chinese (Traditional) translation
Lumynous [Sat, 20 Jun 2026 11:36:09 +0000 (19:36 +0800)]
l10n: zh-TW.po: Update Chinese (Traditional) translation

Signed-off-by: Yi-Jyun Pan <redacted>
5 weeks agot3420-rebase-autostash: don't try to grep non-existing files
SZEDER Gábor [Sun, 10 Oct 2021 17:28:09 +0000 (19:28 +0200)]
t3420-rebase-autostash: don't try to grep non-existing files

Several tests in 't3420-rebase-autostash.sh' start various rebase
processes that are expected to fail because of merge conflicts.  The
tests [1] checking that 'git rebase --quit' and autostash work
together as expected after such a failure then run '! grep ...' to
ensure that the dirty contents of the file is gone.  However, due to
the test repo's history and the choice of upstream branch that file
shouldn't exist in the conflicted state at all, and thus it shouldn't
exist after the subsequent 'git rebase --quit' either.  Consequently,
this 'grep' doesn't fail as expected, i.e. because it can't find the
dirty content, but instead it fails, because it can't open the file.

Thighten this check by using 'test_path_is_missing' instead, thereby
avoiding unexpected errors from 'grep' as well.

Previously 2745817028 (t3420-rebase-autostash: don't try to grep
non-existing files, 2018-08-22) fixed a couple of similar issues; this
one was added later in 9b2df3e8d0 (rebase: save autostash entry into
stash reflog on --quit, 2020-04-28).

[1] This patch modifies only a single test, but that test is run
    several times with different strategies ('--apply', '--merge', and
    '--interactive'), hence the plural "tests".

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agol10n: uk: add 2.55 translation
Arkadii Yakovets [Sat, 27 Jun 2026 18:42:28 +0000 (11:42 -0700)]
l10n: uk: add 2.55 translation

Co-authored-by: Kate Golovanova <redacted>
Signed-off-by: Arkadii Yakovets <redacted>
Signed-off-by: Kate Golovanova <redacted>
5 weeks agol10n: ga.po: update for Git 2.55
Aindriú Mac Giolla Eoin [Sat, 27 Jun 2026 13:41:58 +0000 (14:41 +0100)]
l10n: ga.po: update for Git 2.55

Signed-off-by: Aindriú Mac Giolla Eoin <redacted>
5 weeks agol10n: fr: mass fix of typos
Jean-Noël Avila [Wed, 24 Jun 2026 10:20:45 +0000 (12:20 +0200)]
l10n: fr: mass fix of typos

Helped-by: Kévin Leprêtre <redacted>
Signed-off-by: Jean-Noël Avila <redacted>
5 weeks agol10n: fr: version 2.55
Jean-Noël Avila [Sun, 14 Jun 2026 06:18:10 +0000 (08:18 +0200)]
l10n: fr: version 2.55

Signed-off-by: Jean-Noël Avila <redacted>
5 weeks agol10n: po-id for 2.55
Bagas Sanjaya [Sat, 27 Jun 2026 04:00:14 +0000 (11:00 +0700)]
l10n: po-id for 2.55

Update following components:

  * add-patch.c
  * apply.c
  * bisect.c
  * builtin/add.c
  * builtin/backfill.c
  * builtin/bisect.c
  * builtin/cat-file.c
  * builtin/checkout.c
  * builtin/config.c
  * builtin/fast-import.c
  * builtin/fetch.c
  * builtin/fsmonitor--daemon.c
  * builtin/hook.c
  * builtin/index-pack.c
  * builtin/interpret-trailers.c
  * builtin/last-modified.c
  * builtin/log.c
  * builtin/multi-pack-index.c
  * builtin/name-rev.c
  * builtin/pack-objects.c
  * builtin/push.c
  * builtin/repack.c
  * builtin/replay.c
  * builtin/repo.c
  * builtin/show-index.c
  * builtin/stash.c
  * builtin/submodule--helper.c
  * builtin/worktree.c
  * command-list.h
  * diff.c
  * fetch-pack.c
  * hook.c
  * list-objects-filter-options.c
  * lockfile.c
  * midx-write.c
  * midx.c
  * object-file.c
  * object.c
  * packfile.c
  * path-walk.c
  * pretty.c
  * promisor-remote.c
  * pseudo-merge.c
  * read-cache.c
  * refs.c
  * remote-curl.c
  * repack-midx.c
  * replay.c
  * repository.c
  * revision.c
  * sequencer.c
  * setup.c
  * submodule.c
  * t/helper/test-path-walk.c
  * t/helper/test-read-midx.c
  * trailer.c
  * git-send-email.perl

Translate following new components:

  * builtin/history.c
  * builtin/url-parse.c
  * compat/fsmonitor/fsm-listen-linux.c
  * sideband.c
  * t/helper/test-synthesize.c

Signed-off-by: Bagas Sanjaya <redacted>
5 weeks agorefs: protect against chicken-and-egg recursion
Patrick Steinhardt [Thu, 25 Jun 2026 09:20:09 +0000 (11:20 +0200)]
refs: protect against chicken-and-egg recursion

In the preceding commits we have fixed recursion when creating the
reference backends due to a chicken-and-egg situation with "onbranch"
conditions. Unfortunately, this issue has existed for a while, and we
didn't really have a good mechanism to detect this recursion.

Improve the status quo by detecting the recursion when creating the main
reference store.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agorefs/reftable: lazy-load configuration to fix chicken-and-egg
Patrick Steinhardt [Thu, 25 Jun 2026 09:20:08 +0000 (11:20 +0200)]
refs/reftable: lazy-load configuration to fix chicken-and-egg

Same as with the "files" backend, the "reftable" backend also has a
chicken-and-egg problem with "onbranch" conditions. Fix this issue the
same as we did with the "files" backend by lazy-loading configuration.

Now that both the "files" and the "reftable" backend handle this
properly, add a generic test to t1400 that verifies that the user can
configure "core.logAllRefUpdates" via an "onbranch" condition. This is
mostly a nonsensical thing to do in the first place, but it serves as a
good sanity check.

Note that we had to move `should_write_log()` around so that it can
access the new `reftable_be_write_options()` function.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agoreftable: split up write options
Patrick Steinhardt [Thu, 25 Jun 2026 09:20:07 +0000 (11:20 +0200)]
reftable: split up write options

When initializing the reftable stack the caller may optionally pass some
write options. These write options mix up two different concerns though:

  - Of course, they allow the caller to configure how new reftables are
    being written.

  - But they also allow the caller to configure the stack itself, like
    its hash ID and the `on_reload` callback.

This is somewhat awkward, as it doesn't easily give the caller the
flexibility to for example write multiple reftables with different
options. Furthermore, this requires us to eagerly parse relevant
configuration when initializing the reftable backend.

Refactor the code by splitting out those options that configure the
stack itself. Creating a new stack will thus only require this limited
set of options, whereas the caller is expected to pass write options to
all functions that end up writing tables.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agorefs/files: lazy-load configuration to fix chicken-and-egg
Patrick Steinhardt [Thu, 25 Jun 2026 09:20:06 +0000 (11:20 +0200)]
refs/files: lazy-load configuration to fix chicken-and-egg

When initializing the "files" reference backend we read the repository's
config to parse "core.preferSymlinkRefs" and "core.logAllRefUpdates".
This results in a chicken-and-egg problem though, because parsing the
configuration may require us to have access to the reference store
already when an "onbranch" condition exists.

Luckily, all the configuration that we honor only relates to writing
references. Consequently, we don't strictly need that configuration to
be readily available at initialization time, and we can easiliy defer
parsing it to a later point in time.

Implement this fix and add tests that verify that we can indeed properly
parse these config knobs via an "onbranch" condition.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agorefs: move parsing of "core.logAllRefUpdates" back into ref stores
Patrick Steinhardt [Thu, 25 Jun 2026 09:20:05 +0000 (11:20 +0200)]
refs: move parsing of "core.logAllRefUpdates" back into ref stores

In cc42c88945 (refs: extract out reflog config to generic layer,
2026-05-04) we have refactored how we parse "core.logAllRefUpdates" so
that it happens in the generic layer. Unfortunately, this has worsened a
preexisting issue where we may recurse when creating the reference store
because of a chicken-and-egg problem between parsing the configuration
and evaluating "onbranch" conditions.

Prepare for a fix by essentially reverting that change so that we handle
this setting in the respective backends again. The backends are already
parsing other configuration anyway, so by moving the logic back in there
we can ensure that all backend configuration is parsed the same way.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agorepository: free main reference database
Patrick Steinhardt [Thu, 25 Jun 2026 09:20:04 +0000 (11:20 +0200)]
repository: free main reference database

While we release worktree and submodule reference databases when
clearing a repository, we don't ever release the main reference
database. This memory leak went unnoticed because its pointer is
kept alive by the "chdir_notify" subsystem.

Fix the memory leak.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agochdir-notify: drop unused `chdir_notify_reparent()`
Patrick Steinhardt [Thu, 25 Jun 2026 09:20:03 +0000 (11:20 +0200)]
chdir-notify: drop unused `chdir_notify_reparent()`

With the preceding commit we've removed all callers of
`chdir_notify_reparent()`, so the function is unused now. Drop it.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agorefs: unregister reference stores from "chdir_notify"
Patrick Steinhardt [Thu, 25 Jun 2026 09:20:02 +0000 (11:20 +0200)]
refs: unregister reference stores from "chdir_notify"

When creating reference stores we register them with the "chdir_notify"
subsystem. This is required because some of the paths we track may be
relative paths, so we have to reparent them in case the current working
directory changes.

But while we register the reference stores, we never unregister them.
This can have multiple outcomes:

  - For a repository's main reference database we essentially keep the
    pointer alive. We never free that database, either, and our leak
    checker doesn't notice because it's still registered.

  - For submodule and worktree reference databases we do eventually free
    them in `repo_clear()`, so we may keep pointers to free'd memory
    registered. We never notice though as we don't tend to chdir around
    in the middle of the process.

We never noticed either of these symptoms, but they are obviously bad.

Partially fix those issues by unregistering the reference stores when
releasing them. The leak of the main reference database will be fixed in
a subsequent commit.

Note that this requires us to use `chdir_notify_register()` instead of
`chdir_notify_reparent()`, as there is no infrastructure to unregister the
latter.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agosetup: don't apply "GIT_REFERENCE_BACKEND" without a repository
Patrick Steinhardt [Thu, 25 Jun 2026 09:20:01 +0000 (11:20 +0200)]
setup: don't apply "GIT_REFERENCE_BACKEND" without a repository

When discovering a repository we eventually also apply the
"GIT_REFERENCE_BACKEND" environment variable to the repository. There's
two problems with that:

  - We do this unconditionally, which is rather pointless: we really
    only have to configure the repository when we have found one.

  - We have already applied the repository format at that point in time,
    so we need to manually reapply it.

Move the logic around so that we only apply the environment variable
when a repository was discovered. This also allows us to drop the
explcit call to `repo_set_ref_storage_format()` because we now adjust
the format before we apply it via `apply_repository_format()`.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agosetup: stop applying repository format twice
Patrick Steinhardt [Thu, 25 Jun 2026 09:20:00 +0000 (11:20 +0200)]
setup: stop applying repository format twice

When discovering the repository in "setup.c" we apply the final
repository format multiple times:

  - Once via `repository_format_configure()`, where we apply the hash
    algorithm and ref storage format to both `struct repository_format`
    and `struct repository`.

  - And once via `apply_repository_format()`, where we apply these two
    settings from `struct repository_format` to `struct repository`.

With the current flow both of these are in fact necessary. But this is
only because we call `repository_format_configure()` after we have
called `apply_repository_format()`. Consequently, if we only changed the
repository format in `repository_format_configure()` it would never
propagate to the repository.

Refactor the code so that we first configure the repository format
before applying it to the repository so that we can stop setting the
hash and reference storage format multiple times.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agosetup: inline `check_and_apply_repository_format()`
Patrick Steinhardt [Thu, 25 Jun 2026 09:19:59 +0000 (11:19 +0200)]
setup: inline `check_and_apply_repository_format()`

We have two callsites of `check_and_apply_repository_format()`. In a
subsequent commit we'll want to adapt one of those callsites to change
the order in which we read and apply the repository format, at which
point the helper function will not really be a good fit for us anymore.

Inline the function to both of the callsites.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agoMerge branch 'ps/setup-centralize-odb-creation' into ps/refs-onbranch-fixes
Junio C Hamano [Thu, 11 Jun 2026 12:09:19 +0000 (05:09 -0700)]
Merge branch 'ps/setup-centralize-odb-creation' into ps/refs-onbranch-fixes

* ps/setup-centralize-odb-creation:
  setup: construct object database in `apply_repository_format()`
  repository: stop reading loose object map twice on repo init
  setup: stop initializing object database without repository
  setup: stop creating the object database in `setup_git_env()`
  repository: stop initializing the object database in `repo_set_gitdir()`
  setup: deduplicate logic to apply repository format
  setup: drop `setup_git_env()`
  t0001: plug test gaps for git-init(1) with GIT_OBJECT_DIRECTORY

5 weeks agoMerge branch 'master' of github.com:mbeniamino/git-po
Jiang Xin [Fri, 26 Jun 2026 12:51:39 +0000 (20:51 +0800)]
Merge branch 'master' of github.com:mbeniamino/git-po

* 'master' of github.com:mbeniamino/git-po:
  l10n: it: fix italian usage messages alignment

5 weeks agol10n: AGENTS.md: add quotation mark preservation guidelines
Jiang Xin [Fri, 26 Jun 2026 11:57:52 +0000 (19:57 +0800)]
l10n: AGENTS.md: add quotation mark preservation guidelines

Add a "Preserving Quotation Marks" section to prevent AI-assisted
translation and review from incorrectly converting language-specific
UTF-8 curly quotes (e.g., „ U+201E, " U+201C for Bulgarian) into
ASCII straight quotes " (U+0022), which would cause PO string
truncation and syntax errors.

Also update the "Special characters" item in the Quality checklist
to reference the new section.

Signed-off-by: Jiang Xin <redacted>
5 weeks agol10n: zh_CN: updated translation for 2.55
lilydjwg [Sun, 21 Jun 2026 08:16:11 +0000 (16:16 +0800)]
l10n: zh_CN: updated translation for 2.55

Reviewed-by: Jiang Xin <redacted>
Reviewed-by: Fangyi Zhou <redacted>
Signed-off-by: lilydjwg <redacted>
5 weeks agol10n: TEAMS: change Simplified Chinese team leader
lilydjwg [Mon, 22 Jun 2026 06:20:21 +0000 (14:20 +0800)]
l10n: TEAMS: change Simplified Chinese team leader

Signed-off-by: lilydjwg <redacted>
5 weeks agoMerge branch 'ps/t4216-tap-fix'
Junio C Hamano [Fri, 26 Jun 2026 02:49:01 +0000 (19:49 -0700)]
Merge branch 'ps/t4216-tap-fix'

TAP output breakage fix.

* ps/t4216-tap-fix:
  t4216: fix no-op test that breaks TAP output

5 weeks agoconnected: search promisor objects generically
Patrick Steinhardt [Thu, 25 Jun 2026 09:57:42 +0000 (11:57 +0200)]
connected: search promisor objects generically

When performing connectivity checks we have to figure out whether any of
the new objects are promisor objects, as we cannot assume full
connectivity if so.

This check is performed by iterating through all packfiles in the
repository and searching each of them for the given object. Of course,
this mechanism is quite specific to implementation details of the object
database, as we assume that it uses packfiles in the first place.

Refactor the logic so that we instead use `odb_for_each_object_ext()`
with an object prefix filter and the `ODB_FOR_EACH_OBJECT_PROMISOR_ONLY`
flag. This will yield all objects that have the exact object name and
that are part of a promisor pack in a generic way.

Add a test to verify that we indeed use the optimization.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agoconnected: split out promisor-based connectivity check
Patrick Steinhardt [Thu, 25 Jun 2026 09:57:41 +0000 (11:57 +0200)]
connected: split out promisor-based connectivity check

When performing a connectivity check in a partial clone we try to avoid
doing the connectivity check by checking whether all new tips are part
of a promisor pack. This makes use of the fact that we don't expect full
connectivity for promised objects anyway, so it's basically fine if
those objects are not fully connected.

The logic that handles this promisor-based check is somewhat hard to
read though as it uses nested loops and gotos. Pull it out into a
standalone function, which makes it a bit easier to reason about.

We'll also further simplify the function in the next commit.

Suggested-by: Christian Couder <redacted>
Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agoodb/source-packed: support flags when iterating an object prefix
Patrick Steinhardt [Thu, 25 Jun 2026 09:57:40 +0000 (11:57 +0200)]
odb/source-packed: support flags when iterating an object prefix

Callers of `odb_for_each_object()` can specify an optional object name
prefix so that we only yield objects that match it. This is incompatible
though with passing flags at the same time, as we don't yet know to
handle them.

Loosen this restriction by calling `should_exclude_pack()`.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agoodb/source-packed: extract logic to skip certain packs
Patrick Steinhardt [Thu, 25 Jun 2026 09:57:39 +0000 (11:57 +0200)]
odb/source-packed: extract logic to skip certain packs

The caller can pass flags that allow them to filter out specific kinds
of objects when iterating objects via `odb_for_each_object()`. This only
works for "normal" iteration though, as we `BUG()` when the user passes
flags and specifies an object prefix.

This limitation will be lifted in the next commit. Prepare for this by
extracting the logic that skips certain kinds of packs so that we can
easily reuse it.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agot4216: fix no-op test that breaks TAP output
Patrick Steinhardt [Fri, 19 Jun 2026 07:20:20 +0000 (09:20 +0200)]
t4216: fix no-op test that breaks TAP output

In t4216 we have have a prerequisite that is active in case the system's
`char` type is signed by default. This prerequisite isn't really used by
anything though: while it is used to guard one of our tests, that
specific test is essentially a no-op. So all this infrastructure does is
to provide some debugging hint to a reader that pays a lot of attention.

Besides that, the way we set up the prerequisite also results in broken
TAP output on systems where `char` is unsigned by default: we use
`test_cmp()` to diff two files outside of of any test body, and if the
files differ we enable the prerequisite. If so, the call to `test_cmp()`
would also print output, and that output is of course not valid TAP
output.

That wasn't a problem before 389c83025d (t: let prove fail when parsing
invalid TAP output, 2026-06-04), because our TAP parser was configured
to be lenient. But starting with that commit, t4216 is now failing on
systems with unsigned chars.

Drop the whole infrastructure. The prerequisite is not used anywhere
else, and the only location where it's used doesn't really provide much
value.

Reported-by: Todd Zullinger <redacted>
Signed-off-by: Patrick Steinhardt <redacted>
Tested-by: Todd Zullinger <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agol10n: sv.po: Update Swedish translation
Peter Krefting [Thu, 25 Jun 2026 15:16:10 +0000 (16:16 +0100)]
l10n: sv.po: Update Swedish translation

Reviewed-by: Tuomas Ahola <redacted>
Signed-off-by: Peter Krefting <redacted>
5 weeks agol10n: ca.po: update Catalan translation
Mikel Forcada [Thu, 25 Jun 2026 08:14:24 +0000 (10:14 +0200)]
l10n: ca.po: update Catalan translation

Signed-off-by: Mikel Forcada <redacted>
5 weeks agol10n: tr: Update Turkish translations
Emir SARI [Tue, 16 Jun 2026 17:41:01 +0000 (20:41 +0300)]
l10n: tr: Update Turkish translations

Signed-off-by: Emir SARI <redacted>
5 weeks agol10n: bg.po: Updated Bulgarian translation (6322t)
Alexander Shopov [Sun, 14 Jun 2026 11:27:13 +0000 (13:27 +0200)]
l10n: bg.po: Updated Bulgarian translation (6322t)

Signed-off-by: Alexander Shopov <redacted>
5 weeks agorepo: add path.gitdir with absolute and relative suffix formatting
K Jayatheerth [Wed, 24 Jun 2026 03:37:48 +0000 (09:07 +0530)]
repo: add path.gitdir with absolute and relative suffix formatting

Scripts need a stable way to locate the git directory without
parsing rev-parse output or relying on its flag-driven path format
selection. There is no way to retrieve this path from git repo info
today.

Introduce path.gitdir.absolute and path.gitdir.relative keys,
consistent with the path.commondir keys added in the previous patch.
Reuse the test_repo_info_path helper introduced there to validate
both variants.

Mentored-by: Justin Tobler <redacted>
Mentored-by: Lucas Seiki Oshiro <redacted>
Signed-off-by: K Jayatheerth <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agorepo: add path.commondir with absolute and relative suffix formatting
K Jayatheerth [Wed, 24 Jun 2026 03:37:47 +0000 (09:07 +0530)]
repo: add path.commondir with absolute and relative suffix formatting

Scripts working with worktree setups need a reliable way to discover
the common directory, which diverges from the git directory when
multiple worktrees are in use. There is no way to retrieve this path
from git repo info today.

Introduce path.commondir.absolute and path.commondir.relative keys.
Exposing explicit format variants rather than a single key with a
default avoids ambiguity for scripts that require predictable output.

Mentored-by: Justin Tobler <redacted>
Mentored-by: Lucas Seiki Oshiro <redacted>
Signed-off-by: K Jayatheerth <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agopath: extract format_path() and use in rev-parse
K Jayatheerth [Wed, 24 Jun 2026 03:37:46 +0000 (09:07 +0530)]
path: extract format_path() and use in rev-parse

Path formatting logic in builtin/rev-parse.c writes directly to
stdout. Other builtins cannot reuse it.

Extract this logic into format_path() in path.c and expose
a path_format enum in path.h.

Convert rev-parse to use the new helper in the same step to validate
the API against existing tests and avoid introducing dead code.

Mentored-by: Justin Tobler <redacted>
Mentored-by: Lucas Seiki Oshiro <redacted>
Signed-off-by: K Jayatheerth <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agostatus: improve rebase todo list parsing
Phillip Wood [Tue, 23 Jun 2026 15:53:57 +0000 (16:53 +0100)]
status: improve rebase todo list parsing

When there is rebase in progress "git status" displays the last couple
of completed and the next couple of pending commands from the todo
list. When it does this it tries to abbreviate the object ids of
the commits to be picked. Unfortunately it does not abbreviate the
object ids when the line starts with "fixup -C" or "merge -C". It
also mistakenly replaces the refname in "reset main" and "update-ref
refs/heads/main" with the object id that the ref points to.

Fix this by using the function added in the last commit to parse the
command name and only try to abbreviate the argument for commands that
take an object id. If a command accepts a label then try to resolve the
object name as a label first and only if that fails try to resolve it
as an object_id. When trying to abbreviate an object id, only replace
the object name if it starts with the abbreviated object id so that
tag or branch names that contain only hex digits are left unchanged.

Comments are now processed after stripping any leading
whitespace from the line. This matches what the sequencer does in
parse_insn_line(). The existing test cases are updated to test a
wider variety of commands. Only the pending commands in the tests
are changed to avoid removing existing coverage.

Helped-by: Elijah Newren <redacted>
Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agosequencer: factor out parsing of todo commands
Phillip Wood [Tue, 23 Jun 2026 15:53:56 +0000 (16:53 +0100)]
sequencer: factor out parsing of todo commands

Move the code that parses todo commands into a separate function so
that it can be shared with "git status" in the next commit. As we
know the input is NUL terminated we do not pass a pointer to the end
of the line and instead test for a blank line by looking for NUL, CR
LF, or LF. We use starts_with() instead of starts_with_mem() for the
same reason. This results in slightly different behavior when there
a CR at the start of the line that is not followed by LF. Previously
such a line was treated as a comment rather than an invalid line.

Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
5 weeks agoGit 2.55-rc2 v2.55.0-rc2
Junio C Hamano [Tue, 23 Jun 2026 03:04:38 +0000 (20:04 -0700)]
Git 2.55-rc2

Signed-off-by: Junio C Hamano <redacted>
5 weeks agoMerge branch 'hn/macos-linker-warning'
Junio C Hamano [Tue, 23 Jun 2026 03:05:04 +0000 (20:05 -0700)]
Merge branch 'hn/macos-linker-warning'

Xcode 15 and later has a linker set to complain when the same library
archive is listed twice on the command line.  Squelch the annoyance.

* hn/macos-linker-warning:
  config.mak.uname: avoid macOS dup-library warning

5 weeks agoMerge branch 'js/win32-localtime-r'
Junio C Hamano [Tue, 23 Jun 2026 03:05:03 +0000 (20:05 -0700)]
Merge branch 'js/win32-localtime-r'

Build-fix for 32-bit Windows.

* js/win32-localtime-r:
  win32: ensure that `localtime_r()` is declared even in i686 builds

5 weeks agoMerge branch 'ps/gitlab-ci-windows'
Junio C Hamano [Tue, 23 Jun 2026 03:05:03 +0000 (20:05 -0700)]
Merge branch 'ps/gitlab-ci-windows'

Wean the Windows builds in GitLab CI procedure away from
(unfortunately unreliable) Chocolatey to install dependencies.

* ps/gitlab-ci-windows:
  gitlab-ci: migrate Windows builds away from Chocolatey

6 weeks agoMerge branch 'ps/odb-source-packed' into ps/connected-generic-promisor-checks
Junio C Hamano [Mon, 22 Jun 2026 17:43:15 +0000 (10:43 -0700)]
Merge branch 'ps/odb-source-packed' into ps/connected-generic-promisor-checks

* ps/odb-source-packed:
  odb/source-packed: drop pointer to "files" parent source
  midx: refactor interfaces to work on "packed" source
  odb/source-packed: stub out remaining functions
  odb/source-packed: wire up `freshen_object()` callback
  odb/source-packed: wire up `find_abbrev_len()` callback
  odb/source-packed: wire up `count_objects()` callback
  odb/source-packed: wire up `for_each_object()` callback
  odb/source-packed: wire up `read_object_stream()` callback
  odb/source-packed: wire up `read_object_info()` callback
  packfile: use higher-level interface to implement `has_object_pack()`
  odb/source-packed: wire up `reprepare()` callback
  odb/source-packed: wire up `close()` callback
  odb/source-packed: start converting to a proper `struct odb_source`
  odb/source-packed: store pointer to "files" instead of generic source
  packfile: move packed source into "odb/" subsystem
  packfile: split out packfile list logic
  packfile: rename `struct packfile_store` to `odb_source_packed`

6 weeks agowin32: ensure that `localtime_r()` is declared even in i686 builds
Johannes Schindelin [Mon, 22 Jun 2026 08:44:06 +0000 (08:44 +0000)]
win32: ensure that `localtime_r()` is declared even in i686 builds

The `__MINGW64__` constant is defined, surprise, surprise, only when
building for a 64-bit CPU architecture.

Therefore using it as a guard to define `_POSIX_C_SOURCE` (so that
`localtime_r()` is declared, among other functions) is not enough, we
also need to check `__MINGW32__`.

Technically, the latter constant is defined even for 64-bit builds. But
let's make things a bit easier to understand by testing for both
constants.

Making it so fixes this compile warning (turned error in GCC v14.1):

  archive-zip.c: In function 'dos_time':
  archive-zip.c:612:9: error: implicit declaration of function 'localtime_r';
  did you mean 'localtime_s'? [-Wimplicit-function-declaration]
    612 |         localtime_r(&time, &tm);
        |         ^~~~~~~~~~~
        |         localtime_s

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 weeks agolog: improve --follow following renames for non-linear history
Miklos Vajna [Mon, 22 Jun 2026 06:23:31 +0000 (08:23 +0200)]
log: improve --follow following renames for non-linear history

Have a repo with a subtree merge, do a 'git log --follow prefix/test.c',
the output only contains history in the outer repo, not commits that
were merged via a subtree merge.

What happens is that 'git log --follow' stores the followed path only in
opt->diffopt.pathspec, so in case the commit history is non-linear, and
multiple parents have renames to the followed path, then the end result
isn't really defined: the first commit that happens to be visited in one
of the parents update opt->diffopt.pathspec, and from that point, only
that updated path is visited.

Fix the problem by introducing a commit -> path map
(follow_pathspec_slab) that stores what will be a path to follow when
visiting that parent. At the top of log_tree_commit(), if the slab has
an entry for this commit, we replace opt->diffopt.pathspec with a path
from this entry, so the correct path is followed, even if an unrelated
sub-tree changed the path to be followed to something else. After
log_tree_diff() runs, we record each parent's path in the slab. As a
result, the walk order doesn't matter, which was exactly the source of
problems previously.

This helps with subtree merges (rename happens inside the merge commit),
but also fixes the general case when the rename happens in the history
of parents, not in the merge commit itself.

Signed-off-by: Miklos Vajna <redacted>
Signed-off-by: Junio C Hamano <redacted>
6 weeks agoA few more topics before -rc2
Junio C Hamano [Sun, 21 Jun 2026 23:41:10 +0000 (16:41 -0700)]
A few more topics before -rc2

Signed-off-by: Junio C Hamano <redacted>
6 weeks agoMerge branch 'js/objects-larger-than-4gb-on-windows-more'
Junio C Hamano [Sun, 21 Jun 2026 23:41:37 +0000 (16:41 -0700)]
Merge branch 'js/objects-larger-than-4gb-on-windows-more'

* js/objects-larger-than-4gb-on-windows-more:
  odb: use size_t for object_info.sizep and the size APIs
  packfile,delta: drop the `cast_size_t_to_ulong()` wrappers
  pack-objects: use size_t for in-core object sizes
  packfile: widen unpack_entry()'s size out-parameter to size_t
  pack-objects(check_pack_inflate()): use size_t instead of unsigned long
  patch-delta: use size_t for sizes
  compat/msvc: use _chsize_s for ftruncate

6 weeks agoMerge branch 'kw/gitattributes-typofix'
Junio C Hamano [Sun, 21 Jun 2026 23:41:37 +0000 (16:41 -0700)]
Merge branch 'kw/gitattributes-typofix'

* kw/gitattributes-typofix:
  gitattributes: fix eol attribute for Perl scripts

git clone https://git.99rst.org/PROJECT