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.
21 #include "TortoiseProc.h"
23 #include "StatGraphDlg.h"
25 #include "MessageBox.h"
28 #include "StringUtils.h"
29 #include "UnicodeUtils.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
)
43 , m_currentChangedArray(NULL
)
45 , m_bFollowRenames(false)
47 , m_bSelectionMustBeSingle(true)
49 , m_bShowLocalBranches(true)
50 , m_bShowRemoteBranches(true)
53 , m_bWalkBehavior(FALSE
)
54 , m_bFirstParent(false)
55 , m_bWholeProject(FALSE
)
56 , m_iCompressedGraph(0)
58 , m_bSelectionMustBeContinuous(false)
63 , m_pNotifyWindow(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
);
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"));
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
)
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
)
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
)
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
)
198 JumpType_AuthorEmail
,
199 JumpType_CommitterEmail
,
210 void CLogDlg::SetParams(const CTGitPath
& orgPath
, const CTGitPath
& path
, CString hightlightRevision
, CString range
, DWORD limit
, int limitScale
/*=-1*/)
214 m_hightlightRevision
= hightlightRevision
;
216 if (range
== GIT_REV_ZERO
)
219 if (!(range
.IsEmpty() || range
== _T("HEAD")))
220 m_bAllBranch
= BST_UNCHECKED
;
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
))
237 void CLogDlg::SetFilter(const CString
& findstr
, LONG findtype
, bool findregex
)
239 m_LogList
.m_sFilterText
= findstr
;
241 m_LogList
.m_SelectedFilters
= findtype
;
242 m_LogList
.m_bFilterWithRegex
= m_bFilterWithRegex
= findregex
;
245 BOOL
CLogDlg::OnInitDialog()
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"));
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
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
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();
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
);
300 CheckRegexpTooltip();
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());
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
;
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
));
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))
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
);
379 if (yPos2
&& ((LONG
)yPos2
< rcDlg
.bottom
- 153))
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
);
397 // the dialog is used to select revisions
398 // enable the OK button if appropriate
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
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")))
425 m_LogList
.FetchLogAsync(this);
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));
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
);
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
);
464 void CLogDlg::OnPaint()
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))
471 CWnd
* pWnd
= GetDlgItem(IDC_FROMLABEL
);
476 pWnd
->GetWindowRect(&rect
);
477 ScreenToClient(rect
);
482 dc
.FillRect(rect
, &m_Brush
);
485 LRESULT
CLogDlg::OnLogListLoading(WPARAM wParam
, LPARAM
/*lParam*/)
489 if( cur
== GITLOG_START
)
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);
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();
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();
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
);
552 if(this->m_LogList
.HasText())
554 this->m_LogList
.ClearText();
555 this->m_LogList
.Invalidate();
557 UpdateLogInfoLabel();
558 m_LogProgress
.SetPos(cur
);
561 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
562 m_pTaskbarList
->SetProgressValue(m_hWnd
, cur
, 100);
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
);
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
);
589 m_tooltips
.DelTool(pWnd
);
592 void CLogDlg::EnableOKButton()
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()));
605 DialogEnableWindow(IDOK
, m_LogList
.GetSelectedCount()!=0);
608 DialogEnableWindow(IDOK
, TRUE
);
611 bool LookLikeGitHash(const CString
& msg
, int &pos
)
614 for (; pos
< msg
.GetLength(); ++pos
)
616 if (msg
[pos
] >= '0' && msg
[pos
] <= '9' || msg
[pos
] >= 'a' && msg
[pos
] <= 'f')
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
;
633 while (offset
< msg
.GetLength())
636 TCHAR e
= msg
[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:")
646 while (offset
< msg
.GetLength())
648 if (msg
[++offset
] == '\n')
654 else if (e
>= 'A' && e
<= 'Z' || e
>= 'h' && e
<= 'z')
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')
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
);
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());
702 if (git_object_lookup(commit
.GetPointer(), repo
, (const git_oid
*)hash
.m_hash
, GIT_OBJ_COMMIT
))
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
))
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
))
718 result
= CUnicodeUtils::GetUnicode(describe_buf
->ptr
);
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(" "));
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.
744 m_ChangedFileListCtrl
.Invalidate();
745 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
746 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
747 m_gravatar
.LoadGravatar();
751 // depending on how many revisions are selected, we have to do different
753 int selCount
= m_LogList
.GetSelectedCount();
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();
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
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
);
775 Locker
lock(m_LogList
.m_critSec_AsyncDiff
);
776 GitRevLoglist
* pLogEntry
= reinterpret_cast<GitRevLoglist
*>(m_LogList
.m_arShownList
.SafeGetAt(selIndex
));
779 CString out_describe
;
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);
803 msg
+=pLogEntry
->GetBody();
805 if(!pLogEntry
->m_Notes
.IsEmpty())
807 msg
+= _T("\n*") + CString(MAKEINTRESOURCE(IDS_NOTES
)) + _T("* ");
808 msg
+= pLogEntry
->m_Notes
;
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
;
817 pMsgView
->ReplaceSel(msg
);
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.
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
);
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
;
865 for (int i
= 0 ; i
< count
; ++i
)
866 ((CTGitPath
&)files
[i
]).m_Action
&= ~(CTGitPath::LOGACTIONS_HIDE
| CTGitPath::LOGACTIONS_GRAY
);
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());
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
);
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
);
898 m_ChangedFileListCtrl
.SetBusy(FALSE
);
900 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
901 m_gravatar
.LoadGravatar(pLogEntry
->GetAuthorEmail());
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();
917 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
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());
931 m_ChangedFileListCtrl
.SetItemCountEx(0);
932 m_ChangedFileListCtrl
.Invalidate();
935 // sort according to the settings
936 if (m_nSortColumnPathList
> 0)
937 SetSortArrow(&m_ChangedFileListCtrl
, m_nSortColumnPathList
, m_bAscendingPathList
);
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
))
949 KillTimer(LOG_FILLPATCHVTIMER
);
952 SetTimer(LOG_FILLPATCHVTIMER
, 100, nullptr);
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();
970 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
976 if (CAppUtils::GetMsysgitVersion() > 0x01080100)
977 diffContext
= g_Git
.GetConfigValueInt32(_T("diff.context"), -1);
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
);
988 int nSelect
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
989 CTGitPath
* p
= (CTGitPath
*)m_ChangedFileListCtrl
.GetItemData(nSelect
);
990 if (p
&& !(p
->m_Action
&CTGitPath::LOGACTIONS_UNVER
))
993 if (pLogEntry
->m_CommitHash
.IsEmpty())
994 cmd
.Format(_T("git.exe diff HEAD -- \"%s\""), (LPCTSTR
)p
->GetGitPathString());
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
);
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
);
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);
1038 void CLogDlg::OnMoving(UINT fwSide
, LPRECT pRect
)
1040 __super::OnMoving(fwSide
, pRect
);
1042 if (!::IsWindow(m_patchViewdlg
.m_hWnd
))
1046 m_patchViewdlg
.GetWindowRect(&patchrect
);
1047 if (!::IsWindow(m_hWnd
))
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
))
1065 CRect thisrect
, patchrect
;
1066 this->GetWindowRect(thisrect
);
1067 this->m_patchViewdlg
.GetWindowRect(patchrect
);
1068 if (thisrect
.right
!= patchrect
.left
)
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();
1111 if (bForward
? m_LogList
.m_selectionHistory
.GoForward(gotoHash
) : m_LogList
.m_selectionHistory
.GoBack(gotoHash
))
1114 for (i
= 0; i
< m_LogList
.m_arShownList
.GetCount(); ++i
)
1116 GitRev
*rev
= (GitRev
*)m_LogList
.m_arShownList
.SafeGetAt(i
);
1118 if (rev
->m_CommitHash
== gotoHash
)
1120 m_LogList
.EnsureVisible(i
, FALSE
);
1123 m_LogList
.m_highlight
.Empty();
1124 m_LogList
.SetItemState(m_LogList
.GetSelectionMark(), 0, LVIS_SELECTED
| LVIS_FOCUSED
);
1125 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1128 int index
= m_LogList
.GetNextSelectedItem(pos
);
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;
1138 m_LogList
.m_highlight
= gotoHash
;
1139 m_LogList
.Invalidate();
1143 if (i
== m_LogList
.m_arShownList
.GetCount())
1146 msg
.Format(IDS_LOG_NOT_VISIBLE
, (LPCTSTR
)gotoHash
.ToString());
1147 MessageBox(msg
, _T("TortoiseGit"), MB_OK
| MB_ICONINFORMATION
);
1151 PlaySound((LPCTSTR
)SND_ALIAS_SYSTEMASTERISK
, nullptr, SND_ASYNC
| SND_ALIAS_ID
);
1154 void CLogDlg::OnBnClickedRefresh()
1159 void CLogDlg::Refresh (bool clearfilter
/*autoGoOnline*/)
1161 m_LogList
.Refresh(clearfilter
);
1164 FillLogMessageCtrl(false);
1169 BOOL
CLogDlg::Cancel()
1171 return m_bCancelled
;
1174 void CLogDlg::SaveSplitterPos()
1178 CRegDWORD
regPos1(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
1179 CRegDWORD
regPos2(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
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();
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
1215 // CGitRev* pLogEntry = reinterpret_cast<CGitRev* >(m_LogList.m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(pos)));
1218 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
1221 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
1222 CTGitPath
*path
= (CTGitPath
*)m_ChangedFileListCtrl
.GetItemData(nItem
);
1224 sPaths
+= path
->GetGitPathString();
1225 sPaths
+= _T("\r\n");
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();
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)
1247 if (selRealIndex
== nItem
)
1249 changedlogpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(hiddenindex
);
1256 sPaths
+= changedlogpath
->sPath
;
1257 sPaths
+= _T("\r\n");
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
))
1277 if (!popup
.CreatePopupMenu())
1281 popup
.AppendMenuIcon(++cnt
, IDS_MENUREFBROWSE
);
1282 popup
.SetDefaultItem(cnt
);
1283 popup
.AppendMenuIcon(++cnt
, _T("HEAD"));
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
);
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);
1310 OnBnClickedBrowseRef();
1314 m_LogList
.m_ShowMask
&= ~(CGit::LOG_INFO_ALL_BRANCH
| CGit::LOG_INFO_LOCAL_BRANCHES
);
1315 m_bAllBranch
= BST_UNCHECKED
;
1318 SetRange(g_Git
.GetCurrentBranch(true));
1322 SetRange(fetchHead
.ToString());
1326 m_bAllBranch
= BST_CHECKED
;
1327 m_LogList
.m_ShowMask
|= CGit::LOG_INFO_ALL_BRANCH
;
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
);
1344 FillLogMessageCtrl(false);
1349 if (pWnd
== GetDlgItem(IDC_DATEFROM
))
1352 if (!popup
.CreatePopupMenu())
1357 popup
.AppendMenuIcon(++cnt
, IDS_NO_LIMIT
);
1359 DWORD scale
= (DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\NumberOfLogsScale"), CFilterData::SHOW_NO_LIMIT
);
1363 case CFilterData::SHOW_LAST_N_COMMITS
:
1364 strScale
.LoadString(IDS_LAST_N_COMMITS
);
1366 case CFilterData::SHOW_LAST_N_YEARS
:
1367 strScale
.LoadString(IDS_LAST_N_YEARS
);
1369 case CFilterData::SHOW_LAST_N_MONTHS
:
1370 strScale
.LoadString(IDS_LAST_N_MONTHS
);
1372 case CFilterData::SHOW_LAST_N_WEEKS
:
1373 strScale
.LoadString(IDS_LAST_N_WEEKS
);
1376 if (!strScale
.IsEmpty() && m_LogList
.m_Filter
.m_NumberOfLogs
> 0)
1378 popup
.AppendMenu(MF_SEPARATOR
, 0);
1380 number
.Format(L
"%ld", m_LogList
.m_Filter
.m_NumberOfLogs
);
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);
1391 m_LogList
.m_Filter
.m_NumberOfLogsScale
= CFilterData::SHOW_NO_LIMIT
;
1392 // reset last selected date
1393 m_regLastSelectedFromDate
.removeValue();
1396 m_LogList
.m_Filter
.m_NumberOfLogsScale
= scale
;
1400 FillLogMessageCtrl(false);
1405 int selCount
= m_LogList
.GetSelectedCount();
1406 if ((selCount
== 1)&&(pWnd
== GetDlgItem(IDC_MSGVIEW
)))
1408 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1411 selIndex
= m_LogList
.GetNextSelectedItem(pos
);
1413 GitRevLoglist
* pRev
= ((GitRevLoglist
*)m_LogList
.m_arShownList
[selIndex
]);
1415 if ((point
.x
== -1) && (point
.y
== -1))
1418 GetDlgItem(IDC_MSGVIEW
)->GetClientRect(&rect
);
1419 ClientToScreen(&rect
);
1420 point
= rect
.CenterPoint();
1422 CString sMenuItemText
;
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
);
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);
1444 break; // no command selected
1447 pEdit
->SetRedraw(FALSE
);
1448 int oldLine
= pEdit
->GetFirstVisibleLine();
1449 pEdit
->SetSel(0, -1);
1451 pEdit
->SetSel(start
, end
);
1452 int newLine
= pEdit
->GetFirstVisibleLine();
1453 pEdit
->LineScroll(oldLine
- newLine
);
1454 pEdit
->SetRedraw(TRUE
);
1455 pEdit
->RedrawWindow();
1459 ::SendMessage(GetDlgItem(IDC_MSGVIEW
)->GetSafeHwnd(), cmd
, 0, -1);
1461 case CGitLogList::ID_EDITNOTE
:
1462 CAppUtils::EditNote(pRev
);
1463 this->FillLogMessageCtrl(true);
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();
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
));
1494 m_sSelectedHash
= pLogEntry
->m_CommitHash
;
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.
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();
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
;
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
);
1532 if (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
);
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
);
1584 CRegDWORD
reg(_T("Software\\TortoiseGit\\ShowAllEntry"));
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);
1596 GetTempPath(temppath
);
1599 file1
.Format(_T("%s%s_%s%s"),
1601 (LPCTSTR
)(*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1602 (LPCTSTR
)rev1
->m_CommitHash
.ToString().Left(g_Git
.GetShortHASHLength()),
1603 (LPCTSTR
)(*m_currentChangedArray
)[selIndex
].GetFileExtension());
1606 file2
.Format(_T("%s\\%s_%s%s"),
1608 (LPCTSTR
)(*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1609 (LPCTSTR
)rev2
->m_CommitHash
.ToString().Left(g_Git
.GetShortHASHLength()),
1610 (LPCTSTR
)(*m_currentChangedArray
)[selIndex
].GetFileExtension());
1613 CTGitPath
&path
= (CTGitPath
&)(*m_currentChangedArray
)[selIndex
];
1615 if (g_Git
.GetOneFile(rev1
->m_CommitHash
.ToString(), path
, file1
))
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);
1624 if (g_Git
.GetOneFile(rev2
->m_CommitHash
.ToString(), path
, file2
))
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);
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(),
1640 theApp
.DoWaitCursor(-1);
1644 void CLogDlg::OnPasteGitHash()
1646 if (!IsClipboardFormatAvailable(CF_TEXT
))
1649 CClipboardHelper clipboardHelper
;
1650 if (!clipboardHelper
.Open(GetSafeHwnd()))
1653 HGLOBAL hClipboardData
= GetClipboardData(CF_TEXT
);
1654 if (!hClipboardData
)
1657 char* pStr
= (char*)GlobalLock(hClipboardData
);
1659 GlobalUnlock(hClipboardData
);
1664 if (LookLikeGitHash(str
, pos
))
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
);
1674 if (rev
->m_CommitHash
.ToString().Left(hash
.GetLength()) != hash
)
1677 m_LogList
.SetItemState(m_LogList
.GetSelectionMark(), 0, LVIS_SELECTED
| LVIS_FOCUSED
);
1678 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1681 int index
= m_LogList
.GetNextSelectedItem(pos
);
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);
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();
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();
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
))
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
))
1741 if (m_hAccel
&& !bSkipAccelerator
)
1743 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
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
1759 ((pWnd
== GetDlgItem(IDC_LOGLIST
))||
1760 (pWnd
== GetDlgItem(IDC_MSGVIEW
))||
1761 (pWnd
== GetDlgItem(IDC_LOGMSG
))))
1763 HCURSOR hCur
= LoadCursor(NULL
, IDC_WAIT
);
1768 if ((pWnd
) && (pWnd
== GetDlgItem(IDC_MSGVIEW
)))
1769 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1771 HCURSOR hCur
= LoadCursor(NULL
, IDC_ARROW
);
1773 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1776 void CLogDlg::OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1778 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1780 //if (this->IsThreadRunning())
1781 if(m_LogList
.m_bNoDispUpdates
)
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)
1794 m_LogList
.m_lastSelectedHash
= pLogEntry
->m_CommitHash
;
1795 if (pNMLV
->iSubItem
!= 0)
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();
1805 UpdateLogInfoLabel();
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();
1822 m_LogList
.m_lastSelectedHash
.Empty();
1823 FillLogMessageCtrl();
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
))
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
);
1858 static RECT prevRect
= { 0 };
1859 CWnd
* pMsgView
= GetDlgItem(IDC_MSGVIEW
);
1864 pMsgView
->SendMessage(EM_POSFROMCHAR
, (WPARAM
)&pt
, pEnLink
->chrg
.cpMin
);
1867 pMsgView
->SendMessage(EM_POSFROMCHAR
, (WPARAM
)&pt
, pEnLink
->chrg
.cpMax
);
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);
1879 else if(pEnLink
->msg
== WM_LBUTTONUP
)
1882 if (LookLikeGitHash(url
, pos
))
1889 void CLogDlg::OnBnClickedStatbutton()
1891 if (this->IsThreadRunning())
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);
1899 m_LogList
.RecalculateShownList(&dlg
.m_ShowList
);
1901 dlg
.m_path
= m_orgPath
;
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
);
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
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
);
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
);
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
);
2063 m_LogList
.GetClientRect(rcLogList
);
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
)
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
);
2089 return CResizableDialog::DefWindowProc(message
, wParam
, lParam
);
2092 void CLogDlg::SetSplitterRange()
2094 if ((m_LogList
)&&(m_ChangedFileListCtrl
))
2097 m_LogList
.GetWindowRect(rcTop
);
2098 ScreenToClient(rcTop
);
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())
2117 // FIXME: x64 version would get this function called with unexpected parameters.
2121 RECT
* rect
= (LPRECT
)lParam
;
2124 point
= CPoint(rect
->left
, rect
->bottom
);
2125 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | ((m_LogList.m_SelectedFilters & x) ? MF_CHECKED : MF_UNCHECKED))
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
);
2172 int selection
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 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
;
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
;
2197 else if (selection
== LOGFILTER_ALL
)
2199 m_LogList
.m_SelectedFilters
= selection
;
2204 m_LogList
.m_SelectedFilters
^= selection
;
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
);
2216 LRESULT
CLogDlg::OnClickedCancelFilter(WPARAM wParam
, LPARAM
/*lParam*/)
2218 if ((HWND
)wParam
== m_cFileFilter
.GetSafeHwnd())
2220 KillTimer(FILEFILTER_TIMER
);
2222 FillLogMessageCtrl();
2226 KillTimer(LOGFILTER_TIMER
);
2228 m_LogList
.m_sFilterText
.Empty();
2230 theApp
.DoWaitCursor(1);
2231 CStoreSelection
storeselection(this);
2232 FillLogMessageCtrl(false);
2234 m_LogList
.RemoveFilter();
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();
2248 void CLogDlg::SetFilterCueText()
2250 CString
temp(MAKEINTRESOURCE(IDS_LOG_FILTER_BY
));
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)
2262 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_MESSAGES
));
2265 if (m_LogList
.m_SelectedFilters
& LOGFILTER_PATHS
)
2267 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
2269 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_PATHS
));
2272 if (m_LogList
.m_SelectedFilters
& LOGFILTER_AUTHORS
)
2274 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
2276 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_AUTHORS
));
2279 if (m_LogList
.m_SelectedFilters
& LOGFILTER_EMAILS
)
2281 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
2283 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_EMAILS
));
2286 if (m_LogList
.m_SelectedFilters
& LOGFILTER_REVS
)
2288 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
2290 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_REVS
));
2293 if (m_LogList
.m_SelectedFilters
& LOGFILTER_REFNAME
)
2295 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
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)
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
)
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
)
2337 else if (nIDEvent
== LOGFILTER_TIMER
)
2339 KillTimer(LOGFILTER_TIMER
);
2340 m_LogList
.Refresh(FALSE
);
2341 FillLogMessageCtrl(false);
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
);
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();
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
)
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
)
2404 m_DateTo
.GetTime(_time
);
2407 m_DateFrom
.GetTime(fromTime
);
2408 if (_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
);
2423 CMessageBox::Show(NULL
,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2429 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2435 m_DateFrom
.GetTime(_time
);
2438 m_DateTo
.GetTime(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
);
2459 CMessageBox::Show(NULL
,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
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
)
2485 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
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
);
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
--)
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/"))
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/"))
2564 if (found
&& jumpType
== JumpType_BranchFF
)
2565 found
= g_Git
.IsFastForward(hashValue
, data
->m_CommitHash
);
2570 m_LogList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
2571 m_LogList
.EnsureVisible(i
, FALSE
);
2572 m_LogList
.SetSelectionMark(i
);
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
)
2594 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
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);
2612 else if (jumpType
== JumpType_Parent2
)
2614 if (data
->m_ParentHash
.size() > 1)
2615 hashValue
= data
->m_ParentHash
.at(1);
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
);
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
)
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/"))
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/"))
2677 if (found
&& jumpType
== JumpType_BranchFF
)
2678 found
= g_Git
.IsFastForward(data
->m_CommitHash
, hashValue
);
2683 m_LogList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
2684 m_LogList
.EnsureVisible(i
, FALSE
);
2685 m_LogList
.SetSelectionMark(i
);
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
;
2698 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2700 m_sRepositoryRoot
= GetRepositoryRoot(m_path
);
2702 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2705 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2710 int nextpos
= m_LogList
.GetNextSelectedItem(pos
);
2711 if (nextpos
>= m_arShownList
.GetCount())
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
);
2721 if (!bRelativePaths
)
2722 path
.SetFromGit(m_sRepositoryRoot
);
2723 path
.AppendPathString(cpath
->sPath
);
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();
2737 void CLogDlg::SortByColumn(int /*nSortColumn*/, bool /*bAscending*/)
2745 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscRevSort());
2747 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescRevSort());
2753 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscActionSort());
2755 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescActionSort());
2761 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscAuthorSort());
2763 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescAuthorSort());
2769 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscDateSort());
2771 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescDateSort());
2774 case 4: // Message or bug id
2775 if (m_bShowBugtraqColumn
)
2778 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscBugIDSort());
2780 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescBugIDSort());
2783 // fall through here
2787 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscMessageSort());
2789 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescMessageSort());
2799 void CLogDlg::OnLvnColumnclick(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2801 if (this->IsThreadRunning())
2802 return; //no sorting while the arrays are filled
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();
2814 UNREFERENCED_PARAMETER(pNMHDR
);
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();
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
)
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
);
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()
2870 long selectedrevs
= 0;
2871 long selectedfiles
= 0;
2872 int count
= (int)m_LogList
.m_arShownList
.GetCount();
2876 rev1
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(0)))->m_CommitHash
;
2877 if(this->m_LogList
.m_bShowWC
&& rev1
.IsEmpty()&&(count
>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();
2884 selectedfiles
= m_ChangedFileListCtrl
.GetSelectedCount();
2887 sTemp
.Format(IDS_PROC_LOG_STATS
,
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
;
2902 void CLogDlg::OnDtnDropdownDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2904 // the date control should not show the "today" button
2905 CMonthCalCtrl
* pCtrl
= m_DateFrom
.GetMonthCalCtrl();
2907 SetWindowLongPtr(pCtrl
->GetSafeHwnd(), GWL_STYLE
, LONG_PTR(pCtrl
->GetStyle() | MCS_NOTODAY
));
2911 void CLogDlg::OnSize(UINT nType
, int cx
, int cy
)
2913 __super::OnSize(nType
, cx
, cy
);
2918 void CLogDlg::OnRefresh()
2921 this->m_LogProgress
.SetPos(0);
2927 void CLogDlg::OnFocusFilter()
2929 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2932 void CLogDlg::OnEditCopy()
2934 if (GetFocus() == &m_ChangedFileListCtrl
)
2935 CopyChangedSelectionToClipBoard();
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
);
2953 else if (url
[0] == '/')
2955 // URL is relative to the server's hostname
2957 // find the server's hostname
2958 int schemepos
= m_sRepositoryRoot
.Find(_T("//"));
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
);
2973 void CLogDlg::ShowGravatar()
2975 m_gravatar
.EnableGravatar(m_bShowGravatar
);
2976 RemoveAnchor(IDC_MSGVIEW
);
2977 if (m_gravatar
.IsGravatarEnabled())
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
);
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()
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);
3015 //m_LogList.StartFilter();
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);
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()))));
3039 if (Validate(m_LogList
.m_sFilterText
))
3040 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
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
);
3054 m_bAllBranch
= BST_UNCHECKED
;
3055 m_ChangedFileListCtrl
.m_sDisplayedBranch
= m_LogList
.GetRange();
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
;
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
;
3083 m_bAllBranch
= FALSE
;
3084 m_LogList
.m_ShowMask
&=~ CGit::LOG_INFO_ALL_BRANCH
;
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());
3096 FillLogMessageCtrl(false);
3099 void CLogDlg::HandleShowLabels(bool var
, int flag
)
3102 m_LogList
.m_ShowRefMask
|= flag
;
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.
3110 FillLogMessageCtrl(false);
3115 m_LogList
.Invalidate();
3119 void CLogDlg::OnBnClickedCompressedGraph()
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
);
3128 m_LogList
.m_ShowFilter
= CGitLogListBase::FILTERSHOW_ALL
;
3131 FillLogMessageCtrl(false);
3134 void CLogDlg::OnBnClickedBrowseRef()
3136 CString newRef
= CBrowseRefsDlg::PickRef(false, m_LogList
.GetRange(), gPickRef_All
, true);
3137 if(newRef
.IsEmpty())
3140 m_History
.AddEntry(newRef
);
3145 m_LogList
.m_ShowMask
&= ~(CGit::LOG_INFO_ALL_BRANCH
| CGit::LOG_INFO_LOCAL_BRANCHES
);
3146 m_bAllBranch
= BST_UNCHECKED
;
3150 FillLogMessageCtrl(false);
3153 void CLogDlg::ShowStartRef()
3155 //Show ref name on top
3156 if(!::IsWindow(m_hWnd
))
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
)));
3166 case CGit::LOG_INFO_LOCAL_BRANCHES
:
3167 m_staticRef
.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_LOG_LOCAL_BRANCHES
)));
3171 m_staticRef
.Invalidate(TRUE
);
3172 m_tooltips
.DelTool(GetDlgItem(IDC_STATIC_REF
));
3176 CString showStartRef
= m_LogList
.GetRange();
3177 if (showStartRef
.IsEmpty() || showStartRef
== _T("HEAD"))
3179 showStartRef
.Empty();
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
;
3203 static void AppendMenuChecked(CMenu
&menu
, UINT nTextID
, UINT_PTR nItemID
, BOOL checked
= FALSE
, BOOL enabled
= TRUE
)
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()
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);
3230 GetDlgItem(IDC_WALKBEHAVIOUR
)->GetWindowRect(&rect
);
3231 int selection
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, rect
.left
, rect
.top
, this, 0);
3234 case WALKBEHAVIOUR_FIRSTPARENT
:
3235 m_bFirstParent
= !m_bFirstParent
;
3236 OnBnClickedFirstParent();
3238 case WALKBEHAVIOUR_NOMERGES
:
3239 m_bNoMerges
= !m_bNoMerges
;
3240 OnBnClickedFirstParent(); // OnBnClickedFirstParent handles both cases: m_bFirstParent and m_bNoMerges
3242 case WALKBEHAVIOUR_FOLLOWRENAMES
:
3243 m_bFollowRenames
= !m_bFollowRenames
;
3244 OnBnClickedFollowRenames();
3246 case WALKBEHAVIOUR_COMPRESSEDGRAPH
:
3247 m_iCompressedGraph
= (m_iCompressedGraph
== 1 ? 0 : 1);
3248 OnBnClickedCompressedGraph();
3250 case WALKBEHAVIOUR_LABELEDCOMMITS
:
3251 m_iCompressedGraph
= (m_iCompressedGraph
== 2 ? 0 : 2);
3252 OnBnClickedCompressedGraph();
3257 m_bWalkBehavior
= (m_bFirstParent
|| m_bNoMerges
|| m_bFollowRenames
|| m_iCompressedGraph
);
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()
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
));
3292 GetDlgItem(IDC_VIEW
)->GetWindowRect(&rect
);
3293 int selection
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, rect
.left
, rect
.top
, this, 0);
3296 case VIEW_HIDEPATHS
:
3297 if (m_iHidePaths
== 1)
3301 OnBnClickedHidepaths();
3303 case VIEW_GRAYPATHS
:
3304 if (m_iHidePaths
== 2)
3308 OnBnClickedHidepaths();
3311 m_bShowTags
= !m_bShowTags
;
3312 HandleShowLabels(m_bShowTags
, LOGLIST_SHOWTAGS
);
3314 case VIEW_SHOWLOCALBRANCHES
:
3315 m_bShowLocalBranches
= !m_bShowLocalBranches
;
3316 HandleShowLabels(m_bShowLocalBranches
, LOGLIST_SHOWLOCALBRANCHES
);
3318 case VIEW_SHOWREMOTEBRANCHES
:
3319 m_bShowRemoteBranches
= !m_bShowRemoteBranches
;
3320 HandleShowLabels(m_bShowRemoteBranches
, LOGLIST_SHOWREMOTEBRANCHES
);
3322 case VIEW_SHOWGRAVATAR
:
3324 m_bShowGravatar
= !m_bShowGravatar
;
3328 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
3331 int selIndex
= m_LogList
.GetNextSelectedItem(pos
);
3332 int moreSel
= m_LogList
.GetNextSelectedItem(pos
);
3335 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(selIndex
));
3337 email
= pLogEntry
->GetAuthorEmail();
3340 m_gravatar
.LoadGravatar(email
);
3343 case VIEW_SHOWPATCH
:
3352 void CLogDlg::OnBnClickedFirstParent()
3354 if(this->m_bFirstParent
)
3355 m_LogList
.m_ShowMask
|=CGit::LOG_INFO_FIRST_PARENT
;
3357 m_LogList
.m_ShowMask
&=~CGit::LOG_INFO_FIRST_PARENT
;
3360 m_LogList
.m_ShowMask
|= CGit::LOG_INFO_NO_MERGE
;
3362 m_LogList
.m_ShowMask
&= ~CGit::LOG_INFO_NO_MERGE
;
3366 FillLogMessageCtrl(false);
3370 void CLogDlg::OnBnClickShowWholeProject()
3374 if(this->m_bWholeProject
)
3376 m_LogList
.m_Path
.Reset();
3380 m_LogList
.m_Path
=m_path
;
3382 m_regShowWholeProject
= m_bWholeProject
;
3388 FillLogMessageCtrl(false);
3392 LRESULT
CLogDlg::OnRefLogChanged(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
3398 LRESULT
CLogDlg::OnTaskbarBtnCreated(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
3400 m_pTaskbarList
.Release();
3401 m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
);
3402 SetUUIDOverlayIcon(m_hWnd
);
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();
3412 m_LogList
.SetSelectionMark(selMark
);
3413 m_LogList
.SetItemState(selMark
, 0, LVIS_SELECTED
);
3414 m_LogList
.SetItemState(selMark
, LVIS_SELECTED
, LVIS_SELECTED
);