summaryrefslogtreecommitdiff
path: root/git/objects/commit.py
diff options
context:
space:
mode:
authorVincent Driessen <me@nvie.com>2016-04-14 21:27:39 +0200
committerVincent Driessen <me@nvie.com>2016-04-19 21:45:18 +0200
commite77128e5344ce7d84302facc08d17c3151037ec3 (patch)
tree2ed0edc2293fc83e86c2c874f86848e181a10dd4 /git/objects/commit.py
parent0d7a40f603412be7e1046b500057b08558d9d250 (diff)
downloadgitpython-e77128e5344ce7d84302facc08d17c3151037ec3.tar.gz
Make diff patch parsing more reliable
The a_path and b_path cannot reliably be read from the first diff line as it's ambiguous. From the git-diff manpage: > The a/ and b/ filenames are the same unless rename/copy is involved. > Especially, **even for a creation or a deletion**, /dev/null is not > used in place of the a/ or b/ filenames. This patch changes the a_path and b_path detection to read it from the more reliable locations further down the diff headers. Two use cases are fixed by this: - As the man page snippet above states, for new/deleted files the a or b path will now be properly None. - File names with spaces in it are now properly parsed. Working on this patch, I realized the --- and +++ lines really belong to the diff header, not the diff contents. This means that when parsing the patch format, the --- and +++ will now be swallowed, and not end up anymore as part of the diff contents. The diff contents now always start with an @@ line. This may be a breaking change for some users that rely on this behaviour. However, those users could now access that information more reliably via the normal Diff properties a_path and b_path now.
Diffstat (limited to 'git/objects/commit.py')
0 files changed, 0 insertions, 0 deletions