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.
21 #include "FormatPatchCommand.h"
23 #include "MessageBox.h"
24 #include "FormatPatchDlg.h"
26 #include "ShellUpdater.h"
27 #include "ProgressDlg.h"
30 bool FormatPatchCommand::Execute()
34 CString startval
= parser
.GetVal(_T("startrev"));
35 CString endval
= parser
.GetVal(_T("endrev"));
37 if( endval
.IsEmpty() && (!startval
.IsEmpty()))
40 dlg
.m_Radio
= IDC_RADIO_SINCE
;
43 else if( (!endval
.IsEmpty()) && (!startval
.IsEmpty()))
47 dlg
.m_Radio
= IDC_RADIO_RANGE
;
50 if(dlg
.DoModal()==IDOK
)
58 range
=g_Git
.FixBranchName(dlg
.m_Since
);
61 range
.Format(_T("-%d"),dlg
.m_Num
);
64 range
.Format(_T("%s..%s"),dlg
.m_From
,dlg
.m_To
);
67 dlg
.m_Dir
.Replace(_T('\\'),_T('/'));
68 cmd
.Format(_T("git.exe format-patch -o \"%s\" %s"),
73 CProgressDlg progress
;
74 progress
.m_GitCmd
=cmd
;
77 CShellUpdater::Instance().AddPathForUpdate(CTGitPath(dlg
.m_Dir
));
78 CShellUpdater::Instance().Flush();
80 if(!progress
.m_GitStatus
)
84 CAppUtils::SendPatchMail(cmd
, progress
.m_LogText
, true);
87 return !progress
.m_GitStatus
;