From d0efb00a7edf76cb52dda72e05222386df44a5da Mon Sep 17 00:00:00 2001 From: Frank Li Date: Mon, 4 Jan 2010 16:49:55 +0800 Subject: [PATCH] Build is okay Signed-off-by: Frank Li --- ext/gitdll/gitdll.c | 4 +- ext/gitdll/gitdll.h | 9 ++- src/Git/Git.cpp | 3 +- src/Git/Git.h | 22 ++++++ src/Git/GitHash.h | 3 +- src/Git/GitRev.cpp | 100 ++++++++++++++++++++++++++ src/Git/GitRev.h | 3 + src/Git/TGitPath.h | 1 + src/TGitCache/TSVNCache.vcproj | 8 +-- src/TortoiseGit.sln | 4 ++ src/TortoiseGitBlame/LogListBlameAction.cpp | 4 +- src/TortoiseGitBlame/OutputWnd.cpp | 2 +- src/TortoiseGitBlame/PropertiesWnd.cpp | 6 +- src/TortoiseGitBlame/TortoiseGitBlame.vcproj | 36 +++++----- src/TortoiseGitBlame/TortoiseGitBlameView.cpp | 8 +-- src/TortoiseMerge/TortoiseMerge.vcproj | 12 ++-- src/TortoiseMerge/libsvn_diff/SVNLineDiff.cpp | 2 + src/TortoiseProc/TortoiseProc.vcproj | 32 ++++----- src/TortoiseShell/TortoiseShell.vcproj | 8 +-- src/Utils/Utils.vcproj | 8 +-- 20 files changed, 208 insertions(+), 67 deletions(-) diff --git a/ext/gitdll/gitdll.c b/ext/gitdll/gitdll.c index 3ffee6953..3d60256a8 100644 --- a/ext/gitdll/gitdll.c +++ b/ext/gitdll/gitdll.c @@ -382,7 +382,9 @@ int git_diff_flush(GIT_DIFF diff) int i; p_Rev = (struct rev_info *)diff; - + if(q->nr == 0) + return 0; + for (i = 0; i < q->nr; i++) diff_free_filepair(q->queue[i]); diff --git a/ext/gitdll/gitdll.h b/ext/gitdll/gitdll.h index b771e407d..ee00e9130 100644 --- a/ext/gitdll/gitdll.h +++ b/ext/gitdll/gitdll.h @@ -4,6 +4,9 @@ // that uses this DLL. This way any other project whose source files include this file see // GITDLL_API functions as being imported from a DLL, whereas this DLL sees symbols // defined with this macro as being exported. +#ifndef __GITDLL__ +#define __GITDLL__ + #ifdef __cplusplus #define EXTERN extern "C" #else @@ -11,9 +14,9 @@ #endif #ifdef GITDLL_EXPORTS -#define GITDLL_API __declspec(dllexport) EXTERN +#define GITDLL_API EXTERN __declspec(dllexport) #else -#define GITDLL_API __declspec(dllimport) EXTERN +#define GITDLL_API EXTERN __declspec(dllimport) #endif #if 0 @@ -116,3 +119,5 @@ GITDLL_API int git_close_diff(GIT_DIFF diff); GITDLL_API int git_get_diff_file(GIT_DIFF diff,GIT_FILE file, int i,char **newname, char **oldname, int *mode, int *IsBin, int *inc, int *dec); + +#endif \ No newline at end of file diff --git a/src/Git/Git.cpp b/src/Git/Git.cpp index 80f53b84e..baea8f97f 100644 --- a/src/Git/Git.cpp +++ b/src/Git/Git.cpp @@ -9,6 +9,7 @@ int CGit::m_LogEncode=CP_UTF8; + static LPTSTR nextpath(LPCTSTR src, LPTSTR dst, UINT maxlen) { LPCTSTR orgsrc; @@ -126,7 +127,7 @@ CGit::CGit(void) { GetCurrentDirectory(MAX_DIRBUFFER,m_CurrentDir.GetBuffer(MAX_DIRBUFFER)); m_CurrentDir.ReleaseBuffer(); - + m_IsGitDllInited = false; CheckMsysGitDir(); } diff --git a/src/Git/Git.h b/src/Git/Git.h index 8afb2fa13..425f5e49d 100644 --- a/src/Git/Git.h +++ b/src/Git/Git.h @@ -3,6 +3,7 @@ #include "GitRev.h" #include "GitStatus.h" #include "GitAdminDir.h" +#include "gitdll.h" class CGitCall { @@ -30,7 +31,27 @@ class CGit { private: GitAdminDir m_GitDir; +protected: + bool m_IsGitDllInited; + GIT_DIFF m_GitDiff; public: + void CheckAndInitDll() + { + if(!m_IsGitDllInited) + { + git_init(); + m_IsGitDllInited=true; + } + } + + GIT_DIFF GetGitDiff() + { + if(m_GitDiff) + return m_GitDiff; + else + git_open_diff(&m_GitDiff,"-C -M"); + } + static BOOL CheckMsysGitDir(); static CString ms_LastMsysGitDir; // the last msysgitdir added to the path, blank if none static int m_LogEncode; @@ -132,6 +153,7 @@ public: static CString StripRefName(CString refName); int GetCommitDiffList(CString &rev1,CString &rev2,CTGitPathList &outpathlist); + }; extern void GetTempPath(CString &path); diff --git a/src/Git/GitHash.h b/src/Git/GitHash.h index 900aa166b..65a407f1e 100644 --- a/src/Git/GitHash.h +++ b/src/Git/GitHash.h @@ -6,8 +6,9 @@ class CGitHash { - unsigned char m_hash[GIT_HASH_SIZE]; public: + unsigned char m_hash[GIT_HASH_SIZE]; + CGitHash() { memset(m_hash,0, GIT_HASH_SIZE); diff --git a/src/Git/GitRev.cpp b/src/Git/GitRev.cpp index 145dbe9bf..eca555b46 100644 --- a/src/Git/GitRev.cpp +++ b/src/Git/GitRev.cpp @@ -252,6 +252,7 @@ int GitRev::SafeFetchFullInfo(CGit *git) { if(InterlockedExchange(&m_IsUpdateing,TRUE) == FALSE) { +#if 0 //GitRev rev; BYTE_VECTOR onelog; TCHAR oldmark=this->m_Mark; @@ -269,6 +270,105 @@ int GitRev::SafeFetchFullInfo(CGit *git) InterlockedExchange(&m_IsUpdateing,FALSE); InterlockedExchange(&m_IsFull,TRUE); return 0; +#endif + git->CheckAndInitDll(); + GIT_COMMIT commit; + GIT_COMMIT_LIST list; + GIT_HASH parent; + if(git_get_commit_from_hash(&commit, this->m_CommitHash.m_hash)) + return -1; + + int i=0; + git_get_commit_first_parent(&commit,&list); + while(git_get_commit_next_parent(&list,parent)) + { + GIT_FILE file; + int count; + git_diff(git->GetGitDiff(),parent,commit.m_hash,&file,&count); + CTGitPath path; + CString strnewname; + CString stroldname; + + for(int j=0;jGetGitDiff(),file,j,&newname,&oldname, + &mode,&IsBin,&inc,&dec); + + git->StringAppend(&strnewname,(BYTE*)newname,CP_ACP); + git->StringAppend(&stroldname,(BYTE*)oldname,CP_ACP); + + path.m_ParentNo = i; + path.SetFromGit(strnewname,&stroldname); + path.ParserAction((BYTE)mode); + + this->m_Action|=path.m_Action; + + if(IsBin) + { + path.m_StatAdd=_T("-"); + path.m_StatDel=_T("-"); + }else + { + path.m_StatAdd.Format(_T("%d"),inc); + path.m_StatDel.Format(_T("%d"),dec); + } + } + git_diff_flush(git->GetGitDiff()); + i++; + } + + InterlockedExchange(&m_IsUpdateing,FALSE); + InterlockedExchange(&m_IsFull,TRUE); + } return -1; +} + +int GitRev::ParserParentFromCommit(GIT_COMMIT *commit) +{ + this->m_ParentHash.clear(); + GIT_COMMIT_LIST list; + GIT_HASH parent; + + git_get_commit_first_parent(commit,&list); + while(git_get_commit_next_parent(&list,parent)) + { + m_ParentHash.push_back(CGitHash((char *)parent)); + } + return 0; +} + +int GitRev::ParserFromCommit(GIT_COMMIT *commit) +{ + this->m_AuthorDate = commit->m_Author.Date; + + this->m_AuthorEmail.Empty(); + g_Git.StringAppend(&m_AuthorEmail,(BYTE*)commit->m_Author.Email,CP_ACP,commit->m_Author.EmailSize); + + this->m_AuthorName.Empty(); + g_Git.StringAppend(&m_AuthorName,(BYTE*)commit->m_Author.Name,CP_ACP,commit->m_Author.NameSize); + + this->m_Body.Empty(); + g_Git.StringAppend(&m_Body,(BYTE*)commit->m_Body,CP_ACP,commit->m_BodySize); + + this->m_CommitterDate = commit->m_Committer.Date; + + this->m_CommitterEmail.Empty(); + g_Git.StringAppend(&m_CommitterEmail, (BYTE*)commit->m_Committer.Email,CP_ACP, commit->m_Committer.EmailSize); + + this->m_CommitterName.Empty(); + g_Git.StringAppend(&m_CommitterName, (BYTE*)commit->m_Committer.Name,CP_ACP, commit->m_Committer.NameSize); + + this->m_Subject.Empty(); + g_Git.StringAppend(&m_Subject, (BYTE*)commit->m_Subject,CP_ACP,commit->m_SubjectSize); + + return 0; } \ No newline at end of file diff --git a/src/Git/GitRev.h b/src/Git/GitRev.h index 320a75b2b..eb4adf9f7 100644 --- a/src/Git/GitRev.h +++ b/src/Git/GitRev.h @@ -3,6 +3,7 @@ #include "GitStatus.h" #include "AtlTime.h" #include "GitHash.h" +#include "GitDll.h" typedef std::vector GIT_REV_LIST; @@ -74,6 +75,8 @@ public: int SafeFetchFullInfo(CGit *git); + int ParserFromCommit(GIT_COMMIT *commit); + int ParserParentFromCommit(GIT_COMMIT *commit); private: TIME_ZONE_INFORMATION m_TimeZone; }; diff --git a/src/Git/TGitPath.h b/src/Git/TGitPath.h index 07528fc20..8cbc7c8d3 100644 --- a/src/Git/TGitPath.h +++ b/src/Git/TGitPath.h @@ -8,6 +8,7 @@ public: ~CTGitPath(void); CTGitPath(const CString& sUnknownPath); int m_Stage; + int m_ParentNo; public: enum { diff --git a/src/TGitCache/TSVNCache.vcproj b/src/TGitCache/TSVNCache.vcproj index 2e5441bd8..0ee20e07f 100644 --- a/src/TGitCache/TSVNCache.vcproj +++ b/src/TGitCache/TSVNCache.vcproj @@ -46,7 +46,7 @@ GetMainWnd())->GetActiveView()->GetDocument()->GetPathName(); procCmd+=_T("\" "); - procCmd+=_T(" /rev:")+this->m_logEntries[indexNext].m_CommitHash; + procCmd+=_T(" /rev:")+this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString(); procCmd+=_T(" /command:"); @@ -83,7 +83,7 @@ void CGitBlameLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect break; #endif case ID_COMPARE: - procCmd+=CString(_T("diff \rev1:"))+CString(GIT_REV_ZERO)+CString(_T(" \rev2:"))+this->m_logEntries[indexNext].m_CommitHash; + procCmd+=CString(_T("diff \rev1:"))+CString(GIT_REV_ZERO)+CString(_T(" \rev2:"))+this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString(); break; case ID_COMPAREWITHPREVIOUS: procCmd+=_T("prevdiff"); diff --git a/src/TortoiseGitBlame/OutputWnd.cpp b/src/TortoiseGitBlame/OutputWnd.cpp index 2dcbf832b..1d2c0a95c 100644 --- a/src/TortoiseGitBlame/OutputWnd.cpp +++ b/src/TortoiseGitBlame/OutputWnd.cpp @@ -194,7 +194,7 @@ void COutputWnd::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult) CMainFrame *pMain=DYNAMIC_DOWNCAST(CMainFrame,AfxGetApp()->GetMainWnd()); POSITION pos=pMain->GetActiveDocument()->GetFirstViewPosition(); CTortoiseGitBlameView *pView=DYNAMIC_DOWNCAST(CTortoiseGitBlameView,pMain->GetActiveDocument()->GetNextView(pos)); - pView->FocusOn(&this->m_LogList.m_logEntries[pNMLV->iItem]); + pView->FocusOn(&this->m_LogList.m_logEntries.GetGitRevAt(pNMLV->iItem)); } } } diff --git a/src/TortoiseGitBlame/PropertiesWnd.cpp b/src/TortoiseGitBlame/PropertiesWnd.cpp index fd8ea3785..19e6d3fe4 100644 --- a/src/TortoiseGitBlame/PropertiesWnd.cpp +++ b/src/TortoiseGitBlame/PropertiesWnd.cpp @@ -350,7 +350,7 @@ void CPropertiesWnd::UpdateProperties(GitRev *rev) { if(rev) { - m_CommitHash->SetValue(rev->m_CommitHash); + m_CommitHash->SetValue(rev->m_CommitHash.ToString()); m_AuthorName->SetValue(rev->m_AuthorName); m_AuthorDate->SetValue(rev->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M"))); m_AuthorEmail->SetValue(rev->m_AuthorEmail); @@ -383,12 +383,12 @@ void CPropertiesWnd::UpdateProperties(GitRev *rev) index=pLogEntry->m_HashMap[rev->m_ParentHash[i]]; } if(index>=0) - parentsubject=pLogEntry->at(index).m_Subject; + parentsubject=pLogEntry->GetGitRevAt(index).m_Subject; str.Format(_T("%d - %s \n %s"),i,rev->m_ParentHash[i],parentsubject); CMFCPropertyGridProperty*p=new CMFCPropertyGridProperty( - rev->m_ParentHash[i].Left(8), + rev->m_ParentHash[i].ToString().Left(8), parentsubject, str ); diff --git a/src/TortoiseGitBlame/TortoiseGitBlame.vcproj b/src/TortoiseGitBlame/TortoiseGitBlame.vcproj index eaa63dd61..33b1d37a9 100644 --- a/src/TortoiseGitBlame/TortoiseGitBlame.vcproj +++ b/src/TortoiseGitBlame/TortoiseGitBlame.vcproj @@ -48,7 +48,7 @@ =0 && id <(int)GetLogData()->size()) { m_ID.push_back(pRevs->size()-id); - m_Authors.push_back(pRevs->at(id).m_AuthorName); + m_Authors.push_back(pRevs->GetGitRevAt(id).m_AuthorName); }else { m_ID.push_back(id); @@ -2539,7 +2539,7 @@ void CTortoiseGitBlameView::OnLButtonDown(UINT nFlags,CPoint point) LVIS_SELECTED); GitRev *pRev; - pRev=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID[line]); + pRev=&this->GetLogData()->GetGitRevAt(this->GetLogList()->GetItemCount()-m_ID[line]); this->GetDocument()->GetMainFrame()->m_wndProperties.UpdateProperties(pRev); }else { @@ -2591,7 +2591,7 @@ void CTortoiseGitBlameView::FocusOn(GitRev *pRev) int i; for(i=0;im_CommitHash == m_CommitHash[i] ) + if( pRev->m_CommitHash.ToString() == m_CommitHash[i] ) break; } this->GotoLine(i); @@ -2618,7 +2618,7 @@ void CTortoiseGitBlameView::OnMouseHover(UINT nFlags, CPoint point) }else { - pRev=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID[line]); + pRev=&this->GetLogData()->GetGitRevAt(this->GetLogList()->GetItemCount()-m_ID[line]); } this->ClientToScreen(&point); diff --git a/src/TortoiseMerge/TortoiseMerge.vcproj b/src/TortoiseMerge/TortoiseMerge.vcproj index 4b3962d66..9836cfd59 100644 --- a/src/TortoiseMerge/TortoiseMerge.vcproj +++ b/src/TortoiseMerge/TortoiseMerge.vcproj @@ -47,7 +47,7 @@ +#include #include "SVNLineDiff.h" const svn_diff_fns_t SVNLineDiff::SVNLineDiff_vtable = diff --git a/src/TortoiseProc/TortoiseProc.vcproj b/src/TortoiseProc/TortoiseProc.vcproj index e29bd6096..ec294ac3f 100644 --- a/src/TortoiseProc/TortoiseProc.vcproj +++ b/src/TortoiseProc/TortoiseProc.vcproj @@ -48,7 +48,7 @@