diff options
| author | Victor Garcia <victor@tuenti.com> | 2013-11-07 14:16:20 +0100 |
|---|---|---|
| committer | Victor Garcia <victor@tuenti.com> | 2013-11-07 14:16:20 +0100 |
| commit | 0fe522d1057aef064084a22d116f7c225948a3bd (patch) | |
| tree | 1fe257f593d9d5c2f220897eabd5a3660bba47bd /src | |
| parent | e87d9d3d4d8de9c048476387931c4ac57d1c2b73 (diff) | |
| download | libgit2-0fe522d1057aef064084a22d116f7c225948a3bd.tar.gz | |
allowing create remote with custom fetch spec
Diffstat (limited to 'src')
| -rw-r--r-- | src/clone.c | 2 | ||||
| -rw-r--r-- | src/remote.c | 11 | ||||
| -rw-r--r-- | src/repository.c | 2 |
3 files changed, 9 insertions, 6 deletions
diff --git a/src/clone.c b/src/clone.c index 657243945..8d99e8fc8 100644 --- a/src/clone.c +++ b/src/clone.c @@ -309,7 +309,7 @@ static int create_and_configure_origin( const char *name; name = options->remote_name ? options->remote_name : "origin"; - if ((error = git_remote_create(&origin, repo, name, url)) < 0) + if ((error = git_remote_create(&origin, repo, name, url, NULL)) < 0) goto on_error; if (options->ignore_cert_errors) diff --git a/src/remote.c b/src/remote.c index 3528b1c46..b812c91dd 100644 --- a/src/remote.c +++ b/src/remote.c @@ -174,7 +174,7 @@ static int ensure_remote_doesnot_exist(git_repository *repo, const char *name) } -int git_remote_create(git_remote **out, git_repository *repo, const char *name, const char *url) +int git_remote_create(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch) { git_buf buf = GIT_BUF_INIT; git_remote *remote = NULL; @@ -186,10 +186,13 @@ int git_remote_create(git_remote **out, git_repository *repo, const char *name, if ((error = ensure_remote_doesnot_exist(repo, name)) < 0) return error; - if (git_buf_printf(&buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0) - return -1; + if (fetch == NULL) { + if (git_buf_printf(&buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0) + return -1; + fetch = git_buf_cstr(&buf); + } - if (create_internal(&remote, repo, name, url, git_buf_cstr(&buf)) < 0) + if (create_internal(&remote, repo, name, url, fetch) < 0) goto on_error; git_buf_free(&buf); diff --git a/src/repository.c b/src/repository.c index dcc02e4fb..f1eff165c 100644 --- a/src/repository.c +++ b/src/repository.c @@ -1473,7 +1473,7 @@ static int repo_init_create_origin(git_repository *repo, const char *url) int error; git_remote *remote; - if (!(error = git_remote_create(&remote, repo, GIT_REMOTE_ORIGIN, url))) { + if (!(error = git_remote_create(&remote, repo, GIT_REMOTE_ORIGIN, url, NULL))) { git_remote_free(remote); } |
