Skip to content

fix(scanner): keep pinned submodules from being pruned on rescan#11

Merged
affromero merged 1 commit into
mainfrom
fix/submodule-repo-pruned
Jun 7, 2026
Merged

fix(scanner): keep pinned submodules from being pruned on rescan#11
affromero merged 1 commit into
mainfrom
fix/submodule-repo-pruned

Conversation

@affromero
Copy link
Copy Markdown
Owner

@affromero affromero commented Jun 7, 2026

What happened

Adding a repo with A worked 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 .git is a pointer file (gitdir: <path>), not a directory. Discovery's is_real_git_dir only accepted a .git directory containing HEAD, so the pinned repo passed AddRepo's .git.exists() check but failed discovery on the next FS-driven DiscoverNewRepos. sync_paths then treated it as missing and pruned it.

Fix

is_real_git_dir now also accepts a .git file: it resolves the gitdir: pointer (absolute, or relative to the working tree) and checks for HEAD at the referenced git directory. A small read_gitdir_pointer helper does the parsing.

Tests

Two regression tests added in src/git/scanner.rs, both via a new make_submodule helper:

  • test_pinned_submodule_is_discovered (absolute gitdir: pointer)
  • test_pinned_submodule_relative_gitdir_is_discovered (relative pointer)

Full suite green (231 tests), clippy and fmt clean, pre-commit clean.

Closes #10

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 affromero merged commit 49a850f into main Jun 7, 2026
8 checks passed
@affromero affromero deleted the fix/submodule-repo-pruned branch June 7, 2026 15:43
affromero added a commit that referenced this pull request Jun 7, 2026
fix(scanner): keep pinned submodules from being pruned on rescan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding a submodule with "A" is removed almost immediately

1 participant