Enable F5 refresh in RebaseDlg for conflicted files list
[TortoiseGit.git] / src / TortoiseProc / RebaseDlg.cpp
blob4d5e14e5ea6bf63bb8561363652729fc96596e78
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2011-2012 - Sven Strickroth <email@cs-ware.de>
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 // RebaseDlg.cpp : implementation file
24 #include "stdafx.h"
25 #include "TortoiseProc.h"
26 #include "RebaseDlg.h"
27 #include "AppUtils.h"
28 #include "LoglistUtils.h"
29 #include "MessageBox.h"
30 #include "UnicodeUtils.h"
31 #include "BrowseRefsDlg.h"
32 #include "ProgressDlg.h"
33 #include "SmartHandle.h"
34 #include "../TGitCache/CacheInterface.h"
35 #include "Settings\Settings.h"
37 // CRebaseDlg dialog
39 IMPLEMENT_DYNAMIC(CRebaseDlg, CResizableStandAloneDialog)
41 CRebaseDlg::CRebaseDlg(CWnd* pParent /*=NULL*/)
42 : CResizableStandAloneDialog(CRebaseDlg::IDD, pParent)
43 , m_bPickAll(FALSE)
44 , m_bSquashAll(FALSE)
45 , m_bEditAll(FALSE)
46 , m_bAddCherryPickedFrom(FALSE)
48 m_RebaseStage=CHOOSE_BRANCH;
49 m_CurrentRebaseIndex=-1;
50 m_bThreadRunning =FALSE;
51 this->m_IsCherryPick = FALSE;
52 m_bForce=FALSE;
53 m_IsFastForward=FALSE;
56 CRebaseDlg::~CRebaseDlg()
60 void CRebaseDlg::DoDataExchange(CDataExchange* pDX)
62 CDialog::DoDataExchange(pDX);
63 DDX_Control(pDX, IDC_REBASE_PROGRESS, m_ProgressBar);
64 DDX_Control(pDX, IDC_STATUS_STATIC, m_CtrlStatusText);
65 DDX_Check(pDX, IDC_PICK_ALL, m_bPickAll);
66 DDX_Check(pDX, IDC_SQUASH_ALL, m_bSquashAll);
67 DDX_Check(pDX, IDC_EDIT_ALL, m_bEditAll);
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);
78 BEGIN_MESSAGE_MAP(CRebaseDlg, CResizableStandAloneDialog)
79 ON_BN_CLICKED(IDC_PICK_ALL, &CRebaseDlg::OnBnClickedPickAll)
80 ON_BN_CLICKED(IDC_SQUASH_ALL, &CRebaseDlg::OnBnClickedSquashAll)
81 ON_BN_CLICKED(IDC_EDIT_ALL, &CRebaseDlg::OnBnClickedEditAll)
82 ON_BN_CLICKED(IDC_REBASE_SPLIT, &CRebaseDlg::OnBnClickedRebaseSplit)
83 ON_BN_CLICKED(IDC_REBASE_CONTINUE,OnBnClickedContinue)
84 ON_BN_CLICKED(IDC_REBASE_ABORT, OnBnClickedAbort)
85 ON_WM_SIZE()
86 ON_CBN_SELCHANGE(IDC_REBASE_COMBOXEX_BRANCH, &CRebaseDlg::OnCbnSelchangeBranch)
87 ON_CBN_SELCHANGE(IDC_REBASE_COMBOXEX_UPSTREAM, &CRebaseDlg::OnCbnSelchangeUpstream)
88 ON_MESSAGE(MSG_REBASE_UPDATE_UI, OnRebaseUpdateUI)
89 ON_BN_CLICKED(IDC_BUTTON_BROWSE, &CRebaseDlg::OnBnClickedButtonBrowse)
90 ON_BN_CLICKED(IDC_REBASE_CHECK_FORCE, &CRebaseDlg::OnBnClickedRebaseCheckForce)
91 ON_BN_CLICKED(IDC_CHECK_CHERRYPICKED_FROM, &CRebaseDlg::OnBnClickedCheckCherryPickedFrom)
92 ON_BN_CLICKED(IDC_REBASE_POST_BUTTON, &CRebaseDlg::OnBnClickedRebasePostButton)
93 ON_BN_CLICKED(IDC_BUTTON_UP2, &CRebaseDlg::OnBnClickedButtonUp2)
94 ON_BN_CLICKED(IDC_BUTTON_DOWN2, &CRebaseDlg::OnBnClickedButtonDown2)
95 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED, OnTaskbarBtnCreated)
96 ON_NOTIFY(LVN_ITEMCHANGED, IDC_COMMIT_LIST, OnLvnItemchangedLoglist)
97 END_MESSAGE_MAP()
99 void CRebaseDlg::AddRebaseAnchor()
101 AddAnchor(IDC_REBASE_TAB,TOP_LEFT,BOTTOM_RIGHT);
102 AddAnchor(IDC_COMMIT_LIST,TOP_LEFT, TOP_RIGHT);
103 AddAnchor(IDC_REBASE_SPLIT,TOP_LEFT, TOP_RIGHT);
104 AddAnchor(IDC_STATUS_STATIC, BOTTOM_LEFT,BOTTOM_RIGHT);
105 AddAnchor(IDC_REBASE_CONTINUE,BOTTOM_RIGHT);
106 AddAnchor(IDC_REBASE_ABORT, BOTTOM_RIGHT);
107 AddAnchor(IDC_REBASE_PROGRESS,BOTTOM_LEFT, BOTTOM_RIGHT);
108 AddAnchor(IDC_PICK_ALL,TOP_LEFT);
109 AddAnchor(IDC_SQUASH_ALL,TOP_LEFT);
110 AddAnchor(IDC_EDIT_ALL,TOP_LEFT);
111 AddAnchor(IDC_BUTTON_UP2,TOP_LEFT);
112 AddAnchor(IDC_BUTTON_DOWN2,TOP_LEFT);
113 AddAnchor(IDC_REBASE_COMBOXEX_UPSTREAM,TOP_LEFT);
114 AddAnchor(IDC_REBASE_COMBOXEX_BRANCH,TOP_LEFT);
115 AddAnchor(IDC_REBASE_STATIC_UPSTREAM,TOP_LEFT);
116 AddAnchor(IDC_REBASE_STATIC_BRANCH,TOP_LEFT);
117 AddAnchor(IDHELP, BOTTOM_RIGHT);
118 AddAnchor(IDC_REBASE_CHECK_FORCE,TOP_RIGHT);
119 AddAnchor(IDC_CHECK_CHERRYPICKED_FROM, TOP_RIGHT);
120 AddAnchor(IDC_REBASE_POST_BUTTON,BOTTOM_LEFT);
122 this->AddOthersToAnchor();
125 BOOL CRebaseDlg::OnInitDialog()
127 CResizableStandAloneDialog::OnInitDialog();
128 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
130 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
131 // do this, Explorer would be unable to send that message to our window if we
132 // were running elevated. It's OK to make the call all the time, since if we're
133 // not elevated, this is a no-op.
134 CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) };
135 typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct);
136 CAutoLibrary hUser = ::LoadLibrary(_T("user32.dll"));
137 if (hUser)
139 ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx");
140 if (pfnChangeWindowMessageFilterEx)
142 pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs);
145 m_pTaskbarList.Release();
146 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
148 CRect rectDummy;
149 //IDC_REBASE_DUMY_TAB
151 GetClientRect(m_DlgOrigRect);
152 m_CommitList.GetClientRect(m_CommitListOrigRect);
154 CWnd *pwnd=this->GetDlgItem(IDC_REBASE_DUMY_TAB);
155 pwnd->GetWindowRect(&rectDummy);
156 this->ScreenToClient(rectDummy);
158 if (!m_ctrlTabCtrl.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, IDC_REBASE_TAB))
160 TRACE0("Failed to create output tab window\n");
161 return FALSE; // fail to create
163 m_ctrlTabCtrl.SetResizeMode(CMFCTabCtrl::RESIZE_NO);
164 // Create output panes:
165 //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
166 DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE;
168 if (! this->m_FileListCtrl.Create(dwStyle,rectDummy,&this->m_ctrlTabCtrl,0) )
170 TRACE0("Failed to create output windows\n");
171 return FALSE; // fail to create
174 if( ! this->m_LogMessageCtrl.Create(_T("Scintilla"),_T("source"),0,rectDummy,&m_ctrlTabCtrl,0,0) )
176 TRACE0("Failed to create log message control");
177 return FALSE;
179 m_LogMessageCtrl.Init(0);
180 m_LogMessageCtrl.Call(SCI_SETREADONLY, TRUE);
182 dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
184 if (!m_wndOutputRebase.Create(_T("Scintilla"),_T("source"),0,rectDummy, &m_ctrlTabCtrl, 0,0) )
186 TRACE0("Failed to create output windows\n");
187 return -1; // fail to create
189 m_wndOutputRebase.Init(0);
190 m_wndOutputRebase.Call(SCI_SETREADONLY, TRUE);
192 m_tooltips.Create(this);
194 m_tooltips.AddTool(IDC_REBASE_CHECK_FORCE,IDS_REBASE_FORCE_TT);
195 m_tooltips.AddTool(IDC_REBASE_ABORT,IDS_REBASE_ABORT_TT);
199 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);
201 m_ctrlTabCtrl.AddTab(&m_FileListCtrl, CString(MAKEINTRESOURCE(IDS_PROC_REVISIONFILES)));
202 m_ctrlTabCtrl.AddTab(&m_LogMessageCtrl, CString(MAKEINTRESOURCE(IDS_PROC_COMMITMESSAGE)), 1);
203 AddRebaseAnchor();
205 AdjustControlSize(IDC_PICK_ALL);
206 AdjustControlSize(IDC_SQUASH_ALL);
207 AdjustControlSize(IDC_EDIT_ALL);
208 AdjustControlSize(IDC_CHECK_CHERRYPICKED_FROM);
210 CString sWindowTitle;
211 GetWindowText(sWindowTitle);
212 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
214 EnableSaveRestore(_T("RebaseDlg"));
216 DWORD yPos = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\RebaseDlgSizer"));
217 RECT rcDlg, rcLogMsg, rcFileList;
218 GetClientRect(&rcDlg);
219 m_CommitList.GetWindowRect(&rcLogMsg);
220 ScreenToClient(&rcLogMsg);
221 this->m_ctrlTabCtrl.GetWindowRect(&rcFileList);
222 ScreenToClient(&rcFileList);
223 if (yPos)
225 RECT rectSplitter;
226 m_wndSplitter.GetWindowRect(&rectSplitter);
227 ScreenToClient(&rectSplitter);
228 int delta = yPos - rectSplitter.top;
229 if ((rcLogMsg.bottom + delta > rcLogMsg.top)&&(rcLogMsg.bottom + delta < rcFileList.bottom - 30))
231 m_wndSplitter.SetWindowPos(NULL, 0, yPos, 0, 0, SWP_NOSIZE);
232 DoSize(delta);
236 if( this->m_RebaseStage == CHOOSE_BRANCH)
238 this->LoadBranchInfo();
241 else
243 this->m_BranchCtrl.EnableWindow(FALSE);
244 this->m_UpstreamCtrl.EnableWindow(FALSE);
247 m_CommitList.m_ColumnRegKey = _T("Rebase");
248 m_CommitList.m_IsIDReplaceAction = TRUE;
249 // m_CommitList.m_IsOldFirst = TRUE;
250 m_CommitList.m_IsRebaseReplaceGraph = TRUE;
251 m_CommitList.m_bNoHightlightHead = TRUE;
253 m_CommitList.InsertGitColumn();
255 this->SetControlEnable();
257 if(!this->m_PreCmd.IsEmpty())
259 CProgressDlg progress;
260 progress.m_GitCmd=m_PreCmd;
261 progress.m_bAutoCloseOnSuccess=true;
262 progress.DoModal();
265 if(m_IsCherryPick)
267 this->m_BranchCtrl.SetCurSel(-1);
268 this->m_BranchCtrl.EnableWindow(FALSE);
269 GetDlgItem(IDC_REBASE_CHECK_FORCE)->ShowWindow(SW_HIDE);
270 GetDlgItem(IDC_BUTTON_BROWSE)->EnableWindow(FALSE);
271 this->m_UpstreamCtrl.AddString(_T("HEAD"));
272 this->m_UpstreamCtrl.EnableWindow(FALSE);
273 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, CString(MAKEINTRESOURCE(IDS_PROGS_TITLE_CHERRYPICK)));
274 this->m_CommitList.StartFilter();
276 else
278 GetDlgItem(IDC_CHECK_CHERRYPICKED_FROM)->ShowWindow(SW_HIDE);
279 SetContinueButtonText();
280 m_CommitList.DeleteAllItems();
281 FetchLogList();
284 m_CommitList.m_ContextMenuMask &= ~(m_CommitList.GetContextMenuBit(CGitLogListBase::ID_CHERRY_PICK)|
285 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_SWITCHTOREV)|
286 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_RESET)|
287 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_REVERTREV)|
288 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_REBASE_TO_VERSION)|
289 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_REVERTTOREV)|
290 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_COMBINE_COMMIT));
292 if(m_CommitList.m_IsOldFirst)
293 this->m_CurrentRebaseIndex = -1;
294 else
295 this->m_CurrentRebaseIndex = (int)m_CommitList.m_logEntries.size();
298 if(this->CheckRebaseCondition())
300 /* Disable Start Rebase */
301 this->GetDlgItem(IDC_REBASE_CONTINUE)->EnableWindow(FALSE);
304 return TRUE;
306 // CRebaseDlg message handlers
308 void CRebaseDlg::OnBnClickedPickAll()
310 this->UpdateData();
311 if(this->m_bPickAll)
312 this->SetAllRebaseAction(CTGitPath::LOGACTIONS_REBASE_PICK);
314 this->m_bEditAll=FALSE;
315 this->m_bSquashAll=FALSE;
316 this->UpdateData(FALSE);
319 void CRebaseDlg::OnBnClickedSquashAll()
321 this->UpdateData();
322 if(this->m_bSquashAll)
323 this->SetAllRebaseAction(CTGitPath::LOGACTIONS_REBASE_SQUASH);
325 this->m_bEditAll=FALSE;
326 this->m_bPickAll=FALSE;
327 this->UpdateData(FALSE);
330 void CRebaseDlg::OnBnClickedEditAll()
332 this->UpdateData();
333 if( this->m_bEditAll )
334 this->SetAllRebaseAction(CTGitPath::LOGACTIONS_REBASE_EDIT);
336 this->m_bPickAll=FALSE;
337 this->m_bSquashAll=FALSE;
338 this->UpdateData(FALSE);
341 void CRebaseDlg::SetAllRebaseAction(int action)
343 for(int i=0;i<this->m_CommitList.m_logEntries.size();i++)
345 m_CommitList.m_logEntries.GetGitRevAt(i).GetAction(&m_CommitList)=action;
347 m_CommitList.Invalidate();
350 void CRebaseDlg::OnBnClickedRebaseSplit()
352 this->UpdateData();
355 LRESULT CRebaseDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
357 switch (message) {
358 case WM_NOTIFY:
359 if (wParam == IDC_REBASE_SPLIT)
361 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
362 DoSize(pHdr->delta);
364 break;
367 return __super::DefWindowProc(message, wParam, lParam);
370 void CRebaseDlg::DoSize(int delta)
372 this->RemoveAllAnchors();
374 CSplitterControl::ChangeHeight(GetDlgItem(IDC_COMMIT_LIST), delta, CW_TOPALIGN);
375 //CSplitterControl::ChangeHeight(GetDlgItem(), delta, CW_TOPALIGN);
376 CSplitterControl::ChangeHeight(GetDlgItem(IDC_REBASE_TAB), -delta, CW_BOTTOMALIGN);
377 //CSplitterControl::ChangeHeight(GetDlgItem(), -delta, CW_BOTTOMALIGN);
378 CSplitterControl::ChangePos(GetDlgItem(IDC_SQUASH_ALL),0,delta);
379 CSplitterControl::ChangePos(GetDlgItem(IDC_PICK_ALL),0,delta);
380 CSplitterControl::ChangePos(GetDlgItem(IDC_EDIT_ALL),0,delta);
381 CSplitterControl::ChangePos(GetDlgItem(IDC_BUTTON_UP2),0,delta);
382 CSplitterControl::ChangePos(GetDlgItem(IDC_BUTTON_DOWN2),0,delta);
383 CSplitterControl::ChangePos(GetDlgItem(IDC_REBASE_CHECK_FORCE),0,delta);
385 this->AddRebaseAnchor();
386 // adjust the minimum size of the dialog to prevent the resizing from
387 // moving the list control too far down.
388 CRect rcLogMsg;
389 m_CommitList.GetClientRect(rcLogMsg);
390 SetMinTrackSize(CSize(m_DlgOrigRect.Width(), m_DlgOrigRect.Height()-m_CommitListOrigRect.Height()+rcLogMsg.Height()));
392 SetSplitterRange();
393 // m_CommitList.Invalidate();
395 // GetDlgItem(IDC_LOGMESSAGE)->Invalidate();
397 this->m_ctrlTabCtrl.Invalidate();
398 this->m_CommitList.Invalidate();
399 this->m_FileListCtrl.Invalidate();
400 this->m_LogMessageCtrl.Invalidate();
404 void CRebaseDlg::SetSplitterRange()
406 if ((m_CommitList)&&(m_ctrlTabCtrl))
408 CRect rcTop;
409 m_CommitList.GetWindowRect(rcTop);
410 ScreenToClient(rcTop);
411 CRect rcMiddle;
412 m_ctrlTabCtrl.GetWindowRect(rcMiddle);
413 ScreenToClient(rcMiddle);
414 if (rcMiddle.Height() && rcMiddle.Width())
415 m_wndSplitter.SetRange(rcTop.top+60, rcMiddle.bottom-80);
419 void CRebaseDlg::OnSize(UINT nType,int cx, int cy)
421 // first, let the resizing take place
422 __super::OnSize(nType, cx, cy);
424 //set range
425 SetSplitterRange();
428 void CRebaseDlg::SaveSplitterPos()
430 if (!IsIconic())
432 CRegDWORD regPos = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\RebaseDlgSizer"));
433 RECT rectSplitter;
434 m_wndSplitter.GetWindowRect(&rectSplitter);
435 ScreenToClient(&rectSplitter);
436 regPos = rectSplitter.top;
440 void CRebaseDlg::LoadBranchInfo()
442 m_BranchCtrl.SetMaxHistoryItems(0x7FFFFFFF);
443 m_UpstreamCtrl.SetMaxHistoryItems(0x7FFFFFFF);
445 STRING_VECTOR list;
446 list.clear();
447 int current;
448 g_Git.GetBranchList(list,&current,CGit::BRANCH_ALL);
449 m_BranchCtrl.AddString(list);
450 m_BranchCtrl.SetCurSel(current);
451 list.clear();
452 g_Git.GetBranchList(list, NULL, CGit::BRANCH_ALL_F);
453 m_UpstreamCtrl.AddString(list);
455 AddBranchToolTips(&m_BranchCtrl);
456 AddBranchToolTips(&m_UpstreamCtrl);
458 if(!m_Upstream.IsEmpty())
460 m_UpstreamCtrl.AddString(m_Upstream);
461 m_UpstreamCtrl.SetCurSel(m_UpstreamCtrl.GetCount()-1);
463 else
465 //Select pull-remote from current branch
466 CString currentBranch = g_Git.GetSymbolicRef();
467 CString configName;
468 configName.Format(L"branch.%s.remote", currentBranch);
469 CString pullRemote = g_Git.GetConfigValue(configName);
471 //Select pull-branch from current branch
472 configName.Format(L"branch.%s.merge", currentBranch);
473 CString pullBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));
475 CString defaultUpstream;
476 defaultUpstream.Format(L"remotes/%s/%s", pullRemote, pullBranch);
477 int found = m_UpstreamCtrl.FindStringExact(0, defaultUpstream);
478 if(found >= 0)
479 m_UpstreamCtrl.SetCurSel(found);
480 else
481 m_UpstreamCtrl.SetCurSel(-1);
485 void CRebaseDlg::OnCbnSelchangeBranch()
487 FetchLogList();
490 void CRebaseDlg::OnCbnSelchangeUpstream()
492 FetchLogList();
495 void CRebaseDlg::FetchLogList()
497 CGitHash base,hash;
498 m_IsFastForward=FALSE;
500 hash=g_Git.GetHash(m_BranchCtrl.GetString());
502 if(hash == g_Git.GetHash(this->m_UpstreamCtrl.GetString()))
504 m_CommitList.Clear();
505 CString text,fmt;
506 fmt.LoadString(IDS_REBASE_EQUAL_FMT);
507 text.Format(fmt,m_BranchCtrl.GetString(),this->m_UpstreamCtrl.GetString());
509 m_CommitList.ShowText(text);
510 this->GetDlgItem(IDC_REBASE_CONTINUE)->EnableWindow(false);
511 return;
514 if (g_Git.IsFastForward(m_BranchCtrl.GetString(), m_UpstreamCtrl.GetString(), &base))
516 //fast forword
517 this->m_IsFastForward=TRUE;
519 m_CommitList.Clear();
520 CString text,fmt;
521 fmt.LoadString(IDS_REBASE_FASTFORWARD_FMT);
522 text.Format(fmt,m_BranchCtrl.GetString(),this->m_UpstreamCtrl.GetString(),
523 m_BranchCtrl.GetString(),this->m_UpstreamCtrl.GetString());
525 m_CommitList.ShowText(text);
526 this->GetDlgItem(IDC_REBASE_CONTINUE)->EnableWindow(true);
527 SetContinueButtonText();
529 return ;
532 hash.Empty();
534 if(!this->m_bForce)
536 hash=g_Git.GetHash(m_UpstreamCtrl.GetString());
538 if( base == hash )
540 m_CommitList.Clear();
541 CString text,fmt;
542 fmt.LoadString(IDS_REBASE_UPTODATE_FMT);
543 text.Format(fmt,m_BranchCtrl.GetString());
544 m_CommitList.ShowText(text);
545 this->GetDlgItem(IDC_REBASE_CONTINUE)->EnableWindow(m_CommitList.GetItemCount());
546 SetContinueButtonText();
547 return;
551 m_CommitList.Clear();
552 CString from,to;
553 from = m_UpstreamCtrl.GetString();
554 to = m_BranchCtrl.GetString();
555 this->m_CommitList.FillGitLog(NULL,0,&from,&to);
557 if( m_CommitList.GetItemCount() == 0 )
558 m_CommitList.ShowText(CString(MAKEINTRESOURCE(IDS_PROC_NOTHINGTOREBASE)));
560 hash=g_Git.GetHash(m_UpstreamCtrl.GetString());
562 #if 0
563 if(m_CommitList.m_logEntries[m_CommitList.m_logEntries.size()-1].m_ParentHash.size() >=0 )
565 if(hash == m_CommitList.m_logEntries[m_CommitList.m_logEntries.size()-1].m_ParentHash[0])
567 m_CommitList.Clear();
568 m_CommitList.ShowText(_T("Nothing Rebase"));
571 #endif
573 m_tooltips.Pop();
574 AddBranchToolTips(&this->m_BranchCtrl);
575 AddBranchToolTips(&this->m_UpstreamCtrl);
577 for(int i=0;i<m_CommitList.m_logEntries.size();i++)
579 m_CommitList.m_logEntries.GetGitRevAt(i).GetAction(&m_CommitList) = CTGitPath::LOGACTIONS_REBASE_PICK;
582 m_CommitList.Invalidate();
584 if(m_CommitList.m_IsOldFirst)
585 this->m_CurrentRebaseIndex = -1;
586 else
587 this->m_CurrentRebaseIndex = (int)m_CommitList.m_logEntries.size();
589 this->GetDlgItem(IDC_REBASE_CONTINUE)->EnableWindow(m_CommitList.GetItemCount());
590 SetContinueButtonText();
593 void CRebaseDlg::AddBranchToolTips(CHistoryCombo *pBranch)
595 if(pBranch)
597 CString text=pBranch->GetString();
598 CString tooltip;
600 GitRev rev;
601 rev.GetCommit(text);
603 tooltip.Format(_T("%s: %s\n%s: %s <%s>\n%s: %s\n%s:\n%s\n%s"),
604 CString(MAKEINTRESOURCE(IDS_LOG_REVISION)),
605 rev.m_CommitHash.ToString(),
606 CString(MAKEINTRESOURCE(IDS_LOG_AUTHOR)),
607 rev.GetAuthorName(),
608 rev.GetAuthorEmail(),
609 CString(MAKEINTRESOURCE(IDS_LOG_DATE)),
610 CLoglistUtils::FormatDateAndTime(rev.GetAuthorDate(), DATE_LONGDATE),
611 CString(MAKEINTRESOURCE(IDS_LOG_MESSAGE)),
612 rev.GetSubject(),
613 rev.GetBody());
615 pBranch->DisableTooltip();
616 this->m_tooltips.AddTool(pBranch->GetComboBoxCtrl(),tooltip);
620 BOOL CRebaseDlg::PreTranslateMessage(MSG*pMsg)
622 if (pMsg->message == WM_KEYDOWN)
624 switch (pMsg->wParam)
626 case ' ':
627 if(LogListHasFocus(pMsg->hwnd))
629 m_CommitList.ShiftSelectedAction();
630 return TRUE;
632 break;
633 case 'P':
634 if(LogListHasFocus(pMsg->hwnd))
636 m_CommitList.SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_PICK);
637 return TRUE;
639 break;
640 case 'S':
641 if(LogListHasFocus(pMsg->hwnd))
643 m_CommitList.SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_SKIP);
644 return TRUE;
646 break;
647 case 'Q':
648 if(LogListHasFocus(pMsg->hwnd))
650 m_CommitList.SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_SQUASH);
651 return TRUE;
653 break;
654 case 'E':
655 if(LogListHasFocus(pMsg->hwnd))
657 m_CommitList.SetSelectedAction(CTGitPath::LOGACTIONS_REBASE_EDIT);
658 return TRUE;
660 break;
661 case 'A':
662 if(LogListHasFocus(pMsg->hwnd) && GetAsyncKeyState(VK_CONTROL) & 0x8000)
664 // select all entries
665 for (int i = 0; i < m_CommitList.GetItemCount(); ++i)
667 m_CommitList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
669 return TRUE;
671 break;
672 case VK_F5:
674 Refresh();
675 return TRUE;
677 break;
678 case VK_RETURN:
680 if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
682 if (GetDlgItem(IDC_REBASE_CONTINUE)->IsWindowEnabled())
683 GetDlgItem(IDC_REBASE_CONTINUE)->SetFocus();
684 else if (GetDlgItem(IDC_REBASE_ABORT)->IsWindowEnabled())
685 GetDlgItem(IDC_REBASE_ABORT)->SetFocus();
686 else
687 GetDlgItem(IDHELP)->SetFocus();
688 return TRUE;
691 break;
692 /* Avoid TAB control destroy but dialog exist*/
693 case VK_ESCAPE:
694 case VK_CANCEL:
696 TCHAR buff[128];
697 ::GetClassName(pMsg->hwnd,buff,128);
700 if(_tcsnicmp(buff,_T("RichEdit20W"),128)==0 ||
701 _tcsnicmp(buff,_T("Scintilla"),128)==0 ||
702 _tcsnicmp(buff,_T("SysListView32"),128)==0||
703 ::GetParent(pMsg->hwnd) == this->m_ctrlTabCtrl.m_hWnd)
705 this->PostMessage(WM_KEYDOWN,VK_ESCAPE,0);
706 return TRUE;
711 else if (pMsg->message == WM_NEXTDLGCTL)
713 if (GetFocus()->GetSafeHwnd() == m_LogMessageCtrl.GetSafeHwnd())
715 if (GetDlgItem(IDC_REBASE_CONTINUE)->IsWindowEnabled())
716 GetDlgItem(IDC_REBASE_CONTINUE)->SetFocus();
717 else if (GetDlgItem(IDC_REBASE_ABORT)->IsWindowEnabled())
718 GetDlgItem(IDC_REBASE_ABORT)->SetFocus();
719 else
720 GetDlgItem(IDHELP)->SetFocus();
721 return TRUE;
724 m_tooltips.RelayEvent(pMsg);
725 return CResizableStandAloneDialog::PreTranslateMessage(pMsg);
728 bool CRebaseDlg::LogListHasFocus(HWND hwnd)
730 TCHAR buff[128];
731 ::GetClassName(hwnd, buff, 128);
733 if(_tcsnicmp(buff, _T("SysListView32"), 128) == 0)
734 return true;
735 return false;
738 int CRebaseDlg::CheckRebaseCondition()
740 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_LOG);
742 if( !g_Git.CheckCleanWorkTree() )
744 if (CMessageBox::Show(NULL, IDS_ERROR_NOCLEAN_STASH, IDS_APPNAME, 1, IDI_QUESTION, IDS_STASHBUTTON, IDS_ABORTBUTTON) == 1)
746 CString cmd,out;
747 cmd=_T("git.exe stash");
748 this->AddLogString(cmd);
749 if (g_Git.Run(cmd, &out, CP_UTF8))
751 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);
752 return -1;
756 else
757 return -1;
759 //Todo Check $REBASE_ROOT
760 //Todo Check $DOTEST
762 while (g_Git.GetUserName().IsEmpty() || g_Git.GetUserEmail().IsEmpty())
764 if (CMessageBox::Show(NULL, IDS_PROC_NOUSERDATA, IDS_APPNAME, MB_YESNO | MB_ICONERROR) == IDYES)
766 CTGitPath path(g_Git.m_CurrentDir);
767 CSettings dlg(IDS_PROC_SETTINGS_TITLE, &path);
768 dlg.SetTreeViewMode(TRUE, TRUE, TRUE);
769 dlg.SetTreeWidth(220);
770 dlg.m_DefaultPage = _T("gitconfig");
771 dlg.DoModal();
772 dlg.HandleRestart();
774 else
775 return -1;
778 //Todo call pre_rebase_hook
779 return 0;
781 int CRebaseDlg::StartRebase()
783 CString cmd,out;
784 m_FileListCtrl.m_bIsRevertTheirMy = !m_IsCherryPick;
785 if(!this->m_IsCherryPick)
787 //Todo call comment_for_reflog
788 cmd.Format(_T("git.exe checkout %s"),this->m_BranchCtrl.GetString());
789 this->AddLogString(cmd);
791 if(g_Git.Run(cmd,&out,CP_UTF8))
793 this->AddLogString(out);
794 return -1;
797 this->AddLogString(out);
800 cmd=_T("git.exe rev-parse --verify HEAD");
801 if(g_Git.Run(cmd,&out,CP_UTF8))
803 AddLogString(CString(MAKEINTRESOURCE(IDS_PROC_NOHEAD)));
804 return -1;
806 //Todo
807 //git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
808 // echo "detached HEAD" > "$DOTEST"/head-name
810 cmd.Format(_T("git.exe update-ref ORIG_HEAD HEAD"));
811 if(g_Git.Run(cmd,&out,CP_UTF8))
813 AddLogString(_T("update ORIG_HEAD Fail"));
814 return -1;
817 m_OrigUpstreamHash.Empty();
818 m_OrigUpstreamHash= g_Git.GetHash(this->m_UpstreamCtrl.GetString());
819 if(m_OrigUpstreamHash.IsEmpty())
821 this->AddLogString(m_OrigUpstreamHash);
822 return -1;
825 if( !this->m_IsCherryPick )
827 cmd.Format(_T("git.exe checkout -f %s"), m_OrigUpstreamHash.ToString());
828 this->AddLogString(cmd);
830 out.Empty();
831 if(g_Git.Run(cmd,&out,CP_UTF8))
833 this->AddLogString(out);
834 return -1;
838 CString log;
839 if( !this->m_IsCherryPick )
841 m_OrigBranchHash = g_Git.GetHash(this->m_BranchCtrl.GetString());
842 if(m_OrigBranchHash.IsEmpty())
844 this->AddLogString(m_OrigBranchHash.ToString());
845 return -1;
847 log.Format(_T("%s\r\n"), CString(MAKEINTRESOURCE(IDS_PROC_REBASE_STARTREBASE)));
849 else
850 log.Format(_T("%s\r\n"), CString(MAKEINTRESOURCE(IDS_PROC_REBASE_STARTCHERRYPICK)));
852 this->AddLogString(log);
853 return 0;
855 int CRebaseDlg::VerifyNoConflict()
857 CTGitPathList list;
858 if(g_Git.ListConflictFile(list))
860 AddLogString(_T("Get conflict files fail"));
861 return -1;
863 if( list.GetCount() != 0 )
865 CMessageBox::Show(NULL, IDS_PROGRS_CONFLICTSOCCURED, IDS_APPNAME, MB_OK);
866 return -1;
868 return 0;
871 int CRebaseDlg::FinishRebase()
873 if(this->m_IsCherryPick) //cherry pick mode no "branch", working at upstream branch
874 return 0;
876 git_revnum_t head = g_Git.GetHash(_T("HEAD"));
877 CString out,cmd;
879 out.Empty();
880 cmd.Format(_T("git.exe checkout -f %s"),this->m_BranchCtrl.GetString());
881 AddLogString(cmd);
882 if(g_Git.Run(cmd,&out,CP_UTF8))
884 AddLogString(out);
885 return -1;
887 AddLogString(out);
889 out.Empty();
890 cmd.Format(_T("git.exe reset --hard %s"),head);
891 AddLogString(cmd);
892 if(g_Git.Run(cmd,&out,CP_UTF8))
894 AddLogString(out);
895 return -1;
897 AddLogString(out);
899 m_ctrlTabCtrl.RemoveTab(0);
900 m_ctrlTabCtrl.RemoveTab(0);
901 m_LogMessageCtrl.ShowWindow(SW_HIDE);
902 m_CtrlStatusText.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_REBASEFINISHED)));
904 return 0;
906 void CRebaseDlg::OnBnClickedContinue()
908 if( m_RebaseStage == REBASE_DONE)
910 OnOK();
911 return;
914 if( this->m_IsFastForward )
916 CString cmd,out;
917 CString oldbranch = g_Git.GetCurrentBranch();
918 if( oldbranch != m_BranchCtrl.GetString() )
920 cmd.Format(_T("git.exe checkout %s"),m_BranchCtrl.GetString());
921 AddLogString(cmd);
922 if (g_Git.Run(cmd, &out, CP_UTF8))
924 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_LOG);
925 AddLogString(out);
926 return;
929 AddLogString(out);
930 out.Empty();
931 m_OrigBranchHash = g_Git.GetHash(m_BranchCtrl.GetString());
932 m_OrigUpstreamHash = g_Git.GetHash(this->m_UpstreamCtrl.GetString());
934 if(!g_Git.IsFastForward(this->m_BranchCtrl.GetString(),this->m_UpstreamCtrl.GetString()))
936 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_LOG);
937 AddLogString(_T("No fast forward possible.\r\nMaybe repository changed"));
938 return;
941 cmd.Format(_T("git.exe reset --hard %s"),g_Git.FixBranchName(this->m_UpstreamCtrl.GetString()));
942 CString log;
943 log.Format(IDS_PROC_REBASE_FFTO, m_UpstreamCtrl.GetString());
944 this->AddLogString(log);
946 AddLogString(cmd);
947 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_LOG);
948 if (g_Git.Run(cmd, &out, CP_UTF8))
950 AddLogString(CString(MAKEINTRESOURCE(IDS_FAIL)));
951 AddLogString(out);
952 return;
954 AddLogString(out);
955 AddLogString(CString(MAKEINTRESOURCE(IDS_DONE)));
956 m_RebaseStage = REBASE_DONE;
957 UpdateCurrentStatus();
958 return;
961 if( m_RebaseStage == CHOOSE_BRANCH|| m_RebaseStage == CHOOSE_COMMIT_PICK_MODE )
963 if(CheckRebaseCondition())
964 return ;
965 m_RebaseStage = REBASE_START;
966 m_FileListCtrl.Clear();
967 m_FileListCtrl.m_CurrentVersion = L"";
968 m_ctrlTabCtrl.SetTabLabel(REBASE_TAB_CONFLICT, CString(MAKEINTRESOURCE(IDS_PROC_CONFLICTFILES)));
969 m_ctrlTabCtrl.AddTab(&m_wndOutputRebase, CString(MAKEINTRESOURCE(IDS_LOG)), 2);
972 if( m_RebaseStage == REBASE_FINISH )
974 if(FinishRebase())
975 return ;
977 OnOK();
980 if( m_RebaseStage == REBASE_SQUASH_CONFLICT)
982 if(VerifyNoConflict())
983 return;
984 GitRev *curRev=(GitRev*)m_CommitList.m_arShownList[m_CurrentRebaseIndex];
985 if(this->CheckNextCommitIsSquash())
986 {//next commit is not squash;
987 m_RebaseStage = REBASE_SQUASH_EDIT;
988 this->OnRebaseUpdateUI(0,0);
989 this->UpdateCurrentStatus();
990 return ;
993 m_RebaseStage=REBASE_CONTINUE;
994 curRev->GetAction(&m_CommitList)|=CTGitPath::LOGACTIONS_REBASE_DONE;
995 this->UpdateCurrentStatus();
999 if( m_RebaseStage == REBASE_CONFLICT )
1001 if(VerifyNoConflict())
1002 return;
1004 GitRev *curRev=(GitRev*)m_CommitList.m_arShownList[m_CurrentRebaseIndex];
1006 CString out =_T("");
1007 CString cmd;
1008 cmd.Format(_T("git.exe commit -a -C %s"), curRev->m_CommitHash.ToString());
1010 AddLogString(cmd);
1012 if(g_Git.Run(cmd,&out,CP_UTF8))
1014 AddLogString(out);
1015 if(!g_Git.CheckCleanWorkTree())
1017 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
1018 return;
1022 AddLogString(out);
1023 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_LOG);
1024 if( curRev->GetAction(&m_CommitList) & CTGitPath::LOGACTIONS_REBASE_EDIT)
1026 m_RebaseStage=REBASE_EDIT;
1027 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_MESSAGE);
1028 this->UpdateCurrentStatus();
1029 return;
1031 else
1033 m_RebaseStage=REBASE_CONTINUE;
1034 curRev->GetAction(&m_CommitList)|=CTGitPath::LOGACTIONS_REBASE_DONE;
1035 this->UpdateCurrentStatus();
1039 if( m_RebaseStage == REBASE_EDIT || m_RebaseStage == REBASE_SQUASH_EDIT )
1041 CString str;
1042 GitRev *curRev=(GitRev*)m_CommitList.m_arShownList[m_CurrentRebaseIndex];
1044 str=this->m_LogMessageCtrl.GetText();
1045 if(str.Trim().IsEmpty())
1047 CMessageBox::Show(NULL, IDS_PROC_COMMITMESSAGE_EMPTY,IDS_APPNAME, MB_OK | MB_ICONERROR);
1048 return;
1051 CString tempfile=::GetTempFile();
1052 CAppUtils::SaveCommitUnicodeFile(tempfile, str);
1054 CString out,cmd;
1056 if( m_RebaseStage == REBASE_SQUASH_EDIT )
1057 cmd.Format(_T("git.exe commit -F \"%s\""), tempfile);
1058 else
1059 cmd.Format(_T("git.exe commit --amend -F \"%s\""), tempfile);
1061 if(g_Git.Run(cmd,&out,CP_UTF8))
1063 if(!g_Git.CheckCleanWorkTree())
1065 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
1066 return;
1070 CFile::Remove(tempfile);
1071 AddLogString(out);
1072 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_LOG);
1073 m_RebaseStage=REBASE_CONTINUE;
1074 curRev->GetAction(&m_CommitList)|=CTGitPath::LOGACTIONS_REBASE_DONE;
1075 this->UpdateCurrentStatus();
1079 InterlockedExchange(&m_bThreadRunning, TRUE);
1080 SetControlEnable();
1082 if (AfxBeginThread(RebaseThreadEntry, this)==NULL)
1084 InterlockedExchange(&m_bThreadRunning, FALSE);
1085 CMessageBox::Show(NULL, _T("Create Rebase Thread Fail"), _T("TortoiseGit"), MB_OK | MB_ICONERROR);
1086 SetControlEnable();
1089 int CRebaseDlg::CheckNextCommitIsSquash()
1091 int index;
1092 if(m_CommitList.m_IsOldFirst)
1093 index=m_CurrentRebaseIndex+1;
1094 else
1095 index=m_CurrentRebaseIndex-1;
1097 GitRev *curRev;
1100 if(index<0)
1101 return -1;
1102 if(index>= m_CommitList.GetItemCount())
1103 return -1;
1105 curRev=(GitRev*)m_CommitList.m_arShownList[index];
1107 if( curRev->GetAction(&m_CommitList)&CTGitPath::LOGACTIONS_REBASE_SQUASH )
1108 return 0;
1109 if( curRev->GetAction(&m_CommitList)&CTGitPath::LOGACTIONS_REBASE_SKIP)
1111 if(m_CommitList.m_IsOldFirst)
1112 index++;
1113 else
1114 index--;
1116 else
1117 return -1;
1119 }while(curRev->GetAction(&m_CommitList)&CTGitPath::LOGACTIONS_REBASE_SKIP);
1121 return -1;
1124 int CRebaseDlg::GoNext()
1126 if(m_CommitList.m_IsOldFirst)
1127 m_CurrentRebaseIndex++;
1128 else
1129 m_CurrentRebaseIndex--;
1130 return 0;
1133 int CRebaseDlg::StateAction()
1135 switch(this->m_RebaseStage)
1137 case CHOOSE_BRANCH:
1138 case CHOOSE_COMMIT_PICK_MODE:
1139 if(StartRebase())
1140 return -1;
1141 m_RebaseStage = REBASE_START;
1142 GoNext();
1143 break;
1146 return 0;
1148 void CRebaseDlg::SetContinueButtonText()
1150 CString Text;
1151 switch(this->m_RebaseStage)
1153 case CHOOSE_BRANCH:
1154 case CHOOSE_COMMIT_PICK_MODE:
1155 if(this->m_IsFastForward)
1156 Text.LoadString(IDS_PROC_STARTREBASEFFBUTTON);
1157 else
1158 Text.LoadString(IDS_PROC_STARTREBASEBUTTON);
1159 break;
1161 case REBASE_START:
1162 case REBASE_CONTINUE:
1163 case REBASE_SQUASH_CONFLICT:
1164 Text.LoadString(IDS_CONTINUEBUTTON);
1165 break;
1167 case REBASE_CONFLICT:
1168 Text.LoadString(IDS_COMMITBUTTON);
1169 break;
1170 case REBASE_EDIT:
1171 Text.LoadString(IDS_AMENDBUTTON);
1172 break;
1174 case REBASE_SQUASH_EDIT:
1175 Text.LoadString(IDS_COMMITBUTTON);
1176 break;
1178 case REBASE_ABORT:
1179 case REBASE_FINISH:
1180 Text.LoadString(IDS_FINISHBUTTON);
1181 break;
1183 case REBASE_DONE:
1184 Text.LoadString(IDS_DONE);
1185 break;
1187 this->GetDlgItem(IDC_REBASE_CONTINUE)->SetWindowText(Text);
1190 void CRebaseDlg::SetControlEnable()
1192 switch(this->m_RebaseStage)
1194 case CHOOSE_BRANCH:
1195 case CHOOSE_COMMIT_PICK_MODE:
1197 this->GetDlgItem(IDC_PICK_ALL)->EnableWindow(TRUE);
1198 this->GetDlgItem(IDC_EDIT_ALL)->EnableWindow(TRUE);
1199 this->GetDlgItem(IDC_SQUASH_ALL)->EnableWindow(TRUE);
1200 this->GetDlgItem(IDC_BUTTON_UP2)->EnableWindow(TRUE);
1201 this->GetDlgItem(IDC_BUTTON_DOWN2)->EnableWindow(TRUE);
1203 if(!m_IsCherryPick)
1205 this->GetDlgItem(IDC_REBASE_COMBOXEX_BRANCH)->EnableWindow(TRUE);
1206 this->GetDlgItem(IDC_REBASE_COMBOXEX_UPSTREAM)->EnableWindow(TRUE);
1207 this->GetDlgItem(IDC_REBASE_CHECK_FORCE)->EnableWindow(TRUE);
1209 //this->m_CommitList.m_IsEnableRebaseMenu=TRUE;
1210 this->m_CommitList.m_ContextMenuMask |= m_CommitList.GetContextMenuBit(CGitLogListBase::ID_REBASE_PICK)|
1211 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_REBASE_SQUASH)|
1212 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_REBASE_EDIT)|
1213 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_REBASE_SKIP);
1214 break;
1216 case REBASE_START:
1217 case REBASE_CONTINUE:
1218 case REBASE_ABORT:
1219 case REBASE_FINISH:
1220 case REBASE_CONFLICT:
1221 case REBASE_EDIT:
1222 case REBASE_SQUASH_CONFLICT:
1223 case REBASE_DONE:
1224 this->GetDlgItem(IDC_PICK_ALL)->EnableWindow(FALSE);
1225 this->GetDlgItem(IDC_EDIT_ALL)->EnableWindow(FALSE);
1226 this->GetDlgItem(IDC_SQUASH_ALL)->EnableWindow(FALSE);
1227 this->GetDlgItem(IDC_REBASE_COMBOXEX_BRANCH)->EnableWindow(FALSE);
1228 this->GetDlgItem(IDC_REBASE_COMBOXEX_UPSTREAM)->EnableWindow(FALSE);
1229 this->GetDlgItem(IDC_REBASE_CHECK_FORCE)->EnableWindow(FALSE);
1230 this->GetDlgItem(IDC_BUTTON_UP2)->EnableWindow(FALSE);
1231 this->GetDlgItem(IDC_BUTTON_DOWN2)->EnableWindow(FALSE);
1232 //this->m_CommitList.m_IsEnableRebaseMenu=FALSE;
1233 this->m_CommitList.m_ContextMenuMask &= ~(m_CommitList.GetContextMenuBit(CGitLogListBase::ID_REBASE_PICK)|
1234 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_REBASE_SQUASH)|
1235 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_REBASE_EDIT)|
1236 m_CommitList.GetContextMenuBit(CGitLogListBase::ID_REBASE_SKIP));
1238 if( m_RebaseStage == REBASE_DONE && (this->m_PostButtonTexts.GetCount() != 0) )
1240 this->GetDlgItem(IDC_STATUS_STATIC)->ShowWindow(SW_HIDE);
1241 this->GetDlgItem(IDC_REBASE_POST_BUTTON)->ShowWindow(SW_SHOWNORMAL);
1242 this->m_PostButton.RemoveAll();
1243 this->m_PostButton.AddEntries(m_PostButtonTexts);
1244 //this->GetDlgItem(IDC_REBASE_POST_BUTTON)->SetWindowText(this->m_PostButtonText);
1246 break;
1249 if(m_bThreadRunning)
1251 this->GetDlgItem(IDC_REBASE_CONTINUE)->EnableWindow(FALSE);
1254 else
1256 this->GetDlgItem(IDC_REBASE_CONTINUE)->EnableWindow(TRUE);
1260 void CRebaseDlg::UpdateProgress()
1262 int index;
1263 CRect rect;
1265 if(m_CommitList.m_IsOldFirst)
1266 index = m_CurrentRebaseIndex+1;
1267 else
1268 index = m_CommitList.GetItemCount()-m_CurrentRebaseIndex;
1270 m_ProgressBar.SetRange32(1, m_CommitList.GetItemCount());
1271 m_ProgressBar.SetPos(index);
1272 if (m_pTaskbarList)
1274 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
1275 m_pTaskbarList->SetProgressValue(m_hWnd, index, m_CommitList.GetItemCount());
1278 if(m_CurrentRebaseIndex>=0 && m_CurrentRebaseIndex< m_CommitList.GetItemCount())
1280 CString text;
1281 text.Format(IDS_PROC_REBASING_PROGRESS, index, m_CommitList.GetItemCount());
1282 m_CtrlStatusText.SetWindowText(text);
1286 GitRev *prevRev=NULL, *curRev=NULL;
1288 if( m_CurrentRebaseIndex >= 0 && m_CurrentRebaseIndex< m_CommitList.m_arShownList.GetSize())
1290 curRev=(GitRev*)m_CommitList.m_arShownList[m_CurrentRebaseIndex];
1293 for(int i=0;i<m_CommitList.m_arShownList.GetSize();i++)
1295 prevRev=(GitRev*)m_CommitList.m_arShownList[i];
1296 if(prevRev->GetAction(&m_CommitList) & CTGitPath::LOGACTIONS_REBASE_CURRENT)
1298 prevRev->GetAction(&m_CommitList) &= ~ CTGitPath::LOGACTIONS_REBASE_CURRENT;
1299 m_CommitList.GetItemRect(i,&rect,LVIR_BOUNDS);
1300 m_CommitList.InvalidateRect(rect);
1304 if(curRev)
1306 curRev->GetAction(&m_CommitList) |= CTGitPath::LOGACTIONS_REBASE_CURRENT;
1307 m_CommitList.GetItemRect(m_CurrentRebaseIndex,&rect,LVIR_BOUNDS);
1308 m_CommitList.InvalidateRect(rect);
1310 m_CommitList.EnsureVisible(m_CurrentRebaseIndex,FALSE);
1313 void CRebaseDlg::UpdateCurrentStatus()
1315 SetContinueButtonText();
1316 SetControlEnable();
1317 UpdateProgress();
1320 void CRebaseDlg::AddLogString(CString str)
1322 this->m_wndOutputRebase.SendMessage(SCI_SETREADONLY, FALSE);
1323 CStringA sTextA = m_wndOutputRebase.StringForControl(str);//CUnicodeUtils::GetUTF8(str);
1324 this->m_wndOutputRebase.SendMessage(SCI_DOCUMENTEND);
1325 this->m_wndOutputRebase.SendMessage(SCI_REPLACESEL, 0, (LPARAM)(LPCSTR)sTextA);
1326 this->m_wndOutputRebase.SendMessage(SCI_REPLACESEL, 0, (LPARAM)(LPCSTR)"\n");
1327 this->m_wndOutputRebase.SendMessage(SCI_SETREADONLY, TRUE);
1330 int CRebaseDlg::GetCurrentCommitID()
1332 if(m_CommitList.m_IsOldFirst)
1334 return this->m_CurrentRebaseIndex+1;
1337 else
1339 return m_CommitList.GetItemCount()-m_CurrentRebaseIndex;
1343 int CRebaseDlg::DoRebase()
1345 CString cmd,out;
1346 if(m_CurrentRebaseIndex <0)
1347 return 0;
1348 if(m_CurrentRebaseIndex >= m_CommitList.GetItemCount() )
1349 return 0;
1351 GitRev *pRev = (GitRev*)m_CommitList.m_arShownList[m_CurrentRebaseIndex];
1352 int mode=pRev->GetAction(&m_CommitList) & CTGitPath::LOGACTIONS_REBASE_MODE_MASK;
1353 CString nocommit;
1355 if( mode== CTGitPath::LOGACTIONS_REBASE_SKIP)
1357 pRev->GetAction(&m_CommitList)|= CTGitPath::LOGACTIONS_REBASE_DONE;
1358 return 0;
1361 if (!CheckNextCommitIsSquash() || mode != CTGitPath::LOGACTIONS_REBASE_PICK)
1362 { // next commit is squash or not pick
1363 if (!this->m_SquashMessage.IsEmpty())
1364 this->m_SquashMessage += _T("\n\n");
1365 this->m_SquashMessage += pRev->GetSubject();
1366 this->m_SquashMessage += _T("\n");
1367 this->m_SquashMessage += pRev->GetBody().TrimRight();
1369 else
1370 this->m_SquashMessage.Empty();
1372 if (!CheckNextCommitIsSquash() || mode == CTGitPath::LOGACTIONS_REBASE_SQUASH)
1373 { // next or this commit is squash
1374 nocommit=_T(" --no-commit ");
1377 CString log;
1378 log.Format(_T("%s %d: %s"),CTGitPath::GetActionName(mode),this->GetCurrentCommitID(),pRev->m_CommitHash.ToString());
1379 AddLogString(log);
1380 AddLogString(pRev->GetSubject());
1381 if (pRev->GetSubject().IsEmpty())
1383 CMessageBox::Show(m_hWnd, IDS_PROC_REBASE_EMPTYCOMMITMSG, IDS_APPNAME, MB_OK | MB_ICONEXCLAMATION);
1384 mode = CTGitPath::LOGACTIONS_REBASE_EDIT;
1387 CString cherryPickedFrom;
1388 if (m_bAddCherryPickedFrom)
1389 cherryPickedFrom = _T("-x ");
1391 cmd.Format(_T("git.exe cherry-pick %s%s %s"), cherryPickedFrom, nocommit, pRev->m_CommitHash.ToString());
1393 if(g_Git.Run(cmd,&out,CP_UTF8))
1395 AddLogString(out);
1396 CTGitPathList list;
1397 if(g_Git.ListConflictFile(list))
1399 AddLogString(_T("Get conflict files fail"));
1400 return -1;
1402 if(list.GetCount() == 0 )
1404 if(mode == CTGitPath::LOGACTIONS_REBASE_PICK)
1406 pRev->GetAction(&m_CommitList)|= CTGitPath::LOGACTIONS_REBASE_DONE;
1407 return 0;
1409 if(mode == CTGitPath::LOGACTIONS_REBASE_EDIT)
1411 this->m_RebaseStage = REBASE_EDIT ;
1412 return -1; // Edit return -1 to stop rebase.
1414 // Squash Case
1415 if(CheckNextCommitIsSquash())
1416 { // no squash
1417 // let user edit last commmit message
1418 this->m_RebaseStage = REBASE_SQUASH_EDIT;
1419 return -1;
1422 if(mode == CTGitPath::LOGACTIONS_REBASE_SQUASH)
1423 m_RebaseStage = REBASE_SQUASH_CONFLICT;
1424 else
1425 m_RebaseStage = REBASE_CONFLICT;
1426 return -1;
1429 else
1431 AddLogString(out);
1432 if(mode == CTGitPath::LOGACTIONS_REBASE_PICK)
1434 pRev->GetAction(&m_CommitList)|= CTGitPath::LOGACTIONS_REBASE_DONE;
1435 return 0;
1437 if(mode == CTGitPath::LOGACTIONS_REBASE_EDIT)
1439 this->m_RebaseStage = REBASE_EDIT ;
1440 return -1; // Edit return -1 to stop rebase.
1443 // Squash Case
1444 if(CheckNextCommitIsSquash())
1445 { // no squash
1446 // let user edit last commmit message
1447 this->m_RebaseStage = REBASE_SQUASH_EDIT;
1448 return -1;
1450 else if(mode == CTGitPath::LOGACTIONS_REBASE_SQUASH)
1451 pRev->GetAction(&m_CommitList)|= CTGitPath::LOGACTIONS_REBASE_DONE;
1454 return 0;
1457 BOOL CRebaseDlg::IsEnd()
1459 if(m_CommitList.m_IsOldFirst)
1460 return m_CurrentRebaseIndex>= this->m_CommitList.GetItemCount();
1461 else
1462 return m_CurrentRebaseIndex<0;
1465 int CRebaseDlg::RebaseThread()
1467 CBlockCacheForPath cacheBlock(g_Git.m_CurrentDir);
1469 int ret=0;
1470 while(1)
1472 if( m_RebaseStage == REBASE_START )
1474 if( this->StartRebase() )
1476 InterlockedExchange(&m_bThreadRunning, FALSE);
1477 ret = -1;
1478 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_LOG);
1479 break;
1481 m_RebaseStage = REBASE_CONTINUE;
1484 else if( m_RebaseStage == REBASE_CONTINUE )
1486 this->GoNext();
1487 UpdateCurrentStatus();
1488 if(IsEnd())
1490 ret = 0;
1491 m_RebaseStage = REBASE_FINISH;
1494 else
1496 ret = DoRebase();
1498 if( ret )
1500 break;
1505 else if( m_RebaseStage == REBASE_FINISH )
1507 FinishRebase();
1508 m_RebaseStage = REBASE_DONE;
1509 if (m_pTaskbarList)
1510 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
1511 break;
1514 else
1516 break;
1518 this->PostMessage(MSG_REBASE_UPDATE_UI);
1519 //this->UpdateCurrentStatus();
1522 InterlockedExchange(&m_bThreadRunning, FALSE);
1523 this->PostMessage(MSG_REBASE_UPDATE_UI);
1524 return ret;
1527 void CRebaseDlg::ListConflictFile()
1529 this->m_FileListCtrl.Clear();
1530 CTGitPathList list;
1531 CTGitPath path;
1532 list.AddPath(path);
1534 m_FileListCtrl.m_bIsRevertTheirMy = !m_IsCherryPick;
1536 this->m_FileListCtrl.GetStatus(&list,true);
1537 this->m_FileListCtrl.Show(CTGitPath::LOGACTIONS_UNMERGED|CTGitPath::LOGACTIONS_MODIFIED|CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_DELETED,
1538 CTGitPath::LOGACTIONS_UNMERGED);
1541 LRESULT CRebaseDlg::OnRebaseUpdateUI(WPARAM,LPARAM)
1543 UpdateCurrentStatus();
1544 if(m_CurrentRebaseIndex <0)
1545 return 0;
1546 if(m_CurrentRebaseIndex >= m_CommitList.GetItemCount() )
1547 return 0;
1548 GitRev *curRev=(GitRev*)m_CommitList.m_arShownList[m_CurrentRebaseIndex];
1550 switch(m_RebaseStage)
1552 case REBASE_CONFLICT:
1553 case REBASE_SQUASH_CONFLICT:
1554 ListConflictFile();
1555 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_CONFLICT);
1556 if (m_pTaskbarList)
1557 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR);
1558 this->m_LogMessageCtrl.Call(SCI_SETREADONLY, FALSE);
1559 this->m_LogMessageCtrl.SetText(curRev->GetSubject()+_T("\n")+curRev->GetBody());
1560 break;
1561 case REBASE_EDIT:
1562 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_MESSAGE);
1563 if (m_pTaskbarList)
1564 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_PAUSED);
1565 this->m_LogMessageCtrl.Call(SCI_SETREADONLY, FALSE);
1566 this->m_LogMessageCtrl.SetText(curRev->GetSubject()+_T("\n")+curRev->GetBody());
1567 break;
1568 case REBASE_SQUASH_EDIT:
1569 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_MESSAGE);
1570 this->m_LogMessageCtrl.Call(SCI_SETREADONLY, FALSE);
1571 this->m_LogMessageCtrl.SetText(this->m_SquashMessage);
1572 if (m_pTaskbarList)
1573 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_PAUSED);
1574 break;
1575 default:
1576 this->m_ctrlTabCtrl.SetActiveTab(REBASE_TAB_LOG);
1578 return 0;
1580 void CRebaseDlg::OnCancel()
1582 OnBnClickedAbort();
1584 void CRebaseDlg::OnBnClickedAbort()
1586 if (m_pTaskbarList)
1587 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
1589 CString cmd,out;
1590 CString pron = m_OrigUpstreamHash.ToString();
1591 if(m_OrigUpstreamHash.IsEmpty())
1593 __super::OnCancel();
1596 if(m_RebaseStage == CHOOSE_BRANCH || m_RebaseStage== CHOOSE_COMMIT_PICK_MODE)
1598 return;
1601 if(CMessageBox::Show(NULL, IDS_PROC_REBASE_ABORT, IDS_APPNAME, MB_YESNO) != IDYES)
1602 return;
1604 if(this->m_IsFastForward)
1606 cmd.Format(_T("git.exe reset --hard %s"),this->m_OrigBranchHash.ToString());
1607 if(g_Git.Run(cmd,&out,CP_UTF8))
1609 AddLogString(out);
1610 ::MessageBox(this->m_hWnd, _T("Unrecoverable error on cleanup:\n") + out, _T("TortoiseGit"), MB_ICONERROR);
1612 __super::OnCancel();
1613 return;
1615 cmd.Format(_T("git.exe checkout -f %s"),g_Git.FixBranchName(this->m_UpstreamCtrl.GetString()));
1616 if(g_Git.Run(cmd,&out,CP_UTF8))
1618 AddLogString(out);
1619 ::MessageBox(this->m_hWnd, _T("Unrecoverable error on cleanup:\n") + out, _T("TortoiseGit"), MB_ICONERROR);
1620 __super::OnCancel();
1621 return;
1624 cmd.Format(_T("git.exe reset --hard %s"),this->m_OrigUpstreamHash.ToString());
1625 if(g_Git.Run(cmd,&out,CP_UTF8))
1627 AddLogString(out);
1628 ::MessageBox(this->m_hWnd, _T("Unrecoverable error on cleanup:\n") + out, _T("TortoiseGit"), MB_ICONERROR);
1629 __super::OnCancel();
1630 return;
1633 if(this->m_IsCherryPick) //there are not "branch" at cherry pick mode
1635 __super::OnCancel();
1636 return;
1639 cmd.Format(_T("git checkout -f %s"),this->m_BranchCtrl.GetString());
1640 if(g_Git.Run(cmd,&out,CP_UTF8))
1642 AddLogString(out);
1643 ::MessageBox(this->m_hWnd, _T("Unrecoverable error on cleanup:\n") + out, _T("TortoiseGit"), MB_ICONERROR);
1644 __super::OnCancel();
1645 return;
1648 cmd.Format(_T("git.exe reset --hard %s"),this->m_OrigBranchHash.ToString());
1649 if(g_Git.Run(cmd,&out,CP_UTF8))
1651 AddLogString(out);
1652 ::MessageBox(this->m_hWnd, _T("Unrecoverable error on cleanup:\n") + out, _T("TortoiseGit"), MB_ICONERROR);
1654 __super::OnCancel();
1657 void CRebaseDlg::OnBnClickedButtonBrowse()
1659 if(CBrowseRefsDlg::PickRefForCombo(&m_UpstreamCtrl, gPickRef_NoTag))
1660 OnCbnSelchangeUpstream();
1663 void CRebaseDlg::OnBnClickedRebaseCheckForce()
1665 this->UpdateData();
1666 this->FetchLogList();
1667 if(this->CheckRebaseCondition())
1669 /* Disable Start Rebase */
1670 this->GetDlgItem(IDC_REBASE_CONTINUE)->EnableWindow(FALSE);
1674 void CRebaseDlg::OnBnClickedRebasePostButton()
1676 this->m_Upstream=this->m_UpstreamCtrl.GetString();
1677 this->m_Branch=this->m_BranchCtrl.GetString();
1679 this->EndDialog((int)(IDC_REBASE_POST_BUTTON+this->m_PostButton.GetCurrentEntry()));
1682 void CRebaseDlg::Refresh()
1684 if (m_RebaseStage == REBASE_CONFLICT || m_RebaseStage == REBASE_SQUASH_CONFLICT)
1686 ListConflictFile();
1687 return;
1690 if(this->m_IsCherryPick)
1691 return ;
1693 if(this->m_RebaseStage == CHOOSE_BRANCH )
1695 this->UpdateData();
1696 this->FetchLogList();
1697 if(this->CheckRebaseCondition())
1699 /* Disable Start Rebase */
1700 this->GetDlgItem(IDC_REBASE_CONTINUE)->EnableWindow(FALSE);
1705 void CRebaseDlg::OnBnClickedButtonUp2()
1707 POSITION pos;
1708 pos = m_CommitList.GetFirstSelectedItemPosition();
1710 // do nothing if the first selected item is the first item in the list
1711 if (m_CommitList.GetNextSelectedItem(pos) == 0)
1712 return;
1714 pos = m_CommitList.GetFirstSelectedItemPosition();
1716 bool changed = false;
1717 while(pos)
1719 int index=m_CommitList.GetNextSelectedItem(pos);
1720 if(index>=1)
1722 CGitHash old = m_CommitList.m_logEntries[index-1];
1723 m_CommitList.m_logEntries[index-1] = m_CommitList.m_logEntries[index];
1724 m_CommitList.m_logEntries[index] = old;
1725 m_CommitList.SetItemState(index-1, LVIS_SELECTED, LVIS_SELECTED);
1726 m_CommitList.SetItemState(index, 0, LVIS_SELECTED);
1727 changed = true;
1730 if (changed)
1732 m_CommitList.RecalculateShownList(&m_CommitList.m_arShownList);
1733 m_CommitList.Invalidate();
1734 m_CommitList.SetFocus();
1738 void CRebaseDlg::OnBnClickedButtonDown2()
1740 if (m_CommitList.GetSelectedCount() == 0)
1741 return;
1743 POSITION pos;
1744 pos = m_CommitList.GetFirstSelectedItemPosition();
1745 bool changed = false;
1746 // use an array to store all selected item indexes; the user won't select too much items
1747 int* indexes = NULL;
1748 indexes = new int[m_CommitList.GetSelectedCount()];
1749 int i = 0;
1750 while(pos)
1752 indexes[i++] = m_CommitList.GetNextSelectedItem(pos);
1754 // don't move any item if the last selected item is the last item in the m_CommitList
1755 // (that would change the order of the selected items)
1756 if(indexes[m_CommitList.GetSelectedCount() - 1] < m_CommitList.GetItemCount() - 1)
1758 // iterate over the indexes backwards in order to correctly move multiselected items
1759 for (i = m_CommitList.GetSelectedCount() - 1; i >= 0; i--)
1761 int index = indexes[i];
1762 CGitHash old = m_CommitList.m_logEntries[index+1];
1763 m_CommitList.m_logEntries[index+1] = m_CommitList.m_logEntries[index];
1764 m_CommitList.m_logEntries[index] = old;
1765 m_CommitList.SetItemState(index, 0, LVIS_SELECTED);
1766 m_CommitList.SetItemState(index+1, LVIS_SELECTED, LVIS_SELECTED);
1767 changed = true;
1770 delete [] indexes;
1771 indexes = NULL;
1772 if (changed)
1774 m_CommitList.RecalculateShownList(&m_CommitList.m_arShownList);
1775 m_CommitList.Invalidate();
1776 m_CommitList.SetFocus();
1780 LRESULT CRebaseDlg::OnTaskbarBtnCreated(WPARAM /*wParam*/, LPARAM /*lParam*/)
1782 m_pTaskbarList.Release();
1783 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
1784 return 0;
1787 void CRebaseDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
1789 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
1790 *pResult = 0;
1791 if(m_CommitList.m_bNoDispUpdates)
1792 return;
1793 if (pNMLV->iItem >= 0)
1795 this->m_CommitList.m_nSearchIndex = pNMLV->iItem;
1796 if (pNMLV->iSubItem != 0)
1797 return;
1798 if ((pNMLV->iItem == m_CommitList.m_arShownList.GetCount()))
1800 // remove the selected state
1801 if (pNMLV->uChanged & LVIF_STATE)
1803 m_CommitList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);
1804 FillLogMessageCtrl();
1806 return;
1808 if (pNMLV->uChanged & LVIF_STATE)
1810 FillLogMessageCtrl();
1813 else
1815 FillLogMessageCtrl();
1819 void CRebaseDlg::FillLogMessageCtrl()
1821 int selCount = m_CommitList.GetSelectedCount();
1822 if (selCount == 1 && (m_RebaseStage == CHOOSE_BRANCH || m_RebaseStage == CHOOSE_COMMIT_PICK_MODE))
1824 POSITION pos = m_CommitList.GetFirstSelectedItemPosition();
1825 int selIndex = m_CommitList.GetNextSelectedItem(pos);
1826 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_CommitList.m_arShownList.SafeGetAt(selIndex));
1827 m_FileListCtrl.UpdateWithGitPathList(pLogEntry->GetFiles(&m_CommitList));
1828 m_FileListCtrl.m_CurrentVersion = pLogEntry->m_CommitHash;
1829 m_FileListCtrl.Show(GITSLC_SHOWVERSIONED);
1830 m_LogMessageCtrl.Call(SCI_SETREADONLY, FALSE);
1831 m_LogMessageCtrl.SetText(pLogEntry->GetSubject() + _T("\n") + pLogEntry->GetBody());
1832 m_LogMessageCtrl.Call(SCI_SETREADONLY, TRUE);
1835 void CRebaseDlg::OnBnClickedCheckCherryPickedFrom()
1837 UpdateData();