OSDN Git Service

Auto MsysGit Path and use git.exe replace git.cmd
authorFrank Li <lznuaa@gmail.com>
Thu, 18 Dec 2008 15:14:09 +0000 (23:14 +0800)
committerFrank Li <lznuaa@gmail.com>
Thu, 18 Dec 2008 15:14:09 +0000 (23:14 +0800)
src/Git/Git.cpp
src/Git/Git.h
src/TortoiseProc/TortoiseProc.cpp
src/TortoiseProc/TortoiseProc.h
src/TortoiseProc/TortoiseProc.vcproj

index d0271dd..4450394 100644 (file)
@@ -39,7 +39,6 @@ int CGit::Run(CString cmd, CString* output)
        si.wShowWindow=SW_HIDE;\r
        si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;\r
 \r
-       \r
        if(!CreateProcess(NULL,(LPWSTR)cmd.GetString(), NULL,NULL,TRUE,NULL,NULL,(LPWSTR)m_CurrentDir.GetString(),&si,&pi))\r
        {\r
                LPVOID lpMsgBuf;\r
index 56f8d66..03ffece 100644 (file)
@@ -14,7 +14,7 @@ class CGit
 private:\r
        GitAdminDir m_GitDir;\r
 public:\r
-\r
+       static CString m_MsysGitPath;\r
        CGit(void);\r
        ~CGit(void);\r
        int Run(CString cmd, CString* output);\r
index 0b8a831..c0f9955 100644 (file)
@@ -57,7 +57,7 @@ BEGIN_MESSAGE_MAP(CTortoiseProcApp, CWinAppEx)
 END_MESSAGE_MAP()\r
 \r
 CString g_version;\r
-\r
+CString CGit::m_MsysGitPath;\r
 //////////////////////////////////////////////////////////////////////////\r
 \r
 CTortoiseProcApp::CTortoiseProcApp()\r
@@ -103,6 +103,42 @@ CTortoiseProcApp theApp;
 HWND hWndExplorer;\r
 CString sOrigCWD;\r
 \r
+BOOL CTortoiseProcApp::CheckMsysGitDir()\r
+{\r
+       CRegString msysdir=CRegString(_T("Software\\TortoiseGit\\MSysGit"),_T(""),FALSE,HKEY_LOCAL_MACHINE);\r
+       CString str=msysdir;\r
+       if(str.IsEmpty())\r
+       {\r
+               CRegString msysinstalldir=CRegString(_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1\\InstallLocation"),_T(""),FALSE,HKEY_LOCAL_MACHINE);\r
+               str=msysinstalldir;\r
+               str+="\\bin";\r
+               msysdir=str;\r
+               msysdir.write();\r
+\r
+       }\r
+       CGit::m_MsysGitPath=str;\r
+\r
+       TCHAR *oldpath;\r
+       size_t size;\r
+       \r
+       _tdupenv_s(&oldpath,&size,_T("PATH")); \r
+\r
+       CString path;\r
+       path.Format(_T("%s;"),str);\r
+       path+=oldpath;\r
+\r
+       _tputenv_s(_T("PATH"),path);\r
+\r
+       CString cmd,out;\r
+       cmd=_T("git.exe --version");\r
+       if(g_Git.Run(cmd,&out))\r
+       {\r
+               return false;\r
+       }\r
+       else\r
+               return true;\r
+       \r
+}\r
 //CCrashReport crasher("crashreports@tortoisesvn.tigris.org", "Crash Report for TortoiseSVN " APP_X64_STRING " : " STRPRODUCTVER, TRUE);// crash\r
 \r
 // CTortoiseProcApp initialization\r
@@ -113,6 +149,19 @@ BOOL CTortoiseProcApp::InitInstance()
        CheckUpgrade();\r
        CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));\r
        CMFCButton::EnableWindowsTheming();\r
+\r
+       if(!CheckMsysGitDir())\r
+       {\r
+               if(CMessageBox::Show(NULL,_T("MSysGit(http://code.google.com/p/msysgit) have not installed Correctly\n\\r
+or MSysGit Path setting error\n\\r
+Click Yes to open setting dialog to setup MSysGit Path"),\r
+                                                       _T("TortoiseGit"),MB_YESNO|MB_ICONERROR)==IDYES);\r
+               {\r
+                       //todo open setting\r
+               }\r
+               return FALSE;   \r
+       }\r
+\r
        //set the resource dll for the required language\r
        CRegDWORD loc = CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);\r
        long langId = loc;\r
index b4a3fe2..d61b770 100644 (file)
@@ -55,6 +55,8 @@ public:
        virtual BOOL InitInstance();\r
        virtual int ExitInstance();\r
 \r
+       BOOL CheckMsysGitDir();\r
+\r
        void CheckUpgrade();\r
        void EnableCrashHandler();\r
 \r
index 1e593fb..486644f 100644 (file)
                                </File>\r
                        </Filter>\r
                        <Filter\r
-                               Name="Diff"\r
-                               >\r
-                               <File\r
-                                       RelativePath=".\Commands\DiffCommand.cpp"\r
-                                       >\r
-                               </File>\r
-                               <File\r
-                                       RelativePath=".\Commands\DiffCommand.h"\r
-                                       >\r
-                               </File>\r
-                       </Filter>\r
-                       <Filter\r
                                Name="Rename"\r
                                >\r
                                <File\r
                                </File>\r
                        </Filter>\r
                </Filter>\r
+               <Filter\r
+                       Name="Diff"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\Commands\DiffCommand.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\Commands\DiffCommand.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
                <File\r
                        RelativePath="Resource.h"\r
                        >\r