1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009, 2015-2016, 2018 - 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 "FormatPatchDlg.h"
25 #include "ShellUpdater.h"
26 #include "ProgressDlg.h"
29 bool FormatPatchCommand::Execute()
33 CString startval
= parser
.GetVal(L
"startrev");
34 CString endval
= parser
.GetVal(L
"endrev");
36 if( endval
.IsEmpty() && (!startval
.IsEmpty()))
39 dlg
.m_Radio
= IDC_RADIO_SINCE
;
41 else if( (!endval
.IsEmpty()) && (!startval
.IsEmpty()))
45 dlg
.m_Radio
= IDC_RADIO_RANGE
;
48 if(dlg
.DoModal()==IDOK
)
56 range
=g_Git
.FixBranchName(dlg
.m_Since
);
59 range
.Format(L
"-%d", dlg
.m_Num
);
62 range
.Format(L
"%s..%s", (LPCTSTR
)dlg
.m_From
, (LPCTSTR
)dlg
.m_To
);
65 dlg
.m_Dir
.Replace(L
'\\', L
'/');
66 cmd
.Format(L
"git.exe format-patch%s -o \"%s\" %s",
67 dlg
.m_bNoPrefix
? L
" --no-prefix" : L
"",
72 CProgressDlg progress
;
73 progress
.m_GitCmd
=cmd
;
76 CShellUpdater::Instance().AddPathForUpdate(CTGitPath(dlg
.m_Dir
));
77 CShellUpdater::Instance().Flush();
79 if(!progress
.m_GitStatus
)
82 CAppUtils::SendPatchMail(hwndExplorer
, cmd
, progress
.m_LogText
, true);
84 return !progress
.m_GitStatus
;