Use processdlg to format patch.
[TortoiseGit.git] / src / TortoiseProc / Commands / PrevDiffCommand.cpp
blob4a35ea433410442e7e979d3587190f7335c49527
1 // TortoiseSVN - 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"
28 bool PrevDiffCommand::Execute()
30 bool bRet = false;
31 bool bAlternativeTool = !!parser.HasKey(_T("alternative"));
32 if (cmdLinePath.IsDirectory())
34 CChangedDlg dlg;
35 dlg.m_pathList = CTGitPathList(cmdLinePath);
36 dlg.DoModal();
37 bRet = true;
39 else
41 CGitDiff diff;
42 // diff.SetAlternativeTool(bAlternativeTool);
43 GitStatus st;
44 st.GetStatus(cmdLinePath);
46 if (1)
48 CString hash;
49 CString logout;
51 CLogDataVector revs;
53 revs.ParserShortLog(&cmdLinePath,hash,2);
54 if( revs.size() == 0)
56 CMessageBox::Show(hWndExplorer, IDS_ERR_NOPREVREVISION, IDS_APPNAME, MB_ICONERROR);
57 return FALSE;
60 if( revs.size() == 1 )
62 CGitDiff diff;
63 bRet = (diff.DiffNull(&cmdLinePath,revs[0].m_CommitHash) != 0);
66 if( revs.size() == 2 )
68 CGitDiff diff;
69 bRet = diff.Diff(&cmdLinePath,&cmdLinePath, revs[0].m_CommitHash, revs[1].m_CommitHash, false);
72 else
74 //if (st.GetLastErrorMsg().IsEmpty())
76 CMessageBox::Show(hWndExplorer, IDS_ERR_NOPREVREVISION, IDS_APPNAME, MB_ICONERROR);
78 //else
79 //{
80 // CMessageBox::Show(hWndExplorer, IDS_ERR_NOSTATUS, IDS_APPNAME, MB_ICONERROR);
81 //s}
84 return bRet;