Fixed issue #2219: "add cherry picked from" is not applied when squashing/editing...
[TortoiseGit.git] / src / TortoiseProc / CommitDlg.h
blob5fa97db745915dc93bcd8118f366f63d0f59707c
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2014 - TortoiseGit
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.
20 #pragma once
22 #include "StandAloneDlg.h"
23 #include "GitStatusListCtrl.h"
24 #include "RegHistory.h"
25 #include "registry.h"
26 #include "SciEdit.h"
27 #include "SplitterControl.h"
28 #include "LinkControl.h"
29 #include "PathWatcher.h"
30 #include "BugTraqAssociations.h"
31 #include "Tooltip.h"
32 #include "..\IBugTraqProvider\IBugTraqProvider_h.h"
33 #include "Git.h"
34 #include "HyperLink.h"
35 #include "PatchViewDlg.h"
37 #include <regex>
39 #define ENDDIALOGTIMER 100
40 #define REFRESHTIMER 101
41 #define FILLPATCHVTIMER 102
43 typedef enum
45 GIT_POSTCOMMIT_CMD_NOTHING,
46 GIT_POSTCOMMIT_CMD_RECOMMIT,
47 GIT_POSTCOMMIT_CMD_PUSH,
48 GIT_POSTCOMMIT_CMD_DCOMMIT,
49 GIT_POSTCOMMIT_CMD_PULL,
50 GIT_POSTCOMMIT_CMD_CREATETAG,
51 } GIT_POSTCOMMIT_CMD;
54 /**
55 * \ingroup TortoiseProc
56 * Dialog to enter log messages used in a commit.
58 class CCommitDlg : public CResizableStandAloneDialog, public CSciEditContextMenuInterface, IHasPatchView
60 DECLARE_DYNAMIC(CCommitDlg)
62 public:
63 CCommitDlg(CWnd* pParent = NULL); // standard constructor
64 virtual ~CCommitDlg();
66 protected:
67 // CSciEditContextMenuInterface
68 virtual void InsertMenuItems(CMenu& mPopup, int& nCmd);
69 virtual bool HandleMenuItemClick(int cmd, CSciEdit * pSciEdit);
70 virtual void HandleSnippet(int type, const CString &text, CSciEdit *pSciEdit);
72 public:
73 void ShowViewPatchText(bool b=true)
75 if(b)
76 this->m_ctrlShowPatch.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_SHOWPATCH)));
77 else
78 this->m_ctrlShowPatch.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_HIDEPATCH)));
80 m_ctrlShowPatch.Invalidate();
82 private:
83 static UINT StatusThreadEntry(LPVOID pVoid);
84 UINT StatusThread();
85 void FillPatchView(bool onlySetTimer = false);
86 CWnd * GetPatchViewParentWnd() { return this; }
87 virtual void TogglePatchView();
88 void SetDlgTitle();
89 CString GetSignedOffByLine();
90 CString m_sTitle;
92 // Dialog Data
93 enum { IDD = IDD_COMMITDLG };
95 protected:
96 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
98 virtual BOOL OnInitDialog();
99 virtual void OnOK();
100 virtual void OnCancel();
101 virtual BOOL PreTranslateMessage(MSG* pMsg);
102 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
103 afx_msg void OnBnClickedShowunversioned();
104 afx_msg void OnBnClickedHistory();
105 afx_msg void OnBnClickedBugtraqbutton();
106 afx_msg void OnEnChangeLogmessage();
107 afx_msg void OnStnClickedExternalwarning();
108 afx_msg void OnFocusMessage();
109 afx_msg void OnFocusFileList();
110 afx_msg LRESULT OnGitStatusListCtrlItemCountChanged(WPARAM, LPARAM);
111 afx_msg LRESULT OnGitStatusListCtrlNeedsRefresh(WPARAM, LPARAM);
112 afx_msg LRESULT OnGitStatusListCtrlCheckChanged(WPARAM, LPARAM);
113 afx_msg LRESULT OnGitStatusListCtrlItemChanged(WPARAM, LPARAM);
115 afx_msg LRESULT OnCheck(WPARAM count, LPARAM);
116 afx_msg LRESULT OnAutoListReady(WPARAM, LPARAM);
117 afx_msg LRESULT OnUpdateOKButton(WPARAM, LPARAM);
118 afx_msg LRESULT OnUpdateDataFalse(WPARAM, LPARAM);
119 afx_msg LRESULT OnFileDropped(WPARAM, LPARAM lParam);
120 afx_msg void OnTimer(UINT_PTR nIDEvent);
121 afx_msg void OnSize(UINT nType, int cx, int cy);
122 void Refresh();
123 void GetAutocompletionList();
124 void ScanFile(const CString& sFilePath, const CString& sRegex, const CString& sExt);
125 void DoSize(int delta);
126 void SetSplitterRange();
127 void SaveSplitterPos();
128 void UpdateCheckLinks();
129 void ParseRegexFile(const CString& sFile, std::map<CString, CString>& mapRegex);
130 void ParseSnippetFile(const CString& sFile, std::map<CString, CString>& mapSnippet);
131 void RunStartCommitHook();
133 DECLARE_MESSAGE_MAP()
135 public:
136 CString m_sLogMessage;
137 BOOL m_bKeepChangeList;
138 BOOL m_bDoNotAutoselectSubmodules;
139 bool m_bForceCommitAmend;
140 BOOL m_bCommitAmend;
141 BOOL m_bNoPostActions;
142 bool m_bSelectFilesForCommit;
143 bool m_bAutoClose;
144 CString m_AmendStr;
145 CString m_sBugID;
146 BOOL m_bWholeProject;
147 BOOL m_bWholeProject2;
148 CTGitPathList m_pathList;
149 CTGitPathList m_checkedPathList;
150 CTGitPathList m_updatedPathList;
151 GIT_POSTCOMMIT_CMD m_PostCmd;
152 BOOL m_bAmendDiffToLastCommit;
153 BOOL m_bCommitMessageOnly;
155 protected:
156 CTGitPathList m_selectedPathList;
157 CSciEdit m_cLogMessage;
158 INT_PTR m_itemsCount;
159 CComPtr<IBugTraqProvider> m_BugTraqProvider;
160 CString m_NoAmendStr;
161 BOOL m_bCreateNewBranch;
162 CString m_sCreateNewBranch;
163 BOOL m_bSetAuthor;
164 CString m_sAuthor;
166 int CheckHeadDetach();
168 private:
169 CWinThread* m_pThread;
170 std::map<CString, int> m_autolist;
171 std::map<CString, CString> m_snippet;
172 CGitStatusListCtrl m_ListCtrl;
173 BOOL m_bShowUnversioned;
174 volatile LONG m_bBlock;
175 volatile LONG m_bThreadRunning;
176 volatile LONG m_bRunThread;
177 CToolTips m_tooltips;
178 CRegDWORD m_regAddBeforeCommit;
179 CRegDWORD m_regKeepChangelists;
180 CRegDWORD m_regDoNotAutoselectSubmodules;
181 CRegDWORD m_regShowWholeProject;
182 ProjectProperties m_ProjectProperties;
183 CString m_sWindowTitle;
184 static UINT WM_AUTOLISTREADY;
185 static UINT WM_UPDATEOKBUTTON;
186 static UINT WM_UPDATEDATAFALSE;
187 int m_nPopupPickCommitHash;
188 int m_nPopupPickCommitMessage;
189 int m_nPopupPasteListCmd;
190 int m_nPopupPasteLastMessage;
191 int m_nPopupRecentMessage;
192 CRegHistory m_History;
193 bool m_bCancelled;
194 CSplitterControl m_wndSplitter;
195 CRect m_DlgOrigRect;
196 CRect m_LogMsgOrigRect;
197 CPathWatcher m_pathwatcher;
198 CHyperLink m_ctrlShowPatch;
199 CPatchViewDlg m_patchViewdlg;
200 BOOL m_bSetCommitDateTime;
201 CDateTimeCtrl m_CommitDate;
202 CDateTimeCtrl m_CommitTime;
203 CLinkControl m_linkControl;
204 CString m_sLogTemplate;
206 CBugTraqAssociation m_bugtraq_association;
207 HACCEL m_hAccel;
208 void RestoreFiles(bool doNotAsk = false);
210 protected:
211 afx_msg void OnBnClickedSignOff();
212 afx_msg void OnBnClickedCommitAmend();
213 afx_msg void OnBnClickedCommitMessageOnly();
214 afx_msg void OnBnClickedWholeProject();
215 afx_msg void OnScnUpdateUI(NMHDR *pNMHDR, LRESULT *pResult);
216 afx_msg void OnStnClickedViewPatch();
217 afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
218 afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
219 afx_msg void OnHdnItemchangedFilelist(NMHDR *pNMHDR, LRESULT *pResult);
220 afx_msg void OnBnClickedCommitAmenddiff();
221 afx_msg void OnBnClickedNoautoselectsubmodules();
222 afx_msg void OnBnClickedCommitSetDateTime();
223 afx_msg void OnBnClickedCheckNewBranch();
224 afx_msg void OnBnClickedCommitSetauthor();