Fixed issue #2311: Empty commits cannot be rebased
[TortoiseGit.git] / src / TortoiseProc / RebaseDlg.h
blobe6c24bb2ae2930ad297b364a4e7f5e8a61fec179
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2014 - 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 #pragma once
21 #include "afxcmn.h"
22 #include "afxwin.h"
23 #include "StandAloneDlg.h"
24 #include "GitStatusListCtrl.h"
25 #include "SciEdit.h"
26 #include "SplitterControl.h"
27 #include "HistoryCombo.h"
28 #include "GitLogList.h"
29 #include "MenuButton.h"
30 #include "Win7.h"
31 #include "Tooltip.h"
33 // CRebaseDlg dialog
34 #define IDC_REBASE_TAB 0x1000000
36 #define REBASE_TAB_CONFLICT 0
37 #define REBASE_TAB_MESSAGE 1
38 #define REBASE_TAB_LOG 2
40 #define MSG_REBASE_UPDATE_UI (WM_USER+151)
42 class CRebaseDlg : public CResizableStandAloneDialog
44 DECLARE_DYNAMIC(CRebaseDlg)
46 public:
47 CRebaseDlg(CWnd* pParent = NULL); // standard constructor
48 virtual ~CRebaseDlg();
50 // Dialog Data
51 enum { IDD = IDD_REBASE };
53 enum REBASE_STAGE
55 CHOOSE_BRANCH,
56 CHOOSE_COMMIT_PICK_MODE,
57 REBASE_START,
58 REBASE_CONTINUE,
59 REBASE_ABORT,
60 REBASE_FINISH,
61 REBASE_CONFLICT,
62 REBASE_EDIT,
63 REBASE_SQUASH_EDIT,
64 REBASE_SQUASH_CONFLICT,
65 REBASE_DONE,
66 REBASE_ERROR,
69 protected:
70 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
71 virtual BOOL OnInitDialog();
72 DECLARE_MESSAGE_MAP()
73 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
74 virtual HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
75 LRESULT OnRebaseUpdateUI(WPARAM wParam, LPARAM lParam);
76 void DoSize(int delta);
77 void AddRebaseAnchor();
78 void RemoveAnchor();
80 void SetSplitterRange();
81 void SaveSplitterPos();
83 void LoadBranchInfo();
84 void FetchLogList();
85 void SetAllRebaseAction(int action);
86 void OnCancel();
88 CRect m_DlgOrigRect;
89 CRect m_CommitListOrigRect;
90 CString m_sStatusText;
91 bool m_bStatusWarning;
92 BOOL PreTranslateMessage(MSG* pMsg);
93 bool LogListHasFocus(HWND hwnd);
94 bool LogListHasMenuItem(int i);
96 CSciEdit m_wndOutputRebase;
97 void SetContinueButtonText();
98 void SetControlEnable();
99 void UpdateProgress();
100 void UpdateCurrentStatus();
101 void ListConflictFile();
102 int DoRebase();
103 afx_msg LRESULT OnGitStatusListCtrlNeedsRefresh(WPARAM, LPARAM);
104 void Refresh();
105 volatile LONG m_bThreadRunning;
106 int RebaseThread();
107 static UINT RebaseThreadEntry(LPVOID pVoid){return ((CRebaseDlg *)pVoid)->RebaseThread();};
108 BOOL IsEnd();
110 int IsCommitEmpty(const CGitHash& hash);
112 BOOL m_IsFastForward;
114 CGitHash m_OrigBranchHash;
115 CGitHash m_OrigUpstreamHash;
116 CString m_OrigHEADBranch;
117 CGitHash m_OrigHEADHash;
119 int VerifyNoConflict();
120 CString GetRebaseModeName(int rebasemode);
122 CString m_SquashMessage;
123 CString m_SquashFirstMetaData;
125 int CheckNextCommitIsSquash();
126 int GetCurrentCommitID();
127 int FinishRebase();
129 CMenuButton m_PostButton;
131 afx_msg void OnBnClickedPickAll();
132 afx_msg void OnBnClickedSquashAll();
133 afx_msg void OnBnClickedEditAll();
134 afx_msg void OnBnClickedRebaseSplit();
135 afx_msg void OnSize(UINT nType, int cx, int cy);
136 afx_msg void OnCbnSelchangeBranch();
137 afx_msg void OnCbnSelchangeUpstream();
138 afx_msg void OnBnClickedContinue();
139 afx_msg void OnBnClickedAbort();
140 afx_msg void OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult);
141 void FillLogMessageCtrl();
143 CProgressCtrl m_ProgressBar;
144 CStatic m_CtrlStatusText;
145 CToolTips m_tooltips;
147 BOOL m_bForce;
148 BOOL m_bAddCherryPickedFrom;
149 BOOL m_bAutoSkipFailedCommit;
151 public:
152 CStringArray m_PostButtonTexts;
153 CGitLogList m_CommitList;
155 CString m_Upstream;
156 CString m_Branch;
158 BOOL m_IsCherryPick;
160 protected:
161 CSplitterControl m_wndSplitter;
162 CMFCTabCtrl m_ctrlTabCtrl;
163 CGitStatusListCtrl m_FileListCtrl;
164 CSciEdit m_LogMessageCtrl;
166 CHistoryCombo m_BranchCtrl;
167 CHistoryCombo m_UpstreamCtrl;
169 CMenuButton m_SplitAllOptions;
171 BOOL m_bSplitCommit;
173 REBASE_STAGE m_RebaseStage;
174 bool m_bFinishedRebase;
175 bool m_bStashed;
177 void AddBranchToolTips(CHistoryCombo *pBranch);
178 void AddLogString(CString str);
179 int StartRebase();
180 int CheckRebaseCondition();
181 void CheckRestoreStash();
182 int m_CurrentRebaseIndex;
183 int StateAction();
184 int GoNext();
185 void ResetParentForSquash(const CString& commitMessage);
186 afx_msg void OnBnClickedButtonReverse();
187 afx_msg void OnBnClickedButtonBrowse();
188 afx_msg void OnBnClickedRebaseCheckForce();
189 afx_msg void OnBnClickedCheckCherryPickedFrom();
190 afx_msg void OnBnClickedRebasePostButton();
191 afx_msg void OnBnClickedSplitAllOptions();
192 afx_msg void OnBnClickedButtonUp2();
193 afx_msg void OnBnClickedButtonDown2();
195 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
196 CComPtr<ITaskbarList3> m_pTaskbarList;
198 afx_msg LRESULT OnRebaseActionMessage(WPARAM wParam, LPARAM lParam);
199 afx_msg void OnBnClickedRebaseSplitCommit();