Module Repository

Class "Repository".

Functions

Repository.init (path, is_bare) Create a new Repository object.
Repository.open (path) Create a new Repository object.
Repository:config () object method.
Repository:head () object method.
Repository:head_detached () object method.
Repository:head_orphan () object method.
Repository:index () object method.
Repository:is_bare () object method.
Repository:is_empty () object method.
Repository:odb () object method.
Repository:path () object method.
Repository:set_config (config) object method.
Repository:set_index (index) object method.
Repository:set_odb (odb) object method.
Repository:set_workdir (workdir, update_gitlink) object method.
Repository:workdir () object method.


Functions

Repository.init (path, is_bare)
Create a new Repository object.

Calls git_repository_init:

TODO: - Reinit the repository

Parameters

  • path: the path to the repository. Must be of type string.
  • is_bare: if true, a Git repository without a working directory is created at the pointed path. If false, provided path will be considered as the working directory into which the .git directory will be created.. Must be of type integer.

Return values:

  1. Repository or nil on error.
  2. Error string.
Repository.open (path)
Create a new Repository object.

Calls git_repository_open:

The 'path' argument must point to either a git repository folder, or an existing work dir.

The method will automatically detect if 'path' is a normal or bare repository or fail is 'path' is neither.

Parameters

  • path: the path to the repository. Must be of type string.

Return values:

  1. Repository or nil on error.
  2. Error string.
Repository:config ()
object method.

Calls git_repository_config:

If a configuration file has not been set, the default config set for the repository will be returned, including global and system configurations (if they are available).

The configuration file must be freed once it's no longer being used by the user.

Return values:

  1. Config or nil on error.
  2. Error string.
Repository:head ()
object method.

Calls git_repository_head:

Return values:

  1. Reference or nil on error.
  2. Error string.
Repository:head_detached ()
object method.

Calls git_repository_head_detached:

A repository's HEAD is detached when it points directly to a commit instead of a branch.

Return value:

boolean.
Repository:head_orphan ()
object method.

Calls git_repository_head_orphan:

An orphan branch is one named from HEAD but which doesn't exist in the refs namespace, because it doesn't have any commit to point to.

Return value:

boolean.
Repository:index ()
object method.

Calls git_repository_index:

If a custom index has not been set, the default index for the repository will be returned (the one located in `.git/index`).

The index must be freed once it's no longer being used by the user.

Return values:

  1. Index or nil on error.
  2. Error string.
Repository:is_bare ()
object method.

Calls git_repository_is_bare:

Return value:

boolean.
Repository:is_empty ()
object method.

Calls git_repository_is_empty:

An empty repository has just been initialized and contains no commits.

Return value:

boolean.
Repository:odb ()
object method.

Calls git_repository_odb:

If a custom ODB has not been set, the default database for the repository will be returned (the one located in `.git/objects`).

The ODB must be freed once it's no longer being used by the user.

Return values:

  1. ODB or nil on error.
  2. Error string.
Repository:path ()
object method.

Calls git_repository_path:

This is the path of the `.git` folder for normal repositories, or of the repository itself for bare repositories.

Return value:

string.
Repository:set_config (config)
object method.

Calls git_repository_set_config:

This configuration file will be used for all configuration queries involving this repository.

The repository will keep a reference to the config file; the user must still free the config after setting it to the repository, or it will leak.

Parameters

  • config: A Config object. Must be of type Config.
Repository:set_index (index)
object method.

Calls git_repository_set_index:

This index will be used for all index-related operations involving this repository.

The repository will keep a reference to the index file; the user must still free the index after setting it to the repository, or it will leak.

Parameters

  • index: An index object. Must be of type Index.
Repository:set_odb (odb)
object method.

Calls git_repository_set_odb:

The ODB will be used for all object-related operations involving this repository.

The repository will keep a reference to the ODB; the user must still free the ODB object after setting it to the repository, or it will leak.

Parameters

  • odb: An ODB object. Must be of type ODB.
Repository:set_workdir (workdir, update_gitlink)
object method.

Calls git_repository_set_workdir:

The working directory doesn't need to be the same one that contains the `.git` folder for this repository.

If this repository is bare, setting its working directory will turn it into a normal repository, capable of performing all the common workdir operations (checkout, status, index manipulation, etc).

Parameters

  • workdir: The path to a working directory. Must be of type string.
  • update_gitlink: Must be of type integer.

Return values:

  1. true if no error.
  2. Error string.
Repository:workdir ()
object method.

Calls git_repository_workdir:

If the repository is bare, this function will always return NULL.

Return value:

string.

Valid XHTML 1.0!