From 06f794c7f5cef8b19bf3edcb934de0317cffd600 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Mon, 11 Jan 2010 22:24:35 +0800 Subject: [PATCH] Show add files at init version Signed-off-by: Frank Li --- ext/gitdll/gitdll.c | 32 ++++++++++++++++++++++++++++++++ ext/gitdll/gitdll.h | 1 + src/Git/GitRev.cpp | 11 +++++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ext/gitdll/gitdll.c b/ext/gitdll/gitdll.c index d609b07b1..a9e98439b 100644 --- a/ext/gitdll/gitdll.c +++ b/ext/gitdll/gitdll.c @@ -423,6 +423,38 @@ int git_diff_flush(GIT_DIFF diff) free_diffstat_info(&p_Rev->diffstat); } + +int git_root_diff(GIT_DIFF diff, GIT_HASH hash,GIT_FILE *file, int *count) +{ + int ret; + struct rev_info *p_Rev; + int i; + struct diff_queue_struct *q = &diff_queued_diff; + + p_Rev = (struct rev_info *)diff; + + ret=diff_root_tree_sha1(hash, "", &p_Rev->diffopt); + + if(ret) + return ret; + + diffcore_std(&p_Rev->diffopt); + + memset(&p_Rev->diffstat, 0, sizeof(struct diffstat_t)); + for (i = 0; i < q->nr; i++) { + struct diff_filepair *p = q->queue[i]; + //if (check_pair_status(p)) + diff_flush_stat(p, &p_Rev->diffopt, &p_Rev->diffstat); + } + + if(file) + *file = q; + if(count) + *count = q->nr; + + return 0; +} + int git_diff(GIT_DIFF diff, GIT_HASH hash1, GIT_HASH hash2, GIT_FILE * file, int *count) { struct rev_info *p_Rev; diff --git a/ext/gitdll/gitdll.h b/ext/gitdll/gitdll.h index ee00e9130..fd5e6340f 100644 --- a/ext/gitdll/gitdll.h +++ b/ext/gitdll/gitdll.h @@ -114,6 +114,7 @@ GITDLL_API int git_free_commit(GIT_COMMIT *commit); GITDLL_API int git_open_diff(GIT_DIFF *diff, char * arg); GITDLL_API int git_diff(GIT_DIFF diff, GIT_HASH hash1,GIT_HASH hash2, GIT_FILE * file, int *count); +GITDLL_API int git_root_diff(GIT_DIFF diff, GIT_HASH hash,GIT_FILE *file, int *count); GITDLL_API int git_diff_flush(GIT_DIFF diff); GITDLL_API int git_close_diff(GIT_DIFF diff); diff --git a/src/Git/GitRev.cpp b/src/Git/GitRev.cpp index e23067d78..b3bc325ed 100644 --- a/src/Git/GitRev.cpp +++ b/src/Git/GitRev.cpp @@ -281,12 +281,19 @@ int GitRev::SafeFetchFullInfo(CGit *git) return -1; int i=0; + bool isRoot = this->m_ParentHash.size()==0; git_get_commit_first_parent(&commit,&list); - while(git_get_commit_next_parent(&list,parent) == 0) + while(git_get_commit_next_parent(&list,parent) == 0 || isRoot) { GIT_FILE file; int count; - git_diff(git->GetGitDiff(),parent,commit.m_hash,&file,&count); + if(isRoot) + git_root_diff(git->GetGitDiff(), this->m_CommitHash.m_hash, &file, &count); + else + git_diff(git->GetGitDiff(),parent,commit.m_hash,&file,&count); + + isRoot = false; + CTGitPath path; CString strnewname; CString stroldname; -- 2.11.4.GIT