Allow to use libgit2 for unified diff
[TortoiseGit.git] / src / TortoiseProc / CommitDlg.h
blob30c6163e1ed44165d26da6f9dbbb9cee29f04376
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2013 - 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 "ProjectProperties.h"
25 #include "RegHistory.h"
26 #include "registry.h"
27 #include "SciEdit.h"
28 #include "SplitterControl.h"
29 #include "LinkControl.h"
30 #include "PathWatcher.h"
31 #include "BugTraqAssociations.h"
32 #include "Tooltip.h"
33 #include "..\IBugTraqProvider\IBugTraqProvider_h.h"
34 #include "Git.h"
35 #include "HyperLink.h"
36 #include "PatchViewDlg.h"
38 #include <regex>
39 using namespace std;
41 #define ENDDIALOGTIMER 100
42 #define REFRESHTIMER 101
43 #define FILLPATCHVTIMER 102
45 /**
46 * \ingroup TortoiseProc
47 * Dialog to enter log messages used in a commit.
49 class CCommitDlg : public CResizableStandAloneDialog, public CSciEditContextMenuInterface
51 DECLARE_DYNAMIC(CCommitDlg)
53 public:
54 CCommitDlg(CWnd* pParent = NULL); // standard constructor
55 virtual ~CCommitDlg();
57 protected:
58 // CSciEditContextMenuInterface
59 virtual void InsertMenuItems(CMenu& mPopup, int& nCmd);
60 virtual bool HandleMenuItemClick(int cmd, CSciEdit * pSciEdit);
62 public:
63 void ShowViewPatchText(bool b=true)
65 if(b)
66 this->m_ctrlShowPatch.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_SHOWPATCH)));
67 else
68 this->m_ctrlShowPatch.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_HIDEPATCH)));
70 m_ctrlShowPatch.Invalidate();
72 private:
73 static UINT StatusThreadEntry(LPVOID pVoid);
74 UINT StatusThread();
75 void FillPatchView(bool onlySetTimer = false);
76 void SetDlgTitle();
77 CString GetSignedOffByLine();
78 CString m_sTitle;
80 // Dialog Data
81 enum { IDD = IDD_COMMITDLG };
83 protected:
84 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
86 virtual BOOL OnInitDialog();
87 virtual void OnOK();
88 virtual void OnCancel();
89 virtual BOOL PreTranslateMessage(MSG* pMsg);
90 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
91 afx_msg void OnBnClickedHelp();
92 afx_msg void OnBnClickedShowunversioned();
93 afx_msg void OnBnClickedHistory();
94 afx_msg void OnBnClickedBugtraqbutton();
95 afx_msg void OnEnChangeLogmessage();
96 afx_msg void OnStnClickedExternalwarning();
97 afx_msg void OnFocusMessage();
98 afx_msg LRESULT OnGitStatusListCtrlItemCountChanged(WPARAM, LPARAM);
99 afx_msg LRESULT OnGitStatusListCtrlNeedsRefresh(WPARAM, LPARAM);
100 afx_msg LRESULT OnGitStatusListCtrlCheckChanged(WPARAM, LPARAM);
101 afx_msg LRESULT OnGitStatusListCtrlItemChanged(WPARAM, LPARAM);
103 afx_msg LRESULT OnCheck(WPARAM count, LPARAM);
104 afx_msg LRESULT OnAutoListReady(WPARAM, LPARAM);
105 afx_msg LRESULT OnUpdateOKButton(WPARAM, LPARAM);
106 afx_msg LRESULT OnUpdateDataFalse(WPARAM, LPARAM);
107 afx_msg LRESULT OnFileDropped(WPARAM, LPARAM lParam);
108 afx_msg void OnTimer(UINT_PTR nIDEvent);
109 afx_msg void OnSize(UINT nType, int cx, int cy);
110 void Refresh();
111 void GetAutocompletionList();
112 void ScanFile(const CString& sFilePath, const CString& sRegex);
113 void DoSize(int delta);
114 void SetSplitterRange();
115 void SaveSplitterPos();
116 void UpdateCheckLinks();
117 void ParseRegexFile(const CString& sFile, std::map<CString, CString>& mapRegex);
119 DECLARE_MESSAGE_MAP()
121 public:
122 CString m_sLogMessage;
123 BOOL m_bKeepChangeList;
124 BOOL m_bDoNotAutoselectSubmodules;
125 bool m_bForceCommitAmend;
126 BOOL m_bCommitAmend;
127 BOOL m_bNoPostActions;
128 bool m_bSelectFilesForCommit;
129 bool m_bAutoClose;
130 CString m_AmendStr;
131 CString m_sBugID;
132 BOOL m_bWholeProject;
133 CTGitPathList m_pathList;
134 CTGitPathList m_checkedPathList;
135 CTGitPathList m_updatedPathList;
136 int m_PostCmd;
137 BOOL m_bPushAfterCommit;
138 BOOL m_bCreateTagAfterCommit;
139 BOOL m_bAmendDiffToLastCommit;
140 BOOL m_bCommitMessageOnly;
142 protected:
143 CTGitPathList m_selectedPathList;
144 BOOL m_bRecursive;
145 CSciEdit m_cLogMessage;
146 CString m_sChangeList;
147 INT_PTR m_itemsCount;
148 CComPtr<IBugTraqProvider> m_BugTraqProvider;
149 CString m_NoAmendStr;
150 BOOL m_bCreateNewBranch;
151 CString m_sCreateNewBranch;
152 BOOL m_bSetAuthor;
153 CString m_sAuthor;
155 int CheckHeadDetach();
157 private:
158 CWinThread* m_pThread;
159 std::set<CString> m_autolist;
160 CGitStatusListCtrl m_ListCtrl;
161 BOOL m_bShowUnversioned;
162 volatile LONG m_bBlock;
163 volatile LONG m_bThreadRunning;
164 volatile LONG m_bRunThread;
165 CToolTips m_tooltips;
166 CRegDWORD m_regAddBeforeCommit;
167 CRegDWORD m_regKeepChangelists;
168 CRegDWORD m_regDoNotAutoselectSubmodules;
169 ProjectProperties m_ProjectProperties;
170 CString m_sWindowTitle;
171 static UINT WM_AUTOLISTREADY;
172 static UINT WM_UPDATEOKBUTTON;
173 static UINT WM_UPDATEDATAFALSE;
174 int m_nPopupPasteListCmd;
175 int m_nPopupPasteLastMessage;
176 int m_nPopupRecentMessage;
177 CRegHistory m_History;
178 bool m_bCancelled;
179 CSplitterControl m_wndSplitter;
180 CRect m_DlgOrigRect;
181 CRect m_LogMsgOrigRect;
182 CPathWatcher m_pathwatcher;
183 CHyperLink m_ctrlShowPatch;
184 CPatchViewDlg m_patchViewdlg;
185 BOOL m_bSetCommitDateTime;
186 CDateTimeCtrl m_CommitDate;
187 CDateTimeCtrl m_CommitTime;
188 CLinkControl m_linkControl;
190 CBugTraqAssociation m_bugtraq_association;
191 HACCEL m_hAccel;
192 void RestoreFiles(bool doNotAsk = false);
194 protected:
195 afx_msg void OnBnClickedSignOff();
196 afx_msg void OnBnClickedCommitAmend();
197 afx_msg void OnBnClickedCommitMessageOnly();
198 afx_msg void OnBnClickedWholeProject();
199 afx_msg void OnScnUpdateUI(NMHDR *pNMHDR, LRESULT *pResult);
200 afx_msg void OnStnClickedViewPatch();
201 afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
202 afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
203 afx_msg void OnHdnItemchangedFilelist(NMHDR *pNMHDR, LRESULT *pResult);
204 afx_msg void OnBnClickedCommitAmenddiff();
205 afx_msg void OnBnClickedNoautoselectsubmodules();
206 afx_msg void OnBnClickedCommitSetDateTime();
207 afx_msg void OnBnClickedCheckNewBranch();
208 afx_msg void OnBnClickedCommitSetauthor();