Commit Graph

82456 Commits (fa869359eeafa1369cd2ded0124301abfcb215d2)

Author SHA1 Message Date
Jon Simons fa869359ee t/perf: measure --force-with-lease in p5516
Extend p5516 with rows that push the same delete refspecs plus one
explicit --force-with-lease=<refname>:<expect> per refspec.

The new rows are used to demonstrate a speedup in a subsequent commit.

Numbers as of this commit
(`./p5516-push-delete-refspec.sh -r create,lease`):

  Test                        this tree
  -------------------------------------------
  5516.16: empty:lease:1      0.12(0.06+0.10)
  5516.19: empty:lease:10     0.17(0.10+0.10)
  5516.22: empty:lease:100    0.45(0.38+0.10)
  5516.25: mirror:lease:1     0.15(0.09+0.10)
  5516.28: mirror:lease:10    0.18(0.12+0.10)
  5516.31: mirror:lease:100   0.52(0.42+0.10)

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:37 -07:00
Jon Simons d2634888cc remote: use strmap for match_explicit_refs()
Optimize match_explicit_refs() by replacing two linear refs traversals
with strmap lookups.

Before this change, matching R explicit refspecs against N local refs
and M remote refs in match_explicit() entails O(R * N) and O(R * M)
calls to refname_match() for sources and destinations respectively.

After this change, we build a strmap for local refs O(N), a strmap for
remote refs O(M), and use them for O(R * rules) lookups of the refspecs.

Refspecs are resolved using count_refspec_match_in_map() introduced
earlier in the series, which issues one strmap lookup for each candidate
rules pattern generated with expand_ref_prefix().

The match_explicit_lhs_map() function introduced in a previous commit
has now been recombined into match_explicit_lhs(): all call sites are
now using the new strmap variation.

Timings show benefit where one or both of the client and remote have
many refs, and multiple refspecs are specified:

  Test                           HEAD~1            HEAD
  -----------------------------------------------------------------------
  5516.3: empty:refspecs:1       0.13(0.07+0.10)   0.14(0.07+0.10) +7.7%
  5516.5: empty:refspecs:10      0.17(0.10+0.11)   0.14(0.07+0.11) -17.6%
  5516.7: empty:refspecs:100     0.47(0.41+0.10)   0.15(0.08+0.10) -68.1%
  5516.9: mirror:refspecs:1      0.17(0.10+0.11)   0.17(0.10+0.11) +0.0%
  5516.11: mirror:refspecs:10    0.23(0.16+0.11)   0.17(0.10+0.11) -26.1%
  5516.13: mirror:refspecs:100   0.87(0.80+0.11)   0.18(0.11+0.11) -79.3%

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:37 -07:00
Jon Simons 31151e03ab remote: reject duplicate destinations on an empty remote
match_explicit_refs() passes the head of the remote ref list, 'dst',
to match_explicit() for every refspec.  match_explicit() searches that
list via count_refspec_match() and, when nothing matches, appends a
new destination through 'dst_tail'.

This works when the remote already has refs: 'dst' is non-NULL, so each
loop iteration walks from the same head and finds destinations linked
at the tail.

This fails when the remote is empty and 'dst' is NULL.  match_push_refs()
computes 'dst_tail' with tail_ref(), which for an empty list is the head
slot itself: so the first link writes through '*dst'.  But each loop
iteration still provides the original NULL to match_explicit(), with
the result that newly-linked destinations are not seen.

The behavior dates back to f88395ac23 (Renaming push., 2005-08-03),
where match_explicit_refs() searches the destination list from the
'dst' it was given while appending new destinations through 'dst_tail'.

Pass the remote refs head by pointer in match_explicit_refs() so that
each loop iteration re-reads '*dst' and detects a destination created
by an earlier refspec.

With this, failing tests in t5408, t5516 now pass and are toggled to
test_expect_success.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:37 -07:00
Jon Simons 97bf6f3552 t5408: expect client-side error for duplicate destinations
Update the error message expectation for the existing t5408 tests that
use send-pack to transmit duplicate updates to an empty remote, and
toggle them test_expect_failure.

The tests previously asserted the server-side rejection "multiple
updates for ref '<dst>' not allowed".

The next commit rejects these pushes on the client-side such that
send-pack fails earlier with "dst ref <dst> receives from more than
one src", and never reaches the server.  The tests are toggled to
test_expect_success then.

While here, change the test descriptions to note that they are no
longer asserting anything about the order of partial ref updates.

Also included is a fix for a missing "2>err" in the '--stdin refs
come after cmdline' test.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:37 -07:00
Jon Simons be48597343 t5408: check refspec order with distinct destinations
26be19ba8d (send-pack: take refspecs over stdin, 2014-08-21) added tests
to assert that send-pack sends command-line refspecs in the order given,
and those read with --stdin after them, by pushing to the same
destination twice, and seeing which update succeeded.

But since 9d2962a7c4 (receive-pack: use batched reference updates,
2025-05-19) such pushes to the same destination now fail completely on
the server-side with "multiple updates for ref '<dst>' not allowed",
and so the ordering is no longer being asserted.

Add two explicit tests to reinstate the ordering assertions.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:37 -07:00
Jon Simons 20a198a63b t5408, t5410: test duplicate updates without relying on the client
The existing t5408 tests that use send-pack to transmit duplicate
updates for the same destination happen to rely on the client not
recognizing the duplicates when the remote is empty.

As a result, they are the only push tests that exercise each of:

 - receive-pack rejection of multiple updates for the same ref, from
   9d2962a7c4 (receive-pack: use batched reference updates, 2025-05-19)

 - send-pack's receive_status() handling of a ref reported twice by the
   remote, from 77188b5bba (send-pack: fix memory leak around duplicate
   refs, 2025-05-19)

Add explicit tests for each of those paths, in preparation of an
upcoming commit that fixes the client to reject such pushes before
sending any update.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:37 -07:00
Jon Simons 732abd6821 t5516: test pushing two refspecs creating the same new branch
Pushing two refspecs that create the same new branch fails client-side
as desired with "dst ref <dst> receives from more than one src", as long
as the remote advertises at least one ref.

But pushing the same to an empty remote does not fail client-side as
expected: a --dry-run push prints "[new branch]" twice, and an actual
push fails on the server side with "multiple updates for ref '<dst>'
not allowed".

Add tests for both remotes, with and without --dry-run.  The empty repo
passes are marked as test_expect_failure, in preparation for a commit
that includes a fix and toggles them to test_expect_success.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:37 -07:00
Jon Simons 1d803681e1 remote: use strmap for check_push_refs()
Optimize check_push_refs() by replacing a linear traversal of all
local refs with strmap lookups.

Before this change, matching R explicit refspecs against N local refs
in check_push_refs() entails O(R * N) calls to refname_match().

After this change, we build a strmap of local refs O(N) and use it
for O(R * rules) lookups of the refspecs.

The new count_refspec_match_in_map() is equivalent to the previous
count_refspec_match():

 - count_refspec_match() for 'pattern' iterates every local ref,
   adding a match for each 'refname_match(pattern, refname)',
   which searches against the six ref_rev_parse_rules.

 - count_refspec_match_in_map() for 'pattern' generates the six
   possible matches with expand_ref_prefix(), and then issues
   one strmap lookup for each one.

match_explicit() still works on the ref list, so temporarily introduce
match_explicit_lhs_map() alongside match_explicit_lhs().  These two
functions are recombined in a subsequent commit that converts
match_explicit().

Timings show benefit for the case where the client has many local refs
and specifies multiple refspecs:

  Test                           HEAD~1            HEAD
  -----------------------------------------------------------------------
  5516.3: empty:refspecs:1       0.14(0.07+0.11)   0.13(0.07+0.10) -7.1%
  5516.5: empty:refspecs:10      0.16(0.10+0.10)   0.16(0.10+0.10) +0.0%
  5516.7: empty:refspecs:100     0.47(0.41+0.10)   0.47(0.41+0.10) +0.0%
  5516.9: mirror:refspecs:1      0.16(0.09+0.11)   0.16(0.10+0.11) +0.0%
  5516.11: mirror:refspecs:10    0.26(0.19+0.11)   0.22(0.16+0.11) -15.4%
  5516.13: mirror:refspecs:100   1.19(1.13+0.10)   0.82(0.75+0.11) -31.1%

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:36 -07:00
Jon Simons ac7a88513c refs: stop using mkpath() in refname_match()
refname_match() formats every ref_rev_parse_rules entry through mkpath()
to then strcmp() with its given full_name.  It turns out this formatting
function dominates the client-side cost of matching explicit refspecs
against a remote that advertises lots of refs.

Reuse match_parse_rule() instead to efficiently compare each rule
against its given full_name.  With this change we avoid mkpath()'s
strbuf_vaddf(), and each match is now a direct prefix + suffix
comparison, length check, and memcmp of the refname at hand.

Timings from the test added in the previous commit:

  Test                           HEAD~1            HEAD
  -----------------------------------------------------------------------
  5516.3: empty:refspecs:1       0.15(0.09+0.11)   0.14(0.07+0.11) -6.7%
  5516.5: empty:refspecs:10      0.38(0.32+0.11)   0.17(0.11+0.11) -55.3%
  5516.7: empty:refspecs:100     2.50(2.43+0.11)   0.49(0.42+0.11) -80.4%
  5516.9: mirror:refspecs:1      0.21(0.15+0.11)   0.16(0.09+0.11) -23.8%
  5516.11: mirror:refspecs:10    0.80(0.73+0.11)   0.26(0.19+0.11) -67.5%
  5516.13: mirror:refspecs:100   6.68(6.59+0.13)   1.18(1.11+0.11) -82.3%

Notes on a change in behavior:

 - mkpath() runs cleanup_path(), which strips leading "./".  So,
   "./refs/heads/foo" previously matched "refs/heads/foo" through the
   "%.*s" rule.  As of this commit, this is no longer true.

 - It's considered a bug that "./"-prefixed strings previously could
   have been matched with refnames in this way:

   - cleanup_path() dates back to 26c8a533af (Add "mkpath()" helper
     function, 2005-07-08), and is intended to be used for filepaths,
     not refnames.  The leading-"./" strip itself comes from f17a1b1bec
     (Fix up path-cleanup in git_path() properly, 2005-07-05).

   - refname_match() has used mkpath() in its matching loop since its
     inception with 79803322c1 (add refname_match(), 2007-11-11).

   - 6cd4a8982d (avoid using mksnpath for refs, 2017-03-28) previously
     removed other cleanup_path() spots reachable from mksnpath() and
     notes they were "questionable when dealing with refnames, as we
     could silently canonicalize a syntactically bogus refname into a
     valid one."

Tests in t5510 and t5516 that cover the aliasing behavior are toggled
to test_expect_success.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:36 -07:00
Jon Simons a4c803513e t/perf: add explicit delete refspec matching test
Add p5516 to measure the client-side cost of matching explicit
refspecs on 'git push' against a server that advertises many refs.

The server gets 100k branches, and two clients push 1, 10, 100 delete
refspecs each with --dry-run: an empty client (no local refs), which
isolates matching against the advertised refs, and a mirror client
(full local copy of server refs), to exercise matching against the
same number of local refs.  Delete refspecs and --dry-run are used
to avoid any object transfer or ref update activity in the measurement
and leave the scratch repos unmodified, such that each repetition does
the same amount of matching work.

The test is used to demonstrate speedups in subsequent commits.
Baseline numbers on my machine:

  Test                           this tree
  ----------------------------------------------
  5516.3: empty:refspecs:1       0.14(0.08+0.10)
  5516.5: empty:refspecs:10      0.38(0.32+0.10)
  5516.7: empty:refspecs:100     2.50(2.44+0.10)
  5516.9: mirror:refspecs:1      0.21(0.14+0.11)
  5516.11: mirror:refspecs:10    0.80(0.73+0.11)
  5516.13: mirror:refspecs:100   6.85(6.78+0.12)

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:36 -07:00
Jon Simons 51622104c1 t5510: document fetch with "./"-prefixed branch.<name>.merge
refname_match() formats each candidate through mkpath(), which strips
a leading "./", so a branch.<name>.merge value of "./refs/heads/main"
matches "refs/heads/main" in both places that fetch compares them:

 - branch_merge_matches() when marking fetched refs for merge
   in FETCH_HEAD

 - find_ref_by_name_abbrev() when the merge source is not covered by the
   fetch refspec and is looked up amongst the remote advertised refs

Only a hand-edited config reaches these paths: clone, branch
--set-upstream-to, fetch --set-upstream, and push -u write only names
that have passed check_refname_format(), which rejects a leading "./".

Add two fetch tests asserting that such a "./"-prefixed value does not
match for these cases.  Both are test_expect_failure because the name
matches today:

 - The default fetch refspec should not match "./refs/heads/main"
   with fetched "refs/heads/main" and mark the ref for merge.

 - A protocol v0 fetch with refspec that omits "refs/heads/main"
   should not match "./refs/heads/main" against the remote
   advertised "refs/heads/main".

An upcoming commit stops using mkpath() in refname_match(), at which
point the tests are toggled to test_expect_success.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:36 -07:00
Jon Simons 58654f1bdf t5516: demonstrate push with "./"-prefixed source
'git push <repo> ./refs/heads/main:refs/heads/frotz' succeeds today
and pushes refs/heads/main, although "./refs/heads/main" is not a
valid refname.  count_refspec_match() compares the source to each
local ref using refname_match(), which formats its given name with
mkpath(), whose cleanup_path() strips leading "./".

Add a test_expect_failure asserting that such a source is rejected
with "src refspec ./refs/heads/main does not match any".  An upcoming
commit stops using mkpath() in refname_match(), at which point the
test is toggled to test_expect_success.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:36 -07:00
Jon Simons 8c0a538b5f remote: validate --force-with-lease <refname> argument
Use check_refname_format() to validate the <refname> component of
'git push --force-with-lease=<refname>[:<expect>]'.

apply_push_cas() will silently ignore a lease entry that does not match
any remote ref.  And today "./refs/heads/main" will happen to be matched
with "refs/heads/main" due to refname_match() usage of mkpath(), whose
cleanup_path() strips leading "./".

An upcoming commit removes mkpath() from refname_match(), after which
there is no unintentional match in this situation, so that the lease
is ignored instead of applied.  Reject an invalid refname now to make
this situation fail fast both before and after that change.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-10 16:32:36 -07:00
Junio C Hamano 6de20f6092 The 4th batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-06 10:13:32 -07:00
Junio C Hamano c679abf7d2 Merge branch 'as/push-force-if-includes-no-reflog'
The timestamp used for checking the reflog of a remote-tracking
branch during 'git push --force-if-includes' was left uninitialized
when the reflog was completely empty, which has been corrected.

* as/push-force-if-includes-no-reflog:
  push: fix --force-if-includes when remote-tracking ref has no reflog
2026-10-06 10:13:31 -07:00
Junio C Hamano 38d6f3b3fd Merge branch 'js/p5551-fetch-rescan-fix'
The performance test for `git fetch` pack-dir rescans has been
updated to use the `--no-deref` option when cleaning up
remote-tracking branches.  This prevents `git update-ref` from
failing with a multiple updates error when both a symref and its
target are deleted in the same transaction.

* js/p5551-fetch-rescan-fix:
  p5551: fix repeated runs with update-ref --no-deref
2026-10-06 10:13:31 -07:00
Junio C Hamano 1bed40ea8c Merge branch 'jk/http-curl-strip-creds'
The HTTP transport has been updated to handle changes in recent curl
versions that strip credentials from the effective URL, preventing
unnecessary credential prompts during redirects.

* jk/http-curl-strip-creds:
  http: handle curl stripping creds from effective url
2026-10-06 10:13:31 -07:00
Junio C Hamano 0c53db4bcb Merge branch 'kz/doc-add-rm-typofix'
Typofixes.

* kz/doc-add-rm-typofix:
  doc: remove unnecessary commas in git-add and git-rm documentation
2026-10-06 10:13:31 -07:00
Junio C Hamano 5308423996 Merge branch 'jk/merge-ll-tempfile-cleanup'
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
2026-10-06 10:13:31 -07:00
Junio C Hamano 76514ee87b Merge branch 'js/gitlab-ci-windows-rust'
The Windows GitLab CI job has been updated to provision and use the
GCC-targeting Rust toolchain for MinGW builds, fixing job failures
caused by incomplete Rust setup and missing linker support.

* js/gitlab-ci-windows-rust:
  ci(gitlab,windows): provide GNU Rust's host-linker support
  ci(gitlab,windows): fix Rust setup for GitLab's MinGW build
  ci(gitlab,windows): preserve exclusions during dependency setup
  ci(gitlab,windows): provision GNU Rust for SDK-based MinGW builds
2026-10-06 10:13:31 -07:00
Junio C Hamano 5a7d1e8045 The 3rd batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-05 13:52:30 -07:00
Junio C Hamano 8fff639433 Merge branch 'jk/name-rev-update-hash-descriptions'
The documentation for 'git-name-rev' has been updated to refer to
object IDs instead of SHA-1, to more accurately reflect that the
active hash algorithm is used.

* jk/name-rev-update-hash-descriptions:
  name-rev: update hash descriptions
2026-10-05 13:52:30 -07:00
Junio C Hamano 9ac1e81458 Merge branch 'jk/parse-revision-opt-fixes'
The command-line parsing of revision options has been updated to
properly distinguish between malformed and unknown options, and to
correctly report the name of unknown options after they have been
moved during the option parsing process.

* jk/parse-revision-opt-fixes:
  revision: handle argv movement in parse_revision_opt()
  revision: avoid reporting known options as unknown on error
2026-10-05 13:52:29 -07:00
Junio C Hamano 053d5d2365 Merge branch 'rs/dir-skip-nested-repo-fix'
The directory traversal logic has been updated to correctly evaluate
pathspecs for ignored directories containing nested repositories,
and has been fortified to gracefully handle null pathspecs during
checkout operations.

* rs/dir-skip-nested-repo-fix:
  dir: skip excluded directory with nested repo on prefix match
2026-10-05 13:52:29 -07:00
Junio C Hamano 075eedb150 Merge branch 'je/doc-asciidoc-xrefs'
Various documentation files have been updated to use explicit
'<<TARGET,TARGET>>' AsciiDoc cross-references instead of plain text
references.  This improves rendering on the web and avoids broken
links when manual pages are included into other pages.

* je/doc-asciidoc-xrefs:
  doc: add more AsciiDoc cross-references
2026-10-05 13:52:29 -07:00
Junio C Hamano 0f1778a8d5 Merge branch 'yn/worktree-repair-completion'
The command-line completion script (in 'contrib/') has been taught
to complete the 'repair' subcommand for 'git worktree'.

* yn/worktree-repair-completion:
  completion: complete 'git worktree repair'
2026-10-05 13:52:29 -07:00
Junio C Hamano 8983b6ac7a Merge branch 'kn/ci-unit-tests-on-windows-fix'
The CI script has been updated to check for one-indexed slice numbers
when deciding to run unit tests on Windows, mirroring the behaviour in
the modern GitHub and GitLab workflows.

* kn/ci-unit-tests-on-windows-fix:
  ci: fix unit tests not running on windows
2026-10-05 13:52:29 -07:00
Junio C Hamano 0d1374ead3 Merge branch 'ps/reflog-expiry-fix'
The default expiry periods for both reachable and unreachable reflog
entries have been corrected from a past regression that swapped
them.

* ps/reflog-expiry-fix:
  reflog: fix default expiry periods
2026-10-05 13:52:28 -07:00
Junio C Hamano 3906479d13 Merge branch 'js/ci-debian-12-http2-workaround'
The Debian 12 CI job has been updated to skip a half-auth clone test
that occasionally fails due to a bug in the packaged curl version
handling early HTTP/2 responses.

* js/ci-debian-12-http2-workaround:
  ci: work around Debian 12's HTTP/2 authentication failures
2026-10-05 13:52:28 -07:00
Junio C Hamano d2bda356b7 Merge branch 'jt/object-file-batch-fsync-fix'
When 'core.fsyncMethod' is set to 'batch', the ODB transaction
failed to properly flush large blob packfiles residing in the
temporary directory before migrating the directory's contents to the
main object store.  The execution sequence has been corrected by
performing the packfile flush before the temporary directory
migration, averting failure.

* jt/object-file-batch-fsync-fix:
  object-file: flush transaction packfile before migrating objects
  object-file: lift ODB reprepare out of packfile flush
2026-10-05 13:52:28 -07:00
Junio C Hamano cfbffcd204 Merge branch 'tb/rerere-lock-grace'
The sequencer machinery (used by 'git rebase', 'git cherry-pick', and
'git revert') has been updated to defer automatic maintenance tasks
until the end of the operation, preventing nested 'git commit', 'git
merge', and 'exec' commands from triggering GC operations that could
contend for locks or delete open packs while the sequence is in
progress.

* tb/rerere-lock-grace:
  sequencer: disable auto maintenance in spawned commands
  rebase, cherry-pick, revert: run auto maintenance when done
  config: add git_config_append_parameter()
2026-10-05 13:52:28 -07:00
Junio C Hamano de66ba8633 Merge branch 'yt/winansi-die-lasterr-fix'
The error reporting machinery in the WinANSI compatibility layer has
been simplified to pass the exact Windows error code and correctly
format arguments for fatal errors.

* yt/winansi-die-lasterr-fix:
  compat/winansi: fix die_lasterr() argument formatting
2026-10-05 13:52:28 -07:00
Junio C Hamano 8103b44651 The 2nd batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-03 21:45:55 -07:00
Junio C Hamano f85fa0c567 Merge branch 'jk/pull-null-merge-head'
'git pull' has been taught to fail more gracefully instead of
segfaulting when lookup_commit_reference() fails on unparseable
objects.

* jk/pull-null-merge-head:
  pull: avoid segfault when commit lookup fails
2026-10-03 21:45:55 -07:00
Junio C Hamano 6c698d827d Merge branch 'hd/diff-no-index-reverse-fix'
A bug in git diff --no-index that mishandled reverse (-R) output
when conflicts existed between a file and a directory has been
fixed.

* hd/diff-no-index-reverse-fix:
  diff --no-index: fix -R with file/directory conflicts
2026-10-03 21:45:55 -07:00
Junio C Hamano 8bc9c7fcfd Merge branch 'js/coverity-fixes'
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-10-03 21:45:55 -07:00
Junio C Hamano 2fd3d524ea Merge branch 'rr/upload-pack-swap-shallow-wanted-ref'
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-10-03 21:45:55 -07:00
Junio C Hamano 61bd247fa1 Merge branch 'of/commit-reach-repo-awareness'
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-10-03 21:45:54 -07:00
Junio C Hamano 30cc6c91b6 Merge branch 'sg/precompile-git-compat-util'
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-10-03 21:45:54 -07:00
Junio C Hamano c46c1e3772 Start Git 2.98 cycle
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-10-01 11:28:16 -07:00
Junio C Hamano d1f22bfaec Merge branch 'dk/use-nsec-runtime'
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-10-01 11:26:41 -07:00
Junio C Hamano 2f28db44d5 Merge branch 'ps/ref-storage-format'
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-10-01 11:26:40 -07:00
Junio C Hamano 6b204dc724 Merge branch 'ak/refs-files-root-ref-lock'
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-10-01 11:26:40 -07:00
Junio C Hamano d08565d2c6 Merge branch 'jc/cocci-free-updates'
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-10-01 11:26:40 -07:00
Junio C Hamano 875fa34e94 Merge branch 'kn/receive-report-hook'
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-10-01 11:26:39 -07:00
Junio C Hamano 5cfa270bc4 Merge branch 'hn/history-squash'
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-10-01 11:26:39 -07:00
Junio C Hamano 106bdd26a0 Merge branch 'ps/odb-alternates-at-creation'
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-10-01 11:26:39 -07:00
Khan Zimov e638de60bc doc: remove unnecessary commas in git-add and git-rm documentation
Signed-off-by: Khan Zimov <kaliugov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-29 16:25:01 -07:00
Aleksei Sviridkin c84ed3a0ab push: fix --force-if-includes when remote-tracking ref has no reflog
Since 99a1f9ae10 (push: add reflog check for "--force-if-includes",
2020-10-03), is_reachable_in_reflog() looks for the remote tip in the
local branch's reflog and stops at entries older than the newest entry
of the remote-tracking ref's reflog. That timestamp comes from a
callback of refs_for_each_reflog_ent_reverse(), which never runs when
the remote-tracking ref has no reflog, so the variable stays
uninitialized.

With the files backend a remote-tracking ref that "git clone" created
has no reflog until it moves. On my machine the leftover value exceeded
any real timestamp, so the walk stopped at the first entry and the push
was rejected with "remote ref updated since checkout" though nothing on
the remote had changed.

That stopping point assumes an entry older than the last recorded move
of the remote-tracking ref cannot be the one we want. The record itself
can be missing: never written, deleted, or expired by gc. Initialize
the timestamp to zero for a missing record. timestamp_t is unsigned, so
nothing compares older and the walk stops only at the remote tip or at
the end of the local reflog. "Now" brings the bug straight back. A
fixed age narrows it: the push is rejected when the remote tip is
recorded only past the first entry older than that age and nothing
collected reaches it.

When the remote tip is not in the local reflog at all, a stopped walk
and a full one fall back to the same merge-base check, and the full one
hands it more entries.

Signed-off-by: Aleksei Sviridkin <f@lex.la>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-29 09:52:12 -07:00
Jeff King 5efbff499c merge-ll: use tempfile API for external driver files
When there's a long(er) running merge driver helper, the user may just
decide to terminate it with Ctrl+C. That sends a signal to the driver
program and to the whole process group as well, including the git merge
command proper. Hence the cleanup code would not run and .merge_file_*
files are left behind.

We can fix this by using the tempfile API, which auto-cleans files on
signal or other error. That covers the Ctrl+C case above, as well as any
other incidental death (e.g., allocation error due to a gigantic
output).

Note that there is one gotcha here. The current code uses short,
relative filenames for the tempfiles (like ".merge_file_abc123"). But
the tempfile API stores and returns absolute paths. Because we run the
merge driver as a shell command, this can result in problems if the
leading directories contain shell metacharacters (like our tests, which
put a space in the trash directory name for exactly this purpose).

If we were starting from scratch, I'd say the correct solution here is
to shell-quote the filenames we put in the command. But doing so isn't
strictly backwards compatible, because users might have their own shell
characters. For example, if I configure a driver like this:

  [merge "foo"]
  driver = "my-driver '%O' '%A' '%B'"

then adding extra quoting will screw things up! Strictly speaking, this
kind of quoting is wrong (it would fail if %A expanded to something with
a single-quote in it), but it is entirely harmless with the current
vanilla relative paths. It doesn't seem worth breaking it.

So let's take the most conservative route, and just continue reporting
the relative paths.

Reported-by: Jean Delvare <jdelvare@suse.de>
Reported-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-09-29 09:31:38 -07:00