OSDN Git Service

10751b04a7b2248eed438b62578caa1eb9c55463
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / CommitDlg.cpp
1 // TortoiseGit - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseGit\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #include "stdafx.h"\r
20 #include "TortoiseProc.h"\r
21 #include "CommitDlg.h"\r
22 #include "DirFileEnum.h"\r
23 //#include "GitConfig.h"\r
24 //#include "GitProperties.h"\r
25 #include "MessageBox.h"\r
26 #include "AppUtils.h"\r
27 #include "PathUtils.h"\r
28 #include "Git.h"\r
29 #include "Registry.h"\r
30 #include "GitStatus.h"\r
31 #include "HistoryDlg.h"\r
32 #include "Hooks.h"\r
33 #include "CommonResource.h"\r
34 #include "UnicodeUtils.h"\r
35 \r
36 #ifdef _DEBUG\r
37 #define new DEBUG_NEW\r
38 #undef THIS_FILE\r
39 static char THIS_FILE[] = __FILE__;\r
40 #endif\r
41 \r
42 UINT CCommitDlg::WM_AUTOLISTREADY = RegisterWindowMessage(_T("TORTOISEGIT_AUTOLISTREADY_MSG"));\r
43 \r
44 IMPLEMENT_DYNAMIC(CCommitDlg, CResizableStandAloneDialog)\r
45 CCommitDlg::CCommitDlg(CWnd* pParent /*=NULL*/)\r
46         : CResizableStandAloneDialog(CCommitDlg::IDD, pParent)\r
47         , m_bRecursive(FALSE)\r
48         , m_bShowUnversioned(FALSE)\r
49         , m_bBlock(FALSE)\r
50         , m_bThreadRunning(FALSE)\r
51         , m_bRunThread(FALSE)\r
52         , m_pThread(NULL)\r
53         , m_bKeepLocks(FALSE)\r
54         , m_bKeepChangeList(TRUE)\r
55         , m_itemsCount(0)\r
56         , m_bSelectFilesForCommit(TRUE)\r
57 {\r
58 }\r
59 \r
60 CCommitDlg::~CCommitDlg()\r
61 {\r
62         if(m_pThread != NULL)\r
63         {\r
64                 delete m_pThread;\r
65         }\r
66 }\r
67 \r
68 void CCommitDlg::DoDataExchange(CDataExchange* pDX)\r
69 {\r
70         CResizableStandAloneDialog::DoDataExchange(pDX);\r
71         DDX_Control(pDX, IDC_FILELIST, m_ListCtrl);\r
72         DDX_Control(pDX, IDC_LOGMESSAGE, m_cLogMessage);\r
73         DDX_Check(pDX, IDC_SHOWUNVERSIONED, m_bShowUnversioned);\r
74         DDX_Control(pDX, IDC_SELECTALL, m_SelectAll);\r
75         DDX_Text(pDX, IDC_BUGID, m_sBugID);\r
76         DDX_Check(pDX, IDC_KEEPLOCK, m_bKeepLocks);\r
77         DDX_Control(pDX, IDC_SPLITTER, m_wndSplitter);\r
78         DDX_Check(pDX, IDC_KEEPLISTS, m_bKeepChangeList);\r
79 }\r
80 \r
81 BEGIN_MESSAGE_MAP(CCommitDlg, CResizableStandAloneDialog)\r
82         ON_BN_CLICKED(IDC_SELECTALL, OnBnClickedSelectall)\r
83         ON_BN_CLICKED(IDHELP, OnBnClickedHelp)\r
84         ON_BN_CLICKED(IDC_SHOWUNVERSIONED, OnBnClickedShowunversioned)\r
85 //      ON_BN_CLICKED(IDC_HISTORY, OnBnClickedHistory)\r
86         ON_BN_CLICKED(IDC_BUGTRAQBUTTON, OnBnClickedBugtraqbutton)\r
87         ON_EN_CHANGE(IDC_LOGMESSAGE, OnEnChangeLogmessage)\r
88         ON_REGISTERED_MESSAGE(CGitStatusListCtrl::SVNSLNM_ITEMCOUNTCHANGED, OnGitStatusListCtrlItemCountChanged)\r
89         ON_REGISTERED_MESSAGE(CGitStatusListCtrl::SVNSLNM_NEEDSREFRESH, OnGitStatusListCtrlNeedsRefresh)\r
90         ON_REGISTERED_MESSAGE(CGitStatusListCtrl::SVNSLNM_ADDFILE, OnFileDropped)\r
91         ON_REGISTERED_MESSAGE(CGitStatusListCtrl::SVNSLNM_CHECKCHANGED, &CCommitDlg::OnGitStatusListCtrlCheckChanged)\r
92         ON_REGISTERED_MESSAGE(WM_AUTOLISTREADY, OnAutoListReady) \r
93         ON_WM_TIMER()\r
94     ON_WM_SIZE()\r
95         ON_STN_CLICKED(IDC_EXTERNALWARNING, &CCommitDlg::OnStnClickedExternalwarning)\r
96         ON_BN_CLICKED(IDC_SIGNOFF, &CCommitDlg::OnBnClickedSignOff)\r
97         ON_STN_CLICKED(IDC_COMMITLABEL, &CCommitDlg::OnStnClickedCommitlabel)\r
98     ON_BN_CLICKED(IDC_COMMIT_AMEND, &CCommitDlg::OnBnClickedCommitAmend)\r
99 END_MESSAGE_MAP()\r
100 \r
101 BOOL CCommitDlg::OnInitDialog()\r
102 {\r
103         CResizableStandAloneDialog::OnInitDialog();\r
104         \r
105         m_regAddBeforeCommit = CRegDWORD(_T("Software\\TortoiseGit\\AddBeforeCommit"), TRUE);\r
106         m_bShowUnversioned = m_regAddBeforeCommit;\r
107 \r
108         m_History.SetMaxHistoryItems((LONG)CRegDWORD(_T("Software\\TortoiseGit\\MaxHistoryItems"), 25));\r
109 \r
110         m_regKeepChangelists = CRegDWORD(_T("Software\\TortoiseGit\\KeepChangeLists"), FALSE);\r
111         m_bKeepChangeList = m_regKeepChangelists;\r
112 \r
113 //      GitConfig config;\r
114 //      m_bKeepLocks = config.KeepLocks();\r
115 \r
116         UpdateData(FALSE);\r
117         \r
118         m_ListCtrl.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS , _T("CommitDlg"));\r
119         m_ListCtrl.SetSelectButton(&m_SelectAll);\r
120         m_ListCtrl.SetStatLabel(GetDlgItem(IDC_STATISTICS));\r
121         m_ListCtrl.SetCancelBool(&m_bCancelled);\r
122         m_ListCtrl.SetEmptyString(IDS_COMMITDLG_NOTHINGTOCOMMIT);\r
123         m_ListCtrl.EnableFileDrop();\r
124         m_ListCtrl.SetBackgroundImage(IDI_COMMIT_BKG);\r
125         \r
126         this->DialogEnableWindow(IDC_COMMIT_AMEND,FALSE);\r
127 //      m_ProjectProperties.ReadPropsPathList(m_pathList);\r
128         m_cLogMessage.Init(m_ProjectProperties);\r
129         m_cLogMessage.SetFont((CString)CRegString(_T("Software\\TortoiseGit\\LogFontName"), _T("Courier New")), (DWORD)CRegDWORD(_T("Software\\TortoiseGit\\LogFontSize"), 8));\r
130         m_cLogMessage.RegisterContextMenuHandler(this);\r
131 \r
132         OnEnChangeLogmessage();\r
133 \r
134         m_tooltips.Create(this);\r
135         m_tooltips.AddTool(IDC_EXTERNALWARNING, IDS_COMMITDLG_EXTERNALS);\r
136 //      m_tooltips.AddTool(IDC_HISTORY, IDS_COMMITDLG_HISTORY_TT);\r
137         \r
138         m_SelectAll.SetCheck(BST_INDETERMINATE);\r
139 \r
140 #if 0\r
141         CBugTraqAssociations bugtraq_associations;\r
142         bugtraq_associations.Load();\r
143 \r
144         if (bugtraq_associations.FindProvider(m_pathList, &m_bugtraq_association))\r
145         {\r
146                 GetDlgItem(IDC_BUGID)->ShowWindow(SW_HIDE);\r
147                 GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_HIDE);\r
148 \r
149                 CComPtr<IBugTraqProvider> pProvider;\r
150                 HRESULT hr = pProvider.CoCreateInstance(m_bugtraq_association.GetProviderClass());\r
151                 if (SUCCEEDED(hr))\r
152                 {\r
153                         m_BugTraqProvider = pProvider;\r
154                         BSTR temp = NULL;\r
155                         if (SUCCEEDED(hr = pProvider->GetLinkText(GetSafeHwnd(), m_bugtraq_association.GetParameters().AllocSysString(), &temp)))\r
156                         {\r
157                                 SetDlgItemText(IDC_BUGTRAQBUTTON, temp);\r
158                                 GetDlgItem(IDC_BUGTRAQBUTTON)->EnableWindow(TRUE);\r
159                                 GetDlgItem(IDC_BUGTRAQBUTTON)->ShowWindow(SW_SHOW);\r
160                         }\r
161 \r
162                         SysFreeString(temp);\r
163                 }\r
164 \r
165                 GetDlgItem(IDC_LOGMESSAGE)->SetFocus();\r
166         }\r
167         else if (!m_ProjectProperties.sMessage.IsEmpty())\r
168         {\r
169                 GetDlgItem(IDC_BUGID)->ShowWindow(SW_SHOW);\r
170                 GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_SHOW);\r
171                 if (!m_ProjectProperties.sLabel.IsEmpty())\r
172                         SetDlgItemText(IDC_BUGIDLABEL, m_ProjectProperties.sLabel);\r
173                 GetDlgItem(IDC_BUGTRAQBUTTON)->ShowWindow(SW_HIDE);\r
174                 GetDlgItem(IDC_BUGTRAQBUTTON)->EnableWindow(FALSE);\r
175                 GetDlgItem(IDC_BUGID)->SetFocus();\r
176                 CString sBugID = m_ProjectProperties.GetBugIDFromLog(m_sLogMessage);\r
177                 if (!sBugID.IsEmpty())\r
178                 {\r
179                         SetDlgItemText(IDC_BUGID, sBugID);\r
180                 }\r
181         }\r
182         else\r
183 #endif\r
184         {\r
185                 GetDlgItem(IDC_BUGID)->ShowWindow(SW_HIDE);\r
186                 GetDlgItem(IDC_BUGIDLABEL)->ShowWindow(SW_HIDE);\r
187                 GetDlgItem(IDC_BUGTRAQBUTTON)->ShowWindow(SW_HIDE);\r
188                 GetDlgItem(IDC_BUGTRAQBUTTON)->EnableWindow(FALSE);\r
189                 GetDlgItem(IDC_LOGMESSAGE)->SetFocus();\r
190         }\r
191 \r
192         if (!m_sLogMessage.IsEmpty())\r
193                 m_cLogMessage.SetText(m_sLogMessage);\r
194                 \r
195         GetWindowText(m_sWindowTitle);\r
196         \r
197         AdjustControlSize(IDC_SHOWUNVERSIONED);\r
198         AdjustControlSize(IDC_SELECTALL);\r
199         AdjustControlSize(IDC_KEEPLOCK);\r
200 \r
201         GetClientRect(m_DlgOrigRect);\r
202         m_cLogMessage.GetClientRect(m_LogMsgOrigRect);\r
203 \r
204         AddAnchor(IDC_COMMITLABEL, TOP_LEFT, TOP_RIGHT);\r
205         AddAnchor(IDC_BUGIDLABEL, TOP_RIGHT);\r
206         AddAnchor(IDC_BUGID, TOP_RIGHT);\r
207         AddAnchor(IDC_BUGTRAQBUTTON, TOP_RIGHT);\r
208         AddAnchor(IDC_COMMIT_TO, TOP_LEFT, TOP_RIGHT);\r
209         AddAnchor(IDC_MESSAGEGROUP, TOP_LEFT, TOP_RIGHT);\r
210 //      AddAnchor(IDC_HISTORY, TOP_LEFT);\r
211         AddAnchor(IDC_LOGMESSAGE, TOP_LEFT, TOP_RIGHT);\r
212         AddAnchor(IDC_SIGNOFF,   TOP_RIGHT);\r
213         AddAnchor(IDC_LISTGROUP, TOP_LEFT, BOTTOM_RIGHT);\r
214         AddAnchor(IDC_SPLITTER, TOP_LEFT, TOP_RIGHT);\r
215         AddAnchor(IDC_FILELIST, TOP_LEFT, BOTTOM_RIGHT);\r
216         AddAnchor(IDC_SHOWUNVERSIONED, BOTTOM_LEFT);\r
217         AddAnchor(IDC_SELECTALL, BOTTOM_LEFT);\r
218         AddAnchor(IDC_EXTERNALWARNING, BOTTOM_RIGHT);\r
219         AddAnchor(IDC_STATISTICS, BOTTOM_LEFT, BOTTOM_RIGHT);\r
220         AddAnchor(IDC_KEEPLOCK, BOTTOM_LEFT);\r
221         AddAnchor(IDC_KEEPLISTS, BOTTOM_LEFT);\r
222         AddAnchor(IDOK, BOTTOM_RIGHT);\r
223         AddAnchor(IDCANCEL, BOTTOM_RIGHT);\r
224         AddAnchor(IDHELP, BOTTOM_RIGHT);\r
225         \r
226         if (hWndExplorer)\r
227                 CenterWindow(CWnd::FromHandle(hWndExplorer));\r
228         EnableSaveRestore(_T("CommitDlg"));\r
229         DWORD yPos = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\CommitDlgSizer"));\r
230         RECT rcDlg, rcLogMsg, rcFileList;\r
231         GetClientRect(&rcDlg);\r
232         m_cLogMessage.GetWindowRect(&rcLogMsg);\r
233         ScreenToClient(&rcLogMsg);\r
234         m_ListCtrl.GetWindowRect(&rcFileList);\r
235         ScreenToClient(&rcFileList);\r
236         if (yPos)\r
237         {\r
238                 RECT rectSplitter;\r
239                 m_wndSplitter.GetWindowRect(&rectSplitter);\r
240                 ScreenToClient(&rectSplitter);\r
241                 int delta = yPos - rectSplitter.top;\r
242                 if ((rcLogMsg.bottom + delta > rcLogMsg.top)&&(rcLogMsg.bottom + delta < rcFileList.bottom - 30))\r
243                 {\r
244                         m_wndSplitter.SetWindowPos(NULL, 0, yPos, 0, 0, SWP_NOSIZE);\r
245                         DoSize(delta);\r
246                 }\r
247         }\r
248 \r
249         // add all directories to the watcher\r
250         for (int i=0; i<m_pathList.GetCount(); ++i)\r
251         {\r
252                 if (m_pathList[i].IsDirectory())\r
253                         m_pathwatcher.AddPath(m_pathList[i]);\r
254         }\r
255 \r
256         m_updatedPathList = m_pathList;\r
257 \r
258         //first start a thread to obtain the file list with the status without\r
259         //blocking the dialog\r
260         InterlockedExchange(&m_bBlock, TRUE);\r
261         m_pThread = AfxBeginThread(StatusThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);\r
262         if (m_pThread==NULL)\r
263         {\r
264                 CMessageBox::Show(this->m_hWnd, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);\r
265                 InterlockedExchange(&m_bBlock, FALSE);\r
266         }\r
267         else\r
268         {\r
269                 m_pThread->m_bAutoDelete = FALSE;\r
270                 m_pThread->ResumeThread();\r
271         }\r
272         CRegDWORD err = CRegDWORD(_T("Software\\TortoiseGit\\ErrorOccurred"), FALSE);\r
273         CRegDWORD historyhint = CRegDWORD(_T("Software\\TortoiseGit\\HistoryHintShown"), FALSE);\r
274         if ((((DWORD)err)!=FALSE)&&((((DWORD)historyhint)==FALSE)))\r
275         {\r
276                 historyhint = TRUE;\r
277 //              ShowBalloon(IDC_HISTORY, IDS_COMMITDLG_HISTORYHINT_TT, IDI_INFORMATION);\r
278         }\r
279         err = FALSE;\r
280 \r
281 \r
282         return FALSE;  // return TRUE unless you set the focus to a control\r
283         // EXCEPTION: OCX Property Pages should return FALSE\r
284 }\r
285 \r
286 void CCommitDlg::OnOK()\r
287 {\r
288         if (m_bBlock)\r
289                 return;\r
290         if (m_bThreadRunning)\r
291         {\r
292                 m_bCancelled = true;\r
293                 InterlockedExchange(&m_bRunThread, FALSE);\r
294                 WaitForSingleObject(m_pThread->m_hThread, 1000);\r
295                 if (m_bThreadRunning)\r
296                 {\r
297                         // we gave the thread a chance to quit. Since the thread didn't\r
298                         // listen to us we have to kill it.\r
299                         TerminateThread(m_pThread->m_hThread, (DWORD)-1);\r
300                         InterlockedExchange(&m_bThreadRunning, FALSE);\r
301                 }\r
302         }\r
303         CString id;\r
304         GetDlgItemText(IDC_BUGID, id);\r
305         if (!m_ProjectProperties.CheckBugID(id))\r
306         {\r
307                 ShowBalloon(IDC_BUGID, IDS_COMMITDLG_ONLYNUMBERS, IDI_EXCLAMATION);\r
308                 return;\r
309         }\r
310         m_sLogMessage = m_cLogMessage.GetText();\r
311         if ((m_ProjectProperties.bWarnIfNoIssue) && (id.IsEmpty() && !m_ProjectProperties.HasBugID(m_sLogMessage)))\r
312         {\r
313                 if (CMessageBox::Show(this->m_hWnd, IDS_COMMITDLG_NOISSUEWARNING, IDS_APPNAME, MB_YESNO | MB_ICONWARNING)!=IDYES)\r
314                         return;\r
315         }\r
316 \r
317 #if 0\r
318         CRegDWORD regUnversionedRecurse (_T("Software\\TortoiseGit\\UnversionedRecurse"), TRUE);\r
319         if (!(DWORD)regUnversionedRecurse)\r
320         {\r
321                 // Find unversioned directories which are marked for commit. The user might expect them\r
322                 // to be added recursively since he cannot the the files. Let's ask the user if he knows\r
323                 // what he is doing.\r
324                 int nListItems = m_ListCtrl.GetItemCount();\r
325                 for (int j=0; j<nListItems; j++)\r
326                 {\r
327                         const CGitStatusListCtrl::FileEntry * entry = m_ListCtrl.GetListEntry(j);\r
328                         if (entry->IsChecked() && (entry->status == Git_wc_status_unversioned) && entry->IsFolder() )\r
329                         {\r
330                                 if (CMessageBox::Show(this->m_hWnd, IDS_COMMITDLG_UNVERSIONEDFOLDERWARNING, IDS_APPNAME, MB_YESNO | MB_ICONWARNING)!=IDYES)\r
331                                         return;\r
332                         }\r
333                 }\r
334         }\r
335 #endif\r
336         m_pathwatcher.Stop();\r
337         InterlockedExchange(&m_bBlock, TRUE);\r
338         CDWordArray arDeleted;\r
339         //first add all the unversioned files the user selected\r
340         //and check if all versioned files are selected\r
341         int nUnchecked = 0;\r
342         int nchecked = 0;\r
343         m_bRecursive = true;\r
344         int nListItems = m_ListCtrl.GetItemCount();\r
345 \r
346         CTGitPathList itemsToAdd;\r
347         CTGitPathList itemsToRemove;\r
348         bool bCheckedInExternal = false;\r
349         bool bHasConflicted = false;\r
350         //std::set<CString> checkedLists;\r
351         //std::set<CString> uncheckedLists;\r
352 \r
353         //CString checkedfiles;\r
354         //CString uncheckedfiles;\r
355 \r
356         CString cmd;\r
357         CString out;\r
358 \r
359         for (int j=0; j<nListItems; j++)\r
360         {\r
361                 //const CGitStatusListCtrl::FileEntry * entry = m_ListCtrl.GetListEntry(j);\r
362                 CTGitPath *entry = (CTGitPath*)m_ListCtrl.GetItemData(j);\r
363                 if (entry->m_Checked)\r
364                 {\r
365 #if 0\r
366                         if (entry->status == Git_wc_status_unversioned)\r
367                         {\r
368                                 itemsToAdd.AddPath(entry->GetPath());\r
369                         }\r
370                         if (entry->status == Git_wc_status_conflicted)\r
371                         {\r
372                                 bHasConflicted = true;\r
373                         }\r
374                         if (entry->status == Git_wc_status_missing)\r
375                         {\r
376                                 itemsToRemove.AddPath(entry->GetPath());\r
377                         }\r
378                         if (entry->status == Git_wc_status_deleted)\r
379                         {\r
380                                 arDeleted.Add(j);\r
381                         }\r
382                         if (entry->IsInExternal())\r
383                         {\r
384                                 bCheckedInExternal = true;\r
385                         }\r
386 #endif\r
387                         cmd.Format(_T("git.exe update-index -- \"%s\""),entry->GetGitPathString());\r
388                         g_Git.Run(cmd,&out,CP_OEMCP);\r
389                         nchecked++;\r
390                         //checkedLists.insert(entry->GetGitPathString());\r
391 //                      checkedfiles += _T("\"")+entry->GetGitPathString()+_T("\" ");\r
392                 }\r
393                 else\r
394                 {\r
395                         //uncheckedLists.insert(entry->GetGitPathString());\r
396                         if(entry->m_Action & CTGitPath::LOGACTIONS_ADDED)\r
397                         {       //To init git repository, there are not HEAD, so we can use git reset command\r
398                                 cmd.Format(_T("git.exe rm --cache -- \"%s\""),entry->GetGitPathString());\r
399                                 g_Git.Run(cmd,&out,CP_OEMCP);   \r
400                         }\r
401                         else\r
402                         {\r
403                                 cmd.Format(_T("git.exe reset -- %s"),entry->GetGitPathString());\r
404                                 g_Git.Run(cmd,&out,CP_OEMCP);\r
405                         }\r
406 \r
407                 //      uncheckedfiles += _T("\"")+entry->GetGitPathString()+_T("\" ");\r
408 #if 0\r
409                         if ((entry->status != Git_wc_status_unversioned)        &&\r
410                                 (entry->status != Git_wc_status_ignored))\r
411                         {\r
412                                 nUnchecked++;\r
413                                 uncheckedLists.insert(entry->GetChangeList());\r
414                                 if (m_bRecursive)\r
415                                 {\r
416                                         // This algorithm is for the sake of simplicity of the complexity O(N?\r
417                                         for (int k=0; k<nListItems; k++)\r
418                                         {\r
419                                                 const CGitStatusListCtrl::FileEntry * entryK = m_ListCtrl.GetListEntry(k);\r
420                                                 if (entryK->IsChecked() && entryK->GetPath().IsAncestorOf(entry->GetPath())  )\r
421                                                 {\r
422                                                         // Fall back to a non-recursive commit to prevent items being\r
423                                                         // committed which aren't checked although its parent is checked\r
424                                                         // (property change, directory deletion, ... )\r
425                                                         m_bRecursive = false;\r
426                                                         break;\r
427                                                 }\r
428                                         }\r
429                                 }\r
430                         }\r
431 #endif\r
432                 }\r
433         }\r
434 \r
435         //if(uncheckedfiles.GetLength()>0)\r
436         //{\r
437         //      cmd.Format(_T("git.exe reset -- %s"),uncheckedfiles);\r
438         //      g_Git.Run(cmd,&out);\r
439         //}\r
440 \r
441         //if(checkedfiles.GetLength()>0)\r
442         if(nchecked)\r
443         {\r
444         //      cmd.Format(_T("git.exe update-index -- %s"),checkedfiles);\r
445         //      g_Git.Run(cmd,&out);\r
446 \r
447                 CString tempfile=::GetTempFile();\r
448                 CFile file(tempfile,CFile::modeReadWrite|CFile::modeCreate );\r
449                 CStringA log=CUnicodeUtils::GetUTF8( m_sLogMessage);\r
450                 file.Write(log,log.GetLength());\r
451                 //file.WriteString(m_sLogMessage);\r
452                 file.Close();\r
453         \r
454                 out =_T("");\r
455                 cmd.Format(_T("git.exe commit -F \"%s\""), tempfile);\r
456                 g_Git.Run(cmd,&out,CP_OEMCP);\r
457         \r
458                 CFile::Remove(tempfile);\r
459 \r
460                 CMessageBox::Show(this->m_hWnd, out, _T("Commit Finish"), MB_OK | MB_ICONINFORMATION);\r
461         }else\r
462                 CMessageBox::Show(this->m_hWnd, _T("Nothing Commit"), _T("Commit Finish"), MB_OK | MB_ICONINFORMATION);\r
463 #if 0\r
464         if (m_pathwatcher.GetNumberOfChangedPaths() && m_bRecursive)\r
465         {\r
466                 // There are paths which got changed (touched at least).\r
467                 // We have to find out if this affects the selection in the commit dialog\r
468                 // If it could affect the selection, revert back to a non-recursive commit\r
469                 CTGitPathList changedList = m_pathwatcher.GetChangedPaths();\r
470                 changedList.RemoveDuplicates();\r
471                 for (int i=0; i<changedList.GetCount(); ++i)\r
472                 {\r
473                         if (changedList[i].IsAdminDir())\r
474                         {\r
475                                 // something inside an admin dir was changed.\r
476                                 // if it's the entries file, then we have to fully refresh because\r
477                                 // files may have been added/removed from version control\r
478                                 if ((changedList[i].GetWinPathString().Right(7).CompareNoCase(_T("entries")) == 0) &&\r
479                                         (changedList[i].GetWinPathString().Find(_T("\\tmp\\"))<0))\r
480                                 {\r
481                                         m_bRecursive = false;\r
482                                         break;\r
483                                 }\r
484                         }\r
485                         else if (!m_ListCtrl.IsPathShown(changedList[i]))\r
486                         {\r
487                                 // a path which is not shown in the list has changed\r
488                                 CGitStatusListCtrl::FileEntry * entry = m_ListCtrl.GetListEntry(changedList[i]);\r
489                                 if (entry)\r
490                                 {\r
491                                         // check if the changed path would get committed by a recursive commit\r
492                                         if ((!entry->IsFromDifferentRepository()) &&\r
493                                                 (!entry->IsInExternal()) &&\r
494                                                 (!entry->IsNested()) && \r
495                                                 (!entry->IsChecked()))\r
496                                         {\r
497                                                 m_bRecursive = false;\r
498                                                 break;\r
499                                         }\r
500                                 }\r
501                         }\r
502                 }\r
503         }\r
504 \r
505 \r
506         // Now, do all the adds - make sure that the list is sorted so that parents \r
507         // are added before their children\r
508         itemsToAdd.SortByPathname();\r
509         Git Git;\r
510         if (!Git.Add(itemsToAdd, &m_ProjectProperties, Git_depth_empty, FALSE, FALSE, TRUE))\r
511         {\r
512                 CMessageBox::Show(m_hWnd, Git.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR);\r
513                 InterlockedExchange(&m_bBlock, FALSE);\r
514                 Refresh();\r
515                 return;\r
516         }\r
517 \r
518         // Remove any missing items\r
519         // Not sure that this sort is really necessary - indeed, it might be better to do a reverse sort at this point\r
520         itemsToRemove.SortByPathname();\r
521         Git.Remove(itemsToRemove, TRUE);\r
522 \r
523         //the next step: find all deleted files and check if they're \r
524         //inside a deleted folder. If that's the case, then remove those\r
525         //files from the list since they'll get deleted by the parent\r
526         //folder automatically.\r
527         m_ListCtrl.Block(TRUE, FALSE);\r
528         INT_PTR nDeleted = arDeleted.GetCount();\r
529         for (INT_PTR i=0; i<arDeleted.GetCount(); i++)\r
530         {\r
531                 if (m_ListCtrl.GetCheck(arDeleted.GetAt(i)))\r
532                 {\r
533                         const CTGitPath& path = m_ListCtrl.GetListEntry(arDeleted.GetAt(i))->GetPath();\r
534                         if (path.IsDirectory())\r
535                         {\r
536                                 //now find all children of this directory\r
537                                 for (int j=0; j<arDeleted.GetCount(); j++)\r
538                                 {\r
539                                         if (i!=j)\r
540                                         {\r
541                                                 CGitStatusListCtrl::FileEntry* childEntry = m_ListCtrl.GetListEntry(arDeleted.GetAt(j));\r
542                                                 if (childEntry->IsChecked())\r
543                                                 {\r
544                                                         if (path.IsAncestorOf(childEntry->GetPath()))\r
545                                                         {\r
546                                                                 m_ListCtrl.SetEntryCheck(childEntry, arDeleted.GetAt(j), false);\r
547                                                                 nDeleted--;\r
548                                                         }\r
549                                                 }\r
550                                         }\r
551                                 }\r
552                         }\r
553                 }\r
554         } \r
555         m_ListCtrl.Block(FALSE, FALSE);\r
556 \r
557         if ((nUnchecked != 0)||(bCheckedInExternal)||(bHasConflicted)||(!m_bRecursive))\r
558         {\r
559                 //save only the files the user has checked into the temporary file\r
560                 m_ListCtrl.WriteCheckedNamesToPathList(m_pathList);\r
561         }\r
562         m_ListCtrl.WriteCheckedNamesToPathList(m_selectedPathList);\r
563         // the item count is used in the progress dialog to show the overall commit\r
564         // progress.\r
565         // deleted items only send one notification event, all others send two\r
566         m_itemsCount = ((m_selectedPathList.GetCount() - nDeleted - itemsToRemove.GetCount()) * 2) + nDeleted + itemsToRemove.GetCount();\r
567 \r
568         if ((m_bRecursive)&&(checkedLists.size() == 1))\r
569         {\r
570                 // all checked items belong to the same changelist\r
571                 // find out if there are any unchecked items which belong to that changelist\r
572                 if (uncheckedLists.find(*checkedLists.begin()) == uncheckedLists.end())\r
573                         m_sChangeList = *checkedLists.begin();\r
574         }\r
575 #endif\r
576         UpdateData();\r
577         m_regAddBeforeCommit = m_bShowUnversioned;\r
578         if (!GetDlgItem(IDC_KEEPLOCK)->IsWindowEnabled())\r
579                 m_bKeepLocks = FALSE;\r
580         m_regKeepChangelists = m_bKeepChangeList;\r
581         if (!GetDlgItem(IDC_KEEPLISTS)->IsWindowEnabled())\r
582                 m_bKeepChangeList = FALSE;\r
583         InterlockedExchange(&m_bBlock, FALSE);\r
584         m_sBugID.Trim();\r
585         if (!m_sBugID.IsEmpty())\r
586         {\r
587                 m_sBugID.Replace(_T(", "), _T(","));\r
588                 m_sBugID.Replace(_T(" ,"), _T(","));\r
589                 CString sBugID = m_ProjectProperties.sMessage;\r
590                 sBugID.Replace(_T("%BUGID%"), m_sBugID);\r
591                 if (m_ProjectProperties.bAppend)\r
592                         m_sLogMessage += _T("\n") + sBugID + _T("\n");\r
593                 else\r
594                         m_sLogMessage = sBugID + _T("\n") + m_sLogMessage;\r
595         }\r
596         m_History.AddEntry(m_sLogMessage);\r
597         m_History.Save();\r
598 \r
599         SaveSplitterPos();\r
600 \r
601         CResizableStandAloneDialog::OnOK();\r
602 }\r
603 \r
604 void CCommitDlg::SaveSplitterPos()\r
605 {\r
606         if (!IsIconic())\r
607         {\r
608                 CRegDWORD regPos = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\CommitDlgSizer"));\r
609                 RECT rectSplitter;\r
610                 m_wndSplitter.GetWindowRect(&rectSplitter);\r
611                 ScreenToClient(&rectSplitter);\r
612                 regPos = rectSplitter.top;\r
613         }\r
614 }\r
615 \r
616 UINT CCommitDlg::StatusThreadEntry(LPVOID pVoid)\r
617 {\r
618         return ((CCommitDlg*)pVoid)->StatusThread();\r
619 }\r
620 \r
621 UINT CCommitDlg::StatusThread()\r
622 {\r
623         //get the status of all selected file/folders recursively\r
624         //and show the ones which have to be committed to the user\r
625         //in a list control. \r
626         InterlockedExchange(&m_bBlock, TRUE);\r
627         InterlockedExchange(&m_bThreadRunning, TRUE);// so the main thread knows that this thread is still running\r
628         InterlockedExchange(&m_bRunThread, TRUE);       // if this is set to FALSE, the thread should stop\r
629         m_bCancelled = false;\r
630 \r
631         DialogEnableWindow(IDOK, false);\r
632         DialogEnableWindow(IDC_SHOWUNVERSIONED, false);\r
633         DialogEnableWindow(IDC_SELECTALL, false);\r
634         GetDlgItem(IDC_EXTERNALWARNING)->ShowWindow(SW_HIDE);\r
635         DialogEnableWindow(IDC_EXTERNALWARNING, false);\r
636     // read the list of recent log entries before querying the WC for status\r
637     // -> the user may select one and modify / update it while we are crawling the WC\r
638 #if 0\r
639         if (m_History.GetCount()==0)\r
640         {\r
641                 CString reg;\r
642                 if (m_ListCtrl.m_sUUID.IsEmpty() && m_pathList.GetCount()>0)\r
643                 {\r
644                         Git Git;\r
645                         reg.Format(_T("Software\\TortoiseGit\\History\\commit%s"), (LPCTSTR)Git.GetUUIDFromPath(m_pathList[0]));\r
646                 }\r
647                 else\r
648                         reg.Format(_T("Software\\TortoiseGit\\History\\commit%s"), (LPCTSTR)m_ListCtrl.m_sUUID);\r
649                 m_History.Load(reg, _T("logmsgs"));\r
650         }\r
651 #endif\r
652     // Initialise the list control with the status of the files/folders below us\r
653         BOOL success = m_ListCtrl.GetStatus(m_pathList);\r
654 \r
655         //m_ListCtrl.UpdateFileList(git_revnum_t(GIT_REV_ZERO));\r
656         if(this->m_bShowUnversioned)\r
657                 m_ListCtrl.UpdateFileList(CGitStatusListCtrl::FILELIST_UNVER);\r
658         \r
659         m_ListCtrl.CheckIfChangelistsArePresent(false);\r
660 \r
661         DWORD dwShow = SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALSFROMDIFFERENTREPOS | SVNSLC_SHOWLOCKS | SVNSLC_SHOWINCHANGELIST;\r
662         dwShow |= DWORD(m_regAddBeforeCommit) ? SVNSLC_SHOWUNVERSIONED : 0;\r
663         if (success)\r
664         {\r
665                 if (m_checkedPathList.GetCount())\r
666                         m_ListCtrl.Show(dwShow, m_checkedPathList);\r
667                 else\r
668                 {\r
669                         DWORD dwCheck = m_bSelectFilesForCommit ? dwShow : 0;\r
670                         m_ListCtrl.Show(dwShow, dwCheck);\r
671                         m_bSelectFilesForCommit = true;\r
672                 }\r
673 \r
674                 if (m_ListCtrl.HasExternalsFromDifferentRepos())\r
675                 {\r
676                         GetDlgItem(IDC_EXTERNALWARNING)->ShowWindow(SW_SHOW);\r
677                         DialogEnableWindow(IDC_EXTERNALWARNING, TRUE);\r
678                 }\r
679                 \r
680                 SetDlgItemText(IDC_COMMIT_TO, g_Git.GetCurrentBranch());\r
681                 m_tooltips.AddTool(GetDlgItem(IDC_STATISTICS), m_ListCtrl.GetStatisticsString());\r
682         }\r
683         CString logmsg;\r
684         GetDlgItemText(IDC_LOGMESSAGE, logmsg);\r
685         DialogEnableWindow(IDOK, logmsg.GetLength() >= m_ProjectProperties.nMinLogSize);\r
686         if (!success)\r
687         {\r
688                 if (!m_ListCtrl.GetLastErrorMessage().IsEmpty())\r
689                         m_ListCtrl.SetEmptyString(m_ListCtrl.GetLastErrorMessage());\r
690                 m_ListCtrl.Show(dwShow);\r
691         }\r
692         if ((m_ListCtrl.GetItemCount()==0)&&(m_ListCtrl.HasUnversionedItems()))\r
693         {\r
694                 if (CMessageBox::Show(m_hWnd, IDS_COMMITDLG_NOTHINGTOCOMMITUNVERSIONED, IDS_APPNAME, MB_ICONINFORMATION | MB_YESNO)==IDYES)\r
695                 {\r
696                         m_bShowUnversioned = TRUE;\r
697                         GetDlgItem(IDC_SHOWUNVERSIONED)->SendMessage(BM_SETCHECK, BST_CHECKED);\r
698                         DWORD dwShow = SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALSFROMDIFFERENTREPOS | SVNSLC_SHOWUNVERSIONED | SVNSLC_SHOWLOCKS;\r
699                         m_ListCtrl.Show(dwShow);\r
700                 }\r
701         }\r
702 \r
703         CTGitPath commonDir = m_ListCtrl.GetCommonDirectory(false);\r
704         SetWindowText(m_sWindowTitle + _T(" - ") + commonDir.GetWinPathString());\r
705 \r
706         m_autolist.clear();\r
707         // we don't have to block the commit dialog while we fetch the\r
708         // auto completion list.\r
709         m_pathwatcher.ClearChangedPaths();\r
710         InterlockedExchange(&m_bBlock, FALSE);\r
711         if ((DWORD)CRegDWORD(_T("Software\\TortoiseGit\\Autocompletion"), TRUE)==TRUE)\r
712         {\r
713                 m_ListCtrl.Block(TRUE, TRUE);\r
714                 GetAutocompletionList();\r
715                 m_ListCtrl.Block(FALSE, FALSE);\r
716         }\r
717         if (m_bRunThread)\r
718         {\r
719                 DialogEnableWindow(IDC_SHOWUNVERSIONED, true);\r
720                 DialogEnableWindow(IDC_SELECTALL, true);\r
721                 if (m_ListCtrl.HasChangeLists())\r
722                         DialogEnableWindow(IDC_KEEPLISTS, true);\r
723                 if (m_ListCtrl.HasLocks())\r
724                         DialogEnableWindow(IDC_KEEPLOCK, true);\r
725                 // we have the list, now signal the main thread about it\r
726                 SendMessage(WM_AUTOLISTREADY);  // only send the message if the thread wasn't told to quit!\r
727         }\r
728 \r
729         InterlockedExchange(&m_bRunThread, FALSE);\r
730         InterlockedExchange(&m_bThreadRunning, FALSE);\r
731         // force the cursor to normal\r
732         RefreshCursor();\r
733 \r
734         return 0;\r
735 }\r
736 \r
737 void CCommitDlg::OnCancel()\r
738 {\r
739         m_bCancelled = true;\r
740         if (m_bBlock)\r
741                 return;\r
742         m_pathwatcher.Stop();\r
743         if (m_bThreadRunning)\r
744         {\r
745                 InterlockedExchange(&m_bRunThread, FALSE);\r
746                 WaitForSingleObject(m_pThread->m_hThread, 1000);\r
747                 if (m_bThreadRunning)\r
748                 {\r
749                         // we gave the thread a chance to quit. Since the thread didn't\r
750                         // listen to us we have to kill it.\r
751                         TerminateThread(m_pThread->m_hThread, (DWORD)-1);\r
752                         InterlockedExchange(&m_bThreadRunning, FALSE);\r
753                 }\r
754         }\r
755         UpdateData();\r
756         m_sBugID.Trim();\r
757         m_sLogMessage = m_cLogMessage.GetText();\r
758         if (!m_sBugID.IsEmpty())\r
759         {\r
760                 m_sBugID.Replace(_T(", "), _T(","));\r
761                 m_sBugID.Replace(_T(" ,"), _T(","));\r
762                 CString sBugID = m_ProjectProperties.sMessage;\r
763                 sBugID.Replace(_T("%BUGID%"), m_sBugID);\r
764                 if (m_ProjectProperties.bAppend)\r
765                         m_sLogMessage += _T("\n") + sBugID + _T("\n");\r
766                 else\r
767                         m_sLogMessage = sBugID + _T("\n") + m_sLogMessage;\r
768         }\r
769         if (m_ProjectProperties.sLogTemplate.Compare(m_sLogMessage) != 0)\r
770                 m_History.AddEntry(m_sLogMessage);\r
771         m_History.Save();\r
772         SaveSplitterPos();\r
773         CResizableStandAloneDialog::OnCancel();\r
774 }\r
775 \r
776 void CCommitDlg::OnBnClickedSelectall()\r
777 {\r
778         m_tooltips.Pop();       // hide the tooltips\r
779         UINT state = (m_SelectAll.GetState() & 0x0003);\r
780         if (state == BST_INDETERMINATE)\r
781         {\r
782                 // It is not at all useful to manually place the checkbox into the indeterminate state...\r
783                 // We will force this on to the unchecked state\r
784                 state = BST_UNCHECKED;\r
785                 m_SelectAll.SetCheck(state);\r
786         }\r
787         m_ListCtrl.SelectAll(state == BST_CHECKED);\r
788 }\r
789 \r
790 BOOL CCommitDlg::PreTranslateMessage(MSG* pMsg)\r
791 {\r
792         if (!m_bBlock)\r
793                 m_tooltips.RelayEvent(pMsg);\r
794         if (pMsg->message == WM_KEYDOWN)\r
795         {\r
796                 switch (pMsg->wParam)\r
797                 {\r
798                 case VK_F5:\r
799                         {\r
800                                 if (m_bBlock)\r
801                                         return CResizableStandAloneDialog::PreTranslateMessage(pMsg);\r
802                                 Refresh();\r
803                         }\r
804                         break;\r
805                 case VK_RETURN:\r
806                         {\r
807                                 if (GetAsyncKeyState(VK_CONTROL)&0x8000)\r
808                                 {\r
809                                         if ( GetDlgItem(IDOK)->IsWindowEnabled() )\r
810                                         {\r
811                                                 PostMessage(WM_COMMAND, IDOK);\r
812                                         }\r
813                                         return TRUE;\r
814                                 }\r
815                                 if ( GetFocus()==GetDlgItem(IDC_BUGID) )\r
816                                 {\r
817                                         // Pressing RETURN in the bug id control\r
818                                         // moves the focus to the message\r
819                                         GetDlgItem(IDC_LOGMESSAGE)->SetFocus();\r
820                                         return TRUE;\r
821                                 }\r
822                         }\r
823                         break;\r
824                 }\r
825         }\r
826 \r
827         return CResizableStandAloneDialog::PreTranslateMessage(pMsg);\r
828 }\r
829 \r
830 void CCommitDlg::Refresh()\r
831 {\r
832         if (m_bThreadRunning)\r
833                 return;\r
834 \r
835         InterlockedExchange(&m_bBlock, TRUE);\r
836         m_pThread = AfxBeginThread(StatusThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);\r
837         if (m_pThread==NULL)\r
838         {\r
839                 CMessageBox::Show(this->m_hWnd, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);\r
840                 InterlockedExchange(&m_bBlock, FALSE);\r
841         }\r
842         else\r
843         {\r
844                 m_pThread->m_bAutoDelete = FALSE;\r
845                 m_pThread->ResumeThread();\r
846         }\r
847 }\r
848 \r
849 void CCommitDlg::OnBnClickedHelp()\r
850 {\r
851         OnHelp();\r
852 }\r
853 \r
854 void CCommitDlg::OnBnClickedShowunversioned()\r
855 {\r
856         m_tooltips.Pop();       // hide the tooltips\r
857         UpdateData();\r
858         m_regAddBeforeCommit = m_bShowUnversioned;\r
859         if (!m_bBlock)\r
860         {\r
861                 DWORD dwShow = m_ListCtrl.GetShowFlags();\r
862                 if (DWORD(m_regAddBeforeCommit))\r
863                         dwShow |= SVNSLC_SHOWUNVERSIONED;\r
864                 else\r
865                         dwShow &= ~SVNSLC_SHOWUNVERSIONED;\r
866                 if(dwShow & SVNSLC_SHOWUNVERSIONED)\r
867                 {\r
868                         m_ListCtrl.GetStatus(this->m_pathList,false,false,true);\r
869                 }\r
870                 m_ListCtrl.Show(dwShow);\r
871         }\r
872 }\r
873 \r
874 void CCommitDlg::OnStnClickedExternalwarning()\r
875 {\r
876         m_tooltips.Popup();\r
877 }\r
878 \r
879 void CCommitDlg::OnEnChangeLogmessage()\r
880 {\r
881         UpdateOKButton();\r
882 }\r
883 \r
884 LRESULT CCommitDlg::OnGitStatusListCtrlItemCountChanged(WPARAM, LPARAM)\r
885 {\r
886 #if 0\r
887         if ((m_ListCtrl.GetItemCount() == 0)&&(m_ListCtrl.HasUnversionedItems())&&(!m_bShowUnversioned))\r
888         {\r
889                 if (CMessageBox::Show(*this, IDS_COMMITDLG_NOTHINGTOCOMMITUNVERSIONED, IDS_APPNAME, MB_ICONINFORMATION | MB_YESNO)==IDYES)\r
890                 {\r
891                         m_bShowUnversioned = TRUE;\r
892                         DWORD dwShow = GitSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALSFROMDIFFERENTREPOS | GitSLC_SHOWUNVERSIONED | GitSLC_SHOWLOCKS;\r
893                         m_ListCtrl.Show(dwShow);\r
894                         UpdateData(FALSE);\r
895                 }\r
896         }\r
897 #endif\r
898         return 0;\r
899 }\r
900 \r
901 LRESULT CCommitDlg::OnGitStatusListCtrlNeedsRefresh(WPARAM, LPARAM)\r
902 {\r
903         Refresh();\r
904         return 0;\r
905 }\r
906 \r
907 LRESULT CCommitDlg::OnFileDropped(WPARAM, LPARAM lParam)\r
908 {\r
909 #if 0\r
910         BringWindowToTop();\r
911         SetForegroundWindow();\r
912         SetActiveWindow();\r
913         // if multiple files/folders are dropped\r
914         // this handler is called for every single item\r
915         // separately.\r
916         // To avoid creating multiple refresh threads and\r
917         // causing crashes, we only add the items to the\r
918         // list control and start a timer.\r
919         // When the timer expires, we start the refresh thread,\r
920         // but only if it isn't already running - otherwise we\r
921         // restart the timer.\r
922         CTGitPath path;\r
923         path.SetFromWin((LPCTSTR)lParam);\r
924 \r
925         // just add all the items we get here.\r
926         // if the item is versioned, the add will fail but nothing\r
927         // more will happen.\r
928         Git Git;\r
929         Git.Add(CTGitPathList(path), &m_ProjectProperties, Git_depth_empty, false, true, true);\r
930 \r
931         if (!m_ListCtrl.HasPath(path))\r
932         {\r
933                 if (m_pathList.AreAllPathsFiles())\r
934                 {\r
935                         m_pathList.AddPath(path);\r
936                         m_pathList.RemoveDuplicates();\r
937                         m_updatedPathList.AddPath(path);\r
938                         m_updatedPathList.RemoveDuplicates();\r
939                 }\r
940                 else\r
941                 {\r
942                         // if the path list contains folders, we have to check whether\r
943                         // our just (maybe) added path is a child of one of those. If it is\r
944                         // a child of a folder already in the list, we must not add it. Otherwise\r
945                         // that path could show up twice in the list.\r
946                         bool bHasParentInList = false;\r
947                         for (int i=0; i<m_pathList.GetCount(); ++i)\r
948                         {\r
949                                 if (m_pathList[i].IsAncestorOf(path))\r
950                                 {\r
951                                         bHasParentInList = true;\r
952                                         break;\r
953                                 }\r
954                         }\r
955                         if (!bHasParentInList)\r
956                         {\r
957                                 m_pathList.AddPath(path);\r
958                                 m_pathList.RemoveDuplicates();\r
959                                 m_updatedPathList.AddPath(path);\r
960                                 m_updatedPathList.RemoveDuplicates();\r
961                         }\r
962                 }\r
963         }\r
964         \r
965         // Always start the timer, since the status of an existing item might have changed\r
966         SetTimer(REFRESHTIMER, 200, NULL);\r
967         ATLTRACE(_T("Item %s dropped, timer started\n"), path.GetWinPath());\r
968 #endif\r
969         return 0;\r
970 }\r
971 \r
972 LRESULT CCommitDlg::OnAutoListReady(WPARAM, LPARAM)\r
973 {\r
974         m_cLogMessage.SetAutoCompletionList(m_autolist, '*');\r
975         return 0;\r
976 }\r
977 \r
978 //////////////////////////////////////////////////////////////////////////\r
979 // functions which run in the status thread\r
980 //////////////////////////////////////////////////////////////////////////\r
981 \r
982 void CCommitDlg::ParseRegexFile(const CString& sFile, std::map<CString, CString>& mapRegex)\r
983 {\r
984         CString strLine;\r
985         try\r
986         {\r
987                 CStdioFile file(sFile, CFile::typeText | CFile::modeRead | CFile::shareDenyWrite);\r
988                 while (m_bRunThread && file.ReadString(strLine))\r
989                 {\r
990                         int eqpos = strLine.Find('=');\r
991                         CString rgx;\r
992                         rgx = strLine.Mid(eqpos+1).Trim();\r
993 \r
994                         int pos = -1;\r
995                         while (((pos = strLine.Find(','))>=0)&&(pos < eqpos))\r
996                         {\r
997                                 mapRegex[strLine.Left(pos)] = rgx;\r
998                                 strLine = strLine.Mid(pos+1).Trim();\r
999                         }\r
1000                         mapRegex[strLine.Left(strLine.Find('=')).Trim()] = rgx;\r
1001                 }\r
1002                 file.Close();\r
1003         }\r
1004         catch (CFileException* pE)\r
1005         {\r
1006                 TRACE("CFileException loading auto list regex file\n");\r
1007                 pE->Delete();\r
1008                 return;\r
1009         }\r
1010 }\r
1011 void CCommitDlg::GetAutocompletionList()\r
1012 {\r
1013         // the auto completion list is made of strings from each selected files.\r
1014         // the strings used are extracted from the files with regexes found\r
1015         // in the file "autolist.txt".\r
1016         // the format of that file is:\r
1017         // file extensions separated with commas '=' regular expression to use\r
1018         // example:\r
1019         // .h, .hpp = (?<=class[\s])\b\w+\b|(\b\w+(?=[\s ]?\(\);))\r
1020         // .cpp = (?<=[^\s]::)\b\w+\b\r
1021         \r
1022         std::map<CString, CString> mapRegex;\r
1023         CString sRegexFile = CPathUtils::GetAppDirectory();\r
1024         CRegDWORD regtimeout = CRegDWORD(_T("Software\\TortoiseGit\\AutocompleteParseTimeout"), 5);\r
1025         DWORD timeoutvalue = regtimeout*1000;\r
1026         sRegexFile += _T("autolist.txt");\r
1027         if (!m_bRunThread)\r
1028                 return;\r
1029         ParseRegexFile(sRegexFile, mapRegex);\r
1030         SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, sRegexFile.GetBuffer(MAX_PATH+1));\r
1031         sRegexFile.ReleaseBuffer();\r
1032         sRegexFile += _T("\\TortoiseGit\\autolist.txt");\r
1033         if (PathFileExists(sRegexFile))\r
1034         {\r
1035                 ParseRegexFile(sRegexFile, mapRegex);\r
1036         }\r
1037         DWORD starttime = GetTickCount();\r
1038 \r
1039         // now we have two arrays of strings, where the first array contains all\r
1040         // file extensions we can use and the second the corresponding regex strings\r
1041         // to apply to those files.\r
1042 \r
1043         // the next step is to go over all files shown in the commit dialog\r
1044         // and scan them for strings we can use\r
1045         int nListItems = m_ListCtrl.GetItemCount();\r
1046 \r
1047         for (int i=0; i<nListItems && m_bRunThread; ++i)\r
1048         {\r
1049                 // stop parsing after timeout\r
1050                 if ((!m_bRunThread) || (GetTickCount() - starttime > timeoutvalue))\r
1051                         return;\r
1052 \r
1053                 CTGitPath *path = (CTGitPath*)m_ListCtrl.GetItemData(i);\r
1054 \r
1055                 if(path == NULL)\r
1056                         continue;\r
1057 \r
1058                 CString sPartPath =path->GetGitPathString();\r
1059                 m_autolist.insert(sPartPath);\r
1060 \r
1061 //              const CGitStatusListCtrl::FileEntry * entry = m_ListCtrl.GetListEntry(i);\r
1062 //              if (!entry)\r
1063 //                      continue;\r
1064                 \r
1065                 // add the path parts to the auto completion list too\r
1066 //              CString sPartPath = entry->GetRelativeGitPath();\r
1067 //              m_autolist.insert(sPartPath);\r
1068 \r
1069 \r
1070                 int pos = 0;\r
1071                 int lastPos = 0;\r
1072                 while ((pos = sPartPath.Find('/', pos)) >= 0)\r
1073                 {\r
1074                         pos++;\r
1075                         lastPos = pos;\r
1076                         m_autolist.insert(sPartPath.Mid(pos));\r
1077                 }\r
1078 \r
1079                 // Last inserted entry is a file name.\r
1080                 // Some users prefer to also list file name without extension.\r
1081                 if (CRegDWORD(_T("Software\\TortoiseGit\\AutocompleteRemovesExtensions"), FALSE))\r
1082                 {\r
1083                         int dotPos = sPartPath.ReverseFind('.');\r
1084                         if ((dotPos >= 0) && (dotPos > lastPos))\r
1085                                 m_autolist.insert(sPartPath.Mid(lastPos, dotPos - lastPos));\r
1086                 }\r
1087 #if 0\r
1088                 if ((entry->status <= Git_wc_status_normal)||(entry->status == Git_wc_status_ignored))\r
1089                         continue;\r
1090 \r
1091                 CString sExt = entry->GetPath().GetFileExtension();\r
1092                 sExt.MakeLower();\r
1093                 // find the regex string which corresponds to the file extension\r
1094                 CString rdata = mapRegex[sExt];\r
1095                 if (rdata.IsEmpty())\r
1096                         continue;\r
1097 \r
1098                 ScanFile(entry->GetPath().GetWinPathString(), rdata);\r
1099                 if ((entry->textstatus != Git_wc_status_unversioned) &&\r
1100                         (entry->textstatus != Git_wc_status_none) &&\r
1101                         (entry->textstatus != Git_wc_status_ignored) &&\r
1102                         (entry->textstatus != Git_wc_status_added) &&\r
1103                         (entry->textstatus != Git_wc_status_normal))\r
1104                 {\r
1105                         CTGitPath basePath = Git::GetPristinePath(entry->GetPath());\r
1106                         if (!basePath.IsEmpty())\r
1107                                 ScanFile(basePath.GetWinPathString(), rdata);\r
1108                 }\r
1109 #endif\r
1110         }\r
1111         ATLTRACE(_T("Auto completion list loaded in %d msec\n"), GetTickCount() - starttime);\r
1112 }\r
1113 \r
1114 void CCommitDlg::ScanFile(const CString& sFilePath, const CString& sRegex)\r
1115 {\r
1116         wstring sFileContent;\r
1117         HANDLE hFile = CreateFile(sFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);\r
1118         if (hFile != INVALID_HANDLE_VALUE)\r
1119         {\r
1120                 DWORD size = GetFileSize(hFile, NULL);\r
1121                 if (size > 1000000L)\r
1122                 {\r
1123                         // no files bigger than 1 Meg\r
1124                         CloseHandle(hFile);\r
1125                         return;\r
1126                 }\r
1127                 // allocate memory to hold file contents\r
1128                 char * buffer = new char[size];\r
1129                 DWORD readbytes;\r
1130                 ReadFile(hFile, buffer, size, &readbytes, NULL);\r
1131                 CloseHandle(hFile);\r
1132                 int opts = 0;\r
1133                 IsTextUnicode(buffer, readbytes, &opts);\r
1134                 if (opts & IS_TEXT_UNICODE_NULL_BYTES)\r
1135                 {\r
1136                         delete [] buffer;\r
1137                         return;\r
1138                 }\r
1139                 if (opts & IS_TEXT_UNICODE_UNICODE_MASK)\r
1140                 {\r
1141                         sFileContent = wstring((wchar_t*)buffer, readbytes/sizeof(WCHAR));\r
1142                 }\r
1143                 if ((opts & IS_TEXT_UNICODE_NOT_UNICODE_MASK)||(opts == 0))\r
1144                 {\r
1145                         int ret = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCSTR)buffer, readbytes, NULL, 0);\r
1146                         wchar_t * pWideBuf = new wchar_t[ret];\r
1147                         int ret2 = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCSTR)buffer, readbytes, pWideBuf, ret);\r
1148                         if (ret2 == ret)\r
1149                                 sFileContent = wstring(pWideBuf, ret);\r
1150                         delete [] pWideBuf;\r
1151                 }\r
1152                 delete [] buffer;\r
1153         }\r
1154         if (sFileContent.empty()|| !m_bRunThread)\r
1155         {\r
1156                 return;\r
1157         }\r
1158 \r
1159         try\r
1160         {\r
1161                 const tr1::wregex regCheck(sRegex, tr1::regex_constants::icase | tr1::regex_constants::ECMAScript);\r
1162                 const tr1::wsregex_iterator end;\r
1163                 wstring s = sFileContent;\r
1164                 for (tr1::wsregex_iterator it(s.begin(), s.end(), regCheck); it != end; ++it)\r
1165                 {\r
1166                         const tr1::wsmatch match = *it;\r
1167                         for (size_t i=1; i<match.size(); ++i)\r
1168                         {\r
1169                                 if (match[i].second-match[i].first)\r
1170                                 {\r
1171                                         ATLTRACE(_T("matched keyword : %s\n"), wstring(match[i]).c_str());\r
1172                                         m_autolist.insert(wstring(match[i]).c_str());\r
1173                                 }\r
1174                         }\r
1175                 }\r
1176         }\r
1177         catch (exception) {}\r
1178 }\r
1179 \r
1180 // CSciEditContextMenuInterface\r
1181 void CCommitDlg::InsertMenuItems(CMenu& mPopup, int& nCmd)\r
1182 {\r
1183         CString sMenuItemText(MAKEINTRESOURCE(IDS_COMMITDLG_POPUP_PASTEFILELIST));\r
1184         m_nPopupPasteListCmd = nCmd++;\r
1185         mPopup.AppendMenu(MF_STRING | MF_ENABLED, m_nPopupPasteListCmd, sMenuItemText);\r
1186 }\r
1187 \r
1188 bool CCommitDlg::HandleMenuItemClick(int cmd, CSciEdit * pSciEdit)\r
1189 {\r
1190 #if 0\r
1191         if (m_bBlock)\r
1192                 return false;\r
1193         if (cmd == m_nPopupPasteListCmd)\r
1194         {\r
1195                 CString logmsg;\r
1196                 TCHAR buf[MAX_STATUS_STRING_LENGTH];\r
1197                 int nListItems = m_ListCtrl.GetItemCount();\r
1198                 for (int i=0; i<nListItems; ++i)\r
1199                 {\r
1200                         CGitStatusListCtrl::FileEntry * entry = m_ListCtrl.GetListEntry(i);\r
1201                         if (entry->IsChecked())\r
1202                         {\r
1203                                 CString line;\r
1204                                 Git_wc_status_kind status = entry->status;\r
1205                                 if (status == Git_wc_status_unversioned)\r
1206                                         status = Git_wc_status_added;\r
1207                                 if (status == Git_wc_status_missing)\r
1208                                         status = Git_wc_status_deleted;\r
1209                                 WORD langID = (WORD)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());\r
1210                                 if (m_ProjectProperties.bFileListInEnglish)\r
1211                                         langID = 1033;\r
1212                                 GitStatus::GetStatusString(AfxGetResourceHandle(), status, buf, sizeof(buf)/sizeof(TCHAR), langID);\r
1213                                 line.Format(_T("%-10s %s\r\n"), buf, (LPCTSTR)m_ListCtrl.GetItemText(i,0));\r
1214                                 logmsg += line;\r
1215                         }\r
1216                 }\r
1217                 pSciEdit->InsertText(logmsg);\r
1218                 return true;\r
1219         }\r
1220 #endif\r
1221         return false;\r
1222 }\r
1223 \r
1224 void CCommitDlg::OnTimer(UINT_PTR nIDEvent)\r
1225 {\r
1226         switch (nIDEvent)\r
1227         {\r
1228         case ENDDIALOGTIMER:\r
1229                 KillTimer(ENDDIALOGTIMER);\r
1230                 EndDialog(0);\r
1231                 break;\r
1232         case REFRESHTIMER:\r
1233                 if (m_bThreadRunning)\r
1234                 {\r
1235                         SetTimer(REFRESHTIMER, 200, NULL);\r
1236                         ATLTRACE("Wait some more before refreshing\n");\r
1237                 }\r
1238                 else\r
1239                 {\r
1240                         KillTimer(REFRESHTIMER);\r
1241                         ATLTRACE("Refreshing after items dropped\n");\r
1242                         Refresh();\r
1243                 }\r
1244                 break;\r
1245         }\r
1246         __super::OnTimer(nIDEvent);\r
1247 }\r
1248 \r
1249 void CCommitDlg::OnBnClickedHistory()\r
1250 {\r
1251         m_tooltips.Pop();       // hide the tooltips\r
1252         if (m_pathList.GetCount() == 0)\r
1253                 return;\r
1254 #if 0\r
1255         CHistoryDlg historyDlg;\r
1256         historyDlg.SetHistory(m_History);\r
1257         if (historyDlg.DoModal() != IDOK)\r
1258                 return;\r
1259 \r
1260         CString sMsg = historyDlg.GetSelectedText();\r
1261         if (sMsg != m_cLogMessage.GetText().Left(sMsg.GetLength()))\r
1262         {\r
1263                 CString sBugID = m_ProjectProperties.GetBugIDFromLog(sMsg);\r
1264                 if (!sBugID.IsEmpty())\r
1265                 {\r
1266                         SetDlgItemText(IDC_BUGID, sBugID);\r
1267                 }\r
1268                 if (m_ProjectProperties.sLogTemplate.Compare(m_cLogMessage.GetText())!=0)\r
1269                         m_cLogMessage.InsertText(sMsg, !m_cLogMessage.GetText().IsEmpty());\r
1270                 else\r
1271                         m_cLogMessage.SetText(sMsg);\r
1272         }\r
1273 \r
1274         UpdateOKButton();\r
1275         GetDlgItem(IDC_LOGMESSAGE)->SetFocus();\r
1276 #endif\r
1277 }\r
1278 \r
1279 void CCommitDlg::OnBnClickedBugtraqbutton()\r
1280 {\r
1281 #if 0\r
1282         m_tooltips.Pop();       // hide the tooltips\r
1283         CString sMsg = m_cLogMessage.GetText();\r
1284 \r
1285         if (m_BugTraqProvider == NULL)\r
1286                 return;\r
1287 \r
1288         BSTR parameters = m_bugtraq_association.GetParameters().AllocSysString();\r
1289         BSTR commonRoot = SysAllocString(m_pathList.GetCommonRoot().GetDirectory().GetWinPath());\r
1290         SAFEARRAY *pathList = SafeArrayCreateVector(VT_BSTR, 0, m_pathList.GetCount());\r
1291 \r
1292         for (LONG index = 0; index < m_pathList.GetCount(); ++index)\r
1293                 SafeArrayPutElement(pathList, &index, m_pathList[index].GetGitPathString().AllocSysString());\r
1294 \r
1295         BSTR originalMessage = sMsg.AllocSysString();\r
1296         BSTR temp = NULL;\r
1297 \r
1298         // first try the IBugTraqProvider2 interface\r
1299         CComPtr<IBugTraqProvider2> pProvider2 = NULL;\r
1300         HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider2);\r
1301         if (SUCCEEDED(hr))\r
1302         {\r
1303                 CString common = m_ListCtrl.GetCommonURL(false).GetGitPathString();\r
1304                 BSTR repositoryRoot = common.AllocSysString();\r
1305                 if (FAILED(hr = pProvider2->GetCommitMessage2(GetSafeHwnd(), parameters, repositoryRoot, commonRoot, pathList, originalMessage, &temp)))\r
1306                 {\r
1307                         CString sErr;\r
1308                         sErr.Format(IDS_ERR_FAILEDISSUETRACKERCOM, m_bugtraq_association.GetProviderName(), _com_error(hr).ErrorMessage());\r
1309                         CMessageBox::Show(m_hWnd, sErr, _T("TortoiseGit"), MB_ICONERROR);\r
1310                 }\r
1311                 else\r
1312                         m_cLogMessage.SetText(temp);\r
1313         }\r
1314         else\r
1315         {\r
1316                 // if IBugTraqProvider2 failed, try IBugTraqProvider\r
1317                 CComPtr<IBugTraqProvider> pProvider = NULL;\r
1318                 HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider);\r
1319                 if (FAILED(hr))\r
1320                 {\r
1321                         CString sErr;\r
1322                         sErr.Format(IDS_ERR_FAILEDISSUETRACKERCOM, (LPCTSTR)m_bugtraq_association.GetProviderName(), _com_error(hr).ErrorMessage());\r
1323                         CMessageBox::Show(m_hWnd, sErr, _T("TortoiseGit"), MB_ICONERROR);\r
1324                         return;\r
1325                 }\r
1326 \r
1327                 if (FAILED(hr = pProvider->GetCommitMessage(GetSafeHwnd(), parameters, commonRoot, pathList, originalMessage, &temp)))\r
1328                 {\r
1329                         CString sErr;\r
1330                         sErr.Format(IDS_ERR_FAILEDISSUETRACKERCOM, m_bugtraq_association.GetProviderName(), _com_error(hr).ErrorMessage());\r
1331                         CMessageBox::Show(m_hWnd, sErr, _T("TortoiseGit"), MB_ICONERROR);\r
1332                 }\r
1333                 else\r
1334                         m_cLogMessage.SetText(temp);\r
1335         }\r
1336 \r
1337         m_cLogMessage.SetFocus();\r
1338 \r
1339         SysFreeString(temp);\r
1340 #endif\r
1341 }\r
1342 \r
1343 LRESULT CCommitDlg::OnGitStatusListCtrlCheckChanged(WPARAM, LPARAM)\r
1344 {\r
1345         UpdateOKButton();\r
1346         return 0;\r
1347 }\r
1348 \r
1349 void CCommitDlg::UpdateOKButton()\r
1350 {\r
1351 #if 0\r
1352         BOOL bValidLogSize = FALSE;\r
1353 \r
1354     if (m_cLogMessage.GetText().GetLength() >= m_ProjectProperties.nMinLogSize)\r
1355                 bValidLogSize = !m_bBlock;\r
1356 \r
1357         LONG nSelectedItems = m_ListCtrl.GetSelected();\r
1358         DialogEnableWindow(IDOK, bValidLogSize && nSelectedItems>0);\r
1359 #endif\r
1360 }\r
1361 \r
1362 \r
1363 LRESULT CCommitDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)\r
1364 {\r
1365         switch (message) {\r
1366         case WM_NOTIFY:\r
1367                 if (wParam == IDC_SPLITTER)\r
1368                 { \r
1369                         SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;\r
1370                         DoSize(pHdr->delta);\r
1371                 }\r
1372                 break;\r
1373         }\r
1374 \r
1375         return __super::DefWindowProc(message, wParam, lParam);\r
1376 }\r
1377 \r
1378 void CCommitDlg::SetSplitterRange()\r
1379 {\r
1380         if ((m_ListCtrl)&&(m_cLogMessage))\r
1381         {\r
1382                 CRect rcTop;\r
1383                 m_cLogMessage.GetWindowRect(rcTop);\r
1384                 ScreenToClient(rcTop);\r
1385                 CRect rcMiddle;\r
1386                 m_ListCtrl.GetWindowRect(rcMiddle);\r
1387                 ScreenToClient(rcMiddle);\r
1388                 if (rcMiddle.Height() && rcMiddle.Width())\r
1389                         m_wndSplitter.SetRange(rcTop.top+60, rcMiddle.bottom-80);\r
1390         }\r
1391 }\r
1392 \r
1393 void CCommitDlg::DoSize(int delta)\r
1394 {\r
1395         RemoveAnchor(IDC_MESSAGEGROUP);\r
1396         RemoveAnchor(IDC_LOGMESSAGE);\r
1397         RemoveAnchor(IDC_SPLITTER);\r
1398         RemoveAnchor(IDC_SIGNOFF);\r
1399         RemoveAnchor(IDC_LISTGROUP);\r
1400         RemoveAnchor(IDC_FILELIST);\r
1401         CSplitterControl::ChangeHeight(&m_cLogMessage, delta, CW_TOPALIGN);\r
1402         CSplitterControl::ChangeHeight(GetDlgItem(IDC_MESSAGEGROUP), delta, CW_TOPALIGN);\r
1403         CSplitterControl::ChangeHeight(&m_ListCtrl, -delta, CW_BOTTOMALIGN);\r
1404         CSplitterControl::ChangeHeight(GetDlgItem(IDC_LISTGROUP), -delta, CW_BOTTOMALIGN);\r
1405         CSplitterControl::ChangePos(GetDlgItem(IDC_SIGNOFF),0,delta);\r
1406         AddAnchor(IDC_MESSAGEGROUP, TOP_LEFT, TOP_RIGHT);\r
1407         AddAnchor(IDC_LOGMESSAGE, TOP_LEFT, TOP_RIGHT);\r
1408         AddAnchor(IDC_SPLITTER, TOP_LEFT, TOP_RIGHT);\r
1409         AddAnchor(IDC_LISTGROUP, TOP_LEFT, BOTTOM_RIGHT);\r
1410         AddAnchor(IDC_FILELIST, TOP_LEFT, BOTTOM_RIGHT);\r
1411         AddAnchor(IDC_SIGNOFF,TOP_RIGHT);\r
1412         ArrangeLayout();\r
1413         // adjust the minimum size of the dialog to prevent the resizing from\r
1414         // moving the list control too far down.\r
1415         CRect rcLogMsg;\r
1416         m_cLogMessage.GetClientRect(rcLogMsg);\r
1417         SetMinTrackSize(CSize(m_DlgOrigRect.Width(), m_DlgOrigRect.Height()-m_LogMsgOrigRect.Height()+rcLogMsg.Height()));\r
1418 \r
1419         SetSplitterRange();\r
1420         m_cLogMessage.Invalidate();\r
1421         GetDlgItem(IDC_LOGMESSAGE)->Invalidate();\r
1422 }\r
1423 \r
1424 void CCommitDlg::OnSize(UINT nType, int cx, int cy)\r
1425 {\r
1426     // first, let the resizing take place\r
1427     __super::OnSize(nType, cx, cy);\r
1428 \r
1429     //set range\r
1430     SetSplitterRange();\r
1431 }\r
1432 \r
1433 \r
1434 void CCommitDlg::OnBnClickedSignOff()\r
1435 {\r
1436         // TODO: Add your control notification handler code here\r
1437         CString str;\r
1438         CString username;\r
1439         CString email;\r
1440         username=g_Git.GetUserName();\r
1441         email=g_Git.GetUserEmail();\r
1442         username.Remove(_T('\n'));\r
1443         email.Remove(_T('\n'));\r
1444         str.Format(_T("Signed-off-by: %s <%s>\n"),username,email);\r
1445 \r
1446         m_cLogMessage.SetText(m_cLogMessage.GetText()+_T("\r\n\r\n")+str);\r
1447 }\r
1448 \r
1449 void CCommitDlg::OnStnClickedCommitlabel()\r
1450 {\r
1451         // TODO: Add your control notification handler code here\r
1452 }\r
1453 \r
1454 void CCommitDlg::OnBnClickedCommitAmend()\r
1455 {\r
1456     // TODO: Add your control notification handler code here\r
1457 }\r