From 50fc1d14245b3c6729a7dfe7f52d877d0f6647dd Mon Sep 17 00:00:00 2001 From: Frank Li Date: Thu, 23 Apr 2009 11:16:25 +0800 Subject: [PATCH] Add Cat Command to implement tortoise merge view patch Signed-off-by: Frank Li --- src/TortoiseProc/Commands/CatCommand.cpp | 35 +++++++++++++++++++++----------- src/TortoiseProc/Commands/Command.cpp | 9 ++++---- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/TortoiseProc/Commands/CatCommand.cpp b/src/TortoiseProc/Commands/CatCommand.cpp index 5c3be7728..938c0fbfd 100644 --- a/src/TortoiseProc/Commands/CatCommand.cpp +++ b/src/TortoiseProc/Commands/CatCommand.cpp @@ -21,26 +21,37 @@ #include "PathUtils.h" #include "Git.h" +#include "MessageBox.h" bool CatCommand::Execute() { -#if 0 + CString savepath = CPathUtils::GetLongPathname(parser.GetVal(_T("savepath"))); CString revision = parser.GetVal(_T("revision")); CString pegrevision = parser.GetVal(_T("pegrevision")); - SVNRev rev = SVNRev(revision); - if (!rev.IsValid()) - rev = SVNRev::REV_HEAD; - SVNRev pegrev = SVNRev(pegrevision); - if (!pegrev.IsValid()) - pegrev = SVNRev::REV_HEAD; - SVN svn; - if (!svn.Cat(cmdLinePath, pegrev, rev, CTSVNPath(savepath))) + + CString cmd,output; + cmd.Format(_T("git.exe cat-file -t %s"),revision); + + if( g_Git.Run(cmd,&output,CP_ACP) ) + { + CMessageBox::Show(NULL, output, _T("TortoiseGit"), MB_ICONERROR); + return false; + } + + if(output.Find(_T("blob")) == 0) + { + cmd.Format(_T("git.exe cat-file -p %s"),revision); + } + else + { + cmd.Format(_T("git.exe show %s -- \"%s\""),revision,this->cmdLinePath); + } + + if(g_Git.RunLogFile(cmd,savepath)) { - ::MessageBox(NULL, svn.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); - ::DeleteFile(savepath); + CMessageBox::Show(NULL,_T("Cat file fail"),_T("TortoiseGit"), MB_ICONERROR); return false; } -#endif return true; } diff --git a/src/TortoiseProc/Commands/Command.cpp b/src/TortoiseProc/Commands/Command.cpp index 887147cd7..acaa4fed5 100644 --- a/src/TortoiseProc/Commands/Command.cpp +++ b/src/TortoiseProc/Commands/Command.cpp @@ -60,11 +60,12 @@ #include "SubmoduleCommand.h" #include "ReflogCommand.h" #include "SendMailCommand.h" +#include "CatCommand.h" #if 0 -#include "CatCommand.h" + #include "CheckoutCommand.h" @@ -356,11 +357,11 @@ Command * CommandServer::GetCommand(const CString& sCmd) return new SubmoduleSyncCommand; case cmdSendMail: return new SendMailCommand; - -#if 0 - case cmdCat: return new CatCommand; +#if 0 + + case cmdCheckout: return new CheckoutCommand; -- 2.11.4.GIT