mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-21 22:21:37 +00:00
API updates for repository.h
This commit is contained in:
parent
cb7ac81c4d
commit
c9fc4a6ff9
@ -29,11 +29,11 @@ GIT_BEGIN_DECL
|
|||||||
* The method will automatically detect if 'path' is a normal
|
* The method will automatically detect if 'path' is a normal
|
||||||
* or bare repository or fail is 'path' is neither.
|
* or bare repository or fail is 'path' is neither.
|
||||||
*
|
*
|
||||||
* @param repository pointer to the repo which will be opened
|
* @param out pointer to the repo which will be opened
|
||||||
* @param path the path to the repository
|
* @param path the path to the repository
|
||||||
* @return 0 or an error code
|
* @return 0 or an error code
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *path);
|
GIT_EXTERN(int) git_repository_open(git_repository **out, const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a "fake" repository to wrap an object database
|
* Create a "fake" repository to wrap an object database
|
||||||
@ -42,11 +42,11 @@ GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *pat
|
|||||||
* with the API when all you have is an object database. This doesn't
|
* with the API when all you have is an object database. This doesn't
|
||||||
* have any paths associated with it, so use with care.
|
* have any paths associated with it, so use with care.
|
||||||
*
|
*
|
||||||
* @param repository pointer to the repo
|
* @param out pointer to the repo
|
||||||
* @param odb the object database to wrap
|
* @param odb the object database to wrap
|
||||||
* @return 0 or an error code
|
* @return 0 or an error code
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_repository_wrap_odb(git_repository **repository, git_odb *odb);
|
GIT_EXTERN(int) git_repository_wrap_odb(git_repository **out, git_odb *odb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for a git repository and copy its path in the given buffer.
|
* Look for a git repository and copy its path in the given buffer.
|
||||||
@ -58,10 +58,10 @@ GIT_EXTERN(int) git_repository_wrap_odb(git_repository **repository, git_odb *od
|
|||||||
* The method will automatically detect if the repository is bare
|
* The method will automatically detect if the repository is bare
|
||||||
* (if there is a repository).
|
* (if there is a repository).
|
||||||
*
|
*
|
||||||
* @param repository_path The user allocated buffer which will
|
* @param path_out The user allocated buffer which will
|
||||||
* contain the found path.
|
* contain the found path.
|
||||||
*
|
*
|
||||||
* @param size repository_path size
|
* @param path_size repository_path size
|
||||||
*
|
*
|
||||||
* @param start_path The base path where the lookup starts.
|
* @param start_path The base path where the lookup starts.
|
||||||
*
|
*
|
||||||
@ -77,8 +77,8 @@ GIT_EXTERN(int) git_repository_wrap_odb(git_repository **repository, git_odb *od
|
|||||||
* @return 0 or an error code
|
* @return 0 or an error code
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_repository_discover(
|
GIT_EXTERN(int) git_repository_discover(
|
||||||
char *repository_path,
|
char *path_out,
|
||||||
size_t size,
|
size_t path_size,
|
||||||
const char *start_path,
|
const char *start_path,
|
||||||
int across_fs,
|
int across_fs,
|
||||||
const char *ceiling_dirs);
|
const char *ceiling_dirs);
|
||||||
@ -95,18 +95,18 @@ GIT_EXTERN(int) git_repository_discover(
|
|||||||
* directory "/home/user/source/" will not return "/.git/" as the found
|
* directory "/home/user/source/" will not return "/.git/" as the found
|
||||||
* repo if "/" is a different filesystem than "/home".)
|
* repo if "/" is a different filesystem than "/home".)
|
||||||
*/
|
*/
|
||||||
enum {
|
typedef enum {
|
||||||
GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0),
|
GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0),
|
||||||
GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1),
|
GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1),
|
||||||
};
|
} git_repository_open_flags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find and open a repository with extended controls.
|
* Find and open a repository with extended controls.
|
||||||
*
|
*
|
||||||
* @param repo_out Pointer to the repo which will be opened. This can
|
* @param out Pointer to the repo which will be opened. This can
|
||||||
* actually be NULL if you only want to use the error code to
|
* actually be NULL if you only want to use the error code to
|
||||||
* see if a repo at this path could be opened.
|
* see if a repo at this path could be opened.
|
||||||
* @param start_path Path to open as git repository. If the flags
|
* @param path Path to open as git repository. If the flags
|
||||||
* permit "searching", then this can be a path to a subdirectory
|
* permit "searching", then this can be a path to a subdirectory
|
||||||
* inside the working directory of the repository.
|
* inside the working directory of the repository.
|
||||||
* @param flags A combination of the GIT_REPOSITORY_OPEN flags above.
|
* @param flags A combination of the GIT_REPOSITORY_OPEN flags above.
|
||||||
@ -118,9 +118,9 @@ enum {
|
|||||||
* (such as repo corruption or system errors).
|
* (such as repo corruption or system errors).
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_repository_open_ext(
|
GIT_EXTERN(int) git_repository_open_ext(
|
||||||
git_repository **repo,
|
git_repository **out,
|
||||||
const char *start_path,
|
const char *path,
|
||||||
uint32_t flags,
|
unsigned int flags,
|
||||||
const char *ceiling_dirs);
|
const char *ceiling_dirs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,7 +142,7 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo);
|
|||||||
* TODO:
|
* TODO:
|
||||||
* - Reinit the repository
|
* - Reinit the repository
|
||||||
*
|
*
|
||||||
* @param repo_out pointer to the repo which will be created or reinitialized
|
* @param out pointer to the repo which will be created or reinitialized
|
||||||
* @param path the path to the repository
|
* @param path the path to the repository
|
||||||
* @param is_bare if true, a Git repository without a working directory is
|
* @param is_bare if true, a Git repository without a working directory is
|
||||||
* created at the pointed path. If false, provided path will be
|
* created at the pointed path. If false, provided path will be
|
||||||
@ -152,7 +152,7 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo);
|
|||||||
* @return 0 or an error code
|
* @return 0 or an error code
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_repository_init(
|
GIT_EXTERN(int) git_repository_init(
|
||||||
git_repository **repo_out,
|
git_repository **out,
|
||||||
const char *path,
|
const char *path,
|
||||||
unsigned is_bare);
|
unsigned is_bare);
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ enum {
|
|||||||
* repository initialization is completed, an "origin" remote
|
* repository initialization is completed, an "origin" remote
|
||||||
* will be added pointing to this URL.
|
* will be added pointing to this URL.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct git_repository_init_options {
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t mode;
|
uint32_t mode;
|
||||||
const char *workdir_path;
|
const char *workdir_path;
|
||||||
@ -256,26 +256,26 @@ typedef struct {
|
|||||||
* auto-detect the case sensitivity of the file system and if the
|
* auto-detect the case sensitivity of the file system and if the
|
||||||
* file system supports file mode bits correctly.
|
* file system supports file mode bits correctly.
|
||||||
*
|
*
|
||||||
* @param repo_out Pointer to the repo which will be created or reinitialized.
|
* @param out Pointer to the repo which will be created or reinitialized.
|
||||||
* @param repo_path The path to the repository.
|
* @param repo_path The path to the repository.
|
||||||
* @param opts Pointer to git_repository_init_options struct.
|
* @param opts Pointer to git_repository_init_options struct.
|
||||||
* @return 0 or an error code on failure.
|
* @return 0 or an error code on failure.
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_repository_init_ext(
|
GIT_EXTERN(int) git_repository_init_ext(
|
||||||
git_repository **repo_out,
|
git_repository **out,
|
||||||
const char *repo_path,
|
const char *repo_path,
|
||||||
git_repository_init_options *opts);
|
git_repository_init_options *opts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve and resolve the reference pointed at by HEAD.
|
* Retrieve and resolve the reference pointed at by HEAD.
|
||||||
*
|
*
|
||||||
* @param head_out pointer to the reference which will be retrieved
|
* @param out pointer to the reference which will be retrieved
|
||||||
* @param repo a repository object
|
* @param repo a repository object
|
||||||
*
|
*
|
||||||
* @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing
|
* @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing
|
||||||
* branch, GIT_ENOTFOUND when HEAD is missing; an error code otherwise
|
* branch, GIT_ENOTFOUND when HEAD is missing; an error code otherwise
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_repository_head(git_reference **head_out, git_repository *repo);
|
GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a repository's HEAD is detached
|
* Check if a repository's HEAD is detached
|
||||||
@ -468,12 +468,12 @@ GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index
|
|||||||
* Use this function to get the contents of this file. Don't forget to
|
* Use this function to get the contents of this file. Don't forget to
|
||||||
* remove the file after you create the commit.
|
* remove the file after you create the commit.
|
||||||
*
|
*
|
||||||
* @param buffer Buffer to write data into or NULL to just read required size
|
* @param out Buffer to write data into or NULL to just read required size
|
||||||
* @param len Length of buffer in bytes
|
* @param len Length of buffer in bytes
|
||||||
* @param repo Repository to read prepared message from
|
* @param repo Repository to read prepared message from
|
||||||
* @return Bytes written to buffer, GIT_ENOTFOUND if no message, or -1 on error
|
* @return Bytes written to buffer, GIT_ENOTFOUND if no message, or -1 on error
|
||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_repository_message(char *buffer, size_t len, git_repository *repo);
|
GIT_EXTERN(int) git_repository_message(char *out, size_t len, git_repository *repo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove git's prepared message.
|
* Remove git's prepared message.
|
||||||
|
@ -361,7 +361,7 @@ static int find_repo(
|
|||||||
int git_repository_open_ext(
|
int git_repository_open_ext(
|
||||||
git_repository **repo_ptr,
|
git_repository **repo_ptr,
|
||||||
const char *start_path,
|
const char *start_path,
|
||||||
uint32_t flags,
|
unsigned int flags,
|
||||||
const char *ceiling_dirs)
|
const char *ceiling_dirs)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
@ -1162,14 +1162,14 @@ int git_repository_init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int git_repository_init_ext(
|
int git_repository_init_ext(
|
||||||
git_repository **repo_out,
|
git_repository **out,
|
||||||
const char *given_repo,
|
const char *given_repo,
|
||||||
git_repository_init_options *opts)
|
git_repository_init_options *opts)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT;
|
git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT;
|
||||||
|
|
||||||
assert(repo_out && given_repo && opts);
|
assert(out && given_repo && opts);
|
||||||
|
|
||||||
error = repo_init_directories(&repo_path, &wd_path, given_repo, opts);
|
error = repo_init_directories(&repo_path, &wd_path, given_repo, opts);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
@ -1202,10 +1202,10 @@ int git_repository_init_ext(
|
|||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
error = git_repository_open(repo_out, git_buf_cstr(&repo_path));
|
error = git_repository_open(out, git_buf_cstr(&repo_path));
|
||||||
|
|
||||||
if (!error && opts->origin_url)
|
if (!error && opts->origin_url)
|
||||||
error = repo_init_create_origin(*repo_out, opts->origin_url);
|
error = repo_init_create_origin(*out, opts->origin_url);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
git_buf_free(&repo_path);
|
git_buf_free(&repo_path);
|
||||||
|
Loading…
Reference in New Issue
Block a user