summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-11-02 21:57:14 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2014-11-02 21:58:39 +0100
commita68e217f5c273c5c7bc6a419c600b33747b8558a (patch)
tree4736841c1e0aeb7ad3234c030f6dd232b1832f25
parentea8dedc953919fa3f7a014ee1e0386f84ed326f1 (diff)
downloadlibgit2-cmn/remote-unify.tar.gz
remote: unify the creation codecmn/remote-unify
The create function with default refspec is the same as the one with a custom refspec, but it has the default refspec, so we can create the one on top of the other.
-rw-r--r--src/remote.c23
1 files changed, 2 insertions, 21 deletions
diff --git a/src/remote.c b/src/remote.c
index 0ae377e47..d346fb328 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -207,34 +207,15 @@ 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)
{
git_buf buf = GIT_BUF_INIT;
- git_remote *remote = NULL;
int error;
- if ((error = ensure_remote_name_is_valid(name)) < 0)
- return error;
-
- 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 (create_internal(&remote, repo, name, url, git_buf_cstr(&buf)) < 0)
- goto on_error;
-
+ error = git_remote_create_with_fetchspec(out, repo, name, url, git_buf_cstr(&buf));
git_buf_free(&buf);
- if (git_remote_save(remote) < 0)
- goto on_error;
-
- *out = remote;
-
- return 0;
-
-on_error:
- git_buf_free(&buf);
- git_remote_free(remote);
- return -1;
+ return error;
}
int git_remote_create_with_fetchspec(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch)