Performance optimization
[TortoiseGit.git] / src / TortoiseProc / LogDlg.cpp
blob3686749033718b02617a07cdeed04d0c760fed84
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2009, 2015 - TortoiseSVN
4 // Copyright (C) 2008-2015 - 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 #include "stdafx.h"
21 #include "TortoiseProc.h"
22 #include "cursor.h"
23 #include "StatGraphDlg.h"
24 #include "LogDlg.h"
25 #include "MessageBox.h"
26 #include "registry.h"
27 #include "AppUtils.h"
28 #include "StringUtils.h"
29 #include "UnicodeUtils.h"
30 #include "TempFile.h"
31 #include "IconMenu.h"
32 #include "BrowseRefsDlg.h"
33 #include "SmartHandle.h"
34 #include "LogOrdering.h"
35 #include "ClipboardHelper.h"
37 #define WM_TGIT_REFRESH_SELECTION (WM_APP + 1)
39 IMPLEMENT_DYNAMIC(CLogDlg, CResizableStandAloneDialog)
40 CLogDlg::CLogDlg(CWnd* pParent /*=NULL*/)
41 : CResizableStandAloneDialog(CLogDlg::IDD, pParent)
42 , m_wParam(0)
43 , m_currentChangedArray(NULL)
44 , m_nSortColumn(0)
45 , m_bFollowRenames(false)
46 , m_bSelect(false)
47 , m_bSelectionMustBeSingle(true)
48 , m_bShowTags(true)
49 , m_bShowLocalBranches(true)
50 , m_bShowRemoteBranches(true)
51 , m_bNoMerges(false)
52 , m_iHidePaths(0)
53 , m_bWalkBehavior(FALSE)
54 , m_bFirstParent(false)
55 , m_bWholeProject(FALSE)
56 , m_iCompressedGraph(0)
58 , m_bSelectionMustBeContinuous(false)
60 , m_sLogInfo(_T(""))
62 , m_bCancelled(FALSE)
63 , m_pNotifyWindow(NULL)
65 , m_bAscending(FALSE)
66 , m_hAccel(NULL)
67 , m_bNavigatingWithSelect(false)
69 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), FALSE);
70 m_bFilterCaseSensitively = !!CRegDWORD(L"Software\\TortoiseGit\\FilterCaseSensitively", FALSE);
71 m_bAsteriskLogPrefix = !!CRegDWORD(L"Software\\TortoiseGit\\AsteriskLogPrefix", TRUE);
72 m_LogList.m_SelectedFilters = CRegDWORD(_T("Software\\TortoiseGit\\SelectedLogFilters"), LOGFILTER_ALL);
74 CString str;
75 str=g_Git.m_CurrentDir;
76 str.Replace(_T(":"),_T("_"));
77 str=CString(_T("Software\\TortoiseGit\\LogDialog\\AllBranch\\"))+str;
79 m_regbAllBranch=CRegDWORD(str,FALSE);
81 m_bAllBranch=m_regbAllBranch;
83 str = g_Git.m_CurrentDir;
84 str.Replace(_T(":"),_T("_"));
85 m_regShowWholeProject = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ShowWholeProject\\") + str, FALSE);
86 m_bWholeProject = m_regShowWholeProject;
87 m_regbShowTags = CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\ShowTags\\") + str, TRUE);
88 m_bShowTags = !!m_regbShowTags;
89 m_regbShowLocalBranches = CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\ShowLocalBranches\\") + str, TRUE);
90 m_bShowLocalBranches = !!m_regbShowLocalBranches;
91 m_regbShowRemoteBranches = CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\ShowRemoteBranches\\") + str, TRUE);
92 m_bShowRemoteBranches = !!m_regbShowRemoteBranches;
94 m_bShowUnversioned = CRegDWORD(_T("Software\\TortoiseGit\\AddBeforeCommit"), TRUE);
96 m_bShowGravatar = !!CRegDWORD(_T("Software\\TortoiseGit\\EnableGravatar"), FALSE);
97 m_regbShowGravatar = CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\ShowGravatar\\") + str, m_bShowGravatar);
98 m_bShowGravatar = !!m_regbShowGravatar;
99 m_bShowDescribe = !!CRegDWORD(_T("Software\\TortoiseGit\\ShowDescribe"));
102 CLogDlg::~CLogDlg()
105 m_regbAllBranch = m_bAllBranch;
106 m_regbShowTags = m_bShowTags;
107 m_regbShowLocalBranches = m_bShowLocalBranches;
108 m_regbShowRemoteBranches = m_bShowRemoteBranches;
109 m_regbShowGravatar = m_bShowGravatar;
111 m_CurrentFilteredChangedArray.RemoveAll();
115 void CLogDlg::DoDataExchange(CDataExchange* pDX)
117 CResizableStandAloneDialog::DoDataExchange(pDX);
118 DDX_Control(pDX, IDC_LOGLIST, m_LogList);
119 DDX_Control(pDX, IDC_LOGMSG, m_ChangedFileListCtrl);
120 DDX_Control(pDX, IDC_PROGRESS, m_LogProgress);
121 DDX_Control(pDX, IDC_SPLITTERTOP, m_wndSplitter1);
122 DDX_Control(pDX, IDC_SPLITTERBOTTOM, m_wndSplitter2);
123 DDX_Text(pDX, IDC_SEARCHEDIT, m_LogList.m_sFilterText);
124 DDX_Control(pDX, IDC_DATEFROM, m_DateFrom);
125 DDX_Control(pDX, IDC_DATETO, m_DateTo);
126 DDX_Control(pDX, IDC_LOG_JUMPTYPE, m_JumpType);
127 DDX_Control(pDX, IDC_LOG_JUMPUP, m_JumpUp);
128 DDX_Control(pDX, IDC_LOG_JUMPDOWN, m_JumpDown);
129 DDX_Text(pDX, IDC_LOGINFO, m_sLogInfo);
130 DDX_Check(pDX, IDC_LOG_ALLBRANCH,m_bAllBranch);
131 DDX_Check(pDX, IDC_WHOLE_PROJECT, m_bWholeProject);
132 DDX_Check(pDX, IDC_WALKBEHAVIOUR, m_bWalkBehavior);
133 DDX_Control(pDX, IDC_SEARCHEDIT, m_cFilter);
134 DDX_Control(pDX, IDC_STATIC_REF, m_staticRef);
135 DDX_Control(pDX, IDC_PIC_AUTHOR, m_gravatar);
136 DDX_Control(pDX, IDC_FILTER, m_cFileFilter);
139 BEGIN_MESSAGE_MAP(CLogDlg, CResizableStandAloneDialog)
140 ON_WM_CONTEXTMENU()
141 ON_WM_SETCURSOR()
142 ON_NOTIFY(LVN_ITEMCHANGED, IDC_LOGLIST, OnLvnItemchangedLoglist)
143 ON_NOTIFY(LVN_ITEMCHANGED, IDC_LOGMSG, OnLvnItemchangedLogmsg)
144 ON_NOTIFY(EN_LINK, IDC_MSGVIEW, OnEnLinkMsgview)
145 ON_EN_VSCROLL(IDC_MSGVIEW, OnEnscrollMsgview)
146 ON_EN_HSCROLL(IDC_MSGVIEW, OnEnscrollMsgview)
147 ON_BN_CLICKED(IDC_STATBUTTON, OnBnClickedStatbutton)
149 ON_MESSAGE(WM_TGIT_REFRESH_SELECTION, OnRefreshSelection)
150 ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED, OnClickedInfoIcon)
151 ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED, OnClickedCancelFilter)
153 ON_MESSAGE(MSG_LOAD_PERCENTAGE,OnLogListLoading)
155 ON_EN_CHANGE(IDC_SEARCHEDIT, OnEnChangeSearchedit)
156 ON_WM_TIMER()
157 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETO, OnDtnDatetimechangeDateto)
158 ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATEFROM, OnDtnDatetimechangeDatefrom)
159 ON_CBN_SELCHANGE(IDC_LOG_JUMPTYPE, &CLogDlg::OnCbnSelchangeJumpType)
160 ON_COMMAND(IDC_LOG_JUMPUP, &CLogDlg::OnBnClickedJumpUp)
161 ON_COMMAND(IDC_LOG_JUMPDOWN, &CLogDlg::OnBnClickedJumpDown)
162 ON_COMMAND(ID_GO_UP, &CLogDlg::OnBnClickedJumpUp)
163 ON_COMMAND(ID_GO_DOWN, &CLogDlg::OnBnClickedJumpDown)
164 ON_BN_CLICKED(IDC_WALKBEHAVIOUR, OnBnClickedWalkBehaviour)
165 ON_BN_CLICKED(IDC_VIEW, OnBnClickedView)
166 ON_BN_CLICKED(IDC_WHOLE_PROJECT, OnBnClickShowWholeProject)
167 ON_NOTIFY(LVN_COLUMNCLICK,IDC_LOGLIST, OnLvnColumnclick)
168 ON_COMMAND(MSG_FETCHED_DIFF, OnBnClickedHidepaths)
169 ON_BN_CLICKED(IDC_LOG_ALLBRANCH, OnBnClickedAllBranch)
170 ON_EN_CHANGE(IDC_FILTER, OnEnChangeFileFilter)
172 ON_NOTIFY(DTN_DROPDOWN, IDC_DATEFROM, &CLogDlg::OnDtnDropdownDatefrom)
173 ON_WM_SIZE()
174 ON_BN_CLICKED(IDC_REFRESH, &CLogDlg::OnBnClickedRefresh)
175 ON_STN_CLICKED(IDC_STATIC_REF, &CLogDlg::OnBnClickedBrowseRef)
176 ON_COMMAND(ID_LOGDLG_REFRESH, &CLogDlg::OnBnClickedRefresh)
177 ON_COMMAND(ID_GO_BACKWARD_SELECT, &CLogDlg::GoBackAndSelect)
178 ON_COMMAND(ID_GO_FORWARD_SELECT, &CLogDlg::GoForwardAndSelect)
179 ON_COMMAND(ID_GO_BACKWARD, &CLogDlg::GoBack)
180 ON_COMMAND(ID_GO_FORWARD, &CLogDlg::GoForward)
181 ON_COMMAND(ID_SELECT_SEARCHFIELD, &CLogDlg::OnSelectSearchField)
182 ON_COMMAND(ID_LOGDLG_FIND, &CLogDlg::OnFind)
183 ON_COMMAND(ID_LOGDLG_FOCUSFILTER, &CLogDlg::OnFocusFilter)
184 ON_COMMAND(ID_EDIT_COPY, &CLogDlg::OnEditCopy)
185 ON_MESSAGE(MSG_REFLOG_CHANGED, OnRefLogChanged)
186 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED, OnTaskbarBtnCreated)
188 ON_REGISTERED_MESSAGE(CGitStatusListCtrl::GITSLNM_ITEMCHANGED, &CLogDlg::OnFileListCtrlItemChanged)
189 ON_WM_MOVE()
190 ON_WM_MOVING()
191 ON_WM_SIZING()
192 ON_WM_CTLCOLOR()
193 ON_WM_PAINT()
194 END_MESSAGE_MAP()
196 enum JumpType
198 JumpType_AuthorEmail,
199 JumpType_CommitterEmail,
200 JumpType_MergePoint,
201 JumpType_Parent1,
202 JumpType_Parent2,
203 JumpType_Tag,
204 JumpType_TagFF,
205 JumpType_Branch,
206 JumpType_BranchFF,
207 JumpType_History,
210 void CLogDlg::SetParams(const CTGitPath& orgPath, const CTGitPath& path, CString hightlightRevision, CString range, DWORD limit, int limitScale/*=-1*/)
212 m_orgPath = orgPath;
213 m_path = path;
214 m_hightlightRevision = hightlightRevision;
216 if (range == GIT_REV_ZERO)
217 range = _T("HEAD");
219 if (!(range.IsEmpty() || range == _T("HEAD")))
220 m_bAllBranch = BST_UNCHECKED;
222 SetRange(range);
224 if (limitScale == CFilterData::SHOW_NO_LIMIT || (!range.IsEmpty() && m_LogList.m_Filter.m_NumberOfLogsScale != CFilterData::SHOW_LAST_N_COMMITS))
225 m_LogList.m_Filter.m_NumberOfLogsScale = CFilterData::SHOW_NO_LIMIT;
226 if (limitScale >= CFilterData::SHOW_LAST_N_COMMITS && limit > 0)
228 // limitation from command line argument, so override the filter.
229 m_LogList.m_Filter.m_NumberOfLogs = limit;
230 m_LogList.m_Filter.m_NumberOfLogsScale = limitScale;
233 if (::IsWindow(m_hWnd))
234 UpdateData(FALSE);
237 void CLogDlg::SetFilter(const CString& findstr, LONG findtype, bool findregex)
239 m_LogList.m_sFilterText = findstr;
240 if (findtype)
241 m_LogList.m_SelectedFilters = findtype;
242 m_LogList.m_bFilterWithRegex = m_bFilterWithRegex = findregex;
245 BOOL CLogDlg::OnInitDialog()
247 CString temp;
248 CResizableStandAloneDialog::OnInitDialog();
249 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
251 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
252 // do this, Explorer would be unable to send that message to our window if we
253 // were running elevated. It's OK to make the call all the time, since if we're
254 // not elevated, this is a no-op.
255 CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) };
256 typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct);
257 CAutoLibrary hUser = AtlLoadSystemLibraryUsingFullPath(_T("user32.dll"));
258 if (hUser)
260 ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx");
261 if (pfnChangeWindowMessageFilterEx)
263 pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs);
266 m_pTaskbarList.Release();
267 if (FAILED(m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList)))
268 m_pTaskbarList = nullptr;
270 m_hAccel = LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG));
272 // use the state of the "stop on copy/rename" option from the last time
273 UpdateData(FALSE);
275 // set the font to use in the log message view, configured in the settings dialog
276 CAppUtils::CreateFontForLogs(m_logFont);
277 GetDlgItem(IDC_MSGVIEW)->SetFont(&m_logFont);
278 // make the log message rich edit control send a message when the mouse pointer is over a link
279 GetDlgItem(IDC_MSGVIEW)->SendMessage(EM_SETEVENTMASK, NULL, ENM_LINK | ENM_SCROLL);
281 // "unrelated paths" should be in gray color
282 m_iHidePaths = 2;
284 // set up the columns
285 m_LogList.DeleteAllItems();
287 m_LogList.m_Path=m_path;
288 m_LogList.m_hasWC = m_LogList.m_bShowWC = !GitAdminDir::IsBareRepo(g_Git.m_CurrentDir);
289 m_LogList.InsertGitColumn();
291 if (m_bWholeProject)
292 m_LogList.m_Path.Reset();
294 m_ChangedFileListCtrl.Init(GITSLC_COLEXT | GITSLC_COLSTATUS |GITSLC_COLADD|GITSLC_COLDEL, _T("LogDlg"), (GITSLC_POPALL ^ (GITSLC_POPIGNORE|GITSLC_POPRESTORE)), false, m_LogList.m_hasWC, GITSLC_COLEXT | GITSLC_COLSTATUS | GITSLC_COLADD| GITSLC_COLDEL);
296 GetDlgItem(IDC_LOGLIST)->UpdateData(FALSE);
298 SetDlgTitle();
300 CheckRegexpTooltip();
302 SetSplitterRange();
304 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
305 m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);
306 m_cFilter.SetInfoIcon(IDI_LOGFILTER);
307 m_cFilter.SetValidator(this);
309 AdjustControlSize(IDC_LOG_ALLBRANCH);
310 AdjustControlSize(IDC_WHOLE_PROJECT);
312 GetClientRect(m_DlgOrigRect);
313 m_LogList.GetClientRect(m_LogListOrigRect);
314 GetDlgItem(IDC_MSGVIEW)->GetClientRect(m_MsgViewOrigRect);
315 m_ChangedFileListCtrl.GetClientRect(m_ChgOrigRect);
317 m_Brush.CreateSolidBrush(RGB(174, 200, 255));
319 m_DateFrom.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS|MCS_NOTODAY|MCS_NOTRAILINGDATES|MCS_NOSELCHANGEONNAV);
320 m_DateTo.SendMessage(DTM_SETMCSTYLE, 0, MCS_WEEKNUMBERS | MCS_NOTRAILINGDATES | MCS_NOSELCHANGEONNAV);
322 m_staticRef.SetURL(CString());
324 AddMainAnchors();
325 SetFilterCueText();
327 m_LogList.m_ShowMask &= ~CGit::LOG_INFO_LOCAL_BRANCHES;
328 if (m_bAllBranch == BST_CHECKED)
329 m_LogList.m_ShowMask|=CGit::LOG_INFO_ALL_BRANCH;
330 else if (m_bAllBranch == BST_INDETERMINATE)
331 m_LogList.m_ShowMask |= CGit::LOG_INFO_LOCAL_BRANCHES;
332 else
333 m_LogList.m_ShowMask&=~CGit::LOG_INFO_ALL_BRANCH;
335 HandleShowLabels(m_bShowTags, LOGLIST_SHOWTAGS);
336 HandleShowLabels(m_bShowLocalBranches, LOGLIST_SHOWLOCALBRANCHES);
337 HandleShowLabels(m_bShowRemoteBranches, LOGLIST_SHOWREMOTEBRANCHES);
339 // SetPromptParentWindow(m_hWnd);
340 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_AUTHOREMAIL)));
341 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_COMMITTEREMAIL)));
342 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_MERGEPOINT)));
343 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_PARENT1)));
344 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_PARENT2)));
345 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_TAG)));
346 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_TAG_FF)));
347 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_BRANCH)));
348 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_BRANCH_FF)));
349 m_JumpType.AddString(CString(MAKEINTRESOURCE(IDS_PROC_SELECTION_HISTORY)));
350 m_JumpType.SetCurSel(0);
351 m_JumpUp.SetIcon((HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_JUMPUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
352 m_JumpDown.SetIcon((HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_JUMPDOWN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
354 if (hWndExplorer)
355 CenterWindow(CWnd::FromHandle(hWndExplorer));
356 EnableSaveRestore(_T("LogDlg"));
358 DWORD yPos1 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
359 DWORD yPos2 = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
360 RECT rcDlg, rcLogList, rcChgMsg;
361 GetClientRect(&rcDlg);
362 m_LogList.GetWindowRect(&rcLogList);
363 ScreenToClient(&rcLogList);
364 m_ChangedFileListCtrl.GetWindowRect(&rcChgMsg);
365 ScreenToClient(&rcChgMsg);
366 if (yPos1 && ((LONG)yPos1 < rcDlg.bottom - 185))
368 RECT rectSplitter;
369 m_wndSplitter1.GetWindowRect(&rectSplitter);
370 ScreenToClient(&rectSplitter);
371 int delta = yPos1 - rectSplitter.top;
373 if ((rcLogList.bottom + delta > rcLogList.top)&&(rcLogList.bottom + delta < rcChgMsg.bottom - 30))
375 m_wndSplitter1.SetWindowPos(NULL, rectSplitter.left, yPos1, 0, 0, SWP_NOSIZE);
376 DoSizeV1(delta);
379 if (yPos2 && ((LONG)yPos2 < rcDlg.bottom - 153))
381 RECT rectSplitter;
382 m_wndSplitter2.GetWindowRect(&rectSplitter);
383 ScreenToClient(&rectSplitter);
384 int delta = yPos2 - rectSplitter.top;
386 if ((rcChgMsg.top + delta < rcChgMsg.bottom)&&(rcChgMsg.top + delta > rcLogList.top + 30))
388 m_wndSplitter2.SetWindowPos(NULL, rectSplitter.left, yPos2, 0, 0, SWP_NOSIZE);
389 DoSizeV2(delta);
393 SetSplitterRange();
395 if (m_bSelect)
397 // the dialog is used to select revisions
398 // enable the OK button if appropriate
399 EnableOKButton();
401 else
403 // the dialog is used to just view log messages
404 // hide the OK button and set text on Cancel button to OK
405 GetDlgItemText(IDOK, temp);
406 SetDlgItemText(IDCANCEL, temp);
407 GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
410 // first start a thread to obtain the log messages without
411 // blocking the dialog
412 //m_tTo = 0;
413 //m_tFrom = (DWORD)-1;
415 // scroll to user selected or current revision
416 if (m_hightlightRevision.IsEmpty() || g_Git.GetHash(m_LogList.m_lastSelectedHash, m_hightlightRevision))
418 if (g_Git.GetHash(m_LogList.m_lastSelectedHash, _T("HEAD")))
419 MessageBox(g_Git.GetGitLastErr(_T("Could not get HEAD hash.")), _T("TortoiseGit"), MB_ICONERROR);
422 if (g_Git.GetConfigValueBool(_T("tgit.logshowpatch")))
423 TogglePatchView();
425 m_LogList.FetchLogAsync(this);
426 ShowGravatar();
427 m_gravatar.Init();
429 m_cFileFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);
430 m_cFileFilter.SetInfoIcon(IDI_FILTEREDIT);
431 temp.LoadString(IDS_FILEDIFF_FILTERCUE);
432 temp = _T(" ") + temp;
433 m_cFileFilter.SetCueBanner(temp);
435 GetDlgItem(IDC_LOGLIST)->SetFocus();
437 m_History.SetMaxHistoryItems((LONG)CRegDWORD(_T("Software\\TortoiseGit\\MaxRefHistoryItems"), 5));
438 CString reg;
439 reg.Format(_T("Software\\TortoiseGit\\History\\log-refs\\%s"), (LPCTSTR)g_Git.m_CurrentDir);
440 reg.Replace(_T(':'),_T('_'));
441 m_History.Load(reg, _T("ref"));
443 reg.Format(_T("Software\\TortoiseGit\\History\\LogDlg_Limits\\%s\\FromDate"), (LPCTSTR)g_Git.m_CurrentDir);
444 reg.Replace(_T(':'), _T('_'));
445 m_regLastSelectedFromDate = CRegString(reg);
447 ShowStartRef();
448 return FALSE;
451 HBRUSH CLogDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
453 HBRUSH hbr = __super::OnCtlColor(pDC, pWnd, nCtlColor);
455 if ((m_LogList.m_Filter.m_NumberOfLogsScale >= CFilterData::SHOW_LAST_N_COMMITS || m_LogList.m_Filter.m_NumberOfLogsScale == CFilterData::SHOW_LAST_SEL_DATE && m_LogList.m_Filter.m_From != -1) && pWnd->GetDlgCtrlID() == IDC_FROMLABEL)
457 pDC->SetBkMode(TRANSPARENT);
458 return m_Brush;
461 return hbr;
464 void CLogDlg::OnPaint()
466 CPaintDC dc(this);
468 if (!(m_LogList.m_Filter.m_NumberOfLogsScale >= CFilterData::SHOW_LAST_N_COMMITS || m_LogList.m_Filter.m_NumberOfLogsScale == CFilterData::SHOW_LAST_SEL_DATE && m_LogList.m_Filter.m_From != -1))
469 return;
471 CWnd* pWnd = GetDlgItem(IDC_FROMLABEL);
472 if (!pWnd)
473 return;
475 CRect rect;
476 pWnd->GetWindowRect(&rect);
477 ScreenToClient(rect);
478 rect.left -= 5;
479 rect.top -= 3;
480 rect.bottom += 3;
482 dc.FillRect(rect, &m_Brush);
485 LRESULT CLogDlg::OnLogListLoading(WPARAM wParam, LPARAM /*lParam*/)
487 int cur=(int)wParam;
489 if( cur == GITLOG_START )
491 CString temp;
492 temp.LoadString(IDS_PROGRESSWAIT);
494 this->m_LogList.ShowText(temp, true);
496 // We use a progress bar while getting the logs
497 m_LogProgress.SetRange32(0, 100);
498 m_LogProgress.SetPos(0);
499 if (m_pTaskbarList)
501 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
502 m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
505 GetDlgItem(IDC_WALKBEHAVIOUR)->ShowWindow(SW_HIDE);
506 GetDlgItem(IDC_VIEW)->ShowWindow(SW_HIDE);
507 GetDlgItem(IDC_STATBUTTON)->ShowWindow(SW_HIDE);
508 GetDlgItem(IDC_PROGRESS)->ShowWindow(TRUE);
510 DialogEnableWindow(IDC_WALKBEHAVIOUR, FALSE);
511 DialogEnableWindow(IDC_STATBUTTON, FALSE);
512 //DialogEnableWindow(IDC_REFRESH, FALSE);
513 DialogEnableWindow(IDC_VIEW, FALSE);
516 else if( cur == GITLOG_END)
518 if(this->m_LogList.HasText())
520 this->m_LogList.ClearText();
522 UpdateLogInfoLabel();
524 if (m_pTaskbarList)
525 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
527 DialogEnableWindow(IDC_WHOLE_PROJECT, !m_bFollowRenames && !m_path.IsEmpty());
529 DialogEnableWindow(IDC_STATBUTTON, !(m_LogList.m_arShownList.IsEmpty() || m_LogList.m_arShownList.GetCount() == 1 && m_LogList.m_bShowWC));
530 DialogEnableWindow(IDC_REFRESH, TRUE);
531 DialogEnableWindow(IDC_VIEW, TRUE);
532 DialogEnableWindow(IDC_WALKBEHAVIOUR, TRUE);
533 // PostMessage(WM_TIMER, LOGFILTER_TIMER);
534 GetDlgItem(IDC_WALKBEHAVIOUR)->ShowWindow(SW_SHOW);
535 GetDlgItem(IDC_VIEW)->ShowWindow(SW_SHOW);
536 GetDlgItem(IDC_STATBUTTON)->ShowWindow(SW_SHOW);
537 GetDlgItem(IDC_PROGRESS)->ShowWindow(FALSE);
538 //CTime time=m_LogList.GetOldestTime();
539 CTime begin,end;
540 m_LogList.GetTimeRange(begin,end);
542 if (m_LogList.m_Filter.m_From > 0 && m_LogList.m_Filter.m_NumberOfLogsScale >= CFilterData::SHOW_LAST_SEL_DATE)
543 begin = m_LogList.m_Filter.m_From;
544 m_DateFrom.SetTime(&begin);
545 if (m_LogList.m_Filter.m_To != -1)
546 end = m_LogList.m_Filter.m_To;
547 m_DateTo.SetTime(&end);
548 Invalidate();
550 else
552 if(this->m_LogList.HasText())
554 this->m_LogList.ClearText();
555 this->m_LogList.Invalidate();
557 UpdateLogInfoLabel();
558 m_LogProgress.SetPos(cur);
559 if (m_pTaskbarList)
561 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
562 m_pTaskbarList->SetProgressValue(m_hWnd, cur, 100);
565 return 0;
567 void CLogDlg::SetDlgTitle()
569 if (m_sTitle.IsEmpty())
570 GetWindowText(m_sTitle);
572 if (m_LogList.m_Path.IsEmpty() || m_orgPath.GetWinPathString().IsEmpty())
574 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, m_sTitle);
576 else
577 CAppUtils::SetWindowTitle(m_hWnd, m_orgPath.GetWinPathString(), m_sTitle);
580 void CLogDlg::CheckRegexpTooltip()
582 CWnd *pWnd = GetDlgItem(IDC_SEARCHEDIT);
583 // Since tooltip describes regexp features, show it only if regexps are enabled.
584 if (m_bFilterWithRegex)
586 m_tooltips.AddTool(pWnd, IDS_LOG_FILTER_REGEX_TT);
588 else
589 m_tooltips.DelTool(pWnd);
592 void CLogDlg::EnableOKButton()
594 if (m_bSelect)
596 // the dialog is used to select revisions
597 if (m_bSelectionMustBeSingle)
599 // enable OK button if only a single revision is selected
600 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()==1));
602 else if (m_bSelectionMustBeContinuous)
603 DialogEnableWindow(IDOK, (m_LogList.GetSelectedCount()!=0)&&(m_LogList.IsSelectionContinuous()));
604 else
605 DialogEnableWindow(IDOK, m_LogList.GetSelectedCount()!=0);
607 else
608 DialogEnableWindow(IDOK, TRUE);
611 bool LookLikeGitHash(const CString& msg, int &pos)
613 int c = 0;
614 for (; pos < msg.GetLength(); ++pos)
616 if (msg[pos] >= '0' && msg[pos] <= '9' || msg[pos] >= 'a' && msg[pos] <= 'f')
618 c++;
620 else
622 return c >= g_Git.GetShortHASHLength() && c <= GIT_HASH_SIZE * 2 && msg[pos] != '@';
625 return c >= g_Git.GetShortHASHLength() && c <= GIT_HASH_SIZE * 2;
628 std::vector<CHARRANGE> FindGitHashPositions(const CString& msg, int offset)
630 std::vector<CHARRANGE> result;
631 offset = offset < 0 ? 0 : offset;
632 int old = offset;
633 while (offset < msg.GetLength())
635 old = offset;
636 TCHAR e = msg[offset];
637 if (e == '\n')
639 ++offset;
640 if (msg.Mid(offset, 11) == _T("git-svn-id:")
641 || msg.Mid(offset, 14) == _T("Signed-off-by:")
642 || msg.Mid(offset, 10) == _T("Change-Id:")
645 offset += 10;
646 while (offset < msg.GetLength())
648 if (msg[++offset] == '\n')
649 break;
651 continue;
654 else if (e >= 'A' && e <= 'Z' || e >= 'h' && e <= 'z')
658 e = msg[++offset];
659 } while (offset < msg.GetLength() && (e >= 'A' && e <= 'Z' || e >= 'a' && e <= 'z' || e >= '0' && e <= '9'));
661 else if (e >= 'a' && e <= 'g' || e >= '0' && e <= '9')
663 if (e == 'g')
665 ++old;
666 ++offset;
668 if (LookLikeGitHash(msg, offset))
670 TCHAR d = offset < msg.GetLength() ? msg[offset] : '\0';
671 if (!((d >= 'A' && d <= 'Z') || (d >= 'a' && d <= 'z') || (d >= '0' && d <= '9')))
673 CHARRANGE range = { old, offset };
674 result.push_back(range);
677 ++offset;
679 else
681 ++offset;
685 return result;
688 BOOL FindGitHash(const CString& msg, int offset, CWnd *pWnd)
690 std::vector<CHARRANGE> positions = FindGitHashPositions(msg, offset);
691 CAppUtils::SetCharFormat(pWnd, CFM_LINK, CFE_LINK, positions);
693 return positions.empty() ? FALSE : TRUE;
696 static int DescribeCommit(CGitHash& hash, CString& result)
698 CAutoRepository repo(g_Git.GetGitRepository());
699 if (!repo)
700 return -1;
701 CAutoObject commit;
702 if (git_object_lookup(commit.GetPointer(), repo, (const git_oid *)hash.m_hash, GIT_OBJ_COMMIT))
703 return -1;
705 CAutoDescribeResult describe;
706 git_describe_options describe_options = GIT_DESCRIBE_OPTIONS_INIT;
707 describe_options.describe_strategy = CRegDWORD(_T("Software\\TortoiseGit\\DescribeStrategy"), GIT_DESCRIBE_DEFAULT);
708 if (git_describe_commit(describe.GetPointer(), (git_object *)commit, &describe_options))
709 return -1;
711 CAutoBuf describe_buf;
712 git_describe_format_options format_options = GIT_DESCRIBE_FORMAT_OPTIONS_INIT;
713 format_options.abbreviated_size = CRegDWORD(_T("Software\\TortoiseGit\\DescribeAbbreviatedSize"), GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE);
714 format_options.always_use_long_format = CRegDWORD(_T("Software\\TortoiseGit\\DescribeAlwaysLong"));
715 if (git_describe_format(describe_buf, describe, &format_options))
716 return -1;
718 result = CUnicodeUtils::GetUnicode(describe_buf->ptr);
719 return 0;
722 void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/)
724 // we fill here the log message rich edit control,
725 // and also populate the changed files list control
726 // according to the selected revision(s).
728 CRichEditCtrl * pMsgView = (CRichEditCtrl*)GetDlgItem(IDC_MSGVIEW);
729 // empty the log message view
730 pMsgView->SetWindowText(_T(" "));
731 FillPatchView(true);
732 // empty the changed files list
733 m_ChangedFileListCtrl.SetRedraw(FALSE);
734 // InterlockedExchange(&m_bNoDispUpdates, TRUE);
735 m_currentChangedArray = NULL;
736 m_ChangedFileListCtrl.DeleteAllItems();
738 // if we're not here to really show a selected revision, just
739 // get out of here after clearing the views, which is what is intended
740 // if that flag is not set.
741 if (!bShow)
743 // force a redraw
744 m_ChangedFileListCtrl.Invalidate();
745 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
746 m_ChangedFileListCtrl.SetRedraw(TRUE);
747 m_gravatar.LoadGravatar();
748 return;
751 // depending on how many revisions are selected, we have to do different
752 // tasks.
753 int selCount = m_LogList.GetSelectedCount();
754 if (selCount == 0)
756 // if nothing is selected, we have nothing more to do
757 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
758 m_ChangedFileListCtrl.SetRedraw(TRUE);
759 m_gravatar.LoadGravatar();
760 return;
762 else if (selCount == 1)
764 // if one revision is selected, we have to fill the log message view
765 // with the corresponding log message, and also fill the changed files
766 // list fully.
767 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
768 int selIndex = m_LogList.GetNextSelectedItem(pos);
769 if (selIndex >= m_LogList.m_arShownList.GetCount())
771 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
772 m_ChangedFileListCtrl.SetRedraw(TRUE);
773 return;
775 Locker lock(m_LogList.m_critSec_AsyncDiff);
776 GitRevLoglist* pLogEntry = reinterpret_cast<GitRevLoglist*>(m_LogList.m_arShownList.SafeGetAt(selIndex));
779 CString out_describe;
780 if (m_bShowDescribe)
782 CString result;
783 if (!DescribeCommit(pLogEntry->m_CommitHash, result))
784 out_describe = _T("Describe: ") + result + _T("\r\n");
787 // set the log message text
788 pMsgView->SetWindowText(CString(MAKEINTRESOURCE(IDS_HASH)) + _T(": ") + pLogEntry->m_CommitHash.ToString() + _T("\r\n") + out_describe + _T("\r\n"));
789 // turn bug ID's into links if the bugtraq: properties have been set
790 // and we can find a match of those in the log message
792 pMsgView->SetSel(-1,-1);
793 CAppUtils::SetCharFormat(pMsgView, CFM_BOLD, CFE_BOLD);
795 CString msg = m_bAsteriskLogPrefix ? _T("* ") : _T("");
796 msg+=pLogEntry->GetSubject();
797 pMsgView->ReplaceSel(msg);
799 pMsgView->SetSel(-1,-1);
800 CAppUtils::SetCharFormat(pMsgView, CFM_BOLD, 0);
802 msg=_T("\n");
803 msg+=pLogEntry->GetBody();
805 if(!pLogEntry->m_Notes.IsEmpty())
807 msg+= _T("\n*") + CString(MAKEINTRESOURCE(IDS_NOTES)) + _T("* ");
808 msg+= pLogEntry->m_Notes;
809 msg+= _T("\n\n");
812 CString tagInfo = m_LogList.GetTagInfo(pLogEntry);
813 if(!tagInfo.IsEmpty())
814 tagInfo = _T("\n*") + CString(MAKEINTRESOURCE(IDS_PROC_LOG_TAGINFO)) + _T("*\n\n") + tagInfo;
815 msg += tagInfo;
817 pMsgView->ReplaceSel(msg);
819 CString text;
820 pMsgView->GetWindowText(text);
821 // the rich edit control doesn't count the CR char!
822 // to be exact: CRLF is treated as one char.
823 text.Remove('\r');
825 int findHashStart = text.Find('\n');
826 if (!out_describe.IsEmpty())
827 findHashStart = text.Find('\n', findHashStart + 1);
828 FindGitHash(text, findHashStart, pMsgView);
829 m_LogList.m_ProjectProperties.FindBugID(text, pMsgView);
830 CAppUtils::StyleURLs(text, pMsgView);
831 if (((DWORD)CRegStdDWORD(_T("Software\\TortoiseGit\\StyleCommitMessages"), TRUE)) == TRUE)
832 CAppUtils::FormatTextInRichEditControl(pMsgView);
834 CHARRANGE range;
835 range.cpMin = 0;
836 range.cpMax = 0;
837 pMsgView->SendMessage(EM_EXSETSEL, NULL, (LPARAM)&range);
839 CString matchpath=this->m_path.GetGitPathString();
841 bool mightNeedReset = true;
843 CTGitPathList& files = pLogEntry->GetFiles(&m_LogList);
844 int count = files.GetCount();
845 if (!m_bWholeProject && !matchpath.IsEmpty() && m_iHidePaths)
847 int matchPathLen = matchpath.GetLength();
848 mightNeedReset = false;
849 for (int i = 0; i < count; ++i)
851 ((CTGitPath&)files[i]).m_Action &= ~(CTGitPath::LOGACTIONS_HIDE | CTGitPath::LOGACTIONS_GRAY);
853 if (files[i].GetGitPathString().Left(matchPathLen) != matchpath && ((files[i].m_Action & (CTGitPath::LOGACTIONS_REPLACED | CTGitPath::LOGACTIONS_COPY)) == 0 || files[i].GetGitOldPathString().Left(matchPathLen) != matchpath))
855 if (m_iHidePaths == 1)
856 ((CTGitPath&)files[i]).m_Action |= CTGitPath::LOGACTIONS_HIDE;
857 else if (m_iHidePaths == 2)
858 ((CTGitPath&)files[i]).m_Action |= CTGitPath::LOGACTIONS_GRAY;
863 if (mightNeedReset)
865 for (int i = 0 ; i < count; ++i)
866 ((CTGitPath&)files[i]).m_Action &= ~(CTGitPath::LOGACTIONS_HIDE | CTGitPath::LOGACTIONS_GRAY);
869 CString fileFilter;
870 m_cFileFilter.GetWindowText(fileFilter);
871 if (!fileFilter.IsEmpty())
873 fileFilter.MakeLower();
874 for (int i = 0; i < count; ++i)
876 CString sPath(files[i].GetGitPathString());
877 sPath.MakeLower();
878 if (sPath.Find(fileFilter) < 0)
879 ((CTGitPath&)files[i]).m_Action |= CTGitPath::LOGACTIONS_HIDE;
883 m_ChangedFileListCtrl.UpdateWithGitPathList(pLogEntry->GetFiles(&m_LogList));
884 m_ChangedFileListCtrl.m_CurrentVersion=pLogEntry->m_CommitHash;
885 if (pLogEntry->m_CommitHash.IsEmpty() && m_bShowUnversioned)
887 m_ChangedFileListCtrl.UpdateUnRevFileList(pLogEntry->GetUnRevFiles());
888 m_ChangedFileListCtrl.Show(GITSLC_SHOWVERSIONED | GITSLC_SHOWUNVERSIONED);
890 else
891 m_ChangedFileListCtrl.Show(GITSLC_SHOWVERSIONED);
893 m_ChangedFileListCtrl.SetBusyString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_FETCHINGFILES)));
895 if(!pLogEntry->m_IsDiffFiles)
896 m_ChangedFileListCtrl.SetBusy(TRUE);
897 else
898 m_ChangedFileListCtrl.SetBusy(FALSE);
900 m_ChangedFileListCtrl.SetRedraw(TRUE);
901 m_gravatar.LoadGravatar(pLogEntry->GetAuthorEmail());
902 return;
906 else
908 // more than one revision is selected:
909 // the log message view must be emptied
910 // the changed files list contains all the changed paths from all
911 // selected revisions, with 'doubles' removed
912 m_currentChangedPathList = GetChangedPathsFromSelectedRevisions(true);
913 m_gravatar.LoadGravatar();
916 // redraw the views
917 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
918 #if 0
919 if (m_currentChangedArray)
921 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedArray->GetCount());
922 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedArray->GetCount());
924 else if (m_currentChangedPathList.GetCount())
926 m_ChangedFileListCtrl.SetItemCountEx(m_currentChangedPathList.GetCount());
927 m_ChangedFileListCtrl.RedrawItems(0, m_currentChangedPathList.GetCount());
929 else
931 m_ChangedFileListCtrl.SetItemCountEx(0);
932 m_ChangedFileListCtrl.Invalidate();
934 #endif
935 // sort according to the settings
936 if (m_nSortColumnPathList > 0)
937 SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList);
938 else
939 SetSortArrow(&m_ChangedFileListCtrl, -1, false);
940 m_ChangedFileListCtrl.SetRedraw(TRUE);
944 void CLogDlg::FillPatchView(bool onlySetTimer)
946 if (!::IsWindow(this->m_patchViewdlg.m_hWnd))
947 return;
949 KillTimer(LOG_FILLPATCHVTIMER);
950 if (onlySetTimer)
952 SetTimer(LOG_FILLPATCHVTIMER, 100, nullptr);
953 return;
956 POSITION posLogList = m_LogList.GetFirstSelectedItemPosition();
957 if (posLogList == nullptr)
959 m_patchViewdlg.ClearView();
960 return; // nothing is selected, get out of here
963 GitRev * pLogEntry = reinterpret_cast<GitRev* >(m_LogList.m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(posLogList)));
964 if (pLogEntry == nullptr || m_LogList.GetNextSelectedItem(posLogList) != -1)
966 m_patchViewdlg.ClearView();
967 return;
970 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
971 CString out;
973 if (pos == nullptr)
975 int diffContext = 0;
976 if (CAppUtils::GetMsysgitVersion() > 0x01080100)
977 diffContext = g_Git.GetConfigValueInt32(_T("diff.context"), -1);
978 CStringA outA;
979 CString rev1 = pLogEntry->m_CommitHash.IsEmpty() ? _T("HEAD") : (pLogEntry->m_CommitHash.ToString() + _T("~1"));
980 CString rev2 = pLogEntry->m_CommitHash.IsEmpty() ? GIT_REV_ZERO : pLogEntry->m_CommitHash.ToString();
981 g_Git.GetUnifiedDiff(CTGitPath(), rev1, rev2, &outA, false, false, diffContext);
982 out = CUnicodeUtils::GetUnicode(outA);
984 else
986 while (pos)
988 int nSelect = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
989 CTGitPath * p = (CTGitPath*)m_ChangedFileListCtrl.GetItemData(nSelect);
990 if (p && !(p->m_Action&CTGitPath::LOGACTIONS_UNVER))
992 CString cmd;
993 if (pLogEntry->m_CommitHash.IsEmpty())
994 cmd.Format(_T("git.exe diff HEAD -- \"%s\""), (LPCTSTR)p->GetGitPathString());
995 else
996 cmd.Format(_T("git.exe diff %s^%d..%s -- \"%s\""), (LPCTSTR)pLogEntry->m_CommitHash.ToString(), p->m_ParentNo + 1, (LPCTSTR)pLogEntry->m_CommitHash.ToString(), (LPCTSTR)p->GetGitPathString());
997 g_Git.Run(cmd, &out, CP_UTF8);
1002 m_patchViewdlg.SetText(out);
1005 void CLogDlg::TogglePatchView()
1007 m_patchViewdlg.m_ParentDlg = this;
1008 if (!IsWindow(m_patchViewdlg.m_hWnd))
1010 BOOL viewPatchEnabled = FALSE;
1011 viewPatchEnabled = g_Git.GetConfigValueBool(_T("tgit.logshowpatch"));
1012 if (viewPatchEnabled == FALSE)
1013 g_Git.SetConfigValue(_T("tgit.logshowpatch"), _T("true"));
1014 m_patchViewdlg.Create(IDD_PATCH_VIEW, this);
1015 m_patchViewdlg.m_ctrlPatchView.Call(SCI_SETSCROLLWIDTHTRACKING, TRUE);
1016 CRect rect;
1017 this->GetWindowRect(&rect);
1019 m_patchViewdlg.ShowWindow(SW_SHOW);
1020 m_patchViewdlg.SetWindowPos(nullptr, rect.right, rect.top, rect.Width(), rect.Height(), SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
1022 FillPatchView();
1024 else
1026 g_Git.SetConfigValue(_T("tgit.logshowpatch"), _T("false"));
1027 m_patchViewdlg.ShowWindow(SW_HIDE);
1028 m_patchViewdlg.DestroyWindow();
1032 LRESULT CLogDlg::OnFileListCtrlItemChanged(WPARAM /*wparam*/, LPARAM /*lparam*/)
1034 FillPatchView(true);
1035 return 0;
1038 void CLogDlg::OnMoving(UINT fwSide, LPRECT pRect)
1040 __super::OnMoving(fwSide, pRect);
1042 if (!::IsWindow(m_patchViewdlg.m_hWnd))
1043 return;
1045 RECT patchrect;
1046 m_patchViewdlg.GetWindowRect(&patchrect);
1047 if (!::IsWindow(m_hWnd))
1048 return;
1050 RECT thisrect;
1051 GetWindowRect(&thisrect);
1052 if (patchrect.left == thisrect.right)
1054 m_patchViewdlg.SetWindowPos(nullptr, patchrect.left - (thisrect.left - pRect->left), patchrect.top - (thisrect.top - pRect->top), 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
1058 void CLogDlg::OnSizing(UINT fwSide, LPRECT pRect)
1060 __super::OnSizing(fwSide, pRect);
1062 if (!::IsWindow(this->m_patchViewdlg.m_hWnd))
1063 return;
1065 CRect thisrect, patchrect;
1066 this->GetWindowRect(thisrect);
1067 this->m_patchViewdlg.GetWindowRect(patchrect);
1068 if (thisrect.right != patchrect.left)
1069 return;
1071 patchrect.left -= (thisrect.right - pRect->right);
1072 patchrect.right -= (thisrect.right - pRect->right);
1074 if (patchrect.bottom == thisrect.bottom)
1075 patchrect.bottom -= (thisrect.bottom - pRect->bottom);
1076 if (patchrect.top == thisrect.top)
1077 patchrect.top -= thisrect.top - pRect->top;
1078 m_patchViewdlg.MoveWindow(patchrect);
1081 void CLogDlg::OnSelectSearchField()
1083 m_cFilter.SetSel(0, -1, FALSE);
1084 m_cFilter.SetFocus();
1087 void CLogDlg::GoBack()
1089 GoBackForward(false, false);
1092 void CLogDlg::GoForward()
1094 GoBackForward(false, true);
1097 void CLogDlg::GoBackAndSelect()
1099 GoBackForward(true, false);
1102 void CLogDlg::GoForwardAndSelect()
1104 GoBackForward(true, true);
1107 void CLogDlg::GoBackForward(bool select, bool bForward)
1109 m_LogList.m_highlight.Empty();
1110 CGitHash gotoHash;
1111 if (bForward ? m_LogList.m_selectionHistory.GoForward(gotoHash) : m_LogList.m_selectionHistory.GoBack(gotoHash))
1113 int i;
1114 for (i = 0; i < m_LogList.m_arShownList.GetCount(); ++i)
1116 GitRev *rev = (GitRev *)m_LogList.m_arShownList.SafeGetAt(i);
1117 if (!rev) continue;
1118 if (rev->m_CommitHash == gotoHash)
1120 m_LogList.EnsureVisible(i, FALSE);
1121 if (select)
1123 m_LogList.m_highlight.Empty();
1124 m_LogList.SetItemState(m_LogList.GetSelectionMark(), 0, LVIS_SELECTED | LVIS_FOCUSED);
1125 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1126 while (pos)
1128 int index = m_LogList.GetNextSelectedItem(pos);
1129 if (index >= 0)
1130 m_LogList.SetItemState(index, 0, LVIS_SELECTED);
1132 m_bNavigatingWithSelect = true;
1133 m_LogList.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
1134 m_LogList.SetSelectionMark(i);
1135 m_bNavigatingWithSelect = false;
1137 else
1138 m_LogList.m_highlight = gotoHash;
1139 m_LogList.Invalidate();
1140 return;
1143 if (i == m_LogList.m_arShownList.GetCount())
1145 CString msg;
1146 msg.Format(IDS_LOG_NOT_VISIBLE, (LPCTSTR)gotoHash.ToString());
1147 MessageBox(msg, _T("TortoiseGit"), MB_OK | MB_ICONINFORMATION);
1148 return;
1151 PlaySound((LPCTSTR)SND_ALIAS_SYSTEMASTERISK, nullptr, SND_ASYNC | SND_ALIAS_ID);
1154 void CLogDlg::OnBnClickedRefresh()
1156 Refresh (true);
1159 void CLogDlg::Refresh (bool clearfilter /*autoGoOnline*/)
1161 m_LogList.Refresh(clearfilter);
1162 EnableOKButton();
1163 ShowStartRef();
1164 FillLogMessageCtrl(false);
1169 BOOL CLogDlg::Cancel()
1171 return m_bCancelled;
1174 void CLogDlg::SaveSplitterPos()
1176 if (!IsIconic())
1178 CRegDWORD regPos1(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
1179 CRegDWORD regPos2(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
1180 RECT rectSplitter;
1181 m_wndSplitter1.GetWindowRect(&rectSplitter);
1182 ScreenToClient(&rectSplitter);
1183 regPos1 = rectSplitter.top;
1184 m_wndSplitter2.GetWindowRect(&rectSplitter);
1185 ScreenToClient(&rectSplitter);
1186 regPos2 = rectSplitter.top;
1190 void CLogDlg::OnCancel()
1192 this->ShowWindow(SW_HIDE);
1194 // canceling means stopping the working thread if it's still running.
1195 m_LogList.SafeTerminateAsyncDiffThread();
1196 if (this->IsThreadRunning())
1198 m_LogList.SafeTerminateThread();
1200 UpdateData();
1202 SaveSplitterPos();
1203 __super::OnCancel();
1206 void CLogDlg::CopyChangedSelectionToClipBoard()
1209 POSITION posLogList = m_LogList.GetFirstSelectedItemPosition();
1210 if (posLogList == nullptr)
1211 return; // nothing is selected, get out of here
1213 CString sPaths;
1215 // CGitRev* pLogEntry = reinterpret_cast<CGitRev* >(m_LogList.m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(pos)));
1216 // if (posLogList)
1218 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
1219 while (pos)
1221 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
1222 CTGitPath *path = (CTGitPath*)m_ChangedFileListCtrl.GetItemData(nItem);
1223 if(path)
1224 sPaths += path->GetGitPathString();
1225 sPaths += _T("\r\n");
1228 #if 0
1229 else
1231 // only one revision is selected in the log dialog top pane
1232 // but multiple items could be selected in the changed items list
1233 POSITION pos = m_ChangedFileListCtrl.GetFirstSelectedItemPosition();
1234 while (pos)
1236 int nItem = m_ChangedFileListCtrl.GetNextSelectedItem(pos);
1237 LogChangedPath * changedlogpath = pLogEntry->pArChangedPaths->SafeGetAt(nItem);
1239 if ((m_cHidePaths.GetState() & 0x0003)==BST_CHECKED)
1241 // some items are hidden! So find out which item the user really selected
1242 INT_PTR selRealIndex = -1;
1243 for (INT_PTR hiddenindex=0; hiddenindex<pLogEntry->pArChangedPaths->GetCount(); ++hiddenindex)
1245 if (pLogEntry->pArChangedPaths->SafeGetAt(hiddenindex)->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
1246 ++selRealIndex;
1247 if (selRealIndex == nItem)
1249 changedlogpath = pLogEntry->pArChangedPaths->SafeGetAt(hiddenindex);
1250 break;
1254 if (changedlogpath)
1256 sPaths += changedlogpath->sPath;
1257 sPaths += _T("\r\n");
1261 #endif
1262 sPaths.Trim();
1263 CStringUtils::WriteAsciiStringToClipboard(sPaths, GetSafeHwnd());
1267 void CLogDlg::OnContextMenu(CWnd* pWnd, CPoint point)
1269 // we have 4 separate context menus:
1270 // one for the branch label in the upper left
1271 // one for FROM date control
1272 // one shown on the log message list control,
1273 // one shown in the changed-files list control
1274 if (pWnd == GetDlgItem(IDC_STATIC_REF))
1276 CIconMenu popup;
1277 if (!popup.CreatePopupMenu())
1278 return;
1280 int cnt = 0;
1281 popup.AppendMenuIcon(++cnt, IDS_MENUREFBROWSE);
1282 popup.SetDefaultItem(cnt);
1283 popup.AppendMenuIcon(++cnt, _T("HEAD"));
1284 CGitHash fetchHead;
1285 g_Git.GetHash(fetchHead, g_Git.FixBranchName(_T("FETCH_HEAD")));
1286 popup.AppendMenuIcon(++cnt, _T("FETCH_HEAD"));
1287 popup.EnableMenuItem(cnt, fetchHead.IsEmpty());
1288 popup.AppendMenuIcon(++cnt, IDS_ALL);
1289 popup.EnableMenuItem(cnt, m_bFollowRenames);
1290 popup.AppendMenuIcon(++cnt, IDS_PROC_LOG_SELECT_LOCAL_BRANCHES);
1291 popup.EnableMenuItem(cnt, m_bFollowRenames);
1292 int offset = ++cnt;
1293 if (m_History.GetCount() > 0)
1295 popup.AppendMenu(MF_SEPARATOR, 0);
1296 for (size_t i = 0; i < m_History.GetCount(); ++i)
1298 CString entry = m_History.GetEntry(i);
1299 if (entry.GetLength() > 150)
1300 entry = entry.Left(150) + _T("...");
1301 popup.AppendMenuIcon(cnt++, entry);
1305 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
1306 if (cmd == 0)
1307 return;
1308 else if (cmd == 1)
1310 OnBnClickedBrowseRef();
1311 return;
1314 m_LogList.m_ShowMask &= ~(CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_LOCAL_BRANCHES);
1315 m_bAllBranch = BST_UNCHECKED;
1316 if (cmd == 2)
1318 SetRange(g_Git.GetCurrentBranch(true));
1320 else if (cmd == 3)
1322 SetRange(fetchHead.ToString());
1324 else if (cmd == 4)
1326 m_bAllBranch = BST_CHECKED;
1327 m_LogList.m_ShowMask |= CGit::LOG_INFO_ALL_BRANCH;
1329 else if (cmd == 5)
1331 m_bAllBranch = BST_INDETERMINATE;
1332 m_LogList.m_ShowMask |= CGit::LOG_INFO_LOCAL_BRANCHES;
1334 else if (cmd >= offset)
1336 SetRange(m_History.GetEntry(cmd - offset));
1337 m_History.AddEntry(m_LogList.m_sRange);
1338 m_History.Save();
1341 UpdateData(FALSE);
1343 OnRefresh();
1344 FillLogMessageCtrl(false);
1346 return;
1349 if (pWnd == GetDlgItem(IDC_DATEFROM))
1351 CIconMenu popup;
1352 if (!popup.CreatePopupMenu())
1353 return;
1355 int cnt = 0;
1357 popup.AppendMenuIcon(++cnt, IDS_NO_LIMIT);
1359 DWORD scale = (DWORD)CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\NumberOfLogsScale"), CFilterData::SHOW_NO_LIMIT);
1360 CString strScale;
1361 switch (scale)
1363 case CFilterData::SHOW_LAST_N_COMMITS:
1364 strScale.LoadString(IDS_LAST_N_COMMITS);
1365 break;
1366 case CFilterData::SHOW_LAST_N_YEARS:
1367 strScale.LoadString(IDS_LAST_N_YEARS);
1368 break;
1369 case CFilterData::SHOW_LAST_N_MONTHS:
1370 strScale.LoadString(IDS_LAST_N_MONTHS);
1371 break;
1372 case CFilterData::SHOW_LAST_N_WEEKS:
1373 strScale.LoadString(IDS_LAST_N_WEEKS);
1374 break;
1376 if (!strScale.IsEmpty() && m_LogList.m_Filter.m_NumberOfLogs > 0)
1378 popup.AppendMenu(MF_SEPARATOR, 0);
1379 CString number;
1380 number.Format(L"%ld", m_LogList.m_Filter.m_NumberOfLogs);
1381 CString item;
1382 item.Format(strScale, (LPCTSTR)number);
1383 popup.AppendMenuIcon(++cnt, item);
1386 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
1387 if (cmd <= 0)
1388 return;
1389 else if (cmd == 1)
1391 m_LogList.m_Filter.m_NumberOfLogsScale = CFilterData::SHOW_NO_LIMIT;
1392 // reset last selected date
1393 m_regLastSelectedFromDate.removeValue();
1395 else if (cmd == 2)
1396 m_LogList.m_Filter.m_NumberOfLogsScale = scale;
1398 UpdateData(FALSE);
1399 OnRefresh();
1400 FillLogMessageCtrl(false);
1402 return;
1405 int selCount = m_LogList.GetSelectedCount();
1406 if ((selCount == 1)&&(pWnd == GetDlgItem(IDC_MSGVIEW)))
1408 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1409 int selIndex = -1;
1410 if (pos)
1411 selIndex = m_LogList.GetNextSelectedItem(pos);
1413 GitRevLoglist* pRev = ((GitRevLoglist*)m_LogList.m_arShownList[selIndex]);
1415 if ((point.x == -1) && (point.y == -1))
1417 CRect rect;
1418 GetDlgItem(IDC_MSGVIEW)->GetClientRect(&rect);
1419 ClientToScreen(&rect);
1420 point = rect.CenterPoint();
1422 CString sMenuItemText;
1423 CIconMenu popup;
1424 if (popup.CreatePopupMenu())
1426 long start = -1, end = -1;
1427 auto pEdit = (CRichEditCtrl *)GetDlgItem(IDC_MSGVIEW);
1428 pEdit->GetSel(start, end);
1429 // add the 'default' entries
1430 popup.AppendMenuIcon(WM_COPY, IDS_SCIEDIT_COPY, IDI_COPYCLIP);
1431 if (start >= end)
1432 popup.EnableMenuItem(WM_COPY, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
1433 popup.AppendMenu(MF_SEPARATOR);
1434 sMenuItemText.LoadString(IDS_STATUSLIST_CONTEXT_COPYEXT);
1435 popup.AppendMenuIcon(EM_SETSEL, sMenuItemText, IDI_COPYCLIP);
1436 popup.AppendMenu(MF_SEPARATOR, NULL);
1437 sMenuItemText.LoadString(IDS_EDIT_NOTES);
1438 popup.AppendMenuIcon( CGitLogList::ID_EDITNOTE, sMenuItemText, IDI_EDIT);
1440 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
1441 switch (cmd)
1443 case 0:
1444 break; // no command selected
1445 case EM_SETSEL:
1447 pEdit->SetRedraw(FALSE);
1448 int oldLine = pEdit->GetFirstVisibleLine();
1449 pEdit->SetSel(0, -1);
1450 pEdit->Copy();
1451 pEdit->SetSel(start, end);
1452 int newLine = pEdit->GetFirstVisibleLine();
1453 pEdit->LineScroll(oldLine - newLine);
1454 pEdit->SetRedraw(TRUE);
1455 pEdit->RedrawWindow();
1457 break;
1458 case WM_COPY:
1459 ::SendMessage(GetDlgItem(IDC_MSGVIEW)->GetSafeHwnd(), cmd, 0, -1);
1460 break;
1461 case CGitLogList::ID_EDITNOTE:
1462 CAppUtils::EditNote(pRev);
1463 this->FillLogMessageCtrl(true);
1464 break;
1470 void CLogDlg::OnOK()
1472 // since the log dialog is also used to select revisions for other
1473 // dialogs, we have to do some work before closing this dialog
1474 if (GetFocus() != GetDlgItem(IDOK))
1475 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
1477 m_LogList.SafeTerminateAsyncDiffThread();
1478 if (this->IsThreadRunning())
1480 m_LogList.SafeTerminateThread();
1482 UpdateData();
1483 // check that one and only one row is selected
1484 if (m_LogList.GetSelectedCount() == 1)
1486 // get the selected row
1487 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1488 int selIndex = m_LogList.GetNextSelectedItem(pos);
1489 if (selIndex < m_LogList.m_arShownList.GetCount())
1491 // all ok, pick up the revision
1492 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.SafeGetAt(selIndex));
1493 // extract the hash
1494 m_sSelectedHash = pLogEntry->m_CommitHash;
1497 UpdateData(FALSE);
1498 SaveSplitterPos();
1499 __super::OnOK();
1501 #if 0
1502 if (!GetDlgItem(IDOK)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL))
1503 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
1505 CString temp;
1506 CString buttontext;
1507 GetDlgItemText(IDOK, buttontext);
1508 temp.LoadString(IDS_MSGBOX_CANCEL);
1509 if (temp.Compare(buttontext) != 0)
1510 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
1511 m_bCancelled = TRUE;
1512 m_selectedRevs.Clear();
1513 m_selectedRevsOneRange.Clear();
1514 if (m_pNotifyWindow)
1516 int selIndex = m_LogList.GetSelectionMark();
1517 if (selIndex >= 0)
1519 PLOGENTRYDATA pLogEntry = NULL;
1520 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1521 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(pos)));
1522 m_selectedRevs.AddRevision(pLogEntry->Rev);
1523 git_revnum_t lowerRev = pLogEntry->Rev;
1524 git_revnum_t higherRev = lowerRev;
1525 while (pos)
1527 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(pos)));
1528 git_revnum_t rev = pLogEntry->Rev;
1529 m_selectedRevs.AddRevision(pLogEntry->Rev);
1530 if (lowerRev > rev)
1531 lowerRev = rev;
1532 if (higherRev < rev)
1533 higherRev = rev;
1535 if (m_sFilterText.IsEmpty() && m_nSortColumn == 0 && IsSelectionContinuous())
1537 m_selectedRevsOneRange.AddRevRange(lowerRev, higherRev);
1539 BOOL bSentMessage = FALSE;
1540 if (m_LogList.GetSelectedCount() == 1)
1542 // if only one revision is selected, check if the path/url with which the dialog was started
1543 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
1544 // if it was copied, use the copy from revision as lowerRev
1545 if ((pLogEntry)&&(pLogEntry->pArChangedPaths)&&(lowerRev == higherRev))
1547 CString sUrl = m_path.GetGitPathString();
1548 if (!m_path.IsUrl())
1550 sUrl = GetURLFromPath(m_path);
1552 sUrl = sUrl.Mid(m_sRepositoryRoot.GetLength());
1553 for (int cp = 0; cp < pLogEntry->pArChangedPaths->GetCount(); ++cp)
1555 LogChangedPath * pData = pLogEntry->pArChangedPaths->SafeGetAt(cp);
1556 if (pData)
1558 if (sUrl.Compare(pData->sPath) == 0)
1560 if (!pData->sCopyFromPath.IsEmpty())
1562 lowerRev = pData->lCopyFromRev;
1563 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART), lowerRev);
1564 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND), higherRev);
1565 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
1566 bSentMessage = TRUE;
1573 if ( !bSentMessage )
1575 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTSTART | MERGE_REVSELECTMINUSONE), lowerRev);
1576 m_pNotifyWindow->SendMessage(WM_REVSELECTED, m_wParam & (MERGE_REVSELECTEND | MERGE_REVSELECTMINUSONE), higherRev);
1577 m_pNotifyWindow->SendMessage(WM_REVLIST, m_selectedRevs.GetCount(), (LPARAM)&m_selectedRevs);
1578 if (m_selectedRevsOneRange.GetCount())
1579 m_pNotifyWindow->SendMessage(WM_REVLISTONERANGE, 0, (LPARAM)&m_selectedRevsOneRange);
1583 UpdateData();
1584 CRegDWORD reg(_T("Software\\TortoiseGit\\ShowAllEntry"));
1585 SaveSplitterPos();
1586 #endif
1589 void CLogDlg::DoDiffFromLog(INT_PTR selIndex, GitRev* rev1, GitRev* rev2, bool /*blame*/, bool /*unified*/)
1591 DialogEnableWindow(IDOK, FALSE);
1592 // SetPromptApp(&theApp);
1593 theApp.DoWaitCursor(1);
1595 CString temppath;
1596 GetTempPath(temppath);
1598 CString file1;
1599 file1.Format(_T("%s%s_%s%s"),
1600 (LPCTSTR)temppath,
1601 (LPCTSTR)(*m_currentChangedArray)[selIndex].GetBaseFilename(),
1602 (LPCTSTR)rev1->m_CommitHash.ToString().Left(g_Git.GetShortHASHLength()),
1603 (LPCTSTR)(*m_currentChangedArray)[selIndex].GetFileExtension());
1605 CString file2;
1606 file2.Format(_T("%s\\%s_%s%s"),
1607 (LPCTSTR)temppath,
1608 (LPCTSTR)(*m_currentChangedArray)[selIndex].GetBaseFilename(),
1609 (LPCTSTR)rev2->m_CommitHash.ToString().Left(g_Git.GetShortHASHLength()),
1610 (LPCTSTR)(*m_currentChangedArray)[selIndex].GetFileExtension());
1612 CString cmd;
1613 CTGitPath &path = (CTGitPath &)(*m_currentChangedArray)[selIndex];
1615 if (g_Git.GetOneFile(rev1->m_CommitHash.ToString(), path, file1))
1617 CString out;
1618 out.Format(IDS_STATUSLIST_CHECKOUTFILEFAILED, (LPCTSTR)path.GetGitPathString(), (LPCTSTR)rev1->m_CommitHash.ToString(), (LPCTSTR)file1);
1619 CMessageBox::Show(nullptr, g_Git.GetGitLastErr(out, CGit::GIT_CMD_GETONEFILE), _T("TortoiseGit"), MB_OK);
1620 theApp.DoWaitCursor(-1);
1621 EnableOKButton();
1622 return;
1624 if (g_Git.GetOneFile(rev2->m_CommitHash.ToString(), path, file2))
1626 CString out;
1627 out.Format(IDS_STATUSLIST_CHECKOUTFILEFAILED, (LPCTSTR)path.GetGitPathString(), (LPCTSTR)rev2->m_CommitHash.ToString(), (LPCTSTR)file2);
1628 CMessageBox::Show(nullptr, g_Git.GetGitLastErr(out, CGit::GIT_CMD_GETONEFILE), _T("TortoiseGit"), MB_OK);
1629 theApp.DoWaitCursor(-1);
1630 EnableOKButton();
1631 return;
1634 CAppUtils::DiffFlags flags;
1635 CAppUtils::StartExtDiff(file1,file2,_T("A"),_T("B"),
1636 g_Git.CombinePath(path), g_Git.CombinePath(path),
1637 rev1->m_CommitHash.ToString(), rev2->m_CommitHash.ToString(),
1638 flags);
1640 theApp.DoWaitCursor(-1);
1641 EnableOKButton();
1644 void CLogDlg::OnPasteGitHash()
1646 if (!IsClipboardFormatAvailable(CF_TEXT))
1647 return;
1649 CClipboardHelper clipboardHelper;
1650 if (!clipboardHelper.Open(GetSafeHwnd()))
1651 return;
1653 HGLOBAL hClipboardData = GetClipboardData(CF_TEXT);
1654 if (!hClipboardData)
1655 return;
1657 char* pStr = (char*)GlobalLock(hClipboardData);
1658 CString str(pStr);
1659 GlobalUnlock(hClipboardData);
1660 if (str.IsEmpty())
1661 return;
1663 int pos = 0;
1664 if (LookLikeGitHash(str, pos))
1665 JumpToGitHash(str);
1668 void CLogDlg::JumpToGitHash(CString& hash)
1670 for (int i = 0; i < m_LogList.m_arShownList.GetCount(); ++i)
1672 GitRev* rev = (GitRev*)m_LogList.m_arShownList.SafeGetAt(i);
1673 if (!rev) continue;
1674 if (rev->m_CommitHash.ToString().Left(hash.GetLength()) != hash)
1675 continue;
1677 m_LogList.SetItemState(m_LogList.GetSelectionMark(), 0, LVIS_SELECTED | LVIS_FOCUSED);
1678 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
1679 while (pos)
1681 int index = m_LogList.GetNextSelectedItem(pos);
1682 if (index >= 0)
1683 m_LogList.SetItemState(index, 0, LVIS_SELECTED);
1685 m_LogList.EnsureVisible(i, FALSE);
1686 m_LogList.SetSelectionMark(i);
1687 m_LogList.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
1688 // refresh of selection needs to be queued instead of done immediately, to ensure hyperlinks in target selection are created
1689 PostMessage(WM_TGIT_REFRESH_SELECTION, 0, 0);
1690 return;
1693 CMessageBox::ShowCheck(GetSafeHwnd(), IDS_PROC_LOG_JUMPNOTFOUND, IDS_APPNAME, 1, IDI_INFORMATION, IDS_OKBUTTON, 0, 0, _T("NoJumpNotFoundWarning"), IDS_MSGBOX_DONOTSHOWAGAIN);
1696 BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)
1698 // Skip Ctrl-C when copying text out of the log message or search filter
1699 bool bSkipAccelerator = (pMsg->message == WM_KEYDOWN && (pMsg->wParam == 'C' || pMsg->wParam == VK_INSERT) && (GetFocus() == GetDlgItem(IDC_MSGVIEW) || GetFocus() == GetDlgItem(IDC_SEARCHEDIT) || GetFocus() == GetDlgItem(IDC_FILTER)) && GetKeyState(VK_CONTROL) & 0x8000);
1700 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
1702 if (GetFocus()==GetDlgItem(IDC_LOGLIST))
1704 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
1706 m_LogList.DiffSelectedRevWithPrevious();
1707 return TRUE;
1710 if (GetFocus() == GetDlgItem(IDC_SEARCHEDIT))
1712 KillTimer(LOGFILTER_TIMER);
1713 m_LogList.Refresh(FALSE);
1714 FillLogMessageCtrl(false);
1716 if (GetFocus() == GetDlgItem(IDC_FILTER))
1718 KillTimer(FILEFILTER_TIMER);
1719 FillLogMessageCtrl();
1720 return TRUE;
1723 else if (pMsg->message == WM_KEYDOWN && ((pMsg->wParam == 'V' && GetKeyState(VK_CONTROL) < 0) || (pMsg->wParam == VK_INSERT && GetKeyState(VK_SHIFT) < 0 && GetKeyState(VK_CONTROL) >= 0)) && GetKeyState(VK_MENU) >= 0)
1725 if (GetFocus() != GetDlgItem(IDC_SEARCHEDIT))
1727 OnPasteGitHash();
1728 return TRUE;
1731 else if (pMsg->message == WM_XBUTTONUP)
1733 bool select = (pMsg->wParam & MK_SHIFT) == 0;
1734 if (HIWORD(pMsg->wParam) & XBUTTON1)
1735 GoBackForward(select, false);
1736 if (HIWORD(pMsg->wParam) & XBUTTON2)
1737 GoBackForward(select, true);
1738 if (HIWORD(pMsg->wParam) & (XBUTTON1 | XBUTTON2))
1739 return TRUE;
1741 if (m_hAccel && !bSkipAccelerator)
1743 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
1744 if (ret)
1745 return TRUE;
1748 return __super::PreTranslateMessage(pMsg);
1752 BOOL CLogDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
1754 //if (this->IsThreadRunning())
1755 if(m_LogList.m_bNoDispUpdates)
1757 // only show the wait cursor over the list control
1758 if ((pWnd)&&
1759 ((pWnd == GetDlgItem(IDC_LOGLIST))||
1760 (pWnd == GetDlgItem(IDC_MSGVIEW))||
1761 (pWnd == GetDlgItem(IDC_LOGMSG))))
1763 HCURSOR hCur = LoadCursor(NULL, IDC_WAIT);
1764 SetCursor(hCur);
1765 return TRUE;
1768 if ((pWnd) && (pWnd == GetDlgItem(IDC_MSGVIEW)))
1769 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
1771 HCURSOR hCur = LoadCursor(NULL, IDC_ARROW);
1772 SetCursor(hCur);
1773 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
1776 void CLogDlg::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)
1778 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
1779 *pResult = 0;
1780 //if (this->IsThreadRunning())
1781 if(m_LogList.m_bNoDispUpdates)
1782 return;
1783 if (pNMLV->iItem >= 0)
1785 if (!m_LogList.m_highlight.IsEmpty())
1787 m_LogList.m_highlight.Empty();
1788 m_LogList.Invalidate();
1790 this->m_LogList.m_nSearchIndex = pNMLV->iItem;
1791 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.SafeGetAt(pNMLV->iItem));
1792 if (pLogEntry == nullptr)
1793 return;
1794 m_LogList.m_lastSelectedHash = pLogEntry->m_CommitHash;
1795 if (pNMLV->iSubItem != 0)
1796 return;
1797 if ((pNMLV->iItem == m_LogList.m_arShownList.GetCount()))
1799 // remove the selected state
1800 if (pNMLV->uChanged & LVIF_STATE)
1802 m_LogList.SetItemState(pNMLV->iItem, 0, LVIS_SELECTED);
1803 FillLogMessageCtrl();
1804 UpdateData(FALSE);
1805 UpdateLogInfoLabel();
1807 return;
1809 if (pNMLV->uChanged & LVIF_STATE)
1811 if ((pNMLV->uNewState & LVIS_SELECTED) && !m_bNavigatingWithSelect)
1813 m_LogList.m_selectionHistory.Add(m_LogList.m_lastSelectedHash);
1814 m_LogList.m_lastSelectedHash = pLogEntry->m_CommitHash;
1816 FillLogMessageCtrl();
1817 UpdateData(FALSE);
1820 else
1822 m_LogList.m_lastSelectedHash.Empty();
1823 FillLogMessageCtrl();
1824 UpdateData(FALSE);
1826 EnableOKButton();
1827 UpdateLogInfoLabel();
1830 void CLogDlg::OnLvnItemchangedLogmsg(NMHDR * /*pNMHDR*/, LRESULT * /*pResult*/)
1832 UpdateLogInfoLabel();
1835 void CLogDlg::OnEnLinkMsgview(NMHDR *pNMHDR, LRESULT *pResult)
1837 ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);
1838 if ((pEnLink->msg == WM_LBUTTONUP) || (pEnLink->msg == WM_SETCURSOR))
1840 CString url, msg;
1841 GetDlgItemText(IDC_MSGVIEW, msg);
1842 msg.Replace(_T("\r\n"), _T("\n"));
1843 url = msg.Mid(pEnLink->chrg.cpMin, pEnLink->chrg.cpMax-pEnLink->chrg.cpMin);
1844 auto findResult = m_LogList.m_ProjectProperties.FindBugIDPositions(msg);
1845 if (std::find_if(findResult.begin(), findResult.end(),
1846 [=] (const CHARRANGE &cr) -> bool { return cr.cpMin == pEnLink->chrg.cpMin && cr.cpMax == pEnLink->chrg.cpMax; }
1847 ) != findResult.end())
1849 url = m_LogList.m_ProjectProperties.GetBugIDUrl(url);
1850 url = GetAbsoluteUrlFromRelativeUrl(url);
1852 if (::PathIsURL(url))
1854 if (pEnLink->msg == WM_LBUTTONUP)
1855 ShellExecute(this->m_hWnd, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
1856 else
1858 static RECT prevRect = { 0 };
1859 CWnd * pMsgView = GetDlgItem(IDC_MSGVIEW);
1860 if (pMsgView)
1862 RECT rc;
1863 POINTL pt;
1864 pMsgView->SendMessage(EM_POSFROMCHAR, (WPARAM)&pt, pEnLink->chrg.cpMin);
1865 rc.left = pt.x;
1866 rc.top = pt.y;
1867 pMsgView->SendMessage(EM_POSFROMCHAR, (WPARAM)&pt, pEnLink->chrg.cpMax);
1868 rc.right = pt.x;
1869 rc.bottom = pt.y + 12;
1870 if ((prevRect.left != rc.left) || (prevRect.top != rc.top))
1872 m_tooltips.DelTool(pMsgView, 1);
1873 m_tooltips.AddTool(pMsgView, url, &rc, 1);
1874 prevRect = rc;
1879 else if(pEnLink->msg == WM_LBUTTONUP)
1881 int pos = 0;
1882 if (LookLikeGitHash(url, pos))
1883 JumpToGitHash(url);
1886 *pResult = 0;
1889 void CLogDlg::OnBnClickedStatbutton()
1891 if (this->IsThreadRunning())
1892 return;
1893 if (m_LogList.m_arShownList.IsEmpty() || m_LogList.m_arShownList.GetCount() == 1 && m_LogList.m_bShowWC)
1894 return; // nothing or just the working copy changes are shown, so no statistics.
1895 // the statistics dialog expects the log entries to be sorted by date
1896 SortByColumn(3, false);
1898 CStatGraphDlg dlg;
1899 m_LogList.RecalculateShownList(&dlg.m_ShowList);
1901 dlg.m_path = m_orgPath;
1902 dlg.DoModal();
1903 // restore the previous sorting
1904 SortByColumn(m_nSortColumn, m_bAscending);
1905 OnTimer(LOGFILTER_TIMER);
1908 void CLogDlg::MoveToSameTop(CWnd *pWndRef, CWnd *pWndTarget)
1910 CRect rcWndPicAuthor, rcWndMsgView;
1911 pWndRef->GetWindowRect(rcWndMsgView);
1912 ScreenToClient(rcWndMsgView);
1913 pWndTarget->GetWindowRect(rcWndPicAuthor);
1914 ScreenToClient(rcWndPicAuthor);
1915 int diff = rcWndMsgView.top - rcWndPicAuthor.top;
1916 rcWndPicAuthor.top += diff;
1917 rcWndPicAuthor.bottom += diff;
1918 pWndTarget->MoveWindow(rcWndPicAuthor);
1921 void CLogDlg::DoSizeV1(int delta)
1923 RemoveMainAnchors();
1925 // first, reduce the middle section to a minimum.
1926 // if that is not sufficient, minimize the lower section
1928 CRect changeListViewRect;
1929 m_ChangedFileListCtrl.GetClientRect(changeListViewRect);
1930 CRect messageViewRect;
1931 GetDlgItem(IDC_MSGVIEW)->GetClientRect(messageViewRect);
1933 int messageViewDelta = max(-delta, 20 - messageViewRect.Height());
1934 int changeFileListDelta = -delta - messageViewDelta;
1936 // set new sizes & positions
1937 CSplitterControl::ChangeHeight(&m_LogList, delta, CW_TOPALIGN);
1938 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), messageViewDelta, CW_TOPALIGN);
1939 CSplitterControl::ChangePos(GetDlgItem(IDC_MSGVIEW), 0, delta);
1940 MoveToSameTop(GetDlgItem(IDC_MSGVIEW), GetDlgItem(IDC_PIC_AUTHOR));
1941 CSplitterControl::ChangePos(GetDlgItem(IDC_SPLITTERBOTTOM), 0, -changeFileListDelta);
1942 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, changeFileListDelta, CW_BOTTOMALIGN);
1944 AddMainAnchors();
1945 ArrangeLayout();
1946 AdjustMinSize();
1947 SetSplitterRange();
1948 m_LogList.Invalidate();
1949 m_ChangedFileListCtrl.Invalidate();
1950 GetDlgItem(IDC_MSGVIEW)->Invalidate();
1951 m_gravatar.Invalidate();
1954 void CLogDlg::DoSizeV2(int delta)
1956 RemoveMainAnchors();
1958 // first, reduce the middle section to a minimum.
1959 // if that is not sufficient, minimize the top section
1961 CRect logViewRect;
1962 m_LogList.GetClientRect(logViewRect);
1963 CRect messageViewRect;
1964 GetDlgItem(IDC_MSGVIEW)->GetClientRect(messageViewRect);
1966 int messageViewDelta = max(delta, 20 - messageViewRect.Height());
1967 int logListDelta = delta - messageViewDelta;
1969 // set new sizes & positions
1970 CSplitterControl::ChangeHeight(&m_LogList, logListDelta, CW_TOPALIGN);
1971 CSplitterControl::ChangePos(GetDlgItem(IDC_SPLITTERTOP), 0, logListDelta);
1973 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW), messageViewDelta, CW_TOPALIGN);
1974 CSplitterControl::ChangePos(GetDlgItem(IDC_MSGVIEW), 0, logListDelta);
1975 MoveToSameTop(GetDlgItem(IDC_MSGVIEW), GetDlgItem(IDC_PIC_AUTHOR));
1977 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl, -delta, CW_BOTTOMALIGN);
1979 AddMainAnchors();
1980 ArrangeLayout();
1981 AdjustMinSize();
1982 SetSplitterRange();
1983 GetDlgItem(IDC_MSGVIEW)->Invalidate();
1984 m_ChangedFileListCtrl.Invalidate();
1985 m_gravatar.Invalidate();
1988 void CLogDlg::AddMainAnchors()
1990 AddAnchor(IDC_STATIC_REF, TOP_LEFT);
1991 AddAnchor(IDC_FROMLABEL, TOP_LEFT);
1992 AddAnchor(IDC_DATEFROM, TOP_LEFT);
1993 AddAnchor(IDC_TOLABEL, TOP_LEFT);
1994 AddAnchor(IDC_DATETO, TOP_LEFT);
1996 AddAnchor(IDC_SEARCHEDIT, TOP_LEFT, TOP_RIGHT);
1997 AddAnchor(IDC_LOG_JUMPTYPE, TOP_RIGHT);
1998 AddAnchor(IDC_LOG_JUMPUP, TOP_RIGHT);
1999 AddAnchor(IDC_LOG_JUMPDOWN, TOP_RIGHT);
2001 AddAnchor(IDC_LOGLIST, TOP_LEFT, MIDDLE_RIGHT);
2002 AddAnchor(IDC_SPLITTERTOP, MIDDLE_LEFT, MIDDLE_RIGHT);
2003 AddAnchor(IDC_MSGVIEW, MIDDLE_LEFT, MIDDLE_RIGHT); // keep in sync with ShowGravatar()
2004 AddAnchor(IDC_PIC_AUTHOR, MIDDLE_RIGHT);
2005 AddAnchor(IDC_SPLITTERBOTTOM, MIDDLE_LEFT, MIDDLE_RIGHT);
2006 AddAnchor(IDC_LOGMSG, MIDDLE_LEFT, BOTTOM_RIGHT);
2008 AddAnchor(IDC_LOGINFO, BOTTOM_LEFT, BOTTOM_RIGHT);
2009 AddAnchor(IDC_WALKBEHAVIOUR, BOTTOM_LEFT);
2010 AddAnchor(IDC_VIEW, BOTTOM_LEFT);
2011 AddAnchor(IDC_LOG_ALLBRANCH, BOTTOM_LEFT);
2012 AddAnchor(IDC_FILTER, BOTTOM_LEFT, BOTTOM_RIGHT);
2013 AddAnchor(IDC_WHOLE_PROJECT, BOTTOM_LEFT);
2014 AddAnchor(IDC_REFRESH, BOTTOM_LEFT);
2015 AddAnchor(IDC_STATBUTTON, BOTTOM_LEFT);
2016 AddAnchor(IDC_PROGRESS, BOTTOM_LEFT, BOTTOM_RIGHT);
2017 AddAnchor(IDOK, BOTTOM_RIGHT);
2018 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
2019 AddAnchor(IDHELP, BOTTOM_RIGHT);
2022 void CLogDlg::RemoveMainAnchors()
2024 RemoveAnchor(IDC_STATIC_REF);
2025 RemoveAnchor(IDC_FROMLABEL);
2026 RemoveAnchor(IDC_DATEFROM);
2027 RemoveAnchor(IDC_TOLABEL);
2028 RemoveAnchor(IDC_DATETO);
2030 RemoveAnchor(IDC_SEARCHEDIT);
2031 RemoveAnchor(IDC_LOG_JUMPTYPE);
2032 RemoveAnchor(IDC_LOG_JUMPUP);
2033 RemoveAnchor(IDC_LOG_JUMPDOWN);
2035 RemoveAnchor(IDC_LOGLIST);
2036 RemoveAnchor(IDC_SPLITTERTOP);
2037 RemoveAnchor(IDC_MSGVIEW);
2038 RemoveAnchor(IDC_PIC_AUTHOR);
2039 RemoveAnchor(IDC_SPLITTERBOTTOM);
2040 RemoveAnchor(IDC_LOGMSG);
2042 RemoveAnchor(IDC_LOGINFO);
2043 RemoveAnchor(IDC_WALKBEHAVIOUR);
2044 RemoveAnchor(IDC_VIEW);
2045 RemoveAnchor(IDC_LOG_ALLBRANCH);
2046 RemoveAnchor(IDC_FILTER);
2047 RemoveAnchor(IDC_WHOLE_PROJECT);
2048 RemoveAnchor(IDC_REFRESH);
2049 RemoveAnchor(IDC_STATBUTTON);
2050 RemoveAnchor(IDC_PROGRESS);
2051 RemoveAnchor(IDOK);
2052 RemoveAnchor(IDCANCEL);
2053 RemoveAnchor(IDHELP);
2056 void CLogDlg::AdjustMinSize()
2058 // adjust the minimum size of the dialog to prevent the resizing from
2059 // moving the list control too far down.
2060 CRect rcChgListView;
2061 m_ChangedFileListCtrl.GetClientRect(rcChgListView);
2062 CRect rcLogList;
2063 m_LogList.GetClientRect(rcLogList);
2064 CRect rcLogMsg;
2065 GetDlgItem(IDC_MSGVIEW)->GetClientRect(rcLogMsg);
2067 SetMinTrackSize(CSize(m_DlgOrigRect.Width(),
2068 m_DlgOrigRect.Height()-m_ChgOrigRect.Height()-m_LogListOrigRect.Height()-m_MsgViewOrigRect.Height()
2069 + rcLogMsg.Height() + abs(rcChgListView.Height() - rcLogList.Height()) + 60));
2072 LRESULT CLogDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
2074 switch (message) {
2075 case WM_NOTIFY:
2076 if (wParam == IDC_SPLITTERTOP)
2078 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
2079 DoSizeV1(pHdr->delta);
2081 else if (wParam == IDC_SPLITTERBOTTOM)
2083 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
2084 DoSizeV2(pHdr->delta);
2086 break;
2089 return CResizableDialog::DefWindowProc(message, wParam, lParam);
2092 void CLogDlg::SetSplitterRange()
2094 if ((m_LogList)&&(m_ChangedFileListCtrl))
2096 CRect rcTop;
2097 m_LogList.GetWindowRect(rcTop);
2098 ScreenToClient(rcTop);
2099 CRect rcBottom;
2100 m_ChangedFileListCtrl.GetWindowRect(rcBottom);
2101 ScreenToClient(rcBottom);
2102 m_wndSplitter1.SetRange(rcTop.top + 20, rcBottom.bottom - 50);
2103 m_wndSplitter2.SetRange(rcTop.top + 50, rcBottom.bottom - 20);
2107 void CLogDlg::OnEnscrollMsgview()
2109 m_tooltips.DelTool(GetDlgItem(IDC_MSGVIEW), 1);
2112 LRESULT CLogDlg::OnClickedInfoIcon(WPARAM wParam, LPARAM lParam)
2114 if ((HWND)wParam == m_cFileFilter.GetSafeHwnd())
2115 return 0;
2117 // FIXME: x64 version would get this function called with unexpected parameters.
2118 if (!lParam)
2119 return 0;
2121 RECT * rect = (LPRECT)lParam;
2122 CPoint point;
2123 CString temp;
2124 point = CPoint(rect->left, rect->bottom);
2125 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | ((m_LogList.m_SelectedFilters & x) ? MF_CHECKED : MF_UNCHECKED))
2126 CMenu popup;
2127 if (popup.CreatePopupMenu())
2129 temp.LoadString(IDS_LOG_FILTER_SUBJECT);
2130 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_SUBJECT), LOGFILTER_SUBJECT, temp);
2132 temp.LoadString(IDS_LOG_FILTER_MESSAGES);
2133 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES), LOGFILTER_MESSAGES, temp);
2135 temp.LoadString(IDS_LOG_FILTER_PATHS);
2136 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS), LOGFILTER_PATHS, temp);
2138 temp.LoadString(IDS_LOG_FILTER_AUTHORS);
2139 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS), LOGFILTER_AUTHORS, temp);
2141 temp.LoadString(IDS_LOG_FILTER_EMAILS);
2142 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_EMAILS), LOGFILTER_EMAILS, temp);
2144 temp.LoadString(IDS_LOG_FILTER_REVS);
2145 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS), LOGFILTER_REVS, temp);
2147 temp.LoadString(IDS_LOG_FILTER_REFNAME);
2148 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_REFNAME), LOGFILTER_REFNAME, temp);
2150 if (m_LogList.m_bShowBugtraqColumn == TRUE) {
2151 temp.LoadString(IDS_LOG_FILTER_BUGIDS);
2152 popup.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID), LOGFILTER_BUGID, temp);
2155 popup.AppendMenu(MF_SEPARATOR, NULL);
2157 temp.LoadString(IDS_LOG_FILTER_TOGGLE);
2158 popup.AppendMenu(MF_STRING | MF_ENABLED, LOGFILTER_TOGGLE, temp);
2160 temp.LoadString(IDS_ALL);
2161 popup.AppendMenu(MF_STRING | MF_ENABLED, LOGFILTER_ALL, temp);
2163 popup.AppendMenu(MF_SEPARATOR, NULL);
2165 temp.LoadString(IDS_LOG_FILTER_REGEX);
2166 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterWithRegex ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_REGEX, temp);
2168 temp.LoadString(IDS_LOG_FILTER_CASESENSITIVE);
2169 popup.AppendMenu(MF_STRING | MF_ENABLED | (m_bFilterCaseSensitively ? MF_CHECKED : MF_UNCHECKED), LOGFILTER_CASE, temp);
2171 m_tooltips.Pop();
2172 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
2173 if (selection != 0)
2176 if (selection == LOGFILTER_REGEX)
2178 m_bFilterWithRegex = !m_bFilterWithRegex;
2179 CRegDWORD b(_T("Software\\TortoiseGit\\UseRegexFilter"), FALSE);
2180 b = m_bFilterWithRegex;
2181 m_LogList.m_bFilterWithRegex = m_bFilterWithRegex;
2182 SetFilterCueText();
2183 CheckRegexpTooltip();
2185 else if (selection == LOGFILTER_CASE)
2187 m_bFilterCaseSensitively = !m_bFilterCaseSensitively;
2188 CRegDWORD b(_T("Software\\TortoiseGit\\FilterCaseSensitively"), FALSE);
2189 b = m_bFilterCaseSensitively;
2190 m_LogList.m_bFilterCaseSensitively = m_bFilterCaseSensitively;
2192 else if (selection == LOGFILTER_TOGGLE)
2194 m_LogList.m_SelectedFilters = (~m_LogList.m_SelectedFilters) & LOGFILTER_ALL;
2195 SetFilterCueText();
2197 else if (selection == LOGFILTER_ALL)
2199 m_LogList.m_SelectedFilters = selection;
2200 SetFilterCueText();
2202 else
2204 m_LogList.m_SelectedFilters ^= selection;
2205 SetFilterCueText();
2207 CRegDWORD(_T("Software\\TortoiseGit\\SelectedLogFilters")) = m_LogList.m_SelectedFilters;
2208 // Reload only if a search text is entered
2209 if (m_LogList.HasFilterText())
2210 SetTimer(LOGFILTER_TIMER, 1000, NULL);
2213 return 0L;
2216 LRESULT CLogDlg::OnClickedCancelFilter(WPARAM wParam, LPARAM /*lParam*/)
2218 if ((HWND)wParam == m_cFileFilter.GetSafeHwnd())
2220 KillTimer(FILEFILTER_TIMER);
2222 FillLogMessageCtrl();
2223 return 0L;
2226 KillTimer(LOGFILTER_TIMER);
2228 m_LogList.m_sFilterText.Empty();
2229 UpdateData(FALSE);
2230 theApp.DoWaitCursor(1);
2231 CStoreSelection storeselection(this);
2232 FillLogMessageCtrl(false);
2234 m_LogList.RemoveFilter();
2236 Refresh();
2238 theApp.DoWaitCursor(-1);
2239 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
2240 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
2241 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
2242 UpdateLogInfoLabel();
2244 return 0L;
2248 void CLogDlg::SetFilterCueText()
2250 CString temp(MAKEINTRESOURCE(IDS_LOG_FILTER_BY));
2251 temp += _T(" ");
2253 if (m_LogList.m_SelectedFilters & LOGFILTER_SUBJECT)
2255 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_SUBJECT));
2258 if (m_LogList.m_SelectedFilters & LOGFILTER_MESSAGES)
2260 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
2261 temp += _T(", ");
2262 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_MESSAGES));
2265 if (m_LogList.m_SelectedFilters & LOGFILTER_PATHS)
2267 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
2268 temp += _T(", ");
2269 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_PATHS));
2272 if (m_LogList.m_SelectedFilters & LOGFILTER_AUTHORS)
2274 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
2275 temp += _T(", ");
2276 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_AUTHORS));
2279 if (m_LogList.m_SelectedFilters & LOGFILTER_EMAILS)
2281 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
2282 temp += _T(", ");
2283 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_EMAILS));
2286 if (m_LogList.m_SelectedFilters & LOGFILTER_REVS)
2288 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
2289 temp += _T(", ");
2290 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_REVS));
2293 if (m_LogList.m_SelectedFilters & LOGFILTER_REFNAME)
2295 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
2296 temp += _T(", ");
2297 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_REFNAME));
2300 if (m_LogList.m_bShowBugtraqColumn && m_LogList.m_SelectedFilters & LOGFILTER_BUGID)
2302 if (temp.ReverseFind(_T(' ')) != temp.GetLength() - 1)
2303 temp += _T(", ");
2304 temp += CString(MAKEINTRESOURCE(IDS_LOG_FILTER_BUGIDS));
2307 // to make the cue banner text appear more to the right of the edit control
2308 temp = _T(" ")+temp;
2309 m_cFilter.SetCueBanner(temp.TrimRight());
2312 bool CLogDlg::Validate(LPCTSTR string)
2314 if (!m_bFilterWithRegex)
2315 return true;
2316 std::tr1::wregex pat;
2317 return m_LogList.ValidateRegexp(string, pat, false);
2320 void CLogDlg::OnEnChangeFileFilter()
2322 SetTimer(FILEFILTER_TIMER, 1000, NULL);
2325 void CLogDlg::OnTimer(UINT_PTR nIDEvent)
2327 if (nIDEvent == LOGFTIME_TIMER)
2329 KillTimer(LOGFTIME_TIMER);
2330 m_LogList.Refresh(FALSE);
2331 FillLogMessageCtrl(false);
2333 else if (nIDEvent == LOG_FILLPATCHVTIMER)
2335 FillPatchView();
2337 else if (nIDEvent == LOGFILTER_TIMER)
2339 KillTimer(LOGFILTER_TIMER);
2340 m_LogList.Refresh(FALSE);
2341 FillLogMessageCtrl(false);
2343 #if 0
2344 /* we will use git built-in grep to filter log */
2345 if (this->IsThreadRunning())
2347 // thread still running! So just restart the timer.
2348 SetTimer(LOGFILTER_TIMER, 1000, NULL);
2349 return;
2351 CWnd * focusWnd = GetFocus();
2352 bool bSetFocusToFilterControl = ((focusWnd != GetDlgItem(IDC_DATEFROM))&&(focusWnd != GetDlgItem(IDC_DATETO))
2353 && (focusWnd != GetDlgItem(IDC_LOGLIST)));
2354 if (m_LogList.m_sFilterText.IsEmpty())
2356 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
2357 // do not return here!
2358 // we also need to run the filter if the filter text is empty:
2359 // 1. to clear an existing filter
2360 // 2. to rebuild the m_arShownList after sorting
2362 theApp.DoWaitCursor(1);
2363 CStoreSelection storeselection(this);
2364 KillTimer(LOGFILTER_TIMER);
2365 FillLogMessageCtrl(false);
2367 // now start filter the log list
2368 m_LogList.StartFilter();
2370 if ( m_LogList.GetItemCount()==1 )
2372 m_LogList.SetSelectionMark(0);
2373 m_LogList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
2375 theApp.DoWaitCursor(-1);
2376 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
2377 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
2378 if (bSetFocusToFilterControl)
2379 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
2380 UpdateLogInfoLabel();
2381 #endif
2382 } // if (nIDEvent == LOGFILTER_TIMER)
2383 else if (nIDEvent == LOG_HEADER_ORDER_TIMER)
2385 KillTimer(LOG_HEADER_ORDER_TIMER);
2386 CLogOrdering orderDlg;
2387 if (orderDlg.DoModal() == IDOK)
2388 Refresh();
2390 else if (nIDEvent == FILEFILTER_TIMER)
2392 KillTimer(FILEFILTER_TIMER);
2393 FillLogMessageCtrl();
2395 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty() || m_LogList.m_arShownList.GetCount() == 1 && m_LogList.m_bShowWC))));
2396 __super::OnTimer(nIDEvent);
2399 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR * /*pNMHDR*/, LRESULT *pResult)
2403 CTime _time;
2404 m_DateTo.GetTime(_time);
2406 CTime fromTime;
2407 m_DateFrom.GetTime(fromTime);
2408 if (_time < fromTime)
2410 _time = fromTime;
2411 m_DateTo.SetTime(&_time);
2414 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 23, 59, 59);
2415 if (time.GetTime() != m_LogList.m_Filter.m_To)
2417 m_LogList.m_Filter.m_To = (DWORD)time.GetTime();
2418 SetTimer(LOGFTIME_TIMER, 10, NULL);
2421 catch (...)
2423 CMessageBox::Show(NULL,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);
2426 *pResult = 0;
2429 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
2434 CTime _time;
2435 m_DateFrom.GetTime(_time);
2437 CTime toTime;
2438 m_DateTo.GetTime(toTime);
2439 if (_time > toTime)
2441 _time = toTime;
2442 m_DateFrom.SetTime(&_time);
2445 CTime time(_time.GetYear(), _time.GetMonth(), _time.GetDay(), 0, 0, 0);
2446 if (time.GetTime() != m_LogList.m_Filter.m_From)
2448 m_LogList.m_Filter.m_From = (DWORD)time.GetTime();
2449 m_LogList.m_Filter.m_NumberOfLogsScale = CFilterData::SHOW_LAST_SEL_DATE;
2451 if (CFilterData::SHOW_LAST_SEL_DATE == (DWORD)CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\NumberOfLogsScale"), CFilterData::SHOW_NO_LIMIT))
2452 m_regLastSelectedFromDate = time.Format(L"%Y-%m-%d");
2454 SetTimer(LOGFTIME_TIMER, 10, NULL);
2457 catch (...)
2459 CMessageBox::Show(NULL,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);
2462 *pResult = 0;
2465 void CLogDlg::OnCbnSelchangeJumpType()
2467 // reserved for future use
2470 void CLogDlg::OnBnClickedJumpUp()
2472 int sel = m_JumpType.GetCurSel();
2473 if (sel < 0) return;
2474 JumpType jumpType = (JumpType)sel;
2476 if (jumpType == JumpType_History)
2478 GoBack();
2479 return;
2482 CString strValue;
2483 CGitHash hashValue;
2484 int index = -1;
2485 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
2486 if (pos)
2488 index = m_LogList.GetNextSelectedItem(pos);
2489 if (index == 0) return;
2491 GitRev* data = (GitRev*)m_LogList.m_arShownList.SafeGetAt(index);
2492 if (jumpType == JumpType_AuthorEmail)
2493 strValue = data->GetAuthorEmail();
2494 else if (jumpType == JumpType_CommitterEmail)
2495 strValue = data->GetCommitterEmail();
2496 else if (jumpType == JumpType_Parent1)
2497 hashValue = data->m_CommitHash;
2498 else if (jumpType == JumpType_Parent2)
2499 hashValue = data->m_CommitHash;
2500 else if (jumpType == JumpType_TagFF)
2501 hashValue = data->m_CommitHash;
2502 else if (jumpType == JumpType_BranchFF)
2503 hashValue = data->m_CommitHash;
2505 m_LogList.SetItemState(index, 0, LVIS_SELECTED);
2507 else
2508 return;
2510 while (pos)
2512 index = m_LogList.GetNextSelectedItem(pos);
2513 m_LogList.SetItemState(index, 0, LVIS_SELECTED);
2515 m_LogList.SetSelectionMark(-1);
2517 for (int i = index - 1; i >= 0; i--)
2519 bool found = false;
2520 GitRev* data = (GitRev*)m_LogList.m_arShownList.SafeGetAt(i);
2521 if (jumpType == JumpType_AuthorEmail)
2522 found = strValue == data->GetAuthorEmail();
2523 else if (jumpType == JumpType_CommitterEmail)
2524 found = strValue == data->GetCommitterEmail();
2525 else if (jumpType == JumpType_MergePoint)
2526 found = data->ParentsCount() > 1;
2527 else if (jumpType == JumpType_Parent1)
2529 if (data->m_ParentHash.size() > 0)
2530 found = data->m_ParentHash[0] == hashValue;
2532 else if (jumpType == JumpType_Parent2)
2534 if (data->m_ParentHash.size() > 1)
2535 found = data->m_ParentHash[1] == hashValue;
2537 else if (jumpType == JumpType_Tag || jumpType == JumpType_TagFF)
2539 STRING_VECTOR refList = m_LogList.m_HashMap[data->m_CommitHash];
2540 for (size_t j = 0; j < refList.size(); ++j)
2542 if (refList[j].Left(10) == _T("refs/tags/"))
2544 found = true;
2545 break;
2549 if (found && jumpType == JumpType_TagFF)
2550 found = g_Git.IsFastForward(hashValue, data->m_CommitHash);
2552 else if (jumpType == JumpType_Branch || jumpType == JumpType_BranchFF)
2554 STRING_VECTOR refList = m_LogList.m_HashMap[data->m_CommitHash];
2555 for (size_t j = 0; j < refList.size(); ++j)
2557 if (refList[j].Left(11) == _T("refs/heads/") || refList[j].Left(13) == _T("refs/remotes/"))
2559 found = true;
2560 break;
2564 if (found && jumpType == JumpType_BranchFF)
2565 found = g_Git.IsFastForward(hashValue, data->m_CommitHash);
2568 if (found)
2570 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
2571 m_LogList.EnsureVisible(i, FALSE);
2572 m_LogList.SetSelectionMark(i);
2573 return;
2577 CMessageBox::ShowCheck(GetSafeHwnd(), IDS_PROC_LOG_JUMPNOTFOUND, IDS_APPNAME, 1, IDI_INFORMATION, IDS_OKBUTTON, 0, 0, _T("NoJumpNotFoundWarning"), IDS_MSGBOX_DONOTSHOWAGAIN);
2580 void CLogDlg::OnBnClickedJumpDown()
2582 int jumpType = m_JumpType.GetCurSel();
2583 if (jumpType < 0) return;
2585 if (jumpType == JumpType_History)
2587 GoForward();
2588 return;
2591 CString strValue;
2592 CGitHash hashValue;
2593 int index = -1;
2594 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
2595 if (pos)
2597 index = m_LogList.GetNextSelectedItem(pos);
2598 if (index == 0) return;
2600 GitRev* data = (GitRev*)m_LogList.m_arShownList.SafeGetAt(index);
2601 if (jumpType == JumpType_AuthorEmail)
2602 strValue = data->GetAuthorEmail();
2603 else if (jumpType == JumpType_CommitterEmail)
2604 strValue = data->GetCommitterEmail();
2605 else if (jumpType == JumpType_Parent1)
2607 if (data->m_ParentHash.size() > 0)
2608 hashValue = data->m_ParentHash.at(0);
2609 else
2610 return;
2612 else if (jumpType == JumpType_Parent2)
2614 if (data->m_ParentHash.size() > 1)
2615 hashValue = data->m_ParentHash.at(1);
2616 else
2617 return;
2619 else if (jumpType == JumpType_TagFF)
2620 hashValue = data->m_CommitHash;
2621 else if (jumpType == JumpType_BranchFF)
2622 hashValue = data->m_CommitHash;
2624 m_LogList.SetItemState(index, 0, LVIS_SELECTED);
2626 else
2627 return;
2629 while (pos)
2631 index = m_LogList.GetNextSelectedItem(pos);
2632 m_LogList.SetItemState(index, 0, LVIS_SELECTED);
2634 m_LogList.SetSelectionMark(-1);
2636 for (int i = index + 1; i < m_LogList.GetItemCount(); ++i)
2638 bool found = false;
2639 GitRev* data = (GitRev*)m_LogList.m_arShownList.SafeGetAt(i);
2640 if (jumpType == JumpType_AuthorEmail)
2641 found = strValue == data->GetAuthorEmail();
2642 else if (jumpType == JumpType_CommitterEmail)
2643 found = strValue == data->GetCommitterEmail();
2644 else if (jumpType == JumpType_MergePoint)
2645 found = data->ParentsCount() > 1;
2646 else if (jumpType == JumpType_Parent1)
2647 found = data->m_CommitHash == hashValue;
2648 else if (jumpType == JumpType_Parent2)
2649 found = data->m_CommitHash == hashValue;
2650 else if (jumpType == JumpType_Tag || jumpType == JumpType_TagFF)
2652 STRING_VECTOR refList = m_LogList.m_HashMap[data->m_CommitHash];
2653 for (size_t j = 0; j < refList.size(); ++j)
2655 if (refList[j].Left(10) == _T("refs/tags/"))
2657 found = true;
2658 break;
2662 if (found && jumpType == JumpType_TagFF)
2663 found = g_Git.IsFastForward(data->m_CommitHash, hashValue);
2665 else if (jumpType == JumpType_Branch || jumpType == JumpType_BranchFF)
2667 STRING_VECTOR refList = m_LogList.m_HashMap[data->m_CommitHash];
2668 for (size_t j = 0; j < refList.size(); ++j)
2670 if (refList[j].Left(11) == _T("refs/heads/") || refList[j].Left(13) == _T("refs/remotes/"))
2672 found = true;
2673 break;
2677 if (found && jumpType == JumpType_BranchFF)
2678 found = g_Git.IsFastForward(data->m_CommitHash, hashValue);
2681 if (found)
2683 m_LogList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
2684 m_LogList.EnsureVisible(i, FALSE);
2685 m_LogList.SetSelectionMark(i);
2686 return;
2690 CMessageBox::ShowCheck(GetSafeHwnd(), IDS_PROC_LOG_JUMPNOTFOUND, IDS_APPNAME, 1, IDI_INFORMATION, IDS_OKBUTTON, 0, 0, _T("NoJumpNotFoundWarning"), IDS_MSGBOX_DONOTSHOWAGAIN);
2693 CTGitPathList CLogDlg::GetChangedPathsFromSelectedRevisions(bool /*bRelativePaths*/ /* = false */, bool /*bUseFilter*/ /* = true */)
2695 CTGitPathList pathList;
2696 #if 0
2698 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
2700 m_sRepositoryRoot = GetRepositoryRoot(m_path);
2702 if (m_sRepositoryRoot.IsEmpty() && (bRelativePaths == false))
2703 return pathList;
2705 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
2706 if (pos != NULL)
2708 while (pos)
2710 int nextpos = m_LogList.GetNextSelectedItem(pos);
2711 if (nextpos >= m_arShownList.GetCount())
2712 continue;
2713 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(nextpos));
2714 LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
2715 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount(); ++cpPathIndex)
2717 LogChangedPath * cpath = cpatharray->SafeGetAt(cpPathIndex);
2718 if (cpath == NULL)
2719 continue;
2720 CTGitPath path;
2721 if (!bRelativePaths)
2722 path.SetFromGit(m_sRepositoryRoot);
2723 path.AppendPathString(cpath->sPath);
2724 if ((!bUseFilter)||
2725 ((m_cHidePaths.GetState() & 0x0003)!=BST_CHECKED)||
2726 (cpath->sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0))
2727 pathList.AddPath(path);
2732 pathList.RemoveDuplicates();
2733 #endif
2734 return pathList;
2737 void CLogDlg::SortByColumn(int /*nSortColumn*/, bool /*bAscending*/)
2739 #if 0
2740 switch(nSortColumn)
2742 case 0: // Revision
2744 if(bAscending)
2745 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscRevSort());
2746 else
2747 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescRevSort());
2749 break;
2750 case 1: // action
2752 if(bAscending)
2753 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscActionSort());
2754 else
2755 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescActionSort());
2757 break;
2758 case 2: // Author
2760 if(bAscending)
2761 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscAuthorSort());
2762 else
2763 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescAuthorSort());
2765 break;
2766 case 3: // Date
2768 if(bAscending)
2769 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscDateSort());
2770 else
2771 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescDateSort());
2773 break;
2774 case 4: // Message or bug id
2775 if (m_bShowBugtraqColumn)
2777 if(bAscending)
2778 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscBugIDSort());
2779 else
2780 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescBugIDSort());
2781 break;
2783 // fall through here
2784 case 5: // Message
2786 if(bAscending)
2787 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::AscMessageSort());
2788 else
2789 std::sort(m_logEntries.begin(), m_logEntries.end(), CLogDataVector::DescMessageSort());
2791 break;
2792 default:
2793 ATLASSERT(0);
2794 break;
2796 #endif
2799 void CLogDlg::OnLvnColumnclick(NMHDR *pNMHDR, LRESULT *pResult)
2801 if (this->IsThreadRunning())
2802 return; //no sorting while the arrays are filled
2803 #if 0
2804 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
2805 const int nColumn = pNMLV->iSubItem;
2806 m_bAscending = nColumn == m_nSortColumn ? !m_bAscending : TRUE;
2807 m_nSortColumn = nColumn;
2808 SortByColumn(m_nSortColumn, m_bAscending);
2809 SetSortArrow(&m_LogList, m_nSortColumn, !!m_bAscending);
2810 SortShownListArray();
2811 m_LogList.Invalidate();
2812 UpdateLogInfoLabel();
2813 #else
2814 UNREFERENCED_PARAMETER(pNMHDR);
2815 #endif
2816 *pResult = 0;
2818 SetTimer(LOG_HEADER_ORDER_TIMER, 10, nullptr);
2821 void CLogDlg::SortShownListArray()
2823 // make sure the shown list still matches the filter after sorting.
2824 OnTimer(LOGFILTER_TIMER);
2825 // clear the selection states
2826 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
2827 while (pos)
2829 m_LogList.SetItemState(m_LogList.GetNextSelectedItem(pos), 0, LVIS_SELECTED);
2831 m_LogList.SetSelectionMark(-1);
2834 void CLogDlg::SetSortArrow(CListCtrl * control, int nColumn, bool bAscending)
2836 if (control == NULL)
2837 return;
2838 // set the sort arrow
2839 CHeaderCtrl * pHeader = control->GetHeaderCtrl();
2840 HDITEM HeaderItem = {0};
2841 HeaderItem.mask = HDI_FORMAT;
2842 for (int i=0; i<pHeader->GetItemCount(); ++i)
2844 pHeader->GetItem(i, &HeaderItem);
2845 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
2846 pHeader->SetItem(i, &HeaderItem);
2848 if (nColumn >= 0)
2850 pHeader->GetItem(nColumn, &HeaderItem);
2851 HeaderItem.fmt |= (bAscending ? HDF_SORTUP : HDF_SORTDOWN);
2852 pHeader->SetItem(nColumn, &HeaderItem);
2856 int CLogDlg::m_nSortColumnPathList = 0;
2857 bool CLogDlg::m_bAscendingPathList = false;
2859 void CLogDlg::OnBnClickedHidepaths()
2861 FillLogMessageCtrl();
2862 m_ChangedFileListCtrl.Invalidate();
2865 void CLogDlg::UpdateLogInfoLabel()
2868 CGitHash rev1 ;
2869 CGitHash rev2 ;
2870 long selectedrevs = 0;
2871 long selectedfiles = 0;
2872 int count = (int)m_LogList.m_arShownList.GetCount();
2873 int start = 0;
2874 if (count)
2876 rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.SafeGetAt(0)))->m_CommitHash;
2877 if(this->m_LogList.m_bShowWC && rev1.IsEmpty()&&(count>1))
2878 start = 1;
2879 rev1 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.SafeGetAt(start)))->m_CommitHash;
2880 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(m_arShownList.GetCount()-1));
2881 rev2 = (reinterpret_cast<GitRev*>(m_LogList.m_arShownList.SafeGetAt(count-1)))->m_CommitHash;
2882 selectedrevs = m_LogList.GetSelectedCount();
2883 if (selectedrevs)
2884 selectedfiles = m_ChangedFileListCtrl.GetSelectedCount();
2886 CString sTemp;
2887 sTemp.Format(IDS_PROC_LOG_STATS,
2888 count - start,
2889 (LPCTSTR)rev2.ToString().Left(g_Git.GetShortHASHLength()), (LPCTSTR)rev1.ToString().Left(g_Git.GetShortHASHLength()), selectedrevs, selectedfiles);
2891 if(selectedrevs == 1)
2893 CString str=m_ChangedFileListCtrl.GetStatisticsString(true);
2894 str.Replace(_T('\n'), _T(' '));
2895 sTemp += _T("\r\n") + str;
2897 m_sLogInfo = sTemp;
2899 UpdateData(FALSE);
2902 void CLogDlg::OnDtnDropdownDatefrom(NMHDR * /*pNMHDR*/, LRESULT *pResult)
2904 // the date control should not show the "today" button
2905 CMonthCalCtrl * pCtrl = m_DateFrom.GetMonthCalCtrl();
2906 if (pCtrl)
2907 SetWindowLongPtr(pCtrl->GetSafeHwnd(), GWL_STYLE, LONG_PTR(pCtrl->GetStyle() | MCS_NOTODAY));
2908 *pResult = 0;
2911 void CLogDlg::OnSize(UINT nType, int cx, int cy)
2913 __super::OnSize(nType, cx, cy);
2914 //set range
2915 SetSplitterRange();
2918 void CLogDlg::OnRefresh()
2921 this->m_LogProgress.SetPos(0);
2923 Refresh (false);
2927 void CLogDlg::OnFocusFilter()
2929 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
2932 void CLogDlg::OnEditCopy()
2934 if (GetFocus() == &m_ChangedFileListCtrl)
2935 CopyChangedSelectionToClipBoard();
2936 else
2937 m_LogList.CopySelectionToClipBoard();
2940 CString CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString& url)
2942 // is the URL a relative one?
2943 if (url.Left(2).Compare(_T("^/")) == 0)
2945 // URL is relative to the repository root
2946 CString url1 = m_sRepositoryRoot + url.Mid(1);
2947 TCHAR buf[INTERNET_MAX_URL_LENGTH] = { 0 };
2948 DWORD len = url.GetLength();
2949 if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
2950 return CString(buf, len);
2951 return url1;
2953 else if (url[0] == '/')
2955 // URL is relative to the server's hostname
2956 CString sHost;
2957 // find the server's hostname
2958 int schemepos = m_sRepositoryRoot.Find(_T("//"));
2959 if (schemepos >= 0)
2961 sHost = m_sRepositoryRoot.Left(m_sRepositoryRoot.Find('/', schemepos+3));
2962 CString url1 = sHost + url;
2963 TCHAR buf[INTERNET_MAX_URL_LENGTH] = { 0 };
2964 DWORD len = url.GetLength();
2965 if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
2966 return CString(buf, len);
2967 return url1;
2970 return url;
2973 void CLogDlg::ShowGravatar()
2975 m_gravatar.EnableGravatar(m_bShowGravatar);
2976 RemoveAnchor(IDC_MSGVIEW);
2977 if (m_gravatar.IsGravatarEnabled())
2979 RECT rect, rect2;
2980 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(&rect);
2981 ScreenToClient(&rect);
2982 m_gravatar.GetWindowRect(&rect2);
2983 ScreenToClient(&rect2);
2984 rect.right = rect2.left;
2985 GetDlgItem(IDC_MSGVIEW)->MoveWindow(&rect);
2986 m_gravatar.ShowWindow(SW_SHOW);
2988 else
2990 RECT rect, rect2;
2991 GetDlgItem(IDC_MSGVIEW)->GetWindowRect(&rect);
2992 ScreenToClient(&rect);
2993 m_gravatar.GetWindowRect(&rect2);
2994 ScreenToClient(&rect2);
2995 rect.right = rect2.right;
2996 GetDlgItem(IDC_MSGVIEW)->MoveWindow(&rect);
2997 m_gravatar.ShowWindow(SW_HIDE);
2999 AddAnchor(IDC_MSGVIEW, MIDDLE_LEFT, MIDDLE_RIGHT); // keep in sync with AddMainAnchors
3003 void CLogDlg::OnEnChangeSearchedit()
3005 UpdateData();
3006 if (!m_LogList.HasFilterText())
3008 CStoreSelection storeselection(this);
3009 // clear the filter, i.e. make all entries appear
3010 theApp.DoWaitCursor(1);
3011 KillTimer(LOGFILTER_TIMER);
3012 FillLogMessageCtrl(false);
3014 Refresh();
3015 //m_LogList.StartFilter();
3016 #if 0
3017 InterlockedExchange(&m_bNoDispUpdates, TRUE);
3018 m_arShownList.RemoveAll();
3019 for (DWORD i=0; i<m_logEntries.size(); ++i)
3021 if (IsEntryInDateRange(i))
3022 m_arShownList.Add(m_logEntries[i]);
3024 InterlockedExchange(&m_bNoDispUpdates, FALSE);
3025 m_LogList.DeleteAllItems();
3026 m_LogList.SetItemCountEx(ShownCountWithStopped());
3027 m_LogList.RedrawItems(0, ShownCountWithStopped());
3028 m_LogList.SetRedraw(false);
3029 ResizeAllListCtrlCols();
3030 m_LogList.SetRedraw(true);
3031 #endif
3032 theApp.DoWaitCursor(-1);
3033 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_HIDE);
3034 GetDlgItem(IDC_SEARCHEDIT)->ShowWindow(SW_SHOW);
3035 GetDlgItem(IDC_SEARCHEDIT)->SetFocus();
3036 DialogEnableWindow(IDC_STATBUTTON, !(((this->IsThreadRunning())||(m_LogList.m_arShownList.IsEmpty()))));
3037 return;
3039 if (Validate(m_LogList.m_sFilterText))
3040 SetTimer(LOGFILTER_TIMER, 1000, NULL);
3041 else
3042 KillTimer(LOGFILTER_TIMER);
3046 void CLogDlg::OnBnClickedAllBranch()
3048 // m_bAllBranch is not auto-toggled by MFC, we have to handle it manually (in order to prevent the indeterminate state)
3050 m_LogList.m_ShowMask &=~ (CGit::LOG_INFO_LOCAL_BRANCHES | CGit::LOG_INFO_ALL_BRANCH);
3052 if (m_bAllBranch)
3054 m_bAllBranch = BST_UNCHECKED;
3055 m_ChangedFileListCtrl.m_sDisplayedBranch = m_LogList.GetRange();
3057 else
3059 m_bAllBranch = BST_CHECKED;
3060 m_LogList.m_ShowMask|=CGit::LOG_INFO_ALL_BRANCH;
3061 m_ChangedFileListCtrl.m_sDisplayedBranch.Empty();
3064 // need to save value here, so that log dialogs started from now on also have AllBranch activated
3065 m_regbAllBranch = m_bAllBranch;
3067 UpdateData(FALSE);
3069 OnRefresh();
3071 FillLogMessageCtrl(false);
3074 void CLogDlg::OnBnClickedFollowRenames()
3076 if(m_bFollowRenames)
3078 m_LogList.m_ShowMask |= CGit::LOG_INFO_FOLLOW;
3079 m_LogList.m_ShowMask &=~ CGit::LOG_INFO_LOCAL_BRANCHES;
3080 if (m_bAllBranch)
3083 m_bAllBranch = FALSE;
3084 m_LogList.m_ShowMask &=~ CGit::LOG_INFO_ALL_BRANCH;
3088 else
3089 m_LogList.m_ShowMask &= ~CGit::LOG_INFO_FOLLOW;
3091 DialogEnableWindow(IDC_LOG_ALLBRANCH, !m_bFollowRenames);
3092 DialogEnableWindow(IDC_WHOLE_PROJECT, !m_bFollowRenames && !m_path.IsEmpty());
3094 OnRefresh();
3096 FillLogMessageCtrl(false);
3099 void CLogDlg::HandleShowLabels(bool var, int flag)
3101 if (var)
3102 m_LogList.m_ShowRefMask |= flag;
3103 else
3104 m_LogList.m_ShowRefMask &= ~flag;
3106 if ((m_LogList.m_ShowFilter & CGitLogListBase::FILTERSHOW_REFS) && !(m_LogList.m_ShowFilter & CGitLogListBase::FILTERSHOW_ANYCOMMIT))
3108 // Remove commits where labels are not shown.
3109 OnRefresh();
3110 FillLogMessageCtrl(false);
3112 else
3114 // Just redraw
3115 m_LogList.Invalidate();
3119 void CLogDlg::OnBnClickedCompressedGraph()
3121 UpdateData();
3123 if (m_iCompressedGraph == 2)
3124 m_LogList.m_ShowFilter = CGitLogListBase::FILTERSHOW_REFS;
3125 else if (m_iCompressedGraph == 1)
3126 m_LogList.m_ShowFilter = static_cast<CGitLogListBase::FilterShow>(CGitLogListBase::FILTERSHOW_REFS | CGitLogListBase::FILTERSHOW_MERGEPOINTS);
3127 else
3128 m_LogList.m_ShowFilter = CGitLogListBase::FILTERSHOW_ALL;
3130 OnRefresh();
3131 FillLogMessageCtrl(false);
3134 void CLogDlg::OnBnClickedBrowseRef()
3136 CString newRef = CBrowseRefsDlg::PickRef(false, m_LogList.GetRange(), gPickRef_All, true);
3137 if(newRef.IsEmpty())
3138 return;
3140 m_History.AddEntry(newRef);
3141 m_History.Save();
3143 SetRange(newRef);
3145 m_LogList.m_ShowMask &= ~(CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_LOCAL_BRANCHES);
3146 m_bAllBranch = BST_UNCHECKED;
3147 UpdateData(FALSE);
3149 OnRefresh();
3150 FillLogMessageCtrl(false);
3153 void CLogDlg::ShowStartRef()
3155 //Show ref name on top
3156 if(!::IsWindow(m_hWnd))
3157 return;
3158 if (m_LogList.m_ShowMask & (CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_LOCAL_BRANCHES))
3160 switch (m_LogList.m_ShowMask & (CGit::LOG_INFO_ALL_BRANCH | CGit::LOG_INFO_LOCAL_BRANCHES))
3162 case CGit::LOG_INFO_ALL_BRANCH:
3163 m_staticRef.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_LOG_ALLBRANCHES)));
3164 break;
3166 case CGit::LOG_INFO_LOCAL_BRANCHES:
3167 m_staticRef.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_LOG_LOCAL_BRANCHES)));
3168 break;
3171 m_staticRef.Invalidate(TRUE);
3172 m_tooltips.DelTool(GetDlgItem(IDC_STATIC_REF));
3173 return;
3176 CString showStartRef = m_LogList.GetRange();
3177 if (showStartRef.IsEmpty() || showStartRef == _T("HEAD"))
3179 showStartRef.Empty();
3180 //Ref name is HEAD
3181 if (g_Git.Run(L"git.exe symbolic-ref HEAD", &showStartRef, NULL, CP_UTF8))
3182 showStartRef.LoadString(IDS_PROC_LOG_NOBRANCH);
3183 showStartRef.Trim(L"\r\n\t ");
3187 showStartRef = g_Git.StripRefName(showStartRef);
3189 m_staticRef.SetWindowText(showStartRef);
3190 CWnd *pWnd = GetDlgItem(IDC_STATIC_REF);
3191 m_tooltips.AddTool(pWnd, showStartRef);
3192 m_staticRef.Invalidate(TRUE);
3195 void CLogDlg::SetRange(const CString& range)
3197 m_LogList.SetRange(range);
3198 m_ChangedFileListCtrl.m_sDisplayedBranch = range;
3200 ShowStartRef();
3203 static void AppendMenuChecked(CMenu &menu, UINT nTextID, UINT_PTR nItemID, BOOL checked = FALSE, BOOL enabled = TRUE)
3205 CString text;
3206 text.LoadString(nTextID);
3207 menu.AppendMenu(MF_STRING | (enabled ? MF_ENABLED : MF_DISABLED) | (checked ? MF_CHECKED : MF_UNCHECKED), nItemID, text);
3210 #define WALKBEHAVIOUR_FIRSTPARENT 1
3211 #define WALKBEHAVIOUR_FOLLOWRENAMES 2
3212 #define WALKBEHAVIOUR_COMPRESSEDGRAPH 3
3213 #define WALKBEHAVIOUR_LABELEDCOMMITS 4
3214 #define WALKBEHAVIOUR_NOMERGES 5
3216 void CLogDlg::OnBnClickedWalkBehaviour()
3218 CMenu popup;
3219 if (popup.CreatePopupMenu())
3221 AppendMenuChecked(popup, IDS_WALKBEHAVIOUR_FIRSTPARENT, WALKBEHAVIOUR_FIRSTPARENT, m_bFirstParent);
3222 AppendMenuChecked(popup, IDS_WALKBEHAVIOUR_NOMERGES, WALKBEHAVIOUR_NOMERGES, m_bNoMerges);
3223 AppendMenuChecked(popup, IDS_WALKBEHAVIOUR_FOLLOWRENAMES, WALKBEHAVIOUR_FOLLOWRENAMES, m_bFollowRenames, !(m_path.IsEmpty() || m_path.IsDirectory()));
3224 popup.AppendMenu(MF_SEPARATOR, NULL);
3225 AppendMenuChecked(popup, IDS_WALKBEHAVIOUR_COMPRESSED, WALKBEHAVIOUR_COMPRESSEDGRAPH, m_iCompressedGraph == 1);
3226 AppendMenuChecked(popup, IDS_WALKBEHAVIOUR_LABELEDCOMMITS, WALKBEHAVIOUR_LABELEDCOMMITS, m_iCompressedGraph == 2);
3228 m_tooltips.Pop();
3229 RECT rect;
3230 GetDlgItem(IDC_WALKBEHAVIOUR)->GetWindowRect(&rect);
3231 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, rect.left, rect.top, this, 0);
3232 switch (selection)
3234 case WALKBEHAVIOUR_FIRSTPARENT:
3235 m_bFirstParent = !m_bFirstParent;
3236 OnBnClickedFirstParent();
3237 break;
3238 case WALKBEHAVIOUR_NOMERGES:
3239 m_bNoMerges = !m_bNoMerges;
3240 OnBnClickedFirstParent(); // OnBnClickedFirstParent handles both cases: m_bFirstParent and m_bNoMerges
3241 break;
3242 case WALKBEHAVIOUR_FOLLOWRENAMES:
3243 m_bFollowRenames = !m_bFollowRenames;
3244 OnBnClickedFollowRenames();
3245 break;
3246 case WALKBEHAVIOUR_COMPRESSEDGRAPH:
3247 m_iCompressedGraph = (m_iCompressedGraph == 1 ? 0 : 1);
3248 OnBnClickedCompressedGraph();
3249 break;
3250 case WALKBEHAVIOUR_LABELEDCOMMITS:
3251 m_iCompressedGraph = (m_iCompressedGraph == 2 ? 0 : 2);
3252 OnBnClickedCompressedGraph();
3253 break;
3254 default:
3255 break;
3257 m_bWalkBehavior = (m_bFirstParent || m_bNoMerges || m_bFollowRenames || m_iCompressedGraph);
3258 UpdateData(FALSE);
3262 #define VIEW_HIDEPATHS 1
3263 #define VIEW_GRAYPATHS 2
3264 #define VIEW_SHOWTAGS 3
3265 #define VIEW_SHOWLOCALBRANCHES 4
3266 #define VIEW_SHOWREMOTEBRANCHES 5
3267 #define VIEW_SHOWGRAVATAR 6
3268 #define VIEW_SHOWPATCH 7
3270 void CLogDlg::OnBnClickedView()
3272 CMenu popup;
3273 if (popup.CreatePopupMenu())
3275 AppendMenuChecked(popup, IDS_SHOWFILES_HIDEPATHS, VIEW_HIDEPATHS, m_iHidePaths == 1);
3276 AppendMenuChecked(popup, IDS_SHOWFILES_GRAYPATHS, VIEW_GRAYPATHS, m_iHidePaths == 2);
3277 popup.AppendMenu(MF_SEPARATOR, NULL);
3278 CMenu showLabelsMenu;
3279 if (showLabelsMenu.CreatePopupMenu())
3281 AppendMenuChecked(showLabelsMenu, IDS_VIEW_SHOWTAGLABELS, VIEW_SHOWTAGS, m_bShowTags);
3282 AppendMenuChecked(showLabelsMenu, IDS_VIEW_SHOWLOCALBRANCHLABELS, VIEW_SHOWLOCALBRANCHES, m_bShowLocalBranches);
3283 AppendMenuChecked(showLabelsMenu, IDS_VIEW_SHOWREMOTEBRANCHLABELS, VIEW_SHOWREMOTEBRANCHES, m_bShowRemoteBranches);
3284 popup.AppendMenu(MF_STRING | MF_POPUP, (UINT_PTR)showLabelsMenu.m_hMenu, (CString)MAKEINTRESOURCE(IDS_VIEW_LABELS));
3286 popup.AppendMenu(MF_SEPARATOR, NULL);
3287 AppendMenuChecked(popup, IDS_VIEW_SHOWGRAVATAR, VIEW_SHOWGRAVATAR, m_bShowGravatar);
3288 AppendMenuChecked(popup, IDS_MENU_VIEWPATCH, VIEW_SHOWPATCH, IsWindow(this->m_patchViewdlg.m_hWnd));
3290 m_tooltips.Pop();
3291 RECT rect;
3292 GetDlgItem(IDC_VIEW)->GetWindowRect(&rect);
3293 int selection = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, rect.left, rect.top, this, 0);
3294 switch (selection)
3296 case VIEW_HIDEPATHS:
3297 if (m_iHidePaths == 1)
3298 m_iHidePaths = 0;
3299 else
3300 m_iHidePaths = 1;
3301 OnBnClickedHidepaths();
3302 break;
3303 case VIEW_GRAYPATHS:
3304 if (m_iHidePaths == 2)
3305 m_iHidePaths = 0;
3306 else
3307 m_iHidePaths = 2;
3308 OnBnClickedHidepaths();
3309 break;
3310 case VIEW_SHOWTAGS:
3311 m_bShowTags = !m_bShowTags;
3312 HandleShowLabels(m_bShowTags, LOGLIST_SHOWTAGS);
3313 break;
3314 case VIEW_SHOWLOCALBRANCHES:
3315 m_bShowLocalBranches = !m_bShowLocalBranches;
3316 HandleShowLabels(m_bShowLocalBranches, LOGLIST_SHOWLOCALBRANCHES);
3317 break;
3318 case VIEW_SHOWREMOTEBRANCHES:
3319 m_bShowRemoteBranches = !m_bShowRemoteBranches;
3320 HandleShowLabels(m_bShowRemoteBranches, LOGLIST_SHOWREMOTEBRANCHES);
3321 break;
3322 case VIEW_SHOWGRAVATAR:
3324 m_bShowGravatar = !m_bShowGravatar;
3325 ShowGravatar();
3326 m_gravatar.Init();
3327 CString email;
3328 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
3329 if (pos)
3331 int selIndex = m_LogList.GetNextSelectedItem(pos);
3332 int moreSel = m_LogList.GetNextSelectedItem(pos);
3333 if (moreSel < 0)
3335 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_LogList.m_arShownList.SafeGetAt(selIndex));
3336 if (pLogEntry)
3337 email = pLogEntry->GetAuthorEmail();
3340 m_gravatar.LoadGravatar(email);
3341 break;
3343 case VIEW_SHOWPATCH:
3344 TogglePatchView();
3345 break;
3346 default:
3347 break;
3352 void CLogDlg::OnBnClickedFirstParent()
3354 if(this->m_bFirstParent)
3355 m_LogList.m_ShowMask|=CGit::LOG_INFO_FIRST_PARENT;
3356 else
3357 m_LogList.m_ShowMask&=~CGit::LOG_INFO_FIRST_PARENT;
3359 if (m_bNoMerges)
3360 m_LogList.m_ShowMask |= CGit::LOG_INFO_NO_MERGE;
3361 else
3362 m_LogList.m_ShowMask &= ~CGit::LOG_INFO_NO_MERGE;
3364 OnRefresh();
3366 FillLogMessageCtrl(false);
3370 void CLogDlg::OnBnClickShowWholeProject()
3372 this->UpdateData();
3374 if(this->m_bWholeProject)
3376 m_LogList.m_Path.Reset();
3377 SetDlgTitle();
3379 else
3380 m_LogList.m_Path=m_path;
3382 m_regShowWholeProject = m_bWholeProject;
3384 SetDlgTitle();
3386 OnRefresh();
3388 FillLogMessageCtrl(false);
3392 LRESULT CLogDlg::OnRefLogChanged(WPARAM /*wParam*/, LPARAM /*lParam*/)
3394 ShowStartRef();
3395 return 0;
3398 LRESULT CLogDlg::OnTaskbarBtnCreated(WPARAM /*wParam*/, LPARAM /*lParam*/)
3400 m_pTaskbarList.Release();
3401 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
3402 SetUUIDOverlayIcon(m_hWnd);
3403 return 0;
3406 LRESULT CLogDlg::OnRefreshSelection(WPARAM /*wParam*/, LPARAM /*lParam*/)
3408 // it's enough to deselect, then select again one item of the whole selection
3409 int selMark = m_LogList.GetSelectionMark();
3410 if (selMark >= 0)
3412 m_LogList.SetSelectionMark(selMark);
3413 m_LogList.SetItemState(selMark, 0, LVIS_SELECTED);
3414 m_LogList.SetItemState(selMark, LVIS_SELECTED, LVIS_SELECTED);
3416 return 0;