Repository navigation
Conversation
`git sparse-checkout disable` restores the full working tree and sets core.sparseCheckout=false, but deliberately leaves <gitdir>/info/sparse-checkout in place so the checkout can be re-enabled with the same patterns. detectSparseCheckout treated the mere presence of that pattern file as "sparse", so a fully-populated worktree kept showing the sparse badge and the misleading "Partial checkout. Files outside these paths are not on disk." tooltip. Gate the fast-path fs.stat behind a config read that confirms core.sparseCheckout is actually enabled (shared repo config or per-worktree config.worktree, honoring git's precedence). The config read runs only when a non-empty pattern file exists, so it does not reintroduce the per-poll subprocess fan-out PR stablyai#1290 removed, and it reads git's config files directly (no subprocess). Adds a real-git regression test (enable -> disable leaves file -> not sparse) and unit tests for the git-config boolean parser.
📝 WalkthroughWalkthroughSparse-checkout detection now uses the sparse pattern file as a gate and confirms 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/git/worktree-sparse-checkout.test.ts (1)
77-116: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSolid parser unit-test coverage, but no integration test covers
config.worktree/commondirprecedence.These tests thoroughly lock down
parseCoreSparseCheckoutFlag's text-parsing semantics, but nothing here exercisesisSparseCheckoutEnabled/resolveGitCommonDirend-to-end (e.g., viagit worktree addplusgit config --worktree core.sparseCheckout ...in a linked worktree). That's the part of this PR most likely to have file-resolution bugs (see theextensions.worktreeConfiggap flagged inworktree.ts), and it's currently only indirectly covered.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 1c3d4e56-186e-4370-94b0-0cd5b31931a3
📒 Files selected for processing (2)
src/main/git/worktree-sparse-checkout.test.tssrc/main/git/worktree.ts
| // Whether core.sparseCheckout is actually enabled for this worktree. The value can live in the | ||
| // shared repo config or, when extensions.worktreeConfig is on, in the worktree-local | ||
| // `config.worktree`; later files override earlier ones, matching git's config precedence. | ||
| async function isSparseCheckoutEnabled(gitDir: string): Promise<boolean> { | ||
| const commonDir = await resolveGitCommonDir(gitDir) | ||
| const sharedFlag = await readCoreSparseCheckoutFlag(join(commonDir, 'config')) | ||
| const worktreeFlag = await readCoreSparseCheckoutFlag(join(gitDir, 'config.worktree')) | ||
| return worktreeFlag ?? sharedFlag ?? false | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the target function and related helpers.
FILE="src/main/git/worktree.ts"
echo "== outline =="
ast-grep outline "$FILE" --view expanded || true
echo
echo "== relevant lines around isSparseCheckoutEnabled =="
sed -n '1390,1475p' "$FILE"
echo
echo "== search for helper definitions/usages =="
rg -n "readCoreSparseCheckoutFlag|parseConfigBooleanFlag|extensions.worktreeConfig|config.worktree|isSparseCheckoutEnabled" "$FILE"Repository: stablyai/orca
Length of output: 9027
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== search repo for worktreeConfig / config.worktree / sparseCheckout parsing =="
rg -n "extensions\.worktreeConfig|config\.worktree|sparseCheckout|core\.sparseCheckout" src/main/git src -g '!**/dist/**' -g '!**/build/**'Repository: stablyai/orca
Length of output: 9067
🌐 Web query:
git config extensions.worktreeConfig config.worktree read only when enabled docs
💡 Result:
The extensions.worktreeConfig setting in Git does not make the config.worktree file read-only; rather, it enables a mode where configuration can be set specifically for individual worktrees [1][2]. When extensions.worktreeConfig is enabled, Git allows you to maintain worktree-specific settings in a file located at $GIT_DIR/config.worktree [3][1]. You can add or update configuration in this file using the command git config --worktree [1][2]. Key points regarding this extension: 1. Enabling it: You enable the extension using git config extensions.worktreeConfig true [1][2]. 2. Function: It allows worktrees to load settings from their specific config.worktree file in addition to the common repository config [3][4]. Settings in config.worktree override those in other configuration files [3][4]. 3. Migration: When enabling this, you must manually move certain configuration values (such as core.worktree and core.bare=true) from the common config file to the main worktree's config.worktree file, as they are no longer handled as special cases in the common config [3][1]. 4. Compatibility: Repositories with this extension enabled may not be accessible by older versions of Git [1][2]. There is no documentation indicating that enabling this extension imposes a read-only restriction on the config.worktree file; instead, it provides a mechanism to manage worktree-specific configurations [3][1].
Citations:
- 1: https://git-scm.com/docs/git-worktree
- 2: https://github.com/git/git/blob/master/Documentation/git-worktree.adoc
- 3: https://github.com/git/git/blob/94f05775/Documentation/config/extensions.adoc
- 4: https://code.googlesource.com/git/+/refs/tags/v2.37.0-rc1/Documentation/config/extensions.txt
Gate config.worktree behind extensions.worktreeConfig isSparseCheckoutEnabled() always reads config.worktree, so a stale worktree-local flag can override .git/config even when Git would ignore that file. Only consult it when extensions.worktreeConfig is set.
|
Thanks so much for this, @artile — don't flag a disabled sparse checkout as sparse. Verified (fail-on-main/pass-on-branch), rebased on latest |
…yai#9922) `git sparse-checkout disable` restores the full working tree and sets core.sparseCheckout=false, but deliberately leaves <gitdir>/info/sparse-checkout in place so the checkout can be re-enabled with the same patterns. detectSparseCheckout treated the mere presence of that pattern file as "sparse", so a fully-populated worktree kept showing the sparse badge and the misleading "Partial checkout. Files outside these paths are not on disk." tooltip. Gate the fast-path fs.stat behind a config read that confirms core.sparseCheckout is actually enabled (shared repo config or per-worktree config.worktree, honoring git's precedence). The config read runs only when a non-empty pattern file exists, so it does not reintroduce the per-poll subprocess fan-out PR stablyai#1290 removed, and it reads git's config files directly (no subprocess). Adds a real-git regression test (enable -> disable leaves file -> not sparse) and unit tests for the git-config boolean parser.
Summary
Fixes a worktree falsely showing the
sparsebadge (and the "Files outside these paths are not on disk" tooltip) aftergit sparse-checkout disablehad already restored every file to disk.ELI5
If you turned on a "only show some files" mode and then turned it back off, the app kept warning that files were missing — even though they were all right there. Now it checks the real setting and shows the correct state.
Root cause & fix
detectSparseCheckout()inferred sparsity purely from the presence and non-zero size of<gitdir>/info/sparse-checkout. Butgit sparse-checkout disablesetscore.sparseCheckout=falseand repopulates the tree while deliberately leaving that pattern file in place, so the fast-path probe reported a false positive. The fix keeps the cheapfs.statgate, but when the pattern file exists it confirms the effectivecore.sparseCheckoutflag by reading git's config files directly (sharedconfigplus per-worktreeconfig.worktree, honoring worktree-override precedence) — no subprocess, and config parsing is extracted into the pure, exportedparseCoreSparseCheckoutFlag().Evidence
Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.
origin/main(base8a23618310, head1582cc6abc).src/main/git/worktree.ts(fix),src/main/git/worktree-sparse-checkout.test.ts(test).git checkout origin/main -- src/main/git/worktree.ts) with the test kept: 10 failed | 1 passed, including the behavioral guard "does not report isSparse after disable leaves the pattern file behind" and theparseCoreSparseCheckoutFlagsuite (not exported on main).npx oxlint src/main/git/worktree.tsclean (rc=0).Trade-offs
None — pure fix. The extra config read runs only for the rare worktree that still has a non-empty pattern file, and adds no subprocess.
Regression risk
Zero-regression: only the false-positive branch changes. Worktrees with no pattern file still short-circuit on the
fs.statfast path (byte-identical behavior), and genuinely sparse worktrees still reportisSparsevia the realcore.sparseCheckoutflag — both proven by the passing suite. Note (out of scope, per #9921): SSH/disconnected worktrees synthesizeisSparsefrom persistedWorktreeMetaand are not reconciled here — a separate follow-up.Original fix by @artile (Taras Kornichuk). Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.