GitTest: Try running 'git add' without android

It seems to work
This commit is contained in:
Vishesh Handa
2019-05-14 16:47:49 +02:00
parent 1dbe829372
commit 00b66149a1
2 changed files with 56 additions and 0 deletions

51
git_test/git.c Normal file
View File

@ -0,0 +1,51 @@
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <git2.h>
void handle_error(int err)
{
if (err < 0)
{
const git_error *e = giterr_last();
printf("Error %d/%d: %s\n", err, e->klass, e->message);
}
}
int match_cb(const char *path, const char *spec, void *payload)
{
printf("Match: %s\n", path);
return 0;
}
int main(int argc, char *argv[])
{
int err;
char *git_base_path = "/tmp/journal_test";
char *clone_url = "git@github.com:GitJournal/journal_test.git";
char *add_pattern = ".";
git_libgit2_init();
git_repository *repo = NULL;
err = git_repository_open(&repo, git_base_path);
handle_error(err);
git_index *idx = NULL;
err = git_repository_index(&idx, repo);
handle_error(err);
char *paths[] = {add_pattern};
git_strarray pathspec = {paths, 1};
err = git_index_add_all(idx, &pathspec, GIT_INDEX_ADD_DEFAULT, match_cb, NULL);
handle_error(err);
err = git_index_write(idx);
handle_error(err);
git_index_free(idx);
return 0;
}

5
git_test/make.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euv
clang git.c -lgit2 -lssh2