Skip to content

Commit 7c6ae2b

Browse files
committed
Try to distinguation git.diff module from diff.Diff.diff and diff.Daffable.diff()
1 parent 6271660 commit 7c6ae2b

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

‎git/diff.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,19 @@ def iter_change_type(self, change_type: Lit_change_type) -> Iterator[T_Diff]:
212212
if change_type not in self.change_type:
213213
raise ValueError("Invalid change type: %s" % change_type)
214214

215-
for diff in self:
216-
if diff.change_type == change_type:
217-
yield diff
218-
elif change_type == "A" and diff.new_file:
219-
yield diff
220-
elif change_type == "D" and diff.deleted_file:
221-
yield diff
222-
elif change_type == "C" and diff.copied_file:
223-
yield diff
224-
elif change_type == "R" and diff.renamed:
225-
yield diff
226-
elif change_type == "M" and diff.a_blob and diff.b_blob and diff.a_blob != diff.b_blob:
227-
yield diff
215+
for diffidx in self:
216+
if diffidx.change_type == change_type:
217+
yield diffidx
218+
elif change_type == "A" and diffidx.new_file:
219+
yield diffidx
220+
elif change_type == "D" and diffidx.deleted_file:
221+
yield diffidx
222+
elif change_type == "C" and diffidx.copied_file:
223+
yield diffidx
224+
elif change_type == "R" and diffidx.renamed:
225+
yield diffidx
226+
elif change_type == "M" and diffidx.a_blob and diffidx.b_blob and diffidx.a_blob != diffidx.b_blob:
227+
yield diffidx
228228
# END for each diff
229229

230230

‎git/index/base.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from gitdb.base import IStream
4242
from gitdb.db import MemoryDB
4343

44-
import git.diff as diff
44+
import git.diff as git_diff
4545
import os.path as osp
4646

4747
from .fun import (
@@ -88,7 +88,7 @@
8888
__all__ = ('IndexFile', 'CheckoutError')
8989

9090

91-
class IndexFile(LazyMixin, diff.Diffable, Serializable):
91+
class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
9292

9393
"""
9494
Implements an Index that can be manipulated using a native implementation in
@@ -575,8 +575,8 @@ def write_tree(self) -> Tree:
575575
root_tree._cache = tree_items # type: ignore
576576
return root_tree
577577

578-
def _process_diff_args(self, args: List[Union[str, diff.Diffable, object]]
579-
) -> List[Union[str, diff.Diffable, object]]:
578+
def _process_diff_args(self, args: List[Union[str, git_diff.Diffable, object]]
579+
) -> List[Union[str, git_diff.Diffable, object]]:
580580
try:
581581
args.pop(args.index(self))
582582
except IndexError:
@@ -1272,10 +1272,11 @@ def reset(self, commit: Union[Commit, 'Reference', str] = 'HEAD', working_tree:
12721272
return self
12731273

12741274
@ default_index
1275-
def diff(self, other: Union[diff.Diffable.Index, 'IndexFile.Index', Treeish, None, object] = diff.Diffable.Index,
1275+
def diff(self,
1276+
other: Union[git_diff.Diffable.Index, 'IndexFile.Index', Treeish, None, object] = git_diff.Diffable.Index,
12761277
paths: Union[str, List[PathLike], Tuple[PathLike, ...], None] = None,
12771278
create_patch: bool = False, **kwargs: Any
1278-
) -> diff.DiffIndex:
1279+
) -> git_diff.DiffIndex:
12791280
"""Diff this index against the working copy or a Tree or Commit object
12801281
12811282
For a documentation of the parameters and return values, see,
@@ -1287,7 +1288,7 @@ def diff(self, other: Union[diff.Diffable.Index, 'IndexFile.Index', Treeish, Non
12871288
"""
12881289
# index against index is always empty
12891290
if other is self.Index:
1290-
return diff.DiffIndex()
1291+
return git_diff.DiffIndex()
12911292

12921293
# index against anything but None is a reverse diff with the respective
12931294
# item. Handle existing -R flags properly. Transform strings to the object

‎git/objects/tree.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
from git.util import IterableList, join_path
8-
import git.diff as diff
8+
import git.diff as git_diff
99
from git.util import to_bin_sha
1010

1111
from . import util
@@ -180,7 +180,7 @@ def __delitem__(self, name: str) -> None:
180180
#} END mutators
181181

182182

183-
class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
183+
class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable):
184184

185185
"""Tree objects represent an ordered list of Blobs and other Trees.
186186

‎git/remote.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def __getattr__(self, attr: str) -> Any:
469469
def _config_section_name(self) -> str:
470470
return 'remote "%s"' % self.name
471471

472-
def _set_cache_(self, attr: str) -> Any:
472+
def _set_cache_(self, attr: str) -> None:
473473
if attr == "_config_reader":
474474
# NOTE: This is cached as __getattr__ is overridden to return remote config values implicitly, such as
475475
# in print(r.pushurl)

0 commit comments

Comments
 (0)