Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_git.h File Reference

libgit2 wrapper for Git repository operations More...

#include "nilorea/n_str.h"
#include "nilorea/n_list.h"
#include <git2.h>
+ Include dependency graph for n_git.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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_STRn_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_STRn_git_diff_workdir (N_GIT_REPO *repo)
 Get a diff of the working directory against the index.
 
N_GIT_REPOn_git_init (const char *path)
 Initialize a new Git repository.
 
LISTn_git_list_branches (N_GIT_REPO *repo)
 List all local branch names.
 
LISTn_git_log (N_GIT_REPO *repo, size_t max_entries)
 Retrieve commit log entries starting from HEAD.
 
N_GIT_REPOn_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.
 
LISTn_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).
 

Detailed Description

libgit2 wrapper for Git repository operations

Author
Castagnier Mickael
Version
1.0
Date
26/03/2026

Definition in file n_git.h.