diff options
| author | Etienne Samson <samson.etienne@gmail.com> | 2018-06-20 02:27:11 +0200 |
|---|---|---|
| committer | Etienne Samson <samson.etienne@gmail.com> | 2018-11-02 14:58:12 +0100 |
| commit | 3cbaebdf7dac02b193f3416937c9cdb2e244f50b (patch) | |
| tree | ab3a4d3d3cd049a7b36077e6220d9a9de614b175 /include/git2 | |
| parent | 43b4b2faadbd46c3ef56516785f64b2b9cd2b5a0 (diff) | |
| download | libgit2-3cbaebdf7dac02b193f3416937c9cdb2e244f50b.tar.gz | |
remote: provide a generic API for creating remotes
This supersedes the functionality of remote_create_with_fetchspec, remote_create_anonymous and remote_create_detached.
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/remote.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/include/git2/remote.h b/include/git2/remote.h index f521fab78..b39d081d5 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -42,6 +42,66 @@ GIT_EXTERN(int) git_remote_create( const char *url); /** + * Remote creation options structure + * + * Initialize with `GIT_REMOTE_CREATE_OPTIONS_INIT`. Alternatively, you can + * use `git_remote_create_init_options`. + * + */ +typedef struct git_remote_create_options { + unsigned int version; + + /** + * The repository that should own the remote. + * Setting this to NULL results in a detached remote. + */ + git_repository *repository; + + /** + * The remote's name. + * Setting this to NULL results in an in-memory/anonymous remote. + */ + const char *name; + + /** The fetchspec the remote should use. */ + const char *fetchspec; +} git_remote_create_options; + +#define GIT_REMOTE_CREATE_OPTIONS_VERSION 1 +#define GIT_REMOTE_CREATE_OPTIONS_INIT {GIT_REMOTE_CREATE_OPTIONS_VERSION} + +/** + * Initialize git_remote_create_options structure + * + * Initializes a `git_remote_create_options` with default values. Equivalent to + * creating an instance with `GIT_REMOTE_CREATE_OPTIONS_INIT`. + * + * @param opts The `git_remote_create_options` struct to initialize. + * @param version The struct version; pass `GIT_REMOTE_CREATE_OPTIONS_VERSION`. + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_remote_create_init_options( + git_remote_create_options *opts, + unsigned int version); + +/** + * Create a remote, with options. + * + * This function allows more fine-grained control over the remote creation. + * + * Passing NULL as the opts argument will result in a detached remote. + * + * @param out the resulting remote + * @param url the remote's url + * @param opts the remote creation options + * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code + */ +GIT_EXTERN(int) git_remote_create_with_opts( + git_remote **out, + const char *url, + const git_remote_create_options *opts); + +/** * Add a remote with the provided fetch refspec (or default if NULL) to the repository's * configuration. * |
