46#define N_GIT_STATUS_NEW 1
48#define N_GIT_STATUS_MODIFIED 2
50#define N_GIT_STATUS_DELETED 4
52#define N_GIT_STATUS_STAGED 8
55#define N_GIT_AUTH_NONE 0
57#define N_GIT_AUTH_TOKEN 1
59#define N_GIT_AUTH_BASIC 2
61#define N_GIT_AUTH_SSH 3
161int n_git_commit(
N_GIT_REPO* repo,
const char* message,
const char* author_name,
const char* author_email);
char short_hash[10]
short (abbreviated) hex hash
char author[256]
author name and email
int64_t timestamp
unix timestamp of the commit
char message[512]
first line of commit message
char * password
password or personal access token, or NULL
char * ssh_privkey_path
path to SSH private key file, or NULL
char hash[42]
full hex hash
char * ssh_pubkey_path
path to SSH public key file, or NULL (derived from private key + ".pub")
int flags
combination of N_GIT_STATUS_* flags
char * path
filesystem path to the repository
git_repository * repo
libgit2 repository handle
char * ssh_passphrase
passphrase for SSH key, or NULL
int type
auth type: N_GIT_AUTH_NONE/TOKEN/BASIC/SSH
char * username
username for basic auth or SSH, or NULL
char path[512]
relative path of the file
N_GIT_REMOTE_AUTH * remote_auth
credentials for remote operations, or NULL
void n_git_close(N_GIT_REPO **repo)
Close a Git repository and free resources.
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.
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_switch_branch(N_GIT_REPO *repo, const char *branch_name)
Switch to an existing local branch.
int n_git_pull(N_GIT_REPO *repo)
Fetch from "origin" and fast-forward merge the current branch.
int n_git_checkout_path(N_GIT_REPO *repo, const char *filepath)
Restore a single file from HEAD (discard working directory changes).
LIST * n_git_list_branches(N_GIT_REPO *repo)
List all local branch names.
LIST * n_git_status(N_GIT_REPO *repo)
Get the status of all files in the working directory.
int n_git_unstage(N_GIT_REPO *repo, const char *filepath)
Unstage a single file (reset from HEAD).
int n_git_set_remote_auth(N_GIT_REPO *repo, const N_GIT_REMOTE_AUTH *auth)
Set remote authentication credentials on a repo handle.
LIST * n_git_log(N_GIT_REPO *repo, size_t max_entries)
Retrieve commit log entries starting from HEAD.
int n_git_stage_all(N_GIT_REPO *repo)
Stage all modified and untracked files.
int n_git_stage(N_GIT_REPO *repo, const char *filepath)
Stage a single file by path.
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_checkout_commit(N_GIT_REPO *repo, const char *hash)
Checkout a specific commit (detached HEAD).
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.
N_GIT_REPO * n_git_open(const char *path)
Open an existing Git repository.
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.
int n_git_delete_branch(N_GIT_REPO *repo, const char *branch_name)
Delete a local branch.
Credentials for remote operations.
Wrapper around a git_repository handle.
Single file status entry.
Structure of a generic LIST container.
A box including a string and his lenght.
List structures and definitions.
N_STR and string function declaration.