OSDN Git Service

Fix free commit list problem.
[tortoisegit/TortoiseGitJp.git] / ext / gitdlltest / gitdlltest.cpp
index 39aaeb7..2b1b17a 100644 (file)
@@ -14,6 +14,7 @@ int output(int ret, char * name)
 }\r
 int _tmain(int argc, _TCHAR* argv[])\r
 {\r
+       int count;\r
        GIT_HASH hash;\r
        GIT_COMMIT commit;\r
        char *buf;\r
@@ -28,13 +29,53 @@ int _tmain(int argc, _TCHAR* argv[])
        output(ret,"git_get_sha1");\r
        ret=git_get_commit_from_hash(&commit, hash);\r
        output(ret,"git_get_commit_from_hash");\r
+\r
+       GIT_COMMIT_LIST list;\r
+       GIT_HASH outhash;\r
+       int i=0;\r
+       ret = git_get_commit_first_parent(&commit,&list);\r
+       output(ret, "git_get_commit_first_parent");\r
+       while(list)\r
+       {\r
+               i++;\r
+               ret = git_get_commit_next_parent(&list, outhash);\r
+       }\r
+       printf("parent count %d\r\n",i);\r
+\r
+       GIT_DIFF diff;\r
+       ret = git_open_diff(&diff, "-M -C --stat");\r
+       output(ret, "git_open_diff");\r
        \r
+       GIT_FILE file;\r
+\r
+       ret = git_diff(diff, outhash, commit.m_hash,&file, &count);\r
+       output(ret, "git_diff");\r
+\r
+       for(i =0;i<count;i++)\r
+       {       \r
+               char * newname;\r
+               char * oldname;\r
+               int status;\r
+               int IsBin;\r
+               int inc, dec;\r
+               ret = git_get_diff_file(diff,file,i,&newname, &oldname, &status,\r
+                       &IsBin, &inc, &dec);\r
+       }\r
+       ret = git_diff_flush(diff);\r
+       output(ret, "git_diff_flush");\r
+//     ret = git_close_diff(diff);\r
+//     output(ret, "git_close_diff");\r
+\r
+\r
+       git_free_commit(&commit);\r
+\r
+\r
        GIT_HANDLE handle;\r
        ret=git_open_log(&handle,"--stat -c -- \"build.txt\"");\r
        output(ret,"git_open_log");\r
        ret=git_get_log_firstcommit(handle);\r
        output(ret,"git_get_log_firstcommit");\r
-       int count = 0;\r
+       count = 0;\r
        while( git_get_log_nextcommit(handle,&commit) == 0)\r
        {\r
                //printf("%s\r\n",commit.m_Subject);\r
@@ -43,6 +84,8 @@ int _tmain(int argc, _TCHAR* argv[])
        }\r
        printf("commit number %d\r\n",count);\r
        ret=git_close_log(handle);\r
+\r
+\r
        output(ret,"git_close_log");\r
        return ret;\r
 }\r