Skip to content

Skip bare git repositories, CVS and _darcs when scanning [patch] - #205

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/198-skip-bare-git-directories
Nov 4, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/198-skip-bare-git-directories

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #198

What was wrong

The #192 fix skipped version-control metadata by directory name only. A bare git repository (project.git on a server, git clone --mirror output, the bare-dotfiles ~/.cfg) keeps HEAD, objects/ and refs/ directly in a folder of any name. Two branches at the same commit are byte-identical ref files, so Deduplicate deleted one of them and left the repository without a valid HEAD. CVS checkouts had a similar problem, because every CVS/Root and CVS/Repository file is identical.

Change

  • FileScanner.ShouldRecursePredicate now also refuses to descend into a directory that is a git directory by structure: a HEAD file next to objects/ and refs/ directories, which is the test git itself uses for a gitdir. The check runs once per directory.
  • CVS and _darcs are added to the skipped metadata names.
  • The README's paragraph on skipped metadata describes the new rule.

Tests

  • TheScanSkipsABareGitRepositoryWhateverItsName (srv/project.git, mirror, .cfg) and DeduplicateLeavesTheBranchesOfABareRepositoryAlone, which is the issue's reproduction run end to end.
  • TheScanStillReadsAFolderThatHasOnlyPartOfAGitDirectoryLayout: a notes.git folder with HEAD and refs/ but no objects/ is still scanned. The existing mirror.git/HEAD case also still passes.
  • CVS and _darcs rows added to TheScanSkipsVersionControlMetadataDirectories.
  • With the FileScanner.cs change reverted, those 6 tests fail. With it in place, the full suite passes: 125 passed, 3 skipped. The 3 skips are the existing permission tests, which can't be set up when running as root.

Generated by Claude Code

A bare repository keeps HEAD, objects/ and refs/ directly in a folder of
any name, so the .git name check missed it and Deduplicate deleted one of
two branch refs at the same commit. Recognise a gitdir by that structure,
and add CVS and _darcs to the skipped metadata names.

Fixes #198

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW2ncKULZZ8pQtc75wf
Comment thread FileDeduplicator/FileScanner.cs Fixed
Comment thread FileDeduplicator/FileScanner.cs Fixed
Comment thread FileDeduplicator/FileScanner.cs Fixed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW2ncKULZZ8pQtc75wf
@sonarqubecloud

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 8a064fd into main Nov 4, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/198-skip-bare-git-directories branch November 4, 2026 01:02
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.

Deduplicate still deletes branch refs inside bare git repositories (project.git, mirrors, ~/.cfg): only directories named exactly .git are skipped

2 participants