@@ -1271,10 +1271,10 @@ def reset(self, commit: Union[Commit, 'Reference', str] = 'HEAD', working_tree:
12711271
12721272return self
12731273
1274- @default_index
1274+ # @ default_index, breaks typing for some reason, copied into function
12751275def diff (self ,
12761276other :Union [git_diff .Diffable .Index ,'IndexFile.Index' ,Treeish ,None ,object ]= git_diff .Diffable .Index ,
1277- paths :Union [str ,List [PathLike ],Tuple [PathLike , ...],None ]= None ,
1277+ paths :Union [PathLike ,List [PathLike ],Tuple [PathLike , ...],None ]= None ,
12781278create_patch :bool = False ,** kwargs :Any
12791279 )-> git_diff .DiffIndex :
12801280"""Diff this index against the working copy or a Tree or Commit object
@@ -1286,6 +1286,11 @@ def diff(self,
12861286 Will only work with indices that represent the default git index as
12871287 they have not been initialized with a stream.
12881288 """
1289+
1290+ # only run if we are the default repository index
1291+ if self ._file_path != self ._index_path ():
1292+ raise AssertionError (
1293+ "Cannot call %r on indices that do not represent the default git index" % self .diff ())
12891294# index against index is always empty
12901295if other is self .Index :
12911296return git_diff .DiffIndex ()