Refactor bisect operations into CAppUtils
[TortoiseGit.git] / src / TortoiseProc / Commands / BisectCommand.cpp
blob300b33a9c9704e34f3aa0d478692cb1c61261ab1
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013, 2015 - TortoiseGit
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 "BisectCommand.h"
21 #include "AppUtils.h"
22 #include "ProgressDlg.h"
23 #include "MessageBox.h"
24 #include "resource.h"
26 bool BisectCommand::Execute()
28 CTGitPath path = g_Git.m_CurrentDir;
30 if (this->parser.HasKey(_T("start")) && !path.IsBisectActive())
32 CString lastGood, firstBad;
33 if (parser.HasKey(_T("good")))
34 lastGood = parser.GetVal(_T("good"));
35 if (parser.HasKey(_T("bad")))
36 firstBad = parser.GetVal(_T("bad"));
38 return CAppUtils::BisectStart(lastGood, firstBad, true);
40 else if ((this->parser.HasKey(_T("good")) || this->parser.HasKey(_T("bad")) || this->parser.HasKey(_T("reset"))) && path.IsBisectActive())
42 CString op;
43 CString ref;
45 if (this->parser.HasKey(_T("good")))
46 op = _T("good");
47 else if (this->parser.HasKey(_T("bad")))
48 op = _T("bad");
49 else if (this->parser.HasKey(_T("reset")))
50 op = _T("reset");
52 if (this->parser.HasKey(_T("ref")) &&! this->parser.HasKey(_T("reset")))
53 ref = this->parser.GetVal(_T("ref"));
55 return CAppUtils::BisectOperation(op, ref);
57 else
59 CMessageBox::Show(NULL,_T("Operation unknown or not allowed."), _T("TortoiseGit"), MB_OK|MB_ICONINFORMATION);
61 return false;