diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-08-22 15:43:57 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-08-30 19:37:14 +0200 |
| commit | 778e1c739b1c9e06d5b3e3d5c965f4a63d40881f (patch) | |
| tree | b8912267df7d6957e67660416e2526882b2f7563 /src/remote.c | |
| parent | b5a8aa94bf144d77a922074c7dad38afcf0a6d24 (diff) | |
| download | libgit2-778e1c739b1c9e06d5b3e3d5c965f4a63d40881f.tar.gz | |
Add git_remote_new
As we no longer expose the transport functions, this is now the only
way to connect to a remote when given an URL instead of a remote name
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/remote.c')
| -rw-r--r-- | src/remote.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/remote.c b/src/remote.c index 765e93823..297789a69 100644 --- a/src/remote.c +++ b/src/remote.c @@ -74,6 +74,26 @@ 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) +{ + git_remote *remote; + + remote = git__malloc(sizeof(git_remote)); + if (remote == NULL) + return GIT_ENOMEM; + + memset(remote, 0x0, sizeof(git_remote)); + remote->repo = repo; + remote->url = git__strdup(url); + if (remote->url == NULL) { + free(remote); + return GIT_ENOMEM; + } + + *out = remote; + return GIT_SUCCESS; +} + int git_remote_get(git_remote **out, git_config *cfg, const char *name) { git_remote *remote; |
