![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Data Structures | |
| struct | N_GIT_COMMIT_INFO |
| Commit metadata. More... | |
| struct | N_GIT_REMOTE_AUTH |
| Credentials for remote operations. More... | |
| struct | N_GIT_REPO |
| Wrapper around a git_repository handle. More... | |
| struct | N_GIT_STATUS_ENTRY |
| Single file status entry. More... | |
Macros | |
| #define | N_GIT_AUTH_BASIC 2 |
| Remote auth: username + password. | |
| #define | N_GIT_AUTH_NONE 0 |
| Remote auth: no authentication. | |
| #define | N_GIT_AUTH_SSH 3 |
| Remote auth: SSH key file. | |
| #define | N_GIT_AUTH_TOKEN 1 |
| Remote auth: personal access token (used as password with empty or "x-access-token" user) | |
| #define | N_GIT_STATUS_DELETED 4 |
| File has been deleted. | |
| #define | N_GIT_STATUS_MODIFIED 2 |
| File has been modified. | |
| #define | N_GIT_STATUS_NEW 1 |
| File is new / untracked. | |
| #define | N_GIT_STATUS_STAGED 8 |
| File is staged in the index. | |
Functions | |
| int | n_git_checkout_commit (N_GIT_REPO *repo, const char *hash) |
| Checkout a specific commit (detached HEAD). | |
| int | n_git_checkout_path (N_GIT_REPO *repo, const char *filepath) |
| Restore a single file from HEAD (discard working directory changes). | |
| void | n_git_close (N_GIT_REPO **repo) |
| Close a Git repository and free resources. | |
| int | n_git_commit (N_GIT_REPO *repo, const char *message, const char *author_name, const char *author_email) |
| Create a commit from the current index. | |
| int | n_git_create_branch (N_GIT_REPO *repo, const char *branch_name) |
| Create a new branch from HEAD. | |
| int | n_git_current_branch (N_GIT_REPO *repo, char *out, size_t out_size) |
| Get the name of the current branch. | |
| int | n_git_delete_branch (N_GIT_REPO *repo, const char *branch_name) |
| Delete a local branch. | |
| N_STR * | n_git_diff_commits (N_GIT_REPO *repo, const char *hash_a, const char *hash_b) |
| Get a diff between two commits identified by hash. | |
| N_STR * | n_git_diff_workdir (N_GIT_REPO *repo) |
| Get a diff of the working directory against the index. | |
| N_GIT_REPO * | n_git_init (const char *path) |
| Initialize a new Git repository. | |
| LIST * | n_git_list_branches (N_GIT_REPO *repo) |
| List all local branch names. | |
| LIST * | n_git_log (N_GIT_REPO *repo, size_t max_entries) |
| Retrieve commit log entries starting from HEAD. | |
| N_GIT_REPO * | n_git_open (const char *path) |
| Open an existing Git repository. | |
| int | n_git_pull (N_GIT_REPO *repo) |
| Fetch from "origin" and fast-forward merge the current branch. | |
| int | n_git_push (N_GIT_REPO *repo) |
| Push the current branch to the "origin" remote. | |
| int | n_git_remote_set_url (N_GIT_REPO *repo, const char *url) |
| Ensure a remote named "origin" exists with the given URL. | |
| int | n_git_set_remote_auth (N_GIT_REPO *repo, const N_GIT_REMOTE_AUTH *auth) |
| Set remote authentication credentials on a repo handle. | |
| int | n_git_stage (N_GIT_REPO *repo, const char *filepath) |
| Stage a single file by path. | |
| int | n_git_stage_all (N_GIT_REPO *repo) |
| Stage all modified and untracked files. | |
| LIST * | n_git_status (N_GIT_REPO *repo) |
| Get the status of all files in the working directory. | |
| int | n_git_switch_branch (N_GIT_REPO *repo, const char *branch_name) |
| Switch to an existing local branch. | |
| int | n_git_unstage (N_GIT_REPO *repo, const char *filepath) |
| Unstage a single file (reset from HEAD). | |
| struct N_GIT_COMMIT_INFO |
| struct N_GIT_REMOTE_AUTH |
Collaboration diagram for N_GIT_REMOTE_AUTH:| struct N_GIT_REPO |
Collaboration diagram for N_GIT_REPO:| Data Fields | ||
|---|---|---|
| char * | path | filesystem path to the repository |
| N_GIT_REMOTE_AUTH * | remote_auth | credentials for remote operations, or NULL |
| git_repository * | repo | libgit2 repository handle |
| struct N_GIT_STATUS_ENTRY |
| #define N_GIT_AUTH_TOKEN 1 |
| int n_git_checkout_commit | ( | N_GIT_REPO * | repo, |
| const char * | hash | ||
| ) |
Checkout a specific commit (detached HEAD).
| repo | An opened N_GIT_REPO handle. |
| hash | Hash (or prefix) of the commit to checkout. |
Definition at line 708 of file n_git.c.
References __n_assert, _n_git_log_error(), and N_GIT_REPO::repo.
Here is the call graph for this function:| int n_git_checkout_path | ( | N_GIT_REPO * | repo, |
| const char * | filepath | ||
| ) |
Restore a single file from HEAD (discard working directory changes).
| repo | An opened N_GIT_REPO handle. |
| filepath | Relative path of the file to restore. |
Definition at line 679 of file n_git.c.
References __n_assert, _n_git_log_error(), and N_GIT_REPO::repo.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void n_git_close | ( | N_GIT_REPO ** | repo | ) |
Close a Git repository and free resources.
| repo | Pointer to the N_GIT_REPO handle (set to NULL after close). |
Definition at line 185 of file n_git.c.
References __n_assert, and FreeNoLog.
Referenced by main().
Here is the caller graph for this function:| int n_git_commit | ( | N_GIT_REPO * | repo, |
| const char * | message, | ||
| const char * | author_name, | ||
| const char * | author_email | ||
| ) |
Create a commit from the current index.
| repo | An opened N_GIT_REPO handle. |
| message | The commit message. |
| author_name | Author name string. |
| author_email | Author email string. |
Definition at line 412 of file n_git.c.
References __n_assert, _n_git_log_error(), and N_GIT_REPO::repo.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| int n_git_create_branch | ( | N_GIT_REPO * | repo, |
| const char * | branch_name | ||
| ) |
Create a new branch from HEAD.
| repo | An opened N_GIT_REPO handle. |
| branch_name | Name for the new branch. |
Definition at line 790 of file n_git.c.
References __n_assert, _n_git_log_error(), and N_GIT_REPO::repo.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| int n_git_current_branch | ( | N_GIT_REPO * | repo, |
| char * | out, | ||
| size_t | out_size | ||
| ) |
Get the name of the current branch.
| repo | An opened N_GIT_REPO handle. |
| out | Buffer to receive the branch name. |
| out_size | Size of the output buffer. |
Definition at line 879 of file n_git.c.
References __n_assert, _n_git_log_error(), and N_GIT_REPO::repo.
Referenced by main(), n_git_pull(), and n_git_push().
Here is the call graph for this function:
Here is the caller graph for this function:| int n_git_delete_branch | ( | N_GIT_REPO * | repo, |
| const char * | branch_name | ||
| ) |
Delete a local branch.
| repo | An opened N_GIT_REPO handle. |
| branch_name | Name of the branch to delete. |
Definition at line 909 of file n_git.c.
References __n_assert, _n_git_log_error(), and N_GIT_REPO::repo.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| N_STR * n_git_diff_commits | ( | N_GIT_REPO * | repo, |
| const char * | hash_a, | ||
| const char * | hash_b | ||
| ) |
Get a diff between two commits identified by hash.
| repo | An opened N_GIT_REPO handle. |
| hash_a | Hash (or prefix) of the first commit. |
| hash_b | Hash (or prefix) of the second commit. |
Definition at line 597 of file n_git.c.
References __n_assert, _n_git_diff_print_cb(), _n_git_log_error(), new_nstr(), and N_GIT_REPO::repo.
Here is the call graph for this function:| N_STR * n_git_diff_workdir | ( | N_GIT_REPO * | repo | ) |
Get a diff of the working directory against the index.
| repo | An opened N_GIT_REPO handle. |
Definition at line 567 of file n_git.c.
References __n_assert, _n_git_diff_print_cb(), _n_git_log_error(), new_nstr(), and N_GIT_REPO::repo.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| N_GIT_REPO * n_git_init | ( | const char * | path | ) |
Initialize a new Git repository.
| path | Filesystem path where the repository will be created. |
Definition at line 155 of file n_git.c.
References __n_assert, _n_git_ensure_init(), _n_git_log_error(), FreeNoLog, LOG_ERR, Malloc, n_log, N_GIT_REPO::path, and N_GIT_REPO::repo.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| LIST * n_git_list_branches | ( | N_GIT_REPO * | repo | ) |
List all local branch names.
| repo | An opened N_GIT_REPO handle. |
Definition at line 749 of file n_git.c.
References __n_assert, _n_git_log_error(), _n_git_string_destroy(), list_push(), new_generic_list(), N_GIT_REPO::repo, and UNLIMITED_LIST_ITEMS.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| LIST * n_git_log | ( | N_GIT_REPO * | repo, |
| size_t | max_entries | ||
| ) |
Retrieve commit log entries starting from HEAD.
| repo | An opened N_GIT_REPO handle. |
| max_entries | Maximum number of log entries to retrieve. |
Definition at line 491 of file n_git.c.
References __n_assert, _n_git_commit_info_destroy(), _n_git_log_error(), N_GIT_COMMIT_INFO::author, N_GIT_COMMIT_INFO::hash, list_push(), Malloc, N_GIT_COMMIT_INFO::message, new_generic_list(), N_GIT_REPO::repo, N_GIT_COMMIT_INFO::short_hash, N_GIT_COMMIT_INFO::timestamp, and UNLIMITED_LIST_ITEMS.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| N_GIT_REPO * n_git_open | ( | const char * | path | ) |
Open an existing Git repository.
| path | Filesystem path to the repository root (or .git dir). |
Definition at line 123 of file n_git.c.
References __n_assert, _n_git_ensure_init(), _n_git_log_error(), FreeNoLog, LOG_ERR, Malloc, n_log, N_GIT_REPO::path, and N_GIT_REPO::repo.
Here is the call graph for this function:| int n_git_pull | ( | N_GIT_REPO * | repo | ) |
Fetch from "origin" and fast-forward merge the current branch.
Uses credentials set via n_git_set_remote_auth. If the merge is not a fast-forward, returns -1 (no conflict resolution).
| repo | An opened N_GIT_REPO handle. |
Definition at line 1107 of file n_git.c.
References __n_assert, _n_git_cred_cb(), _n_git_ensure_init(), _n_git_log_error(), LOG_ERR, LOG_INFO, n_git_current_branch(), n_log, N_GIT_REPO::remote_auth, and N_GIT_REPO::repo.
Here is the call graph for this function:| int n_git_push | ( | N_GIT_REPO * | repo | ) |
Push the current branch to the "origin" remote.
Uses credentials set via n_git_set_remote_auth.
| repo | An opened N_GIT_REPO handle. |
Definition at line 1057 of file n_git.c.
References __n_assert, _n_git_cred_cb(), _n_git_ensure_init(), _n_git_log_error(), LOG_ERR, LOG_INFO, n_git_current_branch(), n_log, N_GIT_REPO::remote_auth, and N_GIT_REPO::repo.
Here is the call graph for this function:| int n_git_remote_set_url | ( | N_GIT_REPO * | repo, |
| const char * | url | ||
| ) |
Ensure a remote named "origin" exists with the given URL.
If "origin" exists with a different URL, it is updated.
| repo | An opened N_GIT_REPO handle. |
| url | Remote URL (HTTPS or SSH). |
Definition at line 1019 of file n_git.c.
References __n_assert, _n_git_ensure_init(), _n_git_log_error(), and N_GIT_REPO::repo.
Here is the call graph for this function:| int n_git_set_remote_auth | ( | N_GIT_REPO * | repo, |
| const N_GIT_REMOTE_AUTH * | auth | ||
| ) |
Set remote authentication credentials on a repo handle.
The credentials are used by n_git_push and n_git_pull.
| repo | An opened N_GIT_REPO handle. |
| auth | Pointer to auth struct. Contents are copied (caller can free). |
Definition at line 986 of file n_git.c.
References __n_assert, FreeNoLog, Malloc, N_GIT_REMOTE_AUTH::password, N_GIT_REPO::remote_auth, N_GIT_REMOTE_AUTH::ssh_passphrase, N_GIT_REMOTE_AUTH::ssh_privkey_path, N_GIT_REMOTE_AUTH::ssh_pubkey_path, N_GIT_REMOTE_AUTH::type, and N_GIT_REMOTE_AUTH::username.
| int n_git_stage | ( | N_GIT_REPO * | repo, |
| const char * | filepath | ||
| ) |
Stage a single file by path.
| repo | An opened N_GIT_REPO handle. |
| filepath | Relative path of the file to stage. |
Definition at line 290 of file n_git.c.
References __n_assert, _n_git_log_error(), and N_GIT_REPO::repo.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| int n_git_stage_all | ( | N_GIT_REPO * | repo | ) |
Stage all modified and untracked files.
| repo | An opened N_GIT_REPO handle. |
Definition at line 328 of file n_git.c.
References __n_assert, _n_git_log_error(), and N_GIT_REPO::repo.
Here is the call graph for this function:| LIST * n_git_status | ( | N_GIT_REPO * | repo | ) |
Get the status of all files in the working directory.
| repo | An opened N_GIT_REPO handle. |
Definition at line 210 of file n_git.c.
References __n_assert, _n_git_log_error(), _n_git_status_entry_destroy(), N_GIT_STATUS_ENTRY::flags, list_push(), Malloc, N_GIT_STATUS_DELETED, N_GIT_STATUS_MODIFIED, N_GIT_STATUS_NEW, N_GIT_STATUS_STAGED, new_generic_list(), N_GIT_STATUS_ENTRY::path, N_GIT_REPO::repo, and UNLIMITED_LIST_ITEMS.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| int n_git_switch_branch | ( | N_GIT_REPO * | repo, |
| const char * | branch_name | ||
| ) |
Switch to an existing local branch.
| repo | An opened N_GIT_REPO handle. |
| branch_name | Name of the branch to switch to. |
Definition at line 833 of file n_git.c.
References __n_assert, _n_git_log_error(), and N_GIT_REPO::repo.
Here is the call graph for this function:| int n_git_unstage | ( | N_GIT_REPO * | repo, |
| const char * | filepath | ||
| ) |
Unstage a single file (reset from HEAD).
| repo | An opened N_GIT_REPO handle. |
| filepath | Relative path of the file to unstage. |
Definition at line 366 of file n_git.c.
References __n_assert, _n_git_log_error(), and N_GIT_REPO::repo.
Here is the call graph for this function: