OSDN Git Service

Add home enviroment and fix memory leak problem
authorFrank Li <lznuaa@gmail.com>
Thu, 1 Jan 2009 16:01:39 +0000 (00:01 +0800)
committerFrank Li <lznuaa@gmail.com>
Thu, 1 Jan 2009 16:01:39 +0000 (00:01 +0800)
src/Git/GitStatusListCtrl.cpp
src/Git/GitStatusListCtrl.h
src/TortoiseProc/Commands/CommitCommand.cpp
src/TortoiseProc/CommitDlg.cpp
src/TortoiseProc/TortoiseProc.cpp
src/TortoiseProc/TortoiseProc.vcproj.FSL.B20596.user

index 2bab662..92c4a96 100644 (file)
@@ -1064,7 +1064,8 @@ void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFold
 \r
        for(int i=0;i<this->m_arStatusArray.size();i++)\r
        {\r
-               AddEntry((CTGitPath*)m_arStatusArray[i],langID,i);\r
+               if(((CTGitPath*)m_arStatusArray[i])->m_Action & dwShow)\r
+                               AddEntry((CTGitPath*)m_arStatusArray[i],langID,i);\r
        }\r
        \r
        int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;\r
@@ -1112,13 +1113,15 @@ void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFold
                pApp->DoWaitCursor(-1);\r
 \r
        Invalidate();\r
+       \r
+       m_dwShow = dwShow;\r
 \r
 #if 0\r
 \r
        CWinApp * pApp = AfxGetApp();\r
        if (pApp)\r
                pApp->DoWaitCursor(1);\r
-       m_dwShow = dwShow;\r
+\r
        m_bShowFolders = bShowFolders;\r
        \r
        int nTopIndex = GetTopIndex();\r
@@ -2743,13 +2746,16 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                                                CString cmd;\r
                                                cmd.Format(_T("git.exe add %s"),path->GetGitPathString());\r
                                                CString output;\r
-                                               g_Git.Run(cmd,&output);\r
-                                               path->m_Action = CTGitPath::LOGACTIONS_ADDED;\r
-                                               SetEntryCheck(path,index,true);\r
-                                               SetItemGroup(index,0);\r
-                                               this->m_StatusFileList.AddPath(*path);\r
-                                               this->m_UnRevFileList.RemoveItem(*path);\r
-                                               this->m_IgnoreFileList.RemoveItem(*path);\r
+                                               if(!g_Git.Run(cmd,&output))\r
+                                               {\r
+                                                       path->m_Action = CTGitPath::LOGACTIONS_ADDED;\r
+                                                       SetEntryCheck(path,index,true);\r
+                                                       SetItemGroup(index,0);\r
+                                                       this->m_StatusFileList.AddPath(*path);\r
+                                                       this->m_UnRevFileList.RemoveItem(*path);\r
+                                                       this->m_IgnoreFileList.RemoveItem(*path);\r
+                                                       Show(this->m_dwShow);\r
+                                               }\r
                                        }\r
                                        \r
                                }\r
@@ -5267,7 +5273,21 @@ int CGitStatusListCtrl::UpdateFileList(git_revnum_t hash,CTGitPathList *list)
                        else\r
                                cmd.Format(_T("git.exe diff-index --raw HEAD --numstat -C -M -- \"%s\""),(*list)[i].GetGitPathString());\r
 \r
-                       g_Git.Run(cmd,&cmdout);\r
+                       if(g_Git.Run(cmd,&cmdout))\r
+                       {\r
+                               cmdout.Empty();\r
+                               if(g_Git.Run(_T("git.exe rev-parse --revs-only HEAD"),&cmdout))\r
+                               {\r
+                                       CMessageBox::Show(NULL,cmdout,_T("TortoiseGit"),MB_OK);\r
+                                       return -1;\r
+                               }\r
+                               if(cmdout.IsEmpty())\r
+                                       break; //this is initial repositoyr, there are no any history\r
+\r
+                               CMessageBox::Show(NULL,cmdout,_T("TortoiseGit"),MB_OK);\r
+                               return -1;\r
+\r
+                       }\r
 \r
                        out+=cmdout;\r
                }\r
index 0584d30..21233a9 100644 (file)
 //#define SVNSLC_COLSVNNEEDSLOCK               0x000010000\r
 //#define SVNSLC_COLCOPYFROM                   0x000020000\r
 \r
-\r
-#define SVNSLC_SHOWUNVERSIONED 0x000000001\r
-#define SVNSLC_SHOWNORMAL              0x000000002\r
-#define SVNSLC_SHOWMODIFIED            0x000000004\r
-#define SVNSLC_SHOWADDED               0x000000008\r
-#define SVNSLC_SHOWREMOVED             0x000000010\r
-#define SVNSLC_SHOWCONFLICTED  0x000000020\r
-#define SVNSLC_SHOWMISSING             0x000000040\r
-#define SVNSLC_SHOWREPLACED            0x000000080\r
-#define SVNSLC_SHOWMERGED              0x000000100\r
-#define SVNSLC_SHOWIGNORED             0x000000200\r
-#define SVNSLC_SHOWOBSTRUCTED  0x000000400\r
-#define SVNSLC_SHOWEXTERNAL            0x000000800\r
-#define SVNSLC_SHOWINCOMPLETE  0x000001000\r
-#define SVNSLC_SHOWINEXTERNALS 0x000002000\r
-#define SVNSLC_SHOWREMOVEDANDPRESENT 0x000004000\r
-#define SVNSLC_SHOWLOCKS               0x000008000\r
-#define SVNSLC_SHOWDIRECTFILES 0x000010000\r
-#define SVNSLC_SHOWDIRECTFOLDER 0x000020000\r
-#define SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO 0x000040000\r
-#define SVNSLC_SHOWSWITCHED            0x000080000\r
-#define SVNSLC_SHOWINCHANGELIST 0x000100000\r
+               \r
+#define SVNSLC_SHOWUNVERSIONED CTGitPath::LOGACTIONS_UNVER\r
+#define SVNSLC_SHOWNORMAL              0x000000000\r
+#define SVNSLC_SHOWMODIFIED            CTGitPath::LOGACTIONS_MODIFIED\r
+#define SVNSLC_SHOWADDED               CTGitPath::LOGACTIONS_ADDED\r
+#define SVNSLC_SHOWREMOVED             CTGitPath::LOGACTIONS_DELETED\r
+#define SVNSLC_SHOWCONFLICTED  CTGitPath::LOGACTIONS_CONFLICT\r
+#define SVNSLC_SHOWMISSING             0x00000000\r
+#define SVNSLC_SHOWREPLACED            CTGitPath::LOGACTIONS_REPLACED\r
+#define SVNSLC_SHOWMERGED              0x00000000\r
+#define SVNSLC_SHOWIGNORED             CTGitPath::LOGACTIONS_IGNORE\r
+#define SVNSLC_SHOWOBSTRUCTED  0x00000000\r
+#define SVNSLC_SHOWEXTERNAL            0x00000000\r
+#define SVNSLC_SHOWINCOMPLETE  0x00000000\r
+#define SVNSLC_SHOWINEXTERNALS 0x00000000\r
+#define SVNSLC_SHOWREMOVEDANDPRESENT 0x00000000\r
+#define SVNSLC_SHOWLOCKS               0x00000000\r
+#define SVNSLC_SHOWDIRECTFILES 0x00000000\r
+#define SVNSLC_SHOWDIRECTFOLDER 0x00000000\r
+#define SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO 0x00000000\r
+#define SVNSLC_SHOWSWITCHED            0x00000000\r
+#define SVNSLC_SHOWINCHANGELIST 0x00000000\r
 \r
 #define SVNSLC_SHOWDIRECTS             (SVNSLC_SHOWDIRECTFILES | SVNSLC_SHOWDIRECTFOLDER)\r
 \r
index 60d6f50..93ebf42 100644 (file)
@@ -66,9 +66,7 @@ bool CommitCommand::Execute()
                }\r
        }\r
 #endif\r
-       if(pathList.GetCount()>0)\r
-               g_Git.m_CurrentDir=pathList[0].GetWinPathString();\r
-       \r
+               \r
        while (bFailed)\r
        {\r
                bFailed = false;\r
index fae37ac..8fee91f 100644 (file)
@@ -841,6 +841,10 @@ void CCommitDlg::OnBnClickedShowunversioned()
                        dwShow |= SVNSLC_SHOWUNVERSIONED;\r
                else\r
                        dwShow &= ~SVNSLC_SHOWUNVERSIONED;\r
+               if(dwShow & SVNSLC_SHOWUNVERSIONED)\r
+               {\r
+                       m_ListCtrl.GetStatus(this->m_pathList,false,false,true);\r
+               }\r
                m_ListCtrl.Show(dwShow);\r
        }\r
 }\r
index c0f9955..65e57f4 100644 (file)
@@ -118,9 +118,18 @@ BOOL CTortoiseProcApp::CheckMsysGitDir()
        }\r
        CGit::m_MsysGitPath=str;\r
 \r
-       TCHAR *oldpath;\r
+       TCHAR *oldpath,*home;\r
        size_t size;\r
+\r
+       _tdupenv_s(&home,&size,_T("HOME")); \r
        \r
+       if(home == NULL)\r
+       {               \r
+               _tdupenv_s(&home,&size,_T("USERPROFILE")); \r
+               _tputenv_s(_T("HOME"),home);\r
+               free(home);\r
+       }\r
+       //set path\r
        _tdupenv_s(&oldpath,&size,_T("PATH")); \r
 \r
        CString path;\r
@@ -129,6 +138,8 @@ BOOL CTortoiseProcApp::CheckMsysGitDir()
 \r
        _tputenv_s(_T("PATH"),path);\r
 \r
+       free(oldpath);\r
+\r
        CString cmd,out;\r
        cmd=_T("git.exe --version");\r
        if(g_Git.Run(cmd,&out))\r
index adccdad..2c0372c 100644 (file)
@@ -11,7 +11,7 @@
                        <DebugSettings\r
                                Command="$(TargetPath)"\r
                                WorkingDirectory="D:\Profiles\b20596\tortoisegit"\r
-                               CommandArguments="/command:log /path:&quot;C:\\WINCE600&quot;"\r
+                               CommandArguments="/command:commit /path:&quot;D:\\test&quot;"\r
                                Attach="false"\r
                                DebuggerType="3"\r
                                Remote="1"\r