Blame include/git2/repository.h

Packit ae9e2a
/*
Packit ae9e2a
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit ae9e2a
 *
Packit ae9e2a
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit ae9e2a
 * a Linking Exception. For full terms see the included COPYING file.
Packit ae9e2a
 */
Packit ae9e2a
#ifndef INCLUDE_git_repository_h__
Packit ae9e2a
#define INCLUDE_git_repository_h__
Packit ae9e2a
Packit ae9e2a
#include "common.h"
Packit ae9e2a
#include "types.h"
Packit ae9e2a
#include "oid.h"
Packit ae9e2a
#include "buffer.h"
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * @file git2/repository.h
Packit ae9e2a
 * @brief Git repository management routines
Packit ae9e2a
 * @defgroup git_repository Git repository management routines
Packit ae9e2a
 * @ingroup Git
Packit ae9e2a
 * @{
Packit ae9e2a
 */
Packit ae9e2a
GIT_BEGIN_DECL
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Open a git repository.
Packit ae9e2a
 *
Packit ae9e2a
 * The 'path' argument must point to either a git repository
Packit ae9e2a
 * folder, or an existing work dir.
Packit ae9e2a
 *
Packit ae9e2a
 * The method will automatically detect if 'path' is a normal
Packit ae9e2a
 * or bare repository or fail is 'path' is neither.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to the repo which will be opened
Packit ae9e2a
 * @param path the path to the repository
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_open(git_repository **out, const char *path);
Packit ae9e2a
/**
Packit ae9e2a
 * Open working tree as a repository
Packit ae9e2a
 *
Packit ae9e2a
 * Open the working directory of the working tree as a normal
Packit ae9e2a
 * repository that can then be worked on.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out Output pointer containing opened repository
Packit ae9e2a
 * @param wt Working tree to open
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_open_from_worktree(git_repository **out, git_worktree *wt);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create a "fake" repository to wrap an object database
Packit ae9e2a
 *
Packit ae9e2a
 * Create a repository object to wrap an object database to be used
Packit ae9e2a
 * with the API when all you have is an object database. This doesn't
Packit ae9e2a
 * have any paths associated with it, so use with care.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to the repo
Packit ae9e2a
 * @param odb the object database to wrap
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_wrap_odb(git_repository **out, git_odb *odb);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Look for a git repository and copy its path in the given buffer.
Packit ae9e2a
 * The lookup start from base_path and walk across parent directories
Packit ae9e2a
 * if nothing has been found. The lookup ends when the first repository
Packit ae9e2a
 * is found, or when reaching a directory referenced in ceiling_dirs
Packit ae9e2a
 * or when the filesystem changes (in case across_fs is true).
Packit ae9e2a
 *
Packit ae9e2a
 * The method will automatically detect if the repository is bare
Packit ae9e2a
 * (if there is a repository).
Packit ae9e2a
 *
Packit ae9e2a
 * @param out A pointer to a user-allocated git_buf which will contain
Packit ae9e2a
 * the found path.
Packit ae9e2a
 *
Packit ae9e2a
 * @param start_path The base path where the lookup starts.
Packit ae9e2a
 *
Packit ae9e2a
 * @param across_fs If true, then the lookup will not stop when a
Packit ae9e2a
 * filesystem device change is detected while exploring parent directories.
Packit ae9e2a
 *
Packit ae9e2a
 * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR separated list of
Packit ae9e2a
 * absolute symbolic link free paths. The lookup will stop when any
Packit ae9e2a
 * of this paths is reached. Note that the lookup always performs on
Packit ae9e2a
 * start_path no matter start_path appears in ceiling_dirs ceiling_dirs
Packit ae9e2a
 * might be NULL (which is equivalent to an empty string)
Packit ae9e2a
 *
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_discover(
Packit ae9e2a
		git_buf *out,
Packit ae9e2a
		const char *start_path,
Packit ae9e2a
		int across_fs,
Packit ae9e2a
		const char *ceiling_dirs);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Option flags for `git_repository_open_ext`.
Packit ae9e2a
 *
Packit ae9e2a
 * * GIT_REPOSITORY_OPEN_NO_SEARCH - Only open the repository if it can be
Packit ae9e2a
 *   immediately found in the start_path.  Do not walk up from the
Packit ae9e2a
 *   start_path looking at parent directories.
Packit ae9e2a
 * * GIT_REPOSITORY_OPEN_CROSS_FS - Unless this flag is set, open will not
Packit ae9e2a
 *   continue searching across filesystem boundaries (i.e. when `st_dev`
Packit ae9e2a
 *   changes from the `stat` system call).  (E.g. Searching in a user's home
Packit ae9e2a
 *   directory "/home/user/source/" will not return "/.git/" as the found
Packit ae9e2a
 *   repo if "/" is a different filesystem than "/home".)
Packit ae9e2a
 * * GIT_REPOSITORY_OPEN_BARE - Open repository as a bare repo regardless
Packit ae9e2a
 *   of core.bare config, and defer loading config file for faster setup.
Packit ae9e2a
 *   Unlike `git_repository_open_bare`, this can follow gitlinks.
Packit ae9e2a
 * * GIT_REPOSITORY_OPEN_NO_DOTGIT - Do not check for a repository by
Packit ae9e2a
 *   appending /.git to the start_path; only open the repository if
Packit ae9e2a
 *   start_path itself points to the git directory.
Packit ae9e2a
 * * GIT_REPOSITORY_OPEN_FROM_ENV - Find and open a git repository,
Packit ae9e2a
 *   respecting the environment variables used by the git command-line
Packit ae9e2a
 *   tools. If set, `git_repository_open_ext` will ignore the other
Packit ae9e2a
 *   flags and the `ceiling_dirs` argument, and will allow a NULL `path`
Packit ae9e2a
 *   to use `GIT_DIR` or search from the current directory. The search
Packit ae9e2a
 *   for a repository will respect $GIT_CEILING_DIRECTORIES and
Packit ae9e2a
 *   $GIT_DISCOVERY_ACROSS_FILESYSTEM.  The opened repository will
Packit ae9e2a
 *   respect $GIT_INDEX_FILE, $GIT_NAMESPACE, $GIT_OBJECT_DIRECTORY, and
Packit ae9e2a
 *   $GIT_ALTERNATE_OBJECT_DIRECTORIES.  In the future, this flag will
Packit ae9e2a
 *   also cause `git_repository_open_ext` to respect $GIT_WORK_TREE and
Packit ae9e2a
 *   $GIT_COMMON_DIR; currently, `git_repository_open_ext` with this
Packit ae9e2a
 *   flag will error out if either $GIT_WORK_TREE or $GIT_COMMON_DIR is
Packit ae9e2a
 *   set.
Packit ae9e2a
 */
Packit ae9e2a
typedef enum {
Packit ae9e2a
	GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0),
Packit ae9e2a
	GIT_REPOSITORY_OPEN_CROSS_FS  = (1 << 1),
Packit ae9e2a
	GIT_REPOSITORY_OPEN_BARE      = (1 << 2),
Packit ae9e2a
	GIT_REPOSITORY_OPEN_NO_DOTGIT = (1 << 3),
Packit ae9e2a
	GIT_REPOSITORY_OPEN_FROM_ENV  = (1 << 4),
Packit ae9e2a
} git_repository_open_flag_t;
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Find and open a repository with extended controls.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out Pointer to the repo which will be opened.  This can
Packit ae9e2a
 *        actually be NULL if you only want to use the error code to
Packit ae9e2a
 *        see if a repo at this path could be opened.
Packit ae9e2a
 * @param path Path to open as git repository.  If the flags
Packit ae9e2a
 *        permit "searching", then this can be a path to a subdirectory
Packit ae9e2a
 *        inside the working directory of the repository. May be NULL if
Packit ae9e2a
 *        flags is GIT_REPOSITORY_OPEN_FROM_ENV.
Packit ae9e2a
 * @param flags A combination of the GIT_REPOSITORY_OPEN flags above.
Packit ae9e2a
 * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR delimited list of path
Packit ae9e2a
 *        prefixes at which the search for a containing repository should
Packit ae9e2a
 *        terminate.
Packit ae9e2a
 * @return 0 on success, GIT_ENOTFOUND if no repository could be found,
Packit ae9e2a
 *        or -1 if there was a repository but open failed for some reason
Packit ae9e2a
 *        (such as repo corruption or system errors).
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_open_ext(
Packit ae9e2a
	git_repository **out,
Packit ae9e2a
	const char *path,
Packit ae9e2a
	unsigned int flags,
Packit ae9e2a
	const char *ceiling_dirs);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Open a bare repository on the serverside.
Packit ae9e2a
 *
Packit ae9e2a
 * This is a fast open for bare repositories that will come in handy
Packit ae9e2a
 * if you're e.g. hosting git repositories and need to access them
Packit ae9e2a
 * efficiently
Packit ae9e2a
 *
Packit ae9e2a
 * @param out Pointer to the repo which will be opened.
Packit ae9e2a
 * @param bare_path Direct path to the bare repository
Packit ae9e2a
 * @return 0 on success, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_open_bare(git_repository **out, const char *bare_path);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Free a previously allocated repository
Packit ae9e2a
 *
Packit ae9e2a
 * Note that after a repository is free'd, all the objects it has spawned
Packit ae9e2a
 * will still exist until they are manually closed by the user
Packit ae9e2a
 * with `git_object_free`, but accessing any of the attributes of
Packit ae9e2a
 * an object without a backing repository will result in undefined
Packit ae9e2a
 * behavior
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo repository handle to close. If NULL nothing occurs.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(void) git_repository_free(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Creates a new Git repository in the given folder.
Packit ae9e2a
 *
Packit ae9e2a
 * TODO:
Packit ae9e2a
 *	- Reinit the repository
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to the repo which will be created or reinitialized
Packit ae9e2a
 * @param path the path to the repository
Packit ae9e2a
 * @param is_bare if true, a Git repository without a working directory is
Packit ae9e2a
 *		created at the pointed path. If false, provided path will be
Packit ae9e2a
 *		considered as the working directory into which the .git directory
Packit ae9e2a
 *		will be created.
Packit ae9e2a
 *
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_init(
Packit ae9e2a
	git_repository **out,
Packit ae9e2a
	const char *path,
Packit ae9e2a
	unsigned is_bare);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Option flags for `git_repository_init_ext`.
Packit ae9e2a
 *
Packit ae9e2a
 * These flags configure extra behaviors to `git_repository_init_ext`.
Packit ae9e2a
 * In every case, the default behavior is the zero value (i.e. flag is
Packit ae9e2a
 * not set).  Just OR the flag values together for the `flags` parameter
Packit ae9e2a
 * when initializing a new repo.  Details of individual values are:
Packit ae9e2a
 *
Packit ae9e2a
 * * BARE   - Create a bare repository with no working directory.
Packit ae9e2a
 * * NO_REINIT - Return an GIT_EEXISTS error if the repo_path appears to
Packit ae9e2a
 *        already be an git repository.
Packit ae9e2a
 * * NO_DOTGIT_DIR - Normally a "/.git/" will be appended to the repo
Packit ae9e2a
 *        path for non-bare repos (if it is not already there), but
Packit ae9e2a
 *        passing this flag prevents that behavior.
Packit ae9e2a
 * * MKDIR  - Make the repo_path (and workdir_path) as needed.  Init is
Packit ae9e2a
 *        always willing to create the ".git" directory even without this
Packit ae9e2a
 *        flag.  This flag tells init to create the trailing component of
Packit ae9e2a
 *        the repo and workdir paths as needed.
Packit ae9e2a
 * * MKPATH - Recursively make all components of the repo and workdir
Packit ae9e2a
 *        paths as necessary.
Packit ae9e2a
 * * EXTERNAL_TEMPLATE - libgit2 normally uses internal templates to
Packit ae9e2a
 *        initialize a new repo.  This flags enables external templates,
Packit ae9e2a
 *        looking the "template_path" from the options if set, or the
Packit ae9e2a
 *        `init.templatedir` global config if not, or falling back on
Packit ae9e2a
 *        "/usr/share/git-core/templates" if it exists.
Packit ae9e2a
 * * GIT_REPOSITORY_INIT_RELATIVE_GITLINK - If an alternate workdir is
Packit ae9e2a
 *        specified, use relative paths for the gitdir and core.worktree.
Packit ae9e2a
 */
Packit ae9e2a
typedef enum {
Packit ae9e2a
	GIT_REPOSITORY_INIT_BARE              = (1u << 0),
Packit ae9e2a
	GIT_REPOSITORY_INIT_NO_REINIT         = (1u << 1),
Packit ae9e2a
	GIT_REPOSITORY_INIT_NO_DOTGIT_DIR     = (1u << 2),
Packit ae9e2a
	GIT_REPOSITORY_INIT_MKDIR             = (1u << 3),
Packit ae9e2a
	GIT_REPOSITORY_INIT_MKPATH            = (1u << 4),
Packit ae9e2a
	GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5),
Packit ae9e2a
	GIT_REPOSITORY_INIT_RELATIVE_GITLINK  = (1u << 6),
Packit ae9e2a
} git_repository_init_flag_t;
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Mode options for `git_repository_init_ext`.
Packit ae9e2a
 *
Packit ae9e2a
 * Set the mode field of the `git_repository_init_options` structure
Packit ae9e2a
 * either to the custom mode that you would like, or to one of the
Packit ae9e2a
 * following modes:
Packit ae9e2a
 *
Packit ae9e2a
 * * SHARED_UMASK - Use permissions configured by umask - the default.
Packit ae9e2a
 * * SHARED_GROUP - Use "--shared=group" behavior, chmod'ing the new repo
Packit ae9e2a
 *        to be group writable and "g+sx" for sticky group assignment.
Packit ae9e2a
 * * SHARED_ALL - Use "--shared=all" behavior, adding world readability.
Packit ae9e2a
 * * Anything else - Set to custom value.
Packit ae9e2a
 */
Packit ae9e2a
typedef enum {
Packit ae9e2a
	GIT_REPOSITORY_INIT_SHARED_UMASK = 0,
Packit ae9e2a
	GIT_REPOSITORY_INIT_SHARED_GROUP = 0002775,
Packit ae9e2a
	GIT_REPOSITORY_INIT_SHARED_ALL   = 0002777,
Packit ae9e2a
} git_repository_init_mode_t;
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Extended options structure for `git_repository_init_ext`.
Packit ae9e2a
 *
Packit ae9e2a
 * This contains extra options for `git_repository_init_ext` that enable
Packit ae9e2a
 * additional initialization features.  The fields are:
Packit ae9e2a
 *
Packit ae9e2a
 * * flags - Combination of GIT_REPOSITORY_INIT flags above.
Packit ae9e2a
 * * mode  - Set to one of the standard GIT_REPOSITORY_INIT_SHARED_...
Packit ae9e2a
 *        constants above, or to a custom value that you would like.
Packit ae9e2a
 * * workdir_path - The path to the working dir or NULL for default (i.e.
Packit ae9e2a
 *        repo_path parent on non-bare repos).  IF THIS IS RELATIVE PATH,
Packit ae9e2a
 *        IT WILL BE EVALUATED RELATIVE TO THE REPO_PATH.  If this is not
Packit ae9e2a
 *        the "natural" working directory, a .git gitlink file will be
Packit ae9e2a
 *        created here linking to the repo_path.
Packit ae9e2a
 * * description - If set, this will be used to initialize the "description"
Packit ae9e2a
 *        file in the repository, instead of using the template content.
Packit ae9e2a
 * * template_path - When GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE is set,
Packit ae9e2a
 *        this contains the path to use for the template directory.  If
Packit ae9e2a
 *        this is NULL, the config or default directory options will be
Packit ae9e2a
 *        used instead.
Packit ae9e2a
 * * initial_head - The name of the head to point HEAD at.  If NULL, then
Packit ae9e2a
 *        this will be treated as "master" and the HEAD ref will be set
Packit ae9e2a
 *        to "refs/heads/master".  If this begins with "refs/" it will be
Packit ae9e2a
 *        used verbatim; otherwise "refs/heads/" will be prefixed.
Packit ae9e2a
 * * origin_url - If this is non-NULL, then after the rest of the
Packit ae9e2a
 *        repository initialization is completed, an "origin" remote
Packit ae9e2a
 *        will be added pointing to this URL.
Packit ae9e2a
 */
Packit ae9e2a
typedef struct {
Packit ae9e2a
	unsigned int version;
Packit ae9e2a
	uint32_t    flags;
Packit ae9e2a
	uint32_t    mode;
Packit ae9e2a
	const char *workdir_path;
Packit ae9e2a
	const char *description;
Packit ae9e2a
	const char *template_path;
Packit ae9e2a
	const char *initial_head;
Packit ae9e2a
	const char *origin_url;
Packit ae9e2a
} git_repository_init_options;
Packit ae9e2a
Packit ae9e2a
#define GIT_REPOSITORY_INIT_OPTIONS_VERSION 1
Packit ae9e2a
#define GIT_REPOSITORY_INIT_OPTIONS_INIT {GIT_REPOSITORY_INIT_OPTIONS_VERSION}
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Initializes a `git_repository_init_options` with default values. Equivalent
Packit ae9e2a
 * to creating an instance with GIT_REPOSITORY_INIT_OPTIONS_INIT.
Packit ae9e2a
 *
Packit ae9e2a
 * @param opts the `git_repository_init_options` struct to initialize
Packit ae9e2a
 * @param version Version of struct; pass `GIT_REPOSITORY_INIT_OPTIONS_VERSION`
Packit ae9e2a
 * @return Zero on success; -1 on failure.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_init_init_options(
Packit ae9e2a
	git_repository_init_options *opts,
Packit ae9e2a
	unsigned int version);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create a new Git repository in the given folder with extended controls.
Packit ae9e2a
 *
Packit ae9e2a
 * This will initialize a new git repository (creating the repo_path
Packit ae9e2a
 * if requested by flags) and working directory as needed.  It will
Packit ae9e2a
 * auto-detect the case sensitivity of the file system and if the
Packit ae9e2a
 * file system supports file mode bits correctly.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out Pointer to the repo which will be created or reinitialized.
Packit ae9e2a
 * @param repo_path The path to the repository.
Packit ae9e2a
 * @param opts Pointer to git_repository_init_options struct.
Packit ae9e2a
 * @return 0 or an error code on failure.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_init_ext(
Packit ae9e2a
	git_repository **out,
Packit ae9e2a
	const char *repo_path,
Packit ae9e2a
	git_repository_init_options *opts);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Retrieve and resolve the reference pointed at by HEAD.
Packit ae9e2a
 *
Packit ae9e2a
 * The returned `git_reference` will be owned by caller and
Packit ae9e2a
 * `git_reference_free()` must be called when done with it to release the
Packit ae9e2a
 * allocated memory and prevent a leak.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to the reference which will be retrieved
Packit ae9e2a
 * @param repo a repository object
Packit ae9e2a
 *
Packit ae9e2a
 * @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing
Packit ae9e2a
 * branch, GIT_ENOTFOUND when HEAD is missing; an error code otherwise
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Retrieve the referenced HEAD for the worktree
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to the reference which will be retrieved
Packit ae9e2a
 * @param repo a repository object
Packit ae9e2a
 * @param name name of the worktree to retrieve HEAD for
Packit ae9e2a
 * @return 0 when successful, error-code otherwise
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_head_for_worktree(git_reference **out, git_repository *repo,
Packit ae9e2a
	const char *name);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Check if a repository's HEAD is detached
Packit ae9e2a
 *
Packit ae9e2a
 * A repository's HEAD is detached when it points directly to a commit
Packit ae9e2a
 * instead of a branch.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo Repo to test
Packit ae9e2a
 * @return 1 if HEAD is detached, 0 if it's not; error code if there
Packit ae9e2a
 * was an error.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_head_detached(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/*
Packit ae9e2a
 * Check if a worktree's HEAD is detached
Packit ae9e2a
 *
Packit ae9e2a
 * A worktree's HEAD is detached when it points directly to a
Packit ae9e2a
 * commit instead of a branch.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo a repository object
Packit ae9e2a
 * @param name name of the worktree to retrieve HEAD for
Packit ae9e2a
 * @return 1 if HEAD is detached, 0 if its not; error code if
Packit ae9e2a
 *  there was an error
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_head_detached_for_worktree(git_repository *repo,
Packit ae9e2a
	const char *name);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Check if the current branch is unborn
Packit ae9e2a
 *
Packit ae9e2a
 * An unborn branch is one named from HEAD but which doesn't exist in
Packit ae9e2a
 * the refs namespace, because it doesn't have any commit to point to.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo Repo to test
Packit ae9e2a
 * @return 1 if the current branch is unborn, 0 if it's not; error
Packit ae9e2a
 * code if there was an error
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_head_unborn(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Check if a repository is empty
Packit ae9e2a
 *
Packit ae9e2a
 * An empty repository has just been initialized and contains no references
Packit ae9e2a
 * apart from HEAD, which must be pointing to the unborn master branch.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo Repo to test
Packit ae9e2a
 * @return 1 if the repository is empty, 0 if it isn't, error code
Packit ae9e2a
 * if the repository is corrupted
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_is_empty(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * List of items which belong to the git repository layout
Packit ae9e2a
 */
Packit ae9e2a
typedef enum {
Packit ae9e2a
	GIT_REPOSITORY_ITEM_GITDIR,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_WORKDIR,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_COMMONDIR,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_INDEX,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_OBJECTS,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_REFS,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_PACKED_REFS,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_REMOTES,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_CONFIG,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_INFO,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_HOOKS,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_LOGS,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_MODULES,
Packit ae9e2a
	GIT_REPOSITORY_ITEM_WORKTREES
Packit ae9e2a
} git_repository_item_t;
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the location of a specific repository file or directory
Packit ae9e2a
 *
Packit ae9e2a
 * This function will retrieve the path of a specific repository
Packit ae9e2a
 * item. It will thereby honor things like the repository's
Packit ae9e2a
 * common directory, gitdir, etc. In case a file path cannot
Packit ae9e2a
 * exist for a given item (e.g. the working directory of a bare
Packit ae9e2a
 * repository), GIT_ENOTFOUND is returned.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out Buffer to store the path at
Packit ae9e2a
 * @param repo Repository to get path for
Packit ae9e2a
 * @param item The repository item for which to retrieve the path
Packit ae9e2a
 * @return 0, GIT_ENOTFOUND if the path cannot exist or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_item_path(git_buf *out, git_repository *repo, git_repository_item_t item);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the path of this repository
Packit ae9e2a
 *
Packit ae9e2a
 * This is the path of the `.git` folder for normal repositories,
Packit ae9e2a
 * or of the repository itself for bare repositories.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo A repository object
Packit ae9e2a
 * @return the path to the repository
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const char *) git_repository_path(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the path of the working directory for this repository
Packit ae9e2a
 *
Packit ae9e2a
 * If the repository is bare, this function will always return
Packit ae9e2a
 * NULL.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo A repository object
Packit ae9e2a
 * @return the path to the working dir, if it exists
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the path of the shared common directory for this repository
Packit ae9e2a
 *
Packit ae9e2a
 * If the repository is bare is not a worktree, the git directory
Packit ae9e2a
 * path is returned.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo A repository object
Packit ae9e2a
 * @return the path to the common dir
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const char *) git_repository_commondir(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Set the path to the working directory for this repository
Packit ae9e2a
 *
Packit ae9e2a
 * The working directory doesn't need to be the same one
Packit ae9e2a
 * that contains the `.git` folder for this repository.
Packit ae9e2a
 *
Packit ae9e2a
 * If this repository is bare, setting its working directory
Packit ae9e2a
 * will turn it into a normal repository, capable of performing
Packit ae9e2a
 * all the common workdir operations (checkout, status, index
Packit ae9e2a
 * manipulation, etc).
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo A repository object
Packit ae9e2a
 * @param workdir The path to a working directory
Packit ae9e2a
 * @param update_gitlink Create/update gitlink in workdir and set config
Packit ae9e2a
 *        "core.worktree" (if workdir is not the parent of the .git directory)
Packit ae9e2a
 * @return 0, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_set_workdir(
Packit ae9e2a
	git_repository *repo, const char *workdir, int update_gitlink);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Check if a repository is bare
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo Repo to test
Packit ae9e2a
 * @return 1 if the repository is bare, 0 otherwise.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_is_bare(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Check if a repository is a linked work tree
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo Repo to test
Packit ae9e2a
 * @return 1 if the repository is a linked work tree, 0 otherwise.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_is_worktree(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the configuration file for this repository.
Packit ae9e2a
 *
Packit ae9e2a
 * If a configuration file has not been set, the default
Packit ae9e2a
 * config set for the repository will be returned, including
Packit ae9e2a
 * global and system configurations (if they are available).
Packit ae9e2a
 *
Packit ae9e2a
 * The configuration file must be freed once it's no longer
Packit ae9e2a
 * being used by the user.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out Pointer to store the loaded configuration
Packit ae9e2a
 * @param repo A repository object
Packit ae9e2a
 * @return 0, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_config(git_config **out, git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get a snapshot of the repository's configuration
Packit ae9e2a
 *
Packit ae9e2a
 * Convenience function to take a snapshot from the repository's
Packit ae9e2a
 * configuration.  The contents of this snapshot will not change,
Packit ae9e2a
 * even if the underlying config files are modified.
Packit ae9e2a
 *
Packit ae9e2a
 * The configuration file must be freed once it's no longer
Packit ae9e2a
 * being used by the user.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out Pointer to store the loaded configuration
Packit ae9e2a
 * @param repo the repository
Packit ae9e2a
 * @return 0, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_config_snapshot(git_config **out, git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the Object Database for this repository.
Packit ae9e2a
 *
Packit ae9e2a
 * If a custom ODB has not been set, the default
Packit ae9e2a
 * database for the repository will be returned (the one
Packit ae9e2a
 * located in `.git/objects`).
Packit ae9e2a
 *
Packit ae9e2a
 * The ODB must be freed once it's no longer being used by
Packit ae9e2a
 * the user.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out Pointer to store the loaded ODB
Packit ae9e2a
 * @param repo A repository object
Packit ae9e2a
 * @return 0, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_odb(git_odb **out, git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the Reference Database Backend for this repository.
Packit ae9e2a
 *
Packit ae9e2a
 * If a custom refsdb has not been set, the default database for
Packit ae9e2a
 * the repository will be returned (the one that manipulates loose
Packit ae9e2a
 * and packed references in the `.git` directory).
Packit ae9e2a
 *
Packit ae9e2a
 * The refdb must be freed once it's no longer being used by
Packit ae9e2a
 * the user.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out Pointer to store the loaded refdb
Packit ae9e2a
 * @param repo A repository object
Packit ae9e2a
 * @return 0, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_refdb(git_refdb **out, git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the Index file for this repository.
Packit ae9e2a
 *
Packit ae9e2a
 * If a custom index has not been set, the default
Packit ae9e2a
 * index for the repository will be returned (the one
Packit ae9e2a
 * located in `.git/index`).
Packit ae9e2a
 *
Packit ae9e2a
 * The index must be freed once it's no longer being used by
Packit ae9e2a
 * the user.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out Pointer to store the loaded index
Packit ae9e2a
 * @param repo A repository object
Packit ae9e2a
 * @return 0, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Retrieve git's prepared message
Packit ae9e2a
 *
Packit ae9e2a
 * Operations such as git revert/cherry-pick/merge with the -n option
Packit ae9e2a
 * stop just short of creating a commit with the changes and save
Packit ae9e2a
 * their prepared message in .git/MERGE_MSG so the next git-commit
Packit ae9e2a
 * execution can present it to the user for them to amend if they
Packit ae9e2a
 * wish.
Packit ae9e2a
 *
Packit ae9e2a
 * Use this function to get the contents of this file. Don't forget to
Packit ae9e2a
 * remove the file after you create the commit.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out git_buf to write data into
Packit ae9e2a
 * @param repo Repository to read prepared message from
Packit ae9e2a
 * @return 0, GIT_ENOTFOUND if no message exists or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_message(git_buf *out, git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Remove git's prepared message.
Packit ae9e2a
 *
Packit ae9e2a
 * Remove the message that `git_repository_message` retrieves.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_message_remove(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Remove all the metadata associated with an ongoing command like merge,
Packit ae9e2a
 * revert, cherry-pick, etc.  For example: MERGE_HEAD, MERGE_MSG, etc.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo A repository object
Packit ae9e2a
 * @return 0 on success, or error
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_state_cleanup(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
typedef int (*git_repository_fetchhead_foreach_cb)(const char *ref_name,
Packit ae9e2a
	const char *remote_url,
Packit ae9e2a
	const git_oid *oid,
Packit ae9e2a
	unsigned int is_merge,
Packit ae9e2a
	void *payload);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Invoke 'callback' for each entry in the given FETCH_HEAD file.
Packit ae9e2a
 *
Packit ae9e2a
 * Return a non-zero value from the callback to stop the loop.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo A repository object
Packit ae9e2a
 * @param callback Callback function
Packit ae9e2a
 * @param payload Pointer to callback data (optional)
Packit ae9e2a
 * @return 0 on success, non-zero callback return value, GIT_ENOTFOUND if
Packit ae9e2a
 *         there is no FETCH_HEAD file, or other error code.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_fetchhead_foreach(
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	git_repository_fetchhead_foreach_cb callback,
Packit ae9e2a
	void *payload);
Packit ae9e2a
Packit ae9e2a
typedef int (*git_repository_mergehead_foreach_cb)(const git_oid *oid,
Packit ae9e2a
	void *payload);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * If a merge is in progress, invoke 'callback' for each commit ID in the
Packit ae9e2a
 * MERGE_HEAD file.
Packit ae9e2a
 *
Packit ae9e2a
 * Return a non-zero value from the callback to stop the loop.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo A repository object
Packit ae9e2a
 * @param callback Callback function
Packit ae9e2a
 * @param payload Pointer to callback data (optional)
Packit ae9e2a
 * @return 0 on success, non-zero callback return value, GIT_ENOTFOUND if
Packit ae9e2a
 *         there is no MERGE_HEAD file, or other error code.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_mergehead_foreach(
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	git_repository_mergehead_foreach_cb callback,
Packit ae9e2a
	void *payload);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Calculate hash of file using repository filtering rules.
Packit ae9e2a
 *
Packit ae9e2a
 * If you simply want to calculate the hash of a file on disk with no filters,
Packit ae9e2a
 * you can just use the `git_odb_hashfile()` API.  However, if you want to
Packit ae9e2a
 * hash a file in the repository and you want to apply filtering rules (e.g.
Packit ae9e2a
 * crlf filters) before generating the SHA, then use this function.
Packit ae9e2a
 *
Packit ae9e2a
 * Note: if the repository has `core.safecrlf` set to fail and the
Packit ae9e2a
 * filtering triggers that failure, then this function will return an
Packit ae9e2a
 * error and not calculate the hash of the file.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out Output value of calculated SHA
Packit ae9e2a
 * @param repo Repository pointer
Packit ae9e2a
 * @param path Path to file on disk whose contents should be hashed. If the
Packit ae9e2a
 *             repository is not NULL, this can be a relative path.
Packit ae9e2a
 * @param type The object type to hash as (e.g. GIT_OBJ_BLOB)
Packit ae9e2a
 * @param as_path The path to use to look up filtering rules. If this is
Packit ae9e2a
 *             NULL, then the `path` parameter will be used instead. If
Packit ae9e2a
 *             this is passed as the empty string, then no filters will be
Packit ae9e2a
 *             applied when calculating the hash.
Packit ae9e2a
 * @return 0 on success, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_hashfile(
Packit ae9e2a
	git_oid *out,
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	const char *path,
Packit ae9e2a
	git_otype type,
Packit ae9e2a
	const char *as_path);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Make the repository HEAD point to the specified reference.
Packit ae9e2a
 *
Packit ae9e2a
 * If the provided reference points to a Tree or a Blob, the HEAD is
Packit ae9e2a
 * unaltered and -1 is returned.
Packit ae9e2a
 *
Packit ae9e2a
 * If the provided reference points to a branch, the HEAD will point
Packit ae9e2a
 * to that branch, staying attached, or become attached if it isn't yet.
Packit ae9e2a
 * If the branch doesn't exist yet, no error will be return. The HEAD
Packit ae9e2a
 * will then be attached to an unborn branch.
Packit ae9e2a
 *
Packit ae9e2a
 * Otherwise, the HEAD will be detached and will directly point to
Packit ae9e2a
 * the Commit.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo Repository pointer
Packit ae9e2a
 * @param refname Canonical name of the reference the HEAD should point at
Packit ae9e2a
 * @return 0 on success, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_set_head(
Packit ae9e2a
	git_repository* repo,
Packit ae9e2a
	const char* refname);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Make the repository HEAD directly point to the Commit.
Packit ae9e2a
 *
Packit ae9e2a
 * If the provided committish cannot be found in the repository, the HEAD
Packit ae9e2a
 * is unaltered and GIT_ENOTFOUND is returned.
Packit ae9e2a
 *
Packit ae9e2a
 * If the provided commitish cannot be peeled into a commit, the HEAD
Packit ae9e2a
 * is unaltered and -1 is returned.
Packit ae9e2a
 *
Packit ae9e2a
 * Otherwise, the HEAD will eventually be detached and will directly point to
Packit ae9e2a
 * the peeled Commit.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo Repository pointer
Packit ae9e2a
 * @param commitish Object id of the Commit the HEAD should point to
Packit ae9e2a
 * @return 0 on success, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_set_head_detached(
Packit ae9e2a
	git_repository* repo,
Packit ae9e2a
	const git_oid* commitish);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Make the repository HEAD directly point to the Commit.
Packit ae9e2a
 *
Packit ae9e2a
 * This behaves like `git_repository_set_head_detached()` but takes an
Packit ae9e2a
 * annotated commit, which lets you specify which extended sha syntax
Packit ae9e2a
 * string was specified by a user, allowing for more exact reflog
Packit ae9e2a
 * messages.
Packit ae9e2a
 *
Packit ae9e2a
 * See the documentation for `git_repository_set_head_detached()`.
Packit ae9e2a
 *
Packit ae9e2a
 * @see git_repository_set_head_detached
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_set_head_detached_from_annotated(
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	const git_annotated_commit *commitish);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Detach the HEAD.
Packit ae9e2a
 *
Packit ae9e2a
 * If the HEAD is already detached and points to a Commit, 0 is returned.
Packit ae9e2a
 *
Packit ae9e2a
 * If the HEAD is already detached and points to a Tag, the HEAD is
Packit ae9e2a
 * updated into making it point to the peeled Commit, and 0 is returned.
Packit ae9e2a
 *
Packit ae9e2a
 * If the HEAD is already detached and points to a non commitish, the HEAD is
Packit ae9e2a
 * unaltered, and -1 is returned.
Packit ae9e2a
 *
Packit ae9e2a
 * Otherwise, the HEAD will be detached and point to the peeled Commit.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo Repository pointer
Packit ae9e2a
 * @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing
Packit ae9e2a
 * branch or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_detach_head(
Packit ae9e2a
	git_repository* repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Repository state
Packit ae9e2a
 *
Packit ae9e2a
 * These values represent possible states for the repository to be in,
Packit ae9e2a
 * based on the current operation which is ongoing.
Packit ae9e2a
 */
Packit ae9e2a
typedef enum {
Packit ae9e2a
	GIT_REPOSITORY_STATE_NONE,
Packit ae9e2a
	GIT_REPOSITORY_STATE_MERGE,
Packit ae9e2a
	GIT_REPOSITORY_STATE_REVERT,
Packit ae9e2a
	GIT_REPOSITORY_STATE_REVERT_SEQUENCE,
Packit ae9e2a
	GIT_REPOSITORY_STATE_CHERRYPICK,
Packit ae9e2a
	GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE,
Packit ae9e2a
	GIT_REPOSITORY_STATE_BISECT,
Packit ae9e2a
	GIT_REPOSITORY_STATE_REBASE,
Packit ae9e2a
	GIT_REPOSITORY_STATE_REBASE_INTERACTIVE,
Packit ae9e2a
	GIT_REPOSITORY_STATE_REBASE_MERGE,
Packit ae9e2a
	GIT_REPOSITORY_STATE_APPLY_MAILBOX,
Packit ae9e2a
	GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE,
Packit ae9e2a
} git_repository_state_t;
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Determines the status of a git repository - ie, whether an operation
Packit ae9e2a
 * (merge, cherry-pick, etc) is in progress.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo Repository pointer
Packit ae9e2a
 * @return The state of the repository
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_state(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Sets the active namespace for this Git Repository
Packit ae9e2a
 *
Packit ae9e2a
 * This namespace affects all reference operations for the repo.
Packit ae9e2a
 * See `man gitnamespaces`
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo The repo
Packit ae9e2a
 * @param nmspace The namespace. This should not include the refs
Packit ae9e2a
 *	folder, e.g. to namespace all references under `refs/namespaces/foo/`,
Packit ae9e2a
 *	use `foo` as the namespace.
Packit ae9e2a
 *	@return 0 on success, -1 on error
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_set_namespace(git_repository *repo, const char *nmspace);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the currently active namespace for this repository
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo The repo
Packit ae9e2a
 * @return the active namespace, or NULL if there isn't one
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const char *) git_repository_get_namespace(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Determine if the repository was a shallow clone
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo The repository
Packit ae9e2a
 * @return 1 if shallow, zero if not
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_is_shallow(git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Retrieve the configured identity to use for reflogs
Packit ae9e2a
 *
Packit ae9e2a
 * The memory is owned by the repository and must not be freed by the
Packit ae9e2a
 * user.
Packit ae9e2a
 *
Packit ae9e2a
 * @param name where to store the pointer to the name
Packit ae9e2a
 * @param email where to store the pointer to the email
Packit ae9e2a
 * @param repo the repository
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_ident(const char **name, const char **email, const git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Set the identity to be used for writing reflogs
Packit ae9e2a
 *
Packit ae9e2a
 * If both are set, this name and email will be used to write to the
Packit ae9e2a
 * reflog. Pass NULL to unset. When unset, the identity will be taken
Packit ae9e2a
 * from the repository's configuration.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo the repository to configure
Packit ae9e2a
 * @param name the name to use for the reflog entries
Packit ae9e2a
 * @param email the email to use for the reflog entries
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_repository_set_ident(git_repository *repo, const char *name, const char *email);
Packit ae9e2a
Packit ae9e2a
/** @} */
Packit ae9e2a
GIT_END_DECL
Packit ae9e2a
#endif