Commit Graph

82503 Commits (e65d1295fed495b122b2c8aed13038b00ef857f0)

Author SHA1 Message Date
Junio C Hamano e65d1295fe Merge branch 'mm/diff-process-hunks' into seen
A new 'diff.<driver>.process' configuration has been introduced to
allow a long-running external process to act as a hunk provider,
enabling external tools to control which lines Git considers changed
while leaving all output formatting (word diff, color, blame, etc.) to
Git's standard pipeline.

* mm/diff-process-hunks:
  fixup! diff: consult oid-only hunk providers via diff.<driver>.process
  diff: consult oid-only hunk providers via diff.<driver>.process
  userdiff: add diff.<driver>.process config
  sub-process: add a gentle status read
  sub-process: separate process lifecycle from hashmap management
  blame: read precomputed hunks
  diff: read precomputed hunks for stat output
  diff: record precomputed hunks during stat output
  diff-hunks: add the store format, library, and command
  diff: introduce a hunk provider interface
  gitattributes: document how external diff drivers relate to diff features
2026-09-21 10:04:23 -07:00
Junio C Hamano dd2a803709 Merge branch 'cc/early-scan-options' into seen
The process of parsing command-line options in commands that
perform an early scan over their arguments (such as 'git bisect',
'git rev-parse', and 'git fast-import') has been unified using a
new early-scan sub-API, which parses and skips known options taking
separate values to prevent logic bugs.

* cc/early-scan-options:
  fast-import: use early_scan_options() for --allow-unsafe-features
  parse-options: build early scan options from a struct option array
  parse-options: add parse_options_takes_argument()
  rev-parse: fix "--" detection when it is an option value
  bisect: fix "--" detection when a term name is "--"
  parse-options: add early_scan_options()
2026-09-21 10:04:22 -07:00
Junio C Hamano 3ed3f343c4 Merge branch 'tc/last-modified-bloom' into seen
The 'git last-modified' command has been optimized by using Bloom
filters.  It now reuses revision walk filtering logic from 'git log'
to pre-filter commits, and maintains per-path Bloom filters even when
wildcard pathspecs are used.

* tc/last-modified-bloom:
  last-modified: keep per-path Bloom filters for wildcard pathspecs
  last-modified: check pathspec against Bloom filter first
  revision: add Bloom check that includes parent directories
  bloom: add helper to check if any key in a vector is present
  revision: expose check for paths maybe changed in Bloom filter
  revision: move bloom keyvec precondition into function
2026-09-21 10:04:22 -07:00
Junio C Hamano 24382adf13 Merge branch 'll/doc-pushcert-if-asked' into seen
The remote helper documentation for the 'pushcert' option has been
updated to mention that it can also take 'if-asked', reflecting the
existing implementation in the code.

* ll/doc-pushcert-if-asked:
  doc: remote-helpers: option pushcert if-asked
2026-09-21 10:04:22 -07:00
Junio C Hamano 14c4066793 Merge branch 'jc/checkout-refactor' into seen
The front-end code for 'git checkout', 'git switch', and 'git
restore' has been restructured to cleanly separate their pathspec
and branch handling, eliminating a common bottleneck and paving the
way to libify utility helpers.

* jc/checkout-refactor:
  checkout: move post_checkout_hook() to checkout.c
  checkout: wrap overly long lines
  checkout: restructure switch, restore, and checkout entrypoints
  checkout: extract branch setup and tracking helpers
  checkout: extract option validation and pathspec helpers
  checkout: validate stage and merge option compatibility in checkout_paths()
  checkout: validate new branch name in checkout_branch()
  checkout: pass cb_option explicitly to branch name parsers
2026-09-21 10:04:22 -07:00
Junio C Hamano 7e8679e39e Merge branch 'fz/rebase-autosquash-empty' into seen
A commit that is emptied by melding a 'fixup!' or 'squash!' commit
during 'git rebase --autosquash' is now handled according to the
'--empty' option, allowing it to be dropped, kept, or to halt the
rebase.

* fz/rebase-autosquash-empty:
  sequencer: honor --empty when a fixup!/squash! empties its target
2026-09-21 10:04:21 -07:00
Junio C Hamano b6f078baf9 Merge branch 'ws/squelch-svn-migrate' into seen
* ws/squelch-svn-migrate:
  Makefile: add NO_GIT_SVN knob to skip building/installing git-svn
  git-svn: don't print v1-layout migration noise when there's nothing to migrate
2026-09-21 10:04:21 -07:00
Junio C Hamano 7b3f18a96f Merge branch 'kh/format-rev-more-options' into seen
The experimental 'git format-rev' has been taught a few more
formatting options.

* kh/format-rev-more-options:
  format-rev: learn --abbrev, --color, and --date
  doc: rev-list-options.adoc: factor out --date alts
  format-rev: factor option variables into a struct
  format-rev: place BUG calls first in callback
  format-rev: use lower case for opts description
2026-09-21 10:04:21 -07:00
Junio C Hamano 4eccbf0097 Merge branch 'cc/lazy-fetch-trusted-bit' into seen
A new 'uploadpack.lazyFetchTrusted' configuration variable has been
introduced to allow 'upload-pack' to lazily fetch missing objects from
configured promisor remotes when serving trusted repositories.

* cc/lazy-fetch-trusted-bit:
  builtin/upload-pack: set GIT_NO_LAZY_FETCH to 0 on trusted repo
  promisor-remote: prevent infinite recursion when lazy fetching
  upload-pack: read uploadpack.lazyFetchTrusted
  setup: extract path_allowlist_apply()
  promisor-remote: factor out lazy_fetch_objects()
2026-09-21 10:04:21 -07:00
Junio C Hamano 9bd3a65f02 Merge branch 'ty/repo-config-cleanups' into seen
Repository configuration getters in 'environment.c' have been
simplified by removing redundant NULL checks.  The documentation for
these getters in 'environment.h' has been clarified, and inaccurate
section comments inside 'struct repo_config_values' have been removed.

* ty/repo-config-cleanups:
  environment: remove inaccurate repo_config_values comments
  environment: clarify repository config getter documentation
  environment: drop redundant NULL checks in config getters
2026-09-21 10:04:20 -07:00
Junio C Hamano 57af9a9bf8 Merge branch 'bc/restrict-hex-to-lowercase' into seen
The parser for hex object names has been updated to reject uppercase
hexadecimal characters when running in the breaking changes mode, in
preparation for Git 3.0.

* bc/restrict-hex-to-lowercase:
  hex: allow only lowercase object IDs in breaking changes mode
  t5324: adjust tests for corrupt commit-graph
  object-name: use hexval
  hex: label usages of hex parsing for object IDs
  hex: make hex_to_bytes accept kind of hex to use
  hex: allow specifying hex type with hex2chr
  hex: add functionality for lowercase-only hex
2026-09-21 10:04:20 -07:00
Junio C Hamano ca6e165067 Merge branch 'pz/fetch-submodule-errors-config' into seen
The 'git fetch' command can now configure how submodule fetch errors
are handled via 'fetch.submoduleErrors' and '--submodule-errors',
making them non-fatal.  A premature failure during recursive submodule
fetches has been fixed by deferring the error until the OID-based
retry phase fails.

* pz/fetch-submodule-errors-config:
  fetch: add fetch.submoduleErrors to make submodule fetch errors non-fatal
  submodule: fix premature failure in recursive submodule fetch
2026-09-21 10:04:20 -07:00
Junio C Hamano 932aafe650 Merge branch 'kj/repo-info-more-path-keys' into seen
The 'git repo info' command has been taught more keys to output
paths of various repository components (such as the working tree
root, superproject working tree, object database, etc.), supporting
both absolute and relative path formats.

* kj/repo-info-more-path-keys:
  repo: add path.cdup
  repo: add path.git-prefix
  repo: add path.grafts with absolute and relative suffixes
  repo: add path.index with absolute and relative suffixes
  repo: add path.hooks with absolute and relative suffixes
  repo: add path.superproject-root with absolute and relative suffixes
  repo: add path.toplevel with absolute and relative suffix formatting
2026-09-21 10:04:19 -07:00
Junio C Hamano a2b2a01f7c Merge branch 'ds/trace2-tolerate-failed-timestamp' into seen
Functions like `xstrfmt()` and `xcalloc()` have been banned from use
in the trace2 API codebase to prevent calls to `die()` which lead to
unwanted process exits and recursion when memory allocation fails.

* ds/trace2-tolerate-failed-timestamp:
  trace2: remove use of xcalloc()
  trace2: remove use of ALLOC_GROW()
  trace2: remove use of xstrfmt()
  trace2: remove use of ALLOC_ARRAY()
  trace2: remove use of xstrdup()
  trace2: tolerate failed timestamp formatting
  banned-die: create header for banning of functions
2026-09-21 10:04:19 -07:00
Junio C Hamano e5e5253d9a Merge branch 'mm/line-log-limited-ops' into seen
The 'git log -L<range>:<path>' command has been taught to limit
various 'diff' operations, such as '--stat', '--check', and '-G', to
the specified range and path.

* mm/line-log-limited-ops:
  diffcore-pickaxe: limit -G to the -L tracked range
  diff: support --check with -L line ranges
  diff: support stat formats with -L
  diff: extract a line-range diff helper for reuse
  diff: emit -L hunk headers via xdiff's formatter
  diff: simplify the line-range filter by classifying removals immediately
  diff: rename line-range filter struct and clarify fields
2026-09-21 10:04:19 -07:00
Junio C Hamano 073de0dcdd Merge branch 'tb/midx-incremental-custom-base' into seen
The 'git multi-pack-index write --incremental' command has been
corrected to properly honor the '--base' option.  Previously, the
custom base was ignored by the normal write path; packs from layers
above the selected base were incorrectly skipped by the pack exclusion
logic, and reachability closure for bitmaps was broken.

* tb/midx-incremental-custom-base:
  midx-write: include packs above custom incremental base
  midx: pass custom '--base' through incremental writes
  t5334: expose shared `nth_line()` helper
2026-09-21 10:04:18 -07:00
Junio C Hamano 9abe23147d Merge branch 'ec/commit-fixup-options' into seen
Support for '-m', '-F', '-c', or '-C' options to supply a commit log
message from outside the editor has been added for all 'git commit
--fixup' variations.

* ec/commit-fixup-options:
  commit: allow -c/-C for all kinds of --fixup
  commit: allow -m/-F for all kinds of --fixup
2026-09-21 10:04:18 -07:00
Junio C Hamano c34b0e5d18 Merge branch 'hn/range-diff-matched-only' into jch
The 'git range-diff' command has been augmented with a
'--matched-only' option to skip commits that are only present on
one side, allowing users to easily focus on only the commits that
have been retained.

* hn/range-diff-matched-only:
  range-diff: add --matched-only to skip one-sided commits
2026-09-21 10:04:04 -07:00
Junio C Hamano 2f38fa1473 Merge branch 'pp/midx-write-skip-empty' into jch
The `git multi-pack-index write` command has been updated to
silently return success when there are no object entries to index.
This avoids writing empty `multi-pack-index` layers, which
previously caused subsequent incremental midx writes using the
`--bitmap` option to fail when attempting to load the missing
reverse index.

* pp/midx-write-skip-empty:
  midx-write: skip writes with no object entries
2026-09-21 10:04:04 -07:00
Junio C Hamano eef3cd5d43 Merge branch 'jk/merge-ll-tempfile-cleanup' into jch
The external merge driver in 'git merge' now uses the tempfile API
to create its temporary files.  This ensures that these temporaries
are reliably cleaned up even when the merge driver or its parent Git
process is terminated abruptly.

* jk/merge-ll-tempfile-cleanup:
  merge-ll: use tempfile API for external driver files
  merge-ll: catch close() errors when writing external tempfiles
  merge-ll: use strbuf to read back external merge result
2026-09-21 10:04:04 -07:00
Junio C Hamano c483bdab2a Merge branch 'ta/command-list-guides-sync-lint' into jch
A new linter test has been added to Documentation/lint-manpages.sh
to ensure that all non-command manual pages (guides and developer
interfaces) listed in Documentation/Makefile are present in
command-list.txt, replacing an older comment that reminded
developers to keep them in sync.

* ta/command-list-guides-sync-lint:
  lint-docs: check the guide list in command-list.txt
  command-list.txt: add gitformat-loose(5) and gitpacking(7)
2026-09-21 10:04:03 -07:00
Junio C Hamano a72572927d Merge branch 'dw/config-read-both-global' into jch
The git config --global read operations have been updated to respect
both $HOME/.gitconfig and $XDG_CONFIG_HOME/git/config, fixing an
inconsistency where only the former was read when both configuration
files are present.

* dw/config-read-both-global:
  config: read global scope via config_sequence
  config: let sequence require a successful file
  path: use forward slashes in XDG config on Windows
2026-09-21 10:04:03 -07:00
Junio C Hamano f607f9f36c Merge branch 'vv/branch-recurse-no-start-ref' into jch
The --recurse-submodules option in 'git branch' has been fixed to
avoid a crash when the start point is not a reference (e.g., a raw
object ID).  The creation path now skips setting up tracking and
properly forwards the absent tracking name to the submodule helper.

* vv/branch-recurse-no-start-ref:
  branch: allow recursion with no tracking name
  branch: do not track a start point with no ref
2026-09-21 10:04:03 -07:00
Junio C Hamano 0c8b75e4c5 Merge branch 'as/utimensat-utimes' into jch
The codebase has been updated to use the newer utimensat() POSIX
function instead of the obsolescent utime(), allowing
high-precision timestamps while preserving fallback compatibility.

* as/utimensat-utimes:
  compat/posix: drop legacy <utime.h> header and shims
  treewide: use utimensat(2) instead of legacy utime(3p)
  compat/posix: introduce utimensat(2) wrapper
2026-09-21 10:04:03 -07:00
Junio C Hamano ea4ea09c8d Merge branch 'ap/http-preserve-wwwauth-redirect' into jch
When an HTTP request triggers a redirect and the target yields an
authentication challenge, the WWW-Authenticate headers received
during the redirect are now explicitly preserved across the
credential URL update, fixing an issue where they were incorrectly
cleared.

* ap/http-preserve-wwwauth-redirect:
  http: preserve wwwauth_headers across redirects
2026-09-21 10:04:02 -07:00
Junio C Hamano efd03c700b Merge branch 'ij/subtree-reject-v2-config' into jch
The shell script implementation of 'git subtree' has been updated to
check for the presence of the configuration file of the new Rust
implementation, preventing users from accidentally running the old
script on repositories already managed by the new tool.

* ij/subtree-reject-v2-config:
  git-subtree: Bail out if we find output from Rust rewrite (test)
  git-subtree: Bail out if we find output from Rust rewrite
2026-09-21 10:04:02 -07:00
Junio C Hamano 62f04c4bad Merge branch 'js/coverity-fixes' into jch
Assorted fixes for code paths that are not careful with boundary and
error conditions.

* js/coverity-fixes:
  test-read-midx: check midx_fill_entry() result
  oss-fuzz: handle reftable iterator initialization failures
  t/unit-tests: check reftable iterator initialization
  rerere: do not record failed conflict resolution data
  midx: validate incremental MIDX pack IDs
  gpg-interface: make signature-prefix matching length-aware
  wrapper: guard writev_in_full() against signed overflow
2026-09-21 10:04:02 -07:00
Junio C Hamano 1b6b8c00fd Merge branch 'rr/upload-pack-swap-shallow-wanted-ref' into jch
The server-side protocol v2 response order for 'wanted-refs' and
'shallow-info' has been swapped to match the client's expectation,
fixing a fetch failure when the server has 'uploadpack.allowRefInWant'
enabled and the client performs a shallow fetch.

* rr/upload-pack-swap-shallow-wanted-ref:
  upload-pack: swap wanted-ref/shallow-info responses
2026-09-21 10:04:01 -07:00
Junio C Hamano c698d4a539 Merge branch 'of/commit-reach-repo-awareness' into jch
The can_all_from_reach() and can_all_from_reach_with_flag()
functions have been updated to accept a repository context,
preventing bugs where submodule merging incorrectly reads from the
superproject's commit-graph.

* of/commit-reach-repo-awareness:
  commit-reach: parse commits in the given repository
2026-09-21 10:04:01 -07:00
Junio C Hamano b5888272d4 Merge branch 'gg/http-ssl-verify-status' into jch
The HTTP transport has been taught to check the revocation status of
the server certificate using the stapled OCSP response during the
TLS handshake via a new 'http.sslVerifyStatus' configuration
variable.

* gg/http-ssl-verify-status:
  http: add http.sslVerifyStatus to check stapled OCSP responses
2026-09-21 10:04:01 -07:00
Junio C Hamano 0f775749f6 ### match next 2026-09-21 10:04:01 -07:00
Junio C Hamano 92a9076df4 Merge branch 'sg/precompile-git-compat-util' into jch
The 'Makefile' has been taught to precompile 'git-compat-util.h' to
speed up overall compilation, while excluding sources that do not
include the compatibility header.

* sg/precompile-git-compat-util:
  Makefile: precompile "git-compat-util.h"
  Makefile: reintroduce REFTABLE_OBJS
  cmake: remove any "$(*_OBJS)" variables when parsing Makefile for sources
  Makefile: remove XDIFF_OBJS initialization
2026-09-21 10:04:01 -07:00
Junio C Hamano 5e8287270f Merge branch 'dk/use-nsec-runtime' into jch
The build-time knob 'USE_NSEC' for nanosecond stat precision has been
converted to a runtime configuration 'core.useNanosec', allowing
distributions to bundle one binary that adapts to filesystem
capabilities dynamically.

* dk/use-nsec-runtime:
  core: convert build-time USE_NSEC into runtime core.useNanosec
  environment: align repo_config_values_init with struct declaration
  meson: expose knob for xmlto relative links in manuals
2026-09-21 10:04:00 -07:00
Junio C Hamano c7d4b0c33d Merge branch 'ps/ref-storage-format' into jch
The terminology regarding reference storage formats has been unified
across command-line options, environment variables, configuration
variables, and source code, standardizing on the phrase "ref storage
format" (e.g., `--ref-storage-format`, `'GIT_REF_STORAGE_FORMAT'`).
Additionally, the `--ref-storage-format` option has been updated to
accept payloads in the form `<format>://<payload>`.

* ps/ref-storage-format:
  setup: allow "--ref-storage-format=" to specify a payload
  setup: rename "init.defaultRefFormat" to "init.defaultRefStorageFormat"
  t: rename GIT_TEST_DEFAULT_REF_FORMAT
  setup: rename ref storage format environment variables
  setup: refactor how we configure the ref storage format
  refs: expose function to parse reference URIs
  help: rename "default-ref-format" to "default-ref-storage-format"
  builtin/rev-parse: rename "--show-ref-format" to "--show-ref-storage-format"
  builtin/submodule: rename "--ref-format=" to "--ref-storage-format="
  builtin/refs: rename "--ref-format=" to "--ref-storage-format="
  builtin/clone: rename "--ref-format=" to "--ref-storage-format="
  builtin/init: rename "--ref-format=" to "--ref-storage-format="
  parse-options: allow for hidden aliases
2026-09-21 10:04:00 -07:00
Junio C Hamano 301df04062 Merge branch 'ak/refs-files-root-ref-lock' into jch
The files backend has been updated to avoid unconditionally locking
the 'packed-refs' file when deleting a root ref (which are never
packed).

* ak/refs-files-root-ref-lock:
  refs/files: avoid packed-refs lock for root ref deletion
2026-09-21 10:03:59 -07:00
Junio C Hamano 548b342aa0 Merge branch 'jc/cocci-free-updates' into jch
Updates to Coccinelle semantic patches to correctly handle the
'FREE_AND_NULL()' macro and avoid generating broken transformations
for negated pointer checks.

* jc/cocci-free-updates:
  cocci: FREE_AND_NULL(E) is safe to call on NULL
  cocci: remove risky "if (!E) free(E)" conversion
2026-09-21 10:03:59 -07:00
Junio C Hamano 89b7b646c8 Merge branch 'kn/receive-report-hook' into jch
A new hook 'report' is added to 'git receive-pack', which runs after
reference updates and allows the server to filter or modify the
packet-line status report sent back to the client.

* kn/receive-report-hook:
  receive-pack: coccinelle fix
  hook: introduce the receive-report hook
  receive-pack: move message generation to separate function
  receive-pack: drop static variables to track report status version
  doc: add proc-receive hook info in 'git-receive-pack.adoc'
2026-09-21 10:03:59 -07:00
Junio C Hamano ea12635b2f Merge branch 'hn/history-squash' into jch
The experimental 'git history' command has been taught a new 'squash'
subcommand to fold a range of commits into a single commit, with any
descendants replayed on top.

* hn/history-squash:
  history: support editing squashed commit messages
  history: create squashed commits without editing
  history: protect branches when squashing a range
  history: validate squash revision ranges
  history: add skeleton for squash subcommand
  sequencer: share the squash message marker helpers and flags
  history: give commit_tree_ext a message template
  history: extract helper for a commit's parent tree
2026-09-21 10:03:59 -07:00
Junio C Hamano 9bf045c931 Merge branch 'ps/odb-alternates-at-creation' into jch
The setup of alternates has been deferred to object database
creation time during clone, which drops the unused ad-hoc alternate
writing API, simplifying the object database backend interface.

* ps/odb-alternates-at-creation:
  odb/source: remove the ability to write alternates
  builtin/clone: write alternates via `odb_create_on_disk()`
  odb/source: support writing alternates when creating the database
  builtin/clone: move setup of alternates for non-shared local clones
  builtin/clone: move setup of alternates for shared local clones
  builtin/clone: refactor handling of "--reference{,-if-able}"
  builtin/clone: move around `setup_reference()`
  builtin/clone: defer setup of the object database
  setup: split up concerns of `init_db()`
2026-09-21 10:03:58 -07:00
Johannes Schindelin c88341b7e1 test-read-midx: check midx_fill_entry() result
The `--show-objects` mode of `read_midx_file()` uses the output of
`midx_fill_entry()` without checking whether the lookup succeeded. A
failed lookup or unavailable pack can leave that output unusable,
allowing malformed or concurrently changed MIDX data to make this test
helper crash instead of reporting a controlled error.

Reject the entry unless `midx_fill_entry()` returns `MIDX_FILL_HIT`. The
unchecked call was introduced by 86d174b724
(t/helper/test-read-midx.c: add '--show-objects', 2021-03-30); later
incremental-MIDX changes expanded the possible failure modes, but this
remains a test-helper robustness issue, not a production Git attack
surface or an arbitrary-code-execution vulnerability.

It is unclear why Coverity reports this issue in Git for Windows only
after merging v2.56.0-rc0; The issue was not reported before.

Assisted-by: GPT-5.6 Luna
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-17 12:43:47 -07:00
Johannes Schindelin 237edbc58d oss-fuzz: handle reftable iterator initialization failures
The reftable fuzzer introduced by adf45165e6 (oss-fuzz: add fuzzer for
parsing reftables, 2026-07-03) ignored failures from
`reftable_table_init_ref_iterator()` and
`reftable_table_init_log_iterator()`. Coverity reported that under
allocation failure, either constructor can return
`REFTABLE_OUT_OF_MEMORY_ERROR` without installing an ops table, allowing
a subsequent seek to dereference NULL.

Treat iterator initialization failure as a reason to skip the
corresponding seek and iteration while retaining safe destruction for an
uninitialized iterator.

Assisted-by: GPT-5.6 Luna
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-17 12:43:47 -07:00
Johannes Schindelin 11ab0ca4e3 t/unit-tests: check reftable iterator initialization
Coverity pointed out that the
`test_reftable_table__seek_invalid_log_offset()` test, which was
introduced by a1c085df8d (reftable/table: fix NULL pointer access when
seeking to bogus offsets, 2026-07-03), ignores the result of
`reftable_table_init_log_iterator()` and proceeds to
`reftable_iterator_seek_log()`, although initialization can return
`REFTABLE_OUT_OF_MEMORY_ERROR` without installing an ops table. Under
allocation failure, the test then dereferences a NULL function table.

Assert successful iterator initialization before seeking.

Assisted-by: GPT-5.6 Luna
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-17 12:43:47 -07:00
Johannes Schindelin 742d8eb897 rerere: do not record failed conflict resolution data
`rerere` can mark a conflict variant as resolved even when writing its
preimage or postimage fails. A later invocation may then replay
incomplete data from the cache, turning a local filesystem failure into
an incorrect working-tree change.

629716d256 (rerere: do use multiple variants, 2015-07-30) introduced
the code paths without checks for those I/O results. Treat such failures
as failures, report them, and leave the rerere status unchanged unless
the corresponding data was recorded successfully.

The defect has been latent since 2015. Git for Windows' Coverity run
only reported it after merging v2.56.0-rc0, for reasons that could not
be figured out in a reasonable amount of time.

Assisted-by: GPT-5.6 Luna
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-17 12:43:46 -07:00
Johannes Schindelin c3a6be2333 midx: validate incremental MIDX pack IDs
Incremental MIDX support made object-offset pack IDs local to each layer
and then converted them to chain-global IDs by adding
`num_packs_in_base`. The conversion was introduced by 19419821ba
(midx: teach `nth_midxed_pack_int_id()` about incremental MIDXs,
2024-08-06). Chain-aware pack preparation followed in 1820bd878c
(midx: teach `prepare_midx_pack()` about incremental MIDXs, 2024-08-06),
but the final `midx_fill_entry()` lookup remained tied to the original
layer. Only with 8f909ff4e9 (packfile: recover when a multi-pack-index
names a removed pack, 2026-08-29) did Coverity point out this issue: a
local ID such as `UINT32_MAX` could wrap when the base-pack count was
added, producing a plausible but incorrect global ID. After
`prepare_midx_pack()` resolved the chain, `midx_fill_entry()` could then
underflow or address the wrong layer while indexing the current layer's
pack array, causing an invalid memory access and crashing Git.

Validate each local pack ID against its layer's pack count before adding
the base count, and obtain the final pack through `nth_midxed_pack()`,
which resolves the correct MIDX layer. This prevents an invalid local ID
from wrapping during conversion and ensures that the lookup uses the
layer identified by the resolved chain-global ID.

Assisted-by: GPT-5.6 Luna
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-17 12:43:46 -07:00
Johannes Schindelin 723dd6ca3e gpg-interface: make signature-prefix matching length-aware
After merging v2.56.0-rc0 into Git for Windows, its Coverity run
reported the following issue: The `parse_signed_buffer()` function
accepts object buffers with an explicit size, while
`get_format_by_sig()` uses `starts_with()`, i.e. it expects a
NUL-terminated buffer. A tag object with a non-NUL-terminated payload
ending in a partial signature prefix, such as a final '-' byte, could
therefore cause an invalid read past the object buffer.

The observable consequences are limited to reading past the allocation.
In practice it can crash Git if the read enters an unmapped page. It can
also misplace the payload/signature split, corrupting the compat-hash
object being written.

The older unbounded matcher predates this path, but c8762c30df
(object-file-convert: convert tag objects when writing, 2023-10-01)
exposed the defect by passing exact-sized converted tag buffers to
`parse_signed_buffer()`. That commit first shipped in v2.45.0, so the
defect has been latent in every release since.

This pattern was noticed on the mailing list in February 2024. Reviewing
a patch for a very similar issue in commit.c's find_header_mem(), Jeff
King observed in
https://lore.kernel.org/git/20240208214137.GB1090198@coredump.intra.peff.net/:

  But more interestingly: even though we pass a buf/len pair to
  parse_signed_buffer(), it then calls get_format_by_sig() which takes
  only a NUL-terminated string. [...] That raises the question of
  whether parse_signed_buffer() has a similar walk-too-far problem. ;)
  The answer is no, because we feed it from a strbuf. But it's not a
  great pattern overall.

That reasoning surveyed the callers that existed at the time and missed
c8762c30df (object-file-convert: convert tag objects when writing,
2023-10-01), which was four months old at that time, and does not feed
from a strbuf; `convert_tag_object()` hands `parse_signed_buffer()` an
exact-sized `xmalloc()` buffer, and the concern flagged and dismissed in
that thread is exactly the defect Coverity now reports.

Jeff went on to add `starts_with_mem()` a month later, in
https://lore.kernel.org/git/20240307092638.GK2080210@coredump.intra.peff.net/,
precisely for "cases where the buffer is not NUL-terminated (and we
instead have an explicit size or end pointer)", so the tool for this fix
has been in the tree since v2.45.0.

Even though the issue had been latent, it most likely surfaced via
Coverity because of 215d305f45 (odb: compute compat object ID in
`odb_write_object_ext()`, 2026-07-17), which moved
`convert_object_file()` out of the `source->write_object` function
pointer into a direct call in `odb_write_object_ext()`.

Preserve the existing NUL-terminated behavior for callers that provide
strings while making signature-prefix matching honor the known buffer
lengths, via the `starts_with_mem()` helper. This keeps reads within the
object data without implying exploitability beyond the observed invalid
read.

Assisted-by: GPT-5.6 Luna
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-17 12:43:46 -07:00
Johannes Schindelin 506a21b312 wrapper: guard writev_in_full() against signed overflow
As Git for Windows' Coverity run after merging v2.56.0-rc0 reported,
`writev_in_full()` keeps its cumulative successful output in an
`ssize_t`. Although `xwritev()` limits each individual write to a
syscall-sized amount, repeated successful writes can still exceed
`SSIZE_MAX`. The unchecked accumulation was introduced by d70eb7f360
(wrapper: introduce writev(3p) wrappers, 2026-08-07).

Treat an aggregate that would overflow the signed total as an I/O
failure.

Assisted-by: GPT-5.6 Luna
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-17 12:43:46 -07:00
Junio C Hamano d38352cd43 A few more fixes before -rc2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-17 09:48:17 -07:00
Junio C Hamano 3bbf43483e Merge branch 'yt/pathspec-negative-prefix'
The pathspec matching logic has been updated to avoid out-of-bounds
memory accesses when a negative pathspec is shorter than the common
prefix of positive pathspecs.

* yt/pathspec-negative-prefix:
  dir: preserve pathspec prefix optimization with leading excludes
  dir: do not apply prefix to negative pathspecs
2026-09-17 09:48:17 -07:00
Junio C Hamano 2a41443dc8 Merge branch 'tz/doc-pack-refs-and-refs-fixes'
Doc updates.

* tz/doc-pack-refs-and-refs-fixes:
  doc/refs: backtick-quote commands and options consistently
  doc/pack-refs: convert synopsis and options to new style
2026-09-17 09:48:17 -07:00
Yoichi NAKAYAMA 7b58375ab3 mailmap: normalize name for Yoichi NAKAYAMA
Normalize name formatting and map older formats to the canonical one.

Signed-off-by: Yoichi NAKAYAMA <yoichi.nakayama@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-17 09:43:13 -07:00