Revision parsing

class pygit2.Repository(path=None, flags=0)
revparse(revspec: str) RevSpec

Parse a revision string for from, to, and intent. See man gitrevisions, or the documentation for git rev-parse for information on the syntax accepted.

revparse_ext(revision: str) tuple[Object, Reference]

Find a single object and intermediate reference, as specified by a revision string. See man gitrevisions, or the documentation for git rev-parse for information on the syntax accepted.

In some cases (@{<-n>} or <branchname>@{upstream}), the expression may point to an intermediate reference, which is returned in the second element of the result tuple.

revparse_single(revision: str) Object

Find an object, as specified by a revision string. See man gitrevisions, or the documentation for git rev-parse for information on the syntax accepted.

You can use any of the fancy <rev> forms supported by libgit2:

>>> commit = repo.revparse_single('HEAD^')
class pygit2.RevSpec

RevSpec object, output from Repository.revparse().

flags

A combination of GIT_REVPARSE_* flags which indicate the intended behavior of the spec passed to Repository.revparse()

from_object

From revision

to_object

To revision

Constants:

GIT_REVPARSE_SINGLE
GIT_REVPARSE_RANGE
GIT_REVPARSE_MERGE_BASE