OSDN Git Service

Fix Issue 22 Error deleting file from context menu if filename contains spaces
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / Commands / RemoveCommand.cpp
index 6cc97c6..e618c9c 100644 (file)
@@ -120,24 +120,32 @@ bool RemoveCommand::Execute()
        if(key == IDCANCEL)\r
                return FALSE;\r
 \r
-       CString cmd;\r
+       CString format;\r
        if(key == IDNO)\r
-               cmd=_T("git.exe rm -r -f ");\r
+               format=_T("git.exe rm -r -f \"%s\"");\r
 \r
        if(key == IDYES)\r
-               cmd= _T("git.exe update-index --force-remove -- ");\r
+               format= _T("git.exe update-index --force-remove -- \"%s\"");\r
 \r
-       for(int nPath = 0; nPath < pathList.GetCount(); nPath++)\r
+       CString output;\r
+       CString cmd;\r
+       int nPath;\r
+       for(nPath = 0; nPath < pathList.GetCount(); nPath++)\r
        {\r
-               CString output;\r
-               if(g_Git.Run(cmd+pathList[nPath].GetGitPathString(),&output,CP_OEMCP))\r
+\r
+               cmd.Format(format,pathList[nPath].GetGitPathString());\r
+               if(g_Git.Run(cmd,&output,CP_OEMCP))\r
                {\r
-                       key=CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_ICONINFORMATION|MB_OKCANCEL);\r
+                       key=CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_ICONERROR|MB_OKCANCEL);\r
                        if(key == IDCANCEL)\r
                                return FALSE;\r
 \r
                }\r
        }\r
 \r
+       output.Format(_T("%d files removed"),nPath);\r
+       \r
+       CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_ICONINFORMATION|MB_OK);\r
+\r
        return bRet;\r
 }\r