MCPcopy Create free account
hub / github.com/libgit2/pygit2 / __whatever_to_tree_or_blob

Method __whatever_to_tree_or_blob

pygit2/repository.py:540–561  ·  view source on GitHub ↗
(self, obj)

Source from the content-addressed store, hash-verified

538 # Diff
539 #
540 def __whatever_to_tree_or_blob(self, obj):
541 if obj is None:
542 return None
543
544 # If it's a string, then it has to be valid revspec
545 if isinstance(obj, str) or isinstance(obj, bytes):
546 obj = self.revparse_single(obj)
547 elif isinstance(obj, Oid):
548 obj = self[obj]
549
550 # First we try to get to a blob
551 try:
552 obj = obj.peel(Blob)
553 except Exception:
554 # And if that failed, try to get a tree, raising a type
555 # error if that still doesn't work
556 try:
557 obj = obj.peel(Tree)
558 except Exception:
559 raise TypeError(f'unexpected "{type(obj)}"')
560
561 return obj
562
563 @overload
564 def diff(

Callers 1

diffMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected