diff options
author | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-05-03 20:25:56 +0200 |
---|---|---|
committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-05-08 21:36:40 +0200 |
commit | baaa8a447ed6da152038770805464485d5d7bb21 (patch) | |
tree | e8e9a43b92d031153a4e8a2df21e51c6b945512b /src | |
parent | a209a025c642498f1fa1aecf91ce9e9504d0d419 (diff) | |
download | libgit2-baaa8a447ed6da152038770805464485d5d7bb21.tar.gz |
remotes: change git_remote_new's signature
Add a fetch refspec arguemnt and make the arguments (name, url,
refspec), as that order makes more sense.
Diffstat (limited to 'src')
-rw-r--r-- | src/remote.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/remote.c b/src/remote.c index 3678d3475..a5cfc822e 100644 --- a/src/remote.c +++ b/src/remote.c @@ -54,7 +54,7 @@ static int parse_remote_refspec(git_config *cfg, git_refspec *refspec, const cha return refspec_parse(refspec, val); } -int git_remote_new(git_remote **out, git_repository *repo, const char *url, const char *name) +int git_remote_new(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch) { git_remote *remote; @@ -78,8 +78,17 @@ int git_remote_new(git_remote **out, git_repository *repo, const char *url, cons GITERR_CHECK_ALLOC(remote->name); } + if (fetch != NULL) { + if (refspec_parse(&remote->fetch, fetch) < 0) + goto on_error; + } + *out = remote; return 0; + +on_error: + git_remote_free(remote); + return -1; } int git_remote_load(git_remote **out, git_repository *repo, const char *name) @@ -480,19 +489,17 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo) int git_remote_add(git_remote **out, git_repository *repo, const char *name, const char *url) { git_buf buf = GIT_BUF_INIT; - if (git_remote_new(out, repo, url, name) < 0) - return -1; if (git_buf_printf(&buf, "refs/heads/*:refs/remotes/%s/*", name) < 0) - goto on_error; + return -1; - if (git_remote_set_fetchspec(*out, git_buf_cstr(&buf)) < 0) + if (git_remote_new(out, repo, name, url, git_buf_cstr(&buf)) < 0) goto on_error; git_buf_free(&buf); if (git_remote_save(*out) < 0) - return -1; + goto on_error; return 0; |