diff options
author | Russell Belfer <rb@github.com> | 2012-11-09 11:19:46 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-11-09 13:52:07 -0800 |
commit | 0f3def715dc9af442f5f025c50a041c6319df1e8 (patch) | |
tree | e5a327bab384ab865471d019c83637b6ed167e3c /examples/network/clone.c | |
parent | 8064ecba2384df32d5b821398a346f0c96cf74d1 (diff) | |
download | libgit2-0f3def715dc9af442f5f025c50a041c6319df1e8.tar.gz |
Fix various cross-platform build issues
This fixes a number of warnings and problems with cross-platform
builds. Among other things, it's not safe to name a member of a
structure "strcmp" because that may be #defined.
Diffstat (limited to 'examples/network/clone.c')
-rw-r--r-- | examples/network/clone.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/examples/network/clone.c b/examples/network/clone.c index 791600171..30a4944c2 100644 --- a/examples/network/clone.c +++ b/examples/network/clone.c @@ -22,12 +22,14 @@ static void print_progress(const progress_data *pd) ? (100 * pd->completed_steps) / pd->total_steps : 0.f; int kbytes = pd->fetch_progress.received_bytes / 1024; - printf("net %3d%% (%4d kb, %5d/%5d) / idx %3d%% (%5d/%5d) / chk %3d%% (%4lu/%4lu) %s\n", - network_percent, kbytes, - pd->fetch_progress.received_objects, pd->fetch_progress.total_objects, - index_percent, pd->fetch_progress.indexed_objects, pd->fetch_progress.total_objects, - checkout_percent, pd->completed_steps, pd->total_steps, - pd->path); + + printf("net %3d%% (%4d kb, %5d/%5d) / idx %3d%% (%5d/%5d) / chk %3d%% (%4" PRIuZ "/%4" PRIuZ ") %s\n", + network_percent, kbytes, + pd->fetch_progress.received_objects, pd->fetch_progress.total_objects, + index_percent, pd->fetch_progress.indexed_objects, pd->fetch_progress.total_objects, + checkout_percent, + pd->completed_steps, pd->total_steps, + pd->path); } static void fetch_progress(const git_transfer_progress *stats, void *payload) @@ -47,13 +49,15 @@ static void checkout_progress(const char *path, size_t cur, size_t tot, void *pa int do_clone(git_repository *repo, int argc, char **argv) { - progress_data pd = {0}; + progress_data pd; git_repository *cloned_repo = NULL; - git_checkout_opts checkout_opts = {0}; + git_checkout_opts checkout_opts; const char *url = argv[1]; const char *path = argv[2]; int error; + (void)repo; // unused + // Validate args if (argc < 3) { printf ("USAGE: %s <url> <path>\n", argv[0]); @@ -61,8 +65,10 @@ int do_clone(git_repository *repo, int argc, char **argv) } // Set up options - checkout_opts.checkout_strategy = GIT_CHECKOUT_CREATE_MISSING; + memset(&checkout_opts, 0, sizeof(checkout_opts)); + checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE; checkout_opts.progress_cb = checkout_progress; + memset(&pd, 0, sizeof(pd)); checkout_opts.progress_payload = &pd; // Do the clone |