Includes cleanup
[TortoiseGit.git] / src / TortoiseProc / Commands / FormatPatchCommand.cpp
blob974c61de08fdf7c61a02a7c8caac1cc170dc5335
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009, 2015 - 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 "FormatPatchCommand.h"
23 #include "MessageBox.h"
24 #include "FormatPatchDlg.h"
25 #include "Git.h"
26 #include "ShellUpdater.h"
27 #include "ProgressDlg.h"
28 #include "AppUtils.h"
30 bool FormatPatchCommand::Execute()
32 CFormatPatchDlg dlg;
33 // dlg.m_bIsTag=TRUE;
34 CString startval = parser.GetVal(_T("startrev"));
35 CString endval = parser.GetVal(_T("endrev"));
37 if( endval.IsEmpty() && (!startval.IsEmpty()))
39 dlg.m_Since=startval;
40 dlg.m_Radio = IDC_RADIO_SINCE;
43 else if( (!endval.IsEmpty()) && (!startval.IsEmpty()))
45 dlg.m_From=startval;
46 dlg.m_To=endval;
47 dlg.m_Radio = IDC_RADIO_RANGE;
50 if(dlg.DoModal()==IDOK)
52 CString cmd;
53 CString range;
55 switch(dlg.m_Radio)
57 case IDC_RADIO_SINCE:
58 range=g_Git.FixBranchName(dlg.m_Since);
59 break;
60 case IDC_RADIO_NUM:
61 range.Format(_T("-%d"),dlg.m_Num);
62 break;
63 case IDC_RADIO_RANGE:
64 range.Format(_T("%s..%s"),dlg.m_From,dlg.m_To);
65 break;
67 dlg.m_Dir.Replace(_T('\\'),_T('/'));
68 cmd.Format(_T("git.exe format-patch -o \"%s\" %s"),
69 dlg.m_Dir,
70 range
73 CProgressDlg progress;
74 progress.m_GitCmd=cmd;
75 progress.DoModal();
77 CShellUpdater::Instance().AddPathForUpdate(CTGitPath(dlg.m_Dir));
78 CShellUpdater::Instance().Flush();
80 if(!progress.m_GitStatus)
82 if(dlg.m_bSendMail)
84 CAppUtils::SendPatchMail(cmd, progress.m_LogText, true);
87 return !progress.m_GitStatus;
89 return FALSE;