1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2016 - 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.
22 #include "StandAloneDlg.h"
23 #include "GitStatusListCtrl.h"
24 #include "RegHistory.h"
27 #include "SplitterControl.h"
28 #include "LinkControl.h"
29 #include "PathWatcher.h"
30 #include "BugTraqAssociations.h"
31 #include "..\IBugTraqProvider\IBugTraqProvider_h.h"
33 #include "HyperLink.h"
34 #include "PatchViewDlg.h"
35 #include "MenuButton.h"
39 #define ENDDIALOGTIMER 100
40 #define REFRESHTIMER 101
41 #define FILLPATCHVTIMER 102
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
,
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
)
63 CCommitDlg(CWnd
* pParent
= nullptr); // standard constructor
64 virtual ~CCommitDlg();
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
);
73 void ShowViewPatchText(bool b
=true)
76 this->m_ctrlShowPatch
.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_SHOWPATCH
)));
78 this->m_ctrlShowPatch
.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_HIDEPATCH
)));
80 m_ctrlShowPatch
.Invalidate();
82 void SetAuthor(CString author
)
87 void SetTime(CTime time
)
89 m_bSetCommitDateTime
= TRUE
;
90 m_wantCommitTime
= time
;
93 CTime m_wantCommitTime
;
94 void ReloadHistoryEntries();
95 static UINT
StatusThreadEntry(LPVOID pVoid
);
97 void FillPatchView(bool onlySetTimer
= false);
98 CWnd
* GetPatchViewParentWnd() { return this; }
99 virtual void TogglePatchView();
101 CString
GetSignedOffByLine();
105 enum { IDD
= IDD_COMMITDLG
};
108 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
110 virtual BOOL
OnInitDialog();
112 virtual void OnCancel();
113 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
114 virtual LRESULT
DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
);
115 afx_msg
void OnBnClickedShowunversioned();
116 afx_msg
void OnBnClickedHistory();
117 afx_msg
void OnBnClickedBugtraqbutton();
118 afx_msg
void OnEnChangeLogmessage();
119 afx_msg
void OnStnClickedExternalwarning();
120 afx_msg
void OnFocusMessage();
121 afx_msg
void OnFocusFileList();
122 afx_msg LRESULT
OnGitStatusListCtrlItemCountChanged(WPARAM
, LPARAM
);
123 afx_msg LRESULT
OnGitStatusListCtrlNeedsRefresh(WPARAM
, LPARAM
);
124 afx_msg LRESULT
OnGitStatusListCtrlCheckChanged(WPARAM
, LPARAM
);
125 afx_msg LRESULT
OnGitStatusListCtrlItemChanged(WPARAM
, LPARAM
);
126 afx_msg
void OnSysColorChange();
128 afx_msg LRESULT
OnCheck(WPARAM count
, LPARAM
);
129 afx_msg LRESULT
OnAutoListReady(WPARAM
, LPARAM
);
130 afx_msg LRESULT
OnUpdateOKButton(WPARAM
, LPARAM
);
131 afx_msg LRESULT
OnUpdateDataFalse(WPARAM
, LPARAM
);
132 afx_msg LRESULT
OnFileDropped(WPARAM
, LPARAM lParam
);
133 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
134 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
136 void StartStatusThread();
137 void StopStatusThread();
138 void GetAutocompletionList();
139 void ScanFile(const CString
& sFilePath
, const CString
& sRegex
, const CString
& sExt
);
140 void DoSize(int delta
);
141 void SetSplitterRange();
142 void SaveSplitterPos();
143 void UpdateCheckLinks();
144 void ParseRegexFile(const CString
& sFile
, std::map
<CString
, CString
>& mapRegex
);
145 void ParseSnippetFile(const CString
& sFile
, std::map
<CString
, CString
>& mapSnippet
);
146 bool RunStartCommitHook();
148 DECLARE_MESSAGE_MAP()
151 CString m_sLogMessage
;
152 BOOL m_bKeepChangeList
;
153 BOOL m_bDoNotAutoselectSubmodules
;
154 bool m_bForceCommitAmend
;
156 BOOL m_bNoPostActions
;
157 bool m_bSelectFilesForCommit
;
161 BOOL m_bWholeProject
;
162 BOOL m_bWholeProject2
;
163 CTGitPathList m_pathList
;
164 CTGitPathList m_checkedPathList
;
165 CTGitPathList m_updatedPathList
;
166 GIT_POSTCOMMIT_CMD m_PostCmd
;
167 BOOL m_bAmendDiffToLastCommit
;
168 BOOL m_bCommitMessageOnly
;
169 bool m_bWarnDetachedHead
;
172 CTGitPathList m_selectedPathList
;
173 CSciEdit m_cLogMessage
;
174 INT_PTR m_itemsCount
;
175 CComPtr
<IBugTraqProvider
> m_BugTraqProvider
;
176 CString m_NoAmendStr
;
177 BOOL m_bCreateNewBranch
;
178 CString m_sCreateNewBranch
;
181 volatile bool m_bDoNotStoreLastSelectedLine
; // true on first start of commit dialog and set on recommit
183 int CheckHeadDetach();
186 CWinThread
* m_pThread
;
187 std::map
<CString
, int> m_autolist
;
188 std::map
<CString
, CString
> m_snippet
;
189 CGitStatusListCtrl m_ListCtrl
;
190 BOOL m_bShowUnversioned
;
191 volatile LONG m_bBlock
;
192 volatile LONG m_bThreadRunning
;
193 volatile LONG m_bRunThread
;
194 CRegDWORD m_regAddBeforeCommit
;
195 CRegDWORD m_regKeepChangelists
;
196 CRegDWORD m_regDoNotAutoselectSubmodules
;
197 CRegDWORD m_regShowWholeProject
;
198 ProjectProperties m_ProjectProperties
;
199 CString m_sWindowTitle
;
200 static UINT WM_AUTOLISTREADY
;
201 static UINT WM_UPDATEOKBUTTON
;
202 static UINT WM_UPDATEDATAFALSE
;
203 int m_nPopupPickCommitHash
;
204 int m_nPopupPickCommitMessage
;
205 int m_nPopupPasteListCmd
;
206 int m_nPopupPasteLastMessage
;
207 int m_nPopupRecentMessage
;
208 CRegHistory m_History
;
210 CSplitterControl m_wndSplitter
;
212 CRect m_LogMsgOrigRect
;
213 CPathWatcher m_pathwatcher
;
214 CHyperLink m_ctrlShowPatch
;
215 CPatchViewDlg m_patchViewdlg
;
216 BOOL m_bSetCommitDateTime
;
217 CDateTimeCtrl m_CommitDate
;
218 CDateTimeCtrl m_CommitTime
;
219 CButton m_AsCommitDateCtrl
;
220 CLinkControl m_linkControl
;
221 CString m_sLogTemplate
;
222 CMenuButton m_ctrlOkButton
;
223 CRegDWORD m_regLastAction
;
224 void PrepareOkButton();
231 std::map
<TCHAR
, ACCELLERATOR
> m_accellerators
;
232 HACCEL m_hAccelOkButton
;
234 CBugTraqAssociation m_bugtraq_association
;
236 bool RestoreFiles(bool doNotAsk
= false, bool allowCancel
= true);
239 afx_msg
void OnBnClickedSignOff();
240 afx_msg
void OnBnClickedCommitAmend();
241 afx_msg
void OnBnClickedCommitMessageOnly();
242 afx_msg
void OnBnClickedWholeProject();
243 afx_msg
void OnScnUpdateUI(NMHDR
*pNMHDR
, LRESULT
*pResult
);
244 afx_msg
void OnStnClickedViewPatch();
245 afx_msg
void OnMoving(UINT fwSide
, LPRECT pRect
);
246 afx_msg
void OnSizing(UINT fwSide
, LPRECT pRect
);
247 afx_msg
void OnHdnItemchangedFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
248 afx_msg
void OnBnClickedCommitAmenddiff();
249 afx_msg
void OnBnClickedNoautoselectsubmodules();
250 afx_msg
void OnBnClickedCommitSetDateTime();
251 afx_msg
void OnBnClickedCommitAsCommitDate();
252 afx_msg
void OnBnClickedCheckNewBranch();
253 afx_msg
void OnBnClickedCommitSetauthor();
255 CLinkControl m_CheckAll
;
256 CLinkControl m_CheckNone
;
257 CLinkControl m_CheckUnversioned
;
258 CLinkControl m_CheckVersioned
;
259 CLinkControl m_CheckAdded
;
260 CLinkControl m_CheckDeleted
;
261 CLinkControl m_CheckModified
;
262 CLinkControl m_CheckFiles
;
263 CLinkControl m_CheckSubmodules
;