Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'examples/network/ls-remote.c')
-rw-r--r--examples/network/ls-remote.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/examples/network/ls-remote.c b/examples/network/ls-remote.c
index 39cc64725..252011828 100644
--- a/examples/network/ls-remote.c
+++ b/examples/network/ls-remote.c
@@ -7,25 +7,27 @@
static int show_ref__cb(git_remote_head *head, void *payload)
{
char oid[GIT_OID_HEXSZ + 1] = {0};
+
+ (void)payload;
git_oid_fmt(oid, &head->oid);
printf("%s\t%s\n", oid, head->name);
return 0;
}
-int use_unnamed(git_repository *repo, const char *url)
+static int use_unnamed(git_repository *repo, const char *url)
{
git_remote *remote = NULL;
int error;
// Create an instance of a remote from the URL. The transport to use
// is detected from the URL
- error = git_remote_new(&remote, repo, NULL, url, NULL);
+ error = git_remote_create_inmemory(&remote, repo, NULL, url);
if (error < 0)
goto cleanup;
// When connecting, the underlying code needs to know wether we
// want to push or fetch
- error = git_remote_connect(remote, GIT_DIR_FETCH);
+ error = git_remote_connect(remote, GIT_DIRECTION_FETCH);
if (error < 0)
goto cleanup;
@@ -37,7 +39,7 @@ cleanup:
return error;
}
-int use_remote(git_repository *repo, char *name)
+static int use_remote(git_repository *repo, char *name)
{
git_remote *remote = NULL;
int error;
@@ -47,7 +49,7 @@ int use_remote(git_repository *repo, char *name)
if (error < 0)
goto cleanup;
- error = git_remote_connect(remote, GIT_DIR_FETCH);
+ error = git_remote_connect(remote, GIT_DIRECTION_FETCH);
if (error < 0)
goto cleanup;
@@ -63,7 +65,12 @@ cleanup:
int ls_remote(git_repository *repo, int argc, char **argv)
{
- int error, i;
+ int error;
+
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s ls-remote <remote>\n", argv[-1]);
+ return EXIT_FAILURE;
+ }
/* If there's a ':' in the name, assume it's an URL */
if (strchr(argv[1], ':') != NULL) {