Skip to content

Sparse badge sticks after git sparse-checkout disable (detection reads only pattern-file presence) #9921

Closed

Description

@artile

Summary

A worktree that was sparse-checked-out and later fully restored with git sparse-checkout disable keeps showing the sparse badge and the tooltip "Partial checkout. Files outside these paths are not on disk." — even though every file is on disk and core.sparseCheckout=false.

Root cause

detectSparseCheckout (src/main/git/worktree.ts) infers sparsity purely from the existence + non-zero size of <gitdir>/info/sparse-checkout:

const stats = await stat(join(gitDir, 'info', 'sparse-checkout'))
return stats.isFile() && stats.size > 0

The comment states the assumption: "Git writes this file when sparse checkout is enabled … and does not write it otherwise." That assumption is wrong. git sparse-checkout disable sets core.sparseCheckout=false and repopulates the working tree, but deliberately leaves info/sparse-checkout in place so the checkout can be re-enabled with the same patterns. The fast-path probe from #1290 therefore reports a false positive.

Reproduce

git init repo && cd repo
mkdir keep drop && touch keep/f drop/f && git add -A && git commit -m init
git sparse-checkout set keep     # core.sparseCheckout=true  -> Orca: sparse (correct)
git sparse-checkout disable      # core.sparseCheckout=false, full tree restored
ls .git/info/sparse-checkout     # still present  -> Orca: still "sparse" (WRONG)

Ground truth after disable: core.sparseCheckout=false, full working tree, 0 skip-worktree entries — yet the badge and "files are not on disk" tooltip persist.

Fix

Keep the cheap fs.stat as a fast-path gate, but when the pattern file is present, confirm core.sparseCheckout is actually enabled by reading git's config files directly (shared repo config and, under extensions.worktreeConfig, the per-worktree config.worktree, honoring precedence). No subprocess, and it only runs for the rare worktree that still has a non-empty pattern file — so it does not reintroduce the per-poll git sparse-checkout list fan-out #1290 removed.

PR: tao-io/orca fix/sparse-checkout-false-positive-after-disable (adds a real-git regression test + config-parser unit tests).

Related (separate, not in this PR)

For SSH / disconnected worktrees, isSparse is synthesized purely from persisted WorktreeMeta (sparseDirectories/sparseBaseRef/sparsePresetId). The sparsePresetId doc comment says these are "Cleared when the worktree is no longer sparse on refresh", but no reconciliation code clears them — so a stale badge can persist there independently of git state. Worth a follow-up.

Activity

  1. nwparker commented on Jul 24, 2026

    @nwparker
    Contributor

    Fixed by #9922 — sparse detection now checks core.sparseCheckout, so a disabled sparse checkout no longer keeps the badge.

    Feel free to reopen if you still see it after updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions