summaryrefslogtreecommitdiff
path: root/git/index/base.py
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-07-09 16:12:40 +0100
committerYobmod <yobmod@gmail.com>2021-07-09 16:12:40 +0100
commitb03af0547f5381cf4043a43acf533687d91f0ea1 (patch)
tree8512d68a2952b94963445ba5a3889784abc699dd /git/index/base.py
parent9bb630f03a276a4f1ecc6d6909f82dc90f533026 (diff)
downloadgitpython-b03af0547f5381cf4043a43acf533687d91f0ea1.tar.gz
Remove defsult_index decorator from diff() and do check within function. Breaks typechecking for some reason
Diffstat (limited to 'git/index/base.py')
-rw-r--r--git/index/base.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/git/index/base.py b/git/index/base.py
index 6738e223..149edf5a 100644
--- a/git/index/base.py
+++ b/git/index/base.py
@@ -1271,10 +1271,10 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
return self
- @ default_index
+ # @ default_index, breaks typing for some reason, copied into function
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,
+ paths: Union[PathLike, List[PathLike], Tuple[PathLike, ...], None] = None,
create_patch: bool = False, **kwargs: Any
) -> git_diff.DiffIndex:
"""Diff this index against the working copy or a Tree or Commit object
@@ -1286,6 +1286,11 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
Will only work with indices that represent the default git index as
they have not been initialized with a stream.
"""
+
+ # only run if we are the default repository index
+ if self._file_path != self._index_path():
+ raise AssertionError(
+ "Cannot call %r on indices that do not represent the default git index" % self.diff())
# index against index is always empty
if other is self.Index:
return git_diff.DiffIndex()