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

Method set_head

pygit2/repository.py:516–535  ·  view source on GitHub ↗

Set HEAD to point to the given target. Parameters: target The new target for HEAD. Can be a string or Oid (to detach).

(self, target: Oid | str)

Source from the content-addressed store, hash-verified

514 # Setting HEAD
515 #
516 def set_head(self, target: Oid | str) -> None:
517 """
518 Set HEAD to point to the given target.
519
520 Parameters:
521
522 target
523 The new target for HEAD. Can be a string or Oid (to detach).
524 """
525
526 if isinstance(target, Oid):
527 oid = ffi.new('git_oid *')
528 ffi.buffer(oid)[:] = target.raw[:]
529 err = C.git_repository_set_head_detached(self._repo, oid)
530 check_error(err)
531 return
532
533 # if it's a string, then it's a reference name
534 err = C.git_repository_set_head(self._repo, to_bytes(target))
535 check_error(err)
536
537 #
538 # Diff

Callers 2

checkoutMethod · 0.95
test_set_headFunction · 0.80

Calls 2

check_errorFunction · 0.85
to_bytesFunction · 0.85

Tested by 1

test_set_headFunction · 0.64