summaryrefslogtreecommitdiff
path: root/git/test/test_diff.py
Commit message (Collapse)AuthorAgeFilesLines
* Python 3 compat fixesVincent Driessen2016-04-201-1/+1
| | | | Specifically "string_escape" does not exist as an encoding anymore.
* Fix diff patch parser for paths with unsafe charsVincent Driessen2016-04-191-2/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This specifically covers the cases where unsafe chars occur in path names, and git-diff -p will escape those. From the git-diff-tree manpage: > 3. TAB, LF, double quote and backslash characters in pathnames are > represented as \t, \n, \" and \\, respectively. If there is need > for such substitution then the whole pathname is put in double > quotes. This patch checks whether or not this has happened and will unescape those paths accordingly. One thing to note here is that, depending on the position in the patch format, those paths may be prefixed with an a/ or b/. I've specifically made sure to never interpret a path that actually starts with a/ or b/ incorrectly. Example of that subtlety below. Here, the actual file path is "b/normal". On the diff file that gets encoded as "b/b/normal". diff --git a/b/normal b/b/normal new file mode 100644 index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54 --- /dev/null +++ b/b/normal @@ -0,0 +1 @@ +dummy content Here, we prefer the "---" and "+++" lines' values. Note that these paths start with a/ or b/. The only exception is the value "/dev/null", which is handled as a special case. Suppose now the file gets moved "b/moved", the output of that diff would then be this: diff --git a/b/normal b/b/moved similarity index 100% rename from b/normal rename to b/moved We prefer the "rename" lines' values in this case (the "diff" line is always a last resort). Take note that those lines are not prefixed with a/ or b/, but the ones in the "diff" line are (just like the ones in "---" or "+++" lines).
* Make test stricterVincent Driessen2016-04-191-1/+1
|
* Make diff patch parsing more reliableVincent Driessen2016-04-191-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix test casesVincent Driessen2016-04-141-4/+5
|
* Support "root" as a special value in .diff() callsVincent Driessen2016-04-141-1/+16
| | | | This enabled getting diff patches for root commits.
* Add test and fixture for diff index from raw formatJonathan Chu2016-03-161-0/+6
| | | | | | This tests the edge case of doing a diff against a single whitespace filename and returns the proper change type. All other normal usage of this diff classmethod should remain unchanged.
* fix(diff): mode-assertions now deal with 0Sebastian Thiel2015-07-291-0/+32
| | | | | | | | 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
* Added advance usage examples to tutorial and made minor fixes.Sebastian Thiel2015-01-211-2/+4
| | | | | | GIT_PYTHON_TRACE would actually fail (now) if we debugged archive operations. Related to #239
* Now Diff.__str__ works correctly in all python versions.Sebastian Thiel2015-01-091-2/+2
| | | | | | | | | 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
* Fixed mode-handling in Diff creation, and added assertions to catch this in ↵Sebastian Thiel2015-01-091-1/+5
| | | | | | future There is still some work todo in terms of how we handle the encoding
* Added test to verify binary diffs are working as well.Sebastian Thiel2015-01-091-0/+12
| | | | Related to #74
* Added test to verify binary diffs are working as well.Sebastian Thiel2015-01-091-0/+10
| | | | Related to #74
* Added support for rename detection in raw mode (which is the default).Sebastian Thiel2015-01-081-0/+9
| | | | Fixes #36
* Added assertion to better detect diff issues.Sebastian Thiel2015-01-081-1/+1
| | | | | | | Helps fixing #35 Also, the production status was changed to 'stable', which should have been done much earlier.
* Replaced ordered dict with standard version; used logging moduleSebastian Thiel2015-01-041-0/+1
| | | | All performance tests still print to stderr, but do so in a py3 compatible way
* Removed 'from X import *' whereever possibleSebastian Thiel2015-01-041-3/+13
|
* Bumped version, updated changelog, reduced code smellSebastian Thiel2015-01-041-1/+1
| | | | | There is more work to do though, as many imports are still incorrect. Also, there are still print statements
* pep8 linting (trailing whitespace)Antoine Musso2014-11-161-6/+6
| | | | W291 trailing whitespace
* pep8 linting (whitespace before/after)Antoine Musso2014-11-161-5/+5
| | | | | | | | | | | | | 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
* pep8 linting (blank lines expectations)Antoine Musso2014-11-161-0/+1
| | | | | | E301 expected 1 blank line, found 0 E302 expected 2 blank lines, found 1 E303 too many blank lines (n)
* pep8 linting (whitespaces)Antoine Musso2014-11-161-13/+11
| | | | | | | | | | | 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
* tabs to 4 spaces - this won't make integrating the patches easier, but it's ↵Sebastian Thiel2014-02-091-94/+94
| | | | probably a good idea to go a little more pep8 (and fix sins of my youth ;) )
* Moved everything into the git subdirectory - some tests still need to be ↵Sebastian Thiel2010-11-251-0/+108
adjusted