summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/odb.h2
-rw-r--r--include/git2/remote.h18
-rw-r--r--include/git2/repository.h232
3 files changed, 45 insertions, 207 deletions
diff --git a/include/git2/odb.h b/include/git2/odb.h
index 27837418b..b99c40e00 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -92,7 +92,7 @@ GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, in
*
* @param db database pointer to close. If NULL no action is taken.
*/
-GIT_EXTERN(void) git_odb_close(git_odb *db);
+GIT_EXTERN(void) git_odb_free(git_odb *db);
/**
* Read an object from the database.
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 43bbe9e1c..2bc2d16ec 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -39,7 +39,7 @@ GIT_BEGIN_DECL
* @param name the remote's name
* @return GIT_SUCCESS or an error code
*/
-int git_remote_new(git_remote **out, git_repository *repo, const char *url, const char *name);
+GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *url, const char *name);
/**
* Get the information for a particular remote
@@ -49,7 +49,7 @@ int git_remote_new(git_remote **out, git_repository *repo, const char *url, cons
* @param name the remote's name
* @return GIT_SUCCESS or an error code
*/
-GIT_EXTERN(int) git_remote_get(struct git_remote **out, struct git_config *cfg, const char *name);
+GIT_EXTERN(int) git_remote_load(git_remote **out, git_repository *repo, const char *name);
/**
* Get the remote's name
@@ -57,7 +57,7 @@ GIT_EXTERN(int) git_remote_get(struct git_remote **out, struct git_config *cfg,
* @param remote the remote
* @return a pointer to the name
*/
-GIT_EXTERN(const char *) git_remote_name(struct git_remote *remote);
+GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
/**
* Get the remote's url
@@ -65,7 +65,7 @@ GIT_EXTERN(const char *) git_remote_name(struct git_remote *remote);
* @param remote the remote
* @return a pointer to the url
*/
-GIT_EXTERN(const char *) git_remote_url(struct git_remote *remote);
+GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
/**
* Get the fetch refspec
@@ -73,7 +73,7 @@ GIT_EXTERN(const char *) git_remote_url(struct git_remote *remote);
* @param remote the remote
* @return a pointer to the fetch refspec or NULL if it doesn't exist
*/
-GIT_EXTERN(const git_refspec *) git_remote_fetchspec(struct git_remote *remote);
+GIT_EXTERN(const git_refspec *) git_remote_fetchspec(git_remote *remote);
/**
* Get the push refspec
@@ -82,7 +82,7 @@ GIT_EXTERN(const git_refspec *) git_remote_fetchspec(struct git_remote *remote);
* @return a pointer to the push refspec or NULL if it doesn't exist
*/
-GIT_EXTERN(const git_refspec *) git_remote_pushspec(struct git_remote *remote);
+GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
/**
* Open a connection to a remote
@@ -95,7 +95,7 @@ GIT_EXTERN(const git_refspec *) git_remote_pushspec(struct git_remote *remote);
* @param direction whether you want to receive or send data
* @return GIT_SUCCESS or an error code
*/
-GIT_EXTERN(int) git_remote_connect(struct git_remote *remote, int direction);
+GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
/**
* Get a list of refs at the remote
@@ -149,7 +149,7 @@ GIT_EXTERN(void) git_remote_disconnect(git_remote *remote);
*
* @param remote the remote to free
*/
-GIT_EXTERN(void) git_remote_free(struct git_remote *remote);
+GIT_EXTERN(void) git_remote_free(git_remote *remote);
/**
* Update the tips to the new state
@@ -159,7 +159,7 @@ GIT_EXTERN(void) git_remote_free(struct git_remote *remote);
*
* @param remote the remote to update
*/
-GIT_EXTERN(int) git_remote_update_tips(struct git_remote *remote);
+GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
/** @} */
GIT_END_DECL
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 2e9baf6c0..bacb48145 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -23,21 +23,11 @@ GIT_BEGIN_DECL
/**
* Open a git repository.
*
- * The 'path' argument must point to an existing git repository
- * folder, e.g.
+ * The 'path' argument must point to either a git repository
+ * folder, or an existing work dir.
*
- * /path/to/my_repo/.git/ (normal repository)
- * objects/
- * index
- * HEAD
- *
- * /path/to/bare_repo/ (bare repository)
- * objects/
- * index
- * HEAD
- *
- * The method will automatically detect if 'path' is a normal
- * or bare repository or fail is 'path' is neither.
+ * The method will automatically detect if 'path' is a normal
+ * or bare repository or fail is 'path' is neither.
*
* @param repository pointer to the repo which will be opened
* @param path the path to the repository
@@ -45,130 +35,40 @@ GIT_BEGIN_DECL
*/
GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *path);
-
-/**
- * Open a git repository by manually specifying all its paths
- *
- * @param repository pointer to the repo which will be opened
- *
- * @param git_dir The full path to the repository folder
- * e.g. a '.git' folder for live repos, any folder for bare
- * Equivalent to $GIT_DIR.
- * Cannot be NULL.
- *
- * @param git_object_directory The full path to the ODB folder.
- * the folder where all the loose and packed objects are stored
- * Equivalent to $GIT_OBJECT_DIRECTORY.
- * If NULL, "$GIT_DIR/objects/" is assumed.
- *
- * @param git_index_file The full path to the index (dircache) file
- * Equivalent to $GIT_INDEX_FILE.
- * If NULL, "$GIT_DIR/index" is assumed.
- *
- * @param git_work_tree The full path to the working tree of the repository,
- * if the repository is not bare.
- * Equivalent to $GIT_WORK_TREE.
- * If NULL, the repository is assumed to be bare.
- *
- * @return GIT_SUCCESS or an error code
- */
-GIT_EXTERN(int) git_repository_open2(git_repository **repository,
- const char *git_dir,
- const char *git_object_directory,
- const char *git_index_file,
- const char *git_work_tree);
-
-
-/**
- * Open a git repository by manually specifying its paths and
- * the object database it will use.
- *
- * @param repository pointer to the repo which will be opened
- *
- * @param git_dir The full path to the repository folder
- * e.g. a '.git' folder for live repos, any folder for bare
- * Equivalent to $GIT_DIR.
- * Cannot be NULL.
- *
- * @param object_database A pointer to a git_odb created & initialized
- * by the user (e.g. with custom backends). This object database
- * will be owned by the repository and will be automatically free'd.
- * It should not be manually free'd by the user, or this
- * git_repository object will become invalid.
- *
- * @param git_index_file The full path to the index (dircache) file
- * Equivalent to $GIT_INDEX_FILE.
- * If NULL, "$GIT_DIR/index" is assumed.
- *
- * @param git_work_tree The full path to the working tree of the repository,
- * if the repository is not bare.
- * Equivalent to $GIT_WORK_TREE.
- * If NULL, the repository is assumed to be bare.
- *
- * @return GIT_SUCCESS or an error code
- */
-
-GIT_EXTERN(int) git_repository_open3(git_repository **repository,
- const char *git_dir,
- git_odb *object_database,
- const char *git_index_file,
- const char *git_work_tree);
-
/**
- * Look for a git repository and copy its path in the given buffer. The lookup start
- * from base_path and walk across parent directories if nothing has been found. The
- * lookup ends when the first repository is found, or when reaching a directory
- * referenced in ceiling_dirs or when the filesystem changes (in case across_fs
- * is true).
+ * Look for a git repository and copy its path in the given buffer.
+ * The lookup start from base_path and walk across parent directories
+ * if nothing has been found. The lookup ends when the first repository
+ * is found, or when reaching a directory referenced in ceiling_dirs
+ * or when the filesystem changes (in case across_fs is true).
*
- * The method will automatically detect if the repository is bare (if there is
- * a repository).
+ * The method will automatically detect if the repository is bare
+ * (if there is a repository).
*
- * @param repository_path The user allocated buffer which will contain the found path.
+ * @param repository_path The user allocated buffer which will
+ * contain the found path.
*
* @param size repository_path size
*
* @param start_path The base path where the lookup starts.
*
- * @param across_fs If true, then the lookup will not stop when a filesystem device change
- * is detected while exploring parent directories.
+ * @param across_fs If true, then the lookup will not stop when a
+ * filesystem device change is detected while exploring parent directories.
*
- * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR separated list of absolute symbolic link
- * free paths. The lookup will stop when any of this paths is reached. Note that the
- * lookup always performs on start_path no matter start_path appears in ceiling_dirs
- * ceiling_dirs might be NULL (which is equivalent to an empty string)
+ * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR separated list of
+ * absolute symbolic link free paths. The lookup will stop when any
+ * of this paths is reached. Note that the lookup always performs on
+ * start_path no matter start_path appears in ceiling_dirs ceiling_dirs
+ * might be NULL (which is equivalent to an empty string)
*
* @return GIT_SUCCESS or an error code
*/
-GIT_EXTERN(int) git_repository_discover(char *repository_path, size_t size, const char *start_path, int across_fs, const char *ceiling_dirs);
-
-/**
- * Get the object database behind a Git repository
- *
- * @param repo a repository object
- * @return a pointer to the object db
- */
-GIT_EXTERN(git_odb *) git_repository_database(git_repository *repo);
-
-/**
- * Open the Index file of a Git repository
- *
- * This returns a new and unique `git_index` object representing the
- * active index for the repository.
- *
- * This method may be called more than once (e.g. on different threads).
- *
- * Each returned `git_index` object is independent and suffers no race
- * conditions: synchronization is done at the FS level.
- *
- * Each returned `git_index` object must be manually freed by the user,
- * using `git_index_free`.
- *
- * @param index Pointer where to store the index
- * @param repo a repository object
- * @return GIT_SUCCESS or an error code
- */
-GIT_EXTERN(int) git_repository_index(git_index **index, git_repository *repo);
+GIT_EXTERN(int) git_repository_discover(
+ char *repository_path,
+ size_t size,
+ const char *start_path,
+ int across_fs,
+ const char *ceiling_dirs);
/**
* Free a previously allocated repository
@@ -246,32 +146,9 @@ GIT_EXTERN(int) git_repository_head_orphan(git_repository *repo);
*/
GIT_EXTERN(int) git_repository_is_empty(git_repository *repo);
-/**
- * Internal path identifiers for a repository
- */
-typedef enum {
- GIT_REPO_PATH,
- GIT_REPO_PATH_INDEX,
- GIT_REPO_PATH_ODB,
- GIT_REPO_PATH_WORKDIR
-} git_repository_pathid;
-
-/**
- * Get one of the paths to the repository
- *
- * Possible values for `id`:
- *
- * GIT_REPO_PATH: return the path to the repository
- * GIT_REPO_PATH_INDEX: return the path to the index
- * GIT_REPO_PATH_ODB: return the path to the ODB
- * GIT_REPO_PATH_WORKDIR: return the path to the working
- * directory
- *
- * @param repo a repository object
- * @param id The ID of the path to return
- * @return absolute path of the requested id
- */
-GIT_EXTERN(const char *) git_repository_path(git_repository *repo, git_repository_pathid id);
+GIT_EXTERN(const char *) git_repository_path(git_repository *repo);
+GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo);
+GIT_EXTERN(int) git_repository_set_workdir(git_repository *repo, const char *workdir);
/**
* Check if a repository is bare
@@ -281,53 +158,14 @@ GIT_EXTERN(const char *) git_repository_path(git_repository *repo, git_repositor
*/
GIT_EXTERN(int) git_repository_is_bare(git_repository *repo);
-/**
- * Retrieve the relevant configuration for a repository
- *
- * If either the `global_config_path` or `system_config_path`
- * variables are not NULL, the given config files will be also
- * included in the configuration set. The global configuration file is
- * located in $HOME/.gitconfig. On most UNIX systems, the system
- * config file file may be found on `$sysconfdir/gitconfig`.
- *
- * The resulting `git_config` instance will query the files in the following
- * order:
- *
- * - Repository configuration file
- * - Global configuration file
- * - System configuration file
- *
- * The method will fail if any of the given config files can't be
- * found or accessed.
- *
- * The returned `git_config` instance is owned by the caller and must
- * be manually free'd once it's no longer on use.
- *
- * @param out the repository's configuration
- * @param repo the repository for which to get the config
- * @param system_config_path Path to the global config file
- * @param system_config_path Path to the system-wide config file
- */
+GIT_EXTERN(int) git_repository_config(git_config **out, git_repository *repo);
+GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *config);
-GIT_EXTERN(int) git_repository_config(git_config **out,
- git_repository *repo,
- const char *global_config_path,
- const char *system_config_path);
+GIT_EXTERN(int) git_repository_odb(git_odb **out, git_repository *repo);
+GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
-/**
- * Automatically load the configuration files
- *
- * A wrapper around `git_repository_config` that tries to guess where
- * the global and system config files are located. No error is
- * reported if either of these files are missing at the guessed
- * locations.
- *
- * @param out the repository's configuration
- * @param repo the repository for which to get the config
- */
-GIT_EXTERN(int) git_repository_config_autoload(
- git_config **out,
- git_repository *repo);
+GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
+GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index);
/** @} */
GIT_END_DECL