diff options
author | Arthur Schreiber <schreiber.arthur@googlemail.com> | 2014-01-14 21:03:01 +0100 |
---|---|---|
committer | Arthur Schreiber <schreiber.arthur@googlemail.com> | 2014-01-14 21:03:01 +0100 |
commit | 40ef47dd46fdd361b49ccc97605a93e0993e96db (patch) | |
tree | 77e51167172c5324a7dde1f5faf8e55be670be68 /src/remote.c | |
parent | 557bd1f4108272c6db004aa8b7137d9254c14945 (diff) | |
download | libgit2-40ef47dd46fdd361b49ccc97605a93e0993e96db.tar.gz |
Add `git_remote_dup`.
Diffstat (limited to 'src/remote.c')
-rw-r--r-- | src/remote.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/remote.c b/src/remote.c index 294a8709d..6a4a707a4 100644 --- a/src/remote.c +++ b/src/remote.c @@ -248,6 +248,47 @@ int git_remote_create_inmemory(git_remote **out, git_repository *repo, const cha return 0; } +int git_remote_dup(git_remote **dest, const git_remote *source) +{ + int error; + git_remote *remote = git__calloc(1, sizeof(git_remote)); + GITERR_CHECK_ALLOC(remote); + + memset(remote, 0x0, sizeof(git_remote)); + + if (source->name != NULL) { + remote->name = git__strdup(source->name); + GITERR_CHECK_ALLOC(remote->name); + } + + if (source->url != NULL) { + remote->url = git__strdup(source->url); + GITERR_CHECK_ALLOC(remote->url); + } + + if (source->pushurl != NULL) { + remote->pushurl = git__strdup(source->pushurl); + GITERR_CHECK_ALLOC(remote->pushurl); + } + + remote->repo = source->repo; + remote->need_pack = source->need_pack; + remote->download_tags = source->download_tags; + remote->check_cert = source->check_cert; + remote->update_fetchhead = source->update_fetchhead; + + if ((error = git_vector_dup(&remote->refs, &source->refs, NULL)) < 0 || + (error = git_vector_dup(&remote->refspecs, &source->refspecs, NULL)) < 0 || + (error = git_vector_dup(&remote->active_refspecs, &source->active_refspecs, NULL))) { + git__free(remote); + return error; + } + + *dest = remote; + + return 0; +} + struct refspec_cb_data { git_remote *remote; int fetch; |