OSDN Git Service

Show add files at init version
authorFrank Li <lznuaa@gmail.com>
Mon, 11 Jan 2010 14:24:35 +0000 (22:24 +0800)
committerFrank Li <lznuaa@gmail.com>
Mon, 11 Jan 2010 14:24:35 +0000 (22:24 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
ext/gitdll/gitdll.c
ext/gitdll/gitdll.h
src/Git/GitRev.cpp

index d609b07..a9e9843 100644 (file)
@@ -423,6 +423,38 @@ int git_diff_flush(GIT_DIFF diff)
 \r
        free_diffstat_info(&p_Rev->diffstat);\r
 }\r
+\r
+int git_root_diff(GIT_DIFF diff, GIT_HASH hash,GIT_FILE *file, int *count)\r
+{\r
+       int ret;\r
+       struct rev_info *p_Rev;\r
+       int i;\r
+       struct diff_queue_struct *q = &diff_queued_diff;\r
+\r
+       p_Rev = (struct rev_info *)diff;\r
+\r
+       ret=diff_root_tree_sha1(hash, "", &p_Rev->diffopt);\r
+\r
+       if(ret)\r
+               return ret;\r
+\r
+       diffcore_std(&p_Rev->diffopt);\r
+\r
+       memset(&p_Rev->diffstat, 0, sizeof(struct diffstat_t));\r
+       for (i = 0; i < q->nr; i++) {\r
+               struct diff_filepair *p = q->queue[i];\r
+               //if (check_pair_status(p))\r
+               diff_flush_stat(p, &p_Rev->diffopt, &p_Rev->diffstat);\r
+       }\r
+\r
+       if(file)\r
+               *file = q;\r
+       if(count)\r
+               *count = q->nr;\r
+\r
+       return 0;\r
+}\r
+\r
 int git_diff(GIT_DIFF diff, GIT_HASH hash1, GIT_HASH hash2, GIT_FILE * file, int *count)\r
 {\r
        struct rev_info *p_Rev;\r
index ee00e91..fd5e634 100644 (file)
@@ -114,6 +114,7 @@ GITDLL_API int git_free_commit(GIT_COMMIT *commit);
 \r
 GITDLL_API int git_open_diff(GIT_DIFF *diff, char * arg);\r
 GITDLL_API int git_diff(GIT_DIFF diff, GIT_HASH hash1,GIT_HASH hash2, GIT_FILE * file, int *count);\r
+GITDLL_API int git_root_diff(GIT_DIFF diff, GIT_HASH hash,GIT_FILE *file, int *count);\r
 GITDLL_API int git_diff_flush(GIT_DIFF diff);\r
 GITDLL_API int git_close_diff(GIT_DIFF diff);\r
 \r
index e23067d..b3bc325 100644 (file)
@@ -281,12 +281,19 @@ int GitRev::SafeFetchFullInfo(CGit *git)
                        return -1;\r
 \r
                int i=0;\r
+               bool isRoot = this->m_ParentHash.size()==0;\r
                git_get_commit_first_parent(&commit,&list);\r
-               while(git_get_commit_next_parent(&list,parent) == 0)\r
+               while(git_get_commit_next_parent(&list,parent) == 0 || isRoot)\r
                {\r
                        GIT_FILE file;\r
                        int count;\r
-                       git_diff(git->GetGitDiff(),parent,commit.m_hash,&file,&count);\r
+                       if(isRoot)\r
+                               git_root_diff(git->GetGitDiff(), this->m_CommitHash.m_hash, &file, &count);\r
+                       else\r
+                               git_diff(git->GetGitDiff(),parent,commit.m_hash,&file,&count);\r
+                       \r
+                       isRoot = false;\r
+\r
                        CTGitPath path;\r
                        CString strnewname;\r
                        CString stroldname;\r