]> git.proxmox.com Git - libgit2.git/blame - examples/showindex.c
add examples for docs
[libgit2.git] / examples / showindex.c
CommitLineData
388f37b3
SC
1#include <git2.h>
2#include <stdio.h>
3
4int main (int argc, char** argv)
5{
6 git_repository *repo;
7 git_index *index;
8 unsigned int i, e, ecount;
9 git_index_entry **entries;
10 git_oid oid;
11
12 char out[41];
13 out[40] = '\0';
14
15 git_repository_open(&repo, "/tmp/gittalk/.git");
16
17 git_index_open_inrepo(&index, repo);
18 git_index_read(index);
19
20 ecount = git_index_entrycount(index);
21 for (i = 0; i < ecount; ++i) {
22 git_index_entry *e = git_index_get(index, i);
23
24 oid = e->oid;
25 git_oid_fmt(out, &oid);
26
27 printf("File Path: %s\n", e->path);
28 printf(" Blob SHA: %s\n", out);
29 printf("File Size: %d\n", (int)e->file_size);
30 printf(" Device: %d\n", (int)e->dev);
31 printf(" Inode: %d\n", (int)e->ino);
32 printf(" UID: %d\n", (int)e->uid);
33 printf(" GID: %d\n", (int)e->gid);
34 printf(" ctime: %d\n", (int)e->ctime.seconds);
35 printf(" mtime: %d\n", (int)e->mtime.seconds);
36 printf("\n");
37 }
38
39 git_index_free(index);
40
41 git_repository_free(repo);
42}
43