From 8c91bbc1909bd8bddf37fa47bd4500c271fd5ae7 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Fri, 2 Jan 2009 00:01:39 +0800 Subject: [PATCH] Add home enviroment and fix memory leak problem --- src/Git/GitStatusListCtrl.cpp | 40 +++++++++++++++----- src/Git/GitStatusListCtrl.h | 44 +++++++++++----------- src/TortoiseProc/Commands/CommitCommand.cpp | 4 +- src/TortoiseProc/CommitDlg.cpp | 4 ++ src/TortoiseProc/TortoiseProc.cpp | 13 ++++++- .../TortoiseProc.vcproj.FSL.B20596.user | 2 +- 6 files changed, 70 insertions(+), 37 deletions(-) diff --git a/src/Git/GitStatusListCtrl.cpp b/src/Git/GitStatusListCtrl.cpp index 2bab6626b..92c4a961c 100644 --- a/src/Git/GitStatusListCtrl.cpp +++ b/src/Git/GitStatusListCtrl.cpp @@ -1064,7 +1064,8 @@ void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFold for(int i=0;im_arStatusArray.size();i++) { - AddEntry((CTGitPath*)m_arStatusArray[i],langID,i); + if(((CTGitPath*)m_arStatusArray[i])->m_Action & dwShow) + AddEntry((CTGitPath*)m_arStatusArray[i],langID,i); } int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1; @@ -1112,13 +1113,15 @@ void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFold pApp->DoWaitCursor(-1); Invalidate(); + + m_dwShow = dwShow; #if 0 CWinApp * pApp = AfxGetApp(); if (pApp) pApp->DoWaitCursor(1); - m_dwShow = dwShow; + m_bShowFolders = bShowFolders; int nTopIndex = GetTopIndex(); @@ -2743,13 +2746,16 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) CString cmd; cmd.Format(_T("git.exe add %s"),path->GetGitPathString()); CString output; - g_Git.Run(cmd,&output); - path->m_Action = CTGitPath::LOGACTIONS_ADDED; - SetEntryCheck(path,index,true); - SetItemGroup(index,0); - this->m_StatusFileList.AddPath(*path); - this->m_UnRevFileList.RemoveItem(*path); - this->m_IgnoreFileList.RemoveItem(*path); + if(!g_Git.Run(cmd,&output)) + { + path->m_Action = CTGitPath::LOGACTIONS_ADDED; + SetEntryCheck(path,index,true); + SetItemGroup(index,0); + this->m_StatusFileList.AddPath(*path); + this->m_UnRevFileList.RemoveItem(*path); + this->m_IgnoreFileList.RemoveItem(*path); + Show(this->m_dwShow); + } } } @@ -5267,7 +5273,21 @@ int CGitStatusListCtrl::UpdateFileList(git_revnum_t hash,CTGitPathList *list) else cmd.Format(_T("git.exe diff-index --raw HEAD --numstat -C -M -- \"%s\""),(*list)[i].GetGitPathString()); - g_Git.Run(cmd,&cmdout); + if(g_Git.Run(cmd,&cmdout)) + { + cmdout.Empty(); + if(g_Git.Run(_T("git.exe rev-parse --revs-only HEAD"),&cmdout)) + { + CMessageBox::Show(NULL,cmdout,_T("TortoiseGit"),MB_OK); + return -1; + } + if(cmdout.IsEmpty()) + break; //this is initial repositoyr, there are no any history + + CMessageBox::Show(NULL,cmdout,_T("TortoiseGit"),MB_OK); + return -1; + + } out+=cmdout; } diff --git a/src/Git/GitStatusListCtrl.h b/src/Git/GitStatusListCtrl.h index 0584d301f..21233a9a6 100644 --- a/src/Git/GitStatusListCtrl.h +++ b/src/Git/GitStatusListCtrl.h @@ -52,28 +52,28 @@ //#define SVNSLC_COLSVNNEEDSLOCK 0x000010000 //#define SVNSLC_COLCOPYFROM 0x000020000 - -#define SVNSLC_SHOWUNVERSIONED 0x000000001 -#define SVNSLC_SHOWNORMAL 0x000000002 -#define SVNSLC_SHOWMODIFIED 0x000000004 -#define SVNSLC_SHOWADDED 0x000000008 -#define SVNSLC_SHOWREMOVED 0x000000010 -#define SVNSLC_SHOWCONFLICTED 0x000000020 -#define SVNSLC_SHOWMISSING 0x000000040 -#define SVNSLC_SHOWREPLACED 0x000000080 -#define SVNSLC_SHOWMERGED 0x000000100 -#define SVNSLC_SHOWIGNORED 0x000000200 -#define SVNSLC_SHOWOBSTRUCTED 0x000000400 -#define SVNSLC_SHOWEXTERNAL 0x000000800 -#define SVNSLC_SHOWINCOMPLETE 0x000001000 -#define SVNSLC_SHOWINEXTERNALS 0x000002000 -#define SVNSLC_SHOWREMOVEDANDPRESENT 0x000004000 -#define SVNSLC_SHOWLOCKS 0x000008000 -#define SVNSLC_SHOWDIRECTFILES 0x000010000 -#define SVNSLC_SHOWDIRECTFOLDER 0x000020000 -#define SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO 0x000040000 -#define SVNSLC_SHOWSWITCHED 0x000080000 -#define SVNSLC_SHOWINCHANGELIST 0x000100000 + +#define SVNSLC_SHOWUNVERSIONED CTGitPath::LOGACTIONS_UNVER +#define SVNSLC_SHOWNORMAL 0x000000000 +#define SVNSLC_SHOWMODIFIED CTGitPath::LOGACTIONS_MODIFIED +#define SVNSLC_SHOWADDED CTGitPath::LOGACTIONS_ADDED +#define SVNSLC_SHOWREMOVED CTGitPath::LOGACTIONS_DELETED +#define SVNSLC_SHOWCONFLICTED CTGitPath::LOGACTIONS_CONFLICT +#define SVNSLC_SHOWMISSING 0x00000000 +#define SVNSLC_SHOWREPLACED CTGitPath::LOGACTIONS_REPLACED +#define SVNSLC_SHOWMERGED 0x00000000 +#define SVNSLC_SHOWIGNORED CTGitPath::LOGACTIONS_IGNORE +#define SVNSLC_SHOWOBSTRUCTED 0x00000000 +#define SVNSLC_SHOWEXTERNAL 0x00000000 +#define SVNSLC_SHOWINCOMPLETE 0x00000000 +#define SVNSLC_SHOWINEXTERNALS 0x00000000 +#define SVNSLC_SHOWREMOVEDANDPRESENT 0x00000000 +#define SVNSLC_SHOWLOCKS 0x00000000 +#define SVNSLC_SHOWDIRECTFILES 0x00000000 +#define SVNSLC_SHOWDIRECTFOLDER 0x00000000 +#define SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO 0x00000000 +#define SVNSLC_SHOWSWITCHED 0x00000000 +#define SVNSLC_SHOWINCHANGELIST 0x00000000 #define SVNSLC_SHOWDIRECTS (SVNSLC_SHOWDIRECTFILES | SVNSLC_SHOWDIRECTFOLDER) diff --git a/src/TortoiseProc/Commands/CommitCommand.cpp b/src/TortoiseProc/Commands/CommitCommand.cpp index 60d6f506c..93ebf42e7 100644 --- a/src/TortoiseProc/Commands/CommitCommand.cpp +++ b/src/TortoiseProc/Commands/CommitCommand.cpp @@ -66,9 +66,7 @@ bool CommitCommand::Execute() } } #endif - if(pathList.GetCount()>0) - g_Git.m_CurrentDir=pathList[0].GetWinPathString(); - + while (bFailed) { bFailed = false; diff --git a/src/TortoiseProc/CommitDlg.cpp b/src/TortoiseProc/CommitDlg.cpp index fae37acb8..8fee91f5f 100644 --- a/src/TortoiseProc/CommitDlg.cpp +++ b/src/TortoiseProc/CommitDlg.cpp @@ -841,6 +841,10 @@ void CCommitDlg::OnBnClickedShowunversioned() dwShow |= SVNSLC_SHOWUNVERSIONED; else dwShow &= ~SVNSLC_SHOWUNVERSIONED; + if(dwShow & SVNSLC_SHOWUNVERSIONED) + { + m_ListCtrl.GetStatus(this->m_pathList,false,false,true); + } m_ListCtrl.Show(dwShow); } } diff --git a/src/TortoiseProc/TortoiseProc.cpp b/src/TortoiseProc/TortoiseProc.cpp index c0f9955ef..65e57f49c 100644 --- a/src/TortoiseProc/TortoiseProc.cpp +++ b/src/TortoiseProc/TortoiseProc.cpp @@ -118,9 +118,18 @@ BOOL CTortoiseProcApp::CheckMsysGitDir() } CGit::m_MsysGitPath=str; - TCHAR *oldpath; + TCHAR *oldpath,*home; size_t size; + + _tdupenv_s(&home,&size,_T("HOME")); + if(home == NULL) + { + _tdupenv_s(&home,&size,_T("USERPROFILE")); + _tputenv_s(_T("HOME"),home); + free(home); + } + //set path _tdupenv_s(&oldpath,&size,_T("PATH")); CString path; @@ -129,6 +138,8 @@ BOOL CTortoiseProcApp::CheckMsysGitDir() _tputenv_s(_T("PATH"),path); + free(oldpath); + CString cmd,out; cmd=_T("git.exe --version"); if(g_Git.Run(cmd,&out)) diff --git a/src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user b/src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user index adccdad17..2c0372cbf 100644 --- a/src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user +++ b/src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user @@ -11,7 +11,7 @@