Commit ae789622 by Carlos Martín Nieto

examples: fix warnings in network/

parent ad4b5beb
......@@ -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);
......
#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]);
......
......@@ -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;
}
......@@ -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]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment