Repository navigation
Skip .git, .svn, .hg and .bzr when dedup scans a tree [patch] - #334
matt-edmondson wants to merge 1 commit into
Conversation
Inside .git, every branch ref pointing at the same commit has identical content, as do the reflogs of branches created together. dedup walked into .git like any other folder, so dedupe kept one of those files and deleted the rest, deleting branches, remote-tracking refs and reflogs in every repository under the root. EnumerateRegularFiles now prunes version-control metadata directories by name and leaves out a .git pointer file, so scan, dry-run, dedupe and stats never see them. Directories such as .github and mirror.git are still scanned. Fixes #222 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW34mg5yez39UfTV7yf
|
This failure isn't caused by this PR, which only touches I haven't found a fix to port into this PR. The candidate is #270, which bumps ImageSharp to 3.2.0, but IconHelper#155 reports that 3.2.0 fails CI without a Six Labors license. Choosing between that bump, a license or another option needs a maintainer decision. Locally, with Generated by Claude Code |
Fixes #222
What changes
Inside
.git, every branch ref that points at the same commit has identical content, and so do the reflogs of branches created together.dedupwalked into.gitlike any other folder, sodedup dedupekept one of those files and deleted the rest. That deleted branches, remote-tracking refs and reflogs in every repository under the root.FileDedupeService.EnumerateRegularFilesnow walks with aFileSystemEnumerable. It prunes.git,.svn,.hgand.bzrdirectories (name match, case-insensitive) instead of filtering paths afterwards, and it leaves out a.gitpointer file, as the issue asks: deleting a worktree's or submodule's pointer would detach that checkout. The reparse-point and link-target rules from #219 are unchanged.scan,dry-run,dedupeandstatsall go through this helper, so all four are covered.This is the same rule as ktsu-dev/FileDeduplicator#194 (fix for FileDeduplicator#192). The one difference is the
.gitpointer file, which this issue asked to skip and that one didn't.The optional
--exclude <name>idea from the issue isn't included.Tests
DedupeLeavesVersionControlMetadataAlone, one row each for.git/.svn/.hg/.bzr. Three identical refs plus a real duplicate pair: only the copy outside the metadata is planned for removal and deleted, and every ref survives.EnumerateRegularFilesSkipsAGitPointerFileButNotLookAlikes: a worktree.gitfile is left out, while.github/,mirror.git/and.gitignoreare listed.KtsuTools.Testrun: 390 passed, 0 failed.CI note
maincurrently fails restore withNU1903on SixLabors.ImageSharp 3.1.12 (GHSA-v76p-62qx-wwq2). Every open KtsuTools PR's test jobs are red for that reason, e.g. #331. That failure isn't from this change, and I verified locally with-p:WarningsNotAsErrors=NU1903. The ImageSharp bump in #270 is the candidate fix, but IconHelper#155 reports that 3.2.0 fails CI without a Six Labors license, so it needs a maintainer decision.Generated by Claude Code