# General

Top level constants and exceptions from the library.

## Version

The following constants provide information about the version of the libgit2 library that has been built against. The version number has a `MAJOR.MINOR.REVISION` format.

LIBGIT2_VER_MAJOR

  Integer value of the major version number. For example, for the version `0.26.0`:

      >>> print(pygit2.LIBGIT2_VER_MAJOR)
      0

LIBGIT2_VER_MINOR

  Integer value of the minor version number. For example, for the version `0.26.0`:

      >>> print(pygit2.LIBGIT2_VER_MINOR)
      26

LIBGIT2_VER_REVISION

  Integer value of the revision version number. For example, for the version `0.26.0`:

      >>> print(pygit2.LIBGIT2_VER_REVISION)
      0

LIBGIT2_VER

  Tuple value of the revision version numbers. For example, for the version `0.26.0`:

      >>> print(pygit2.LIBGIT2_VER)
      (0, 26, 0)

LIBGIT2_VERSION

  The libgit2 version number as a string:

      >>> print(pygit2.LIBGIT2_VERSION)
      '0.26.0'

## Options

pygit2.option(option_type: Literal[Option.GET_MWINDOW_SIZE, Option.GET_MWINDOW_MAPPED_LIMIT, Option.GET_MWINDOW_FILE_LIMIT]) → int
pygit2.option(option_type: Literal[Option.SET_MWINDOW_SIZE, Option.SET_MWINDOW_MAPPED_LIMIT, Option.SET_MWINDOW_FILE_LIMIT, Option.SET_CACHE_MAX_SIZE], arg1: int) → None
pygit2.option(option_type: Literal[Option.GET_SEARCH_PATH], arg1: ConfigLevel) → str
pygit2.option(option_type: Literal[Option.SET_SEARCH_PATH], arg1: ConfigLevel, arg2: str) → None
pygit2.option(option_type: Literal[Option.SET_CACHE_OBJECT_LIMIT], arg1: ObjectType, arg2: int) → None
pygit2.option(option_type: Literal[Option.GET_CACHED_MEMORY]) → tuple[int, int]
pygit2.option(option_type: Literal[Option.SET_SSL_CERT_LOCATIONS], arg1: str | bytes | None, arg2: str | bytes | None) → None
pygit2.option(option_type: Literal[Option.ENABLE_CACHING, Option.ENABLE_STRICT_OBJECT_CREATION, Option.ENABLE_STRICT_SYMBOLIC_REF_CREATION, Option.ENABLE_OFS_DELTA, Option.ENABLE_FSYNC_GITDIR, Option.ENABLE_STRICT_HASH_VERIFICATION, Option.ENABLE_UNSAVED_INDEX_SAFETY, Option.DISABLE_PACK_KEEP_FILE_CHECKS, Option.SET_OWNER_VALIDATION], arg1: bool) → None
pygit2.option(option_type: Literal[Option.GET_OWNER_VALIDATION]) → bool
pygit2.option(option_type: Literal[Option.GET_TEMPLATE_PATH, Option.GET_USER_AGENT, Option.GET_HOMEDIR, Option.GET_USER_AGENT_PRODUCT]) → str | None
pygit2.option(option_type: Literal[Option.SET_TEMPLATE_PATH, Option.SET_USER_AGENT, Option.SET_SSL_CIPHERS, Option.SET_HOMEDIR, Option.SET_USER_AGENT_PRODUCT], arg1: str | bytes) → None
pygit2.option(option_type: Literal[Option.GET_WINDOWS_SHAREMODE, Option.GET_PACK_MAX_OBJECTS, Option.GET_SERVER_CONNECT_TIMEOUT, Option.GET_SERVER_TIMEOUT]) → int
pygit2.option(option_type: Literal[Option.SET_WINDOWS_SHAREMODE, Option.SET_PACK_MAX_OBJECTS, Option.ENABLE_HTTP_EXPECT_CONTINUE, Option.SET_ODB_PACKED_PRIORITY, Option.SET_ODB_LOOSE_PRIORITY, Option.SET_SERVER_CONNECT_TIMEOUT, Option.SET_SERVER_TIMEOUT], arg1: int) → None
pygit2.option(option_type: Literal[Option.GET_EXTENSIONS]) → list[str]
pygit2.option(option_type: Literal[Option.SET_EXTENSIONS], arg1: list[str], arg2: int) → None
pygit2.option(option_type: Literal[Option.ADD_SSL_X509_CERT], arg1: str | bytes) → None
pygit2.option(option_type: Option, arg1: ~typing.Any = <object object>, arg2: ~typing.Any = <object object>) → Any

  Get or set a libgit2 option.

  Parameters:

  GIT_OPT_GET_SEARCH_PATH, level

    Get the config search path for the given level.

  GIT_OPT_SET_SEARCH_PATH, level, path

    Set the config search path for the given level.

  GIT_OPT_GET_MWINDOW_SIZE

    Get the maximum mmap window size.

  GIT_OPT_SET_MWINDOW_SIZE, size

    Set the maximum mmap window size.

  GIT_OPT_GET_MWINDOW_FILE_LIMIT

    Get the maximum number of files that will be mapped at any time by the library.

  GIT_OPT_SET_MWINDOW_FILE_LIMIT, size

    Set the maximum number of files that can be mapped at any time by the library. The default (0) is unlimited.

  GIT_OPT_GET_OWNER_VALIDATION

    Gets the owner validation setting for repository directories.

  GIT_OPT_SET_OWNER_VALIDATION, enabled

    Set that repository directories should be owned by the current user. The default is to validate ownership.

  GIT_OPT_GET_TEMPLATE_PATH

    Get the default template path.

  GIT_OPT_SET_TEMPLATE_PATH, path

    Set the default template path.

  GIT_OPT_GET_USER_AGENT

    Get the user agent string.

  GIT_OPT_SET_USER_AGENT, user_agent

    Set the user agent string.

  GIT_OPT_GET_PACK_MAX_OBJECTS

    Get the maximum number of objects to include in a pack.

  GIT_OPT_SET_PACK_MAX_OBJECTS, count

    Set the maximum number of objects to include in a pack.

## Exceptions

exception pygit2.GitError

  Bases: `Exception`

exception pygit2.AlreadyExistsError

  Bases: `ValueError`

Exception when trying to create an object (reference, etc) that already exists.

exception pygit2.InvalidSpecError

  Bases: `ValueError`

Exception when an input specification such as a reference name is invalid.