Use static method
[TortoiseGit.git] / src / TortoiseProc / Commands / CatCommand.cpp
blob91e6b8fa84d0612ce434d2d7f3800047677cdb78
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 #include "CatCommand.h"
22 #include "PathUtils.h"
23 #include "Git.h"
24 #include "MessageBox.h"
26 bool CatCommand::Execute()
29 CString savepath = CPathUtils::GetLongPathname(parser.GetVal(_T("savepath")));
30 CString revision = parser.GetVal(_T("revision"));
31 CString pegrevision = parser.GetVal(_T("pegrevision"));
33 CString cmd, output, err;
34 cmd.Format(_T("git.exe cat-file -t %s"),revision);
36 if (g_Git.Run(cmd, &output, &err, CP_UTF8))
38 ::DeleteFile(savepath);
39 CMessageBox::Show(NULL, output + L"\n" + err, _T("TortoiseGit"), MB_ICONERROR);
40 return false;
43 if(output.Find(_T("blob")) == 0)
45 cmd.Format(_T("git.exe cat-file -p %s"),revision);
47 else
49 cmd.Format(_T("git.exe show %s -- \"%s\""),revision,this->cmdLinePath);
52 if(g_Git.RunLogFile(cmd,savepath))
54 ::DeleteFile(savepath);
55 CMessageBox::Show(NULL,_T("Cat file fail"),_T("TortoiseGit"), MB_ICONERROR);
56 return false;
58 return true;