Fix diff parsing to support mnemonicPrefix configuration #2092
+39
−2
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 #2013
When
diff.mnemonicPrefix=trueis set in git config, git uses different prefixes for diff paths instead of the standarda/andb/:c/for commitw/for worktreei/for indexo/for objecth/for HEADPreviously, the diff regex and
decode_path()function only accepteda/andb/prefixes, causingcreate_patch=Truediffs to fail parsing when users had this config enabled.Reproduction
As described in #2013:
Changes
re_headerregex to accept[abciwoh]/prefixes instead of just[ab]/decode_path()assertion to accept all valid mnemonic prefixesTesting
test_diff_mnemonic_prefixverifies parsing works withc/andw/prefixesReferences