summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-07-25 10:52:20 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-07-30 20:28:16 +0200
commitae789622e438e213d8a2059f7aeeeae931442c18 (patch)
treece8fc86c0aa34f1b14c4c958767118d56244aed9 /examples
parentad4b5beb50dc484f86534dc127646eafb39d96fe (diff)
downloadlibgit2-ae789622e438e213d8a2059f7aeeeae931442c18.tar.gz
examples: fix warnings in network/
Diffstat (limited to 'examples')
-rw-r--r--examples/network/fetch.c9
-rw-r--r--examples/network/git2.c5
-rw-r--r--examples/network/index-pack.c47
-rw-r--r--examples/network/ls-remote.c9
4 files changed, 24 insertions, 46 deletions
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index 157f9142..52e0412f 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -40,9 +40,8 @@ exit:
pthread_exit(&data->ret);
}
-int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data)
+static int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data)
{
- const char *action;
char a_str[GIT_OID_HEXSZ+1], b_str[GIT_OID_HEXSZ+1];
git_oid_fmt(b_str, b);
@@ -68,6 +67,7 @@ int fetch(git_repository *repo, int argc, char **argv)
struct dl_data data;
git_remote_callbacks callbacks;
+ argc = argc;
// Figure out whether it's a named remote or a URL
printf("Fetching %s\n", argv[1]);
if (git_remote_load(&remote, repo, argv[1]) < 0) {
@@ -96,13 +96,14 @@ int fetch(git_repository *repo, int argc, char **argv)
// the download rate.
do {
usleep(10000);
- printf("\rReceived %d/%d objects in %d bytes", stats.processed, stats.total, bytes);
+ printf("\rReceived %d/%d objects in %zu bytes", stats.processed, stats.total, bytes);
} while (!data.finished);
if (data.ret < 0)
goto on_error;
- printf("\rReceived %d/%d objects in %d bytes\n", stats.processed, stats.total, bytes);
+ pthread_join(worker, NULL);
+ printf("\rReceived %d/%d objects in %zu bytes\n", stats.processed, stats.total, bytes);
// Disconnect the underlying connection to prevent from idling.
git_remote_disconnect(remote);
diff --git a/examples/network/git2.c b/examples/network/git2.c
index 7c02305c..1bfb13c9 100644
--- a/examples/network/git2.c
+++ b/examples/network/git2.c
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include "common.h"
@@ -16,7 +17,7 @@ struct {
{ NULL, NULL}
};
-int run_command(git_cb fn, int argc, char **argv)
+static int run_command(git_cb fn, int argc, char **argv)
{
int error;
git_repository *repo;
@@ -45,7 +46,7 @@ int run_command(git_cb fn, int argc, char **argv)
int main(int argc, char **argv)
{
- int i, error;
+ int i;
if (argc < 2) {
fprintf(stderr, "usage: %s <cmd> [repo]\n", argv[0]);
diff --git a/examples/network/index-pack.c b/examples/network/index-pack.c
index ef5a3595..85aac4af 100644
--- a/examples/network/index-pack.c
+++ b/examples/network/index-pack.c
@@ -2,13 +2,20 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
#include "common.h"
// This could be run in the main loop whilst the application waits for
// the indexing to finish in a worker thread
-int index_cb(const git_indexer_stats *stats, void *data)
+static int index_cb(const git_indexer_stats *stats, void *data)
{
+ data = data;
printf("\rProcessing %d of %d", stats->processed, stats->total);
+
+ return 0;
}
int index_pack(git_repository *repo, int argc, char **argv)
@@ -20,6 +27,7 @@ int index_pack(git_repository *repo, int argc, char **argv)
ssize_t read_bytes;
char buf[512];
+ repo = repo;
if (argc < 2) {
fprintf(stderr, "I need a packfile\n");
return EXIT_FAILURE;
@@ -43,7 +51,7 @@ int index_pack(git_repository *repo, int argc, char **argv)
if ((error = git_indexer_stream_add(idx, buf, read_bytes, &stats)) < 0)
goto cleanup;
- printf("\rIndexing %d of %d", stats.processed, stats.total);
+ index_cb(&stats, NULL);
} while (read_bytes > 0);
if (read_bytes < 0) {
@@ -65,38 +73,3 @@ int index_pack(git_repository *repo, int argc, char **argv)
git_indexer_stream_free(idx);
return error;
}
-
-int index_pack_old(git_repository *repo, int argc, char **argv)
-{
- git_indexer *indexer;
- git_indexer_stats stats;
- int error;
- char hash[GIT_OID_HEXSZ + 1] = {0};
-
- if (argc < 2) {
- fprintf(stderr, "I need a packfile\n");
- return EXIT_FAILURE;
- }
-
- // Create a new indexer
- error = git_indexer_new(&indexer, argv[1]);
- if (error < 0)
- return error;
-
- // Index the packfile. This function can take a very long time and
- // should be run in a worker thread.
- error = git_indexer_run(indexer, &stats);
- if (error < 0)
- return error;
-
- // Write the information out to an index file
- error = git_indexer_write(indexer);
-
- // Get the packfile's hash (which should become it's filename)
- git_oid_fmt(hash, git_indexer_hash(indexer));
- puts(hash);
-
- git_indexer_free(indexer);
-
- return 0;
-}
diff --git a/examples/network/ls-remote.c b/examples/network/ls-remote.c
index 39cc6472..822d6f66 100644
--- a/examples/network/ls-remote.c
+++ b/examples/network/ls-remote.c
@@ -7,12 +7,14 @@
static int show_ref__cb(git_remote_head *head, void *payload)
{
char oid[GIT_OID_HEXSZ + 1] = {0};
+
+ payload = 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;
@@ -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;
@@ -63,8 +65,9 @@ cleanup:
int ls_remote(git_repository *repo, int argc, char **argv)
{
- int error, i;
+ int error;
+ argc = argc;
/* If there's a ':' in the name, assume it's an URL */
if (strchr(argv[1], ':') != NULL) {
error = use_unnamed(repo, argv[1]);