# Revision parsing

class pygit2.Repository(path: str | None = None, flags: RepositoryOpenFlag = RepositoryOpenFlag.DEFAULT)
  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 enums.RevSpecFlag constants indicating the intended behavior of the spec passed to Repository.revparse()

  from_object

    From revision

  to_object

    To revision

Constants:

pygit2.enums.RevSpecFlag.SINGLE

pygit2.enums.RevSpecFlag.RANGE

pygit2.enums.RevSpecFlag.MERGE_BASE