OSDN Git Service

Fixed issue #133: (mv\rename problem) Command fails on folder with leading dash
[tortoisegit/TortoiseGitJp.git] / src / Git / Git.cpp
index 864684b..0d00b9a 100644 (file)
@@ -655,6 +655,30 @@ git_revnum_t CGit::GetHash(const CString &friendname)
        return out;\r
 }\r
 \r
+int CGit::GetCommitDiffList(CString &rev1,CString &rev2,CTGitPathList &outputlist)\r
+{\r
+       CString cmd;\r
+       \r
+       if(rev1 == GIT_REV_ZERO || rev2 == GIT_REV_ZERO)\r
+       {\r
+               //rev1=+_T("");\r
+               if(rev1 == GIT_REV_ZERO)\r
+                       cmd.Format(_T("git.exe diff -r --raw -C -M --numstat -z %s"),rev2);\r
+               else\r
+                       cmd.Format(_T("git.exe diff -r -R --raw -C -M --numstat -z %s"),rev1);\r
+       }else\r
+       {\r
+               cmd.Format(_T("git.exe diff-tree -r --raw -C -M --numstat -z %s %s"),rev2,rev1);\r
+       }\r
+\r
+       BYTE_VECTOR out;\r
+       if(g_Git.Run(cmd,&out))\r
+               return -1;\r
+\r
+       outputlist.ParserFromLog(out);\r
+\r
+}\r
+\r
 int CGit::GetTagList(STRING_VECTOR &list)\r
 {\r
        int ret;\r
@@ -1063,10 +1087,27 @@ BOOL CGit::EnumFiles(const TCHAR *pszProjectPath, const TCHAR *pszSubPath, unsig
                sMode = _T("-");\r
        }\r
 \r
+       // NOTE: there seems to be some issue with msys based app receiving backslash on commandline, at least\r
+       // if followed by " like for example 'igit "C:\"', the commandline igit receives is 'igit.exe C:" status' with\r
+       // the 'C:" status' part as a single arg, Maybe it uses unix style processing. In order to avoid this just\r
+       // use forward slashes for supplied project and sub paths\r
+\r
+       CString sProjectPath = pszProjectPath;\r
+       sProjectPath.Replace(_T('\\'), _T('/'));\r
+\r
        if (pszSubPath)\r
-               cmd.Format(_T("igit.exe \"%s\" status %s \"%s\""), pszProjectPath, sMode, pszSubPath);\r
+       {\r
+               CString sSubPath = pszSubPath;\r
+               sSubPath.Replace(_T('\\'), _T('/'));\r
+\r
+               cmd.Format(_T("igit.exe \"%s\" status %s \"%s\""), sProjectPath, sMode, sSubPath);\r
+       }\r
        else\r
-               cmd.Format(_T("igit.exe \"%s\" status %s"), pszProjectPath, sMode);\r
+       {\r
+               cmd.Format(_T("igit.exe \"%s\" status %s"), sProjectPath, sMode);\r
+       }\r
+\r
+       //OutputDebugStringA("---");OutputDebugStringW(cmd);OutputDebugStringA("\r\n");\r
 \r
        W_GitCall.SetCmd(cmd);\r
        // NOTE: should igit get added as a part of msysgit then use below line instead of the above one\r
@@ -1117,14 +1158,14 @@ int CGit::Revert(CTGitPath &path,bool keep)
        CString cmd, out;\r
        if(path.m_Action & CTGitPath::LOGACTIONS_ADDED)\r
        {       //To init git repository, there are not HEAD, so we can use git reset command\r
-               cmd.Format(_T("git.exe rm --cached \"%s\""),path.GetGitPathString());\r
+               cmd.Format(_T("git.exe rm --cached -- \"%s\""),path.GetGitPathString());\r
 \r
                if(g_Git.Run(cmd,&out,CP_ACP))\r
                        return -1;\r
        }\r
        else if(path.m_Action & CTGitPath::LOGACTIONS_REPLACED )\r
        {\r
-               cmd.Format(_T("git.exe mv \"%s\" \"%s\""),path.GetGitPathString(),path.GetGitOldPathString());\r
+               cmd.Format(_T("git.exe mv -- \"%s\" \"%s\""),path.GetGitPathString(),path.GetGitOldPathString());\r
                if(g_Git.Run(cmd,&out,CP_ACP))\r
                        return -1;\r
                \r