inherit filter from selected folder in explorer
[TortoiseGit.git] / src / TortoiseProc / Commands / PrevDiffCommand.cpp
blob295a136c22fa5a68bf851bdbb8847ef9ab48ab16
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 "PrevDiffCommand.h"
21 #include "GitDiff.h"
22 #include "GitStatus.h"
23 #include "MessageBox.h"
24 #include "ChangedDlg.h"
25 #include "LogDlgHelper.h"
26 #include "CommonResource.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;