Repository navigation
Tags
Tags
tree-walk: preserve large entry path lengths From: Alessio Attilio <attilio.alessio@protonmail.com> The tree buffer uses size_t, but decoded entry lengths were still stored in unsigned int and int. A large path could therefore be truncated before tree walkers reached it. Keep the decoded length as size_t so walkers can reject oversized index paths correctly. Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com> Submitted-As: https://lore.kernel.org/git/pull.2514.git.git.1796150994354.gitgitgadget@gmail.com
status: report when submodule URLs are out of sync When a submodule URL changes in .gitmodules, the URL cached in the superproject's .git/config can remain stale. This change makes git status report the mismatch and suggest git submodule sync. Relative URLs are resolved as git submodule sync resolves them. For populated submodules, the check follows the remote that git submodule sync would update. Local remote customizations are respected so the advice does not suggest overwriting them. The warning is written to standard error for long, short, and porcelain formats, follows pathspecs, and is suppressed by --ignore-submodules=all. Closes #565 Alessio Attilio (4): submodule: share repository-aware URL resolution status: warn about submodule URL mismatches status: preserve customized submodule remotes status: test submodule URL warnings Documentation/git-status.adoc | 12 +++ builtin/commit.c | 1 + builtin/submodule--helper.c | 60 ++------------- submodule.c | 45 +++++++++++ submodule.h | 12 +++ t/t7508-status.sh | 121 ++++++++++++++++++++++++++++++ wt-status.c | 136 ++++++++++++++++++++++++++++++++++ wt-status.h | 1 + 8 files changed, 335 insertions(+), 53 deletions(-) base-commit: 566b699 Submitted-As: https://lore.kernel.org/git/pull.2509.v5.git.git.1796159338.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2509.git.git.1795774880142.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2509.v2.git.git.1795796162.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2509.v3.git.git.1795814853.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2509.v4.git.git.1795884822.gitgitgadget@gmail.com
status: base the "results were cached" remark on the untracked cache From: Xing Xin <xingxin.xx@bytedance.com> Since ecbc23e (status: modernize git-status "slow untracked files" advice, 2022-11-30), the advice that "git status" gives when enumerating untracked files takes more than 2 seconds adds "but the results were cached, and subsequent runs may be faster" whenever core.fsmonitor is enabled. But it is the untracked cache that caches these results, with or without fsmonitor: - Without the untracked cache, which is off by default, every run enumerates all untracked files again, however fsmonitor is configured, and the promised speedup never comes. - With it, subsequent runs only read the directories that changed, which they find by checking the stat data of all directories, or, with fsmonitor, by asking it. In the Linux kernel repository, on an Apple M4 Pro, enumerating the untracked files takes 305ms when the untracked cache is created, then 17ms with the untracked cache alone, 9ms with fsmonitor as well, and still 313ms with fsmonitor alone. The documentation that ecbc23e added says as much: "While the FSMonitor feature can be enabled without the untracked cache, the benefits are greatly reduced in that case." But the code checks only core.fsmonitor. Give the remark when the untracked cache was used to enumerate the untracked files, whether fsmonitor is enabled or not. Checking core.untrackedCache instead would not be accurate either: the untracked cache is enabled but not used with "--ignored" or a pathspec, and with core.untrackedCache set to "keep", its default, the untracked cache is used if the index already has one. So record in struct wt_status whether dir.untracked is set after fill_directory(), as read_directory() resets it when it cannot use the untracked cache. Signed-off-by: Xing Xin <xingxin.xx@bytedance.com> Submitted-As: https://lore.kernel.org/git/pull.2345.git.1796112069353.gitgitgadget@gmail.com
rebase: support --whitespace=fix with --interactive The apply backend implements --whitespace=fix through git apply, which prevents users from combining it with interactive rebases and other merge-backend features. Teach merge replay to compare whitespace-normalized records, then fix only lines introduced by replay using the path's whitespace rules. Keep other whitespace actions on the apply backend. Tests cover interactive replay, attributes, existing whitespace, added files, end-of-file handling, and unsupported actions. Closes #1472 Alessio Attilio (4): xdiff: support transformed records in merge matching merge-ort: fix whitespace in replayed changes rebase: route whitespace fixes through the selected backend rebase: test whitespace fixes with the merge backend Documentation/git-rebase.adoc | 6 +- builtin/rebase.c | 55 +++++++- contrib/completion/git-completion.bash | 2 +- merge-ll.c | 182 ++++++++++++++++++++++++- merge-ll.h | 5 + merge-ort.c | 52 +++++++ merge-ort.h | 1 + t/t3417-rebase-whitespace-fix.sh | 163 ++++++++++++++++++++++ t/t3422-rebase-incompatible-options.sh | 17 ++- xdiff/xdiff.h | 4 + xdiff/xmerge.c | 16 +-- xdiff/xprepare.c | 57 ++++++-- xdiff/xtypes.h | 2 + xdiff/xutils.c | 14 ++ xdiff/xutils.h | 2 + 15 files changed, 547 insertions(+), 31 deletions(-) base-commit: acba8bf Submitted-As: https://lore.kernel.org/git/pull.2511.git.git.1795996885.gitgitgadget@gmail.com
fetch: avoid fetching every branch of a new remote in a shallow repo
In a shallow single-branch clone of a large repository, git remote add
upstream <url> sets up the default +refs/heads/*:refs/remotes/upstream/*
refspec. The next git fetch upstream then downloads every branch of that
remote, which defeats the point of a shallow clone.
This series lets a remote fetch only the branches that local branches track:
git remote add --limited-fetch upstream <url>
git fetch upstream main
git branch --set-upstream-to=upstream/main
git fetch upstream # fetches only main from now on
What to fetch and where to store it are separate settings.
remote.<name>.fetchUpstreams says what to fetch, and
remote.<name>.fetchRefmap says where it is stored. --limited-fetch sets
both:
[remote "upstream"]
url = <url>
fetchRefmap = +refs/heads/*:refs/remotes/upstream/*
fetchUpstreams = true
remote.<name>.fetchRefmap is the configured default for --refmap, the same
way remote.<name>.fetch is the default for the refspecs on the command line.
The command line overrides the configuration, and at the same level a
refspec's own destination wins over the refmap:
* A refspec <src>:<dst> with non-empty <dst> on the command line is stored
at <dst> only, with --refmap or with fetchRefmap.
* A non-empty destination in remote.<name>.fetch is stored only there when
the refmap comes from fetchRefmap.
* --refmap on the command line replaces the destinations in
remote.<name>.fetch. It now also works without refspecs on the command
line, as long as the remote has something configured to fetch.
A refspec with an empty <dst>, which is what a bare <src> means, is stored
through the refmap. So this stores three branches under refs/remotes/cabal/:
[remote "cabal"]
url = <url>
fetch = master
fetch = next
fetch = seen
fetchRefmap = +refs/heads/*:refs/remotes/cabal/*
In a shallow repository, git remote add turns --limited-fetch on by default.
Design notes:
* A *@{upstream} entry in remote.<name>.fetch was considered for saying
what to fetch. Released versions of Git die with "invalid refspec" on it,
so a separate setting is used.
* The opportunistic update through remote.<name>.fetch is unchanged. On an
ordinary remote git fetch origin side:refs/heads/tmp still updates
origin/side. On a remote that only has a fetchRefmap it stores only
refs/heads/tmp.
* Tags are followed when a fetch without command-line refspecs ends up
storing refs, through a destination or through a refmap. --refmap="" and
a refmap entry without a destination store nothing and follow no tags.
* With --prefetch the refmap's destinations move under refs/prefetch/ like
those in remote.<name>.fetch, and an empty refmap stays empty.
* --prune only acts on destinations written in refspecs. With --refmap and
no command-line refspecs it leaves the destinations in
remote.<name>.fetch alone, and destinations that come from a refmap are
not pruned.
Changes in v17:
* A refmap entry without a destination, such as --refmap=refs/heads/main or
--refmap=refs/heads/main:, no longer makes the fetch follow tags. Such
entries are skipped, and the test now covers them together with
--refmap="".
* --prefetch no longer drops an empty --refmap or an empty fetchRefmap, so
git fetch --prefetch --refmap= <remote> stores nothing again.
* A fetch for a remote without a refmap no longer copies its unmapped refs
for nothing.
Changes in v16:
* Tags are now followed when a fetch without command-line refspecs stores
refs through --refmap or fetchRefmap. --refmap="" stores nothing and no
longer follows tags.
* --refmap without command-line refspecs is rejected again when the remote
has nothing configured to fetch, as with a bare URL.
* --prune with --refmap and no command-line refspecs no longer prunes under
the destinations in remote.<name>.fetch.
* The --refmap docs and the first commit message now say that a refspec
with non-empty <dst> is not mapped, and that commit message says "a later
commit".
Changes in v15:
* Added remote.<name>.fetchUpstreams to say explicitly that the upstreams
of local branches are fetched, in addition to remote.<name>.fetch. A
fetchRefmap alone no longer changes what is fetched.
* A refspec with its own destination on the command line is no longer
mapped through --refmap or fetchRefmap. This is a new first patch. A
destination in remote.<name>.fetch is no longer mapped through
fetchRefmap either.
* --refmap now works without refspecs on the command line. This is a new
second patch. It stores what remote.<name>.fetch fetches through the
given refmap, and it overrides fetchRefmap.
* Fixed git pull merging every tracked branch into the current one.
* git remote add --limited-fetch now sets both fetchRefmap and
fetchUpstreams.
* Fixed a leftover remote.<name>.refmap in the --refmap docs.
* Tests share helpers for repeated setup and checks, drop two steps that
other tests cover, and the "does not fetch it twice" test now checks
FETCH_HEAD.
Changes in v14:
* Squashed the @{push} fix into "fetch: infer branches to fetch from a
refmap-only remote", so the series no longer adds the bug in one patch
and fixes it in a later one
* Moved its test to t5586 using the refmap-only remote, so it no longer
depends on --limited-fetch
* Dropped the separate "remote: resolve @{push} through
remote..fetchRefmap" commit
Changes in v13:
* Added a new commit so @{push} resolves correctly for a --limited-fetch
remote, falling back to remote.<name>.fetchRefmap the same way fetch
already does when remote.<name>.fetch doesn't cover the branch being
pushed.
* Added a regression test to fetch: add remote.<name>.fetchRefmap covering
a remote.<name>.fetch entry with an explicit destination, confirming it's
stored in both that destination and the refmap's.
Changes in v12:
* Renamed remote.<name>.refmap to remote.<name>.fetchRefmap throughout
code, docs, and tests, so it reads unambiguously as fetch-only.
* Added the missing code path in get_ref_map() so a branch fetched by name
via remote.<name>.fetch is also stored through remote.<name>.fetchRefmap,
with a new test (the "cabal" example: fetch = master/next/seen plus a
refmap storing them all under one namespace).
* Reworded the fetchRefmap commit message and doc entry to drop a redundant
sentence, fix a confusing paragraph, and spell out that
remote.<name>.fetch, when configured, still decides what's fetched while
the refmap only remaps it.
* Added a prefetch coverage test to t5586-fetch-refmap.sh.
Changes in v11:
* remote_find_tracking() now falls back to remote.<name>.refmap when
remote.<name>.fetch doesn't match. Negative refspecs in fetch still
exclude refs, and both cases have tests
* The helpers write straight into a strvec, take the output parameter last
and the remote as const
* The followRemoteHEAD lookup is done once, not duplicated in two branches
* Clearer commit messages and docs: a working example plus a reference to
49ca2fb, the goal stated first, an incorrect "used to die" claim
dropped, and an explanation of why a refmap turns on the inference
* use_limited_fetch is a bool
Changes in v10:
* Resolve merge conflict after master integrated
ch/fetch-followremotehead-lazy-validation.
Changes in v9:
* Moved the do_fetch() if/else-if/else split out of the preliminary
helper-extraction commit and into the refmap-inference commit that needs
it. Preliminary commit is now a simpler refactor.
Changes in v8:
* Split into a preliminary collect_upstream_from_remote() helper commit
plus a simplified refmap-inference commit.
* Fixed a regression that could drop the current branch's @{upstream} when
remote.<name>.fetch was narrowed.
* Threaded struct repository * through instead of hardcoding
the_repository.
* Minor naming and comment cleanups.
Changes in v7:
* Fixed fatal: --refmap option is only meaningful with command-line
refspec(s) firing just from configuring remote.<name>.refmap alone, with
nothing else to fetch.
* When both remote.<name>.fetch and remote.<name>.refmap are configured, a
refspec-less fetch follows .fetch as usual, .refmap only remaps something
already being fetched by name. Added tests.
Changes in v6:
* Remove leftover reference to deleted default-branch logic in commit
message.
Changes in v5:
* Renumber test file from t5585 to t5586.
Changes in v4:
* Removed the automatic default-branch fetch. A fresh remote fetches
nothing until you track a branch explicitly.
* Fixed fetch report showing "new ref HEAD" instead of "new branch "
* Reworded remote..refmap docs and commit message.
Changes in v3:
* Replace the special ":"/"+:" fetch refspec with remote.<name>.refmap,
reusing git's existing --refmap mechanism instead of inventing new
refspec syntax.
* Split the change into 4 commits.
Changes in v2:
* Replaced the opt-in fetch.shallow config entirely with a new special
fetch refspec (+:) that git remote add now defaults new remotes to in a
shallow repository. The new refspec fetches whichever branches any local
branch tracks at that remote, plus the remote's default branch.
Harald Nordgren (7):
fetch: do not apply --refmap to a refspec with a destination
fetch: let --refmap apply to configured refspecs
fetch: add remote.<name>.fetchRefmap
fetch: extract collect_upstream_from_remote() helper
fetch: add remote.<name>.fetchUpstreams
remote: add "git remote add --limited-fetch"
remote: default to --limited-fetch in a shallow repository
Documentation/config/remote.adoc | 17 +++
Documentation/fetch-options.adoc | 12 +-
Documentation/git-remote.adoc | 15 +-
builtin/fetch.c | 174 +++++++++++++++------
builtin/remote.c | 34 ++++-
remote.c | 64 +++++++-
remote.h | 26 ++++
t/meson.build | 1 +
t/t5505-remote.sh | 77 ++++++++++
t/t5510-fetch.sh | 253 ++++++++++++++++++++++++++++++-
t/t5586-fetch-refmap.sh | 183 ++++++++++++++++++++++
11 files changed, 802 insertions(+), 54 deletions(-)
create mode 100755 t/t5586-fetch-refmap.sh
base-commit: 86e79b2
Submitted-As: https://lore.kernel.org/git/pull.2412.v17.git.git.1796046376.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.git.git.1789829246437.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v2.git.git.1790195720941.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v3.git.git.1790333402.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v4.git.git.1790673598.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v5.git.git.1790925198.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v6.git.git.1791102684.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v7.git.git.1791410164.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v8.git.git.1791619334.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v9.git.git.1791961452.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v10.git.git.1792503778.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v11.git.git.1792959921.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v12.git.git.1793103884.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v13.git.git.1793357550.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v14.git.git.1794681496.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v15.git.git.1795348644.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2412.v16.git.git.1795633584.gitgitgadget@gmail.com
delta-islands: revisit trees with new delta marks From: Derrick Stolee <stolee@gmail.com> When exploring the object graph to group objects into delta-islands, some trees and blobs can be visited from one path and then revisited later from another. If those two visits come from objects with different delta marks, then the final mark of the visited object should be the union of those marks. Instead, some cases only have the first marks as we don't reprocess objects marked with SEEN. This gets worse for objects recursively reachable from that object. This change includes some test cases that demonstrate this problem, and several of the modes fail without the accompanying code change. These examples were discovered while working with the --path-walk option as integrated with delta islands in 7e6de2a (pack-objects: support `--delta-islands` with `--path-walk`, 2026-06-21), but that option only exposed an existing failure within the marking algorithm. At least one of the new tests exposes a failure without --path-walk. The issue is not just about different path names, but about appearing at paths of different depth. For example, a tree appearing at a/b/ can be visited with one set of marks as supplied from the trees at a/ while later being seen at x/y/z/ with different marks supplied by objects at x/y/. To fix this issue, we need to potentially reprocess a tree and everything it can reach when we discover an update to the delta island marks. This can lead to massive recomputation with certain data shapes that revisit objects from different paths. This seems unlikely to happen often in realistic scenarios, but is unavoidable without topologically sorting the entire object graph before distributing marks. Concretely, update set_island_marks() to report whether the object gained any bits in the process. Use a depth-priority queue to revisit trees that have new marks. We need to be careful to avoid adding duplicates to the queue without replicating the SEEN bit. This depth heuristic is only to prioritize a breadth-first-search, handling root trees before the next set of trees, and so on. This is intended to maximize the possibility of seeing all links to an object before visiting that object. The first-seen-depth problem was identified during the original delta-island review [1]: SEEN prevents revisiting shared trees, so their recorded depths need not give a topological ordering. That discussion illustrated missed delta opportunities. Incomplete marks can also allow unwanted cross-island deltas, as acknowledged for a related root-depth bug in 3949053 (pack-objects: fix off-by-one in delta-island tree-depth computation, 2018-11-20) [2]. Later discussion emphasized real fork-network results and the difficulty of constructing focused corner-case tests [3]. [1] https://lore.kernel.org/git/20180727130229.GB18599@sigill.intra.peff.net/ [2] https://lore.kernel.org/git/20181120095053.GC22742@sigill.intra.peff.net/ [3] https://lore.kernel.org/git/20181120113423.GA29319@sigill.intra.peff.net/ Using p5305's historical-fork island selection, with --no-path-walk, bitmap reads disabled, --window=0, --compression=0, and stored deltas reusable, gives these old-to-fixed command times and tree visits: Time (s) Tree visits git/git 8.08 -> 8.24 162,791 -> 162,795 nodejs/node 9.85 -> 10.14 238,723 -> 239,837 microsoft/fluentui 4.13 -> 4.24 287,056 -> 287,136 torvalds/linux 176.28 -> 170.73 6,888,020 -> 6,888,085 It's possible that a true integration of delta islands with path-walk would help here, having the path-walk API compute the delta island marks as we traverse objects in path-based groups. Such an implementation would need to allow for objects to be readded to groups when their delta marks are updated while avoiding multiple emissions of the object from the API. Such a large rework of the delta island computation is avoided for now, as we can reproduce the error with the existing implementation. Assisted-by: GPT-6.1 Sol Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Submitted-As: https://lore.kernel.org/git/pull.2343.git.1796066735611.gitgitgadget@gmail.com
tree-walk: reject tree entries whose name length overflows an int From: Kristofer Karlsson <krka@spotify.com> The EXPENSIVE tests 13-15 in t1600 have been failing in CI on all 64-bit platforms since 53d5cfc (tree-walk: use size_t for the size of tree buffers, 2026-10-30) was merged: -fatal: index entry path is too long (4294967298 bytes) +fatal: malformed mode in tree entry The tests were added in 89048b4 (t1600-index: add expensive tests for over-long tree paths, 2026-10-16). They use a tree with a single entry whose name is 2^32 - 2 bytes long. decode_tree_entry() stores that length in the "int" pathlen of struct name_entry, where it wraps to -2. update_tree_entry() then uses it to find the next entry, ends up in the middle of the name, and fails to parse it. Before 53d5cfc the tree size was truncated to 32 bits as well, so the walk saw the 2^32 + 26 byte tree as 26 bytes. That is exactly what the wrapped entry length consumed, so the walk stopped without an error and read-cache rejected the path as the tests expect. Fixing the tree size exposed the pathlen bug. Fix this by keeping the name length in a size_t and rejecting names longer than INT_MAX. read-cache already has the same limit for index entries, and index.maxPathLen cannot be set higher, so such names could never be used anyway. Update the tests to expect the new error. Signed-off-by: Kristofer Karlsson <krka@spotify.com> Submitted-As: https://lore.kernel.org/git/pull.2342.git.1796049772272.gitgitgadget@gmail.com
submodule: fix handling of unusual submodule names This series fixes issues with unusual submodule names. The first patch fixes 'git submodule deinit' failing to remove the configuration section for submodules whose names contain regexp metacharacters. The second patch rejects "." as a submodule name in 'git submodule add'. This avoids a confusing error and prevents an invalid submodule...gitdir entry from being written to the configuration when extensions.submodulePathConfig is enabled. * [1/2] submodule deinit: handle regexp metacharacters in names * [2/2] submodule add: reject "." as submodule name Yoichi NAKAYAMA (2): submodule deinit: handle regexp metacharacters in names submodule add: reject "." as submodule name builtin/submodule--helper.c | 26 +++++++++++++++++++++++--- submodule-config.c | 4 ++-- t/t7400-submodule-basic.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 5 deletions(-) base-commit: acba8bf Submitted-As: https://lore.kernel.org/git/pull.2340.git.1795989773.gitgitgadget@gmail.com
worktree add: skip HEAD reads for destination checks
From: Maik Riechert <letmaik@outlook.com>
add_worktree() calls get_worktrees() to check whether the destination
matches a registered worktree. This also resolves HEAD for the
enumerated worktrees, although check_candidate_path() only needs their
paths, IDs and lock state.
Use get_worktrees_without_reading_head() for the destination check to
avoid these unnecessary lookups.
Measured with 'git worktree add --detach --no-checkout' on a repository
with 200 existing linked worktrees (median of seven runs per version,
warm caches):
before after
files 11.13 ms 6.77 ms
reftable 18.86 ms 7.60 ms
Signed-off-by: Maik Riechert <letmaik@outlook.com>
Submitted-As: https://lore.kernel.org/git/pull.2339.v2.git.1795930874388.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2339.git.1795907202117.gitgitgadget@gmail.com
PreviousNext