summaryrefslogtreecommitdiff
path: root/git/test/test_diff.py
Commit message (Collapse)AuthorAgeFilesLines
* tests: move to root dirKonrad Weihmann2020-07-121-369/+0
| | | | | | | | | This should ensure that tests are NOT packaged into release package by setuptools, as tests are development only + fixtures after moving Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
* Revert moving tests out of 'git' folder, related to #1030Sebastian Thiel2020-07-121-0/+369
|
* tests: move to root dirKonrad Weihmann2020-07-121-369/+0
| | | | | | | | | This should ensure that tests are NOT packaged into release package by setuptools, as tests are development only + fixtures after moving Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
* Remove now unnecessary explicit Unicode string literal prefixesHarmon2020-02-251-24/+24
|
* Replace assert_true with assertTrueHarmon2020-02-161-6/+5
| | | | Also change TestOutputStream to subclass TestBase rather than object
* Replace assert_equal with assertEqualHarmon2020-02-161-14/+13
| | | | Also change TestActor to subclass TestBase rather than object and create and use base TestCommitSerialization class for assert_commit_serialization method
* Adding assertions to existing test case to cover this changeJJ Graham2019-10-221-1/+6
|
* Removing f-strings to maintain 3.4 and 3.5 compatabilityJJ Graham2019-10-211-4/+4
|
* Added new test to cover the issue this fix addresses (#891)JJ Graham2019-10-211-2/+48
|
* Expanded new test for copied fileJJ Graham2019-10-191-1/+4
|
* Fixed new test for copied filesJJ Graham2019-10-191-1/+0
|
* Adding diff support for copied files, still working on testJJ Graham2019-10-191-0/+21
|
* Add change in type supportAurélien Matouillot2018-05-191-0/+27
|
* Get correcly rename change_type.Aurélien Matouillot2018-05-191-0/+2
| | | | Also store the rename score
* Rewrite unnecessary dict/list/tuple calls as literalsHugo2018-03-181-1/+1
|
* src: import os.path as ospKostis Anagnostopoulos2016-10-161-13/+11
|
* cygwin, #533: polish abs-paths in `git add` commandsKostis Anagnostopoulos2016-10-161-1/+2
| | | | | | | | | | | + Modify TCs - no main-code changes. + FIXed: + `TestSubmodule.test_git_submodules_and_add_sm_with_new_commit()` + TestDiff.test_diff_with_staged_file() - Cygwin TCs failing: - PY2: err: 12, fail: 2 - PY3: err: 11, fail: 2
* io, dif: #519: FIX DIFF freeze when reading from GILKostis Anagnostopoulos2016-09-281-10/+10
| | | | | | | | | | | | | | | + CAUSE: In Windows, Diffs freeze while reading Popen streams, probably buffers smaller; good-thin(TM) in this case because reading a Popen-proc from the launching-thread freezes GIL. The alternative to use `proc.communicate()` also relies on big buffers. + SOLUTION: Use `cmd.handle_process_output()` to consume Diff-proc streams. + Retroffited `handle_process_output()` code to support also byte-streams, both Threading(Windows) and Select/Poll (Posix) paths updated. - TODO: Unfortunately, `Diff._index_from_patch_format()` still slurps input; need to re-phrase header-regexes linewise to resolve it.
* test: Start using `ddt` library for TCsKostis Anagnostopoulos2016-09-281-12/+16
| | | | | + DataDriven TCs for identifying which separate case failed. + appveyor: rework matrix, conda3.4 cannot install in develop mode
* Win, #519: FIX with_rw_directory() to remove read-only dirsKostis Anagnostopoulos2016-09-281-1/+1
| | | | | + Stop using gitdb's respective helper. + Fix files chmod(555) which CANNOT DELETE on Windows (but do on Linux).
* win, #519: proc.terminate() instead of kill(SIGTERM)Kostis Anagnostopoulos2016-09-261-36/+39
| | | + test_diff: replace asserts with unittest-asserts.
* win: GC.collect on all TC.tearDown to fix appveyor hang runsKostis Anagnostopoulos2016-09-261-2/+6
| | | | | + Fixed the hangs at `test_git:TestGit.test_handle_process_output()`. [travisci skip]
* fix(diff): use explicit change-type if possibleSebastian Thiel2016-07-231-0/+9
| | | | | | | | | | That way, we do not have to figure the change type out by examining the diff object. It's implemented in a way that should yield more desireable results as we keep the change-type that git is providing us with. Fixes #493
* Store raw path bytes in Diff instanceskeep-raw-bytes-on-diffsVincent Driessen2016-06-141-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the following fields on Diff instances were assumed to be passed in as unicode strings: - `a_path` - `b_path` - `rename_from` - `rename_to` However, since Git natively records paths as bytes, these may potentially not have a valid unicode representation. This patch changes the Diff instance to instead take the following equivalent fields that should be raw bytes instead: - `a_rawpath` - `b_rawpath` - `raw_rename_from` - `raw_rename_to` NOTE ON BACKWARD COMPATIBILITY: The original `a_path`, `b_path`, etc. fields are still available as properties (rather than slots). These properties now dynamically decode the raw bytes into a unicode string (performing the potentially destructive operation of replacing invalid unicode chars by "�"'s). This means that all code using Diffs should remain backward compatible. The only exception is when people would manually construct Diff instances by calling the constructor directly, in which case they should now pass in bytes rather than unicode strings. See also the discussion on https://github.com/gitpython-developers/GitPython/pull/467
* Don't choke on (legitimately) invalidly encoded Unicode pathsfix-dont-choke-on-invalid-unicode-pathsVincent Driessen2016-06-061-6/+7
|
* Fix bug in diff parser outputfix-octal-escaped-path-parser-bugVincent Driessen2016-05-301-6/+7
| | | | | | | | | | | | The diff --patch parser was missing some edge case where Git would encode non-ASCII chars in path names as octals, but these weren't decoded properly. \360\237\222\251.txt Decoded via utf-8, that will return: 💩.txt
* Deprecate Diffable.rename for .renamed_fileSebastian Thiel2016-05-191-0/+2
| | | | Fixes #426
* 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 ;) )