aboutsummaryrefslogtreecommitdiff
path: root/git/diff.py
AgeCommit message (Collapse)Author
2016-04-19Make diff patch parsing more reliableVincent Driessen
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.
2016-04-14Perform diff-tree recursively to have the same output as diffVincent Driessen
2016-04-14Export NULL_TREEVincent Driessen
2016-04-14Use a special object rather than a stringVincent Driessen
This alternative API does not prevent users from using the valid treeish "root".
2016-04-14Support "root" as a special value in .diff() callsVincent Driessen
This enabled getting diff patches for root commits.
2016-03-15Split diff line by '\t' for metadata and pathJonathan Chu
This protects against `.split(None)` which uses consecutive whitespace as a separator to overlook paths where a single space is the filename. For example, in this diff line: line = ':100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D ' The deleted file is a file named ' ' (just one space). It's entirely possible to commit this, remove, and to produce the following output from `git diff`: git diff --name-status <SHA1> <SHA2> D M path/to/another/file.py ... This would cause the initial `.split(None, 5)` to fail as it will count all consecutive whitespace as a separator, disregarding the ' ' (single space) filename.
2015-07-29fix(diff): mode-assertions now deal with 0Sebastian Thiel
If the file was not present, the mode seen in a diff can be legally '0', which previously caused an assertion to fail for no good reason. Now the assertion tests for None instead. Closes #323
2015-03-02Store path attribute on Diff objectJames E. Blair
If a file in a commit contains no changes (for example, if only the file mode is changed) there will be no blob attached. This is usually where the filename is stored, so without it, the calling context can not tell what file was changed. Instead, always store a_path and b_path on the Diff object so that information is available.
2015-01-22Overhauled all tutorials, and placed them in a unit-test.Sebastian Thiel
That way they are protected from regression. Fixes #239
2015-01-09Now Diff.__str__ works correctly in all python versions.Sebastian Thiel
Additionally, unicode handling was improved to the point where we deal with all diff(create_path=True) data as binary. Therefore we don't claim to know all encodings of all textfiles in the world, even though we still assume that everything git throws at us is utf-8 encoded. Fixes #113
2015-01-09Fixed mode-handling in Diff creation, and added assertions to catch this in ↵Sebastian Thiel
future There is still some work todo in terms of how we handle the encoding
2015-01-09Added test to verify binary diffs are working as well.Sebastian Thiel
Related to #74
2015-01-08Added support for rename detection in raw mode (which is the default).Sebastian Thiel
Fixes #36
2015-01-08Added assertion to better detect diff issues.Sebastian Thiel
Helps fixing #35 Also, the production status was changed to 'stable', which should have been done much earlier.
2015-01-05test_diff worksSebastian Thiel
2015-01-05test_commit works once againSebastian Thiel
2015-01-04initial set of adjustments to make (most) imports work.Sebastian Thiel
More to come, especially when it's about strings
2015-01-04Bumped version, updated changelog, reduced code smellSebastian Thiel
There is more work to do though, as many imports are still incorrect. Also, there are still print statements
2014-11-19Applied autopep8Sebastian Thiel
Commandline was autopep8 -j 8 --max-line-length 120 --in-place --recursive --exclude "*gitdb*,*async*" git/
2014-11-16pep8 linting (trailing whitespace)Antoine Musso
W291 trailing whitespace
2014-11-16pep8 linting (whitespace before/after)Antoine Musso
E201 whitespace after '(' E202 whitespace before ')' E203 whitespace before ':' E225 missing whitespace around operator E226 missing whitespace around arithmetic operator E227 missing whitespace around bitwise or shift operator E228 missing whitespace around modulo operator E231 missing whitespace after ',' E241 multiple spaces after ',' E251 unexpected spaces around keyword / parameter equals
2014-11-16pep8 linting (blank lines expectations)Antoine Musso
E301 expected 1 blank line, found 0 E302 expected 2 blank lines, found 1 E303 too many blank lines (n)
2014-11-16pep8 linting (whitespaces)Antoine Musso
W191 indentation contains tabs E221 multiple spaces before operator E222 multiple spaces after operator E225 missing whitespace around operator E271 multiple spaces after keyword W292 no newline at end of file W293 blank line contains whitespace W391 blank line at end of file
2014-07-17Untested fix for #172Sebastian Thiel
See https://github.com/gitpython-developers/GitPython/issues/172 for more information
2014-02-09tabs to 4 spaces - this won't make integrating the patches easier, but it's ↵Sebastian Thiel
probably a good idea to go a little more pep8 (and fix sins of my youth ;) )
2011-01-12OSX Signal handling: removed previous hack to fix it somehow using sleep - ↵Sebastian Thiel
the error was caused by PySide which, when instantiating a QApplication, changed the signal handlers to interrupt, instead of retry operating system calls, which caused git-python to fail subsequently. signal.siginterrupt can be used to fix this behaviour after an QApplication was instatiated.
2011-01-06Added the bugfix code as a utility function to be reused wherever this ↵Andreas Gutsche
specific subprocess bug occurs.
2010-11-25Moved everything into the git subdirectory - some tests still need to be ↵Sebastian Thiel
adjusted