-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to git_transport extensibility
git_remote_set_transport now takes a transport factory rather than a transport git_clone_options now allows the caller to specify a remote creation callback
- Loading branch information
Showing
10 changed files
with
177 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "clar_libgit2.h" | ||
|
||
#include "git2/clone.h" | ||
#include "git2/transport.h" | ||
#include "fileops.h" | ||
|
||
static int custom_transport( | ||
git_transport **out, | ||
git_remote *owner, | ||
void *payload) | ||
{ | ||
*((int*)payload) = 1; | ||
|
||
return git_transport_local(out, owner, payload); | ||
} | ||
|
||
static int custom_transport_remote_create( | ||
git_remote **out, | ||
git_repository *repo, | ||
const char *name, | ||
const char *url, | ||
void *payload) | ||
{ | ||
int error; | ||
|
||
if ((error = git_remote_create(out, repo, name, url)) < 0) | ||
return error; | ||
|
||
if ((error = git_remote_set_transport(*out, custom_transport, payload)) < 0) | ||
return error; | ||
|
||
return 0; | ||
} | ||
|
||
void test_clone_transport__custom_transport(void) | ||
{ | ||
git_repository *repo; | ||
git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT; | ||
int custom_transport_used = 0; | ||
|
||
clone_opts.remote_cb = custom_transport_remote_create; | ||
clone_opts.remote_cb_payload = &custom_transport_used; | ||
|
||
cl_git_pass(git_clone(&repo, cl_fixture("testrepo.git"), "./custom_transport.git", &clone_opts)); | ||
git_repository_free(repo); | ||
|
||
cl_git_pass(git_futils_rmdir_r("./custom_transport.git", NULL, GIT_RMDIR_REMOVE_FILES)); | ||
|
||
cl_assert(custom_transport_used == 1); | ||
} |
Oops, something went wrong.