fix(scanner): keep pinned submodules from being pruned on rescan#11
Merged
Conversation
A git submodule (or linked worktree) stores `.git` as a pointer file (`gitdir: <path>`) rather than a directory. `is_real_git_dir` only accepted a `.git` directory containing HEAD, so pinning a submodule via "A" passed AddRepo's `.git.exists()` check but failed discovery: the next FS-driven DiscoverNewRepos rescan couldn't find it, sync_paths treated it as removed, and it vanished from the list almost immediately. Resolve the `gitdir:` pointer (absolute or relative to the working tree) and look for HEAD at the referenced git directory. Covers the reported case of adding ~/Code/Hax-CV/dependencies/3dgrut.
affromero
added a commit
that referenced
this pull request
Jun 7, 2026
fix(scanner): keep pinned submodules from being pruned on rescan
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happened
Adding a repo with
Aworked for a moment, then the row vanished within about a second whenever the path was a git submodule (or a linked worktree).A submodule's
.gitis a pointer file (gitdir: <path>), not a directory. Discovery'sis_real_git_dironly accepted a.gitdirectory containingHEAD, so the pinned repo passedAddRepo's.git.exists()check but failed discovery on the next FS-drivenDiscoverNewRepos.sync_pathsthen treated it as missing and pruned it.Fix
is_real_git_dirnow also accepts a.gitfile: it resolves thegitdir:pointer (absolute, or relative to the working tree) and checks forHEADat the referenced git directory. A smallread_gitdir_pointerhelper does the parsing.Tests
Two regression tests added in
src/git/scanner.rs, both via a newmake_submodulehelper:test_pinned_submodule_is_discovered(absolutegitdir:pointer)test_pinned_submodule_relative_gitdir_is_discovered(relative pointer)Full suite green (231 tests), clippy and fmt clean, pre-commit clean.
Closes #10