| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,9 @@ | |||
| 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 | class Diffable(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 | - If the string 'root', it will compare the empty tree against this tree. | ||
| 55 | + If git.NULL_TREE, it will compare against the 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 | if other is self.Index: | |
| 93 | 96 | args.insert(0, '--cached') | |
| 94 | - elif other == 'root': | ||
| 97 | + elif other is NULL_TREE: | ||
| 95 | 98 | args.insert(0, '--root') | |
| 96 | 99 | diff_cmd = self.repo.git.diff_tree | |
| 97 | 100 | elif other is not None: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments