Commit 77855d7
committed
config: mark as sparse-index compatible
`git config --blob :.lfsconfig` (and similar :path lookups) triggers
ensure_full_index() in sparse checkouts, expanding the entire sparse
index to a full index. On large repositories this takes seconds even
though the command only needs to look up a single path.
The root cause has two parts:
1. `git config` uses RUN_SETUP_GENTLY and never calls repo_config(),
so the sparse checkout globals (core.sparseCheckout,
core.sparseCheckoutCone) are unset when the index is first read.
2. Without those globals, is_sparse_index_allowed() returns false,
causing ensure_correct_sparsity() to call ensure_full_index()
during do_read_index().
Fix this by loading repo config and setting command_requires_full_index
to 0 in cmd_config(). This is the standard opt-in pattern used by the
~30 other commands that are sparse-index compatible.
The repo_config() call is needed because RUN_SETUP_GENTLY does not
load the default config callbacks that populate the sparse checkout
globals. Other sparse-index-compatible commands use RUN_SETUP, which
handles this during setup_git_directory().
The flag is safe to set unconditionally because git config only
accesses the index when resolving --blob :path specs. For non-blob
invocations, the flag has no effect. For --blob :path, in-cone paths
resolve directly from the sparse index; out-of-cone paths trigger
on-demand expansion through index_name_pos() with EXPAND_SPARSE.
Signed-off-by: Kristofer Karlsson <krka@spotify.com>1 parent 1666c12 commit 77855d7
1 file changed
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1618 | 1618 | | |
1619 | 1619 | | |
1620 | 1620 | | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
1621 | 1627 | | |
1622 | 1628 | | |
1623 | 1629 | | |
| |||
0 commit comments