1 // gitdlltest.cpp : Defines the entry point for the console application.
\r
7 int output(int ret, char * name)
\r
10 printf("Fail \t%s\r\n",name);
\r
12 printf("Success\t%s\r\n",name);
\r
15 int _tmain(int argc, _TCHAR* argv[])
\r
22 memset(&hash,0,sizeof(GIT_HASH));
\r
25 output(ret,"git_init");
\r
26 ret=git_get_sha1("master",hash);
\r
27 output(ret,"git_get_sha1");
\r
28 ret=git_get_sha1("head",hash);
\r
29 output(ret,"git_get_sha1");
\r
30 ret=git_get_commit_from_hash(&commit, hash);
\r
31 output(ret,"git_get_commit_from_hash");
\r
33 GIT_COMMIT_LIST list;
\r
36 ret = git_get_commit_first_parent(&commit,&list);
\r
37 output(ret, "git_get_commit_first_parent");
\r
41 ret = git_get_commit_next_parent(&list, outhash);
\r
43 printf("parent count %d\r\n",i);
\r
46 ret = git_open_diff(&diff, "-M -C --stat");
\r
47 output(ret, "git_open_diff");
\r
51 ret = git_diff(diff, outhash, commit.m_hash,&file, &count);
\r
52 output(ret, "git_diff");
\r
54 for(i =0;i<count;i++)
\r
61 ret = git_get_diff_file(diff,file,i,&newname, &oldname, &status,
\r
62 &IsBin, &inc, &dec);
\r
64 ret = git_diff_flush(diff);
\r
65 output(ret, "git_diff_flush");
\r
66 // ret = git_close_diff(diff);
\r
67 // output(ret, "git_close_diff");
\r
70 git_free_commit(&commit);
\r
74 ret=git_open_log(&handle,"--stat -c -- \"build.txt\"");
\r
75 output(ret,"git_open_log");
\r
76 ret=git_get_log_firstcommit(handle);
\r
77 output(ret,"git_get_log_firstcommit");
\r
79 while( git_get_log_nextcommit(handle,&commit) == 0)
\r
81 //printf("%s\r\n",commit.m_Subject);
\r
83 git_free_commit(&commit);
\r
85 printf("commit number %d\r\n",count);
\r
86 ret=git_close_log(handle);
\r
89 output(ret,"git_close_log");
\r