libgit2: Enable fetch function
[TortoiseGit.git] / src / TortoiseProc / Commands / PrevDiffCommand.cpp
blobf23d7828c9cb6ddf4155d7c4616f6c4f1a1bd724
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
4 // Copyright (C) 2007-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "PrevDiffCommand.h"
22 #include "GitDiff.h"
23 #include "GitStatus.h"
24 #include "MessageBox.h"
25 #include "ChangedDlg.h"
26 #include "LogDlgHelper.h"
27 #include "FileDiffDlg.h"
29 bool PrevDiffCommand::Execute()
31 bool bRet = false;
32 //bool bAlternativeTool = !!parser.HasKey(_T("alternative"));
33 if (this->orgCmdLinePath.IsDirectory())
35 CFileDiffDlg dlg;
37 dlg.m_strRev1 = GIT_REV_ZERO;
38 dlg.m_strRev2 = _T("HEAD~1");
39 dlg.m_sFilter = this->cmdLinePath.GetGitPathString();
41 //dlg.m_pathList = CTGitPathList(cmdLinePath);
42 dlg.DoModal();
43 bRet = true;
45 else
47 CGitDiff diff;
48 // diff.SetAlternativeTool(bAlternativeTool);
49 GitStatus st;
50 st.GetStatus(cmdLinePath);
52 if (1)
54 CString hash;
55 CString logout;
57 CLogDataVector revs;
58 CLogCache cache;
59 revs.m_pLogCache=&cache;
61 revs.ParserFromLog(&cmdLinePath,2,CGit::LOG_INFO_ONLY_HASH);
63 if( revs.size() != 2)
65 CMessageBox::Show(hWndExplorer, IDS_ERR_NOPREVREVISION, IDS_APPNAME, MB_ICONERROR);
66 bRet = false;
68 else
70 CGitDiff diff;
71 bRet = !!diff.Diff(&cmdLinePath,&cmdLinePath, GIT_REV_ZERO, revs.GetGitRevAt(1).m_CommitHash.ToString());
74 else
76 //if (st.GetLastErrorMsg().IsEmpty())
78 CMessageBox::Show(hWndExplorer, IDS_ERR_NOPREVREVISION, IDS_APPNAME, MB_ICONERROR);
80 //else
81 //{
82 // CMessageBox::Show(hWndExplorer, IDS_ERR_NOSTATUS, IDS_APPNAME, MB_ICONERROR);
83 //s}
86 return bRet;