Repository navigation
Conversation
With `git diff --no-prefix`, `is_rename` unconditionally discards the first two filename characters, so a rename such as `a.py` to `b.py` goes undetected and `path` returns the source filename. Remove surrounding quotes for comparison and discard two characters only when both resulting paths start with a character followed by `/`; this retains custom prefixes such as `x/` and `y/`. For equally quoted inputs, comparisons with two such prefixes remain equivalent to the original behavior; otherwise, results change only when the original strings differ but become equal after discarding their first two characters. This follows the target-path behavior discussed in [matiasb#77](matiasb#77) and implemented in [matiasb#79](matiasb#79). A no-prefix rename where both real directory names resemble single-character prefixes, such as `a/x.py` to `b/x.py`, remains ambiguous from the header and is unchanged.
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.
With
git diff --no-prefix,is_renameunconditionally discards the first two filename characters, so a rename such asa.pytob.pygoes undetected andpathreturns the source filename. Remove surrounding quotes for comparison and discard two characters only when both resulting paths start with a character followed by/; this retains custom prefixes such asx/andy/. For equally quoted inputs, comparisons with two such prefixes remain equivalent to the original behavior; otherwise, results change only when the original strings differ but become equal after discarding their first two characters. This follows the target-path behavior discussed in #77 and implemented in #79. A no-prefix rename where both real directory names resemble single-character prefixes, such asa/x.pytob/x.py, remains ambiguous from the header and is unchanged.Reproduce with an installed checkout:
False a.py a.py b.pyTrue b.py a.py b.pyValidation on macOS arm64:
python -m unittest discover -s tests/passes 72 tests (69 on the unchanged baseline); applying only the added tests produces 14 expected failures.python -m mypy unidiff/with mypy 2.4.0 on Python 3.12: no issues in 6 source files before and after.git diffwith the default,--no-prefix, mnemonic, and custom--src-prefix/--dst-prefixsettings; only no-prefix names that differ in their first two characters change.The upstream CI matrix has not been run locally.
Manually written headers that quote only one side of otherwise equivalent filenames change from renames to non-renames; Git does not generate such output.
AI disclosure: Codex assisted with part of the code and this description.