SyncDlg: Make check if local branch fast-fowards to remote branch work again
[TortoiseGit.git] / src / TortoiseProc / Commands / CatCommand.cpp
blob7091d1fd6f4d79d3d7497c73a3908c70f22a750f
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 CMessageBox::Show(NULL, output + L"\n" + err, _T("TortoiseGit"), MB_ICONERROR);
39 return false;
42 if(output.Find(_T("blob")) == 0)
44 cmd.Format(_T("git.exe cat-file -p %s"),revision);
46 else
48 cmd.Format(_T("git.exe show %s -- \"%s\""),revision,this->cmdLinePath);
51 if(g_Git.RunLogFile(cmd,savepath))
53 CMessageBox::Show(NULL,_T("Cat file fail"),_T("TortoiseGit"), MB_ICONERROR);
54 return false;
56 return true;