mirror of
https://git.proxmox.com/git/libgit2
synced 2025-12-30 21:34:00 +00:00
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>
This commit is contained in:
parent
b5a8aa94bf
commit
778e1c739b
@ -45,6 +45,18 @@ GIT_BEGIN_DECL
|
||||
* - _del (needs support from config)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a new unnamed remote
|
||||
*
|
||||
* Useful when you don't want to store the remote
|
||||
*
|
||||
* @param out pointer to the new remote object
|
||||
* @param repo the associtated repository
|
||||
* @param url the remote repository's URL
|
||||
* @return GIT_SUCCESS or an error message
|
||||
*/
|
||||
int git_remote_new(git_remote **out, git_repository *repo, const char *url);
|
||||
|
||||
/**
|
||||
* Get the information for a particular remote
|
||||
*
|
||||
|
||||
20
src/remote.c
20
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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user