Created
July 31, 2020 15:05
-
-
Save alexcrichton/63eb27cd2428e0edf3fce8997bdf08ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <git2/remote.h> | |
#include <git2/repository.h> | |
#include <git2/errors.h> | |
#include <git2/global.h> | |
#include <stdio.h> | |
int main() { | |
assert(git_libgit2_init() == 1); | |
git_repository *repo; | |
assert(git_repository_init(&repo, "index-clone", 0) == 0); | |
git_remote *remote; | |
assert(git_remote_create_anonymous(&remote, repo, "index/.git") == 0); | |
git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT; | |
char *strings[] = {"HEAD:refs/remotes/origin/head"}; | |
git_strarray refspecs; | |
refspecs.strings = strings; | |
refspecs.count = 1; | |
int err = git_remote_fetch(remote, &refspecs, &fetch_opts, NULL); | |
printf("err = %d\n", err); | |
if (err == 0) | |
return 0; | |
const git_error *last = git_error_last(); | |
if (last != NULL) { | |
printf("message: %s\n", last->message); | |
printf("klass: %d\n", last->klass); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment