summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Chacon <schacon@gmail.com>2011-06-15 09:38:55 -0700
committerScott Chacon <schacon@gmail.com>2011-06-15 09:40:06 -0700
commit96da90ae1f5b1a90b387832d3b970bd6ef1cefbd (patch)
tree4f901d4501d8d434cf87a04420ed7100f72ab54a
parent2e6d8ec4369abbc360f7a5ce3ccd62295ac93f19 (diff)
downloadlibgit2-96da90ae1f5b1a90b387832d3b970bd6ef1cefbd.tar.gz
update examples content to be compilable and up to date
-rw-r--r--api.docurium2
-rw-r--r--examples/.gitignore2
-rw-r--r--examples/Makefile10
-rw-r--r--examples/general.c (renamed from examples/libgit.c)27
-rw-r--r--examples/showindex.c4
5 files changed, 40 insertions, 5 deletions
diff --git a/api.docurium b/api.docurium
index 217c08587..9e17817db 100644
--- a/api.docurium
+++ b/api.docurium
@@ -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"],
diff --git a/examples/.gitignore b/examples/.gitignore
new file mode 100644
index 000000000..4c34e4ab5
--- /dev/null
+++ b/examples/.gitignore
@@ -0,0 +1,2 @@
+general
+showindex
diff --git a/examples/Makefile b/examples/Makefile
new file mode 100644
index 000000000..f7bf469a5
--- /dev/null
+++ b/examples/Makefile
@@ -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
diff --git a/examples/libgit.c b/examples/general.c
index 9843d05d1..6362e9650 100644
--- a/examples/libgit.c
+++ b/examples/general.c
@@ -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);
}
diff --git a/examples/showindex.c b/examples/showindex.c
index 908a114f4..7f2130b90 100644
--- a/examples/showindex.c
+++ b/examples/showindex.c
@@ -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);