From 9ae1f213e1b99638ba685f58d489c0afa90a3991 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Tue, 12 Apr 2016 15:54:41 +0200 Subject: Pass through the $HOME env var to the tox env --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index da624b5e..b2f7e27e 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ envlist = py26,py27,py33,py34,flake8 commands = nosetests {posargs} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt +passenv = HOME [testenv:cover] commands = nosetests --with-coverage {posargs} -- cgit v1.2.1 From 83156b950bb76042198950f2339cb940f1170ee2 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Tue, 12 Apr 2016 16:08:13 +0200 Subject: Add Python 3.5 env --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index b2f7e27e..9f03872b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26,py27,py33,py34,flake8 +envlist = py26,py27,py33,py34,py35,flake8 [testenv] commands = nosetests {posargs} -- cgit v1.2.1 From 5de21c7fa2bdd5cd50c4f62ba848af54589167d0 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Tue, 12 Apr 2016 15:55:01 +0200 Subject: Support "root" as a special value in .diff() calls This enabled getting diff patches for root commits. --- git/diff.py | 14 ++++++++++---- git/test/fixtures/diff_initial | 10 ++++++++++ git/test/test_diff.py | 17 ++++++++++++++++- 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 git/test/fixtures/diff_initial diff --git a/git/diff.py b/git/diff.py index 062220df..eada73b9 100644 --- a/git/diff.py +++ b/git/diff.py @@ -49,6 +49,7 @@ class Diffable(object): If None, we will be compared to the working tree. If Treeish, it will be compared against the respective tree If Index ( type ), it will be compared against the index. + If the string 'root', it will compare the empty tree against this tree. It defaults to Index to assure the method will not by-default fail on bare repositories. @@ -87,10 +88,15 @@ class Diffable(object): if paths is not None and not isinstance(paths, (tuple, list)): paths = [paths] - if other is not None and other is not self.Index: - args.insert(0, other) + diff_cmd = self.repo.git.diff if other is self.Index: - args.insert(0, "--cached") + args.insert(0, '--cached') + elif other == 'root': + args.insert(0, '--root') + diff_cmd = self.repo.git.diff_tree + elif other is not None: + args.insert(0, other) + diff_cmd = self.repo.git.diff_tree args.insert(0, self) @@ -101,7 +107,7 @@ class Diffable(object): # END paths handling kwargs['as_process'] = True - proc = self.repo.git.diff(*self._process_diff_args(args), **kwargs) + proc = diff_cmd(*self._process_diff_args(args), **kwargs) diff_method = Diff._index_from_raw_format if create_patch: diff --git a/git/test/fixtures/diff_initial b/git/test/fixtures/diff_initial new file mode 100644 index 00000000..6037c677 --- /dev/null +++ b/git/test/fixtures/diff_initial @@ -0,0 +1,10 @@ +--- /dev/null ++++ b/CHANGES +@@ -0,0 +1,7 @@ ++======= ++CHANGES ++======= ++ ++0.1.0 ++===== ++initial release diff --git a/git/test/test_diff.py b/git/test/test_diff.py index b0d98248..136e6fd9 100644 --- a/git/test/test_diff.py +++ b/git/test/test_diff.py @@ -128,6 +128,21 @@ class TestDiff(TestBase): assert res[0].deleted_file assert res[0].b_path == '' + def test_diff_initial_commit(self): + initial_commit = self.rorepo.commit('33ebe7acec14b25c5f84f35a664803fcab2f7781') + + # Without creating a patch... + diff_index = initial_commit.diff('root') + assert diff_index[0].b_path == 'CHANGES' + assert diff_index[0].new_file + assert diff_index[0].diff == '' + + # ...and with creating a patch + diff_index = initial_commit.diff('root', create_patch=True) + assert diff_index[0].b_path == 'CHANGES' + assert diff_index[0].new_file + assert diff_index[0].diff == fixture('diff_initial') + def test_diff_patch_format(self): # test all of the 'old' format diffs for completness - it should at least # be able to deal with it @@ -149,7 +164,7 @@ class TestDiff(TestBase): diff_item = commit.tree # END use tree every second item - for other in (None, commit.Index, commit.parents[0]): + for other in (None, 'root', commit.Index, commit.parents[0]): for paths in (None, "CHANGES", ("CHANGES", "lib")): for create_patch in range(2): diff_index = diff_item.diff(other=other, paths=paths, create_patch=create_patch) -- cgit v1.2.1 From aae2a7328a4d28077a4b4182b4f36f19c953765b Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Thu, 14 Apr 2016 12:38:53 +0200 Subject: Fix comment --- git/compat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git/compat.py b/git/compat.py index 146bfd4b..1630fcd5 100644 --- a/git/compat.py +++ b/git/compat.py @@ -56,7 +56,9 @@ def safe_decode(s): return s elif isinstance(s, six.binary_type): if PRE_PY27: - return s.decode(defenc) # we're screwed + # Python 2.6 does not support the `errors` argument, so we cannot + # control the replacement of unsafe chars in it. + return s.decode(defenc) else: return s.decode(defenc, errors='replace') raise TypeError('Expected bytes or text, but got %r' % (s,)) -- cgit v1.2.1 From 82b533f86cf86c96a16f96c815533bdda0585f48 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Thu, 14 Apr 2016 12:43:54 +0200 Subject: Use a special object rather than a string This alternative API does not prevent users from using the valid treeish "root". --- git/diff.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/git/diff.py b/git/diff.py index eada73b9..67d1986c 100644 --- a/git/diff.py +++ b/git/diff.py @@ -18,6 +18,9 @@ from git.compat import ( __all__ = ('Diffable', 'DiffIndex', 'Diff') +# Special object to compare against the empty tree in diffs +NULL_TREE = object() + class Diffable(object): @@ -49,7 +52,7 @@ class Diffable(object): If None, we will be compared to the working tree. If Treeish, it will be compared against the respective tree If Index ( type ), it will be compared against the index. - If the string 'root', it will compare the empty tree against this tree. + If git.NULL_TREE, it will compare against the empty tree. It defaults to Index to assure the method will not by-default fail on bare repositories. @@ -91,7 +94,7 @@ class Diffable(object): diff_cmd = self.repo.git.diff if other is self.Index: args.insert(0, '--cached') - elif other == 'root': + elif other is NULL_TREE: args.insert(0, '--root') diff_cmd = self.repo.git.diff_tree elif other is not None: -- cgit v1.2.1 From 07b124c118942bc1eec3a21601ee38de40a2ba0e Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Thu, 14 Apr 2016 12:22:28 +0200 Subject: Update changelog for next release --- doc/source/changes.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/source/changes.rst b/doc/source/changes.rst index 84dd8dfe..dfd0a4a4 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -2,6 +2,13 @@ Changelog ========= +1.0.3 - Fixes +============= + +* `Commit.diff()` now supports diffing the root commit via `Commit.diff(NULL_TREE)`. +* `Repo.blame()` now respects `incremental=True`, supporting incremental blames. Incremental blames are slightly faster since they don't include the file's contents in them. + + 1.0.2 - Fixes ============= -- cgit v1.2.1 From c042f56fc801235b202ae43489787a6d479cd277 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Thu, 14 Apr 2016 13:23:35 +0200 Subject: Export NULL_TREE --- git/diff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/diff.py b/git/diff.py index 67d1986c..7a75ffed 100644 --- a/git/diff.py +++ b/git/diff.py @@ -16,7 +16,7 @@ from git.compat import ( ) -__all__ = ('Diffable', 'DiffIndex', 'Diff') +__all__ = ('Diffable', 'DiffIndex', 'Diff', 'NULL_TREE') # Special object to compare against the empty tree in diffs NULL_TREE = object() -- cgit v1.2.1 From 1875885485e7c78d34fd56b8db69d8b3f0df830c Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Thu, 14 Apr 2016 15:55:21 +0200 Subject: Fix test cases --- git/test/test_diff.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/git/test/test_diff.py b/git/test/test_diff.py index 136e6fd9..56e395fd 100644 --- a/git/test/test_diff.py +++ b/git/test/test_diff.py @@ -21,7 +21,8 @@ from git import ( Repo, GitCommandError, Diff, - DiffIndex + DiffIndex, + NULL_TREE, ) @@ -132,13 +133,13 @@ class TestDiff(TestBase): initial_commit = self.rorepo.commit('33ebe7acec14b25c5f84f35a664803fcab2f7781') # Without creating a patch... - diff_index = initial_commit.diff('root') + diff_index = initial_commit.diff(NULL_TREE) assert diff_index[0].b_path == 'CHANGES' assert diff_index[0].new_file assert diff_index[0].diff == '' # ...and with creating a patch - diff_index = initial_commit.diff('root', create_patch=True) + diff_index = initial_commit.diff(NULL_TREE, create_patch=True) assert diff_index[0].b_path == 'CHANGES' assert diff_index[0].new_file assert diff_index[0].diff == fixture('diff_initial') @@ -164,7 +165,7 @@ class TestDiff(TestBase): diff_item = commit.tree # END use tree every second item - for other in (None, 'root', commit.Index, commit.parents[0]): + for other in (None, NULL_TREE, commit.Index, commit.parents[0]): for paths in (None, "CHANGES", ("CHANGES", "lib")): for create_patch in range(2): diff_index = diff_item.diff(other=other, paths=paths, create_patch=create_patch) -- cgit v1.2.1 From 6bdaa463f7c73d30d75d7ea954dd3c5c0c31617b Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Thu, 14 Apr 2016 15:58:27 +0200 Subject: Drop dependency on six --- git/compat.py | 7 ++++--- git/repo/base.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/git/compat.py b/git/compat.py index 1630fcd5..f018ef33 100644 --- a/git/compat.py +++ b/git/compat.py @@ -8,7 +8,6 @@ # flake8: noqa import sys -import six from gitdb.utils.compat import ( PY3, @@ -34,6 +33,7 @@ if PY3: return bytes([n]) def mviter(d): return d.values() + range = xrange unicode = str else: FileType = file @@ -44,6 +44,7 @@ else: byte_ord = ord bchr = chr unicode = unicode + range = xrange def mviter(d): return d.itervalues() @@ -52,9 +53,9 @@ PRE_PY27 = sys.version_info < (2, 7) def safe_decode(s): """Safely decodes a binary string to unicode""" - if isinstance(s, six.text_type): + if isinstance(s, unicode): return s - elif isinstance(s, six.binary_type): + elif isinstance(s, bytes): if PRE_PY27: # Python 2.6 does not support the `errors` argument, so we cannot # control the replacement of unsafe chars in it. diff --git a/git/repo/base.py b/git/repo/base.py index 9d013230..f74e0b59 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -54,12 +54,12 @@ from git.compat import ( defenc, PY3, safe_decode, + range, ) import os import sys import re -from six.moves import range DefaultDBType = GitCmdObjectDB if sys.version_info[:2] < (2, 5): # python 2.4 compatiblity -- cgit v1.2.1 From 28afef550371cd506db2045cbdd89d895bec5091 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Thu, 14 Apr 2016 17:31:17 +0200 Subject: Perform diff-tree recursively to have the same output as diff --- git/diff.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git/diff.py b/git/diff.py index 7a75ffed..de3aa1e8 100644 --- a/git/diff.py +++ b/git/diff.py @@ -95,9 +95,11 @@ class Diffable(object): if other is self.Index: args.insert(0, '--cached') elif other is NULL_TREE: + args.insert(0, '-r') # recursive diff-tree args.insert(0, '--root') diff_cmd = self.repo.git.diff_tree elif other is not None: + args.insert(0, '-r') # recursive diff-tree args.insert(0, other) diff_cmd = self.repo.git.diff_tree -- cgit v1.2.1 From 76e19e4221684f24ef881415ec6ccb6bab6eb8e8 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 19 Apr 2016 08:35:06 +0200 Subject: feat(py-support): drop py2.6 support In response to https://github.com/gitpython-developers/GitPython/pull/408/files/5de21c7fa2bdd5cd50c4f62ba848af54589167d0..aae2a7328a4d28077a4b4182b4f36f19c953765b#r59722704 --- .travis.yml | 1 - doc/source/changes.rst | 4 ++++ setup.py | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e367fff..2c720821 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: python python: - - "2.6" - "2.7" - "3.3" - "3.4" diff --git a/doc/source/changes.rst b/doc/source/changes.rst index 84dd8dfe..23954c7f 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -2,6 +2,10 @@ Changelog ========= +1.0.3 - Fixes +============= +* IMPORTANT: This release drops support for python 2.6, which is officially deprecated by the python maintainers. + 1.0.2 - Fixes ============= diff --git a/setup.py b/setup.py index d35301ae..868f98f0 100755 --- a/setup.py +++ b/setup.py @@ -110,7 +110,6 @@ GitPython is a python library used to interact with Git repositories""", "Operating System :: MacOS :: MacOS X", "Programming Language :: Python", "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", -- cgit v1.2.1 From 722473e86e64405ac5eb9cb43133f8953d6c65d0 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Tue, 19 Apr 2016 21:34:24 +0200 Subject: Remove Python 2.6 hack Since support was dropped. --- git/compat.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/git/compat.py b/git/compat.py index f018ef33..7bd8e494 100644 --- a/git/compat.py +++ b/git/compat.py @@ -48,20 +48,13 @@ else: def mviter(d): return d.itervalues() -PRE_PY27 = sys.version_info < (2, 7) - def safe_decode(s): """Safely decodes a binary string to unicode""" if isinstance(s, unicode): return s elif isinstance(s, bytes): - if PRE_PY27: - # Python 2.6 does not support the `errors` argument, so we cannot - # control the replacement of unsafe chars in it. - return s.decode(defenc) - else: - return s.decode(defenc, errors='replace') + return s.decode(defenc, errors='replace') raise TypeError('Expected bytes or text, but got %r' % (s,)) -- cgit v1.2.1