Repository navigation
Fix false repo relocation warning on macOS due to NFC/NFD path differences, fixes #2913 (1.4-maint) - #10576
Open
ThomasWaldmann wants to merge 1 commit into
Open
Fix false repo relocation warning on macOS due to NFC/NFD path differences, fixes #2913 (1.4-maint)#10576ThomasWaldmann wants to merge 1 commit into
ThomasWaldmann wants to merge 1 commit into
Conversation
…rning on macOS, fixes 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. Backport of borgbackup#9940 (master commit 4a25abc). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.4-maint #10576 +/- ##
=============================================
- Coverage 82.11% 82.10% -0.02%
=============================================
Files 38 38
Lines 11485 11489 +4
Branches 1810 1810
=============================================
+ Hits 9431 9433 +2
- Misses 1468 1469 +1
- Partials 586 587 +1 ☔ View full report in Codecov by Harness. |
This branch has not been deployed
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.
Backport of #9940 to 1.4-maint. 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. They look identical but are byte-different, so accessing a repo whose path contains non-ASCII characters via a relative path /
./$(pwd)made borg believe the repository had been relocated and prompt "The repository at location … was previously located at …".Fix
helpers.normalize_local_path(): NFD on macOS, no-op elsewhere.filelocations through it inLocation.canonical_path().SecurityManager.assert_location_matches()(incache.pyon 1.4), so existing NFC-form securitylocationfiles still match after upgrade.Only affects the repository location string used for the relocation check; archived file paths are unaffected.
Backport notes
Manual port: on 1.4
SecurityManagerlives incache.pyand the tests intestsuite/helpers.py.Testing
test_normalize_local_path,test_canonical_path_unicode_normalization;testsuite/helpers.py+testsuite/cache.pypass.🤖 Generated with Claude Code