summaryrefslogtreecommitdiff
path: root/git/diff.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove checks for Python 2 and/or 3Harmon2020-02-081-10/+2
|
* Remove and replace compat.binary_typeHarmon2020-02-081-5/+4
|
* Merge branch 'fix/deepsource-issues' of https://github.com/imkaka/GitPython ↵Sebastian Thiel2019-10-291-4/+6
|\ | | | | | | into imkaka-fix/deepsource-issues
| * Merge branch 'master' into fix/deepsource-issuesAnil Khatri2019-10-231-10/+33
| |\
| * | fix Loop variable used outside the loopAnil Khatri2019-10-231-4/+6
| | |
* | | Check if submodule exists before referencingtanaga92019-10-281-1/+2
| |/ |/|
* | Fix #852 by tweaking regex to handle -R option to git diffJJ Graham2019-10-221-1/+1
| |
* | Initial stab at fixing diffs involving submodule changesJJ Graham2019-10-211-0/+8
| |
* | Satisfying flake8JJ Graham2019-10-191-2/+2
| |
* | Updating variable name to more accurately reflect contentsJJ Graham2019-10-191-3/+3
| |
* | Fixed new test for copied filesJJ Graham2019-10-191-2/+4
| |
* | Adding diff support for copied files, still working on testJJ Graham2019-10-191-8/+21
|/
* Fixed error in documentationSyoc2019-01-121-1/+0
| | | | | | The renamed_file function contains the following which ends up on readthedocs: :note: This property is deprecated, please use ``renamed_file`` instead. Removed the line
* Add change in type supportAurélien Matouillot2018-05-191-3/+9
|
* Get correcly rename change_type.Aurélien Matouillot2018-05-191-6/+14
| | | | Also store the rename score
* Rewrite unnecessary dict/list/tuple calls as literalsHugo2018-03-181-2/+2
|
* RF: primarily flake8 lints + minor RF to reduce duplication in PATHEXTYaroslav Halchenko2017-11-271-7/+7
| | | | | I did keep some "bare" except with catch all Exception: , while tried to disable flake8 complaints where clearly all exceptions are to be catched
* Merge branch 'cygwin' of https://github.com/ankostis/GitPython into ↵Sebastian Thiel2016-10-221-7/+6
|\ | | | | | | ankostis-cygwin
| * src: reduce needless deps to `gitdb.util`Kostis Anagnostopoulos2016-10-161-7/+6
| |
* | Fix some typosSantiago Castro2016-10-201-7/+7
|/
* Proc, #519: Rework error-exc msgs & log thread-pumps errorsKostis Anagnostopoulos2016-09-281-2/+2
| | | | | + No WindowsError exception. + Add `test_exc.py` for unicode issues. + Single-arg for decoding-streams in pump-func.
* io, dif: #519: FIX DIFF freeze when reading from GILKostis Anagnostopoulos2016-09-281-11/+21
| | | | | | | | | | | | | | | + 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.
* fix(diff): use explicit change-type if possibleSebastian Thiel2016-07-231-5/+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-17/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-4/+4
|
* Fix bug in diff parser outputfix-octal-escaped-path-parser-bugVincent Driessen2016-05-301-2/+15
| | | | | | | | | | | | 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-1/+10
| | | | Fixes #426
* Python 3 compat fixesVincent Driessen2016-04-201-1/+4
| | | | Specifically "string_escape" does not exist as an encoding anymore.
* Fix diff patch parser for paths with unsafe charsVincent Driessen2016-04-191-13/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Fix order of regex partsVincent Driessen2016-04-191-3/+4
| | | | | When both old/new mode and rename from/to lines are found, they will appear in different order.
* Fix regexVincent Driessen2016-04-191-2/+2
| | | | | | This makes sure we're not matching a \n here by accident. It's now almost the same as the original that used \S+, except that spaces are not eaten at the end of the string (for files that end in a space).
* Make diff patch parsing more reliableVincent Driessen2016-04-191-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Perform diff-tree recursively to have the same output as diffVincent Driessen2016-04-141-0/+2
|
* Export NULL_TREEVincent Driessen2016-04-141-1/+1
|
* Use a special object rather than a stringVincent Driessen2016-04-141-2/+5
| | | | | This alternative API does not prevent users from using the valid treeish "root".
* Support "root" as a special value in .diff() callsVincent Driessen2016-04-141-4/+10
| | | | This enabled getting diff patches for root commits.
* Split diff line by '\t' for metadata and pathJonathan Chu2016-03-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | 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.
* fix(diff): mode-assertions now deal with 0Sebastian Thiel2015-07-291-2/+2
| | | | | | | | 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
* Store path attribute on Diff objectJames E. Blair2015-03-021-2/+7
| | | | | | | | | 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.
* Overhauled all tutorials, and placed them in a unit-test.Sebastian Thiel2015-01-221-3/+1
| | | | | | That way they are protected from regression. Fixes #239
* Now Diff.__str__ works correctly in all python versions.Sebastian Thiel2015-01-091-7/+29
| | | | | | | | | 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-2/+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-10/+20
| | | | Related to #74
* Added support for rename detection in raw mode (which is the default).Sebastian Thiel2015-01-081-6/+8
| | | | Fixes #36
* Added assertion to better detect diff issues.Sebastian Thiel2015-01-081-0/+1
| | | | | | | Helps fixing #35 Also, the production status was changed to 'stable', which should have been done much earlier.
* test_diff worksSebastian Thiel2015-01-051-1/+4
|
* test_commit works once againSebastian Thiel2015-01-051-1/+1
|
* initial set of adjustments to make (most) imports work.Sebastian Thiel2015-01-041-3/+3
| | | | More to come, especially when it's about strings
* Bumped version, updated changelog, reduced code smellSebastian Thiel2015-01-041-3/+2
| | | | | There is more work to do though, as many imports are still incorrect. Also, there are still print statements
* Applied autopep8Sebastian Thiel2014-11-191-2/+2
| | | | | Commandline was autopep8 -j 8 --max-line-length 120 --in-place --recursive --exclude "*gitdb*,*async*" git/