aboutsummaryrefslogtreecommitdiff
path: root/git/diff.py
AgeCommit message (Collapse)Author
2020-02-08Remove checks for Python 2 and/or 3Harmon
2020-02-08Remove and replace compat.binary_typeHarmon
2019-10-29Merge branch 'fix/deepsource-issues' of https://github.com/imkaka/GitPython ↵Sebastian Thiel
into imkaka-fix/deepsource-issues
2019-10-28Check if submodule exists before referencingtanaga9
2019-10-23Merge branch 'master' into fix/deepsource-issuesAnil Khatri
2019-10-23fix Loop variable used outside the loopAnil Khatri
2019-10-22Fix #852 by tweaking regex to handle -R option to git diffJJ Graham
2019-10-21Initial stab at fixing diffs involving submodule changesJJ Graham
2019-10-19Satisfying flake8JJ Graham
2019-10-19Updating variable name to more accurately reflect contentsJJ Graham
2019-10-19Fixed new test for copied filesJJ Graham
2019-10-19Adding diff support for copied files, still working on testJJ Graham
2019-01-12Fixed error in documentationSyoc
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
2018-05-19Add change in type supportAurélien Matouillot
2018-05-19Get correcly rename change_type.Aurélien Matouillot
Also store the rename score
2018-03-18Rewrite unnecessary dict/list/tuple calls as literalsHugo
2017-11-27RF: primarily flake8 lints + minor RF to reduce duplication in PATHEXTYaroslav Halchenko
I did keep some "bare" except with catch all Exception: , while tried to disable flake8 complaints where clearly all exceptions are to be catched
2016-10-22Merge branch 'cygwin' of https://github.com/ankostis/GitPython into ↵Sebastian Thiel
ankostis-cygwin
2016-10-20Fix some typosSantiago Castro
2016-10-16src: reduce needless deps to `gitdb.util`Kostis Anagnostopoulos
2016-09-28Proc, #519: Rework error-exc msgs & log thread-pumps errorsKostis Anagnostopoulos
+ No WindowsError exception. + Add `test_exc.py` for unicode issues. + Single-arg for decoding-streams in pump-func.
2016-09-28io, dif: #519: FIX DIFF freeze when reading from GILKostis Anagnostopoulos
+ 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.
2016-07-23fix(diff): use explicit change-type if possibleSebastian Thiel
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
2016-06-14Store raw path bytes in Diff instancesVincent Driessen
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
2016-06-06Don't choke on (legitimately) invalidly encoded Unicode pathsVincent Driessen
2016-05-30Fix bug in diff parser outputVincent Driessen
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
2016-05-19Deprecate Diffable.rename for .renamed_fileSebastian Thiel
Fixes #426
2016-04-20Python 3 compat fixesVincent Driessen
Specifically "string_escape" does not exist as an encoding anymore.
2016-04-19Fix diff patch parser for paths with unsafe charsVincent Driessen
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).
2016-04-19Fix order of regex partsVincent Driessen
When both old/new mode and rename from/to lines are found, they will appear in different order.
2016-04-19Fix regexVincent Driessen
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).
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/