summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Driessen <me@nvie.com>2016-04-14 12:43:54 +0200
committerVincent Driessen <me@nvie.com>2016-04-14 12:46:17 +0200
commit82b533f86cf86c96a16f96c815533bdda0585f48 (patch)
tree11bef9c802bae05c9e3a486904098b8ce5b0ef1f
parentaae2a7328a4d28077a4b4182b4f36f19c953765b (diff)
downloadgitpython-82b533f86cf86c96a16f96c815533bdda0585f48.tar.gz
Use a special object rather than a string
This alternative API does not prevent users from using the valid treeish "root".
-rw-r--r--git/diff.py7
1 files 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: