|
18 | 18 |
|
19 | 19 | __all__= ('Diffable','DiffIndex','Diff')
|
20 | 20 |
|
| 21 | +# Special object to compare against the empty tree in diffs |
| 22 | +NULL_TREE=object() |
| 23 | + |
21 | 24 |
|
22 | 25 | classDiffable(object):
|
23 | 26 |
|
@@ -49,7 +52,7 @@ def diff(self, other=Index, paths=None, create_patch=False, **kwargs):
|
49 | 52 | If None, we will be compared to the working tree.
|
50 | 53 | If Treeish, it will be compared against the respective tree
|
51 | 54 | If Index ( type ), it will be compared against the index.
|
52 |
| - Ifthe string 'root', it will compare the empty tree against this tree. |
| 55 | + Ifgit.NULL_TREE, it will compareagainstthe empty tree. |
53 | 56 | It defaults to Index to assure the method will not by-default fail
|
54 | 57 | on bare repositories.
|
55 | 58 |
|
@@ -91,7 +94,7 @@ def diff(self, other=Index, paths=None, create_patch=False, **kwargs):
|
91 | 94 | diff_cmd=self.repo.git.diff
|
92 | 95 | ifotherisself.Index:
|
93 | 96 | args.insert(0,'--cached')
|
94 |
| -elifother=='root': |
| 97 | +elifotherisNULL_TREE: |
95 | 98 | args.insert(0,'--root')
|
96 | 99 | diff_cmd=self.repo.git.diff_tree
|
97 | 100 | elifotherisnotNone:
|
|