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
;
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
;
166 int CheckHeadDetach();
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
;
194 CSplitterControl m_wndSplitter
;
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
;
208 void RestoreFiles(bool doNotAsk
= false);
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();