checkpoint: accept case-folded shard directories in ParseRef - #2403
Open
KC1706 wants to merge 1 commit into
Open
checkpoint: accept case-folded shard directories in ParseRef#2403KC1706 wants to merge 1 commit into
KC1706 wants to merge 1 commit into
Conversation
On a case-insensitive-but-case-preserving filesystem (macOS APFS, Windows
NTFS defaults), git resolves a new checkpoint ref's shard directory against
existing ones case-insensitively. A ULID checkpoint's canonical shard is
uppercase (e.g. "6B"), so if an unrelated legacy hex checkpoint already
shards to the lowercase form ("6b"), the new ref lands inside that same
lowercase directory instead of a distinct one.
ParseRef then rejected such refs outright: it recomputed the ID's shard and
required an exact, case-sensitive match against the ref's actual path
component, so "6B" != "6b" caused a well-formed, intact checkpoint to be
treated as malformed and silently disappear from `entire checkpoint list`/
`explain`.
Fix: compare the shard case-insensitively (strings.EqualFold) instead of
exactly. Adds regression tests reproducing both directions of the collision.
Fixes entireio#2402
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.
Fixes #2402
On a case-insensitive-but-case-preserving filesystem (macOS APFS, Windows NTFS defaults), a checkpoint ref's shard directory can get case-folded by the filesystem itself — e.g. a ULID checkpoint whose correct shard is
6Blands inside an already-present6bdirectory left by an unrelated legacy hex checkpoint.ParseRefcompared the recomputed shard against the ref's actual path component byte-for-byte, so"6B" != "6b"caused a well-formed, intact checkpoint to be rejected as malformed and silently disappear fromcheckpoint list/explain.This PR makes that comparison case-insensitive (
strings.EqualFold), matching what the filesystem already does, and adds two regression tests reproducing both directions of the collision (ULID→lowercase dir, legacy-hex→uppercase dir).Verified locally:
mise run fmt && mise run lint(0 issues) andmise run test:cipass.