Commit fdb116b3 by Etienne Samson

remote: add a creation flag for ignoring url.insteadOf

parent 3cbaebdf
......@@ -42,6 +42,14 @@ GIT_EXTERN(int) git_remote_create(
const char *url);
/**
* Remote creation options flags
*/
typedef enum {
/** Ignore the repository apply.insteadOf configuration */
GIT_REMOTE_CREATE_SKIP_INSTEADOF = (1 << 0),
} git_remote_create_flags;
/**
* Remote creation options structure
*
* Initialize with `GIT_REMOTE_CREATE_OPTIONS_INIT`. Alternatively, you can
......@@ -65,6 +73,9 @@ typedef struct git_remote_create_options {
/** The fetchspec the remote should use. */
const char *fetchspec;
/** Additional flags for the remote. See git_remote_create_flags. */
unsigned int flags;
} git_remote_create_options;
#define GIT_REMOTE_CREATE_OPTIONS_VERSION 1
......
......@@ -264,7 +264,7 @@ static int create_internal(git_remote **out, const char *url, const git_remote_c
(error = canonicalize_url(&canonical_url, url)) < 0)
goto on_error;
if (opts->repository) {
if (opts->repository && !(opts->flags & GIT_REMOTE_CREATE_SKIP_INSTEADOF)) {
remote->url = apply_insteadof(config_ro, canonical_url.ptr, GIT_DIRECTION_FETCH);
} else {
remote->url = git__strdup(canonical_url.ptr);
......
......@@ -311,6 +311,23 @@ void test_remote_create__with_opts_detached(void)
git_remote_free(remote);
}
void test_remote_create__with_opts_insteadof_disabled(void)
{
git_remote *remote;
git_remote_create_options opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
opts.repository = _repo;
opts.flags = GIT_REMOTE_CREATE_SKIP_INSTEADOF;
cl_git_pass(git_remote_create_with_opts(&remote, "http://example.com/libgit2/libgit2", &opts));
cl_assert_equal_s(git_remote_url(remote), "http://example.com/libgit2/libgit2");
cl_assert_equal_p(git_remote_pushurl(remote), NULL);
git_remote_free(remote);
}
static int create_with_name(git_remote **remote, git_repository *repo, const char *name, const char *url)
{
git_remote_create_options opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment