OSDN Git Service

Add Cat Command to implement tortoise merge view patch
authorFrank Li <lznuaa@gmail.com>
Thu, 23 Apr 2009 03:16:25 +0000 (11:16 +0800)
committerFrank Li <lznuaa@gmail.com>
Thu, 23 Apr 2009 03:16:25 +0000 (11:16 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseProc/Commands/CatCommand.cpp
src/TortoiseProc/Commands/Command.cpp

index 5c3be77..938c0fb 100644 (file)
 \r
 #include "PathUtils.h"\r
 #include "Git.h"\r
+#include "MessageBox.h"\r
 \r
 bool CatCommand::Execute()\r
 {\r
-#if 0\r
+\r
        CString savepath = CPathUtils::GetLongPathname(parser.GetVal(_T("savepath")));\r
        CString revision = parser.GetVal(_T("revision"));\r
        CString pegrevision = parser.GetVal(_T("pegrevision"));\r
-       SVNRev rev = SVNRev(revision);\r
-       if (!rev.IsValid())\r
-               rev = SVNRev::REV_HEAD;\r
-       SVNRev pegrev = SVNRev(pegrevision);\r
-       if (!pegrev.IsValid())\r
-               pegrev = SVNRev::REV_HEAD;\r
-       SVN svn;\r
-       if (!svn.Cat(cmdLinePath, pegrev, rev, CTSVNPath(savepath)))\r
+\r
+       CString cmd,output;\r
+       cmd.Format(_T("git.exe cat-file -t %s"),revision);\r
+\r
+       if( g_Git.Run(cmd,&output,CP_ACP) )\r
+       {\r
+               CMessageBox::Show(NULL, output, _T("TortoiseGit"), MB_ICONERROR);\r
+               return false;\r
+       }\r
+       \r
+       if(output.Find(_T("blob")) == 0)\r
+       {\r
+               cmd.Format(_T("git.exe cat-file -p %s"),revision);\r
+       }\r
+       else\r
+       {\r
+               cmd.Format(_T("git.exe show %s -- \"%s\""),revision,this->cmdLinePath);\r
+       }\r
+\r
+       if(g_Git.RunLogFile(cmd,savepath))\r
        {\r
-               ::MessageBox(NULL, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR);\r
-               ::DeleteFile(savepath);\r
+               CMessageBox::Show(NULL,_T("Cat file fail"),_T("TortoiseGit"), MB_ICONERROR);\r
                return false;\r
        }\r
-#endif\r
        return true;\r
 }\r
index 887147c..acaa4fe 100644 (file)
 #include "SubmoduleCommand.h"\r
 #include "ReflogCommand.h"\r
 #include "SendMailCommand.h"\r
+#include "CatCommand.h"\r
 \r
 #if 0\r
 \r
 \r
-#include "CatCommand.h"\r
+\r
 #include "CheckoutCommand.h"\r
 \r
 \r
@@ -356,11 +357,11 @@ Command * CommandServer::GetCommand(const CString& sCmd)
                return new SubmoduleSyncCommand;\r
        case cmdSendMail:\r
                return new SendMailCommand;\r
-\r
-#if 0\r
-\r
        case cmdCat:\r
                return new CatCommand;\r
+#if 0\r
+\r
+       \r
        case cmdCheckout:\r
                return new CheckoutCommand;\r
 \r