Permalink
Browse files

update examples content to be compilable and up to date

  • Loading branch information...
1 parent 2e6d8ec commit 96da90ae1f5b1a90b387832d3b970bd6ef1cefbd @schacon schacon committed Jun 15, 2011
Showing with 40 additions and 5 deletions.
  1. +1 −1 api.docurium
  2. +2 −0 examples/.gitignore
  3. +10 −0 examples/Makefile
  4. +25 −2 examples/{libgit.c → general.c}
  5. +2 −2 examples/showindex.c
View
@@ -4,7 +4,7 @@
"input": "include/git2",
"prefix": "git_",
"output": "docs",
- "xbranch": "gh-pages",
+ "branch": "gh-pages",
"examples": "examples",
"legacy": {
"input": {"src/git": ["v0.1.0"],
View
@@ -0,0 +1,2 @@
+general
+showindex
View
@@ -0,0 +1,10 @@
+all: general showindex
+
+general : general.c
+ gcc -lgit2 -o general general.c
+
+showindex : showindex.c
+ gcc -lgit2 -o showindex showindex.c
+
+clean:
+ rm general showindex
@@ -246,7 +246,7 @@ int main (int argc, char** argv)
printf("\n*Tree Parsing*\n");
git_tree *tree;
- git_tree_entry *entry;
+ const git_tree_entry *entry;
git_object *objt;
// Create the oid and lookup the tree object just like the other objects.
@@ -356,7 +356,7 @@ int main (int argc, char** argv)
// You can either open the index from the standard location in an open repository, as we're doing
// here, or you can open and manipulate any index file with `git_index_open_bare()`. The index
// for the repository will be located and loaded from disk.
- git_index_open_inrepo(&index, repo);
+ git_repository_index(&index, repo);
// For each entry in the index, you can get a bunch of information including the SHA (oid), path
// and mode which map to the tree objects that are written out. It also has filesystem properties
@@ -410,6 +410,29 @@ int main (int argc, char** argv)
git_strarray_free(&ref_list);
+ // ### Config Files
+ //
+ // The [config API][config] allows you to list and updatee config values in
+ // any of the accessible config file locations (system, global, local).
+ //
+ // [config]: http://libgit2.github.com/libgit2/#HEAD/group/config
+
+ printf("\n*Config Listing*\n");
+
+ const char *email;
+ int j;
+
+ git_config *cfg;
+
+ // Open a config object so we can read global values from it.
+ git_config_open_global(&cfg);
+
+ git_config_get_int(cfg, "help.autocorrect", &j);
+ printf("Autocorrect: %d\n", j);
+
+ git_config_get_string(cfg, "user.email", &email);
+ printf("Email: %s\n", email);
+
// Finally, when you're done with the repository, you can free it as well.
git_repository_free(repo);
}
View
@@ -12,9 +12,9 @@ int main (int argc, char** argv)
char out[41];
out[40] = '\0';
- git_repository_open(&repo, "/tmp/gittalk/.git");
+ git_repository_open(&repo, "/opt/libgit2-test/.git");
- git_index_open_inrepo(&index, repo);
+ git_repository_index(&index, repo);
git_index_read(index);
ecount = git_index_entrycount(index);

0 comments on commit 96da90a

Please sign in to comment.