Skip to content

fix: derive extra path repository names from portable paths - #90

Open
markmybytes wants to merge 1 commit into
iHildy:mainfrom
markmybytes:fix/portable-extra-path-naming
Open

markmybytes wants to merge 1 commit into
iHildy:mainfrom
markmybytes:fix/portable-extra-path-naming

Conversation

@markmybytes

Copy link
Copy Markdown

Problem

Extra path repository names are derived from the machine-local absolute source path, so the same file ends up with a different name under config/extra/ (and secrets/extra/) depending on which machine pushes. Windows and Linux disagree on top of that, since Windows resolves paths case-insensitively.

I believe stabilizing these names is the right move — the same logical file should map to the same repository path on every machine. This PR makes that hold.

What this PR does

  • Derives repository names from the portable path form (config-relative, home-relative, or absolute fallback), NFC-normalized and lowercased, so the same file maps to the same repository path on every machine and platform.
  • Folds pull-side manifest matching the same way and restores each entry to the machine's own path spelling. A manifest pushed from Windows (where paths arrive lowercased) previously wouldn't restore mixed-case names on Linux; it does now, without creating duplicate lowercase files.
  • Collapses duplicate declarations that resolve to the same file into one entry.
  • Fails fast with a clear error when two declared paths fold to the same repository name (Foo.md vs foo.md, or É.md vs é.md) — the message says to rename or drop one. Since the declarations live in the synced config itself, the error shows up on any sync command until resolved.

Migration is free: old manifests keep applying, and the first push after upgrading rewrites entries to the stable names — push already fully rewrites the extra directory. 213 tests pass, with new coverage for cross-machine name equality, case folding, dedup, and the collision error.

Extra path and extra secret repository names previously encoded the
machine-local absolute source path, so every machine or platform
switch renamed all entries under config/extra/ and secrets/extra/.
Names now derive from the portable path form (config-relative,
home-relative, or absolute fallback, lowercased), so the same logical
file maps to the same repository path on every machine.

Repository names must fold case (full Unicode, because Windows
normalizes resolved paths with a Unicode lowercase) and Unicode
normalization (NFC, because macOS stores decomposed names) for the
same file to map to the same repository path on both
case-insensitive and case-sensitive platforms. As a consequence,
distinct POSIX paths that differ only by case (Foo.md and foo.md,
or É.md and é.md) now fail fast with a clear error instead of
syncing as separate repository entries; case-sensitive setups with
such extra paths must rename or drop one of them. The check covers a
single machine's declarations: case variants declared on different
machines still fold to one repository entry and share content. The
error stops every command that builds a sync plan, including pulls,
so a fleet stays affected until one declaration is renamed or
removed.

Pull-side manifest matching folds case and normalization the same
way and restores each entry to the machine's own resolved path, so
Windows-pushed entries (whose manifest source paths arrive folded)
restore on case-sensitive platforms instead of being silently
skipped. Manifest source paths keep the pushing machine's spelling,
so that field may still flip case when pushes alternate between
platforms; repository paths and restores stay stable. Absolute
out-of-home declarations keep their absolute portable form and stay
stable only when the declared path itself is not machine-specific.

Duplicate declarations that resolve to the same file still collapse
to a single entry. Existing manifests keep applying unchanged; the
first push after this upgrade rewrites entries to the stable names.
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.

1 participant