Module gall.repository
Repository interface
Functions
create (path, full) | Create a repository |
new (path) | Create a new repository object for a given git repository. |
Class repository
repository:all_refs () | Return all (non-symbolic) references in the repository. |
repository:config (confname[, The]) | Interact with the git configuration. |
repository:force_empty_tree () | Force the empty tree object to exist and return it. |
repository:gather (command, ...) | Run a git command across a repository and gather its stdout
This will run the supplied git command within the repository and will return the stdout of the run, with the final newline removed. |
repository:get (_sha) | Retrieve an object from the repository. |
repository:get_ref (ref) | Get the OID referent of the given reference. |
repository:hash_object (type, content, inject) | Calculate the hash of the given object, optionally injecting it into the repository store. |
repository:merge_base (sha_1, sha_2, get_all) | Calculate the merge base(s) for the given sha pair |
repository:normalise (sha) | Normalise a given SHAish to a true OID. |
repository:rawgather (command, ...) | Run a git command across a repository and gather its stdout raw. |
repository:rev_list (oldhead, newhead, firstonly) | Calculate the revision list shared between the given tips. |
repository:symbolic_ref (name[, toref]) | Get or set the given symbolic reference. |
repository:update_ref (ref, new_ref, reason, old_ref) | Update the given reference. |
repository:update_server_info () | Ensure the HTTP server info is updated in the repository. |
Functions
- create (path, full)
-
Create a repository Create a new repository on disk and return its representation.
Parameters:
- path string The path to the repository to be created.
- full boolean Whether to create a full repository or a bare one.
Returns:
-
repository
The newly created repository
Or
- nil Nil on error
- string The error message
- new (path)
-
Create a new repository object for a given git repository.
Create a new repository object representing the given git repository. If the path refers to a repository with a working tree (non-bare) then the
/.git
is automatically added.Parameters:
- path string The path to the repository to open.
Returns:
-
repository
The newly created repository.
Or
- nil Nil on error.
- string The error message.
Class repository
Abstracted representation of a Git repository.A repository instance represents a Git repository on disk. It is the interface through which all interaction with a Git repository begins.
- repository:all_refs ()
-
Return all (non-symbolic) references in the repository.
The returned table is a map from reference name to the SHA1 referent.
Returns:
-
table
The references in the repository
Or
- nil Nil on error
- string The error message
- repository:config (confname[, The])
-
Interact with the git configuration.
Parameters:
- confname string The name of the configuration value to query/set
- The value value to set (or nil to query the current value) (optional)
Returns:
-
string
The value of the configuration entry if queried
Or
- nil Nil on error
- string The error message
- repository:force_empty_tree ()
-
Force the empty tree object to exist and return it.
Returns:
-
object
The git object representing the empty tree
- repository:gather (command, ...)
-
Run a git command across a repository and gather its stdout
This will run the supplied git command within the repository and will return the stdout of the run, with the final newline removed.
For return values, see gall.ll.rungit
Parameters:
Returns:
-
...
As per gall.ll.rungit
See also:
- repository:get (_sha)
-
Retrieve an object from the repository.
Parameters:
- _sha string The SHAish to retrieve.
Returns:
-
object
The low level object representing the given SHAish.
Or
- nil Nil on error
- string The error message
- repository:get_ref (ref)
-
Get the OID referent of the given reference.
Parameters:
- ref string The reference name
Returns:
-
string
The OID referent
Or
-
nil
Nil on error
- repository:hash_object (type, content, inject)
-
Calculate the hash of the given object, optionally injecting it into
the repository store.
Parameters:
- type string The type of the object
- content string The raw content of the object
- inject boolean Whether or not to inject the object into the store.
Returns:
-
string
The OID of the given object
Or
-
nil
Nil on error.
- repository:merge_base (sha_1, sha_2, get_all)
-
Calculate the merge base(s) for the given sha pair
Parameters:
- sha_1 string The left-side OID for the merge
- sha_2 string The right-side OID for the merge
- get_all boolean Whether to retrieve all possible merge bases.
Returns:
-
boolean
True if there simply isn’t a merge base to be found
Or
-
string...
The OID(s) of the merge base(s)
Or
- nil Nil on error
- string The error message
- repository:normalise (sha)
-
Normalise a given SHAish to a true OID.
Parameters:
- sha string The SHAish to normalise.
Returns:
-
string
The full OID referred to by SHAish
Or
- nil Nil on error
- string The error message.
- repository:rawgather (command, ...)
-
Run a git command across a repository and gather its stdout raw.
This will run the supplied git command within the repository and will return the stdout of the run without processing it at all.
For return values, see gall.ll.rungit
Parameters:
Returns:
-
...
As per gall.ll.rungit
See also:
- repository:rev_list (oldhead, newhead, firstonly)
-
Calculate the revision list shared between the given tips.
Parameters:
- oldhead string The “old” tip of the commit tree.
- newhead string The “new” tip of the commit tree.
- firstonly boolean Whether to return only the first shared revision
Returns:
-
boolean
True if there are no shared commits
Or
-
string...
The OIDs of the shared revision(s)
Or
- nil Nil on error
- string The error message
- repository:symbolic_ref (name[, toref])
-
Get or set the given symbolic reference.
Parameters:
- name string The reference to get or set
- toref string The referent for the symbolic reference. (optional)
Returns:
-
boolean
False if the reference queried and was not found
Or
- boolean True if the reference was queried and found (or set)
- string The referent of the given reference.
Or
-
nil
Nil on error
Or
-
string
The error message
- repository:update_ref (ref, new_ref, reason, old_ref)
-
Update the given reference.
If new_ref is nil then the reference is to be deleted. If reason is nil, then
"Gall internal operations"
will be used. If old_ref is nil then the reference must not exist before calling this.Parameters:
- repository:update_server_info ()
-
Ensure the HTTP server info is updated in the repository.
This essentially just calls
git update-server-info
Returns:
-
boolean
True on success
Or
- nil Nil on error
- string The error message