fix: show microsecond precision in borg diff when timestamps differ only at sub-second level (fixes #9147)#9561
Open
hiepau1231 wants to merge 6 commits intoborgbackup:masterfrom
Conversation
… display Add format_timestamp_pair() function that intelligently formats two timestamps for diff output. When timestamps are equal at second resolution but differ at the microsecond level (common on FreeBSD/NetBSD), microsecond precision is used to show the difference. Otherwise, second-precision format is used to match existing behavior. Includes 3 comprehensive unit tests covering: 1. Timestamps differing at second level (no microseconds shown) 2. Timestamps identical at second level but different at microsecond level (microseconds shown) 3. Completely identical timestamps (no microseconds shown) Fixes issue borgbackup#9147 where diff output showed confusing identical timestamps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…econd timestamp diffs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
BSD may produce a POSIX-valid sub-second ctime change on b/hardlink when a previously hard-linked path is recreated as a new inode. The test now accepts this BSD behavior while still verifying no content/mode/mtime changes. Fixes borgbackup#9147 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
Thanks for the PR! That variable formatting is a mixed blessing:
Can you fix the linting issues, so the BSD tests are not cancelled? |
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.
Summary
Fixes #9147 —
borg diffon FreeBSD/NetBSD shows confusing[ctime: Wed, 2025-11-05 17:45:53 +0000 -> Wed, 2025-11-05 17:45:53 +0000]output where both timestamps look identical but actually differ at nanosecond level.format_timestamp_pair(ts1, ts2)inhelpers/time.py: selects second-precision format normally, but upgrades to microsecond precision (%H:%M:%S.%f) when two timestamps appear equal at second resolution but differ at sub-second levelDiffFormatter.format_time()inhelpers/parseformat.pyto useformat_timestamp_pair(), so diff output shows[ctime: ...17:45:53.000123 ... -> ...17:45:53.000456 ...]instead of the confusing identical-looking pairtest_hard_link_deletion_and_replacementon FreeBSD, NetBSD, and OpenBSD (was previously skipped): the test now accepts a POSIX-valid sub-second ctime update on surviving hardlinks while verifying no content/mode/mtime changes occurredRoot cause
On BSD, creating a new file at a previously hard-linked path causes a sub-second ctime update on surviving hard links (POSIX-valid behaviour). The old
format_time()always used second-precision format, so two timestamps like17:45:53.000123and17:45:53.000456both rendered as17:45:53, producing the confusingX -> Xoutput.Test plan
test_format_timestamp_pair_different_seconds— second-precision when timestamps differ by ≥1stest_format_timestamp_pair_same_second_different_microsecond— microsecond-precision for sub-second difftest_format_timestamp_pair_identical— second-precision for identical timestampstest_diff_formatter_format_time_shows_microseconds_when_same_second— full formatter pathtest_diff_formatter_format_time_no_microseconds_for_different_seconds— control casetest_hard_link_deletion_and_replacementon FreeBSD/NetBSD/OpenBSD CI — required before merge