diff options
author | Vicent Marti <tanoku@gmail.com> | 2013-04-16 19:46:41 +0400 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2013-04-16 19:46:41 +0400 |
commit | a50086d174658914d4d6462afbc83b02825b1f5b (patch) | |
tree | e8daa1c7bf678222cf351445179837bed7db3a72 /examples/network/ls-remote.c | |
parent | 5b9fac39d8a76b9139667c26a63e6b3f204b3977 (diff) | |
parent | f124ebd457bfbf43de3516629aaba5a279636e04 (diff) |
Merge branch 'development'v0.18.0
Diffstat (limited to 'examples/network/ls-remote.c')
-rw-r--r-- | examples/network/ls-remote.c | 19 |
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) { |