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.
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"
32 #include "..\IBugTraqProvider\IBugTraqProvider_h.h"
34 #include "HyperLink.h"
35 #include "PatchViewDlg.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
= NULL
); // 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();
83 static UINT
StatusThreadEntry(LPVOID pVoid
);
85 void FillPatchView(bool onlySetTimer
= false);
86 CWnd
* GetPatchViewParentWnd() { return this; }
87 virtual void TogglePatchView();
89 CString
GetSignedOffByLine();
93 enum { IDD
= IDD_COMMITDLG
};
96 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
98 virtual BOOL
OnInitDialog();
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
);
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()
136 CString m_sLogMessage
;
137 BOOL m_bKeepChangeList
;
138 BOOL m_bDoNotAutoselectSubmodules
;
139 bool m_bForceCommitAmend
;
141 BOOL m_bNoPostActions
;
142 bool m_bSelectFilesForCommit
;
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
;
154 bool m_bWarnDetachedHead
;
157 CTGitPathList m_selectedPathList
;
158 CSciEdit m_cLogMessage
;
159 INT_PTR m_itemsCount
;
160 CComPtr
<IBugTraqProvider
> m_BugTraqProvider
;
161 CString m_NoAmendStr
;
162 BOOL m_bCreateNewBranch
;
163 CString m_sCreateNewBranch
;
167 int CheckHeadDetach();
170 CWinThread
* m_pThread
;
171 std::map
<CString
, int> m_autolist
;
172 std::map
<CString
, CString
> m_snippet
;
173 CGitStatusListCtrl m_ListCtrl
;
174 BOOL m_bShowUnversioned
;
175 volatile LONG m_bBlock
;
176 volatile LONG m_bThreadRunning
;
177 volatile LONG m_bRunThread
;
178 CToolTips m_tooltips
;
179 CRegDWORD m_regAddBeforeCommit
;
180 CRegDWORD m_regKeepChangelists
;
181 CRegDWORD m_regDoNotAutoselectSubmodules
;
182 CRegDWORD m_regShowWholeProject
;
183 ProjectProperties m_ProjectProperties
;
184 CString m_sWindowTitle
;
185 static UINT WM_AUTOLISTREADY
;
186 static UINT WM_UPDATEOKBUTTON
;
187 static UINT WM_UPDATEDATAFALSE
;
188 int m_nPopupPickCommitHash
;
189 int m_nPopupPickCommitMessage
;
190 int m_nPopupPasteListCmd
;
191 int m_nPopupPasteLastMessage
;
192 int m_nPopupRecentMessage
;
193 CRegHistory m_History
;
195 CSplitterControl m_wndSplitter
;
197 CRect m_LogMsgOrigRect
;
198 CPathWatcher m_pathwatcher
;
199 CHyperLink m_ctrlShowPatch
;
200 CPatchViewDlg m_patchViewdlg
;
201 BOOL m_bSetCommitDateTime
;
202 CDateTimeCtrl m_CommitDate
;
203 CDateTimeCtrl m_CommitTime
;
204 CLinkControl m_linkControl
;
205 CString m_sLogTemplate
;
207 CBugTraqAssociation m_bugtraq_association
;
209 void RestoreFiles(bool doNotAsk
= false);
212 afx_msg
void OnBnClickedSignOff();
213 afx_msg
void OnBnClickedCommitAmend();
214 afx_msg
void OnBnClickedCommitMessageOnly();
215 afx_msg
void OnBnClickedWholeProject();
216 afx_msg
void OnScnUpdateUI(NMHDR
*pNMHDR
, LRESULT
*pResult
);
217 afx_msg
void OnStnClickedViewPatch();
218 afx_msg
void OnMoving(UINT fwSide
, LPRECT pRect
);
219 afx_msg
void OnSizing(UINT fwSide
, LPRECT pRect
);
220 afx_msg
void OnHdnItemchangedFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
221 afx_msg
void OnBnClickedCommitAmenddiff();
222 afx_msg
void OnBnClickedNoautoselectsubmodules();
223 afx_msg
void OnBnClickedCommitSetDateTime();
224 afx_msg
void OnBnClickedCheckNewBranch();
225 afx_msg
void OnBnClickedCommitSetauthor();