Smoothly migrate msysgit\cmd-paths to bin-paths on upgrade
authorSven Strickroth <email@cs-ware.de>
Sun, 24 Mar 2013 20:09:11 +0000 (24 21:09 +0100)
committerSven Strickroth <email@cs-ware.de>
Sun, 24 Mar 2013 20:17:49 +0000 (24 21:17 +0100)
Signed-off-by: Sven Strickroth <email@cs-ware.de>
src/TortoiseProc/TortoiseProc.cpp

index e87d4dd..cfc2843 100644 (file)
@@ -42,6 +42,7 @@
 #include "gitindex.h"\r
 #include "Libraries.h"\r
 #include "TaskbarUUID.h"\r
+#include "GitConfig.h"\r
 \r
 #define STRUCT_IOVEC_DEFINED\r
 \r
@@ -558,6 +559,21 @@ void CTortoiseProcApp::CheckUpgrade()
        {\r
                if (CRegStdDWORD(_T("Software\\TortoiseGit\\LogTopoOrder"), TRUE) == FALSE)\r
                        CRegStdDWORD(_T("Software\\TortoiseGit\\LogOrderBy")) = 0;\r
+\r
+               // smoothly migrate broken msysgit path settings\r
+               CString oldmsysGitSetting = CRegString(REG_MSYSGIT_PATH);\r
+               oldmsysGitSetting.TrimRight(_T("\\"));\r
+               CString right = oldmsysGitSetting.Right(4);\r
+               if (oldmsysGitSetting.GetLength() > 4 && oldmsysGitSetting.Right(4) == _T("\\cmd"))\r
+               {\r
+                       CString newPath = oldmsysGitSetting.Mid(0, oldmsysGitSetting.GetLength() - 3) + _T("bin");\r
+                       if (PathFileExists(newPath + _T("\\git.exe")))\r
+                       {\r
+                               CRegString(REG_MSYSGIT_PATH) = newPath;\r
+                               g_Git.m_bInitialized = FALSE;\r
+                               g_Git.CheckMsysGitDir();\r
+                       }\r
+               }\r
        }\r
 \r
        if (lVersion <= 0x01040000)\r