Use a consistent file path label when paths share no suffix - #997
Open
StressTestor wants to merge 1 commit into
Open
Use a consistent file path label when paths share no suffix#997StressTestor wants to merge 1 commit into
StressTestor wants to merge 1 commit into
Conversation
When two paths have no common trailing component, build_display_path chose the rhs path if it had an extension and the lhs path otherwise, so the label shown depended on whether the files had an extension (e.g. `a` vs `b` showed `a`, but `a.txt` vs `b.txt` showed `b.txt`). Always use the rhs path in this case, matching the git-tmpfile branch above. Fixes Wilfred#925.
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.
what
When diffing two files whose paths share no common trailing component, the path shown in the hunk header depends on whether the files have an extension:
avsblabels with the left path, buta.txtvsb.txtlabels with the right path. This is #925.why
build_display_path's no-common-suffix arm picked the rhs path when rhs had an extension and the lhs path otherwise:so the side shown was driven by the extension.
fix
Use the rhs path consistently here, matching the git-tmpfile branch just above (which already returns rhs) and the usual convention of showing the new/destination file.
The change is scoped to that one match arm. The reporter also suggested detecting a rename and showing both paths; that is a larger behaviour change, so I kept this minimal and easy to extend if you would rather take the show-both approach.
tests
test_build_display_path_consistent_without_common_suffixcovers the extensionless and extensioned cases (both now use rhs) and the shared-suffix case (unchanged). It fails before the fix and passes after. Full suite green.Fixes #925.