Make sure buffer is large enough for the nul terminator
[TortoiseGit.git] / src / TortoiseProc / CommitDlg.h
blob484307a715d3ad880cb3caf954f3483cd4ecd4c5
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 "..\IBugTraqProvider\IBugTraqProvider_h.h"
32 #include "Git.h"
33 #include "HyperLink.h"
34 #include "PatchViewDlg.h"
36 #include <regex>
38 #define ENDDIALOGTIMER 100
39 #define REFRESHTIMER 101
40 #define FILLPATCHVTIMER 102
42 typedef enum
44 GIT_POSTCOMMIT_CMD_NOTHING,
45 GIT_POSTCOMMIT_CMD_RECOMMIT,
46 GIT_POSTCOMMIT_CMD_PUSH,
47 GIT_POSTCOMMIT_CMD_DCOMMIT,
48 GIT_POSTCOMMIT_CMD_PULL,
49 GIT_POSTCOMMIT_CMD_CREATETAG,
50 } GIT_POSTCOMMIT_CMD;
53 /**
54 * \ingroup TortoiseProc
55 * Dialog to enter log messages used in a commit.
57 class CCommitDlg : public CResizableStandAloneDialog, public CSciEditContextMenuInterface, IHasPatchView
59 DECLARE_DYNAMIC(CCommitDlg)
61 public:
62 CCommitDlg(CWnd* pParent = NULL); // standard constructor
63 virtual ~CCommitDlg();
65 protected:
66 // CSciEditContextMenuInterface
67 virtual void InsertMenuItems(CMenu& mPopup, int& nCmd);
68 virtual bool HandleMenuItemClick(int cmd, CSciEdit * pSciEdit);
69 virtual void HandleSnippet(int type, const CString &text, CSciEdit *pSciEdit);
71 public:
72 void ShowViewPatchText(bool b=true)
74 if(b)
75 this->m_ctrlShowPatch.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_SHOWPATCH)));
76 else
77 this->m_ctrlShowPatch.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_HIDEPATCH)));
79 m_ctrlShowPatch.Invalidate();
81 private:
82 static UINT StatusThreadEntry(LPVOID pVoid);
83 UINT StatusThread();
84 void FillPatchView(bool onlySetTimer = false);
85 CWnd * GetPatchViewParentWnd() { return this; }
86 virtual void TogglePatchView();
87 void SetDlgTitle();
88 CString GetSignedOffByLine();
89 CString m_sTitle;
91 // Dialog Data
92 enum { IDD = IDD_COMMITDLG };
94 protected:
95 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
97 virtual BOOL OnInitDialog();
98 virtual void OnOK();
99 virtual void OnCancel();
100 virtual BOOL PreTranslateMessage(MSG* pMsg);
101 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
102 afx_msg void OnBnClickedShowunversioned();
103 afx_msg void OnBnClickedHistory();
104 afx_msg void OnBnClickedBugtraqbutton();
105 afx_msg void OnEnChangeLogmessage();
106 afx_msg void OnStnClickedExternalwarning();
107 afx_msg void OnFocusMessage();
108 afx_msg void OnFocusFileList();
109 afx_msg LRESULT OnGitStatusListCtrlItemCountChanged(WPARAM, LPARAM);
110 afx_msg LRESULT OnGitStatusListCtrlNeedsRefresh(WPARAM, LPARAM);
111 afx_msg LRESULT OnGitStatusListCtrlCheckChanged(WPARAM, LPARAM);
112 afx_msg LRESULT OnGitStatusListCtrlItemChanged(WPARAM, LPARAM);
114 afx_msg LRESULT OnCheck(WPARAM count, LPARAM);
115 afx_msg LRESULT OnAutoListReady(WPARAM, LPARAM);
116 afx_msg LRESULT OnUpdateOKButton(WPARAM, LPARAM);
117 afx_msg LRESULT OnUpdateDataFalse(WPARAM, LPARAM);
118 afx_msg LRESULT OnFileDropped(WPARAM, LPARAM lParam);
119 afx_msg void OnTimer(UINT_PTR nIDEvent);
120 afx_msg void OnSize(UINT nType, int cx, int cy);
121 void Refresh();
122 void GetAutocompletionList();
123 void ScanFile(const CString& sFilePath, const CString& sRegex, const CString& sExt);
124 void DoSize(int delta);
125 void SetSplitterRange();
126 void SaveSplitterPos();
127 void UpdateCheckLinks();
128 void ParseRegexFile(const CString& sFile, std::map<CString, CString>& mapRegex);
129 void ParseSnippetFile(const CString& sFile, std::map<CString, CString>& mapSnippet);
130 void RunStartCommitHook();
132 DECLARE_MESSAGE_MAP()
134 public:
135 CString m_sLogMessage;
136 BOOL m_bKeepChangeList;
137 BOOL m_bDoNotAutoselectSubmodules;
138 bool m_bForceCommitAmend;
139 BOOL m_bCommitAmend;
140 BOOL m_bNoPostActions;
141 bool m_bSelectFilesForCommit;
142 bool m_bAutoClose;
143 CString m_AmendStr;
144 CString m_sBugID;
145 BOOL m_bWholeProject;
146 BOOL m_bWholeProject2;
147 CTGitPathList m_pathList;
148 CTGitPathList m_checkedPathList;
149 CTGitPathList m_updatedPathList;
150 GIT_POSTCOMMIT_CMD m_PostCmd;
151 BOOL m_bAmendDiffToLastCommit;
152 BOOL m_bCommitMessageOnly;
153 bool m_bWarnDetachedHead;
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 CRegDWORD m_regAddBeforeCommit;
178 CRegDWORD m_regKeepChangelists;
179 CRegDWORD m_regDoNotAutoselectSubmodules;
180 CRegDWORD m_regShowWholeProject;
181 ProjectProperties m_ProjectProperties;
182 CString m_sWindowTitle;
183 static UINT WM_AUTOLISTREADY;
184 static UINT WM_UPDATEOKBUTTON;
185 static UINT WM_UPDATEDATAFALSE;
186 int m_nPopupPickCommitHash;
187 int m_nPopupPickCommitMessage;
188 int m_nPopupPasteListCmd;
189 int m_nPopupPasteLastMessage;
190 int m_nPopupRecentMessage;
191 CRegHistory m_History;
192 bool m_bCancelled;
193 CSplitterControl m_wndSplitter;
194 CRect m_DlgOrigRect;
195 CRect m_LogMsgOrigRect;
196 CPathWatcher m_pathwatcher;
197 CHyperLink m_ctrlShowPatch;
198 CPatchViewDlg m_patchViewdlg;
199 BOOL m_bSetCommitDateTime;
200 CDateTimeCtrl m_CommitDate;
201 CDateTimeCtrl m_CommitTime;
202 CButton m_AsCommitDateCtrl;
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 OnBnClickedCommitAsCommitDate();
224 afx_msg void OnBnClickedCheckNewBranch();
225 afx_msg void OnBnClickedCommitSetauthor();