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_PUSH
,
47 GIT_POSTCOMMIT_CMD_DCOMMIT
,
48 GIT_POSTCOMMIT_CMD_PULL
,
49 GIT_POSTCOMMIT_CMD_CREATETAG
,
54 * \ingroup TortoiseProc
55 * Dialog to enter log messages used in a commit.
57 class CCommitDlg
: public CResizableStandAloneDialog
, public CSciEditContextMenuInterface
59 DECLARE_DYNAMIC(CCommitDlg
)
62 CCommitDlg(CWnd
* pParent
= NULL
); // standard constructor
63 virtual ~CCommitDlg();
66 // CSciEditContextMenuInterface
67 virtual void InsertMenuItems(CMenu
& mPopup
, int& nCmd
);
68 virtual bool HandleMenuItemClick(int cmd
, CSciEdit
* pSciEdit
);
71 void ShowViewPatchText(bool b
=true)
74 this->m_ctrlShowPatch
.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_SHOWPATCH
)));
76 this->m_ctrlShowPatch
.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_HIDEPATCH
)));
78 m_ctrlShowPatch
.Invalidate();
81 static UINT
StatusThreadEntry(LPVOID pVoid
);
83 void FillPatchView(bool onlySetTimer
= false);
85 CString
GetSignedOffByLine();
89 enum { IDD
= IDD_COMMITDLG
};
92 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
94 virtual BOOL
OnInitDialog();
96 virtual void OnCancel();
97 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
98 virtual LRESULT
DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
);
99 afx_msg
void OnBnClickedShowunversioned();
100 afx_msg
void OnBnClickedHistory();
101 afx_msg
void OnBnClickedBugtraqbutton();
102 afx_msg
void OnEnChangeLogmessage();
103 afx_msg
void OnStnClickedExternalwarning();
104 afx_msg
void OnFocusMessage();
105 afx_msg
void OnFocusFileList();
106 afx_msg LRESULT
OnGitStatusListCtrlItemCountChanged(WPARAM
, LPARAM
);
107 afx_msg LRESULT
OnGitStatusListCtrlNeedsRefresh(WPARAM
, LPARAM
);
108 afx_msg LRESULT
OnGitStatusListCtrlCheckChanged(WPARAM
, LPARAM
);
109 afx_msg LRESULT
OnGitStatusListCtrlItemChanged(WPARAM
, LPARAM
);
111 afx_msg LRESULT
OnCheck(WPARAM count
, LPARAM
);
112 afx_msg LRESULT
OnAutoListReady(WPARAM
, LPARAM
);
113 afx_msg LRESULT
OnUpdateOKButton(WPARAM
, LPARAM
);
114 afx_msg LRESULT
OnUpdateDataFalse(WPARAM
, LPARAM
);
115 afx_msg LRESULT
OnFileDropped(WPARAM
, LPARAM lParam
);
116 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
117 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
119 void GetAutocompletionList();
120 void ScanFile(const CString
& sFilePath
, const CString
& sRegex
, const CString
& sExt
);
121 void DoSize(int delta
);
122 void SetSplitterRange();
123 void SaveSplitterPos();
124 void UpdateCheckLinks();
125 void ParseRegexFile(const CString
& sFile
, std::map
<CString
, CString
>& mapRegex
);
127 DECLARE_MESSAGE_MAP()
130 CString m_sLogMessage
;
131 BOOL m_bKeepChangeList
;
132 BOOL m_bDoNotAutoselectSubmodules
;
133 bool m_bForceCommitAmend
;
135 BOOL m_bNoPostActions
;
136 bool m_bSelectFilesForCommit
;
140 BOOL m_bWholeProject
;
141 BOOL m_bWholeProject2
;
142 CTGitPathList m_pathList
;
143 CTGitPathList m_checkedPathList
;
144 CTGitPathList m_updatedPathList
;
145 GIT_POSTCOMMIT_CMD m_PostCmd
;
146 BOOL m_bAmendDiffToLastCommit
;
147 BOOL m_bCommitMessageOnly
;
150 CTGitPathList m_selectedPathList
;
152 CSciEdit m_cLogMessage
;
153 CString m_sChangeList
;
154 INT_PTR m_itemsCount
;
155 CComPtr
<IBugTraqProvider
> m_BugTraqProvider
;
156 CString m_NoAmendStr
;
157 BOOL m_bCreateNewBranch
;
158 CString m_sCreateNewBranch
;
162 int CheckHeadDetach();
165 CWinThread
* m_pThread
;
166 std::set
<CString
> m_autolist
;
167 CGitStatusListCtrl m_ListCtrl
;
168 BOOL m_bShowUnversioned
;
169 volatile LONG m_bBlock
;
170 volatile LONG m_bThreadRunning
;
171 volatile LONG m_bRunThread
;
172 CToolTips m_tooltips
;
173 CRegDWORD m_regAddBeforeCommit
;
174 CRegDWORD m_regKeepChangelists
;
175 CRegDWORD m_regDoNotAutoselectSubmodules
;
176 CRegDWORD m_regShowWholeProject
;
177 ProjectProperties m_ProjectProperties
;
178 CString m_sWindowTitle
;
179 static UINT WM_AUTOLISTREADY
;
180 static UINT WM_UPDATEOKBUTTON
;
181 static UINT WM_UPDATEDATAFALSE
;
182 int m_nPopupPickCommitHash
;
183 int m_nPopupPickCommitMessage
;
184 int m_nPopupPasteListCmd
;
185 int m_nPopupPasteLastMessage
;
186 int m_nPopupRecentMessage
;
187 CRegHistory m_History
;
189 CSplitterControl m_wndSplitter
;
191 CRect m_LogMsgOrigRect
;
192 CPathWatcher m_pathwatcher
;
193 CHyperLink m_ctrlShowPatch
;
194 CPatchViewDlg m_patchViewdlg
;
195 BOOL m_bSetCommitDateTime
;
196 CDateTimeCtrl m_CommitDate
;
197 CDateTimeCtrl m_CommitTime
;
198 CLinkControl m_linkControl
;
199 CString m_sLogTemplate
;
201 CBugTraqAssociation m_bugtraq_association
;
203 void RestoreFiles(bool doNotAsk
= false);
206 afx_msg
void OnBnClickedSignOff();
207 afx_msg
void OnBnClickedCommitAmend();
208 afx_msg
void OnBnClickedCommitMessageOnly();
209 afx_msg
void OnBnClickedWholeProject();
210 afx_msg
void OnScnUpdateUI(NMHDR
*pNMHDR
, LRESULT
*pResult
);
211 afx_msg
void OnStnClickedViewPatch();
212 afx_msg
void OnMoving(UINT fwSide
, LPRECT pRect
);
213 afx_msg
void OnSizing(UINT fwSide
, LPRECT pRect
);
214 afx_msg
void OnHdnItemchangedFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
215 afx_msg
void OnBnClickedCommitAmenddiff();
216 afx_msg
void OnBnClickedNoautoselectsubmodules();
217 afx_msg
void OnBnClickedCommitSetDateTime();
218 afx_msg
void OnBnClickedCheckNewBranch();
219 afx_msg
void OnBnClickedCommitSetauthor();