SyncDlg: Make check if local branch fast-fowards to remote branch work again
[TortoiseGit.git] / src / TortoiseProc / Commands / BisectCommand.cpp
blob12bda5372cdb5ee5df37b26672b82ff05af05836
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - 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 bool autoClose = false;
33 if (parser.HasVal(_T("closeonend")))
34 autoClose = !!parser.GetLongVal(_T("closeonend"));
36 CString lastGood, firstBad;
37 if (parser.HasKey(_T("good")))
38 lastGood = parser.GetVal(_T("good"));
39 if (parser.HasKey(_T("bad")))
40 firstBad = parser.GetVal(_T("bad"));
42 return CAppUtils::BisectStart(lastGood, firstBad, autoClose);
44 else if ((this->parser.HasKey(_T("good")) || this->parser.HasKey(_T("bad")) || this->parser.HasKey(_T("reset"))) && path.IsBisectActive())
46 CString cmd = _T("git.exe bisect ");
48 if (this->parser.HasKey(_T("good")))
49 cmd += _T("good");
50 else if (this->parser.HasKey(_T("bad")))
51 cmd += _T("bad");
52 else if (this->parser.HasKey(_T("reset")))
53 cmd += _T("reset");
55 if (this->parser.HasKey(_T("ref")) &&! this->parser.HasKey(_T("reset")))
57 cmd += _T(" ");
58 cmd += this->parser.GetVal(_T("ref"));
61 CProgressDlg progress;
62 theApp.m_pMainWnd = &progress;
63 if (parser.HasVal(_T("closeonend")))
64 progress.m_bAutoCloseOnSuccess = !!parser.GetLongVal(_T("closeonend"));
65 progress.m_GitCmd = cmd;
67 if (path.HasSubmodules())
68 progress.m_PostCmdList.Add(CString(MAKEINTRESOURCE(IDS_PROC_SUBMODULESUPDATE)));
70 int reset = -1;
71 if (!this->parser.HasKey(_T("reset")))
72 reset = (int)progress.m_PostCmdList.Add(_T("Bisect reset"));
74 INT_PTR ret = progress.DoModal();
75 if (path.HasSubmodules() && ret == IDC_PROGRESS_BUTTON1)
77 CString sCmd;
78 sCmd.Format(_T("/command:subupdate /bkpath:\"%s\""), g_Git.m_CurrentDir);
80 CAppUtils::RunTortoiseProc(sCmd);
81 return true;
83 else if (reset >= 0 && ret == IDC_PROGRESS_BUTTON1 + reset)
85 CAppUtils::RunTortoiseProc(_T("/command:bisect /reset"));
86 return true;
88 else if (ret == IDOK)
89 return true;
91 else
93 CMessageBox::Show(NULL,_T("Operation unknown or not allowed."), _T("TortoiseGit"), MB_OK|MB_ICONINFORMATION);
95 return false;