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"
36 #define WM_TGIT_REFRESH_SELECTION (WM_APP + 1)
38 IMPLEMENT_DYNAMIC(CLogDlg
, CResizableStandAloneDialog
)
39 CLogDlg::CLogDlg(CWnd
* pParent
/*=NULL*/)
40 : CResizableStandAloneDialog(CLogDlg::IDD
, pParent
)
42 , m_currentChangedArray(NULL
)
44 , m_bFollowRenames(false)
46 , m_bSelectionMustBeSingle(true)
48 , m_bShowLocalBranches(true)
49 , m_bShowRemoteBranches(true)
52 , m_bWalkBehavior(FALSE
)
53 , m_bFirstParent(false)
54 , m_bWholeProject(FALSE
)
55 , m_iCompressedGraph(0)
57 , m_bSelectionMustBeContinuous(false)
62 , m_pNotifyWindow(NULL
)
68 , m_bNavigatingWithSelect(false)
70 m_bFilterWithRegex
= !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), FALSE
);
71 m_bFilterCaseSensitively
= !!CRegDWORD(L
"Software\\TortoiseGit\\FilterCaseSensitively", FALSE
);
72 m_bAsteriskLogPrefix
= !!CRegDWORD(L
"Software\\TortoiseGit\\AsteriskLogPrefix", TRUE
);
73 m_LogList
.m_SelectedFilters
= CRegDWORD(_T("Software\\TortoiseGit\\SelectedLogFilters"), LOGFILTER_ALL
);
76 str
=g_Git
.m_CurrentDir
;
77 str
.Replace(_T(":"),_T("_"));
78 str
=CString(_T("Software\\TortoiseGit\\LogDialog\\AllBranch\\"))+str
;
80 m_regbAllBranch
=CRegDWORD(str
,FALSE
);
82 m_bAllBranch
=m_regbAllBranch
;
84 str
= g_Git
.m_CurrentDir
;
85 str
.Replace(_T(":"),_T("_"));
86 m_regShowWholeProject
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ShowWholeProject\\") + str
, FALSE
);
87 m_bWholeProject
= m_regShowWholeProject
;
88 m_regbShowTags
= CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\ShowTags\\") + str
, TRUE
);
89 m_bShowTags
= !!m_regbShowTags
;
90 m_regbShowLocalBranches
= CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\ShowLocalBranches\\") + str
, TRUE
);
91 m_bShowLocalBranches
= !!m_regbShowLocalBranches
;
92 m_regbShowRemoteBranches
= CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\ShowRemoteBranches\\") + str
, TRUE
);
93 m_bShowRemoteBranches
= !!m_regbShowRemoteBranches
;
95 m_bShowUnversioned
= CRegDWORD(_T("Software\\TortoiseGit\\AddBeforeCommit"), TRUE
);
97 m_bShowGravatar
= !!CRegDWORD(_T("Software\\TortoiseGit\\EnableGravatar"), FALSE
);
98 m_regbShowGravatar
= CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\ShowGravatar\\") + str
, m_bShowGravatar
);
99 m_bShowGravatar
= !!m_regbShowGravatar
;
100 m_bShowDescribe
= !!CRegDWORD(_T("Software\\TortoiseGit\\ShowDescribe"));
106 m_regbAllBranch
= m_bAllBranch
;
107 m_regbShowTags
= m_bShowTags
;
108 m_regbShowLocalBranches
= m_bShowLocalBranches
;
109 m_regbShowRemoteBranches
= m_bShowRemoteBranches
;
110 m_regbShowGravatar
= m_bShowGravatar
;
112 m_CurrentFilteredChangedArray
.RemoveAll();
116 void CLogDlg::DoDataExchange(CDataExchange
* pDX
)
118 CResizableStandAloneDialog::DoDataExchange(pDX
);
119 DDX_Control(pDX
, IDC_LOGLIST
, m_LogList
);
120 DDX_Control(pDX
, IDC_LOGMSG
, m_ChangedFileListCtrl
);
121 DDX_Control(pDX
, IDC_PROGRESS
, m_LogProgress
);
122 DDX_Control(pDX
, IDC_SPLITTERTOP
, m_wndSplitter1
);
123 DDX_Control(pDX
, IDC_SPLITTERBOTTOM
, m_wndSplitter2
);
124 DDX_Text(pDX
, IDC_SEARCHEDIT
, m_LogList
.m_sFilterText
);
125 DDX_Control(pDX
, IDC_DATEFROM
, m_DateFrom
);
126 DDX_Control(pDX
, IDC_DATETO
, m_DateTo
);
127 DDX_Control(pDX
, IDC_LOG_JUMPTYPE
, m_JumpType
);
128 DDX_Control(pDX
, IDC_LOG_JUMPUP
, m_JumpUp
);
129 DDX_Control(pDX
, IDC_LOG_JUMPDOWN
, m_JumpDown
);
130 DDX_Text(pDX
, IDC_LOGINFO
, m_sLogInfo
);
131 DDX_Check(pDX
, IDC_LOG_ALLBRANCH
,m_bAllBranch
);
132 DDX_Check(pDX
, IDC_SHOWWHOLEPROJECT
,m_bWholeProject
);
133 DDX_Check(pDX
, IDC_WALKBEHAVIOUR
, m_bWalkBehavior
);
134 DDX_Control(pDX
, IDC_SEARCHEDIT
, m_cFilter
);
135 DDX_Control(pDX
, IDC_STATIC_REF
, m_staticRef
);
136 DDX_Control(pDX
, IDC_PIC_AUTHOR
, m_gravatar
);
137 DDX_Control(pDX
, IDC_FILTER
, m_cFileFilter
);
140 BEGIN_MESSAGE_MAP(CLogDlg
, CResizableStandAloneDialog
)
143 ON_NOTIFY(LVN_ITEMCHANGED
, IDC_LOGLIST
, OnLvnItemchangedLoglist
)
144 ON_NOTIFY(LVN_ITEMCHANGED
, IDC_LOGMSG
, OnLvnItemchangedLogmsg
)
145 ON_NOTIFY(EN_LINK
, IDC_MSGVIEW
, OnEnLinkMsgview
)
146 ON_EN_VSCROLL(IDC_MSGVIEW
, OnEnscrollMsgview
)
147 ON_EN_HSCROLL(IDC_MSGVIEW
, OnEnscrollMsgview
)
148 ON_BN_CLICKED(IDC_STATBUTTON
, OnBnClickedStatbutton
)
150 ON_MESSAGE(WM_TGIT_REFRESH_SELECTION
, OnRefreshSelection
)
151 ON_MESSAGE(WM_FILTEREDIT_INFOCLICKED
, OnClickedInfoIcon
)
152 ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED
, OnClickedCancelFilter
)
154 ON_MESSAGE(MSG_LOAD_PERCENTAGE
,OnLogListLoading
)
156 ON_EN_CHANGE(IDC_SEARCHEDIT
, OnEnChangeSearchedit
)
158 ON_NOTIFY(DTN_DATETIMECHANGE
, IDC_DATETO
, OnDtnDatetimechangeDateto
)
159 ON_NOTIFY(DTN_DATETIMECHANGE
, IDC_DATEFROM
, OnDtnDatetimechangeDatefrom
)
160 ON_CBN_SELCHANGE(IDC_LOG_JUMPTYPE
, &CLogDlg::OnCbnSelchangeJumpType
)
161 ON_COMMAND(IDC_LOG_JUMPUP
, &CLogDlg::OnBnClickedJumpUp
)
162 ON_COMMAND(IDC_LOG_JUMPDOWN
, &CLogDlg::OnBnClickedJumpDown
)
163 ON_COMMAND(ID_GO_UP
, &CLogDlg::OnBnClickedJumpUp
)
164 ON_COMMAND(ID_GO_DOWN
, &CLogDlg::OnBnClickedJumpDown
)
165 ON_BN_CLICKED(IDC_WALKBEHAVIOUR
, OnBnClickedWalkBehaviour
)
166 ON_BN_CLICKED(IDC_VIEW
, OnBnClickedView
)
167 ON_BN_CLICKED(IDC_SHOWWHOLEPROJECT
, OnBnClickShowWholeProject
)
168 ON_NOTIFY(LVN_COLUMNCLICK
,IDC_LOGLIST
, OnLvnColumnclick
)
169 ON_COMMAND(MSG_FETCHED_DIFF
, OnBnClickedHidepaths
)
170 ON_BN_CLICKED(IDC_LOG_ALLBRANCH
, OnBnClickedAllBranch
)
171 ON_EN_CHANGE(IDC_FILTER
, OnEnChangeFileFilter
)
173 ON_NOTIFY(DTN_DROPDOWN
, IDC_DATEFROM
, &CLogDlg::OnDtnDropdownDatefrom
)
174 ON_NOTIFY(DTN_DROPDOWN
, IDC_DATETO
, &CLogDlg::OnDtnDropdownDateto
)
176 ON_BN_CLICKED(IDC_REFRESH
, &CLogDlg::OnBnClickedRefresh
)
177 ON_STN_CLICKED(IDC_STATIC_REF
, &CLogDlg::OnBnClickedBrowseRef
)
178 ON_COMMAND(ID_LOGDLG_REFRESH
, &CLogDlg::OnBnClickedRefresh
)
179 ON_COMMAND(ID_GO_BACKWARD_SELECT
, &CLogDlg::GoBackAndSelect
)
180 ON_COMMAND(ID_GO_FORWARD_SELECT
, &CLogDlg::GoForwardAndSelect
)
181 ON_COMMAND(ID_GO_BACKWARD
, &CLogDlg::GoBack
)
182 ON_COMMAND(ID_GO_FORWARD
, &CLogDlg::GoForward
)
183 ON_COMMAND(ID_SELECT_SEARCHFIELD
, &CLogDlg::OnSelectSearchField
)
184 ON_COMMAND(ID_LOGDLG_FIND
, &CLogDlg::OnFind
)
185 ON_COMMAND(ID_LOGDLG_FOCUSFILTER
, &CLogDlg::OnFocusFilter
)
186 ON_COMMAND(ID_EDIT_COPY
, &CLogDlg::OnEditCopy
)
187 ON_MESSAGE(MSG_REFLOG_CHANGED
, OnRefLogChanged
)
188 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED
, OnTaskbarBtnCreated
)
190 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
, int limit
)
214 m_hightlightRevision
= hightlightRevision
;
216 if (range
== GIT_REV_ZERO
)
219 if (!(range
.IsEmpty() || range
== _T("HEAD")))
220 m_bAllBranch
= BST_UNCHECKED
;
225 if (::IsWindow(m_hWnd
))
229 void CLogDlg::SetFilter(const CString
& findstr
, LONG findtype
, bool findregex
)
231 m_LogList
.m_sFilterText
= findstr
;
233 m_LogList
.m_SelectedFilters
= findtype
;
234 m_LogList
.m_bFilterWithRegex
= m_bFilterWithRegex
= findregex
;
237 BOOL
CLogDlg::OnInitDialog()
240 CResizableStandAloneDialog::OnInitDialog();
241 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
243 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
244 // do this, Explorer would be unable to send that message to our window if we
245 // were running elevated. It's OK to make the call all the time, since if we're
246 // not elevated, this is a no-op.
247 CHANGEFILTERSTRUCT cfs
= { sizeof(CHANGEFILTERSTRUCT
) };
248 typedef BOOL STDAPICALLTYPE
ChangeWindowMessageFilterExDFN(HWND hWnd
, UINT message
, DWORD action
, PCHANGEFILTERSTRUCT pChangeFilterStruct
);
249 CAutoLibrary hUser
= AtlLoadSystemLibraryUsingFullPath(_T("user32.dll"));
252 ChangeWindowMessageFilterExDFN
*pfnChangeWindowMessageFilterEx
= (ChangeWindowMessageFilterExDFN
*)GetProcAddress(hUser
, "ChangeWindowMessageFilterEx");
253 if (pfnChangeWindowMessageFilterEx
)
255 pfnChangeWindowMessageFilterEx(m_hWnd
, WM_TASKBARBTNCREATED
, MSGFLT_ALLOW
, &cfs
);
258 m_pTaskbarList
.Release();
259 if (FAILED(m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
)))
260 m_pTaskbarList
= nullptr;
262 m_hAccel
= LoadAccelerators(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_ACC_LOGDLG
));
264 // use the state of the "stop on copy/rename" option from the last time
267 // set the font to use in the log message view, configured in the settings dialog
268 CAppUtils::CreateFontForLogs(m_logFont
);
269 GetDlgItem(IDC_MSGVIEW
)->SetFont(&m_logFont
);
270 // make the log message rich edit control send a message when the mouse pointer is over a link
271 GetDlgItem(IDC_MSGVIEW
)->SendMessage(EM_SETEVENTMASK
, NULL
, ENM_LINK
| ENM_SCROLL
);
273 // "unrelated paths" should be in gray color
276 // set up the columns
277 m_LogList
.DeleteAllItems();
279 m_LogList
.m_Path
=m_path
;
280 m_LogList
.m_hasWC
= m_LogList
.m_bShowWC
= !GitAdminDir::IsBareRepo(g_Git
.m_CurrentDir
);
281 m_LogList
.InsertGitColumn();
284 m_LogList
.m_Path
.Reset();
286 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
);
288 GetDlgItem(IDC_LOGLIST
)->UpdateData(FALSE
);
292 CheckRegexpTooltip();
296 // the filter control has a 'cancel' button (the red 'X'), we need to load its bitmap
297 m_cFilter
.SetCancelBitmaps(IDI_CANCELNORMAL
, IDI_CANCELPRESSED
);
298 m_cFilter
.SetInfoIcon(IDI_LOGFILTER
);
299 m_cFilter
.SetValidator(this);
301 AdjustControlSize(IDC_LOG_ALLBRANCH
);
302 AdjustControlSize(IDC_SHOWWHOLEPROJECT
);
304 GetClientRect(m_DlgOrigRect
);
305 m_LogList
.GetClientRect(m_LogListOrigRect
);
306 GetDlgItem(IDC_MSGVIEW
)->GetClientRect(m_MsgViewOrigRect
);
307 m_ChangedFileListCtrl
.GetClientRect(m_ChgOrigRect
);
309 m_DateFrom
.SendMessage(DTM_SETMCSTYLE
, 0, MCS_WEEKNUMBERS
|MCS_NOTODAY
|MCS_NOTRAILINGDATES
|MCS_NOSELCHANGEONNAV
);
310 m_DateTo
.SendMessage(DTM_SETMCSTYLE
, 0, MCS_WEEKNUMBERS
|MCS_NOTODAY
|MCS_NOTRAILINGDATES
|MCS_NOSELCHANGEONNAV
);
312 m_staticRef
.SetURL(CString());
315 AddAnchor(IDC_STATIC_REF
, TOP_LEFT
);
316 //AddAnchor(IDC_BUTTON_BROWSE_REF, TOP_LEFT);
317 AddAnchor(IDC_FROMLABEL
, TOP_LEFT
);
318 AddAnchor(IDC_DATEFROM
, TOP_LEFT
);
319 AddAnchor(IDC_TOLABEL
, TOP_LEFT
);
320 AddAnchor(IDC_DATETO
, TOP_LEFT
);
323 AddAnchor(IDC_SEARCHEDIT
, TOP_LEFT
, TOP_RIGHT
);
324 AddAnchor(IDC_LOG_JUMPTYPE
, TOP_RIGHT
);
325 AddAnchor(IDC_LOG_JUMPUP
, TOP_RIGHT
);
326 AddAnchor(IDC_LOG_JUMPDOWN
, TOP_RIGHT
);
328 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
329 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
330 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
331 AddAnchor(IDC_PIC_AUTHOR
, TOP_RIGHT
);
332 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
333 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
335 AddAnchor(IDC_LOGINFO
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
336 AddAnchor(IDC_WALKBEHAVIOUR
, BOTTOM_LEFT
);
337 AddAnchor(IDC_VIEW
, BOTTOM_LEFT
);
338 AddAnchor(IDC_LOG_ALLBRANCH
,BOTTOM_LEFT
);
339 AddAnchor(IDC_FILTER
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
340 AddAnchor(IDC_SHOWWHOLEPROJECT
, BOTTOM_LEFT
);
341 AddAnchor(IDC_REFRESH
, BOTTOM_LEFT
);
342 AddAnchor(IDC_STATBUTTON
, BOTTOM_LEFT
);
343 AddAnchor(IDC_PROGRESS
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
344 AddAnchor(IDOK
, BOTTOM_RIGHT
);
345 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
346 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
348 m_LogList
.m_ShowMask
&= ~CGit::LOG_INFO_LOCAL_BRANCHES
;
349 if (m_bAllBranch
== BST_CHECKED
)
350 m_LogList
.m_ShowMask
|=CGit::LOG_INFO_ALL_BRANCH
;
351 else if (m_bAllBranch
== BST_INDETERMINATE
)
352 m_LogList
.m_ShowMask
|= CGit::LOG_INFO_LOCAL_BRANCHES
;
354 m_LogList
.m_ShowMask
&=~CGit::LOG_INFO_ALL_BRANCH
;
356 HandleShowLabels(m_bShowTags
, LOGLIST_SHOWTAGS
);
357 HandleShowLabels(m_bShowLocalBranches
, LOGLIST_SHOWLOCALBRANCHES
);
358 HandleShowLabels(m_bShowRemoteBranches
, LOGLIST_SHOWREMOTEBRANCHES
);
360 // SetPromptParentWindow(m_hWnd);
361 m_JumpType
.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_AUTHOREMAIL
)));
362 m_JumpType
.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_COMMITTEREMAIL
)));
363 m_JumpType
.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_MERGEPOINT
)));
364 m_JumpType
.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_PARENT1
)));
365 m_JumpType
.AddString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_PARENT2
)));
366 m_JumpType
.AddString(CString(MAKEINTRESOURCE(IDS_PROC_TAG
)));
367 m_JumpType
.AddString(CString(MAKEINTRESOURCE(IDS_PROC_TAG_FF
)));
368 m_JumpType
.AddString(CString(MAKEINTRESOURCE(IDS_PROC_BRANCH
)));
369 m_JumpType
.AddString(CString(MAKEINTRESOURCE(IDS_PROC_BRANCH_FF
)));
370 m_JumpType
.AddString(CString(MAKEINTRESOURCE(IDS_PROC_SELECTION_HISTORY
)));
371 m_JumpType
.SetCurSel(0);
372 m_JumpUp
.SetIcon((HICON
)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_JUMPUP
), IMAGE_ICON
, 16, 16, LR_DEFAULTCOLOR
));
373 m_JumpDown
.SetIcon((HICON
)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_JUMPDOWN
), IMAGE_ICON
, 16, 16, LR_DEFAULTCOLOR
));
376 CenterWindow(CWnd::FromHandle(hWndExplorer
));
377 EnableSaveRestore(_T("LogDlg"));
379 DWORD yPos1
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
380 DWORD yPos2
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
381 RECT rcDlg
, rcLogList
, rcChgMsg
;
382 GetClientRect(&rcDlg
);
383 m_LogList
.GetWindowRect(&rcLogList
);
384 ScreenToClient(&rcLogList
);
385 m_ChangedFileListCtrl
.GetWindowRect(&rcChgMsg
);
386 ScreenToClient(&rcChgMsg
);
390 m_wndSplitter1
.GetWindowRect(&rectSplitter
);
391 ScreenToClient(&rectSplitter
);
392 int delta
= yPos1
- rectSplitter
.top
;
394 if ((rcLogList
.bottom
+ delta
> rcLogList
.top
)&&(rcLogList
.bottom
+ delta
< rcChgMsg
.bottom
- 30))
396 m_wndSplitter1
.SetWindowPos(NULL
, rectSplitter
.left
, yPos1
, 0, 0, SWP_NOSIZE
);
403 m_wndSplitter2
.GetWindowRect(&rectSplitter
);
404 ScreenToClient(&rectSplitter
);
405 int delta
= yPos2
- rectSplitter
.top
;
407 if ((rcChgMsg
.top
+ delta
< rcChgMsg
.bottom
)&&(rcChgMsg
.top
+ delta
> rcLogList
.top
+ 30))
409 m_wndSplitter2
.SetWindowPos(NULL
, rectSplitter
.left
, yPos2
, 0, 0, SWP_NOSIZE
);
418 // the dialog is used to select revisions
419 // enable the OK button if appropriate
424 // the dialog is used to just view log messages
425 // hide the OK button and set text on Cancel button to OK
426 GetDlgItemText(IDOK
, temp
);
427 SetDlgItemText(IDCANCEL
, temp
);
428 GetDlgItem(IDOK
)->ShowWindow(SW_HIDE
);
431 // first start a thread to obtain the log messages without
432 // blocking the dialog
434 //m_tFrom = (DWORD)-1;
436 // scroll to user selected or current revision
437 if (m_hightlightRevision
.IsEmpty() || g_Git
.GetHash(m_LogList
.m_lastSelectedHash
, m_hightlightRevision
))
439 if (g_Git
.GetHash(m_LogList
.m_lastSelectedHash
, _T("HEAD")))
440 MessageBox(g_Git
.GetGitLastErr(_T("Could not get HEAD hash.")), _T("TortoiseGit"), MB_ICONERROR
);
443 if (g_Git
.GetConfigValueBool(_T("tgit.logshowpatch")))
446 m_LogList
.FetchLogAsync(this);
450 m_cFileFilter
.SetCancelBitmaps(IDI_CANCELNORMAL
, IDI_CANCELPRESSED
);
451 m_cFileFilter
.SetInfoIcon(IDI_FILTEREDIT
);
452 temp
.LoadString(IDS_FILEDIFF_FILTERCUE
);
453 temp
= _T(" ") + temp
;
454 m_cFileFilter
.SetCueBanner(temp
);
456 GetDlgItem(IDC_LOGLIST
)->SetFocus();
458 m_History
.SetMaxHistoryItems((LONG
)CRegDWORD(_T("Software\\TortoiseGit\\MaxRefHistoryItems"), 5));
460 reg
.Format(_T("Software\\TortoiseGit\\History\\log-refs\\%s"), g_Git
.m_CurrentDir
);
461 reg
.Replace(_T(':'),_T('_'));
462 m_History
.Load(reg
, _T("ref"));
468 LRESULT
CLogDlg::OnLogListLoading(WPARAM wParam
, LPARAM
/*lParam*/)
472 if( cur
== GITLOG_START
)
475 temp
.LoadString(IDS_PROGRESSWAIT
);
477 this->m_LogList
.ShowText(temp
, true);
479 // We use a progress bar while getting the logs
480 m_LogProgress
.SetRange32(0, 100);
481 m_LogProgress
.SetPos(0);
484 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
485 m_pTaskbarList
->SetProgressValue(m_hWnd
, 0, 100);
488 GetDlgItem(IDC_WALKBEHAVIOUR
)->ShowWindow(SW_HIDE
);
489 GetDlgItem(IDC_VIEW
)->ShowWindow(SW_HIDE
);
490 GetDlgItem(IDC_STATBUTTON
)->ShowWindow(SW_HIDE
);
491 GetDlgItem(IDC_PROGRESS
)->ShowWindow(TRUE
);
493 DialogEnableWindow(IDC_WALKBEHAVIOUR
, FALSE
);
494 DialogEnableWindow(IDC_STATBUTTON
, FALSE
);
495 //DialogEnableWindow(IDC_REFRESH, FALSE);
496 DialogEnableWindow(IDC_VIEW
, FALSE
);
499 else if( cur
== GITLOG_END
)
501 if(this->m_LogList
.HasText())
503 this->m_LogList
.ClearText();
505 UpdateLogInfoLabel();
508 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NOPROGRESS
);
510 DialogEnableWindow(IDC_SHOWWHOLEPROJECT
, !m_bFollowRenames
&& !m_path
.IsEmpty());
512 DialogEnableWindow(IDC_STATBUTTON
, !(m_LogList
.m_arShownList
.IsEmpty() || m_LogList
.m_arShownList
.GetCount() == 1 && m_LogList
.m_bShowWC
));
513 DialogEnableWindow(IDC_REFRESH
, TRUE
);
514 DialogEnableWindow(IDC_VIEW
, TRUE
);
515 DialogEnableWindow(IDC_WALKBEHAVIOUR
, TRUE
);
516 // PostMessage(WM_TIMER, LOGFILTER_TIMER);
517 GetDlgItem(IDC_WALKBEHAVIOUR
)->ShowWindow(SW_SHOW
);
518 GetDlgItem(IDC_VIEW
)->ShowWindow(SW_SHOW
);
519 GetDlgItem(IDC_STATBUTTON
)->ShowWindow(SW_SHOW
);
520 GetDlgItem(IDC_PROGRESS
)->ShowWindow(FALSE
);
521 //CTime time=m_LogList.GetOldestTime();
523 m_LogList
.GetTimeRange(begin
,end
);
525 if(m_LogList
.m_From
== -1)
526 m_DateFrom
.SetTime(&begin
);
528 if(m_LogList
.m_To
== -1)
529 m_DateTo
.SetTime(&end
);
535 if(this->m_LogList
.HasText())
537 this->m_LogList
.ClearText();
538 this->m_LogList
.Invalidate();
540 UpdateLogInfoLabel();
541 m_LogProgress
.SetPos(cur
);
544 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
545 m_pTaskbarList
->SetProgressValue(m_hWnd
, cur
, 100);
550 void CLogDlg::SetDlgTitle()
552 if (m_sTitle
.IsEmpty())
553 GetWindowText(m_sTitle
);
555 if (m_LogList
.m_Path
.IsEmpty() || m_orgPath
.GetWinPathString().IsEmpty())
557 CAppUtils::SetWindowTitle(m_hWnd
, g_Git
.m_CurrentDir
, m_sTitle
);
560 CAppUtils::SetWindowTitle(m_hWnd
, m_orgPath
.GetWinPathString(), m_sTitle
);
563 void CLogDlg::CheckRegexpTooltip()
565 CWnd
*pWnd
= GetDlgItem(IDC_SEARCHEDIT
);
566 // Since tooltip describes regexp features, show it only if regexps are enabled.
567 if (m_bFilterWithRegex
)
569 m_tooltips
.AddTool(pWnd
, IDS_LOG_FILTER_REGEX_TT
);
572 m_tooltips
.DelTool(pWnd
);
575 void CLogDlg::EnableOKButton()
579 // the dialog is used to select revisions
580 if (m_bSelectionMustBeSingle
)
582 // enable OK button if only a single revision is selected
583 DialogEnableWindow(IDOK
, (m_LogList
.GetSelectedCount()==1));
585 else if (m_bSelectionMustBeContinuous
)
586 DialogEnableWindow(IDOK
, (m_LogList
.GetSelectedCount()!=0)&&(m_LogList
.IsSelectionContinuous()));
588 DialogEnableWindow(IDOK
, m_LogList
.GetSelectedCount()!=0);
591 DialogEnableWindow(IDOK
, TRUE
);
594 bool LookLikeGitHash(const CString
& msg
, int &pos
)
597 for (; pos
< msg
.GetLength(); ++pos
)
599 if (msg
[pos
] >= '0' && msg
[pos
] <= '9' || msg
[pos
] >= 'a' && msg
[pos
] <= 'f')
605 return c
>= g_Git
.GetShortHASHLength() && c
<= GIT_HASH_SIZE
* 2;
608 return c
>= g_Git
.GetShortHASHLength() && c
<= GIT_HASH_SIZE
* 2;
611 std::vector
<CHARRANGE
> FindGitHashPositions(const CString
& msg
, int offset
)
613 std::vector
<CHARRANGE
> result
;
614 offset
= offset
< 0 ? 0 : offset
;
616 while (offset
< msg
.GetLength())
619 TCHAR e
= msg
[offset
];
623 if (msg
.Mid(offset
, 11) == _T("git-svn-id:")
624 || msg
.Mid(offset
, 14) == _T("Signed-off-by:")
625 || msg
.Mid(offset
, 10) == _T("Change-Id:")
629 while (offset
< msg
.GetLength())
631 if (msg
[offset
++] == '\n')
637 else if (e
>= 'A' && e
<= 'Z' || e
>= 'h' && e
<= 'z')
642 } while (offset
< msg
.GetLength() && (e
>= 'A' && e
<= 'Z' || e
>= 'a' && e
<= 'z' || e
>= '0' && e
<= '9'));
644 else if (e
>= 'a' && e
<= 'g' || e
>= '0' && e
<= '9')
651 if (LookLikeGitHash(msg
, offset
))
653 TCHAR d
= offset
< msg
.GetLength() ? msg
[offset
] : '\0';
654 if (!((d
>= 'A' && d
<= 'Z') || (d
>= 'a' && d
<= 'z') || (d
>= '0' && d
<= '9')))
656 CHARRANGE range
= { old
, offset
};
657 result
.push_back(range
);
671 BOOL
FindGitHash(const CString
& msg
, int offset
, CWnd
*pWnd
)
673 std::vector
<CHARRANGE
> positions
= FindGitHashPositions(msg
, offset
);
674 CAppUtils::SetCharFormat(pWnd
, CFM_LINK
, CFE_LINK
, positions
);
676 return positions
.empty() ? FALSE
: TRUE
;
679 static int DescribeCommit(CGitHash
& hash
, CString
& result
)
681 CAutoRepository
repo(g_Git
.GetGitRepository());
685 if (git_object_lookup(commit
.GetPointer(), repo
, (const git_oid
*)hash
.m_hash
, GIT_OBJ_COMMIT
))
688 CAutoDescribeResult describe
;
689 git_describe_options describe_options
= GIT_DESCRIBE_OPTIONS_INIT
;
690 describe_options
.describe_strategy
= CRegDWORD(_T("Software\\TortoiseGit\\DescribeStrategy"), GIT_DESCRIBE_DEFAULT
);
691 if (git_describe_commit(describe
.GetPointer(), (git_object
*)commit
, &describe_options
))
694 CAutoBuf describe_buf
;
695 git_describe_format_options format_options
= GIT_DESCRIBE_FORMAT_OPTIONS_INIT
;
696 format_options
.abbreviated_size
= CRegDWORD(_T("Software\\TortoiseGit\\DescribeAbbreviatedSize"), GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE
);
697 format_options
.always_use_long_format
= CRegDWORD(_T("Software\\TortoiseGit\\DescribeAlwaysLong"));
698 if (git_describe_format(describe_buf
, describe
, &format_options
))
701 result
= CUnicodeUtils::GetUnicode(describe_buf
->ptr
);
705 void CLogDlg::FillLogMessageCtrl(bool bShow
/* = true*/)
707 // we fill here the log message rich edit control,
708 // and also populate the changed files list control
709 // according to the selected revision(s).
711 CRichEditCtrl
* pMsgView
= (CRichEditCtrl
*)GetDlgItem(IDC_MSGVIEW
);
712 // empty the log message view
713 pMsgView
->SetWindowText(_T(" "));
715 // empty the changed files list
716 m_ChangedFileListCtrl
.SetRedraw(FALSE
);
717 // InterlockedExchange(&m_bNoDispUpdates, TRUE);
718 m_currentChangedArray
= NULL
;
719 m_ChangedFileListCtrl
.DeleteAllItems();
721 // if we're not here to really show a selected revision, just
722 // get out of here after clearing the views, which is what is intended
723 // if that flag is not set.
727 m_ChangedFileListCtrl
.Invalidate();
728 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
729 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
730 m_gravatar
.LoadGravatar();
734 // depending on how many revisions are selected, we have to do different
736 int selCount
= m_LogList
.GetSelectedCount();
739 // if nothing is selected, we have nothing more to do
740 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
741 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
742 m_gravatar
.LoadGravatar();
745 else if (selCount
== 1)
747 // if one revision is selected, we have to fill the log message view
748 // with the corresponding log message, and also fill the changed files
750 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
751 int selIndex
= m_LogList
.GetNextSelectedItem(pos
);
752 if (selIndex
>= m_LogList
.m_arShownList
.GetCount())
754 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
755 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
758 Locker
lock(m_LogList
.m_critSec_AsyncDiff
);
759 GitRevLoglist
* pLogEntry
= reinterpret_cast<GitRevLoglist
*>(m_LogList
.m_arShownList
.SafeGetAt(selIndex
));
762 CString out_describe
;
766 if (!DescribeCommit(pLogEntry
->m_CommitHash
, result
))
767 out_describe
= _T("Describe: ") + result
+ _T("\r\n");
770 // set the log message text
771 pMsgView
->SetWindowText(CString(MAKEINTRESOURCE(IDS_HASH
)) + _T(": ") + pLogEntry
->m_CommitHash
.ToString() + _T("\r\n") + out_describe
+ _T("\r\n"));
772 // turn bug ID's into links if the bugtraq: properties have been set
773 // and we can find a match of those in the log message
775 pMsgView
->SetSel(-1,-1);
776 CAppUtils::SetCharFormat(pMsgView
, CFM_BOLD
, CFE_BOLD
);
778 CString msg
= m_bAsteriskLogPrefix
? _T("* ") : _T("");
779 msg
+=pLogEntry
->GetSubject();
780 pMsgView
->ReplaceSel(msg
);
782 pMsgView
->SetSel(-1,-1);
783 CAppUtils::SetCharFormat(pMsgView
, CFM_BOLD
, 0);
786 msg
+=pLogEntry
->GetBody();
788 if(!pLogEntry
->m_Notes
.IsEmpty())
790 msg
+= _T("\n*") + CString(MAKEINTRESOURCE(IDS_NOTES
)) + _T("* ");
791 msg
+= pLogEntry
->m_Notes
;
795 CString tagInfo
= m_LogList
.GetTagInfo(pLogEntry
);
796 if(!tagInfo
.IsEmpty())
797 tagInfo
= _T("\n*") + CString(MAKEINTRESOURCE(IDS_PROC_LOG_TAGINFO
)) + _T("*\n\n") + tagInfo
;
800 pMsgView
->ReplaceSel(msg
);
803 pMsgView
->GetWindowText(text
);
804 // the rich edit control doesn't count the CR char!
805 // to be exact: CRLF is treated as one char.
808 int findHashStart
= text
.Find('\n');
809 if (!out_describe
.IsEmpty())
810 findHashStart
= text
.Find('\n', findHashStart
+ 1);
811 FindGitHash(text
, findHashStart
, pMsgView
);
812 m_LogList
.m_ProjectProperties
.FindBugID(text
, pMsgView
);
813 CAppUtils::StyleURLs(text
, pMsgView
);
814 if (((DWORD
)CRegStdDWORD(_T("Software\\TortoiseGit\\StyleCommitMessages"), TRUE
)) == TRUE
)
815 CAppUtils::FormatTextInRichEditControl(pMsgView
);
820 pMsgView
->SendMessage(EM_EXSETSEL
, NULL
, (LPARAM
)&range
);
822 CString matchpath
=this->m_path
.GetGitPathString();
824 bool mightNeedReset
= true;
826 int count
= pLogEntry
->GetFiles(&m_LogList
).GetCount();
827 for (int i
= 0 ; i
< count
&& (!matchpath
.IsEmpty()); ++i
)
829 if( m_bWholeProject
)
832 ((CTGitPath
&)pLogEntry
->GetFiles(&m_LogList
)[i
]).m_Action
&= ~(CTGitPath::LOGACTIONS_HIDE
|CTGitPath::LOGACTIONS_GRAY
);
833 mightNeedReset
= false;
835 if(pLogEntry
->GetFiles(&m_LogList
)[i
].GetGitPathString().Left(matchpath
.GetLength()) != matchpath
&& pLogEntry
->GetFiles(&m_LogList
)[i
].GetGitOldPathString().Left(matchpath
.GetLength()) != matchpath
)
837 if (m_iHidePaths
== 1)
838 ((CTGitPath
&)pLogEntry
->GetFiles(&m_LogList
)[i
]).m_Action
|= CTGitPath::LOGACTIONS_HIDE
;
839 else if (m_iHidePaths
== 2)
840 ((CTGitPath
&)pLogEntry
->GetFiles(&m_LogList
)[i
]).m_Action
|= CTGitPath::LOGACTIONS_GRAY
;
846 for (int i
= 0 ; i
< count
; ++i
)
847 ((CTGitPath
&)pLogEntry
->GetFiles(&m_LogList
)[i
]).m_Action
&= ~CTGitPath::LOGACTIONS_HIDE
;
851 m_cFileFilter
.GetWindowText(fileFilter
);
852 fileFilter
.MakeLower();
853 for (int i
= 0; i
< count
&& (!fileFilter
.IsEmpty()); ++i
)
855 CString sPath
= pLogEntry
->GetFiles(&m_LogList
)[i
].GetGitPathString();
857 if (sPath
.Find(fileFilter
) < 0)
858 ((CTGitPath
&)pLogEntry
->GetFiles(&m_LogList
)[i
]).m_Action
|= CTGitPath::LOGACTIONS_HIDE
;
861 m_ChangedFileListCtrl
.UpdateWithGitPathList(pLogEntry
->GetFiles(&m_LogList
));
862 m_ChangedFileListCtrl
.m_CurrentVersion
=pLogEntry
->m_CommitHash
;
863 if (pLogEntry
->m_CommitHash
.IsEmpty() && m_bShowUnversioned
)
865 m_ChangedFileListCtrl
.UpdateUnRevFileList(pLogEntry
->GetUnRevFiles());
866 m_ChangedFileListCtrl
.Show(GITSLC_SHOWVERSIONED
| GITSLC_SHOWUNVERSIONED
);
869 m_ChangedFileListCtrl
.Show(GITSLC_SHOWVERSIONED
);
871 m_ChangedFileListCtrl
.SetBusyString(CString(MAKEINTRESOURCE(IDS_PROC_LOG_FETCHINGFILES
)));
873 if(!pLogEntry
->m_IsDiffFiles
)
874 m_ChangedFileListCtrl
.SetBusy(TRUE
);
876 m_ChangedFileListCtrl
.SetBusy(FALSE
);
878 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
879 m_gravatar
.LoadGravatar(pLogEntry
->GetAuthorEmail());
886 // more than one revision is selected:
887 // the log message view must be emptied
888 // the changed files list contains all the changed paths from all
889 // selected revisions, with 'doubles' removed
890 m_currentChangedPathList
= GetChangedPathsFromSelectedRevisions(true);
891 m_gravatar
.LoadGravatar();
895 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
897 if (m_currentChangedArray
)
899 m_ChangedFileListCtrl
.SetItemCountEx(m_currentChangedArray
->GetCount());
900 m_ChangedFileListCtrl
.RedrawItems(0, m_currentChangedArray
->GetCount());
902 else if (m_currentChangedPathList
.GetCount())
904 m_ChangedFileListCtrl
.SetItemCountEx(m_currentChangedPathList
.GetCount());
905 m_ChangedFileListCtrl
.RedrawItems(0, m_currentChangedPathList
.GetCount());
909 m_ChangedFileListCtrl
.SetItemCountEx(0);
910 m_ChangedFileListCtrl
.Invalidate();
913 // sort according to the settings
914 if (m_nSortColumnPathList
> 0)
915 SetSortArrow(&m_ChangedFileListCtrl
, m_nSortColumnPathList
, m_bAscendingPathList
);
917 SetSortArrow(&m_ChangedFileListCtrl
, -1, false);
918 m_ChangedFileListCtrl
.SetRedraw(TRUE
);
922 void CLogDlg::FillPatchView(bool onlySetTimer
)
924 if (!::IsWindow(this->m_patchViewdlg
.m_hWnd
))
927 KillTimer(LOG_FILLPATCHVTIMER
);
930 SetTimer(LOG_FILLPATCHVTIMER
, 100, nullptr);
934 POSITION posLogList
= m_LogList
.GetFirstSelectedItemPosition();
935 if (posLogList
== nullptr)
937 m_patchViewdlg
.ClearView();
938 return; // nothing is selected, get out of here
941 GitRev
* pLogEntry
= reinterpret_cast<GitRev
* >(m_LogList
.m_arShownList
.SafeGetAt(m_LogList
.GetNextSelectedItem(posLogList
)));
942 if (pLogEntry
== nullptr || m_LogList
.GetNextSelectedItem(posLogList
) != -1)
944 m_patchViewdlg
.ClearView();
948 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
954 if (CAppUtils::GetMsysgitVersion() > 0x01080100)
955 diffContext
= g_Git
.GetConfigValueInt32(_T("diff.context"), -1);
957 CString rev1
= pLogEntry
->m_CommitHash
.IsEmpty() ? _T("HEAD") : (pLogEntry
->m_CommitHash
.ToString() + _T("~1"));
958 CString rev2
= pLogEntry
->m_CommitHash
.IsEmpty() ? GIT_REV_ZERO
: pLogEntry
->m_CommitHash
.ToString();
959 g_Git
.GetUnifiedDiff(CTGitPath(), rev1
, rev2
, &outA
, false, false, diffContext
);
960 out
= CUnicodeUtils::GetUnicode(outA
);
966 int nSelect
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
967 CTGitPath
* p
= (CTGitPath
*)m_ChangedFileListCtrl
.GetItemData(nSelect
);
968 if (p
&& !(p
->m_Action
&CTGitPath::LOGACTIONS_UNVER
))
971 if (pLogEntry
->m_CommitHash
.IsEmpty())
972 cmd
.Format(_T("git.exe diff HEAD -- \"%s\""), p
->GetGitPathString());
974 cmd
.Format(_T("git.exe diff %s^%d..%s -- \"%s\""), pLogEntry
->m_CommitHash
.ToString(), p
->m_ParentNo
+ 1, pLogEntry
->m_CommitHash
.ToString(), p
->GetGitPathString());
975 g_Git
.Run(cmd
, &out
, CP_UTF8
);
980 m_patchViewdlg
.SetText(out
);
983 void CLogDlg::TogglePatchView()
985 m_patchViewdlg
.m_pProjectProperties
= &m_LogList
.m_ProjectProperties
;
986 m_patchViewdlg
.m_ParentDlg
= this;
987 if (!IsWindow(m_patchViewdlg
.m_hWnd
))
989 BOOL viewPatchEnabled
= FALSE
;
990 viewPatchEnabled
= g_Git
.GetConfigValueBool(_T("tgit.logshowpatch"));
991 if (viewPatchEnabled
== FALSE
)
992 g_Git
.SetConfigValue(_T("tgit.logshowpatch"), _T("true"));
993 m_patchViewdlg
.Create(IDD_PATCH_VIEW
, this);
994 m_patchViewdlg
.m_ctrlPatchView
.Call(SCI_SETSCROLLWIDTHTRACKING
, TRUE
);
996 this->GetWindowRect(&rect
);
998 m_patchViewdlg
.ShowWindow(SW_SHOW
);
999 m_patchViewdlg
.SetWindowPos(nullptr, rect
.right
, rect
.top
, rect
.Width(), rect
.Height(), SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOZORDER
);
1005 g_Git
.SetConfigValue(_T("tgit.logshowpatch"), _T("false"));
1006 m_patchViewdlg
.ShowWindow(SW_HIDE
);
1007 m_patchViewdlg
.DestroyWindow();
1011 LRESULT
CLogDlg::OnFileListCtrlItemChanged(WPARAM
/*wparam*/, LPARAM
/*lparam*/)
1013 FillPatchView(true);
1017 void CLogDlg::OnMoving(UINT fwSide
, LPRECT pRect
)
1019 __super::OnMoving(fwSide
, pRect
);
1021 if (!::IsWindow(m_patchViewdlg
.m_hWnd
))
1025 m_patchViewdlg
.GetWindowRect(&patchrect
);
1026 if (!::IsWindow(m_hWnd
))
1030 GetWindowRect(&thisrect
);
1031 if (patchrect
.left
== thisrect
.right
)
1033 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
);
1037 void CLogDlg::OnSizing(UINT fwSide
, LPRECT pRect
)
1039 __super::OnSizing(fwSide
, pRect
);
1041 if (!::IsWindow(this->m_patchViewdlg
.m_hWnd
))
1044 CRect thisrect
, patchrect
;
1045 this->GetWindowRect(thisrect
);
1046 this->m_patchViewdlg
.GetWindowRect(patchrect
);
1047 if (thisrect
.right
!= patchrect
.left
)
1050 patchrect
.left
-= (thisrect
.right
- pRect
->right
);
1051 patchrect
.right
-= (thisrect
.right
- pRect
->right
);
1053 if (patchrect
.bottom
== thisrect
.bottom
)
1054 patchrect
.bottom
-= (thisrect
.bottom
- pRect
->bottom
);
1055 if (patchrect
.top
== thisrect
.top
)
1056 patchrect
.top
-= thisrect
.top
- pRect
->top
;
1057 m_patchViewdlg
.MoveWindow(patchrect
);
1060 void CLogDlg::OnSelectSearchField()
1062 m_cFilter
.SetSel(0, -1, FALSE
);
1063 m_cFilter
.SetFocus();
1066 void CLogDlg::GoBack()
1068 GoBackForward(false, false);
1071 void CLogDlg::GoForward()
1073 GoBackForward(false, true);
1076 void CLogDlg::GoBackAndSelect()
1078 GoBackForward(true, false);
1081 void CLogDlg::GoForwardAndSelect()
1083 GoBackForward(true, true);
1086 void CLogDlg::GoBackForward(bool select
, bool bForward
)
1088 m_LogList
.m_highlight
.Empty();
1090 if (bForward
? m_LogList
.m_selectionHistory
.GoForward(gotoHash
) : m_LogList
.m_selectionHistory
.GoBack(gotoHash
))
1093 for (i
= 0; i
< m_LogList
.m_arShownList
.GetCount(); ++i
)
1095 GitRev
*rev
= (GitRev
*)m_LogList
.m_arShownList
.SafeGetAt(i
);
1097 if (rev
->m_CommitHash
== gotoHash
)
1099 m_LogList
.EnsureVisible(i
, FALSE
);
1102 m_LogList
.m_highlight
.Empty();
1103 m_LogList
.SetItemState(m_LogList
.GetSelectionMark(), 0, LVIS_SELECTED
);
1104 m_bNavigatingWithSelect
= true;
1105 m_LogList
.SetItemState(i
, LVIS_SELECTED
| LVIS_FOCUSED
, LVIS_SELECTED
| LVIS_FOCUSED
);
1106 m_LogList
.SetSelectionMark(i
);
1107 m_bNavigatingWithSelect
= false;
1110 m_LogList
.m_highlight
= gotoHash
;
1111 m_LogList
.Invalidate();
1115 if (i
== m_LogList
.m_arShownList
.GetCount())
1118 msg
.Format(IDS_LOG_NOT_VISIBLE
, gotoHash
.ToString());
1119 MessageBox(msg
, _T("TortoiseGit"), MB_OK
| MB_ICONINFORMATION
);
1123 PlaySound((LPCTSTR
)SND_ALIAS_SYSTEMASTERISK
, nullptr, SND_ASYNC
| SND_ALIAS_ID
);
1126 void CLogDlg::OnBnClickedRefresh()
1131 void CLogDlg::Refresh (bool clearfilter
/*autoGoOnline*/)
1134 m_LogList
.Refresh(clearfilter
);
1137 FillLogMessageCtrl(false);
1142 BOOL
CLogDlg::Cancel()
1144 return m_bCancelled
;
1147 void CLogDlg::SaveSplitterPos()
1151 CRegDWORD
regPos1(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer1"));
1152 CRegDWORD
regPos2(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\LogDlgSizer2"));
1154 m_wndSplitter1
.GetWindowRect(&rectSplitter
);
1155 ScreenToClient(&rectSplitter
);
1156 regPos1
= rectSplitter
.top
;
1157 m_wndSplitter2
.GetWindowRect(&rectSplitter
);
1158 ScreenToClient(&rectSplitter
);
1159 regPos2
= rectSplitter
.top
;
1163 void CLogDlg::OnCancel()
1165 this->ShowWindow(SW_HIDE
);
1167 // canceling means stopping the working thread if it's still running.
1168 m_LogList
.SafeTerminateAsyncDiffThread();
1169 if (this->IsThreadRunning())
1171 m_LogList
.SafeTerminateThread();
1176 __super::OnCancel();
1179 void CLogDlg::CopyChangedSelectionToClipBoard()
1182 POSITION posLogList
= m_LogList
.GetFirstSelectedItemPosition();
1183 if (posLogList
== nullptr)
1184 return; // nothing is selected, get out of here
1188 // CGitRev* pLogEntry = reinterpret_cast<CGitRev* >(m_LogList.m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(pos)));
1191 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
1194 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
1195 CTGitPath
*path
= (CTGitPath
*)m_ChangedFileListCtrl
.GetItemData(nItem
);
1197 sPaths
+= path
->GetGitPathString();
1198 sPaths
+= _T("\r\n");
1204 // only one revision is selected in the log dialog top pane
1205 // but multiple items could be selected in the changed items list
1206 POSITION pos
= m_ChangedFileListCtrl
.GetFirstSelectedItemPosition();
1209 int nItem
= m_ChangedFileListCtrl
.GetNextSelectedItem(pos
);
1210 LogChangedPath
* changedlogpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(nItem
);
1212 if ((m_cHidePaths
.GetState() & 0x0003)==BST_CHECKED
)
1214 // some items are hidden! So find out which item the user really selected
1215 INT_PTR selRealIndex
= -1;
1216 for (INT_PTR hiddenindex
=0; hiddenindex
<pLogEntry
->pArChangedPaths
->GetCount(); ++hiddenindex
)
1218 if (pLogEntry
->pArChangedPaths
->SafeGetAt(hiddenindex
)->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
1220 if (selRealIndex
== nItem
)
1222 changedlogpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(hiddenindex
);
1229 sPaths
+= changedlogpath
->sPath
;
1230 sPaths
+= _T("\r\n");
1236 CStringUtils::WriteAsciiStringToClipboard(sPaths
, GetSafeHwnd());
1240 void CLogDlg::OnContextMenu(CWnd
* pWnd
, CPoint point
)
1242 // we have three separate context menus:
1243 // one for the branch label in the upper left
1244 // one shown on the log message list control,
1245 // one shown in the changed-files list control
1246 if (pWnd
== GetDlgItem(IDC_STATIC_REF
))
1249 if (!popup
.CreatePopupMenu())
1253 popup
.AppendMenuIcon(++cnt
, IDS_MENUREFBROWSE
);
1254 popup
.SetDefaultItem(cnt
);
1255 popup
.AppendMenuIcon(++cnt
, _T("HEAD"));
1257 g_Git
.GetHash(fetchHead
, g_Git
.FixBranchName(_T("FETCH_HEAD")));
1258 popup
.AppendMenuIcon(++cnt
, _T("FETCH_HEAD"));
1259 popup
.EnableMenuItem(cnt
, fetchHead
.IsEmpty());
1260 popup
.AppendMenuIcon(++cnt
, IDS_ALL
);
1261 popup
.EnableMenuItem(cnt
, m_bFollowRenames
);
1262 popup
.AppendMenuIcon(++cnt
, IDS_PROC_LOG_SELECT_LOCAL_BRANCHES
);
1263 popup
.EnableMenuItem(cnt
, m_bFollowRenames
);
1265 if (m_History
.GetCount() > 0)
1267 popup
.AppendMenu(MF_SEPARATOR
, 0);
1268 for (size_t i
= 0; i
< m_History
.GetCount(); ++i
)
1270 CString entry
= m_History
.GetEntry(i
);
1271 if (entry
.GetLength() > 150)
1272 entry
= entry
.Left(150) + _T("...");
1273 popup
.AppendMenuIcon(cnt
++, entry
);
1277 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1282 OnBnClickedBrowseRef();
1286 m_LogList
.m_ShowMask
&= ~(CGit::LOG_INFO_ALL_BRANCH
| CGit::LOG_INFO_LOCAL_BRANCHES
);
1287 m_bAllBranch
= BST_UNCHECKED
;
1290 SetRange(g_Git
.GetCurrentBranch(true));
1294 SetRange(fetchHead
.ToString());
1298 m_bAllBranch
= BST_CHECKED
;
1299 m_LogList
.m_ShowMask
|= CGit::LOG_INFO_ALL_BRANCH
;
1303 m_bAllBranch
= BST_INDETERMINATE
;
1304 m_LogList
.m_ShowMask
|= CGit::LOG_INFO_LOCAL_BRANCHES
;
1306 else if (cmd
>= offset
)
1308 SetRange(m_History
.GetEntry(cmd
- offset
));
1309 m_History
.AddEntry(m_LogList
.m_sRange
);
1316 FillLogMessageCtrl(false);
1320 int selCount
= m_LogList
.GetSelectedCount();
1321 if ((selCount
== 1)&&(pWnd
== GetDlgItem(IDC_MSGVIEW
)))
1323 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1326 selIndex
= m_LogList
.GetNextSelectedItem(pos
);
1328 GitRevLoglist
* pRev
= ((GitRevLoglist
*)m_LogList
.m_arShownList
[selIndex
]);
1330 if ((point
.x
== -1) && (point
.y
== -1))
1333 GetDlgItem(IDC_MSGVIEW
)->GetClientRect(&rect
);
1334 ClientToScreen(&rect
);
1335 point
= rect
.CenterPoint();
1337 CString sMenuItemText
;
1339 if (popup
.CreatePopupMenu())
1341 long start
= -1, end
= -1;
1342 auto pEdit
= (CRichEditCtrl
*)GetDlgItem(IDC_MSGVIEW
);
1343 pEdit
->GetSel(start
, end
);
1344 // add the 'default' entries
1345 popup
.AppendMenuIcon(WM_COPY
, IDS_SCIEDIT_COPY
, IDI_COPYCLIP
);
1347 popup
.EnableMenuItem(WM_COPY
, MF_BYCOMMAND
| MF_DISABLED
| MF_GRAYED
);
1348 popup
.AppendMenu(MF_SEPARATOR
);
1349 sMenuItemText
.LoadString(IDS_STATUSLIST_CONTEXT_COPYEXT
);
1350 popup
.AppendMenuIcon(EM_SETSEL
, sMenuItemText
, IDI_COPYCLIP
);
1351 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1352 sMenuItemText
.LoadString(IDS_EDIT_NOTES
);
1353 popup
.AppendMenuIcon( CGitLogList::ID_EDITNOTE
, sMenuItemText
, IDI_EDIT
);
1355 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1359 break; // no command selected
1362 pEdit
->SetRedraw(FALSE
);
1363 int oldLine
= pEdit
->GetFirstVisibleLine();
1364 pEdit
->SetSel(0, -1);
1366 pEdit
->SetSel(start
, end
);
1367 int newLine
= pEdit
->GetFirstVisibleLine();
1368 pEdit
->LineScroll(oldLine
- newLine
);
1369 pEdit
->SetRedraw(TRUE
);
1370 pEdit
->RedrawWindow();
1374 ::SendMessage(GetDlgItem(IDC_MSGVIEW
)->GetSafeHwnd(), cmd
, 0, -1);
1376 case CGitLogList::ID_EDITNOTE
:
1377 CAppUtils::EditNote(pRev
);
1378 this->FillLogMessageCtrl(true);
1385 void CLogDlg::OnOK()
1387 // since the log dialog is also used to select revisions for other
1388 // dialogs, we have to do some work before closing this dialog
1389 if (GetFocus() != GetDlgItem(IDOK
))
1390 return; // if the "OK" button doesn't have the focus, do nothing: this prevents closing the dialog when pressing enter
1392 m_LogList
.SafeTerminateAsyncDiffThread();
1393 if (this->IsThreadRunning())
1395 m_LogList
.SafeTerminateThread();
1398 // check that one and only one row is selected
1399 if (m_LogList
.GetSelectedCount() == 1)
1401 // get the selected row
1402 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1403 int selIndex
= m_LogList
.GetNextSelectedItem(pos
);
1404 if (selIndex
< m_LogList
.m_arShownList
.GetCount())
1406 // all ok, pick up the revision
1407 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(selIndex
));
1409 m_sSelectedHash
= pLogEntry
->m_CommitHash
;
1417 if (!GetDlgItem(IDOK
)->IsWindowVisible() && GetFocus() != GetDlgItem(IDCANCEL
))
1418 return; // the Cancel button works as the OK button. But if the cancel button has not the focus, do nothing.
1422 GetDlgItemText(IDOK
, buttontext
);
1423 temp
.LoadString(IDS_MSGBOX_CANCEL
);
1424 if (temp
.Compare(buttontext
) != 0)
1425 __super::OnOK(); // only exit if the button text matches, and that will match only if the thread isn't running anymore
1426 m_bCancelled
= TRUE
;
1427 m_selectedRevs
.Clear();
1428 m_selectedRevsOneRange
.Clear();
1429 if (m_pNotifyWindow
)
1431 int selIndex
= m_LogList
.GetSelectionMark();
1434 PLOGENTRYDATA pLogEntry
= NULL
;
1435 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1436 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(m_LogList
.GetNextSelectedItem(pos
)));
1437 m_selectedRevs
.AddRevision(pLogEntry
->Rev
);
1438 git_revnum_t lowerRev
= pLogEntry
->Rev
;
1439 git_revnum_t higherRev
= lowerRev
;
1442 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(m_LogList
.GetNextSelectedItem(pos
)));
1443 git_revnum_t rev
= pLogEntry
->Rev
;
1444 m_selectedRevs
.AddRevision(pLogEntry
->Rev
);
1447 if (higherRev
< rev
)
1450 if (m_sFilterText
.IsEmpty() && m_nSortColumn
== 0 && IsSelectionContinuous())
1452 m_selectedRevsOneRange
.AddRevRange(lowerRev
, higherRev
);
1454 BOOL bSentMessage
= FALSE
;
1455 if (m_LogList
.GetSelectedCount() == 1)
1457 // if only one revision is selected, check if the path/url with which the dialog was started
1458 // was directly affected in that revision. If it was, then check if our path was copied from somewhere.
1459 // if it was copied, use the copy from revision as lowerRev
1460 if ((pLogEntry
)&&(pLogEntry
->pArChangedPaths
)&&(lowerRev
== higherRev
))
1462 CString sUrl
= m_path
.GetGitPathString();
1463 if (!m_path
.IsUrl())
1465 sUrl
= GetURLFromPath(m_path
);
1467 sUrl
= sUrl
.Mid(m_sRepositoryRoot
.GetLength());
1468 for (int cp
= 0; cp
< pLogEntry
->pArChangedPaths
->GetCount(); ++cp
)
1470 LogChangedPath
* pData
= pLogEntry
->pArChangedPaths
->SafeGetAt(cp
);
1473 if (sUrl
.Compare(pData
->sPath
) == 0)
1475 if (!pData
->sCopyFromPath
.IsEmpty())
1477 lowerRev
= pData
->lCopyFromRev
;
1478 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTSTART
), lowerRev
);
1479 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTEND
), higherRev
);
1480 m_pNotifyWindow
->SendMessage(WM_REVLIST
, m_selectedRevs
.GetCount(), (LPARAM
)&m_selectedRevs
);
1481 bSentMessage
= TRUE
;
1488 if ( !bSentMessage
)
1490 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTSTART
| MERGE_REVSELECTMINUSONE
), lowerRev
);
1491 m_pNotifyWindow
->SendMessage(WM_REVSELECTED
, m_wParam
& (MERGE_REVSELECTEND
| MERGE_REVSELECTMINUSONE
), higherRev
);
1492 m_pNotifyWindow
->SendMessage(WM_REVLIST
, m_selectedRevs
.GetCount(), (LPARAM
)&m_selectedRevs
);
1493 if (m_selectedRevsOneRange
.GetCount())
1494 m_pNotifyWindow
->SendMessage(WM_REVLISTONERANGE
, 0, (LPARAM
)&m_selectedRevsOneRange
);
1499 CRegDWORD
reg(_T("Software\\TortoiseGit\\ShowAllEntry"));
1504 void CLogDlg::DoDiffFromLog(INT_PTR selIndex
, GitRev
* rev1
, GitRev
* rev2
, bool /*blame*/, bool /*unified*/)
1506 DialogEnableWindow(IDOK
, FALSE
);
1507 // SetPromptApp(&theApp);
1508 theApp
.DoWaitCursor(1);
1511 GetTempPath(temppath
);
1514 file1
.Format(_T("%s%s_%s%s"),
1516 (*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1517 rev1
->m_CommitHash
.ToString().Left(g_Git
.GetShortHASHLength()),
1518 (*m_currentChangedArray
)[selIndex
].GetFileExtension());
1521 file2
.Format(_T("%s\\%s_%s%s"),
1523 (*m_currentChangedArray
)[selIndex
].GetBaseFilename(),
1524 rev2
->m_CommitHash
.ToString().Left(g_Git
.GetShortHASHLength()),
1525 (*m_currentChangedArray
)[selIndex
].GetFileExtension());
1528 CTGitPath
&path
= (CTGitPath
&)(*m_currentChangedArray
)[selIndex
];
1530 if (g_Git
.GetOneFile(rev1
->m_CommitHash
.ToString(), path
, file1
))
1533 out
.Format(IDS_STATUSLIST_CHECKOUTFILEFAILED
, path
.GetGitPathString(), rev1
->m_CommitHash
.ToString(), file1
);
1534 CMessageBox::Show(nullptr, g_Git
.GetGitLastErr(out
, CGit::GIT_CMD_GETONEFILE
), _T("TortoiseGit"), MB_OK
);
1535 theApp
.DoWaitCursor(-1);
1539 if (g_Git
.GetOneFile(rev2
->m_CommitHash
.ToString(), path
, file2
))
1542 out
.Format(IDS_STATUSLIST_CHECKOUTFILEFAILED
, path
.GetGitPathString(), rev2
->m_CommitHash
.ToString(), file2
);
1543 CMessageBox::Show(nullptr, g_Git
.GetGitLastErr(out
, CGit::GIT_CMD_GETONEFILE
), _T("TortoiseGit"), MB_OK
);
1544 theApp
.DoWaitCursor(-1);
1549 CAppUtils::DiffFlags flags
;
1550 CAppUtils::StartExtDiff(file1
,file2
,_T("A"),_T("B"),
1551 g_Git
.CombinePath(path
), g_Git
.CombinePath(path
),
1552 rev1
->m_CommitHash
.ToString(), rev2
->m_CommitHash
.ToString(),
1555 theApp
.DoWaitCursor(-1);
1559 BOOL
CLogDlg::PreTranslateMessage(MSG
* pMsg
)
1561 // Skip Ctrl-C when copying text out of the log message or search filter
1562 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);
1563 if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='\r')
1565 if (GetFocus()==GetDlgItem(IDC_LOGLIST
))
1567 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1569 m_LogList
.DiffSelectedRevWithPrevious();
1573 if (GetFocus() == GetDlgItem(IDC_SEARCHEDIT
))
1575 KillTimer(LOGFILTER_TIMER
);
1577 m_LogList
.Refresh(FALSE
);
1578 FillLogMessageCtrl(false);
1580 if (GetFocus() == GetDlgItem(IDC_FILTER
))
1582 KillTimer(FILEFILTER_TIMER
);
1583 FillLogMessageCtrl();
1587 else if (pMsg
->message
== WM_XBUTTONUP
)
1589 bool select
= (pMsg
->wParam
& MK_SHIFT
) == 0;
1590 if (HIWORD(pMsg
->wParam
) & XBUTTON1
)
1591 GoBackForward(select
, false);
1592 if (HIWORD(pMsg
->wParam
) & XBUTTON2
)
1593 GoBackForward(select
, true);
1594 if (HIWORD(pMsg
->wParam
) & (XBUTTON1
| XBUTTON2
))
1597 if (m_hAccel
&& !bSkipAccelerator
)
1599 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
1604 return __super::PreTranslateMessage(pMsg
);
1608 BOOL
CLogDlg::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
1610 //if (this->IsThreadRunning())
1611 if(m_LogList
.m_bNoDispUpdates
)
1613 // only show the wait cursor over the list control
1615 ((pWnd
== GetDlgItem(IDC_LOGLIST
))||
1616 (pWnd
== GetDlgItem(IDC_MSGVIEW
))||
1617 (pWnd
== GetDlgItem(IDC_LOGMSG
))))
1619 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
1624 if ((pWnd
) && (pWnd
== GetDlgItem(IDC_MSGVIEW
)))
1625 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1627 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
1629 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
1632 void CLogDlg::OnLvnItemchangedLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1634 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1636 //if (this->IsThreadRunning())
1637 if(m_LogList
.m_bNoDispUpdates
)
1639 if (pNMLV
->iItem
>= 0)
1641 if (!m_LogList
.m_highlight
.IsEmpty())
1643 m_LogList
.m_highlight
.Empty();
1644 m_LogList
.Invalidate();
1646 this->m_LogList
.m_nSearchIndex
= pNMLV
->iItem
;
1647 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(pNMLV
->iItem
));
1648 if (pLogEntry
== nullptr)
1650 m_LogList
.m_lastSelectedHash
= pLogEntry
->m_CommitHash
;
1651 if (pNMLV
->iSubItem
!= 0)
1653 if ((pNMLV
->iItem
== m_LogList
.m_arShownList
.GetCount()))
1655 // remove the selected state
1656 if (pNMLV
->uChanged
& LVIF_STATE
)
1658 m_LogList
.SetItemState(pNMLV
->iItem
, 0, LVIS_SELECTED
);
1659 FillLogMessageCtrl();
1661 UpdateLogInfoLabel();
1665 if (pNMLV
->uChanged
& LVIF_STATE
)
1667 if ((pNMLV
->uNewState
& LVIS_SELECTED
) && !m_bNavigatingWithSelect
)
1669 m_LogList
.m_selectionHistory
.Add(m_LogList
.m_lastSelectedHash
);
1670 m_LogList
.m_lastSelectedHash
= pLogEntry
->m_CommitHash
;
1672 FillLogMessageCtrl();
1678 m_LogList
.m_lastSelectedHash
.Empty();
1679 FillLogMessageCtrl();
1683 UpdateLogInfoLabel();
1686 void CLogDlg::OnLvnItemchangedLogmsg(NMHDR
* /*pNMHDR*/, LRESULT
* /*pResult*/)
1688 UpdateLogInfoLabel();
1691 void CLogDlg::OnEnLinkMsgview(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1693 ENLINK
*pEnLink
= reinterpret_cast<ENLINK
*>(pNMHDR
);
1694 if ((pEnLink
->msg
== WM_LBUTTONUP
) || (pEnLink
->msg
== WM_SETCURSOR
))
1697 GetDlgItemText(IDC_MSGVIEW
, msg
);
1698 msg
.Replace(_T("\r\n"), _T("\n"));
1699 url
= msg
.Mid(pEnLink
->chrg
.cpMin
, pEnLink
->chrg
.cpMax
-pEnLink
->chrg
.cpMin
);
1700 auto findResult
= m_LogList
.m_ProjectProperties
.FindBugIDPositions(msg
);
1701 if (std::find_if(findResult
.begin(), findResult
.end(),
1702 [=] (const CHARRANGE
&cr
) -> bool { return cr
.cpMin
== pEnLink
->chrg
.cpMin
&& cr
.cpMax
== pEnLink
->chrg
.cpMax
; }
1703 ) != findResult
.end())
1705 url
= m_LogList
.m_ProjectProperties
.GetBugIDUrl(url
);
1706 url
= GetAbsoluteUrlFromRelativeUrl(url
);
1708 if (::PathIsURL(url
))
1710 if (pEnLink
->msg
== WM_LBUTTONUP
)
1711 ShellExecute(this->m_hWnd
, _T("open"), url
, NULL
, NULL
, SW_SHOWDEFAULT
);
1714 static RECT prevRect
= { 0 };
1715 CWnd
* pMsgView
= GetDlgItem(IDC_MSGVIEW
);
1720 pMsgView
->SendMessage(EM_POSFROMCHAR
, (WPARAM
)&pt
, pEnLink
->chrg
.cpMin
);
1723 pMsgView
->SendMessage(EM_POSFROMCHAR
, (WPARAM
)&pt
, pEnLink
->chrg
.cpMax
);
1725 rc
.bottom
= pt
.y
+ 12;
1726 if ((prevRect
.left
!= rc
.left
) || (prevRect
.top
!= rc
.top
))
1728 m_tooltips
.DelTool(pMsgView
, 1);
1729 m_tooltips
.AddTool(pMsgView
, url
, &rc
, 1);
1735 else if(pEnLink
->msg
== WM_LBUTTONUP
)
1738 if (LookLikeGitHash(url
, pos
))
1741 for (int i
= 0; i
< m_LogList
.m_arShownList
.GetCount(); ++i
)
1743 GitRev
*rev
= (GitRev
*)m_LogList
.m_arShownList
.SafeGetAt(i
);
1745 if (rev
->m_CommitHash
.ToString().Left(url
.GetLength()) == url
)
1747 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
1750 int index
= m_LogList
.GetNextSelectedItem(pos
);
1752 m_LogList
.SetItemState(index
, 0, LVIS_SELECTED
);
1754 m_LogList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
1755 m_LogList
.EnsureVisible(i
, FALSE
);
1756 m_LogList
.SetSelectionMark(i
);
1758 PostMessage(WM_TGIT_REFRESH_SELECTION
, 0, 0);
1764 CMessageBox::ShowCheck(GetSafeHwnd(), IDS_PROC_LOG_JUMPNOTFOUND
, IDS_APPNAME
, 1, IDI_INFORMATION
, IDS_OKBUTTON
, 0, 0, _T("NoJumpNotFoundWarning"), IDS_MSGBOX_DONOTSHOWAGAIN
);
1771 void CLogDlg::OnBnClickedStatbutton()
1773 if (this->IsThreadRunning())
1775 if (m_LogList
.m_arShownList
.IsEmpty() || m_LogList
.m_arShownList
.GetCount() == 1 && m_LogList
.m_bShowWC
)
1776 return; // nothing or just the working copy changes are shown, so no statistics.
1777 // the statistics dialog expects the log entries to be sorted by date
1778 SortByColumn(3, false);
1781 m_LogList
.RecalculateShownList(&dlg
.m_ShowList
);
1783 dlg
.m_path
= m_orgPath
;
1785 // restore the previous sorting
1786 SortByColumn(m_nSortColumn
, m_bAscending
);
1787 OnTimer(LOGFILTER_TIMER
);
1790 void CLogDlg::MoveToSameTop(CWnd
*pWndRef
, CWnd
*pWndTarget
)
1792 CRect rcWndPicAuthor
, rcWndMsgView
;
1793 pWndRef
->GetWindowRect(rcWndMsgView
);
1794 ScreenToClient(rcWndMsgView
);
1795 pWndTarget
->GetWindowRect(rcWndPicAuthor
);
1796 ScreenToClient(rcWndPicAuthor
);
1797 int diff
= rcWndMsgView
.top
- rcWndPicAuthor
.top
;
1798 rcWndPicAuthor
.top
+= diff
;
1799 rcWndPicAuthor
.bottom
+= diff
;
1800 pWndTarget
->MoveWindow(rcWndPicAuthor
);
1803 void CLogDlg::DoSizeV1(int delta
)
1806 RemoveAnchor(IDC_LOGLIST
);
1807 RemoveAnchor(IDC_SPLITTERTOP
);
1808 RemoveAnchor(IDC_MSGVIEW
);
1809 RemoveAnchor(IDC_PIC_AUTHOR
);
1810 RemoveAnchor(IDC_SPLITTERBOTTOM
);
1811 RemoveAnchor(IDC_LOGMSG
);
1812 CSplitterControl::ChangeHeight(&m_LogList
, delta
, CW_TOPALIGN
);
1813 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW
), -delta
, CW_BOTTOMALIGN
);
1814 MoveToSameTop(GetDlgItem(IDC_MSGVIEW
), GetDlgItem(IDC_PIC_AUTHOR
));
1815 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
1816 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
1817 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
1818 AddAnchor(IDC_PIC_AUTHOR
, TOP_RIGHT
);
1819 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
1820 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
1824 m_LogList
.Invalidate();
1825 GetDlgItem(IDC_MSGVIEW
)->Invalidate();
1826 m_gravatar
.Invalidate();
1830 void CLogDlg::DoSizeV2(int delta
)
1833 RemoveAnchor(IDC_LOGLIST
);
1834 RemoveAnchor(IDC_SPLITTERTOP
);
1835 RemoveAnchor(IDC_MSGVIEW
);
1836 RemoveAnchor(IDC_PIC_AUTHOR
);
1837 RemoveAnchor(IDC_SPLITTERBOTTOM
);
1838 RemoveAnchor(IDC_LOGMSG
);
1839 CSplitterControl::ChangeHeight(GetDlgItem(IDC_MSGVIEW
), delta
, CW_TOPALIGN
);
1840 CSplitterControl::ChangeHeight(&m_ChangedFileListCtrl
, -delta
, CW_BOTTOMALIGN
);
1841 AddAnchor(IDC_LOGLIST
, TOP_LEFT
, TOP_RIGHT
);
1842 AddAnchor(IDC_SPLITTERTOP
, TOP_LEFT
, TOP_RIGHT
);
1843 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
1844 AddAnchor(IDC_PIC_AUTHOR
, TOP_RIGHT
);
1845 AddAnchor(IDC_SPLITTERBOTTOM
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
1846 AddAnchor(IDC_LOGMSG
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
1850 GetDlgItem(IDC_MSGVIEW
)->Invalidate();
1851 m_ChangedFileListCtrl
.Invalidate();
1852 m_gravatar
.Invalidate();
1856 void CLogDlg::AdjustMinSize()
1858 // adjust the minimum size of the dialog to prevent the resizing from
1859 // moving the list control too far down.
1860 CRect rcChgListView
;
1861 m_ChangedFileListCtrl
.GetClientRect(rcChgListView
);
1863 m_LogList
.GetClientRect(rcLogList
);
1865 SetMinTrackSize(CSize(m_DlgOrigRect
.Width(),
1866 m_DlgOrigRect
.Height()-m_ChgOrigRect
.Height()-m_LogListOrigRect
.Height()-m_MsgViewOrigRect
.Height()
1867 +rcChgListView
.Height()+rcLogList
.Height()+60));
1870 LRESULT
CLogDlg::DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
)
1874 if (wParam
== IDC_SPLITTERTOP
)
1876 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
1877 DoSizeV1(pHdr
->delta
);
1879 else if (wParam
== IDC_SPLITTERBOTTOM
)
1881 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
1882 DoSizeV2(pHdr
->delta
);
1887 return CResizableDialog::DefWindowProc(message
, wParam
, lParam
);
1890 void CLogDlg::SetSplitterRange()
1892 if ((m_LogList
)&&(m_ChangedFileListCtrl
))
1895 m_LogList
.GetWindowRect(rcTop
);
1896 ScreenToClient(rcTop
);
1898 GetDlgItem(IDC_MSGVIEW
)->GetWindowRect(rcMiddle
);
1899 ScreenToClient(rcMiddle
);
1900 m_wndSplitter1
.SetRange(rcTop
.top
+30, rcMiddle
.bottom
-20);
1902 m_ChangedFileListCtrl
.GetWindowRect(rcBottom
);
1903 ScreenToClient(rcBottom
);
1904 m_wndSplitter2
.SetRange(rcMiddle
.top
+30, rcBottom
.bottom
-20);
1908 void CLogDlg::OnEnscrollMsgview()
1910 m_tooltips
.DelTool(GetDlgItem(IDC_MSGVIEW
), 1);
1913 LRESULT
CLogDlg::OnClickedInfoIcon(WPARAM wParam
, LPARAM lParam
)
1915 if ((HWND
)wParam
== m_cFileFilter
.GetSafeHwnd())
1918 // FIXME: x64 version would get this function called with unexpected parameters.
1922 RECT
* rect
= (LPRECT
)lParam
;
1925 point
= CPoint(rect
->left
, rect
->bottom
);
1926 #define LOGMENUFLAGS(x) (MF_STRING | MF_ENABLED | ((m_LogList.m_SelectedFilters & x) ? MF_CHECKED : MF_UNCHECKED))
1928 if (popup
.CreatePopupMenu())
1930 temp
.LoadString(IDS_LOG_FILTER_SUBJECT
);
1931 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_SUBJECT
), LOGFILTER_SUBJECT
, temp
);
1933 temp
.LoadString(IDS_LOG_FILTER_MESSAGES
);
1934 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_MESSAGES
), LOGFILTER_MESSAGES
, temp
);
1936 temp
.LoadString(IDS_LOG_FILTER_PATHS
);
1937 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_PATHS
), LOGFILTER_PATHS
, temp
);
1939 temp
.LoadString(IDS_LOG_FILTER_AUTHORS
);
1940 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_AUTHORS
), LOGFILTER_AUTHORS
, temp
);
1942 temp
.LoadString(IDS_LOG_FILTER_EMAILS
);
1943 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_EMAILS
), LOGFILTER_EMAILS
, temp
);
1945 temp
.LoadString(IDS_LOG_FILTER_REVS
);
1946 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_REVS
), LOGFILTER_REVS
, temp
);
1948 temp
.LoadString(IDS_LOG_FILTER_REFNAME
);
1949 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_REFNAME
), LOGFILTER_REFNAME
, temp
);
1951 if (m_LogList
.m_bShowBugtraqColumn
== TRUE
) {
1952 temp
.LoadString(IDS_LOG_FILTER_BUGIDS
);
1953 popup
.AppendMenu(LOGMENUFLAGS(LOGFILTER_BUGID
), LOGFILTER_BUGID
, temp
);
1956 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1958 temp
.LoadString(IDS_LOG_FILTER_TOGGLE
);
1959 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, LOGFILTER_TOGGLE
, temp
);
1961 temp
.LoadString(IDS_ALL
);
1962 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, LOGFILTER_ALL
, temp
);
1964 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1966 temp
.LoadString(IDS_LOG_FILTER_REGEX
);
1967 popup
.AppendMenu(MF_STRING
| MF_ENABLED
| (m_bFilterWithRegex
? MF_CHECKED
: MF_UNCHECKED
), LOGFILTER_REGEX
, temp
);
1969 temp
.LoadString(IDS_LOG_FILTER_CASESENSITIVE
);
1970 popup
.AppendMenu(MF_STRING
| MF_ENABLED
| (m_bFilterCaseSensitively
? MF_CHECKED
: MF_UNCHECKED
), LOGFILTER_CASE
, temp
);
1973 int selection
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1977 if (selection
== LOGFILTER_REGEX
)
1979 m_bFilterWithRegex
= !m_bFilterWithRegex
;
1980 CRegDWORD
b(_T("Software\\TortoiseGit\\UseRegexFilter"), FALSE
);
1981 b
= m_bFilterWithRegex
;
1982 m_LogList
.m_bFilterWithRegex
= m_bFilterWithRegex
;
1984 CheckRegexpTooltip();
1986 else if (selection
== LOGFILTER_CASE
)
1988 m_bFilterCaseSensitively
= !m_bFilterCaseSensitively
;
1989 CRegDWORD
b(_T("Software\\TortoiseGit\\FilterCaseSensitively"), FALSE
);
1990 b
= m_bFilterCaseSensitively
;
1991 m_LogList
.m_bFilterCaseSensitively
= m_bFilterCaseSensitively
;
1993 else if (selection
== LOGFILTER_TOGGLE
)
1995 m_LogList
.m_SelectedFilters
= (~m_LogList
.m_SelectedFilters
) & LOGFILTER_ALL
;
1998 else if (selection
== LOGFILTER_ALL
)
2000 m_LogList
.m_SelectedFilters
= selection
;
2005 m_LogList
.m_SelectedFilters
^= selection
;
2008 CRegDWORD(_T("Software\\TortoiseGit\\SelectedLogFilters")) = m_LogList
.m_SelectedFilters
;
2009 // Reload only if a search text is entered
2010 if (m_LogList
.HasFilterText())
2011 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
2017 LRESULT
CLogDlg::OnClickedCancelFilter(WPARAM wParam
, LPARAM
/*lParam*/)
2019 if ((HWND
)wParam
== m_cFileFilter
.GetSafeHwnd())
2021 KillTimer(FILEFILTER_TIMER
);
2023 FillLogMessageCtrl();
2027 KillTimer(LOGFILTER_TIMER
);
2029 m_LogList
.m_sFilterText
.Empty();
2031 theApp
.DoWaitCursor(1);
2032 CStoreSelection
storeselection(this);
2033 FillLogMessageCtrl(false);
2035 m_LogList
.RemoveFilter();
2040 m_LogList
.GetTimeRange(begin
,end
);
2041 m_DateFrom
.SetTime(&begin
);
2042 m_DateTo
.SetTime(&end
);
2044 theApp
.DoWaitCursor(-1);
2045 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
2046 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
2047 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2048 UpdateLogInfoLabel();
2054 void CLogDlg::SetFilterCueText()
2056 CString
temp(MAKEINTRESOURCE(IDS_LOG_FILTER_BY
));
2059 if (m_LogList
.m_SelectedFilters
& LOGFILTER_SUBJECT
)
2061 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_SUBJECT
));
2064 if (m_LogList
.m_SelectedFilters
& LOGFILTER_MESSAGES
)
2066 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
2068 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_MESSAGES
));
2071 if (m_LogList
.m_SelectedFilters
& LOGFILTER_PATHS
)
2073 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
2075 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_PATHS
));
2078 if (m_LogList
.m_SelectedFilters
& LOGFILTER_AUTHORS
)
2080 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
2082 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_AUTHORS
));
2085 if (m_LogList
.m_SelectedFilters
& LOGFILTER_EMAILS
)
2087 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
2089 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_EMAILS
));
2092 if (m_LogList
.m_SelectedFilters
& LOGFILTER_REVS
)
2094 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
2096 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_REVS
));
2099 if (m_LogList
.m_SelectedFilters
& LOGFILTER_REFNAME
)
2101 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
2103 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_REFNAME
));
2106 if (m_LogList
.m_bShowBugtraqColumn
&& m_LogList
.m_SelectedFilters
& LOGFILTER_BUGID
)
2108 if (temp
.ReverseFind(_T(' ')) != temp
.GetLength() - 1)
2110 temp
+= CString(MAKEINTRESOURCE(IDS_LOG_FILTER_BUGIDS
));
2113 // to make the cue banner text appear more to the right of the edit control
2114 temp
= _T(" ")+temp
;
2115 m_cFilter
.SetCueBanner(temp
.TrimRight());
2118 bool CLogDlg::Validate(LPCTSTR string
)
2120 if (!m_bFilterWithRegex
)
2122 std::tr1::wregex pat
;
2123 return m_LogList
.ValidateRegexp(string
, pat
, false);
2126 void CLogDlg::OnEnChangeFileFilter()
2128 SetTimer(FILEFILTER_TIMER
, 1000, NULL
);
2131 void CLogDlg::OnTimer(UINT_PTR nIDEvent
)
2133 if (nIDEvent
== LOGFTIME_TIMER
)
2135 KillTimer(LOGFTIME_TIMER
);
2137 m_LogList
.Refresh(FALSE
);
2138 FillLogMessageCtrl(false);
2140 else if (nIDEvent
== LOG_FILLPATCHVTIMER
)
2144 else if (nIDEvent
== LOGFILTER_TIMER
)
2146 KillTimer(LOGFILTER_TIMER
);
2148 m_LogList
.Refresh(FALSE
);
2149 FillLogMessageCtrl(false);
2152 /* we will use git built-in grep to filter log */
2153 if (this->IsThreadRunning())
2155 // thread still running! So just restart the timer.
2156 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
2159 CWnd
* focusWnd
= GetFocus();
2160 bool bSetFocusToFilterControl
= ((focusWnd
!= GetDlgItem(IDC_DATEFROM
))&&(focusWnd
!= GetDlgItem(IDC_DATETO
))
2161 && (focusWnd
!= GetDlgItem(IDC_LOGLIST
)));
2162 if (m_LogList
.m_sFilterText
.IsEmpty())
2164 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
2165 // do not return here!
2166 // we also need to run the filter if the filter text is empty:
2167 // 1. to clear an existing filter
2168 // 2. to rebuild the m_arShownList after sorting
2170 theApp
.DoWaitCursor(1);
2171 CStoreSelection
storeselection(this);
2172 KillTimer(LOGFILTER_TIMER
);
2173 FillLogMessageCtrl(false);
2175 // now start filter the log list
2176 m_LogList
.StartFilter();
2178 if ( m_LogList
.GetItemCount()==1 )
2180 m_LogList
.SetSelectionMark(0);
2181 m_LogList
.SetItemState(0, LVIS_SELECTED
, LVIS_SELECTED
);
2183 theApp
.DoWaitCursor(-1);
2184 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
2185 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
2186 if (bSetFocusToFilterControl
)
2187 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2188 UpdateLogInfoLabel();
2190 } // if (nIDEvent == LOGFILTER_TIMER)
2191 else if (nIDEvent
== LOG_HEADER_ORDER_TIMER
)
2193 KillTimer(LOG_HEADER_ORDER_TIMER
);
2194 CLogOrdering orderDlg
;
2195 if (orderDlg
.DoModal() == IDOK
)
2198 else if (nIDEvent
== FILEFILTER_TIMER
)
2200 KillTimer(FILEFILTER_TIMER
);
2201 FillLogMessageCtrl();
2203 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty() || m_LogList
.m_arShownList
.GetCount() == 1 && m_LogList
.m_bShowWC
))));
2204 __super::OnTimer(nIDEvent
);
2207 void CLogDlg::OnDtnDatetimechangeDateto(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2212 m_DateTo
.GetTime(_time
);
2214 CTime
time(_time
.GetYear(), _time
.GetMonth(), _time
.GetDay(), 23, 59, 59);
2215 if (time
.GetTime() != m_LogList
.m_To
)
2217 m_LogList
.m_To
= (DWORD
)time
.GetTime();
2218 SetTimer(LOGFTIME_TIMER
, 10, NULL
);
2223 CMessageBox::Show(NULL
,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2229 void CLogDlg::OnDtnDatetimechangeDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2235 m_DateFrom
.GetTime(_time
);
2237 CTime
time(_time
.GetYear(), _time
.GetMonth(), _time
.GetDay(), 0, 0, 0);
2238 if (time
.GetTime() != m_LogList
.m_From
)
2240 m_LogList
.m_From
= (DWORD
)time
.GetTime();
2241 SetTimer(LOGFTIME_TIMER
, 10, NULL
);
2246 CMessageBox::Show(NULL
,_T("Invalidate Parameter"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
2252 void CLogDlg::OnCbnSelchangeJumpType()
2254 // reserved for future use
2257 void CLogDlg::OnBnClickedJumpUp()
2259 int sel
= m_JumpType
.GetCurSel();
2260 if (sel
< 0) return;
2261 JumpType jumpType
= (JumpType
)sel
;
2263 if (jumpType
== JumpType_History
)
2272 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2275 index
= m_LogList
.GetNextSelectedItem(pos
);
2276 if (index
== 0) return;
2278 GitRev
* data
= (GitRev
*)m_LogList
.m_arShownList
.SafeGetAt(index
);
2279 if (jumpType
== JumpType_AuthorEmail
)
2280 strValue
= data
->GetAuthorEmail();
2281 else if (jumpType
== JumpType_CommitterEmail
)
2282 strValue
= data
->GetCommitterEmail();
2283 else if (jumpType
== JumpType_Parent1
)
2284 hashValue
= data
->m_CommitHash
;
2285 else if (jumpType
== JumpType_Parent2
)
2286 hashValue
= data
->m_CommitHash
;
2287 else if (jumpType
== JumpType_TagFF
)
2288 hashValue
= data
->m_CommitHash
;
2289 else if (jumpType
== JumpType_BranchFF
)
2290 hashValue
= data
->m_CommitHash
;
2292 m_LogList
.SetItemState(index
, 0, LVIS_SELECTED
);
2299 index
= m_LogList
.GetNextSelectedItem(pos
);
2300 m_LogList
.SetItemState(index
, 0, LVIS_SELECTED
);
2302 m_LogList
.SetSelectionMark(-1);
2304 for (int i
= index
- 1; i
>= 0; i
--)
2307 GitRev
* data
= (GitRev
*)m_LogList
.m_arShownList
.SafeGetAt(i
);
2308 if (jumpType
== JumpType_AuthorEmail
)
2309 found
= strValue
== data
->GetAuthorEmail();
2310 else if (jumpType
== JumpType_CommitterEmail
)
2311 found
= strValue
== data
->GetCommitterEmail();
2312 else if (jumpType
== JumpType_MergePoint
)
2313 found
= data
->ParentsCount() > 1;
2314 else if (jumpType
== JumpType_Parent1
)
2316 if (data
->m_ParentHash
.size() > 0)
2317 found
= data
->m_ParentHash
[0] == hashValue
;
2319 else if (jumpType
== JumpType_Parent2
)
2321 if (data
->m_ParentHash
.size() > 1)
2322 found
= data
->m_ParentHash
[1] == hashValue
;
2324 else if (jumpType
== JumpType_Tag
|| jumpType
== JumpType_TagFF
)
2326 STRING_VECTOR refList
= m_LogList
.m_HashMap
[data
->m_CommitHash
];
2327 for (size_t j
= 0; j
< refList
.size(); ++j
)
2329 if (refList
[j
].Left(10) == _T("refs/tags/"))
2336 if (found
&& jumpType
== JumpType_TagFF
)
2337 found
= g_Git
.IsFastForward(hashValue
, data
->m_CommitHash
);
2339 else if (jumpType
== JumpType_Branch
|| jumpType
== JumpType_BranchFF
)
2341 STRING_VECTOR refList
= m_LogList
.m_HashMap
[data
->m_CommitHash
];
2342 for (size_t j
= 0; j
< refList
.size(); ++j
)
2344 if (refList
[j
].Left(11) == _T("refs/heads/") || refList
[j
].Left(13) == _T("refs/remotes/"))
2351 if (found
&& jumpType
== JumpType_BranchFF
)
2352 found
= g_Git
.IsFastForward(hashValue
, data
->m_CommitHash
);
2357 m_LogList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
2358 m_LogList
.EnsureVisible(i
, FALSE
);
2359 m_LogList
.SetSelectionMark(i
);
2364 CMessageBox::ShowCheck(GetSafeHwnd(), IDS_PROC_LOG_JUMPNOTFOUND
, IDS_APPNAME
, 1, IDI_INFORMATION
, IDS_OKBUTTON
, 0, 0, _T("NoJumpNotFoundWarning"), IDS_MSGBOX_DONOTSHOWAGAIN
);
2367 void CLogDlg::OnBnClickedJumpDown()
2369 int jumpType
= m_JumpType
.GetCurSel();
2370 if (jumpType
< 0) return;
2372 if (jumpType
== JumpType_History
)
2381 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2384 index
= m_LogList
.GetNextSelectedItem(pos
);
2385 if (index
== 0) return;
2387 GitRev
* data
= (GitRev
*)m_LogList
.m_arShownList
.SafeGetAt(index
);
2388 if (jumpType
== JumpType_AuthorEmail
)
2389 strValue
= data
->GetAuthorEmail();
2390 else if (jumpType
== JumpType_CommitterEmail
)
2391 strValue
= data
->GetCommitterEmail();
2392 else if (jumpType
== JumpType_Parent1
)
2394 if (data
->m_ParentHash
.size() > 0)
2395 hashValue
= data
->m_ParentHash
.at(0);
2399 else if (jumpType
== JumpType_Parent2
)
2401 if (data
->m_ParentHash
.size() > 1)
2402 hashValue
= data
->m_ParentHash
.at(1);
2406 else if (jumpType
== JumpType_TagFF
)
2407 hashValue
= data
->m_CommitHash
;
2408 else if (jumpType
== JumpType_BranchFF
)
2409 hashValue
= data
->m_CommitHash
;
2411 m_LogList
.SetItemState(index
, 0, LVIS_SELECTED
);
2418 index
= m_LogList
.GetNextSelectedItem(pos
);
2419 m_LogList
.SetItemState(index
, 0, LVIS_SELECTED
);
2421 m_LogList
.SetSelectionMark(-1);
2423 for (int i
= index
+ 1; i
< m_LogList
.GetItemCount(); ++i
)
2426 GitRev
* data
= (GitRev
*)m_LogList
.m_arShownList
.SafeGetAt(i
);
2427 if (jumpType
== JumpType_AuthorEmail
)
2428 found
= strValue
== data
->GetAuthorEmail();
2429 else if (jumpType
== JumpType_CommitterEmail
)
2430 found
= strValue
== data
->GetCommitterEmail();
2431 else if (jumpType
== JumpType_MergePoint
)
2432 found
= data
->ParentsCount() > 1;
2433 else if (jumpType
== JumpType_Parent1
)
2434 found
= data
->m_CommitHash
== hashValue
;
2435 else if (jumpType
== JumpType_Parent2
)
2436 found
= data
->m_CommitHash
== hashValue
;
2437 else if (jumpType
== JumpType_Tag
|| jumpType
== JumpType_TagFF
)
2439 STRING_VECTOR refList
= m_LogList
.m_HashMap
[data
->m_CommitHash
];
2440 for (size_t j
= 0; j
< refList
.size(); ++j
)
2442 if (refList
[j
].Left(10) == _T("refs/tags/"))
2449 if (found
&& jumpType
== JumpType_TagFF
)
2450 found
= g_Git
.IsFastForward(data
->m_CommitHash
, hashValue
);
2452 else if (jumpType
== JumpType_Branch
|| jumpType
== JumpType_BranchFF
)
2454 STRING_VECTOR refList
= m_LogList
.m_HashMap
[data
->m_CommitHash
];
2455 for (size_t j
= 0; j
< refList
.size(); ++j
)
2457 if (refList
[j
].Left(11) == _T("refs/heads/") || refList
[j
].Left(13) == _T("refs/remotes/"))
2464 if (found
&& jumpType
== JumpType_BranchFF
)
2465 found
= g_Git
.IsFastForward(data
->m_CommitHash
, hashValue
);
2470 m_LogList
.SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
2471 m_LogList
.EnsureVisible(i
, FALSE
);
2472 m_LogList
.SetSelectionMark(i
);
2477 CMessageBox::ShowCheck(GetSafeHwnd(), IDS_PROC_LOG_JUMPNOTFOUND
, IDS_APPNAME
, 1, IDI_INFORMATION
, IDS_OKBUTTON
, 0, 0, _T("NoJumpNotFoundWarning"), IDS_MSGBOX_DONOTSHOWAGAIN
);
2480 CTGitPathList
CLogDlg::GetChangedPathsFromSelectedRevisions(bool /*bRelativePaths*/ /* = false */, bool /*bUseFilter*/ /* = true */)
2482 CTGitPathList pathList
;
2485 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2487 m_sRepositoryRoot
= GetRepositoryRoot(m_path
);
2489 if (m_sRepositoryRoot
.IsEmpty() && (bRelativePaths
== false))
2492 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2497 int nextpos
= m_LogList
.GetNextSelectedItem(pos
);
2498 if (nextpos
>= m_arShownList
.GetCount())
2500 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(nextpos
));
2501 LogChangedPathArray
* cpatharray
= pLogEntry
->pArChangedPaths
;
2502 for (INT_PTR cpPathIndex
= 0; cpPathIndex
<cpatharray
->GetCount(); ++cpPathIndex
)
2504 LogChangedPath
* cpath
= cpatharray
->SafeGetAt(cpPathIndex
);
2508 if (!bRelativePaths
)
2509 path
.SetFromGit(m_sRepositoryRoot
);
2510 path
.AppendPathString(cpath
->sPath
);
2512 ((m_cHidePaths
.GetState() & 0x0003)!=BST_CHECKED
)||
2513 (cpath
->sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0))
2514 pathList
.AddPath(path
);
2519 pathList
.RemoveDuplicates();
2524 void CLogDlg::SortByColumn(int /*nSortColumn*/, bool /*bAscending*/)
2532 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscRevSort());
2534 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescRevSort());
2540 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscActionSort());
2542 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescActionSort());
2548 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscAuthorSort());
2550 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescAuthorSort());
2556 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscDateSort());
2558 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescDateSort());
2561 case 4: // Message or bug id
2562 if (m_bShowBugtraqColumn
)
2565 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscBugIDSort());
2567 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescBugIDSort());
2570 // fall through here
2574 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::AscMessageSort());
2576 std::sort(m_logEntries
.begin(), m_logEntries
.end(), CLogDataVector::DescMessageSort());
2586 void CLogDlg::OnLvnColumnclick(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2588 if (this->IsThreadRunning())
2589 return; //no sorting while the arrays are filled
2591 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
2592 const int nColumn
= pNMLV
->iSubItem
;
2593 m_bAscending
= nColumn
== m_nSortColumn
? !m_bAscending
: TRUE
;
2594 m_nSortColumn
= nColumn
;
2595 SortByColumn(m_nSortColumn
, m_bAscending
);
2596 SetSortArrow(&m_LogList
, m_nSortColumn
, !!m_bAscending
);
2597 SortShownListArray();
2598 m_LogList
.Invalidate();
2599 UpdateLogInfoLabel();
2601 UNREFERENCED_PARAMETER(pNMHDR
);
2605 SetTimer(LOG_HEADER_ORDER_TIMER
, 10, nullptr);
2608 void CLogDlg::SortShownListArray()
2610 // make sure the shown list still matches the filter after sorting.
2611 OnTimer(LOGFILTER_TIMER
);
2612 // clear the selection states
2613 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2616 m_LogList
.SetItemState(m_LogList
.GetNextSelectedItem(pos
), 0, LVIS_SELECTED
);
2618 m_LogList
.SetSelectionMark(-1);
2621 void CLogDlg::SetSortArrow(CListCtrl
* control
, int nColumn
, bool bAscending
)
2623 if (control
== NULL
)
2625 // set the sort arrow
2626 CHeaderCtrl
* pHeader
= control
->GetHeaderCtrl();
2627 HDITEM HeaderItem
= {0};
2628 HeaderItem
.mask
= HDI_FORMAT
;
2629 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
2631 pHeader
->GetItem(i
, &HeaderItem
);
2632 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
2633 pHeader
->SetItem(i
, &HeaderItem
);
2637 pHeader
->GetItem(nColumn
, &HeaderItem
);
2638 HeaderItem
.fmt
|= (bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
2639 pHeader
->SetItem(nColumn
, &HeaderItem
);
2643 int CLogDlg::m_nSortColumnPathList
= 0;
2644 bool CLogDlg::m_bAscendingPathList
= false;
2646 void CLogDlg::OnBnClickedHidepaths()
2648 FillLogMessageCtrl();
2649 m_ChangedFileListCtrl
.Invalidate();
2652 void CLogDlg::UpdateLogInfoLabel()
2657 long selectedrevs
= 0;
2658 long selectedfiles
= 0;
2659 int count
= (int)m_LogList
.m_arShownList
.GetCount();
2663 rev1
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(0)))->m_CommitHash
;
2664 if(this->m_LogList
.m_bShowWC
&& rev1
.IsEmpty()&&(count
>1))
2666 rev1
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(start
)))->m_CommitHash
;
2667 //pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(m_arShownList.GetCount()-1));
2668 rev2
= (reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(count
-1)))->m_CommitHash
;
2669 selectedrevs
= m_LogList
.GetSelectedCount();
2671 selectedfiles
= m_ChangedFileListCtrl
.GetSelectedCount();
2674 sTemp
.Format(IDS_PROC_LOG_STATS
,
2676 rev2
.ToString().Left(g_Git
.GetShortHASHLength()), rev1
.ToString().Left(g_Git
.GetShortHASHLength()), selectedrevs
, selectedfiles
);
2678 if(selectedrevs
== 1)
2680 CString str
=m_ChangedFileListCtrl
.GetStatisticsString(true);
2681 str
.Replace(_T('\n'), _T(' '));
2682 sTemp
+= _T("\r\n") + str
;
2689 void CLogDlg::OnDtnDropdownDatefrom(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2691 // the date control should not show the "today" button
2692 CMonthCalCtrl
* pCtrl
= m_DateFrom
.GetMonthCalCtrl();
2694 SetWindowLongPtr(pCtrl
->GetSafeHwnd(), GWL_STYLE
, LONG_PTR(pCtrl
->GetStyle() | MCS_NOTODAY
));
2698 void CLogDlg::OnDtnDropdownDateto(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2700 // the date control should not show the "today" button
2701 CMonthCalCtrl
* pCtrl
= m_DateTo
.GetMonthCalCtrl();
2703 SetWindowLongPtr(pCtrl
->GetSafeHwnd(), GWL_STYLE
, LONG_PTR(pCtrl
->GetStyle() | MCS_NOTODAY
));
2707 void CLogDlg::OnSize(UINT nType
, int cx
, int cy
)
2709 __super::OnSize(nType
, cx
, cy
);
2714 void CLogDlg::OnRefresh()
2718 this->m_LogProgress
.SetPos(0);
2724 void CLogDlg::OnFocusFilter()
2726 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2729 void CLogDlg::OnEditCopy()
2731 if (GetFocus() == &m_ChangedFileListCtrl
)
2732 CopyChangedSelectionToClipBoard();
2734 m_LogList
.CopySelectionToClipBoard();
2737 CString
CLogDlg::GetAbsoluteUrlFromRelativeUrl(const CString
& url
)
2739 // is the URL a relative one?
2740 if (url
.Left(2).Compare(_T("^/")) == 0)
2742 // URL is relative to the repository root
2743 CString url1
= m_sRepositoryRoot
+ url
.Mid(1);
2744 TCHAR buf
[INTERNET_MAX_URL_LENGTH
] = { 0 };
2745 DWORD len
= url
.GetLength();
2746 if (UrlCanonicalize((LPCTSTR
)url1
, buf
, &len
, 0) == S_OK
)
2747 return CString(buf
, len
);
2750 else if (url
[0] == '/')
2752 // URL is relative to the server's hostname
2754 // find the server's hostname
2755 int schemepos
= m_sRepositoryRoot
.Find(_T("//"));
2758 sHost
= m_sRepositoryRoot
.Left(m_sRepositoryRoot
.Find('/', schemepos
+3));
2759 CString url1
= sHost
+ url
;
2760 TCHAR buf
[INTERNET_MAX_URL_LENGTH
] = { 0 };
2761 DWORD len
= url
.GetLength();
2762 if (UrlCanonicalize((LPCTSTR
)url
, buf
, &len
, 0) == S_OK
)
2763 return CString(buf
, len
);
2770 void CLogDlg::ShowGravatar()
2772 m_gravatar
.EnableGravatar(m_bShowGravatar
);
2773 RemoveAnchor(IDC_MSGVIEW
);
2774 if (m_gravatar
.IsGravatarEnabled())
2777 GetDlgItem(IDC_MSGVIEW
)->GetWindowRect(&rect
);
2778 ScreenToClient(&rect
);
2779 m_gravatar
.GetWindowRect(&rect2
);
2780 ScreenToClient(&rect2
);
2781 rect
.right
= rect2
.left
;
2782 GetDlgItem(IDC_MSGVIEW
)->MoveWindow(&rect
);
2783 m_gravatar
.ShowWindow(SW_SHOW
);
2788 GetDlgItem(IDC_MSGVIEW
)->GetWindowRect(&rect
);
2789 ScreenToClient(&rect
);
2790 m_gravatar
.GetWindowRect(&rect2
);
2791 ScreenToClient(&rect2
);
2792 rect
.right
= rect2
.right
;
2793 GetDlgItem(IDC_MSGVIEW
)->MoveWindow(&rect
);
2794 m_gravatar
.ShowWindow(SW_HIDE
);
2796 AddAnchor(IDC_MSGVIEW
, TOP_LEFT
, BOTTOM_RIGHT
);
2800 void CLogDlg::OnEnChangeSearchedit()
2803 if (!m_LogList
.HasFilterText())
2805 CStoreSelection
storeselection(this);
2806 // clear the filter, i.e. make all entries appear
2807 theApp
.DoWaitCursor(1);
2808 KillTimer(LOGFILTER_TIMER
);
2809 FillLogMessageCtrl(false);
2812 //m_LogList.StartFilter();
2814 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2815 m_arShownList
.RemoveAll();
2816 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
2818 if (IsEntryInDateRange(i
))
2819 m_arShownList
.Add(m_logEntries
[i
]);
2821 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2822 m_LogList
.DeleteAllItems();
2823 m_LogList
.SetItemCountEx(ShownCountWithStopped());
2824 m_LogList
.RedrawItems(0, ShownCountWithStopped());
2825 m_LogList
.SetRedraw(false);
2826 ResizeAllListCtrlCols();
2827 m_LogList
.SetRedraw(true);
2829 theApp
.DoWaitCursor(-1);
2830 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_HIDE
);
2831 GetDlgItem(IDC_SEARCHEDIT
)->ShowWindow(SW_SHOW
);
2832 GetDlgItem(IDC_SEARCHEDIT
)->SetFocus();
2833 DialogEnableWindow(IDC_STATBUTTON
, !(((this->IsThreadRunning())||(m_LogList
.m_arShownList
.IsEmpty()))));
2836 if (Validate(m_LogList
.m_sFilterText
))
2837 SetTimer(LOGFILTER_TIMER
, 1000, NULL
);
2839 KillTimer(LOGFILTER_TIMER
);
2843 void CLogDlg::OnBnClickedAllBranch()
2845 // m_bAllBranch is not auto-toggled by MFC, we have to handle it manually (in order to prevent the indeterminate state)
2847 m_LogList
.m_ShowMask
&=~ (CGit::LOG_INFO_LOCAL_BRANCHES
| CGit::LOG_INFO_ALL_BRANCH
);
2851 m_bAllBranch
= BST_UNCHECKED
;
2852 m_ChangedFileListCtrl
.m_sDisplayedBranch
= m_LogList
.GetRange();
2856 m_bAllBranch
= BST_CHECKED
;
2857 m_LogList
.m_ShowMask
|=CGit::LOG_INFO_ALL_BRANCH
;
2858 m_ChangedFileListCtrl
.m_sDisplayedBranch
.Empty();
2861 // need to save value here, so that log dialogs started from now on also have AllBranch activated
2862 m_regbAllBranch
= m_bAllBranch
;
2868 FillLogMessageCtrl(false);
2871 void CLogDlg::OnBnClickedFollowRenames()
2873 if(m_bFollowRenames
)
2875 m_LogList
.m_ShowMask
|= CGit::LOG_INFO_FOLLOW
;
2876 m_LogList
.m_ShowMask
&=~ CGit::LOG_INFO_LOCAL_BRANCHES
;
2880 m_bAllBranch
= FALSE
;
2881 m_LogList
.m_ShowMask
&=~ CGit::LOG_INFO_ALL_BRANCH
;
2886 m_LogList
.m_ShowMask
&= ~CGit::LOG_INFO_FOLLOW
;
2888 DialogEnableWindow(IDC_LOG_ALLBRANCH
, !m_bFollowRenames
);
2889 DialogEnableWindow(IDC_SHOWWHOLEPROJECT
, !m_bFollowRenames
&& !m_path
.IsEmpty());
2893 FillLogMessageCtrl(false);
2896 void CLogDlg::HandleShowLabels(bool var
, int flag
)
2899 m_LogList
.m_ShowRefMask
|= flag
;
2901 m_LogList
.m_ShowRefMask
&= ~flag
;
2903 if ((m_LogList
.m_ShowFilter
& CGitLogListBase::FILTERSHOW_REFS
) && !(m_LogList
.m_ShowFilter
& CGitLogListBase::FILTERSHOW_ANYCOMMIT
))
2905 // Remove commits where labels are not shown.
2907 FillLogMessageCtrl(false);
2912 m_LogList
.Invalidate();
2916 void CLogDlg::OnBnClickedCompressedGraph()
2920 if (m_iCompressedGraph
== 2)
2921 m_LogList
.m_ShowFilter
= CGitLogListBase::FILTERSHOW_REFS
;
2922 else if (m_iCompressedGraph
== 1)
2923 m_LogList
.m_ShowFilter
= static_cast<CGitLogListBase::FilterShow
>(CGitLogListBase::FILTERSHOW_REFS
| CGitLogListBase::FILTERSHOW_MERGEPOINTS
);
2925 m_LogList
.m_ShowFilter
= CGitLogListBase::FILTERSHOW_ALL
;
2928 FillLogMessageCtrl(false);
2931 void CLogDlg::OnBnClickedBrowseRef()
2933 CString newRef
= CBrowseRefsDlg::PickRef(false, m_LogList
.GetRange(), gPickRef_All
, true);
2934 if(newRef
.IsEmpty())
2937 m_History
.AddEntry(newRef
);
2942 m_LogList
.m_ShowMask
&= ~(CGit::LOG_INFO_ALL_BRANCH
| CGit::LOG_INFO_LOCAL_BRANCHES
);
2943 m_bAllBranch
= BST_UNCHECKED
;
2947 FillLogMessageCtrl(false);
2950 void CLogDlg::ShowStartRef()
2952 //Show ref name on top
2953 if(!::IsWindow(m_hWnd
))
2955 if (m_LogList
.m_ShowMask
& (CGit::LOG_INFO_ALL_BRANCH
| CGit::LOG_INFO_LOCAL_BRANCHES
))
2957 switch (m_LogList
.m_ShowMask
& (CGit::LOG_INFO_ALL_BRANCH
| CGit::LOG_INFO_LOCAL_BRANCHES
))
2959 case CGit::LOG_INFO_ALL_BRANCH
:
2960 m_staticRef
.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_LOG_ALLBRANCHES
)));
2963 case CGit::LOG_INFO_LOCAL_BRANCHES
:
2964 m_staticRef
.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_LOG_LOCAL_BRANCHES
)));
2968 m_staticRef
.Invalidate(TRUE
);
2969 m_tooltips
.DelTool(GetDlgItem(IDC_STATIC_REF
));
2973 CString showStartRef
= m_LogList
.GetRange();
2974 if (showStartRef
.IsEmpty() || showStartRef
== _T("HEAD"))
2976 showStartRef
.Empty();
2978 if (g_Git
.Run(L
"git.exe symbolic-ref HEAD", &showStartRef
, NULL
, CP_UTF8
))
2979 showStartRef
= CString(MAKEINTRESOURCE(IDS_PROC_LOG_NOBRANCH
));
2980 showStartRef
.Trim(L
"\r\n\t ");
2984 showStartRef
= g_Git
.StripRefName(showStartRef
);
2986 m_staticRef
.SetWindowText(showStartRef
);
2987 CWnd
*pWnd
= GetDlgItem(IDC_STATIC_REF
);
2988 m_tooltips
.AddTool(pWnd
, showStartRef
);
2989 m_staticRef
.Invalidate(TRUE
);
2992 void CLogDlg::SetRange(const CString
& range
)
2994 m_LogList
.SetRange(range
);
2995 m_ChangedFileListCtrl
.m_sDisplayedBranch
= range
;
3000 static void AppendMenuChecked(CMenu
&menu
, UINT nTextID
, UINT_PTR nItemID
, BOOL checked
= FALSE
, BOOL enabled
= TRUE
)
3003 text
.LoadString(nTextID
);
3004 menu
.AppendMenu(MF_STRING
| (enabled
? MF_ENABLED
: MF_DISABLED
) | (checked
? MF_CHECKED
: MF_UNCHECKED
), nItemID
, text
);
3007 #define WALKBEHAVIOUR_FIRSTPARENT 1
3008 #define WALKBEHAVIOUR_FOLLOWRENAMES 2
3009 #define WALKBEHAVIOUR_COMPRESSEDGRAPH 3
3010 #define WALKBEHAVIOUR_LABELEDCOMMITS 4
3011 #define WALKBEHAVIOUR_NOMERGES 5
3013 void CLogDlg::OnBnClickedWalkBehaviour()
3016 if (popup
.CreatePopupMenu())
3018 AppendMenuChecked(popup
, IDS_WALKBEHAVIOUR_FIRSTPARENT
, WALKBEHAVIOUR_FIRSTPARENT
, m_bFirstParent
);
3019 AppendMenuChecked(popup
, IDS_WALKBEHAVIOUR_NOMERGES
, WALKBEHAVIOUR_NOMERGES
, m_bNoMerges
);
3020 AppendMenuChecked(popup
, IDS_WALKBEHAVIOUR_FOLLOWRENAMES
, WALKBEHAVIOUR_FOLLOWRENAMES
, m_bFollowRenames
, !(m_path
.IsEmpty() || m_path
.IsDirectory()));
3021 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
3022 AppendMenuChecked(popup
, IDS_WALKBEHAVIOUR_COMPRESSED
, WALKBEHAVIOUR_COMPRESSEDGRAPH
, m_iCompressedGraph
== 1);
3023 AppendMenuChecked(popup
, IDS_WALKBEHAVIOUR_LABELEDCOMMITS
, WALKBEHAVIOUR_LABELEDCOMMITS
, m_iCompressedGraph
== 2);
3027 GetDlgItem(IDC_WALKBEHAVIOUR
)->GetWindowRect(&rect
);
3028 int selection
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, rect
.left
, rect
.top
, this, 0);
3031 case WALKBEHAVIOUR_FIRSTPARENT
:
3032 m_bFirstParent
= !m_bFirstParent
;
3033 OnBnClickedFirstParent();
3035 case WALKBEHAVIOUR_NOMERGES
:
3036 m_bNoMerges
= !m_bNoMerges
;
3037 OnBnClickedFirstParent(); // OnBnClickedFirstParent handles both cases: m_bFirstParent and m_bNoMerges
3039 case WALKBEHAVIOUR_FOLLOWRENAMES
:
3040 m_bFollowRenames
= !m_bFollowRenames
;
3041 OnBnClickedFollowRenames();
3043 case WALKBEHAVIOUR_COMPRESSEDGRAPH
:
3044 m_iCompressedGraph
= (m_iCompressedGraph
== 1 ? 0 : 1);
3045 OnBnClickedCompressedGraph();
3047 case WALKBEHAVIOUR_LABELEDCOMMITS
:
3048 m_iCompressedGraph
= (m_iCompressedGraph
== 2 ? 0 : 2);
3049 OnBnClickedCompressedGraph();
3054 m_bWalkBehavior
= (m_bFirstParent
|| m_bNoMerges
|| m_bFollowRenames
|| m_iCompressedGraph
);
3059 #define VIEW_HIDEPATHS 1
3060 #define VIEW_GRAYPATHS 2
3061 #define VIEW_SHOWTAGS 3
3062 #define VIEW_SHOWLOCALBRANCHES 4
3063 #define VIEW_SHOWREMOTEBRANCHES 5
3064 #define VIEW_SHOWGRAVATAR 6
3065 #define VIEW_SHOWPATCH 7
3067 void CLogDlg::OnBnClickedView()
3070 if (popup
.CreatePopupMenu())
3072 AppendMenuChecked(popup
, IDS_SHOWFILES_HIDEPATHS
, VIEW_HIDEPATHS
, m_iHidePaths
== 1);
3073 AppendMenuChecked(popup
, IDS_SHOWFILES_GRAYPATHS
, VIEW_GRAYPATHS
, m_iHidePaths
== 2);
3074 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
3075 CMenu showLabelsMenu
;
3076 if (showLabelsMenu
.CreatePopupMenu())
3078 AppendMenuChecked(showLabelsMenu
, IDS_VIEW_SHOWTAGLABELS
, VIEW_SHOWTAGS
, m_bShowTags
);
3079 AppendMenuChecked(showLabelsMenu
, IDS_VIEW_SHOWLOCALBRANCHLABELS
, VIEW_SHOWLOCALBRANCHES
, m_bShowLocalBranches
);
3080 AppendMenuChecked(showLabelsMenu
, IDS_VIEW_SHOWREMOTEBRANCHLABELS
, VIEW_SHOWREMOTEBRANCHES
, m_bShowRemoteBranches
);
3081 popup
.AppendMenu(MF_STRING
| MF_POPUP
, (UINT
)showLabelsMenu
.m_hMenu
, (CString
)MAKEINTRESOURCE(IDS_VIEW_LABELS
));
3083 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
3084 AppendMenuChecked(popup
, IDS_VIEW_SHOWGRAVATAR
, VIEW_SHOWGRAVATAR
, m_bShowGravatar
);
3085 AppendMenuChecked(popup
, IDS_MENU_VIEWPATCH
, VIEW_SHOWPATCH
, IsWindow(this->m_patchViewdlg
.m_hWnd
));
3089 GetDlgItem(IDC_VIEW
)->GetWindowRect(&rect
);
3090 int selection
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, rect
.left
, rect
.top
, this, 0);
3093 case VIEW_HIDEPATHS
:
3094 if (m_iHidePaths
== 1)
3098 OnBnClickedHidepaths();
3100 case VIEW_GRAYPATHS
:
3101 if (m_iHidePaths
== 2)
3105 OnBnClickedHidepaths();
3108 m_bShowTags
= !m_bShowTags
;
3109 HandleShowLabels(m_bShowTags
, LOGLIST_SHOWTAGS
);
3111 case VIEW_SHOWLOCALBRANCHES
:
3112 m_bShowLocalBranches
= !m_bShowLocalBranches
;
3113 HandleShowLabels(m_bShowLocalBranches
, LOGLIST_SHOWLOCALBRANCHES
);
3115 case VIEW_SHOWREMOTEBRANCHES
:
3116 m_bShowRemoteBranches
= !m_bShowRemoteBranches
;
3117 HandleShowLabels(m_bShowRemoteBranches
, LOGLIST_SHOWREMOTEBRANCHES
);
3119 case VIEW_SHOWGRAVATAR
:
3121 m_bShowGravatar
= !m_bShowGravatar
;
3125 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
3128 int selIndex
= m_LogList
.GetNextSelectedItem(pos
);
3129 int moreSel
= m_LogList
.GetNextSelectedItem(pos
);
3132 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_LogList
.m_arShownList
.SafeGetAt(selIndex
));
3134 email
= pLogEntry
->GetAuthorEmail();
3137 m_gravatar
.LoadGravatar(email
);
3140 case VIEW_SHOWPATCH
:
3149 void CLogDlg::OnBnClickedFirstParent()
3151 if(this->m_bFirstParent
)
3152 m_LogList
.m_ShowMask
|=CGit::LOG_INFO_FIRST_PARENT
;
3154 m_LogList
.m_ShowMask
&=~CGit::LOG_INFO_FIRST_PARENT
;
3157 m_LogList
.m_ShowMask
|= CGit::LOG_INFO_NO_MERGE
;
3159 m_LogList
.m_ShowMask
&= ~CGit::LOG_INFO_NO_MERGE
;
3163 FillLogMessageCtrl(false);
3167 void CLogDlg::OnBnClickShowWholeProject()
3171 if(this->m_bWholeProject
)
3173 m_LogList
.m_Path
.Reset();
3177 m_LogList
.m_Path
=m_path
;
3179 m_regShowWholeProject
= m_bWholeProject
;
3185 FillLogMessageCtrl(false);
3189 LRESULT
CLogDlg::OnRefLogChanged(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
3195 LRESULT
CLogDlg::OnTaskbarBtnCreated(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
3197 m_pTaskbarList
.Release();
3198 m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
);
3199 SetUUIDOverlayIcon(m_hWnd
);
3203 LRESULT
CLogDlg::OnRefreshSelection(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
3205 // it's enough to deselect, then select again one item of the whole selection
3206 int selMark
= m_LogList
.GetSelectionMark();
3209 m_LogList
.SetSelectionMark(selMark
);
3210 m_LogList
.SetItemState(selMark
, 0, LVIS_SELECTED
);
3211 m_LogList
.SetItemState(selMark
, LVIS_SELECTED
, LVIS_SELECTED
);