OSDN Git Service

Show nothing rebase when local branch equal upstream at rebasedlg
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / TortoiseProc.cpp
index 8dd922d..f1e4158 100644 (file)
@@ -20,7 +20,7 @@
 //#include "vld.h"\r
 #include "TortoiseProc.h"\r
 #include "SysImageList.h"\r
-//#include "CrashReport.h"\r
+#include "CrashReport.h"\r
 #include "CmdLineParser.h"\r
 #include "Hooks.h"\r
 #include "AppUtils.h"\r
 //#include <openssl/err.h>\r
 \r
 #include "Commands\Command.h"\r
-\r
+#include "CommonResource.h"\r
 #include "..\version.h"\r
+#include "..\Settings\Settings.h"\r
+#include "gitindex.h"\r
+\r
 #define STRUCT_IOVEC_DEFINED\r
 //#include "sasl.h"\r
 \r
@@ -56,16 +59,16 @@ BEGIN_MESSAGE_MAP(CTortoiseProcApp, CWinAppEx)
        ON_COMMAND(ID_HELP, CWinAppEx::OnHelp)\r
 END_MESSAGE_MAP()\r
 \r
-CString g_version;\r
-\r
+//CString g_version;\r
+//CString CGit::m_MsysGitPath;\r
 //////////////////////////////////////////////////////////////////////////\r
 \r
 CTortoiseProcApp::CTortoiseProcApp()\r
 {\r
        EnableHtmlHelp();\r
-       int argc = 0;\r
-       g_version=_T("abc");\r
-       const char* const * argv = NULL;\r
+//     int argc = 0;\r
+//     g_version=_T("abc");\r
+//     const char* const * argv = NULL;\r
 //     apr_app_initialize(&argc, &argv, NULL);\r
 //     svn_dso_initialize2();\r
        SYS_IMAGE_LIST();\r
@@ -74,8 +77,10 @@ CTortoiseProcApp::CTortoiseProcApp()
        m_bLoadUserToolbars = FALSE;\r
        m_bSaveState = FALSE;\r
        retSuccess = false;\r
-       CGit git;\r
-       git.GetUserName();\r
+       //CGit git;\r
+       //git.GetUserName();\r
+\r
+       \r
 }\r
 \r
 CTortoiseProcApp::~CTortoiseProcApp()\r
@@ -103,7 +108,16 @@ CTortoiseProcApp theApp;
 HWND hWndExplorer;\r
 CString sOrigCWD;\r
 \r
-//CCrashReport crasher("crashreports@tortoisesvn.tigris.org", "Crash Report for TortoiseSVN " APP_X64_STRING " : " STRPRODUCTVER, TRUE);// crash\r
+BOOL CTortoiseProcApp::CheckMsysGitDir()\r
+{\r
+       CGitIndexFileMap map;\r
+       //int status;\r
+       //CTGitPath path;\r
+       //path.SetFromGit(_T("src/gpl.txt"));\r
+       //map.GetFileStatus(_T("D:\\TortoiseGit"),&path, &status);\r
+       return CGit::CheckMsysGitDir(); \r
+}\r
+CCrashReport crasher("tortoisegit-bug@googlegroups.com", "Crash Report for TortoiseGit " APP_X64_STRING " : " STRPRODUCTVER, TRUE);// crash\r
 \r
 // CTortoiseProcApp initialization\r
 \r
@@ -113,8 +127,31 @@ BOOL CTortoiseProcApp::InitInstance()
        CheckUpgrade();\r
        CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));\r
        CMFCButton::EnableWindowsTheming();\r
+\r
+       Gdiplus::GdiplusStartupInput gdiplusStartupInput;\r
+       Gdiplus::GdiplusStartup(&m_gdiplusToken,&gdiplusStartupInput,NULL);\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
+                       // open settings dialog\r
+                       CSettings dlg(IDS_PROC_SETTINGS_TITLE);\r
+                       dlg.SetTreeViewMode(TRUE, TRUE, TRUE);\r
+                       dlg.SetTreeWidth(220);\r
+                       \r
+                       dlg.DoModal();\r
+                       dlg.HandleRestart();\r
+                       return TRUE;\r
+               }\r
+               return FALSE;   \r
+       }\r
+\r
        //set the resource dll for the required language\r
-       CRegDWORD loc = CRegDWORD(_T("Software\\TortoiseSVN\\LanguageID"), 1033);\r
+       CRegDWORD loc = CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);\r
        long langId = loc;\r
        CString langDll;\r
        CStringA langpath = CStringA(CPathUtils::GetAppParentDirectory());\r
@@ -159,10 +196,10 @@ BOOL CTortoiseProcApp::InitInstance()
        sHelppath = sHelppath.MakeLower();\r
        // MFC uses a help file with the same name as the application by default,\r
        // which means we have to change that default to our language specific help files\r
-       sHelppath.Replace(_T("tortoiseproc.chm"), _T("TortoiseSVN_en.chm"));\r
+       sHelppath.Replace(_T("tortoiseproc.chm"), _T("TortoiseGit_en.chm"));\r
        free((void*)m_pszHelpFilePath);\r
        m_pszHelpFilePath=_tcsdup(sHelppath);\r
-       sHelppath = CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseSVN_en.chm");\r
+       sHelppath = CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseGit_en.chm");\r
        do\r
        {\r
                CString sLang = _T("_");\r
@@ -220,13 +257,13 @@ BOOL CTortoiseProcApp::InitInstance()
        AfxEnableControlContainer();\r
        AfxInitRichEdit2();\r
        CWinAppEx::InitInstance();\r
-       SetRegistryKey(_T("TortoiseSVN"));\r
+       SetRegistryKey(_T("TortoiseGit"));\r
 \r
        CCmdLineParser parser(AfxGetApp()->m_lpCmdLine);\r
 \r
        // if HKCU\Software\TortoiseSVN\Debug is not 0, show our command line\r
        // in a message box\r
-       if (CRegDWORD(_T("Software\\TortoiseSVN\\Debug"), FALSE)==TRUE)\r
+       if (CRegDWORD(_T("Software\\TortoiseGit\\Debug"), FALSE)==TRUE)\r
                AfxMessageBox(AfxGetApp()->m_lpCmdLine, MB_OK | MB_ICONINFORMATION);\r
 \r
        if ( parser.HasKey(_T("path")) && parser.HasKey(_T("pathfile")))\r
@@ -241,6 +278,7 @@ BOOL CTortoiseProcApp::InitInstance()
        {\r
 \r
                CString sPathfileArgument = CPathUtils::GetLongPathname(parser.GetVal(_T("pathfile")));\r
+\r
                cmdLinePath.SetFromUnknown(sPathfileArgument);\r
                if (pathList.LoadFromFile(cmdLinePath)==false)\r
                        return FALSE;           // no path specified!\r
@@ -298,7 +336,7 @@ BOOL CTortoiseProcApp::InitInstance()
        }\r
 \r
        // check for newer versions\r
-       if (CRegDWORD(_T("Software\\TortoiseSVN\\CheckNewer"), TRUE) != FALSE)\r
+       if (CRegDWORD(_T("Software\\TortoiseGit\\CheckNewer"), TRUE) != FALSE)\r
        {\r
                time_t now;\r
                struct tm ptm;\r
@@ -312,7 +350,7 @@ BOOL CTortoiseProcApp::InitInstance()
                        // that's not needed.\r
                        week = ptm.tm_yday / 7;\r
 \r
-                       CRegDWORD oldweek = CRegDWORD(_T("Software\\TortoiseSVN\\CheckNewerWeek"), (DWORD)-1);\r
+                       CRegDWORD oldweek = CRegDWORD(_T("Software\\TortoiseGit\\CheckNewerWeek"), (DWORD)-1);\r
                        if (((DWORD)oldweek) == -1)\r
                                oldweek = week;         // first start of TortoiseProc, no update check needed\r
                        else\r
@@ -371,8 +409,23 @@ BOOL CTortoiseProcApp::InitInstance()
        if (cmd)\r
        {\r
                cmd->SetExplorerHwnd(hWndExplorer);\r
+               \r
+               if(!g_Git.SetCurrentDir(cmdLinePath.GetWinPathString()))\r
+               {\r
+                       int i=0;\r
+                       for(i=0;i<pathList.GetCount();i++)\r
+                               if(g_Git.SetCurrentDir(pathList[i].GetWinPath()))\r
+                                       break;\r
+               }\r
+\r
+               if(!g_Git.m_CurrentDir.IsEmpty())\r
+                       SetCurrentDirectory(g_Git.m_CurrentDir);\r
+\r
                cmd->SetParser(parser);\r
                cmd->SetPaths(pathList, cmdLinePath);\r
+               \r
+               CGit::m_LogEncode = CAppUtils::GetLogOutputEncode();\r
+\r
                retSuccess = cmd->Execute();\r
                delete cmd;\r
        }\r
@@ -428,7 +481,7 @@ BOOL CTortoiseProcApp::InitInstance()
 \r
 void CTortoiseProcApp::CheckUpgrade()\r
 {\r
-       CRegString regVersion = CRegString(_T("Software\\TortoiseSVN\\CurrentVersion"));\r
+       CRegString regVersion = CRegString(_T("Software\\TortoiseGit\\CurrentVersion"));\r
        CString sVersion = regVersion;\r
        if (sVersion.Compare(_T(STRPRODUCTVER))==0)\r
                return;\r
@@ -444,11 +497,11 @@ void CTortoiseProcApp::CheckUpgrade()
                lVersion |= (_ttol(sVersion.Mid(pos+1))<<8);\r
        }\r
        \r
-       CRegDWORD regval = CRegDWORD(_T("Software\\TortoiseSVN\\DontConvertBase"), 999);\r
+       CRegDWORD regval = CRegDWORD(_T("Software\\TortoiseGit\\DontConvertBase"), 999);\r
        if ((DWORD)regval != 999)\r
        {\r
                // there's a leftover registry setting we have to convert and then delete it\r
-               CRegDWORD newregval = CRegDWORD(_T("Software\\TortoiseSVN\\ConvertBase"));\r
+               CRegDWORD newregval = CRegDWORD(_T("Software\\TortoiseGit\\ConvertBase"));\r
                newregval = !regval;\r
                regval.removeValue();\r
        }\r
@@ -457,22 +510,22 @@ void CTortoiseProcApp::CheckUpgrade()
        {\r
                CSoundUtils::RegisterTSVNSounds();\r
                // remove all saved dialog positions\r
-               CRegString(_T("Software\\TortoiseSVN\\TortoiseProc\\ResizableState\\")).removeKey();\r
-               CRegDWORD(_T("Software\\TortoiseSVN\\RecursiveOverlay")).removeValue();\r
+               CRegString(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\")).removeKey();\r
+               CRegDWORD(_T("Software\\TortoiseGit\\RecursiveOverlay")).removeValue();\r
                // remove the external cache key\r
-               CRegDWORD(_T("Software\\TortoiseSVN\\ExternalCache")).removeValue();\r
+               CRegDWORD(_T("Software\\TortoiseGit\\ExternalCache")).removeValue();\r
        }\r
 #endif \r
        if (lVersion <= 0x01020200)\r
        {\r
                // upgrade to > 1.2.3 means the doc diff scripts changed from vbs to js\r
                // so remove the diff/merge scripts if they're the defaults\r
-               CRegString diffreg = CRegString(_T("Software\\TortoiseSVN\\DiffTools\\.doc"));\r
+               CRegString diffreg = CRegString(_T("Software\\TortoiseGit\\DiffTools\\.doc"));\r
                CString sDiff = diffreg;\r
                CString sCL = _T("wscript.exe \"") + CPathUtils::GetAppParentDirectory()+_T("Diff-Scripts\\diff-doc.vbs\"");\r
                if (sDiff.Left(sCL.GetLength()).CompareNoCase(sCL)==0)\r
                        diffreg = _T("");\r
-               CRegString mergereg = CRegString(_T("Software\\TortoiseSVN\\MergeTools\\.doc"));\r
+               CRegString mergereg = CRegString(_T("Software\\TortoiseGit\\MergeTools\\.doc"));\r
                sDiff = mergereg;\r
                sCL = _T("wscript.exe \"") + CPathUtils::GetAppParentDirectory()+_T("Diff-Scripts\\merge-doc.vbs\"");\r
                if (sDiff.Left(sCL.GetLength()).CompareNoCase(sCL)==0)\r
@@ -480,7 +533,7 @@ void CTortoiseProcApp::CheckUpgrade()
        }\r
        if (lVersion <= 0x01040000)\r
        {\r
-               CRegStdWORD(_T("Software\\TortoiseSVN\\OwnerdrawnMenus")).removeValue();\r
+               CRegStdWORD(_T("Software\\TortoiseGit\\OwnerdrawnMenus")).removeValue();\r
        }\r
        \r
        // set the custom diff scripts for every user\r
@@ -505,26 +558,26 @@ void CTortoiseProcApp::CheckUpgrade()
                \r
                if (filename.Left(5).CompareNoCase(_T("diff-"))==0)\r
                {\r
-                       CRegString diffreg = CRegString(_T("Software\\TortoiseSVN\\DiffTools\\")+ext);\r
+                       CRegString diffreg = CRegString(_T("Software\\TortoiseGit\\DiffTools\\")+ext);\r
                        CString diffregstring = diffreg;\r
                        if ((diffregstring.IsEmpty()) || (diffregstring.Find(filename)>=0))\r
                                diffreg = _T("wscript.exe \"") + file + _T("\" %base %mine") + kind;\r
                }\r
                if (filename.Left(6).CompareNoCase(_T("merge-"))==0)\r
                {\r
-                       CRegString diffreg = CRegString(_T("Software\\TortoiseSVN\\MergeTools\\")+ext);\r
+                       CRegString diffreg = CRegString(_T("Software\\TortoiseGit\\MergeTools\\")+ext);\r
                        CString diffregstring = diffreg;\r
                        if ((diffregstring.IsEmpty()) || (diffregstring.Find(filename)>=0))\r
                                diffreg = _T("wscript.exe \"") + file + _T("\" %merged %theirs %mine %base") + kind;\r
                }\r
        }\r
 \r
-       // Initialize "Software\\TortoiseSVN\\DiffProps" once with the same value as "Software\\TortoiseSVN\\Diff"\r
-       CRegString regDiffPropsPath = CRegString(_T("Software\\TortoiseSVN\\DiffProps"),_T("non-existant"));\r
+       // Initialize "Software\\TortoiseGit\\DiffProps" once with the same value as "Software\\TortoiseGit\\Diff"\r
+       CRegString regDiffPropsPath = CRegString(_T("Software\\TortoiseGit\\DiffProps"),_T("non-existant"));\r
        CString strDiffPropsPath = regDiffPropsPath;\r
        if ( strDiffPropsPath==_T("non-existant") )\r
        {\r
-               CString strDiffPath = CRegString(_T("Software\\TortoiseSVN\\Diff"));\r
+               CString strDiffPath = CRegString(_T("Software\\TortoiseGit\\Diff"));\r
                regDiffPropsPath = strDiffPath;\r
        }\r
 \r
@@ -567,6 +620,8 @@ void CTortoiseProcApp::EnableCrashHandler()
 \r
 int CTortoiseProcApp::ExitInstance()\r
 {\r
+       Gdiplus::GdiplusShutdown(m_gdiplusToken);\r
+\r
        CWinAppEx::ExitInstance();\r
        if (retSuccess)\r
                return 0;\r