1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-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.
20 // RebaseDlg.cpp : implementation file
24 #include "TortoiseProc.h"
25 #include "RebaseDlg.h"
27 #include "LoglistUtils.h"
28 #include "MessageBox.h"
29 #include "UnicodeUtils.h"
30 #include "BrowseRefsDlg.h"
31 #include "ProgressDlg.h"
32 #include "SmartHandle.h"
33 #include "../TGitCache/CacheInterface.h"
34 #include "Settings\Settings.h"
35 #include "MassiveGitTask.h"
36 #include "CommitDlg.h"
40 IMPLEMENT_DYNAMIC(CRebaseDlg
, CResizableStandAloneDialog
)
42 CRebaseDlg::CRebaseDlg(CWnd
* pParent
/*=NULL*/)
43 : CResizableStandAloneDialog(CRebaseDlg::IDD
, pParent
)
44 , m_bAddCherryPickedFrom(FALSE
)
45 , m_bStatusWarning(false)
46 , m_bAutoSkipFailedCommit(FALSE
)
47 , m_bFinishedRebase(false)
49 , m_bSplitCommit(FALSE
)
51 m_RebaseStage
=CHOOSE_BRANCH
;
52 m_CurrentRebaseIndex
=-1;
53 m_bThreadRunning
=FALSE
;
54 this->m_IsCherryPick
= FALSE
;
56 m_IsFastForward
=FALSE
;
59 CRebaseDlg::~CRebaseDlg()
63 void CRebaseDlg::DoDataExchange(CDataExchange
* pDX
)
65 CDialog::DoDataExchange(pDX
);
66 DDX_Control(pDX
, IDC_REBASE_PROGRESS
, m_ProgressBar
);
67 DDX_Control(pDX
, IDC_STATUS_STATIC
, m_CtrlStatusText
);
68 DDX_Control(pDX
, IDC_REBASE_SPLIT
, m_wndSplitter
);
69 DDX_Control(pDX
,IDC_COMMIT_LIST
,m_CommitList
);
70 DDX_Control(pDX
,IDC_REBASE_COMBOXEX_BRANCH
, this->m_BranchCtrl
);
71 DDX_Control(pDX
,IDC_REBASE_COMBOXEX_UPSTREAM
, this->m_UpstreamCtrl
);
72 DDX_Check(pDX
, IDC_REBASE_CHECK_FORCE
,m_bForce
);
73 DDX_Check(pDX
, IDC_CHECK_CHERRYPICKED_FROM
, m_bAddCherryPickedFrom
);
74 DDX_Control(pDX
,IDC_REBASE_POST_BUTTON
,m_PostButton
);
75 DDX_Control(pDX
, IDC_SPLITALLOPTIONS
, m_SplitAllOptions
);
76 DDX_Check(pDX
, IDC_REBASE_SPLIT_COMMIT
, m_bSplitCommit
);
80 BEGIN_MESSAGE_MAP(CRebaseDlg
, CResizableStandAloneDialog
)
81 ON_BN_CLICKED(IDC_REBASE_SPLIT
, &CRebaseDlg::OnBnClickedRebaseSplit
)
82 ON_BN_CLICKED(IDC_REBASE_CONTINUE
,OnBnClickedContinue
)
83 ON_BN_CLICKED(IDC_REBASE_ABORT
, OnBnClickedAbort
)
85 ON_CBN_SELCHANGE(IDC_REBASE_COMBOXEX_BRANCH
, &CRebaseDlg::OnCbnSelchangeBranch
)
86 ON_CBN_SELCHANGE(IDC_REBASE_COMBOXEX_UPSTREAM
, &CRebaseDlg::OnCbnSelchangeUpstream
)
87 ON_MESSAGE(MSG_REBASE_UPDATE_UI
, OnRebaseUpdateUI
)
88 ON_REGISTERED_MESSAGE(CGitStatusListCtrl::GITSLNM_NEEDSREFRESH
, OnGitStatusListCtrlNeedsRefresh
)
89 ON_BN_CLICKED(IDC_BUTTON_REVERSE
, OnBnClickedButtonReverse
)
90 ON_BN_CLICKED(IDC_BUTTON_BROWSE
, &CRebaseDlg::OnBnClickedButtonBrowse
)
91 ON_BN_CLICKED(IDC_REBASE_CHECK_FORCE
, &CRebaseDlg::OnBnClickedRebaseCheckForce
)
92 ON_BN_CLICKED(IDC_CHECK_CHERRYPICKED_FROM
, &CRebaseDlg::OnBnClickedCheckCherryPickedFrom
)
93 ON_BN_CLICKED(IDC_REBASE_POST_BUTTON
, &CRebaseDlg::OnBnClickedRebasePostButton
)
94 ON_BN_CLICKED(IDC_BUTTON_UP2
, &CRebaseDlg::OnBnClickedButtonUp2
)
95 ON_BN_CLICKED(IDC_BUTTON_DOWN2
, &CRebaseDlg::OnBnClickedButtonDown2
)
96 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED
, OnTaskbarBtnCreated
)
97 ON_NOTIFY(LVN_ITEMCHANGED
, IDC_COMMIT_LIST
, OnLvnItemchangedLoglist
)
98 ON_REGISTERED_MESSAGE(CGitLogListBase::m_RebaseActionMessage
, OnRebaseActionMessage
)
100 ON_BN_CLICKED(IDC_SPLITALLOPTIONS
, &CRebaseDlg::OnBnClickedSplitAllOptions
)
101 ON_BN_CLICKED(IDC_REBASE_SPLIT_COMMIT
, &CRebaseDlg::OnBnClickedRebaseSplitCommit
)
102 ON_BN_CLICKED(IDC_BUTTON_ONTO
, &CRebaseDlg::OnBnClickedButtonOnto
)
105 void CRebaseDlg::AddRebaseAnchor()
107 AddAnchor(IDC_REBASE_TAB
,TOP_LEFT
,BOTTOM_RIGHT
);
108 AddAnchor(IDC_COMMIT_LIST
,TOP_LEFT
, TOP_RIGHT
);
109 AddAnchor(IDC_REBASE_SPLIT
,TOP_LEFT
, TOP_RIGHT
);
110 AddAnchor(IDC_STATUS_STATIC
, BOTTOM_LEFT
,BOTTOM_RIGHT
);
111 AddAnchor(IDC_REBASE_CONTINUE
,BOTTOM_RIGHT
);
112 AddAnchor(IDC_REBASE_ABORT
, BOTTOM_RIGHT
);
113 AddAnchor(IDC_REBASE_PROGRESS
,BOTTOM_LEFT
, BOTTOM_RIGHT
);
114 AddAnchor(IDC_SPLITALLOPTIONS
, TOP_LEFT
);
115 AddAnchor(IDC_BUTTON_UP2
,TOP_LEFT
);
116 AddAnchor(IDC_BUTTON_DOWN2
,TOP_LEFT
);
117 AddAnchor(IDC_REBASE_COMBOXEX_UPSTREAM
,TOP_LEFT
);
118 AddAnchor(IDC_REBASE_COMBOXEX_BRANCH
,TOP_LEFT
);
119 AddAnchor(IDC_REBASE_STATIC_UPSTREAM
,TOP_LEFT
);
120 AddAnchor(IDC_REBASE_STATIC_BRANCH
,TOP_LEFT
);
121 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
122 AddAnchor(IDC_REBASE_CHECK_FORCE
,TOP_RIGHT
);
123 AddAnchor(IDC_CHECK_CHERRYPICKED_FROM
, TOP_RIGHT
);
124 AddAnchor(IDC_REBASE_SPLIT_COMMIT
, BOTTOM_RIGHT
);
125 AddAnchor(IDC_REBASE_POST_BUTTON
,BOTTOM_LEFT
);
127 this->AddOthersToAnchor();
130 BOOL
CRebaseDlg::OnInitDialog()
132 CResizableStandAloneDialog::OnInitDialog();
133 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
135 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
136 // do this, Explorer would be unable to send that message to our window if we
137 // were running elevated. It's OK to make the call all the time, since if we're
138 // not elevated, this is a no-op.
139 CHANGEFILTERSTRUCT cfs
= { sizeof(CHANGEFILTERSTRUCT
) };
140 typedef BOOL STDAPICALLTYPE
ChangeWindowMessageFilterExDFN(HWND hWnd
, UINT message
, DWORD action
, PCHANGEFILTERSTRUCT pChangeFilterStruct
);
141 CAutoLibrary hUser
= AtlLoadSystemLibraryUsingFullPath(_T("user32.dll"));
144 ChangeWindowMessageFilterExDFN
*pfnChangeWindowMessageFilterEx
= (ChangeWindowMessageFilterExDFN
*)GetProcAddress(hUser
, "ChangeWindowMessageFilterEx");
145 if (pfnChangeWindowMessageFilterEx
)
147 pfnChangeWindowMessageFilterEx(m_hWnd
, WM_TASKBARBTNCREATED
, MSGFLT_ALLOW
, &cfs
);
150 m_pTaskbarList
.Release();
151 if (FAILED(m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
)))
152 m_pTaskbarList
= nullptr;
155 //IDC_REBASE_DUMY_TAB
157 GetClientRect(m_DlgOrigRect
);
158 m_CommitList
.GetClientRect(m_CommitListOrigRect
);
160 CWnd
*pwnd
=this->GetDlgItem(IDC_REBASE_DUMY_TAB
);
161 pwnd
->GetWindowRect(&rectDummy
);
162 this->ScreenToClient(rectDummy
);
164 if (!m_ctrlTabCtrl
.Create(CMFCTabCtrl::STYLE_FLAT
, rectDummy
, this, IDC_REBASE_TAB
))
166 TRACE0("Failed to create output tab window\n");
167 return FALSE
; // fail to create
169 m_ctrlTabCtrl
.SetResizeMode(CMFCTabCtrl::RESIZE_NO
);
170 // Create output panes:
171 //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
172 DWORD dwStyle
=LVS_REPORT
| LVS_SHOWSELALWAYS
| LVS_ALIGNLEFT
| WS_BORDER
| WS_TABSTOP
| WS_CHILD
| WS_VISIBLE
;
174 if (! this->m_FileListCtrl
.Create(dwStyle
,rectDummy
,&this->m_ctrlTabCtrl
,0) )
176 TRACE0("Failed to create output windows\n");
177 return FALSE
; // fail to create
179 m_FileListCtrl
.m_hwndLogicalParent
= this;
181 if( ! this->m_LogMessageCtrl
.Create(_T("Scintilla"),_T("source"),0,rectDummy
,&m_ctrlTabCtrl
,0,0) )
183 TRACE0("Failed to create log message control");
186 m_ProjectProperties
.ReadProps();
187 m_LogMessageCtrl
.Init(m_ProjectProperties
);
188 m_LogMessageCtrl
.SetFont((CString
)CRegString(_T("Software\\TortoiseGit\\LogFontName"), _T("Courier New")), (DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\LogFontSize"), 8));
189 m_LogMessageCtrl
.Call(SCI_SETREADONLY
, TRUE
);
191 dwStyle
= LBS_NOINTEGRALHEIGHT
| WS_CHILD
| WS_VISIBLE
| WS_HSCROLL
| WS_VSCROLL
;
193 if (!m_wndOutputRebase
.Create(_T("Scintilla"),_T("source"),0,rectDummy
, &m_ctrlTabCtrl
, 0,0) )
195 TRACE0("Failed to create output windows\n");
196 return -1; // fail to create
198 m_wndOutputRebase
.Init(0, FALSE
);
199 m_wndOutputRebase
.Call(SCI_SETREADONLY
, TRUE
);
201 m_tooltips
.AddTool(IDC_REBASE_CHECK_FORCE
,IDS_REBASE_FORCE_TT
);
202 m_tooltips
.AddTool(IDC_REBASE_ABORT
, IDS_REBASE_ABORT_TT
);
206 temp
.LoadString(IDS_PROC_REBASE_SELECTALL_PICK
);
207 m_SplitAllOptions
.AddEntry(temp
);
208 temp
.LoadString(IDS_PROC_REBASE_SELECTALL_SQUASH
);
209 m_SplitAllOptions
.AddEntry(temp
);
210 temp
.LoadString(IDS_PROC_REBASE_SELECTALL_EDIT
);
211 m_SplitAllOptions
.AddEntry(temp
);
214 m_FileListCtrl
.Init(GITSLC_COLEXT
| GITSLC_COLSTATUS
|GITSLC_COLADD
|GITSLC_COLDEL
, _T("RebaseDlg"),(GITSLC_POPALL
^ (GITSLC_POPCOMMIT
|GITSLC_POPRESTORE
)), false, true, GITSLC_COLEXT
| GITSLC_COLSTATUS
| GITSLC_COLADD
| GITSLC_COLDEL
);
216 m_ctrlTabCtrl
.AddTab(&m_FileListCtrl
, CString(MAKEINTRESOURCE(IDS_PROC_REVISIONFILES
)));
217 m_ctrlTabCtrl
.AddTab(&m_LogMessageCtrl
, CString(MAKEINTRESOURCE(IDS_PROC_COMMITMESSAGE
)), 1);
220 AdjustControlSize(IDC_CHECK_CHERRYPICKED_FROM
);
221 AdjustControlSize(IDC_REBASE_SPLIT_COMMIT
);
223 CString sWindowTitle
;
224 GetWindowText(sWindowTitle
);
225 CAppUtils::SetWindowTitle(m_hWnd
, g_Git
.m_CurrentDir
, sWindowTitle
);
227 EnableSaveRestore(_T("RebaseDlg"));
229 DWORD yPos
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\RebaseDlgSizer"));
230 RECT rcDlg
, rcLogMsg
, rcFileList
;
231 GetClientRect(&rcDlg
);
232 m_CommitList
.GetWindowRect(&rcLogMsg
);
233 ScreenToClient(&rcLogMsg
);
234 this->m_ctrlTabCtrl
.GetWindowRect(&rcFileList
);
235 ScreenToClient(&rcFileList
);
239 m_wndSplitter
.GetWindowRect(&rectSplitter
);
240 ScreenToClient(&rectSplitter
);
241 int delta
= yPos
- rectSplitter
.top
;
242 if ((rcLogMsg
.bottom
+ delta
> rcLogMsg
.top
)&&(rcLogMsg
.bottom
+ delta
< rcFileList
.bottom
- 30))
244 m_wndSplitter
.SetWindowPos(NULL
, 0, yPos
, 0, 0, SWP_NOSIZE
);
249 if( this->m_RebaseStage
== CHOOSE_BRANCH
)
251 this->LoadBranchInfo();
256 this->m_BranchCtrl
.EnableWindow(FALSE
);
257 this->m_UpstreamCtrl
.EnableWindow(FALSE
);
258 GetDlgItem(IDC_BUTTON_REVERSE
)->EnableWindow(FALSE
);
261 m_CommitList
.m_ColumnRegKey
= _T("Rebase");
262 m_CommitList
.m_IsIDReplaceAction
= TRUE
;
263 // m_CommitList.m_IsOldFirst = TRUE;
264 m_CommitList
.m_IsRebaseReplaceGraph
= TRUE
;
265 m_CommitList
.m_bNoHightlightHead
= TRUE
;
267 m_CommitList
.InsertGitColumn();
269 this->SetControlEnable();
273 this->m_BranchCtrl
.SetCurSel(-1);
274 this->m_BranchCtrl
.EnableWindow(FALSE
);
275 GetDlgItem(IDC_REBASE_CHECK_FORCE
)->ShowWindow(SW_HIDE
);
276 GetDlgItem(IDC_BUTTON_BROWSE
)->EnableWindow(FALSE
);
277 GetDlgItem(IDC_BUTTON_REVERSE
)->EnableWindow(FALSE
);
278 GetDlgItem(IDC_BUTTON_ONTO
)->EnableWindow(FALSE
);
279 this->m_UpstreamCtrl
.AddString(_T("HEAD"));
280 this->m_UpstreamCtrl
.EnableWindow(FALSE
);
281 CAppUtils::SetWindowTitle(m_hWnd
, g_Git
.m_CurrentDir
, CString(MAKEINTRESOURCE(IDS_PROGS_TITLE_CHERRYPICK
)));
282 this->m_CommitList
.StartFilter();
286 ((CButton
*)GetDlgItem(IDC_BUTTON_ONTO
))->SetCheck(m_Onto
.IsEmpty() ? BST_UNCHECKED
: BST_CHECKED
);
287 GetDlgItem(IDC_CHECK_CHERRYPICKED_FROM
)->ShowWindow(SW_HIDE
);
288 ((CButton
*)GetDlgItem(IDC_BUTTON_REVERSE
))->SetIcon((HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_SWITCHLEFTRIGHT
), IMAGE_ICON
, 16, 16, LR_DEFAULTCOLOR
));
289 SetContinueButtonText();
290 m_CommitList
.DeleteAllItems();
294 m_CommitList
.m_ContextMenuMask
&= ~(m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_CHERRY_PICK
)|
295 m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_SWITCHTOREV
)|
296 m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_RESET
)|
297 m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_REVERTREV
)|
298 m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_MERGEREV
) |
299 m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_REBASE_TO_VERSION
)|
300 m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_REVERTTOREV
)|
301 m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_COMBINE_COMMIT
));
303 if(m_CommitList
.m_IsOldFirst
)
304 this->m_CurrentRebaseIndex
= -1;
306 this->m_CurrentRebaseIndex
= (int)m_CommitList
.m_logEntries
.size();
310 // CRebaseDlg message handlers
312 HBRUSH
CRebaseDlg::OnCtlColor(CDC
* pDC
, CWnd
* pWnd
, UINT nCtlColor
)
314 if (pWnd
->GetDlgCtrlID() == IDC_STATUS_STATIC
&& nCtlColor
== CTLCOLOR_STATIC
&& m_bStatusWarning
)
316 pDC
->SetBkColor(RGB(255, 0, 0));
317 pDC
->SetTextColor(RGB(255, 255, 255));
318 return CreateSolidBrush(RGB(255, 0, 0));
321 return CResizableStandAloneDialog::OnCtlColor(pDC
, pWnd
, nCtlColor
);
324 void CRebaseDlg::SetAllRebaseAction(int action
)
326 for (size_t i
= 0; i
< this->m_CommitList
.m_logEntries
.size(); ++i
)
328 m_CommitList
.m_logEntries
.GetGitRevAt(i
).GetRebaseAction() = action
;
330 m_CommitList
.Invalidate();
333 void CRebaseDlg::OnBnClickedRebaseSplit()
338 LRESULT
CRebaseDlg::DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
)
342 if (wParam
== IDC_REBASE_SPLIT
)
344 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
350 return __super::DefWindowProc(message
, wParam
, lParam
);
353 void CRebaseDlg::DoSize(int delta
)
355 this->RemoveAllAnchors();
357 CSplitterControl::ChangeHeight(GetDlgItem(IDC_COMMIT_LIST
), delta
, CW_TOPALIGN
);
358 //CSplitterControl::ChangeHeight(GetDlgItem(), delta, CW_TOPALIGN);
359 CSplitterControl::ChangeHeight(GetDlgItem(IDC_REBASE_TAB
), -delta
, CW_BOTTOMALIGN
);
360 //CSplitterControl::ChangeHeight(GetDlgItem(), -delta, CW_BOTTOMALIGN);
361 CSplitterControl::ChangePos(GetDlgItem(IDC_SPLITALLOPTIONS
), 0, delta
);
362 CSplitterControl::ChangePos(GetDlgItem(IDC_BUTTON_UP2
),0,delta
);
363 CSplitterControl::ChangePos(GetDlgItem(IDC_BUTTON_DOWN2
),0,delta
);
364 CSplitterControl::ChangePos(GetDlgItem(IDC_REBASE_CHECK_FORCE
),0,delta
);
365 CSplitterControl::ChangePos(GetDlgItem(IDC_CHECK_CHERRYPICKED_FROM
), 0, delta
);
367 this->AddRebaseAnchor();
368 // adjust the minimum size of the dialog to prevent the resizing from
369 // moving the list control too far down.
371 m_CommitList
.GetClientRect(rcLogMsg
);
372 SetMinTrackSize(CSize(m_DlgOrigRect
.Width(), m_DlgOrigRect
.Height()-m_CommitListOrigRect
.Height()+rcLogMsg
.Height()));
375 // m_CommitList.Invalidate();
377 // GetDlgItem(IDC_LOGMESSAGE)->Invalidate();
379 this->m_ctrlTabCtrl
.Invalidate();
380 this->m_CommitList
.Invalidate();
381 this->m_FileListCtrl
.Invalidate();
382 this->m_LogMessageCtrl
.Invalidate();
386 void CRebaseDlg::SetSplitterRange()
388 if ((m_CommitList
)&&(m_ctrlTabCtrl
))
391 m_CommitList
.GetWindowRect(rcTop
);
392 ScreenToClient(rcTop
);
394 m_ctrlTabCtrl
.GetWindowRect(rcMiddle
);
395 ScreenToClient(rcMiddle
);
396 if (rcMiddle
.Height() && rcMiddle
.Width())
397 m_wndSplitter
.SetRange(rcTop
.top
+60, rcMiddle
.bottom
-80);
401 void CRebaseDlg::OnSize(UINT nType
,int cx
, int cy
)
403 // first, let the resizing take place
404 __super::OnSize(nType
, cx
, cy
);
410 void CRebaseDlg::SaveSplitterPos()
414 CRegDWORD regPos
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\RebaseDlgSizer"));
416 m_wndSplitter
.GetWindowRect(&rectSplitter
);
417 ScreenToClient(&rectSplitter
);
418 regPos
= rectSplitter
.top
;
422 void CRebaseDlg::LoadBranchInfo()
424 m_BranchCtrl
.SetMaxHistoryItems(0x7FFFFFFF);
425 m_UpstreamCtrl
.SetMaxHistoryItems(0x7FFFFFFF);
430 g_Git
.GetBranchList(list
,¤t
,CGit::BRANCH_ALL
);
431 m_BranchCtrl
.SetList(list
);
433 m_BranchCtrl
.SetCurSel(current
);
435 m_BranchCtrl
.AddString(g_Git
.GetCurrentBranch(true));
437 g_Git
.GetBranchList(list
, NULL
, CGit::BRANCH_ALL_F
);
438 g_Git
.GetTagList(list
);
439 m_UpstreamCtrl
.SetList(list
);
441 AddBranchToolTips(&m_BranchCtrl
);
443 if(!m_Upstream
.IsEmpty())
445 m_UpstreamCtrl
.AddString(m_Upstream
);
449 //Select pull-remote from current branch
450 CString pullRemote
, pullBranch
;
451 g_Git
.GetRemoteTrackedBranchForHEAD(pullRemote
, pullBranch
);
453 CString defaultUpstream
;
454 defaultUpstream
.Format(L
"remotes/%s/%s", pullRemote
, pullBranch
);
455 int found
= m_UpstreamCtrl
.FindStringExact(0, defaultUpstream
);
457 m_UpstreamCtrl
.SetCurSel(found
);
459 m_UpstreamCtrl
.SetCurSel(-1);
461 AddBranchToolTips(&m_UpstreamCtrl
);
464 void CRebaseDlg::OnCbnSelchangeBranch()
469 void CRebaseDlg::OnCbnSelchangeUpstream()
474 void CRebaseDlg::FetchLogList()
476 CGitHash base
,hash
,upstream
;
477 m_IsFastForward
=FALSE
;
479 if (m_BranchCtrl
.GetString().IsEmpty())
481 m_CommitList
.ShowText(CString(MAKEINTRESOURCE(IDS_SELECTBRANCH
)));
482 this->GetDlgItem(IDC_REBASE_CONTINUE
)->EnableWindow(false);
486 if (g_Git
.GetHash(hash
, m_BranchCtrl
.GetString()))
488 m_CommitList
.ShowText(g_Git
.GetGitLastErr(_T("Could not get hash of \"") + m_BranchCtrl
.GetString() + _T("\".")));
489 this->GetDlgItem(IDC_REBASE_CONTINUE
)->EnableWindow(false);
493 if (m_UpstreamCtrl
.GetString().IsEmpty())
495 m_CommitList
.ShowText(CString(MAKEINTRESOURCE(IDS_SELECTUPSTREAM
)));
496 this->GetDlgItem(IDC_REBASE_CONTINUE
)->EnableWindow(false);
500 if (g_Git
.GetHash(upstream
, m_UpstreamCtrl
.GetString()))
502 m_CommitList
.ShowText(g_Git
.GetGitLastErr(_T("Could not get hash of \"") + m_UpstreamCtrl
.GetString() + _T("\".")));
503 this->GetDlgItem(IDC_REBASE_CONTINUE
)->EnableWindow(false);
507 if (hash
== upstream
)
509 m_CommitList
.Clear();
511 fmt
.LoadString(IDS_REBASE_EQUAL_FMT
);
512 text
.Format(fmt
,m_BranchCtrl
.GetString(),this->m_UpstreamCtrl
.GetString());
514 m_CommitList
.ShowText(text
);
515 this->GetDlgItem(IDC_REBASE_CONTINUE
)->EnableWindow(false);
519 if (g_Git
.IsFastForward(m_BranchCtrl
.GetString(), m_UpstreamCtrl
.GetString(), &base
) && m_Onto
.IsEmpty())
522 this->m_IsFastForward
=TRUE
;
524 m_CommitList
.Clear();
526 fmt
.LoadString(IDS_REBASE_FASTFORWARD_FMT
);
527 text
.Format(fmt
,m_BranchCtrl
.GetString(),this->m_UpstreamCtrl
.GetString(),
528 m_BranchCtrl
.GetString(),this->m_UpstreamCtrl
.GetString());
530 m_CommitList
.ShowText(text
);
531 this->GetDlgItem(IDC_REBASE_CONTINUE
)->EnableWindow(true);
532 SetContinueButtonText();
537 if (!m_bForce
&& m_Onto
.IsEmpty())
539 if (base
== upstream
)
541 m_CommitList
.Clear();
543 fmt
.LoadString(IDS_REBASE_UPTODATE_FMT
);
544 text
.Format(fmt
,m_BranchCtrl
.GetString());
545 m_CommitList
.ShowText(text
);
546 this->GetDlgItem(IDC_REBASE_CONTINUE
)->EnableWindow(m_CommitList
.GetItemCount());
547 SetContinueButtonText();
552 m_CommitList
.Clear();
553 CString refFrom
= g_Git
.FixBranchName(m_UpstreamCtrl
.GetString());
554 CString refTo
= g_Git
.FixBranchName(m_BranchCtrl
.GetString());
556 range
.Format(_T("%s..%s"), refFrom
, refTo
);
557 this->m_CommitList
.FillGitLog(nullptr, &range
, 0);
559 if( m_CommitList
.GetItemCount() == 0 )
560 m_CommitList
.ShowText(CString(MAKEINTRESOURCE(IDS_PROC_NOTHINGTOREBASE
)));
563 if(m_CommitList
.m_logEntries
[m_CommitList
.m_logEntries
.size()-1].m_ParentHash
.size() >=0 )
565 if(upstream
== m_CommitList
.m_logEntries
[m_CommitList
.m_logEntries
.size()-1].m_ParentHash
[0])
567 m_CommitList
.Clear();
568 m_CommitList
.ShowText(_T("Nothing Rebase"));
574 AddBranchToolTips(&this->m_BranchCtrl
);
575 AddBranchToolTips(&this->m_UpstreamCtrl
);
577 // Default all actions to 'pick'
578 std::map
<CGitHash
, size_t> revIxMap
;
579 for (size_t i
= 0; i
< m_CommitList
.m_logEntries
.size(); ++i
)
581 GitRevLoglist
& rev
= m_CommitList
.m_logEntries
.GetGitRevAt(i
);
582 rev
.GetRebaseAction() = CGitLogListBase::LOGACTIONS_REBASE_PICK
;
583 revIxMap
[rev
.m_CommitHash
] = i
;
586 // Default to skip when already in upstream
587 if (!m_Onto
.IsEmpty())
588 refFrom
= g_Git
.FixBranchName(m_Onto
);
590 cherryCmd
.Format(L
"git.exe cherry \"%s\" \"%s\"", refFrom
, refTo
);
591 bool bHasSKip
= false;
592 g_Git
.Run(cherryCmd
, [&](const CStringA
& line
)
594 if (line
.GetLength() < 2)
597 return; // Don't skip (only skip commits starting with a '-')
598 CString hash
= CUnicodeUtils::GetUnicode(line
.Mid(1));
600 auto itIx
= revIxMap
.find(CGitHash(hash
));
601 if (itIx
== revIxMap
.end())
602 return; // Not found?? Should not occur...
605 m_CommitList
.m_logEntries
.GetGitRevAt(itIx
->second
).GetRebaseAction() = CGitLogListBase::LOGACTIONS_REBASE_SKIP
;
609 m_CommitList
.Invalidate();
612 m_CtrlStatusText
.SetWindowText(CString(MAKEINTRESOURCE(IDS_REBASE_AUTOSKIPPED
)));
613 m_bStatusWarning
= true;
617 m_CtrlStatusText
.SetWindowText(m_sStatusText
);
618 m_bStatusWarning
= false;
620 m_CtrlStatusText
.Invalidate();
622 if(m_CommitList
.m_IsOldFirst
)
623 this->m_CurrentRebaseIndex
= -1;
625 this->m_CurrentRebaseIndex
= (int)m_CommitList
.m_logEntries
.size();
627 this->GetDlgItem(IDC_REBASE_CONTINUE
)->EnableWindow(m_CommitList
.GetItemCount());
628 SetContinueButtonText();
631 void CRebaseDlg::AddBranchToolTips(CHistoryCombo
*pBranch
)
635 CString text
=pBranch
->GetString();
640 pBranch
->DisableTooltip();
645 if (rev
.GetCommit(text
))
647 MessageBox(rev
.GetLastErr(), _T("TortoiseGit"), MB_ICONERROR
);
648 pBranch
->DisableTooltip();
652 tooltip
.Format(_T("%s: %s\n%s: %s <%s>\n%s: %s\n%s:\n%s\n%s"),
653 CString(MAKEINTRESOURCE(IDS_LOG_REVISION
)),
654 rev
.m_CommitHash
.ToString(),
655 CString(MAKEINTRESOURCE(IDS_LOG_AUTHOR
)),
657 rev
.GetAuthorEmail(),
658 CString(MAKEINTRESOURCE(IDS_LOG_DATE
)),
659 CLoglistUtils::FormatDateAndTime(rev
.GetAuthorDate(), DATE_LONGDATE
),
660 CString(MAKEINTRESOURCE(IDS_LOG_MESSAGE
)),
664 pBranch
->DisableTooltip();
665 this->m_tooltips
.AddTool(pBranch
->GetComboBoxCtrl(),tooltip
);
669 BOOL
CRebaseDlg::PreTranslateMessage(MSG
*pMsg
)
671 if (pMsg
->message
== WM_KEYDOWN
)
673 switch (pMsg
->wParam
)
676 if (LogListHasFocus(pMsg
->hwnd
)
677 && LogListHasMenuItem(CGitLogListBase::ID_REBASE_PICK
)
678 && LogListHasMenuItem(CGitLogListBase::ID_REBASE_SQUASH
)
679 && LogListHasMenuItem(CGitLogListBase::ID_REBASE_EDIT
)
680 && LogListHasMenuItem(CGitLogListBase::ID_REBASE_SKIP
))
682 m_CommitList
.ShiftSelectedRebaseAction();
687 if (LogListHasFocus(pMsg
->hwnd
) && LogListHasMenuItem(CGitLogListBase::ID_REBASE_PICK
))
689 m_CommitList
.SetSelectedRebaseAction(CGitLogListBase::LOGACTIONS_REBASE_PICK
);
694 if (LogListHasFocus(pMsg
->hwnd
) && LogListHasMenuItem(CGitLogListBase::ID_REBASE_SKIP
))
696 m_CommitList
.SetSelectedRebaseAction(CGitLogListBase::LOGACTIONS_REBASE_SKIP
);
701 if (LogListHasFocus(pMsg
->hwnd
) && LogListHasMenuItem(CGitLogListBase::ID_REBASE_SQUASH
))
703 m_CommitList
.SetSelectedRebaseAction(CGitLogListBase::LOGACTIONS_REBASE_SQUASH
);
708 if (LogListHasFocus(pMsg
->hwnd
) && LogListHasMenuItem(CGitLogListBase::ID_REBASE_EDIT
))
710 m_CommitList
.SetSelectedRebaseAction(CGitLogListBase::LOGACTIONS_REBASE_EDIT
);
715 if(LogListHasFocus(pMsg
->hwnd
) && GetAsyncKeyState(VK_CONTROL
) & 0x8000)
717 // select all entries
718 for (int i
= 0; i
< m_CommitList
.GetItemCount(); ++i
)
720 m_CommitList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
733 if (GetAsyncKeyState(VK_CONTROL
) & 0x8000)
735 if (GetDlgItem(IDC_REBASE_CONTINUE
)->IsWindowEnabled())
736 GetDlgItem(IDC_REBASE_CONTINUE
)->SetFocus();
737 else if (GetDlgItem(IDC_REBASE_ABORT
)->IsWindowEnabled())
738 GetDlgItem(IDC_REBASE_ABORT
)->SetFocus();
740 GetDlgItem(IDHELP
)->SetFocus();
745 /* Avoid TAB control destroy but dialog exist*/
749 TCHAR buff
[128] = { 0 };
750 ::GetClassName(pMsg
->hwnd
,buff
,128);
753 /* Use MSFTEDIT_CLASS http://msdn.microsoft.com/en-us/library/bb531344.aspx */
754 if (_tcsnicmp(buff
, MSFTEDIT_CLASS
, 128) == 0 || //Unicode and MFC 2012 and later
755 _tcsnicmp(buff
, RICHEDIT_CLASS
, 128) == 0 || //ANSI or MFC 2010
756 _tcsnicmp(buff
,_T("Scintilla"),128)==0 ||
757 _tcsnicmp(buff
,_T("SysListView32"),128)==0||
758 ::GetParent(pMsg
->hwnd
) == this->m_ctrlTabCtrl
.m_hWnd
)
760 this->PostMessage(WM_KEYDOWN
,VK_ESCAPE
,0);
766 else if (pMsg
->message
== WM_NEXTDLGCTL
)
768 HWND hwnd
= GetFocus()->GetSafeHwnd();
769 if (hwnd
== m_LogMessageCtrl
.GetSafeHwnd() || hwnd
== m_wndOutputRebase
.GetSafeHwnd())
771 if (GetDlgItem(IDC_REBASE_CONTINUE
)->IsWindowEnabled())
772 GetDlgItem(IDC_REBASE_CONTINUE
)->SetFocus();
773 else if (GetDlgItem(IDC_REBASE_ABORT
)->IsWindowEnabled())
774 GetDlgItem(IDC_REBASE_ABORT
)->SetFocus();
776 GetDlgItem(IDHELP
)->SetFocus();
780 return CResizableStandAloneDialog::PreTranslateMessage(pMsg
);
783 bool CRebaseDlg::LogListHasFocus(HWND hwnd
)
785 TCHAR buff
[128] = { 0 };
786 ::GetClassName(hwnd
, buff
, 128);
788 if(_tcsnicmp(buff
, _T("SysListView32"), 128) == 0)
793 bool CRebaseDlg::LogListHasMenuItem(int i
)
795 return (m_CommitList
.m_ContextMenuMask
& m_CommitList
.GetContextMenuBit(i
)) != 0;
798 int CRebaseDlg::CheckRebaseCondition()
800 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_LOG
);
802 if( !g_Git
.CheckCleanWorkTree() )
804 if (CMessageBox::Show(NULL
, IDS_ERROR_NOCLEAN_STASH
, IDS_APPNAME
, 1, IDI_QUESTION
, IDS_STASHBUTTON
, IDS_ABORTBUTTON
) == 1)
807 cmd
=_T("git.exe stash");
808 this->AddLogString(cmd
);
809 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
811 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
819 //Todo Check $REBASE_ROOT
822 if (!CAppUtils::CheckUserData())
825 //Todo call pre_rebase_hook
829 void CRebaseDlg::CheckRestoreStash()
831 if (m_bStashed
&& CMessageBox::Show(nullptr, IDS_DCOMMIT_STASH_POP
, IDS_APPNAME
, MB_YESNO
| MB_ICONQUESTION
) == IDYES
)
832 CAppUtils::StashPop();
836 int CRebaseDlg::StartRebase()
839 m_FileListCtrl
.m_bIsRevertTheirMy
= !m_IsCherryPick
;
841 m_OrigHEADBranch
= g_Git
.GetCurrentBranch(true);
843 m_OrigHEADHash
.Empty();
844 if (g_Git
.GetHash(m_OrigHEADHash
, _T("HEAD")))
846 AddLogString(CString(MAKEINTRESOURCE(IDS_PROC_NOHEAD
)));
850 //git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
851 // echo "detached HEAD" > "$DOTEST"/head-name
853 cmd
.Format(_T("git.exe update-ref ORIG_HEAD ") + m_OrigHEADHash
.ToString());
854 if(g_Git
.Run(cmd
,&out
,CP_UTF8
))
856 AddLogString(_T("update ORIG_HEAD Fail"));
860 m_OrigUpstreamHash
.Empty();
861 if (g_Git
.GetHash(m_OrigUpstreamHash
, (m_IsCherryPick
|| m_Onto
.IsEmpty()) ? m_UpstreamCtrl
.GetString() : m_Onto
))
863 MessageBox(g_Git
.GetGitLastErr(_T("Could not get hash of \"") + (m_IsCherryPick
|| m_Onto
.IsEmpty()) ? m_UpstreamCtrl
.GetString() : m_Onto
+ _T("\".")), _T("TortoiseGit"), MB_ICONERROR
);
867 if( !this->m_IsCherryPick
)
869 cmd
.Format(_T("git.exe checkout -f %s --"), m_OrigUpstreamHash
.ToString());
870 this->AddLogString(cmd
);
874 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
876 this->AddLogString(out
);
877 if (CMessageBox::Show(m_hWnd
, out
+ _T("\nRetry?"), _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
886 if( !this->m_IsCherryPick
)
888 if (g_Git
.GetHash(m_OrigBranchHash
, m_BranchCtrl
.GetString()))
890 MessageBox(g_Git
.GetGitLastErr(_T("Could not get hash of \"") + m_BranchCtrl
.GetString() + _T("\".")), _T("TortoiseGit"), MB_ICONERROR
);
893 log
.Format(_T("%s\r\n"), CString(MAKEINTRESOURCE(IDS_PROC_REBASE_STARTREBASE
)));
896 log
.Format(_T("%s\r\n"), CString(MAKEINTRESOURCE(IDS_PROC_REBASE_STARTCHERRYPICK
)));
898 this->AddLogString(log
);
901 int CRebaseDlg::VerifyNoConflict()
903 int hasConflicts
= g_Git
.HasWorkingTreeConflicts();
904 if (hasConflicts
< 0)
906 AddLogString(g_Git
.GetGitLastErr(L
"Checking for conflicts failed.", CGit::GIT_CMD_CHECKCONFLICTS
));
911 CMessageBox::Show(NULL
, IDS_PROGRS_CONFLICTSOCCURED
, IDS_APPNAME
, MB_OK
);
918 static bool IsLocalBranch(CString ref
)
921 g_Git
.GetBranchList(list
, nullptr, CGit::BRANCH_LOCAL
);
922 return std::find(list
.begin(), list
.end(), ref
) != list
.end();
925 int CRebaseDlg::FinishRebase()
927 if (m_bFinishedRebase
)
930 m_bFinishedRebase
= true;
931 if(this->m_IsCherryPick
) //cherry pick mode no "branch", working at upstream branch
933 m_sStatusText
.LoadString(IDS_DONE
);
934 m_CtrlStatusText
.SetWindowText(m_sStatusText
);
935 m_bStatusWarning
= false;
936 m_CtrlStatusText
.Invalidate();
941 if (g_Git
.GetHash(head
, _T("HEAD")))
943 MessageBox(g_Git
.GetGitLastErr(_T("Could not get HEAD hash.")), _T("TortoiseGit"), MB_ICONERROR
);
948 if (IsLocalBranch(m_BranchCtrl
.GetString()))
950 cmd
.Format(_T("git.exe checkout -f -B %s %s --"), m_BranchCtrl
.GetString(), head
.ToString());
955 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
958 if (CMessageBox::Show(m_hWnd
, out
+ _T("\nRetry?"), _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
967 cmd
.Format(_T("git.exe reset --hard %s --"), head
.ToString());
972 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
975 if (CMessageBox::Show(m_hWnd
, out
+ _T("\nRetry?"), _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
983 while (m_ctrlTabCtrl
.GetTabsNum() > 1)
984 m_ctrlTabCtrl
.RemoveTab(0);
985 m_CtrlStatusText
.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_REBASEFINISHED
)));
986 m_sStatusText
= CString(MAKEINTRESOURCE(IDS_PROC_REBASEFINISHED
));
987 m_bStatusWarning
= false;
988 m_CtrlStatusText
.Invalidate();
992 void CRebaseDlg::OnBnClickedContinue()
994 if( m_RebaseStage
== REBASE_DONE
)
1001 if (m_RebaseStage
== CHOOSE_BRANCH
|| m_RebaseStage
== CHOOSE_COMMIT_PICK_MODE
)
1003 if (CheckRebaseCondition())
1007 if( this->m_IsFastForward
)
1010 if (g_Git
.GetHash(m_OrigBranchHash
, m_BranchCtrl
.GetString()))
1012 MessageBox(g_Git
.GetGitLastErr(_T("Could not get hash of \"") + m_BranchCtrl
.GetString() + _T("\".")), _T("TortoiseGit"), MB_ICONERROR
);
1015 if (g_Git
.GetHash(m_OrigUpstreamHash
, m_UpstreamCtrl
.GetString()))
1017 MessageBox(g_Git
.GetGitLastErr(_T("Could not get hash of \"") + m_UpstreamCtrl
.GetString() + _T("\".")), _T("TortoiseGit"), MB_ICONERROR
);
1021 if(!g_Git
.IsFastForward(this->m_BranchCtrl
.GetString(),this->m_UpstreamCtrl
.GetString()))
1023 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_LOG
);
1024 AddLogString(_T("No fast forward possible.\r\nMaybe repository changed"));
1028 if (IsLocalBranch(m_BranchCtrl
.GetString()))
1030 cmd
.Format(_T("git.exe checkout --no-track -f -B %s %s --"), m_BranchCtrl
.GetString(), m_UpstreamCtrl
.GetString());
1035 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
1037 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_LOG
);
1039 if (CMessageBox::Show(m_hWnd
, out
+ _T("\nRetry?"), _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
1048 cmd
.Format(_T("git.exe reset --hard %s --"), g_Git
.FixBranchName(this->m_UpstreamCtrl
.GetString()));
1050 log
.Format(IDS_PROC_REBASE_FFTO
, m_UpstreamCtrl
.GetString());
1051 this->AddLogString(log
);
1054 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_LOG
);
1058 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
1060 AddLogString(CString(MAKEINTRESOURCE(IDS_FAIL
)));
1062 if (CMessageBox::Show(m_hWnd
, out
+ _T("\nRetry?"), _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
1069 AddLogString(CString(MAKEINTRESOURCE(IDS_DONE
)));
1070 m_RebaseStage
= REBASE_DONE
;
1071 UpdateCurrentStatus();
1075 if( m_RebaseStage
== CHOOSE_BRANCH
|| m_RebaseStage
== CHOOSE_COMMIT_PICK_MODE
)
1077 if(CheckRebaseCondition())
1079 m_RebaseStage
= REBASE_START
;
1080 m_FileListCtrl
.Clear();
1081 m_FileListCtrl
.SetHasCheckboxes(false);
1082 m_FileListCtrl
.m_CurrentVersion
= L
"";
1083 m_ctrlTabCtrl
.SetTabLabel(REBASE_TAB_CONFLICT
, CString(MAKEINTRESOURCE(IDS_PROC_CONFLICTFILES
)));
1084 m_ctrlTabCtrl
.AddTab(&m_wndOutputRebase
, CString(MAKEINTRESOURCE(IDS_LOG
)), 2);
1087 if( m_RebaseStage
== REBASE_FINISH
)
1095 if( m_RebaseStage
== REBASE_SQUASH_CONFLICT
)
1097 if(VerifyNoConflict())
1099 GitRevLoglist
* curRev
= (GitRevLoglist
*)m_CommitList
.m_arShownList
[m_CurrentRebaseIndex
];
1100 if(this->CheckNextCommitIsSquash())
1101 {//next commit is not squash;
1102 m_RebaseStage
= REBASE_SQUASH_EDIT
;
1103 this->OnRebaseUpdateUI(0,0);
1104 this->UpdateCurrentStatus();
1108 m_RebaseStage
=REBASE_CONTINUE
;
1109 curRev
->GetRebaseAction() |= CGitLogListBase::LOGACTIONS_REBASE_DONE
;
1110 this->UpdateCurrentStatus();
1114 if( m_RebaseStage
== REBASE_CONFLICT
)
1116 if(VerifyNoConflict())
1119 GitRevLoglist
* curRev
= (GitRevLoglist
*)m_CommitList
.m_arShownList
[m_CurrentRebaseIndex
];
1120 // ***************************************************
1121 // ATTENTION: Similar code in CommitDlg.cpp!!!
1122 // ***************************************************
1123 CMassiveGitTask
mgtReAddAfterCommit(_T("add --ignore-errors -f"));
1124 CMassiveGitTask
mgtAdd(_T("add -f"));
1125 CMassiveGitTask
mgtUpdateIndexForceRemove(_T("update-index --force-remove"));
1126 CMassiveGitTask
mgtUpdateIndex(_T("update-index"));
1127 CMassiveGitTask
mgtRm(_T("rm --ignore-unmatch"));
1128 CMassiveGitTask
mgtRmFCache(_T("rm -f --cache"));
1129 CMassiveGitTask
mgtReset(_T("reset"), TRUE
, true);
1130 for (int i
= 0; i
< m_FileListCtrl
.GetItemCount(); i
++)
1132 CTGitPath
*entry
= (CTGitPath
*)m_FileListCtrl
.GetItemData(i
);
1133 if (entry
->m_Checked
)
1135 if (entry
->m_Action
& CTGitPath::LOGACTIONS_UNVER
)
1136 mgtAdd
.AddFile(entry
->GetGitPathString());
1137 else if (entry
->m_Action
& CTGitPath::LOGACTIONS_DELETED
)
1138 mgtUpdateIndexForceRemove
.AddFile(entry
->GetGitPathString());
1140 mgtUpdateIndex
.AddFile(entry
->GetGitPathString());
1142 if (entry
->m_Action
& CTGitPath::LOGACTIONS_REPLACED
)
1143 mgtRm
.AddFile(entry
->GetGitOldPathString());
1147 if (entry
->m_Action
& CTGitPath::LOGACTIONS_ADDED
|| entry
->m_Action
& CTGitPath::LOGACTIONS_REPLACED
)
1149 mgtRmFCache
.AddFile(entry
->GetGitPathString());
1150 mgtReAddAfterCommit
.AddFile(*entry
);
1152 if (entry
->m_Action
& CTGitPath::LOGACTIONS_REPLACED
&& !entry
->GetGitOldPathString().IsEmpty())
1153 mgtReset
.AddFile(entry
->GetGitOldPathString());
1155 else if(!(entry
->m_Action
& CTGitPath::LOGACTIONS_UNVER
))
1156 mgtReset
.AddFile(entry
->GetGitPathString());
1160 BOOL cancel
= FALSE
;
1161 bool successful
= true;
1162 successful
= successful
&& mgtAdd
.Execute(cancel
);
1163 successful
= successful
&& mgtUpdateIndexForceRemove
.Execute(cancel
);
1164 successful
= successful
&& mgtUpdateIndex
.Execute(cancel
);
1165 successful
= successful
&& mgtRm
.Execute(cancel
);
1166 successful
= successful
&& mgtRmFCache
.Execute(cancel
);
1167 successful
= successful
&& mgtReset
.Execute(cancel
);
1171 AddLogString(_T("An error occurred while updating the index."));
1175 CString out
=_T("");
1177 cmd
.Format(_T("git.exe commit -C %s"), curRev
->m_CommitHash
.ToString());
1181 if(g_Git
.Run(cmd
,&out
,CP_UTF8
))
1184 if(!g_Git
.CheckCleanWorkTree())
1186 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
1193 // update commit message if needed
1194 CString str
= m_LogMessageCtrl
.GetText().Trim();
1195 if (str
!= (curRev
->GetSubject() + _T("\n") + curRev
->GetBody()).Trim())
1197 if (str
.Trim().IsEmpty())
1199 CMessageBox::Show(NULL
, IDS_PROC_COMMITMESSAGE_EMPTY
,IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
1202 CString tempfile
= ::GetTempFile();
1203 if (CAppUtils::SaveCommitUnicodeFile(tempfile
, str
))
1205 CMessageBox::Show(nullptr, _T("Could not save commit message"), _T("TortoiseGit"), MB_OK
| MB_ICONERROR
);
1210 cmd
.Format(_T("git.exe commit --amend -F \"%s\""), tempfile
);
1213 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
1216 if (!g_Git
.CheckCleanWorkTree())
1218 CMessageBox::Show(NULL
, out
, _T("TortoiseGit"), MB_OK
| MB_ICONERROR
);
1226 if (((DWORD
)CRegStdDWORD(_T("Software\\TortoiseGit\\ReaddUnselectedAddedFilesAfterCommit"), TRUE
)) == TRUE
)
1228 BOOL cancel
= FALSE
;
1229 mgtReAddAfterCommit
.Execute(cancel
);
1232 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_LOG
);
1233 if (curRev
->GetRebaseAction() & CGitLogListBase::LOGACTIONS_REBASE_EDIT
)
1235 m_RebaseStage
=REBASE_EDIT
;
1236 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_MESSAGE
);
1237 this->UpdateCurrentStatus();
1242 m_RebaseStage
=REBASE_CONTINUE
;
1243 curRev
->GetRebaseAction() |= CGitLogListBase::LOGACTIONS_REBASE_DONE
;
1244 this->UpdateCurrentStatus();
1246 if (CheckNextCommitIsSquash() == 0) // remember commit msg after edit if next commit if squash
1247 ResetParentForSquash(str
);
1249 m_SquashMessage
.Empty();
1253 if ((m_RebaseStage
== REBASE_EDIT
|| m_RebaseStage
== REBASE_CONTINUE
|| m_bSplitCommit
) && CheckNextCommitIsSquash() && (m_bSplitCommit
|| !g_Git
.CheckCleanWorkTree(true)))
1255 if (!m_bSplitCommit
&& CMessageBox::Show(nullptr, IDS_PROC_REBASE_CONTINUE_NOTCLEAN
, IDS_APPNAME
, 1, IDI_ERROR
, IDS_MSGBOX_OK
, IDS_ABORTBUTTON
) == 2)
1257 BOOL isFirst
= TRUE
;
1262 dlg
.m_sLogMessage
= m_LogMessageCtrl
.GetText();
1263 dlg
.m_bWholeProject
= true;
1264 dlg
.m_bSelectFilesForCommit
= true;
1265 dlg
.m_bCommitAmend
= isFirst
&& (m_RebaseStage
!= REBASE_SQUASH_EDIT
); // do not amend on squash_edit stage, we need a normal commit there
1267 gpl
.AddPath(CTGitPath(g_Git
.m_CurrentDir
));
1268 dlg
.m_pathList
= gpl
;
1269 dlg
.m_bAmendDiffToLastCommit
= !m_bSplitCommit
;
1270 dlg
.m_bNoPostActions
= true;
1271 if (dlg
.m_bCommitAmend
)
1272 dlg
.m_AmendStr
= dlg
.m_sLogMessage
;
1273 dlg
.m_bWarnDetachedHead
= false;
1275 if (dlg
.DoModal() != IDOK
)
1278 isFirst
= !m_bSplitCommit
; // only select amend on second+ runs if not in split commit mode
1280 m_SquashMessage
.Empty();
1281 } while (!g_Git
.CheckCleanWorkTree() || (m_bSplitCommit
&& CMessageBox::Show(GetSafeHwnd(), IDS_REBASE_ADDANOTHERCOMMIT
, IDS_APPNAME
, MB_YESNO
| MB_ICONQUESTION
) == IDYES
));
1283 m_bSplitCommit
= FALSE
;
1286 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_LOG
);
1287 m_RebaseStage
= REBASE_CONTINUE
;
1288 GitRevLoglist
* curRev
= (GitRevLoglist
*)m_CommitList
.m_arShownList
[m_CurrentRebaseIndex
];
1289 curRev
->GetRebaseAction() |= CGitLogListBase::LOGACTIONS_REBASE_DONE
;
1290 this->UpdateCurrentStatus();
1293 if( m_RebaseStage
== REBASE_EDIT
|| m_RebaseStage
== REBASE_SQUASH_EDIT
)
1296 GitRevLoglist
* curRev
= (GitRevLoglist
*)m_CommitList
.m_arShownList
[m_CurrentRebaseIndex
];
1298 str
=this->m_LogMessageCtrl
.GetText();
1299 if(str
.Trim().IsEmpty())
1301 CMessageBox::Show(NULL
, IDS_PROC_COMMITMESSAGE_EMPTY
,IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
1305 CString tempfile
=::GetTempFile();
1306 if (CAppUtils::SaveCommitUnicodeFile(tempfile
, str
))
1308 CMessageBox::Show(nullptr, _T("Could not save commit message"), _T("TortoiseGit"), MB_OK
| MB_ICONERROR
);
1314 if( m_RebaseStage
== REBASE_SQUASH_EDIT
)
1315 cmd
.Format(_T("git.exe commit %s-F \"%s\""), m_SquashFirstMetaData
, tempfile
);
1319 int isEmpty
= IsCommitEmpty(curRev
->m_CommitHash
);
1321 options
= _T("--allow-empty ");
1322 else if (isEmpty
< 0)
1324 cmd
.Format(_T("git.exe commit --amend %s-F \"%s\""), options
, tempfile
);
1327 if(g_Git
.Run(cmd
,&out
,CP_UTF8
))
1329 if(!g_Git
.CheckCleanWorkTree())
1331 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
1336 ::DeleteFile(tempfile
);
1338 if (CheckNextCommitIsSquash() == 0 && m_RebaseStage
!= REBASE_SQUASH_EDIT
) // remember commit msg after edit if next commit if squash; but don't do this if ...->squash(reset here)->pick->squash
1340 ResetParentForSquash(str
);
1343 m_SquashMessage
.Empty();
1344 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_LOG
);
1345 m_RebaseStage
=REBASE_CONTINUE
;
1346 curRev
->GetRebaseAction() |= CGitLogListBase::LOGACTIONS_REBASE_DONE
;
1347 this->UpdateCurrentStatus();
1351 InterlockedExchange(&m_bThreadRunning
, TRUE
);
1354 if (AfxBeginThread(RebaseThreadEntry
, this)==NULL
)
1356 InterlockedExchange(&m_bThreadRunning
, FALSE
);
1357 CMessageBox::Show(NULL
, _T("Create Rebase Thread Fail"), _T("TortoiseGit"), MB_OK
| MB_ICONERROR
);
1361 void CRebaseDlg::ResetParentForSquash(const CString
& commitMessage
)
1363 m_SquashMessage
= commitMessage
;
1364 // reset parent so that we can do "git cherry-pick --no-commit" w/o introducing an unwanted commit
1365 CString cmd
= _T("git.exe reset --soft HEAD~1");
1366 m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_LOG
);
1370 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
1373 AddLogString(CString(MAKEINTRESOURCE(IDS_FAIL
)));
1375 if (CMessageBox::Show(m_hWnd
, out
+ _T("\nRetry?"), _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
1382 int CRebaseDlg::CheckNextCommitIsSquash()
1385 if(m_CommitList
.m_IsOldFirst
)
1386 index
=m_CurrentRebaseIndex
+1;
1388 index
=m_CurrentRebaseIndex
-1;
1390 GitRevLoglist
* curRev
;
1395 if(index
>= m_CommitList
.GetItemCount())
1398 curRev
= (GitRevLoglist
*)m_CommitList
.m_arShownList
[index
];
1400 if (curRev
->GetRebaseAction() & CGitLogListBase::LOGACTIONS_REBASE_SQUASH
)
1402 if (curRev
->GetRebaseAction() & CGitLogListBase::LOGACTIONS_REBASE_SKIP
)
1404 if(m_CommitList
.m_IsOldFirst
)
1412 } while(curRev
->GetRebaseAction() & CGitLogListBase::LOGACTIONS_REBASE_SKIP
);
1417 int CRebaseDlg::GoNext()
1419 if(m_CommitList
.m_IsOldFirst
)
1420 ++m_CurrentRebaseIndex
;
1422 --m_CurrentRebaseIndex
;
1426 int CRebaseDlg::StateAction()
1428 switch(this->m_RebaseStage
)
1431 case CHOOSE_COMMIT_PICK_MODE
:
1434 m_RebaseStage
= REBASE_START
;
1441 void CRebaseDlg::SetContinueButtonText()
1444 switch(this->m_RebaseStage
)
1447 case CHOOSE_COMMIT_PICK_MODE
:
1448 if(this->m_IsFastForward
)
1449 Text
.LoadString(IDS_PROC_STARTREBASEFFBUTTON
);
1451 Text
.LoadString(IDS_PROC_STARTREBASEBUTTON
);
1456 case REBASE_CONTINUE
:
1457 case REBASE_SQUASH_CONFLICT
:
1458 Text
.LoadString(IDS_CONTINUEBUTTON
);
1461 case REBASE_CONFLICT
:
1462 Text
.LoadString(IDS_COMMITBUTTON
);
1465 Text
.LoadString(IDS_AMENDBUTTON
);
1468 case REBASE_SQUASH_EDIT
:
1469 Text
.LoadString(IDS_COMMITBUTTON
);
1474 Text
.LoadString(IDS_FINISHBUTTON
);
1478 Text
.LoadString(IDS_DONE
);
1481 this->GetDlgItem(IDC_REBASE_CONTINUE
)->SetWindowText(Text
);
1484 void CRebaseDlg::SetControlEnable()
1486 switch(this->m_RebaseStage
)
1489 case CHOOSE_COMMIT_PICK_MODE
:
1491 this->GetDlgItem(IDC_SPLITALLOPTIONS
)->EnableWindow(TRUE
);
1492 this->GetDlgItem(IDC_BUTTON_UP2
)->EnableWindow(TRUE
);
1493 this->GetDlgItem(IDC_BUTTON_DOWN2
)->EnableWindow(TRUE
);
1497 this->GetDlgItem(IDC_REBASE_COMBOXEX_BRANCH
)->EnableWindow(TRUE
);
1498 this->GetDlgItem(IDC_REBASE_COMBOXEX_UPSTREAM
)->EnableWindow(TRUE
);
1499 this->GetDlgItem(IDC_BUTTON_REVERSE
)->EnableWindow(TRUE
);
1500 this->GetDlgItem(IDC_REBASE_CHECK_FORCE
)->EnableWindow(TRUE
);
1502 this->m_CommitList
.m_ContextMenuMask
|= m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_REBASE_PICK
)|
1503 m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_REBASE_SQUASH
)|
1504 m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_REBASE_EDIT
)|
1505 m_CommitList
.GetContextMenuBit(CGitLogListBase::ID_REBASE_SKIP
);
1509 case REBASE_CONTINUE
:
1513 case REBASE_CONFLICT
:
1515 case REBASE_SQUASH_CONFLICT
:
1517 this->GetDlgItem(IDC_SPLITALLOPTIONS
)->EnableWindow(FALSE
);
1518 this->GetDlgItem(IDC_REBASE_COMBOXEX_BRANCH
)->EnableWindow(FALSE
);
1519 this->GetDlgItem(IDC_REBASE_COMBOXEX_UPSTREAM
)->EnableWindow(FALSE
);
1520 this->GetDlgItem(IDC_BUTTON_REVERSE
)->EnableWindow(FALSE
);
1521 this->GetDlgItem(IDC_REBASE_CHECK_FORCE
)->EnableWindow(FALSE
);
1522 this->GetDlgItem(IDC_BUTTON_UP2
)->EnableWindow(FALSE
);
1523 this->GetDlgItem(IDC_BUTTON_DOWN2
)->EnableWindow(FALSE
);
1525 if( m_RebaseStage
== REBASE_DONE
&& (this->m_PostButtonTexts
.GetCount() != 0) )
1527 this->GetDlgItem(IDC_STATUS_STATIC
)->ShowWindow(SW_HIDE
);
1528 this->GetDlgItem(IDC_REBASE_POST_BUTTON
)->ShowWindow(SW_SHOWNORMAL
);
1529 this->m_PostButton
.RemoveAll();
1530 this->m_PostButton
.AddEntries(m_PostButtonTexts
);
1531 //this->GetDlgItem(IDC_REBASE_POST_BUTTON)->SetWindowText(this->m_PostButtonText);
1536 GetDlgItem(IDC_REBASE_SPLIT_COMMIT
)->ShowWindow((m_RebaseStage
== REBASE_EDIT
|| m_RebaseStage
== REBASE_SQUASH_EDIT
) ? SW_SHOW
: SW_HIDE
);
1538 if(m_bThreadRunning
)
1540 this->GetDlgItem(IDC_REBASE_CONTINUE
)->EnableWindow(FALSE
);
1543 else if (m_RebaseStage
!= REBASE_ERROR
)
1545 this->GetDlgItem(IDC_REBASE_CONTINUE
)->EnableWindow(TRUE
);
1549 void CRebaseDlg::UpdateProgress()
1554 if(m_CommitList
.m_IsOldFirst
)
1555 index
= m_CurrentRebaseIndex
+1;
1557 index
= m_CommitList
.GetItemCount()-m_CurrentRebaseIndex
;
1559 int finishedCommits
= index
- 1; // introduced an variable which shows the number handled revisions for the progress bars
1560 if (m_RebaseStage
== REBASE_FINISH
|| finishedCommits
== -1)
1561 finishedCommits
= index
;
1563 m_ProgressBar
.SetRange32(0, m_CommitList
.GetItemCount());
1564 m_ProgressBar
.SetPos(finishedCommits
);
1567 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
1568 m_pTaskbarList
->SetProgressValue(m_hWnd
, finishedCommits
, m_CommitList
.GetItemCount());
1571 if(m_CurrentRebaseIndex
>=0 && m_CurrentRebaseIndex
< m_CommitList
.GetItemCount())
1574 text
.Format(IDS_PROC_REBASING_PROGRESS
, index
, m_CommitList
.GetItemCount());
1575 m_sStatusText
= text
;
1576 m_CtrlStatusText
.SetWindowText(text
);
1577 m_bStatusWarning
= false;
1578 m_CtrlStatusText
.Invalidate();
1581 GitRevLoglist
* prevRev
= nullptr, *curRev
= nullptr;
1583 if( m_CurrentRebaseIndex
>= 0 && m_CurrentRebaseIndex
< m_CommitList
.m_arShownList
.GetSize())
1585 curRev
= (GitRevLoglist
*)m_CommitList
.m_arShownList
[m_CurrentRebaseIndex
];
1588 for (int i
= 0; i
< m_CommitList
.m_arShownList
.GetSize(); ++i
)
1590 prevRev
= (GitRevLoglist
*)m_CommitList
.m_arShownList
[i
];
1591 if (prevRev
->GetRebaseAction() & CGitLogListBase::LOGACTIONS_REBASE_CURRENT
)
1593 prevRev
->GetRebaseAction() &= ~CGitLogListBase::LOGACTIONS_REBASE_CURRENT
;
1594 m_CommitList
.GetItemRect(i
,&rect
,LVIR_BOUNDS
);
1595 m_CommitList
.InvalidateRect(rect
);
1601 curRev
->GetRebaseAction() |= CGitLogListBase::LOGACTIONS_REBASE_CURRENT
;
1602 m_CommitList
.GetItemRect(m_CurrentRebaseIndex
,&rect
,LVIR_BOUNDS
);
1603 m_CommitList
.InvalidateRect(rect
);
1605 m_CommitList
.EnsureVisible(m_CurrentRebaseIndex
,FALSE
);
1608 void CRebaseDlg::UpdateCurrentStatus()
1610 SetContinueButtonText();
1613 if (m_RebaseStage
== REBASE_DONE
)
1614 GetDlgItem(IDC_REBASE_CONTINUE
)->SetFocus();
1617 void CRebaseDlg::AddLogString(CString str
)
1619 this->m_wndOutputRebase
.SendMessage(SCI_SETREADONLY
, FALSE
);
1620 CStringA sTextA
= m_wndOutputRebase
.StringForControl(str
);//CUnicodeUtils::GetUTF8(str);
1621 this->m_wndOutputRebase
.SendMessage(SCI_DOCUMENTEND
);
1622 this->m_wndOutputRebase
.SendMessage(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)sTextA
);
1623 this->m_wndOutputRebase
.SendMessage(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)"\n");
1624 this->m_wndOutputRebase
.SendMessage(SCI_SETREADONLY
, TRUE
);
1627 int CRebaseDlg::GetCurrentCommitID()
1629 if(m_CommitList
.m_IsOldFirst
)
1631 return this->m_CurrentRebaseIndex
+1;
1636 return m_CommitList
.GetItemCount()-m_CurrentRebaseIndex
;
1640 int CRebaseDlg::IsCommitEmpty(const CGitHash
& hash
)
1642 CString cmd
, tree
, ptree
;
1643 cmd
.Format(_T("git.exe rev-parse -q --verify %s^{tree}"), hash
.ToString());
1644 if (g_Git
.Run(cmd
, &tree
, CP_UTF8
))
1650 cmd
.Format(_T("git.exe rev-parse -q --verify %s^^{tree}"), hash
.ToString());
1651 if (g_Git
.Run(cmd
, &ptree
, CP_UTF8
))
1652 ptree
= _T("4b825dc642cb6eb9a060e54bf8d69288fbee4904"); // empty tree
1653 return tree
== ptree
;
1656 int CRebaseDlg::DoRebase()
1659 if(m_CurrentRebaseIndex
<0)
1661 if(m_CurrentRebaseIndex
>= m_CommitList
.GetItemCount() )
1664 GitRevLoglist
* pRev
= (GitRevLoglist
*)m_CommitList
.m_arShownList
[m_CurrentRebaseIndex
];
1665 int mode
= pRev
->GetRebaseAction() & CGitLogListBase::LOGACTIONS_REBASE_MODE_MASK
;
1668 if (mode
== CGitLogListBase::LOGACTIONS_REBASE_SKIP
)
1670 pRev
->GetRebaseAction() |= CGitLogListBase::LOGACTIONS_REBASE_DONE
;
1674 bool nextCommitIsSquash
= (CheckNextCommitIsSquash() == 0);
1675 if (nextCommitIsSquash
|| mode
!= CGitLogListBase::LOGACTIONS_REBASE_PICK
)
1676 { // next commit is squash or not pick
1677 if (!this->m_SquashMessage
.IsEmpty())
1678 this->m_SquashMessage
+= _T("\n\n");
1679 this->m_SquashMessage
+= pRev
->GetSubject();
1680 this->m_SquashMessage
+= _T("\n");
1681 this->m_SquashMessage
+= pRev
->GetBody().TrimRight();
1682 if (m_bAddCherryPickedFrom
)
1684 if (!pRev
->GetBody().IsEmpty())
1685 m_SquashMessage
+= _T("\n");
1686 m_SquashMessage
+= _T("(cherry picked from commit ");
1687 m_SquashMessage
+= pRev
->m_CommitHash
.ToString();
1688 m_SquashMessage
+= _T(")");
1693 this->m_SquashMessage
.Empty();
1694 m_SquashFirstMetaData
.Empty();
1697 if ((nextCommitIsSquash
&& mode
!= CGitLogListBase::LOGACTIONS_REBASE_EDIT
) || mode
== CGitLogListBase::LOGACTIONS_REBASE_SQUASH
)
1698 { // next or this commit is squash (don't do this on edit->squash sequence)
1699 nocommit
=_T(" --no-commit ");
1702 if (nextCommitIsSquash
&& mode
!= CGitLogListBase::LOGACTIONS_REBASE_SQUASH
)
1703 m_SquashFirstMetaData
.Format(_T("--date=%s --author=\"%s <%s>\" "), pRev
->GetAuthorDate().Format(_T("%Y-%m-%dT%H:%M:%S")), pRev
->GetAuthorName(), pRev
->GetAuthorEmail());
1706 log
.Format(_T("%s %d: %s"), CGitLogListBase::GetRebaseActionName(mode
), GetCurrentCommitID(), pRev
->m_CommitHash
.ToString());
1708 AddLogString(pRev
->GetSubject());
1709 if (pRev
->GetSubject().IsEmpty())
1711 CMessageBox::Show(m_hWnd
, IDS_PROC_REBASE_EMPTYCOMMITMSG
, IDS_APPNAME
, MB_OK
| MB_ICONEXCLAMATION
);
1712 mode
= CGitLogListBase::LOGACTIONS_REBASE_EDIT
;
1715 CString cherryPickedFrom
;
1716 if (m_bAddCherryPickedFrom
)
1717 cherryPickedFrom
= _T("-x ");
1718 else if (!m_IsCherryPick
&& nocommit
.IsEmpty())
1719 cherryPickedFrom
= _T("--ff "); // for issue #1833: "If the current HEAD is the same as the parent of the cherry-pick’ed commit, then a fast forward to this commit will be performed."
1721 int isEmpty
= IsCommitEmpty(pRev
->m_CommitHash
);
1723 cherryPickedFrom
+= _T("--allow-empty ");
1724 else if (isEmpty
< 0)
1729 cmd
.Format(_T("git.exe cherry-pick %s%s %s"), cherryPickedFrom
, nocommit
, pRev
->m_CommitHash
.ToString());
1731 if(g_Git
.Run(cmd
,&out
,CP_UTF8
))
1734 int hasConflicts
= g_Git
.HasWorkingTreeConflicts();
1735 if (hasConflicts
< 0)
1737 AddLogString(g_Git
.GetGitLastErr(L
"Checking for conflicts failed.", CGit::GIT_CMD_CHECKCONFLICTS
));
1742 if (mode
== CGitLogListBase::LOGACTIONS_REBASE_PICK
)
1745 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_ERROR
);
1747 if (!m_bAutoSkipFailedCommit
)
1749 choose
= CMessageBox::ShowCheck(m_hWnd
, IDS_CHERRYPICKFAILEDSKIP
, IDS_APPNAME
, 1, IDI_QUESTION
, IDS_SKIPBUTTON
, IDS_MSGBOX_RETRY
, IDS_MSGBOX_CANCEL
, NULL
, IDS_DO_SAME_FOR_REST
, &m_bAutoSkipFailedCommit
);
1752 m_bAutoSkipFailedCommit
= FALSE
;
1753 continue; // retry cherry pick
1756 if (m_bAutoSkipFailedCommit
|| choose
== 1)
1758 bool resetOK
= false;
1762 if (g_Git
.Run(_T("git.exe reset --hard"), &out
, CP_UTF8
))
1765 if (CMessageBox::Show(m_hWnd
, _T("Retry?\nUnrecoverable error on cleanup:\n") + out
, _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
1774 pRev
->GetRebaseAction() = CGitLogListBase::LOGACTIONS_REBASE_SKIP
;
1775 m_CommitList
.Invalidate();
1780 m_RebaseStage
= REBASE_ERROR
;
1781 AddLogString(_T("An unrecoverable error occurred."));
1784 if (mode
== CGitLogListBase::LOGACTIONS_REBASE_EDIT
)
1786 this->m_RebaseStage
= REBASE_EDIT
;
1787 return -1; // Edit return -1 to stop rebase.
1790 if(CheckNextCommitIsSquash())
1792 // let user edit last commmit message
1793 this->m_RebaseStage
= REBASE_SQUASH_EDIT
;
1799 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_ERROR
);
1800 if (mode
== CGitLogListBase::LOGACTIONS_REBASE_SQUASH
)
1801 m_RebaseStage
= REBASE_SQUASH_CONFLICT
;
1803 m_RebaseStage
= REBASE_CONFLICT
;
1810 if (mode
== CGitLogListBase::LOGACTIONS_REBASE_PICK
)
1812 pRev
->GetRebaseAction() |= CGitLogListBase::LOGACTIONS_REBASE_DONE
;
1815 if (mode
== CGitLogListBase::LOGACTIONS_REBASE_EDIT
)
1817 this->m_RebaseStage
= REBASE_EDIT
;
1818 return -1; // Edit return -1 to stop rebase.
1822 if(CheckNextCommitIsSquash())
1824 // let user edit last commmit message
1825 this->m_RebaseStage
= REBASE_SQUASH_EDIT
;
1828 else if (mode
== CGitLogListBase::LOGACTIONS_REBASE_SQUASH
)
1829 pRev
->GetRebaseAction() |= CGitLogListBase::LOGACTIONS_REBASE_DONE
;
1836 BOOL
CRebaseDlg::IsEnd()
1838 if(m_CommitList
.m_IsOldFirst
)
1839 return m_CurrentRebaseIndex
>= this->m_CommitList
.GetItemCount();
1841 return m_CurrentRebaseIndex
<0;
1844 int CRebaseDlg::RebaseThread()
1846 CBlockCacheForPath
cacheBlock(g_Git
.m_CurrentDir
);
1851 if( m_RebaseStage
== REBASE_START
)
1853 if( this->StartRebase() )
1858 m_RebaseStage
= REBASE_CONTINUE
;
1861 else if( m_RebaseStage
== REBASE_CONTINUE
)
1864 SendMessage(MSG_REBASE_UPDATE_UI
);
1868 m_RebaseStage
= REBASE_FINISH
;
1882 else if( m_RebaseStage
== REBASE_FINISH
)
1884 SendMessage(MSG_REBASE_UPDATE_UI
);
1885 m_RebaseStage
= REBASE_DONE
;
1893 this->PostMessage(MSG_REBASE_UPDATE_UI
);
1896 InterlockedExchange(&m_bThreadRunning
, FALSE
);
1897 this->PostMessage(MSG_REBASE_UPDATE_UI
);
1901 void CRebaseDlg::ListConflictFile()
1903 this->m_FileListCtrl
.Clear();
1904 m_FileListCtrl
.SetHasCheckboxes(true);
1909 m_FileListCtrl
.m_bIsRevertTheirMy
= !m_IsCherryPick
;
1911 this->m_FileListCtrl
.GetStatus(&list
,true);
1912 this->m_FileListCtrl
.Show(CTGitPath::LOGACTIONS_UNMERGED
|CTGitPath::LOGACTIONS_MODIFIED
|CTGitPath::LOGACTIONS_ADDED
|CTGitPath::LOGACTIONS_DELETED
,
1913 CTGitPath::LOGACTIONS_UNMERGED
);
1915 m_FileListCtrl
.Check(GITSLC_SHOWFILES
);
1916 bool hasSubmoduleChange
= false;
1917 for (int i
= 0; i
< m_FileListCtrl
.GetItemCount(); i
++)
1919 CTGitPath
*entry
= (CTGitPath
*)m_FileListCtrl
.GetItemData(i
);
1920 if (entry
->IsDirectory())
1922 hasSubmoduleChange
= true;
1927 if (hasSubmoduleChange
)
1929 m_CtrlStatusText
.SetWindowText(m_sStatusText
+ _T(", ") + CString(MAKEINTRESOURCE(IDS_CARE_SUBMODULE_CHANGES
)));
1930 m_bStatusWarning
= true;
1931 m_CtrlStatusText
.Invalidate();
1935 m_CtrlStatusText
.SetWindowText(m_sStatusText
);
1936 m_bStatusWarning
= false;
1937 m_CtrlStatusText
.Invalidate();
1941 LRESULT
CRebaseDlg::OnRebaseUpdateUI(WPARAM
,LPARAM
)
1943 if (m_RebaseStage
== REBASE_FINISH
)
1948 UpdateCurrentStatus();
1949 if (m_RebaseStage
== REBASE_DONE
&& m_pTaskbarList
)
1950 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NOPROGRESS
); // do not show progress on taskbar any more to show we finished
1951 if(m_CurrentRebaseIndex
<0)
1953 if(m_CurrentRebaseIndex
>= m_CommitList
.GetItemCount() )
1955 GitRev
*curRev
=(GitRev
*)m_CommitList
.m_arShownList
[m_CurrentRebaseIndex
];
1957 switch(m_RebaseStage
)
1959 case REBASE_CONFLICT
:
1960 case REBASE_SQUASH_CONFLICT
:
1963 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_CONFLICT
);
1965 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_ERROR
);
1966 this->m_LogMessageCtrl
.Call(SCI_SETREADONLY
, FALSE
);
1971 GitAdminDir::GetAdminDirPath(g_Git
.m_CurrentDir
, dotGitPath
);
1972 // vanilla git also re-uses MERGE_MSG on conflict (listing all conflicted files)
1973 // and it's also needed for cherry-pick in order to get cherry-picked-from included on conflicts
1974 CGit::LoadTextFile(dotGitPath
+ _T("MERGE_MSG"), logMessage
);
1976 if (logMessage
.IsEmpty())
1977 logMessage
= curRev
->GetSubject() + _T("\n") + curRev
->GetBody();
1978 this->m_LogMessageCtrl
.SetText(logMessage
);
1982 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_MESSAGE
);
1984 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_PAUSED
);
1985 this->m_LogMessageCtrl
.Call(SCI_SETREADONLY
, FALSE
);
1986 if (m_bAddCherryPickedFrom
)
1988 // Since the new commit is done and the HEAD points to it,
1989 // just using the new body modified by git self.
1990 GitRev headRevision
;
1991 if (headRevision
.GetCommit(_T("HEAD")))
1992 MessageBox(headRevision
.GetLastErr(), _T("TortoiseGit"), MB_ICONERROR
);
1994 m_LogMessageCtrl
.SetText(headRevision
.GetSubject() + _T("\n") + headRevision
.GetBody());
1997 m_LogMessageCtrl
.SetText(curRev
->GetSubject() + _T("\n") + curRev
->GetBody());
1999 case REBASE_SQUASH_EDIT
:
2000 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_MESSAGE
);
2001 this->m_LogMessageCtrl
.Call(SCI_SETREADONLY
, FALSE
);
2002 this->m_LogMessageCtrl
.SetText(this->m_SquashMessage
);
2004 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_PAUSED
);
2007 this->m_ctrlTabCtrl
.SetActiveTab(REBASE_TAB_LOG
);
2011 void CRebaseDlg::OnCancel()
2015 void CRebaseDlg::OnBnClickedAbort()
2018 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NOPROGRESS
);
2023 if(m_OrigUpstreamHash
.IsEmpty())
2025 __super::OnCancel();
2028 if(m_RebaseStage
== CHOOSE_BRANCH
|| m_RebaseStage
== CHOOSE_COMMIT_PICK_MODE
)
2033 if(CMessageBox::Show(NULL
, IDS_PROC_REBASE_ABORT
, IDS_APPNAME
, MB_YESNO
) != IDYES
)
2036 if(this->m_IsFastForward
)
2038 cmd
.Format(_T("git.exe reset --hard %s --"),this->m_OrigBranchHash
.ToString());
2042 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
2045 if (CMessageBox::Show(m_hWnd
, _T("Retry?\nUnrecoverable error on cleanup:\n") + out
, _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
2051 __super::OnCancel();
2055 if (m_IsCherryPick
) // there are not "branch" at cherry pick mode
2057 cmd
.Format(_T("git.exe reset --hard %s --"), m_OrigUpstreamHash
.ToString());
2061 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
2064 if (CMessageBox::Show(m_hWnd
, _T("Retry?\nUnrecoverable error on cleanup:\n") + out
, _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
2071 __super::OnCancel();
2075 if (m_OrigHEADBranch
== m_BranchCtrl
.GetString())
2077 if (IsLocalBranch(m_OrigHEADBranch
))
2078 cmd
.Format(_T("git.exe checkout -f -B %s %s --"), m_BranchCtrl
.GetString(), m_OrigBranchHash
.ToString());
2080 cmd
.Format(_T("git.exe checkout -f %s --"), m_OrigBranchHash
.ToString());
2081 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
2084 ::MessageBox(m_hWnd
, _T("Unrecoverable error on cleanup:\n") + out
, _T("TortoiseGit"), MB_ICONERROR
);
2085 __super::OnCancel();
2089 cmd
.Format(_T("git.exe reset --hard %s --"), m_OrigBranchHash
.ToString());
2093 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
2096 if (CMessageBox::Show(m_hWnd
, _T("Retry?\nUnrecoverable error on cleanup:\n") + out
, _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
2105 if (m_OrigHEADBranch
!= g_Git
.GetCurrentBranch(true))
2107 if (IsLocalBranch(m_OrigHEADBranch
))
2108 cmd
.Format(_T("git.exe checkout -f -B %s %s --"), m_OrigHEADBranch
, m_OrigHEADHash
.ToString());
2110 cmd
.Format(_T("git.exe checkout -f %s --"), m_OrigHEADHash
.ToString());
2111 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
2114 ::MessageBox(m_hWnd
, _T("Unrecoverable error on cleanup:\n") + out
, _T("TortoiseGit"), MB_ICONERROR
);
2115 // continue to restore moved branch
2119 cmd
.Format(_T("git.exe reset --hard %s --"), m_OrigHEADHash
.ToString());
2123 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
2126 if (CMessageBox::Show(m_hWnd
, _T("Retry?\nUnrecoverable error on cleanup:\n") + out
, _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
2133 // restore moved branch
2134 if (IsLocalBranch(m_BranchCtrl
.GetString()))
2136 cmd
.Format(_T("git.exe branch -f %s %s --"), m_BranchCtrl
.GetString(), m_OrigBranchHash
.ToString());
2137 if (g_Git
.Run(cmd
, &out
, CP_UTF8
))
2140 ::MessageBox(m_hWnd
, _T("Unrecoverable error on cleanup:\n") + out
, _T("TortoiseGit"), MB_ICONERROR
);
2141 __super::OnCancel();
2146 __super::OnCancel();
2148 CheckRestoreStash();
2151 void CRebaseDlg::OnBnClickedButtonReverse()
2153 CString temp
= m_BranchCtrl
.GetString();
2154 m_BranchCtrl
.AddString(m_UpstreamCtrl
.GetString());
2155 m_UpstreamCtrl
.AddString(temp
);
2156 OnCbnSelchangeUpstream();
2159 void CRebaseDlg::OnBnClickedButtonBrowse()
2161 if(CBrowseRefsDlg::PickRefForCombo(&m_UpstreamCtrl
))
2162 OnCbnSelchangeUpstream();
2165 void CRebaseDlg::OnBnClickedRebaseCheckForce()
2168 this->FetchLogList();
2171 void CRebaseDlg::OnBnClickedRebasePostButton()
2173 this->m_Upstream
=this->m_UpstreamCtrl
.GetString();
2174 this->m_Branch
=this->m_BranchCtrl
.GetString();
2176 this->EndDialog((int)(IDC_REBASE_POST_BUTTON
+this->m_PostButton
.GetCurrentEntry()));
2179 LRESULT
CRebaseDlg::OnGitStatusListCtrlNeedsRefresh(WPARAM
, LPARAM
)
2185 void CRebaseDlg::Refresh()
2187 if (m_RebaseStage
== REBASE_CONFLICT
|| m_RebaseStage
== REBASE_SQUASH_CONFLICT
)
2193 if(this->m_IsCherryPick
)
2196 if(this->m_RebaseStage
== CHOOSE_BRANCH
)
2199 this->FetchLogList();
2203 void CRebaseDlg::OnBnClickedButtonUp2()
2206 pos
= m_CommitList
.GetFirstSelectedItemPosition();
2208 // do nothing if the first selected item is the first item in the list
2209 int idx
= m_CommitList
.GetNextSelectedItem(pos
);
2213 bool moveToTop
= !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000);
2214 int move
= moveToTop
? idx
: 1;
2215 pos
= m_CommitList
.GetFirstSelectedItemPosition();
2217 bool changed
= false;
2220 int index
=m_CommitList
.GetNextSelectedItem(pos
);
2223 CGitHash old
= m_CommitList
.m_logEntries
[index
- move
];
2224 m_CommitList
.m_logEntries
[index
- move
] = m_CommitList
.m_logEntries
[index
];
2225 m_CommitList
.m_logEntries
[index
] = old
;
2226 m_CommitList
.RecalculateShownList(&m_CommitList
.m_arShownList
);
2227 m_CommitList
.SetItemState(index
- move
, LVIS_SELECTED
, LVIS_SELECTED
);
2228 m_CommitList
.SetItemState(index
, 0, LVIS_SELECTED
);
2234 pos
= m_CommitList
.GetFirstSelectedItemPosition();
2235 m_CommitList
.EnsureVisible(m_CommitList
.GetNextSelectedItem(pos
), false);
2236 m_CommitList
.Invalidate();
2237 m_CommitList
.SetFocus();
2241 void CRebaseDlg::OnBnClickedButtonDown2()
2243 if (m_CommitList
.GetSelectedCount() == 0)
2246 bool moveToBottom
= !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000);
2248 pos
= m_CommitList
.GetFirstSelectedItemPosition();
2249 bool changed
= false;
2250 // use an array to store all selected item indexes; the user won't select too much items
2251 int* indexes
= NULL
;
2252 indexes
= new int[m_CommitList
.GetSelectedCount()];
2256 indexes
[i
++] = m_CommitList
.GetNextSelectedItem(pos
);
2258 int distanceToBottom
= m_CommitList
.GetItemCount() - 1 - indexes
[m_CommitList
.GetSelectedCount() - 1];
2259 int move
= moveToBottom
? distanceToBottom
: 1;
2260 // don't move any item if the last selected item is the last item in the m_CommitList
2261 // (that would change the order of the selected items)
2262 if (distanceToBottom
> 0)
2264 // iterate over the indexes backwards in order to correctly move multiselected items
2265 for (i
= m_CommitList
.GetSelectedCount() - 1; i
>= 0; i
--)
2267 int index
= indexes
[i
];
2268 CGitHash old
= m_CommitList
.m_logEntries
[index
+ move
];
2269 m_CommitList
.m_logEntries
[index
+ move
] = m_CommitList
.m_logEntries
[index
];
2270 m_CommitList
.m_logEntries
[index
] = old
;
2271 m_CommitList
.RecalculateShownList(&m_CommitList
.m_arShownList
);
2272 m_CommitList
.SetItemState(index
, 0, LVIS_SELECTED
);
2273 m_CommitList
.SetItemState(index
+ move
, LVIS_SELECTED
, LVIS_SELECTED
);
2277 m_CommitList
.EnsureVisible(indexes
[m_CommitList
.GetSelectedCount() - 1] + move
, false);
2282 m_CommitList
.Invalidate();
2283 m_CommitList
.SetFocus();
2287 LRESULT
CRebaseDlg::OnTaskbarBtnCreated(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
2289 m_pTaskbarList
.Release();
2290 m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
);
2291 SetUUIDOverlayIcon(m_hWnd
);
2295 void CRebaseDlg::OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2297 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
2299 if(m_CommitList
.m_bNoDispUpdates
)
2301 if (pNMLV
->iItem
>= 0)
2303 this->m_CommitList
.m_nSearchIndex
= pNMLV
->iItem
;
2304 if (pNMLV
->iSubItem
!= 0)
2306 if ((pNMLV
->iItem
== m_CommitList
.m_arShownList
.GetCount()))
2308 // remove the selected state
2309 if (pNMLV
->uChanged
& LVIF_STATE
)
2311 m_CommitList
.SetItemState(pNMLV
->iItem
, 0, LVIS_SELECTED
);
2312 FillLogMessageCtrl();
2316 if (pNMLV
->uChanged
& LVIF_STATE
)
2318 FillLogMessageCtrl();
2323 FillLogMessageCtrl();
2327 void CRebaseDlg::FillLogMessageCtrl()
2329 int selCount
= m_CommitList
.GetSelectedCount();
2330 if (selCount
== 1 && (m_RebaseStage
== CHOOSE_BRANCH
|| m_RebaseStage
== CHOOSE_COMMIT_PICK_MODE
))
2332 POSITION pos
= m_CommitList
.GetFirstSelectedItemPosition();
2333 int selIndex
= m_CommitList
.GetNextSelectedItem(pos
);
2334 GitRevLoglist
* pLogEntry
= reinterpret_cast<GitRevLoglist
*>(m_CommitList
.m_arShownList
.SafeGetAt(selIndex
));
2335 m_FileListCtrl
.UpdateWithGitPathList(pLogEntry
->GetFiles(&m_CommitList
));
2336 m_FileListCtrl
.m_CurrentVersion
= pLogEntry
->m_CommitHash
;
2337 m_FileListCtrl
.Show(GITSLC_SHOWVERSIONED
);
2338 m_LogMessageCtrl
.Call(SCI_SETREADONLY
, FALSE
);
2339 m_LogMessageCtrl
.SetText(pLogEntry
->GetSubject() + _T("\n") + pLogEntry
->GetBody());
2340 m_LogMessageCtrl
.Call(SCI_SETREADONLY
, TRUE
);
2343 void CRebaseDlg::OnBnClickedCheckCherryPickedFrom()
2348 LRESULT
CRebaseDlg::OnRebaseActionMessage(WPARAM
, LPARAM
)
2350 if (m_RebaseStage
== REBASE_ERROR
|| m_RebaseStage
== REBASE_CONFLICT
)
2352 GitRevLoglist
* pRev
= (GitRevLoglist
*)m_CommitList
.m_arShownList
[m_CurrentRebaseIndex
];
2353 int mode
= pRev
->GetRebaseAction() & CGitLogListBase::LOGACTIONS_REBASE_MODE_MASK
;
2354 if (mode
== CGitLogListBase::LOGACTIONS_REBASE_SKIP
)
2357 bool resetOK
= false;
2361 if (g_Git
.Run(_T("git.exe reset --hard"), &out
, CP_UTF8
))
2364 if (CMessageBox::Show(m_hWnd
, _T("Retry?\nUnrecoverable error on cleanup:\n") + out
, _T("TortoiseGit"), MB_YESNO
| MB_ICONERROR
) != IDYES
)
2373 m_FileListCtrl
.Clear();
2374 m_RebaseStage
= REBASE_CONTINUE
;
2375 UpdateCurrentStatus();
2383 void CRebaseDlg::OnBnClickedSplitAllOptions()
2385 switch (m_SplitAllOptions
.GetCurrentEntry())
2388 SetAllRebaseAction(CGitLogListBase::LOGACTIONS_REBASE_PICK
);
2391 SetAllRebaseAction(CGitLogListBase::LOGACTIONS_REBASE_SQUASH
);
2394 SetAllRebaseAction(CGitLogListBase::LOGACTIONS_REBASE_EDIT
);
2401 void CRebaseDlg::OnBnClickedRebaseSplitCommit()
2406 static bool GetCompareHash(const CString
& ref
, const CGitHash
& hash
)
2409 if (g_Git
.GetHash(refHash
, ref
))
2410 MessageBox(nullptr, g_Git
.GetGitLastErr(_T("Could not get hash of \"") + ref
+ _T("\".")), _T("TortoiseGit"), MB_ICONERROR
);
2411 return refHash
.IsEmpty() || (hash
== refHash
);
2414 void CRebaseDlg::OnBnClickedButtonOnto()
2416 m_Onto
= CBrowseRefsDlg::PickRef(false, m_Onto
);
2417 if (!m_Onto
.IsEmpty())
2419 // make sure that the user did not select upstream, selected branch or HEAD
2421 if (g_Git
.GetHash(hash
, m_Onto
))
2423 MessageBox(g_Git
.GetGitLastErr(_T("Could not get hash of \"") + m_BranchCtrl
.GetString() + _T("\".")), _T("TortoiseGit"), MB_ICONERROR
);
2425 ((CButton
*)GetDlgItem(IDC_BUTTON_ONTO
))->SetCheck(m_Onto
.IsEmpty() ? BST_UNCHECKED
: BST_CHECKED
);
2428 if (GetCompareHash(_T("HEAD"), hash
) || GetCompareHash(m_UpstreamCtrl
.GetString(), hash
) || GetCompareHash(m_BranchCtrl
.GetString(), hash
))
2431 if (m_Onto
.IsEmpty())
2432 m_tooltips
.DelTool(IDC_BUTTON_ONTO
);
2434 m_tooltips
.AddTool(IDC_BUTTON_ONTO
, m_Onto
);
2435 ((CButton
*)GetDlgItem(IDC_BUTTON_ONTO
))->SetCheck(m_Onto
.IsEmpty() ? BST_UNCHECKED
: BST_CHECKED
);