@@ -78,7 +78,10 @@ static void check_error(int error_code, const char *action)
7878
7979int main (int argc , char * * argv )
8080{
81+ int error ;
8182 git_oid oid ;
83+ char * repo_path ;
84+ git_repository * repo ;
8285
8386 /**
8487 * Initialize the library, this will set up any global state which libgit2 needs
@@ -97,9 +100,7 @@ int main (int argc, char** argv)
97100 *
98101 * [me]: http://libgit2.github.com/libgit2/#HEAD/group/repository
99102 */
100- int error ;
101- const char * repo_path = (argc > 1 ) ? argv [1 ] : "/opt/libgit2-test/.git" ;
102- git_repository * repo ;
103+ repo_path = (argc > 1 ) ? argv [1 ] : "/opt/libgit2-test/.git" ;
103104
104105 error = git_repository_open (& repo , repo_path );
105106 check_error (error , "opening repository" );
@@ -216,9 +217,9 @@ static void object_database(git_repository *repo, git_oid *oid)
216217 * a string representation of that value (and vice-versa).
217218 */
218219 str_type = git_object_type2string (otype );
219- printf ("object length and type: %d, %s\n" ,
220+ printf ("object length and type: %d, %s\nobject data: %s\ n" ,
220221 (int )git_odb_object_size (obj ),
221- str_type );
222+ str_type , data );
222223
223224 /**
224225 * For proper memory management, close the object when you are done with
@@ -339,7 +340,7 @@ static void commit_parsing(git_repository *repo)
339340 const char * message ;
340341 unsigned int parents , p ;
341342 int error ;
342- time_t ctime ;
343+ time_t time ;
343344
344345 printf ("\n*Commit Parsing*\n" );
345346
@@ -357,14 +358,17 @@ static void commit_parsing(git_repository *repo)
357358 message = git_commit_message (commit );
358359 author = git_commit_author (commit );
359360 cmtter = git_commit_committer (commit );
360- ctime = git_commit_time (commit );
361+ time = git_commit_time (commit );
361362
362363 /**
363364 * The author and committer methods return [git_signature] structures,
364365 * which give you name, email and `when`, which is a `git_time` structure,
365366 * giving you a timestamp and timezone offset.
366367 */
367- printf ("Author: %s (%s)\n" , author -> name , author -> email );
368+ printf ("Author: %s (%s)\nCommitter: %s (%s)\nDate: %s\nMessage: %s\n" ,
369+ author -> name , author -> email ,
370+ cmtter -> name , cmtter -> email ,
371+ ctime (& time ), message );
368372
369373 /**
370374 * Commits can have zero or more parents. The first (root) commit will
@@ -424,7 +428,8 @@ static void tag_parsing(git_repository *repo)
424428 name = git_tag_name (tag ); /* "test" */
425429 type = git_tag_target_type (tag ); /* GIT_OBJ_COMMIT (otype enum) */
426430 message = git_tag_message (tag ); /* "tag message\n" */
427- printf ("Tag Message: %s\n" , message );
431+ printf ("Tag Name: %s\nTag Type: %s\nTag Message: %s\n" ,
432+ name , git_object_type2string (type ), message );
428433
429434 git_commit_free (commit );
430435}
0 commit comments