37 Repository
(require libgit2/include/repository) | package: libgit2 |
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.
Convenience function to take a snapshot from the repository’s configuration. The contents of this snapshot will not change, even if the underlying config files are modified.
The configuration file must be freed once it’s no longer being used by the user.
procedure
(git_repository_detach_head repo) → integer?
repo : repository?
If the HEAD is already detached and points to a Commit, 0 is returned.
If the HEAD is already detached and points to a Tag, the HEAD is updated into making it point to the peeled Commit, and 0 is returned.
If the HEAD is already detached and points to a non commitish, the HEAD is unaltered, and -1 is returned.
Otherwise, the HEAD will be detached and point to the peeled Commit.
procedure
(git_repository_discover out start_path across_fs ceiling_dirs) → integer? out : buf? start_path : string? across_fs : boolean? ceiling_dirs : string?
The method will automatically detect if the repository is bare (if there is a repository).
procedure
(git_repository_fetchhead_foreach repo callback payload) → integer? repo : repository? callback : git_repository_fetchhead_foreach_cb payload : bytes?
Return a non-zero value from the callback to stop the loop.
procedure
(git_repository_free repo) → void?
repo : repository?
Note that after a repository is free’d, all the objects it has spawned will still exist until they are manually closed by the user with git_object_free, but accessing any of the attributes of an object without a backing repository will result in undefined behavior
procedure
(git_repository_get_namespace repo) → string?
repo : repository?
procedure
(git_repository_hashfile out repo path type as_path) → integer? out : oid? repo : repository? path : string? type : git_otype as_path : string?
If you simply want to calculate the hash of a file on disk with no filters, you can just use the git_odb_hashfile() API. However, if you want to hash a file in the repository and you want to apply filtering rules (e.g. crlf filters) before generating the SHA, then use this function.
Note: if the repository has core.safecrlf set to fail and the filtering triggers that failure, then this function will return an error and not calculate the hash of the file.
The returned git_reference will be owned by caller and git_reference_free() must be called when done with it to release the allocated memory and prevent a leak.
procedure
(git_repository_head_detached repo) → boolean?
repo : repository?
A repository’s HEAD is detached when it points directly to a commit instead of a branch.
procedure
(git_repository_head_unborn repo) → boolean?
repo : repository?
An unborn 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.
procedure
(git_repository_ident repo) → integer?
repo : repository?
The memory is owned by the repository and must not be freed by the user.
Returns (values (name : string?) (email : string?)). See Multiple Values
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.
procedure
path : string? is_bare : #f
TODO: - Reinit the repository
procedure
repo_path : string? opts : git_repository_init_opts?
This will initialize a new git repository (creating the repo_path if requested by flags) and working directory as needed. It will auto-detect the case sensitivity of the file system and if the file system supports file mode bits correctly.
procedure
(git_repository_init_init_options opts version) → integer? opts : git_repository_init_options? version : integer?
procedure
(git_repository_is_bare repo) → boolean?
repo : repository?
procedure
(git_repository_is_empty repo) → boolean?
repo : repository?
An empty repository has just been initialized and contains no references apart from HEAD, which must be pointing to the unborn master branch.
procedure
(git_repository_is_shallow repo) → boolean?
repo : repository?
procedure
(git_repository_mergehead_foreach repo callback payload) → integer? repo : repository? callback : git_repository_mergehead_foreach_cb payload : bytes?
Return a non-zero value from the callback to stop the loop.
procedure
(git_repository_message out repo) → integer?
out : buf? repo : repository?
Operations such as git revert/cherry-pick/merge with the -n option stop just short of creating a commit with the changes and save their prepared message in .git/MERGE_MSG so the next git-commit execution can present it to the user for them to amend if they wish.
Use this function to get the contents of this file. Don’t forget to remove the file after you create the commit.
procedure
(git_repository_message_remove repo) → integer?
repo : repository?
Remove the message that git_repository_message retrieves.
Note that this is only useful if you wish to associate the repository with a non-filesystem-backed object database and config store.
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.
procedure
path : string?
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.
procedure
bare_path : string?
This is a fast open for bare repositories that will come in handy if you’re e.g. hosting git repositories and need to access them efficiently
procedure
(git_repository_open_ext path flags ceiling_dirs) → repository? path : string? flags : integer? ceiling_dirs : string?
procedure
(git_repository_path repo) → string?
repo : repository?
This is the path of the .git folder for normal repositories, or of the repository itself for bare repositories.
If a custom refsdb has not been set, the default database for the repository will be returned (the one that manipulates loose and packed references in the .git directory).
The refdb must be freed once it’s no longer being used by the user.
procedure
(git_repository_reinit_filesystem repo recurse_submodules) → integer? repo : repository? recurse_submodules : boolean?
When a repository is initialized, config values are set based on the properties of the filesystem that the repository is on, such as "core.ignorecase", "core.filemode", "core.symlinks", etc. If the repository is moved to a new filesystem, these properties may no longer be correct and API calls may not behave as expected. This call reruns the phase of repository initialization that sets those properties to compensate for the current filesystem of the repo.
procedure
(git_repository_set_bare repo) → integer?
repo : repository?
Clear the working directory and set core.bare to true. You may also want to call git_repository_set_index(repo, NULL) since a bare repo typically does not have an index, but this function will not do that for you.
procedure
(git_repository_set_config repo config) → void?
repo : repository? config : 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.
If the provided reference points to a Tree or a Blob, the HEAD is unaltered and -1 is returned.
If the provided reference points to a branch, the HEAD will point to that branch, staying attached, or become attached if it isn’t yet. If the branch doesn’t exist yet, no error will be return. The HEAD will then be attached to an unborn branch.
Otherwise, the HEAD will be detached and will directly point to the Commit.
procedure
(git_repository_set_head_detached repo commitish) → integer? repo : repository? commitish : oid?
If the provided committish cannot be found in the repository, the HEAD is unaltered and GIT_ENOTFOUND is returned.
If the provided commitish cannot be peeled into a commit, the HEAD is unaltered and -1 is returned.
Otherwise, the HEAD will eventually be detached and will directly point to the peeled Commit.
procedure
(git_repository_set_head_detached_from_annotated repo commitish) → integer? repo : repository? commitish : annotated_commit?
This behaves like git_repository_set_head_detached() but takes an annotated commit, which lets you specify which extended sha syntax string was specified by a user, allowing for more exact reflog messages.
See the documentation for git_repository_set_head_detached().
procedure
(git_repository_set_ident repo name email) → integer?
repo : repository? name : string? email : string?
If both are set, this name and email will be used to write to the reflog. Pass NULL to unset. When unset, the identity will be taken from the repository’s configuration.
procedure
(git_repository_set_index repo index) → void?
repo : repository? index : 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.
procedure
(git_repository_set_namespace repo nmspace) → integer?
repo : repository? nmspace : string?
This namespace affects all reference operations for the repo. See man gitnamespaces
procedure
(git_repository_set_odb repo odb) → void?
repo : repository? odb : 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.
procedure
(git_repository_set_refdb repo refdb) → void?
repo : repository? refdb : refdb?
The refdb will be used for all reference related operations involving this repository.
The repository will keep a reference to the refdb; the user must still free the refdb object after setting it to the repository, or it will leak.
procedure
(git_repository_set_workdir repo workdir update_gitlink) → integer? repo : repository? workdir : string? update_gitlink : boolean?
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).
procedure
(git_repository_state repo) → integer?
repo : repository?
procedure
(git_repository_state_cleanup repo) → integer?
repo : repository?
procedure
(git_repository_workdir repo) → string?
repo : repository?
If the repository is bare, this function will always return NULL.
Create a repository object to wrap an object database to be used with the API when all you have is an object database. This doesn’t have any paths associated with it, so use with care.