OSDN Git Service

updated wingit and fixed bug in new PATH init code (used wrong function for tchar...
authorMyagi <snowcoder@gmail.com>
Tue, 27 Jan 2009 05:18:25 +0000 (06:18 +0100)
committerFrank Li <lznuaa@gmail.com>
Wed, 28 Jan 2009 03:14:43 +0000 (11:14 +0800)
ext/wingit/wingit.dll
src/Git/Git.cpp
src/TortoiseShell/ContextMenu.cpp

index 81681c6..1617b05 100644 (file)
Binary files a/ext/wingit/wingit.dll and b/ext/wingit/wingit.dll differ
index f9b5278..6d84e6f 100644 (file)
@@ -73,27 +73,24 @@ static BOOL FindGitPath()
                return FALSE;\r
        }\r
 \r
-       TCHAR *env = (TCHAR*)alloca(size);\r
+       TCHAR *env = (TCHAR*)alloca(size * sizeof(TCHAR));\r
        _tgetenv_s(&size, env, size, _T("PATH"));\r
 \r
        TCHAR buf[_MAX_PATH];\r
 \r
-       const LPCTSTR filename = _T("git.exe");\r
-       const int filelen = _tcslen(filename);\r
-\r
        // search in all paths defined in PATH\r
        while ((env = nextpath(env, buf, _MAX_PATH-1)) && *buf)\r
        {\r
                TCHAR *pfin = buf + _tcslen(buf)-1;\r
 \r
                // ensure trailing slash\r
-               if (*pfin != '/' && *pfin != '\\')\r
-                       _tccpy(pfin+1, _T("\\"));\r
+               if (*pfin != _T('/') && *pfin != _T('\\'))\r
+                       _tcscpy(++pfin, _T("\\"));\r
 \r
                const int len = _tcslen(buf);\r
 \r
-               if ((len + filelen) < _MAX_PATH)\r
-                       _tccpy(buf+len, filename);\r
+               if ((len + 7) < _MAX_PATH)\r
+                       _tcscpy(pfin+1, _T("git.exe"));\r
                else\r
                        break;\r
 \r
@@ -652,15 +649,16 @@ BOOL CGit::CheckMsysGitDir()
        {\r
                CRegString msysinstalldir=CRegString(REG_MSYSGIT_INSTALL,_T(""),FALSE,HKEY_LOCAL_MACHINE);\r
                str=msysinstalldir;\r
-        // check it has a trailing blank\r
-        if (str.Right(1) != _T("\\"))\r
-        {\r
-            str += _T("\\");\r
-        }\r
-               str+=_T("bin");\r
-               msysdir=str;\r
-               msysdir.write();\r
-\r
+               if ( !str.IsEmpty() )\r
+               {\r
+                       str += (str[str.GetLength()-1] != '\\') ? "\\bin" : "bin";\r
+                       msysdir=str;\r
+                       msysdir.write();\r
+               }\r
+               else\r
+               {\r
+                       return false;\r
+               }\r
        }\r
        //CGit::m_MsysGitPath=str;\r
 \r
@@ -669,29 +667,10 @@ BOOL CGit::CheckMsysGitDir()
        _tdupenv_s(&oldpath,&size,_T("PATH")); \r
 \r
        CString path;\r
-       CString unterminated_path = str;        // path to msysgit without semicolon\r
-       CString oldpath_s = oldpath;\r
-       path.Format(_T("%s;"),str);\r
-       // check msysgit not already in path\r
-       if ( oldpath_s.Find( path ) < 0  &&  oldpath_s.Right( unterminated_path.GetLength() ) != unterminated_path )\r
-       {\r
-               // not already there, see if we have to take out one we added last time\r
-               if ( ms_LastMsysGitDir != _T("") )\r
-               {\r
-                       // we have added one so take it out\r
-                       int index = oldpath_s.Find( ms_LastMsysGitDir );\r
-                       if ( index >= 0 )\r
-                       {\r
-                               oldpath_s = oldpath_s.Left( index ) + \r
-                                       oldpath_s.Right( oldpath_s.GetLength() - (index+ms_LastMsysGitDir.GetLength()) );\r
-                       }\r
-               }\r
-               // save the new msysdir path that we are about to add\r
-               ms_LastMsysGitDir = path;\r
-               // add the new one on the front of the existing path\r
-               path+=oldpath_s;\r
-               _tputenv_s(_T("PATH"),path);\r
-       }\r
+       path.Format(_T("%s;%s"),oldpath,str);\r
+\r
+       _tputenv_s(_T("PATH"),path);\r
+\r
        free(oldpath);\r
 \r
        if( !FindGitPath() )\r
index ead4a78..c85e65c 100644 (file)
@@ -468,13 +468,14 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                        }\r
                                } // for (int i = 0; i < count; ++i)\r
                                ItemIDList child (GetPIDLItem (cida, 0), &parent);\r
-//                             if (g_ShellCache.HasGitAdminDir(child.toString().c_str(), FALSE))\r
+// ? was this disabled because the /wc option does not work safely with Git? or because the code below didn't compile before?\r
+//                             if (g_ShellCache.HasSVNAdminDir(child.toString().c_str(), FALSE))\r
 //                                     itemStates |= ITEMIS_INVERSIONEDFOLDER;\r
                                GlobalUnlock(medium.hGlobal);\r
 \r
                                // if the item is a versioned folder, check if there's a patch file\r
                                // in the clipboard to be used in "Apply Patch"\r
-                               UINT cFormatDiff = RegisterClipboardFormat(_T("Tgit_UNIFIEDDIFF"));\r
+                               UINT cFormatDiff = RegisterClipboardFormat(_T("TGIT_UNIFIEDDIFF"));\r
                                if (cFormatDiff)\r
                                {\r
                                        if (IsClipboardFormatAvailable(cFormatDiff)) \r
@@ -775,7 +776,7 @@ bool CShellExt::WriteClipboardPathsToTempFile(stdstring& tempfile)
        TCHAR * path = new TCHAR[pathlength+1];\r
        TCHAR * tempFile = new TCHAR[pathlength + 100];\r
        GetTempPath (pathlength+1, path);\r
-       GetTempFileName (path, _T("svn"), 0, tempFile);\r
+       GetTempFileName (path, _T("git"), 0, tempFile);\r
        tempfile = stdstring(tempFile);\r
 \r
        HANDLE file = ::CreateFile (tempFile,\r
@@ -829,7 +830,7 @@ stdstring CShellExt::WriteFileListToTempFile()
        TCHAR * path = new TCHAR[pathlength+1];\r
        TCHAR * tempFile = new TCHAR[pathlength + 100];\r
        GetTempPath (pathlength+1, path);\r
-       GetTempFileName (path, _T("svn"), 0, tempFile);\r
+       GetTempFileName (path, _T("git"), 0, tempFile);\r
        stdstring retFilePath = stdstring(tempFile);\r
        \r
        HANDLE file = ::CreateFile (tempFile,\r
@@ -1631,7 +1632,7 @@ STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
                                {\r
                                        // if there's a patch file in the clipboard, we save it\r
                                        // to a temporary file and tell TortoiseMerge to use that one\r
-                                       UINT cFormat = RegisterClipboardFormat(_T("Tgit_UNIFIEDDIFF"));\r
+                                       UINT cFormat = RegisterClipboardFormat(_T("TGIT_UNIFIEDDIFF"));\r
                                        if ((cFormat)&&(OpenClipboard(NULL)))\r
                                        { \r
                                                HGLOBAL hglb = GetClipboardData(cFormat); \r
@@ -1641,7 +1642,7 @@ STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
                                                TCHAR * path = new TCHAR[len+1];\r
                                                TCHAR * tempF = new TCHAR[len+100];\r
                                                GetTempPath (len+1, path);\r
-                                               GetTempFileName (path, TEXT("svn"), 0, tempF);\r
+                                               GetTempFileName (path, TEXT("git"), 0, tempF);\r
                                                std::wstring sTempFile = std::wstring(tempF);\r
                                                delete [] path;\r
                                                delete [] tempF;\r