diff options
-rw-r--r-- | git/diff.py | 26 | ||||
-rw-r--r-- | git/index/base.py | 15 | ||||
-rw-r--r-- | git/objects/tree.py | 4 | ||||
-rw-r--r-- | git/remote.py | 2 |
4 files changed, 24 insertions, 23 deletions
diff --git a/git/diff.py b/git/diff.py index cb216299..71bbdf75 100644 --- a/git/diff.py +++ b/git/diff.py @@ -212,19 +212,19 @@ class DiffIndex(List[T_Diff]): if change_type not in self.change_type: raise ValueError("Invalid change type: %s" % change_type) - for diff in self: - if diff.change_type == change_type: - yield diff - elif change_type == "A" and diff.new_file: - yield diff - elif change_type == "D" and diff.deleted_file: - yield diff - elif change_type == "C" and diff.copied_file: - yield diff - elif change_type == "R" and diff.renamed: - yield diff - elif change_type == "M" and diff.a_blob and diff.b_blob and diff.a_blob != diff.b_blob: - yield diff + for diffidx in self: + if diffidx.change_type == change_type: + yield diffidx + elif change_type == "A" and diffidx.new_file: + yield diffidx + elif change_type == "D" and diffidx.deleted_file: + yield diffidx + elif change_type == "C" and diffidx.copied_file: + yield diffidx + elif change_type == "R" and diffidx.renamed: + yield diffidx + elif change_type == "M" and diffidx.a_blob and diffidx.b_blob and diffidx.a_blob != diffidx.b_blob: + yield diffidx # END for each diff diff --git a/git/index/base.py b/git/index/base.py index 1812faee..bd3dde99 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -41,7 +41,7 @@ from git.util import ( from gitdb.base import IStream from gitdb.db import MemoryDB -import git.diff as diff +import git.diff as git_diff import os.path as osp from .fun import ( @@ -88,7 +88,7 @@ Treeish = Union[Tree, Commit, str, bytes] __all__ = ('IndexFile', 'CheckoutError') -class IndexFile(LazyMixin, diff.Diffable, Serializable): +class IndexFile(LazyMixin, git_diff.Diffable, Serializable): """ Implements an Index that can be manipulated using a native implementation in @@ -575,8 +575,8 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): root_tree._cache = tree_items # type: ignore return root_tree - def _process_diff_args(self, args: List[Union[str, diff.Diffable, object]] - ) -> List[Union[str, diff.Diffable, object]]: + def _process_diff_args(self, args: List[Union[str, git_diff.Diffable, object]] + ) -> List[Union[str, git_diff.Diffable, object]]: try: args.pop(args.index(self)) except IndexError: @@ -1272,10 +1272,11 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): return self @ default_index - def diff(self, other: Union[diff.Diffable.Index, 'IndexFile.Index', Treeish, None, object] = diff.Diffable.Index, + def diff(self, + other: Union[git_diff.Diffable.Index, 'IndexFile.Index', Treeish, None, object] = git_diff.Diffable.Index, paths: Union[str, List[PathLike], Tuple[PathLike, ...], None] = None, create_patch: bool = False, **kwargs: Any - ) -> diff.DiffIndex: + ) -> git_diff.DiffIndex: """Diff this index against the working copy or a Tree or Commit object For a documentation of the parameters and return values, see, @@ -1287,7 +1288,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): """ # index against index is always empty if other is self.Index: - return diff.DiffIndex() + return git_diff.DiffIndex() # index against anything but None is a reverse diff with the respective # item. Handle existing -R flags properly. Transform strings to the object diff --git a/git/objects/tree.py b/git/objects/tree.py index 9d221652..4c2a02bf 100644 --- a/git/objects/tree.py +++ b/git/objects/tree.py @@ -5,7 +5,7 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php from git.util import IterableList, join_path -import git.diff as diff +import git.diff as git_diff from git.util import to_bin_sha from . import util @@ -180,7 +180,7 @@ class TreeModifier(object): #} END mutators -class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable): +class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable): """Tree objects represent an ordered list of Blobs and other Trees. diff --git a/git/remote.py b/git/remote.py index 739424ee..2998b987 100644 --- a/git/remote.py +++ b/git/remote.py @@ -469,7 +469,7 @@ class Remote(LazyMixin, IterableObj): def _config_section_name(self) -> str: return 'remote "%s"' % self.name - def _set_cache_(self, attr: str) -> Any: + def _set_cache_(self, attr: str) -> None: if attr == "_config_reader": # NOTE: This is cached as __getattr__ is overridden to return remote config values implicitly, such as # in print(r.pushurl) |