#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <pthread.h>
-#include <unistd.h>
+#ifndef _WIN32
+# include <pthread.h>
+# include <unistd.h>
+#endif
typedef struct progress_data {
git_transfer_progress fetch_progress;
pd->path);
}
-static void fetch_progress(const git_transfer_progress *stats, void *payload)
+static int fetch_progress(const git_transfer_progress *stats, void *payload)
{
progress_data *pd = (progress_data*)payload;
pd->fetch_progress = *stats;
print_progress(pd);
+ return 0;
}
static void checkout_progress(const char *path, size_t cur, size_t tot, void *payload)
{
print_progress(pd);
}
+
int do_clone(git_repository *repo, int argc, char **argv)
{
- progress_data pd;
+ progress_data pd = {{0}};
git_repository *cloned_repo = NULL;
- git_checkout_opts checkout_opts;
+ git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT;
+ git_checkout_opts checkout_opts = GIT_CHECKOUT_OPTS_INIT;
const char *url = argv[1];
const char *path = argv[2];
int error;
}
// Set up options
- memset(&checkout_opts, 0, sizeof(checkout_opts));
- checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE;
checkout_opts.progress_cb = checkout_progress;
- memset(&pd, 0, sizeof(pd));
checkout_opts.progress_payload = &pd;
+ clone_opts.checkout_opts = checkout_opts;
+ clone_opts.fetch_progress_cb = &fetch_progress;
+ clone_opts.fetch_progress_payload = &pd;
+ clone_opts.cred_acquire_cb = cred_acquire_cb;
// Do the clone
- error = git_clone(&cloned_repo, url, path, &checkout_opts, &fetch_progress, &pd);
+ error = git_clone(&cloned_repo, url, path, &clone_opts);
printf("\n");
if (error != 0) {
const git_error *err = giterr_last();