Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit82b533f

Browse files
committed
Use a special object rather than a string
This alternative API does not prevent users from using the valid treeish"root".
1 parentaae2a73 commit82b533f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎git/diff.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
__all__= ('Diffable','DiffIndex','Diff')
2020

21+
# Special object to compare against the empty tree in diffs
22+
NULL_TREE=object()
23+
2124

2225
classDiffable(object):
2326

@@ -49,7 +52,7 @@ def diff(self, other=Index, paths=None, create_patch=False, **kwargs):
4952
If None, we will be compared to the working tree.
5053
If Treeish, it will be compared against the respective tree
5154
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.
5356
It defaults to Index to assure the method will not by-default fail
5457
on bare repositories.
5558
@@ -91,7 +94,7 @@ def diff(self, other=Index, paths=None, create_patch=False, **kwargs):
9194
diff_cmd=self.repo.git.diff
9295
ifotherisself.Index:
9396
args.insert(0,'--cached')
94-
elifother=='root':
97+
elifotherisNULL_TREE:
9598
args.insert(0,'--root')
9699
diff_cmd=self.repo.git.diff_tree
97100
elifotherisnotNone:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp