summaryrefslogtreecommitdiff
path: root/examples/network/index-pack.c
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/network/index-pack.c
parentad4b5beb50dc484f86534dc127646eafb39d96fe (diff)
downloadlibgit2-ae789622e438e213d8a2059f7aeeeae931442c18.tar.gz
examples: fix warnings in network/
Diffstat (limited to 'examples/network/index-pack.c')
-rw-r--r--examples/network/index-pack.c47
1 files changed, 10 insertions, 37 deletions
diff --git a/examples/network/index-pack.c b/examples/network/index-pack.c
index ef5a35957..85aac4aff 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;
-}