python-unidiff icon indicating copy to clipboard operation
python-unidiff copied to clipboard

Unable to handle file paths from "git diff --cached"

Open rohanpm opened this issue 8 years ago • 1 comments

"git diff --cached" produces file headers such as:

diff --git c/README.md i/README.md
index cfe07c3..6d38cfe 100644
--- c/README.md
+++ i/README.md

unidiff incorrectly considers this as a change to file "c/README.md" instead of a change to "README.md".

It looks like the reason is that https://github.com/matiasb/python-unidiff/blob/a7e46e07660772d8eaff64c9996b2fe9142faa4a/unidiff/patch.py#L226 has hardcoded expectations about a/ and b/ prefixes only.

rohanpm avatar Aug 02 '16 02:08 rohanpm

Actually, "git diff --cached" only behaves that way if diff.mnemonicprefix config item is set.

rohanpm avatar Aug 23 '16 06:08 rohanpm