From 51cc50a37d1dbff2f877012073c13f6d24308bfe Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Tue, 5 Jul 2011 11:43:21 +0300 Subject: [PATCH 1/3] examples/general: fix git_commit_create_v() arguments type general.c:208: warning: passing argument 7 of 'git_commit_create_v' from incompatible pointer type Signed-off-by: Kirill A. Shutemov --- examples/general.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/general.c b/examples/general.c index f02c40977..db0b2db48 100644 --- a/examples/general.c +++ b/examples/general.c @@ -180,6 +180,8 @@ int main (int argc, char** argv) printf("\n*Commit Writing*\n"); git_oid tree_id, parent_id, commit_id; + git_tree *tree; + git_commit *parent; // Creating signatures for an authoring identity and time is pretty simple - you will need to have // this to create a commit in order to specify who created it and when. Default values for the name @@ -193,7 +195,9 @@ int main (int argc, char** argv) // Commit objects need a tree to point to and optionally one or more parents. Here we're creating oid // objects to create the commit with, but you can also use git_oid_fromstr(&tree_id, "28873d96b4e8f4e33ea30f4c682fd325f7ba56ac"); + git_tree_lookup(&tree, repo, &tree_id); git_oid_fromstr(&parent_id, "f0877d0b841d75172ec404fc9370173dfffc20d1"); + git_commit_lookup(&parent, repo, &parent_id); // Here we actually create the commit object with a single call with all the values we need to create // the commit. The SHA key is written to the `commit_id` variable here. @@ -204,8 +208,8 @@ int main (int argc, char** argv) author, cmtter, "example commit", - &tree_id, - 1, &parent_id); + tree, + 1, parent); // Now we can take a look at the commit SHA we've generated. git_oid_fmt(out, &commit_id); @@ -245,7 +249,6 @@ int main (int argc, char** argv) // [tp]: http://libgit2.github.com/libgit2/#HEAD/group/tree printf("\n*Tree Parsing*\n"); - git_tree *tree; const git_tree_entry *entry; git_object *objt; From d6d877d20f76b3b6bf0e370cadd24e3321ce5371 Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Tue, 5 Jul 2011 11:54:16 +0300 Subject: [PATCH 2/3] examples/general: fix warnings on not handled reference type in switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit examples/general.c:402:5: warning: enumeration value ‘GIT_REF_INVALID’ not handled in switch [-Wswitch] examples/general.c:402:5: warning: enumeration value ‘GIT_REF_PACKED’ not handled in switch [-Wswitch] examples/general.c:402:5: warning: enumeration value ‘GIT_REF_HAS_PEEL’ not handled in switch [-Wswitch] examples/general.c:402:5: warning: enumeration value ‘GIT_REF_LISTALL’ not handled in switch [-Wswitch] Signe-off-by: Kirill A. Shutemov --- examples/general.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/general.c b/examples/general.c index db0b2db48..176f49feb 100644 --- a/examples/general.c +++ b/examples/general.c @@ -408,6 +408,9 @@ int main (int argc, char** argv) case GIT_REF_SYMBOLIC: printf("%s => %s\n", refname, git_reference_target(ref)); break; + default: + fprintf(stderr, "Unexpected reference type\n"); + exit(1); } } From 6f2b0a3ae2fd57dc52d2e84367b51cd06ba9a11c Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Tue, 5 Jul 2011 12:00:18 +0300 Subject: [PATCH 3/3] examples/general: fix misc warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit examples/general.c:393:25: warning: unused variable ‘reftarget’ [-Wunused-variable] examples/general.c:357:19: warning: unused variable ‘e’ [-Wunused-variable] examples/general.c:444:1: warning: control reaches end of non-void function [-Wreturn-type] Signed-off-by: Kirill A. Shutemov --- examples/general.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/general.c b/examples/general.c index 176f49feb..91b6ee859 100644 --- a/examples/general.c +++ b/examples/general.c @@ -354,7 +354,7 @@ int main (int argc, char** argv) printf("\n*Index Walking*\n"); git_index *index; - unsigned int i, e, ecount; + unsigned int i, ecount; // 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 @@ -390,7 +390,7 @@ int main (int argc, char** argv) git_strarray ref_list; git_reference_listall(&ref_list, repo, GIT_REF_LISTALL); - const char *refname, *reftarget; + const char *refname; git_reference *ref; // Now that we have the list of reference names, we can lookup each ref one at a time and @@ -441,5 +441,7 @@ int main (int argc, char** argv) // Finally, when you're done with the repository, you can free it as well. git_repository_free(repo); + + return 0; }