Commit 388f37b3 by Scott Chacon

add examples for docs

parent 742e3fc9
......@@ -4,6 +4,8 @@
"input": "include/git2",
"prefix": "git_",
"output": "docs",
"branch": "gh-pages",
"examples": "examples",
"legacy": {
"input": {"src/git": ["v0.1.0"],
"src/git2": ["v0.2.0", "v0.3.0"]}
......
#include <git2.h>
#include <stdio.h>
int main (int argc, char** argv)
{
git_repository *repo;
git_index *index;
unsigned int i, e, ecount;
git_index_entry **entries;
git_oid oid;
char out[41];
out[40] = '\0';
git_repository_open(&repo, "/tmp/gittalk/.git");
git_index_open_inrepo(&index, repo);
git_index_read(index);
ecount = git_index_entrycount(index);
for (i = 0; i < ecount; ++i) {
git_index_entry *e = git_index_get(index, i);
oid = e->oid;
git_oid_fmt(out, &oid);
printf("File Path: %s\n", e->path);
printf(" Blob SHA: %s\n", out);
printf("File Size: %d\n", (int)e->file_size);
printf(" Device: %d\n", (int)e->dev);
printf(" Inode: %d\n", (int)e->ino);
printf(" UID: %d\n", (int)e->uid);
printf(" GID: %d\n", (int)e->gid);
printf(" ctime: %d\n", (int)e->ctime.seconds);
printf(" mtime: %d\n", (int)e->mtime.seconds);
printf("\n");
}
git_index_free(index);
git_repository_free(repo);
}
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