OSDN Git Service

Auto MsysGit Path and use git.exe replace git.cmd
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / TortoiseProc.cpp
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