Fix false repo relocation warning on macOS due to NFC/NFD path differences (#2913)#9940
Merged
ThomasWaldmann merged 1 commit intoJul 26, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9940 +/- ##
==========================================
- Coverage 85.68% 85.68% -0.01%
==========================================
Files 95 95
Lines 16794 16799 +5
Branches 2574 2574
==========================================
+ Hits 14390 14394 +4
- Misses 1668 1669 +1
Partials 736 736 ☔ View full report in Codecov by Harness. |
…rning on macOS (borgbackup#2913) On macOS the filesystem returns paths in NFD (decomposed) form, while a path typed as a command line argument is usually in NFC (composed) form. These look identical but are byte-different, so accessing a repo via a relative path / `.` / `$(pwd)` after `cd` made borg believe the repository had been relocated and prompt for confirmation. Add helpers.normalize_local_path() (NFD on macOS, no-op elsewhere) and run local file locations through it in Location.canonical_path(). Also normalize both sides of the location comparison in SecurityManager.assert_location_matches() so existing NFC-form security "location" files keep matching after upgrade. This only affects the repository *location* string used for the security / relocation check (and its display); archived file paths are unaffected, and the change is a no-op on non-macOS platforms.
ThomasWaldmann
force-pushed
the
fix-macos-nfd-repo-relocation-2913
branch
from
July 26, 2026 14:25
0f98f35 to
4a25abc
Compare
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 #2913.
Problem
On macOS the filesystem returns paths in NFD (decomposed) unicode form, while a path typed as a command line argument is usually in NFC (composed) form. These render identically but are byte-different. So accessing a repo whose path contains non-ASCII characters via a relative path /
./$(pwd)aftercdmade borg believe the repository had been relocated:The two locations are visually identical because one is NFC and the other NFD.
Fix
helpers.normalize_local_path()— normalizes to NFD on macOS (the form the filesystem itself uses, matching whatpatterns.normalize_path()already does), a no-op on other platforms.filelocations through it inLocation.canonical_path().SecurityManager.assert_location_matches(), so existing NFC-form securitylocationfiles still match after upgrade (no one-time spurious prompt) and remote (rest/ssh/borgstore) URLs stay consistent (normalization is idempotent and applied symmetrically).Scope / safety
is_darwinis fixed at import time).Tests
Added
test_normalize_local_pathandtest_canonical_path_unicode_normalization(both platform-aware). Fullparseformat+ archivercheckssuites pass locally.🤖 Generated with Claude Code