python-unidiff
python-unidiff copied to clipboard
Unable to handle file paths from "git diff --cached"
"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.
Actually, "git diff --cached" only behaves that way if diff.mnemonicprefix config item is set.