1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2016 - TortoiseGit
4 // Copyright (C) 2005-2007 Marco Costalba
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // GitLogList.cpp : implementation file
24 #include "GitLogListBase.h"
27 #include "GitProgressDlg.h"
28 #include "ProgressDlg.h"
29 #include "MessageBox.h"
31 #include "LoglistUtils.h"
32 #include "StringUtils.h"
33 #include "UnicodeUtils.h"
35 #include "GitStatus.h"
36 #include "..\TortoiseShell\Resource.h"
39 template < typename Cont
, typename Pred
>
40 void for_each(Cont
& c
, Pred p
)
42 std::for_each(cbegin(c
), cend(c
), p
);
46 using const_iterator
= typename
T::const_iterator
;
48 template <typename Cont
, typename Pred
>
49 const_iterator
<Cont
> find_if(Cont
& c
, Pred p
)
51 return std::find_if(cbegin(c
), cend(c
), p
);
54 const UINT
CGitLogListBase::m_FindDialogMessage
= RegisterWindowMessage(FINDMSGSTRING
);
55 const UINT
CGitLogListBase::m_ScrollToMessage
= RegisterWindowMessage(_T("TORTOISEGIT_LOG_SCROLLTO"));
56 const UINT
CGitLogListBase::m_RebaseActionMessage
= RegisterWindowMessage(_T("TORTOISEGIT_LOG_REBASEACTION"));
58 IMPLEMENT_DYNAMIC(CGitLogListBase
, CHintListCtrl
)
60 CGitLogListBase::CGitLogListBase():CHintListCtrl()
61 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
63 ,m_bNoDispUpdates(FALSE
)
64 , m_bThreadRunning(FALSE
)
65 , m_bStrictStopped(false)
66 , m_SelectedFilters(LOGFILTER_ALL
)
67 , m_ShowFilter(FILTERSHOW_ALL
)
69 , m_logEntries(&m_LogCache
)
70 , m_pFindDialog(nullptr)
71 , m_ColumnManager(this)
72 , m_dwDefaultColumns(0)
73 , m_arShownList(&m_critSec
)
75 , m_bNoHightlightHead(FALSE
)
76 , m_ShowRefMask(LOGLIST_SHOWALLREFS
)
77 , m_bFullCommitMessageOnLogLine(false)
79 , m_AsyncThreadRunning(FALSE
)
80 , m_AsyncThreadExit(FALSE
)
81 , m_bIsCherryPick(false)
83 // use the default GUI font, create a copy of it and
84 // change the copy to BOLD (leave the rest of the font
86 HFONT hFont
= (HFONT
)GetStockObject(DEFAULT_GUI_FONT
);
88 GetObject(hFont
, sizeof(LOGFONT
), &lf
);
89 lf
.lfWeight
= FW_BOLD
;
90 m_boldFont
.CreateFontIndirect(&lf
);
91 lf
.lfWeight
= FW_DONTCARE
;
93 m_FontItalics
.CreateFontIndirect(&lf
);
94 lf
.lfWeight
= FW_BOLD
;
95 m_boldItalicsFont
.CreateFontIndirect(&lf
);
97 m_bShowBugtraqColumn
=false;
99 m_IsIDReplaceAction
=FALSE
;
101 this->m_critSec
.Init();
104 m_hModifiedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
105 m_hReplacedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
106 m_hConflictedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONCONFLICTED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
107 m_hAddedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
108 m_hDeletedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
109 m_hFetchIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONFETCHING
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
111 m_bFilterWithRegex
= !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), FALSE
);
112 m_bFilterCaseSensitively
= !!CRegDWORD(_T("Software\\TortoiseGit\\FilterCaseSensitively"), FALSE
);
114 m_Filter
.m_NumberOfLogsScale
= (DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\NumberOfLogsScale"), CFilterData::SHOW_NO_LIMIT
);
115 if (m_Filter
.m_NumberOfLogsScale
== CFilterData::SHOW_LAST_SEL_DATE
)
118 key
.Format(_T("Software\\TortoiseGit\\History\\LogDlg_Limits\\%s\\FromDate"), (LPCTSTR
)g_Git
.m_CurrentDir
);
119 key
.Replace(_T(':'), _T('_'));
120 CString lastSelFromDate
= CRegString(key
);
121 if (lastSelFromDate
.GetLength() == 10)
123 CTime time
= CTime(_wtoi((LPCTSTR
)lastSelFromDate
.Mid(0, 4)), _wtoi((LPCTSTR
)lastSelFromDate
.Mid(5, 2)), _wtoi((LPCTSTR
)lastSelFromDate
.Mid(8, 2)), 0, 0, 0);
124 m_Filter
.m_From
= (DWORD
)time
.GetTime();
127 m_Filter
.m_NumberOfLogs
= (DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\LogDialog\\NumberOfLogs"), 1);
130 m_LoadingThread
= nullptr;
132 InterlockedExchange(&m_bExitThread
,FALSE
);
133 m_IsOldFirst
= FALSE
;
134 m_IsRebaseReplaceGraph
= FALSE
;
136 for (int i
= 0; i
< Lanes::COLORS_NUM
; ++i
)
138 m_LineColors
[i
] = m_Colors
.GetColor((CColors::Colors
)(CColors::BranchLine1
+i
));
140 // get short/long datetime setting from registry
141 DWORD RegUseShortDateFormat
= CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE
);
142 if ( RegUseShortDateFormat
)
144 m_DateFormat
= DATE_SHORTDATE
;
148 m_DateFormat
= DATE_LONGDATE
;
150 // get relative time display setting from registry
151 DWORD regRelativeTimes
= CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE
);
152 m_bRelativeTimes
= (regRelativeTimes
!= 0);
153 m_ContextMenuMask
= 0xFFFFFFFFFFFFFFFF;
155 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_PICK
);
156 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_SQUASH
);
157 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_EDIT
);
158 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_SKIP
);
159 m_ContextMenuMask
&= ~GetContextMenuBit(ID_LOG
);
160 m_ContextMenuMask
&= ~GetContextMenuBit(ID_BLAME
);
161 m_ContextMenuMask
&= ~GetContextMenuBit(ID_BLAMEPREVIOUS
);
163 m_ColumnRegKey
=_T("log");
165 m_bTagsBranchesOnRightSide
= !!CRegDWORD(_T("Software\\TortoiseGit\\DrawTagsBranchesOnRightSide"), FALSE
);
166 m_bSymbolizeRefNames
= !!CRegDWORD(_T("Software\\TortoiseGit\\SymbolizeRefNames"), FALSE
);
167 m_bIncludeBoundaryCommits
= !!CRegDWORD(_T("Software\\TortoiseGit\\LogIncludeBoundaryCommits"), FALSE
);
168 m_bFullCommitMessageOnLogLine
= !!CRegDWORD(_T("Software\\TortoiseGit\\FullCommitMessageOnLogLine"), FALSE
);
170 m_LineWidth
= max(1, CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Graph\\LogLineWidth"), 2));
171 m_NodeSize
= max(1, CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Graph\\LogNodeSize"), 10));
173 m_AsyncDiffEvent
= ::CreateEvent(nullptr, FALSE
, TRUE
, nullptr);
174 m_AsynDiffListLock
.Init();
175 StartAsyncDiffThread();
178 int CGitLogListBase::AsyncDiffThread()
180 while(!m_AsyncThreadExit
)
182 ::WaitForSingleObject(m_AsyncDiffEvent
, INFINITE
);
184 GitRevLoglist
* pRev
= nullptr;
185 while(!m_AsyncThreadExit
&& !m_AsynDiffList
.empty())
187 m_AsynDiffListLock
.Lock();
188 pRev
= m_AsynDiffList
.back();
189 m_AsynDiffList
.pop_back();
190 m_AsynDiffListLock
.Unlock();
192 if( pRev
->m_CommitHash
.IsEmpty() )
194 if(pRev
->m_IsDiffFiles
)
197 CTGitPathList
& files
= pRev
->GetFiles(this);
199 pRev
->m_ParentHash
.clear();
200 pRev
->m_ParentHash
.push_back(m_HeadHash
);
201 g_Git
.GetWorkingTreeChanges(files
);
202 int& action
= pRev
->GetAction(this);
204 for (int j
= 0; j
< files
.GetCount(); ++j
)
205 action
|= files
[j
].m_Action
;
208 if (pRev
->GetUnRevFiles().FillUnRev(CTGitPath::LOGACTIONS_UNVER
, nullptr, &err
))
210 MessageBox(_T("Failed to get UnRev file list\n") + err
, _T("TortoiseGit"), MB_OK
| MB_ICONERROR
);
211 InterlockedExchange(&m_AsyncThreadRunning
, FALSE
);
215 InterlockedExchange(&pRev
->m_IsDiffFiles
, TRUE
);
216 InterlockedExchange(&pRev
->m_IsFull
, TRUE
);
218 pRev
->GetBody().Format(IDS_FILESCHANGES
, files
.GetCount());
219 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)0,0);
220 this->GetParent()->PostMessage(WM_COMMAND
, MSG_FETCHED_DIFF
, 0);
223 if (!pRev
->CheckAndDiff())
224 { // fetch change file list
225 for (int i
= GetTopIndex(); !m_AsyncThreadExit
&& i
<= GetTopIndex() + GetCountPerPage(); ++i
)
227 if (i
< (int)m_arShownList
.size())
229 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(i
);
230 if(data
->m_CommitHash
== pRev
->m_CommitHash
)
232 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)i
,0);
238 if(!m_AsyncThreadExit
&& GetSelectedCount() == 1)
240 POSITION pos
= GetFirstSelectedItemPosition();
241 int nItem
= GetNextSelectedItem(pos
);
245 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(nItem
);
247 if(data
->m_CommitHash
== pRev
->m_CommitHash
)
248 this->GetParent()->PostMessage(WM_COMMAND
, MSG_FETCHED_DIFF
, 0);
254 InterlockedExchange(&m_AsyncThreadRunning
, FALSE
);
257 void CGitLogListBase::hideFromContextMenu(unsigned __int64 hideMask
, bool exclusivelyShow
)
260 m_ContextMenuMask
&= hideMask
;
262 m_ContextMenuMask
&= ~hideMask
;
265 CGitLogListBase::~CGitLogListBase()
267 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
268 this->m_arShownList
.SafeRemoveAll();
270 DestroyIcon(m_hModifiedIcon
);
271 DestroyIcon(m_hReplacedIcon
);
272 DestroyIcon(m_hConflictedIcon
);
273 DestroyIcon(m_hAddedIcon
);
274 DestroyIcon(m_hDeletedIcon
);
275 m_logEntries
.ClearAll();
277 SafeTerminateThread();
278 SafeTerminateAsyncDiffThread();
281 CloseHandle(m_AsyncDiffEvent
);
285 BEGIN_MESSAGE_MAP(CGitLogListBase
, CHintListCtrl
)
286 ON_REGISTERED_MESSAGE(m_FindDialogMessage
, OnFindDialogMessage
)
287 ON_REGISTERED_MESSAGE(m_ScrollToMessage
, OnScrollToMessage
)
288 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW
, OnNMCustomdrawLoglist
)
289 ON_NOTIFY_REFLECT(LVN_GETDISPINFO
, OnLvnGetdispinfoLoglist
)
291 ON_NOTIFY_REFLECT(NM_DBLCLK
, OnNMDblclkLoglist
)
292 ON_NOTIFY_REFLECT(LVN_ODFINDITEM
,OnLvnOdfinditemLoglist
)
295 ON_MESSAGE(MSG_LOADED
,OnLoad
)
297 ON_WM_MEASUREITEM_REFLECT()
298 ON_NOTIFY(HDN_BEGINTRACKA
, 0, OnHdnBegintrack
)
299 ON_NOTIFY(HDN_BEGINTRACKW
, 0, OnHdnBegintrack
)
300 ON_NOTIFY(HDN_ITEMCHANGINGA
, 0, OnHdnItemchanging
)
301 ON_NOTIFY(HDN_ITEMCHANGINGW
, 0, OnHdnItemchanging
)
302 ON_NOTIFY(HDN_ENDTRACK
, 0, OnColumnResized
)
303 ON_NOTIFY(HDN_ENDDRAG
, 0, OnColumnMoved
)
304 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW
, 0, 0xFFFF, &OnToolTipText
)
305 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA
, 0, 0xFFFF, &OnToolTipText
)
308 void CGitLogListBase::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct
)
310 //if (m_nRowHeight>0)
311 lpMeasureItemStruct
->itemHeight
= 50;
314 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct
)
317 return CHintListCtrl::OnCreate(lpCreateStruct
);
320 void CGitLogListBase::PreSubclassWindow()
322 SetExtendedStyle(LVS_EX_FULLROWSELECT
| LVS_EX_SUBITEMIMAGES
);
323 // load the icons for the action columns
324 // m_Theme.Open(m_hWnd, L"ListView");
325 SetWindowTheme(m_hWnd
, L
"Explorer", nullptr);
326 CHintListCtrl::PreSubclassWindow();
329 CString
CGitLogListBase::GetRebaseActionName(int action
)
331 if (action
& LOGACTIONS_REBASE_EDIT
)
332 return MAKEINTRESOURCE(IDS_PATHACTIONS_EDIT
);
333 if (action
& LOGACTIONS_REBASE_SQUASH
)
334 return MAKEINTRESOURCE(IDS_PATHACTIONS_SQUASH
);
335 if (action
& LOGACTIONS_REBASE_PICK
)
336 return MAKEINTRESOURCE(IDS_PATHACTIONS_PICK
);
337 if (action
& LOGACTIONS_REBASE_SKIP
)
338 return MAKEINTRESOURCE(IDS_PATHACTIONS_SKIP
);
340 return MAKEINTRESOURCE(IDS_PATHACTIONS_UNKNOWN
);
343 void CGitLogListBase::InsertGitColumn()
347 CRegDWORD
regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE
);
348 DWORD exStyle
= LVS_EX_HEADERDRAGDROP
| LVS_EX_DOUBLEBUFFER
| LVS_EX_INFOTIP
| LVS_EX_SUBITEMIMAGES
;
349 if (DWORD(regFullRowSelect
))
350 exStyle
|= LVS_EX_FULLROWSELECT
;
351 SetExtendedStyle(exStyle
);
353 // only load properties if we have a repository
354 if (GitAdminDir::IsWorkingTreeOrBareRepo(g_Git
.m_CurrentDir
))
355 UpdateProjectProperties();
357 static UINT normal
[] =
369 IDS_LOG_COMMIT_EMAIL
,
381 2*ICONITEMBORDER
+16*4,
392 m_dwDefaultColumns
= GIT_LOG_GRAPH
|GIT_LOG_ACTIONS
|GIT_LOG_MESSAGE
|GIT_LOG_AUTHOR
|GIT_LOG_DATE
;
394 DWORD hideColumns
= 0;
395 if(this->m_IsRebaseReplaceGraph
)
397 hideColumns
|= GIT_LOG_GRAPH
;
398 m_dwDefaultColumns
|= GIT_LOG_REBASE
;
401 hideColumns
|= GIT_LOG_REBASE
;
403 if(this->m_IsIDReplaceAction
)
405 hideColumns
|= GIT_LOG_ACTIONS
;
406 m_dwDefaultColumns
|= GIT_LOG_ID
;
407 m_dwDefaultColumns
|= GIT_LOG_HASH
;
410 hideColumns
|= GIT_LOG_ID
;
411 if(this->m_bShowBugtraqColumn
)
412 m_dwDefaultColumns
|= GIT_LOGLIST_BUG
;
414 hideColumns
|= GIT_LOGLIST_BUG
;
415 if (CTGitPath(g_Git
.m_CurrentDir
).HasGitSVNDir())
416 m_dwDefaultColumns
|= GIT_LOGLIST_SVNREV
;
418 hideColumns
|= GIT_LOGLIST_SVNREV
;
421 m_ColumnManager
.SetNames(normal
, _countof(normal
));
422 m_ColumnManager
.ReadSettings(m_dwDefaultColumns
, hideColumns
, m_ColumnRegKey
+_T("loglist"), _countof(normal
), with
);
423 m_ColumnManager
.SetRightAlign(LOGLIST_ID
);
428 void CGitLogListBase::FillBackGround(HDC hdc
, DWORD_PTR Index
, CRect
&rect
)
430 LVITEM rItem
= { 0 };
431 rItem
.mask
= LVIF_STATE
;
432 rItem
.iItem
= (int)Index
;
433 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
436 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(Index
);
437 HBRUSH brush
= nullptr;
439 if (!(rItem
.state
& LVIS_SELECTED
))
441 int action
= pLogEntry
->GetRebaseAction();
442 if (action
& LOGACTIONS_REBASE_SQUASH
)
443 brush
= ::CreateSolidBrush(RGB(156,156,156));
444 else if (action
& LOGACTIONS_REBASE_EDIT
)
445 brush
= ::CreateSolidBrush(RGB(200,200,128));
447 else if (!IsAppThemed())
449 if (rItem
.state
& LVIS_SELECTED
)
451 if (::GetFocus() == m_hWnd
)
452 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT
));
454 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE
));
459 ::FillRect(hdc
, &rect
, brush
);
460 ::DeleteObject(brush
);
464 void DrawTrackingRoundRect(HDC hdc
, CRect rect
, HBRUSH brush
, COLORREF darkColor
)
466 POINT point
= { 4, 4 };
468 rt2
.DeflateRect(1, 1);
469 rt2
.OffsetRect(2, 2);
471 HPEN nullPen
= ::CreatePen(PS_NULL
, 0, 0);
472 HPEN oldpen
= (HPEN
)::SelectObject(hdc
, nullPen
);
473 HBRUSH darkBrush
= (HBRUSH
)::CreateSolidBrush(darkColor
);
474 HBRUSH oldbrush
= (HBRUSH
)::SelectObject(hdc
, darkBrush
);
475 ::RoundRect(hdc
, rt2
.left
, rt2
.top
, rt2
.right
, rt2
.bottom
, point
.x
, point
.y
);
477 ::SelectObject(hdc
, brush
);
478 rt2
.OffsetRect(-2, -2);
479 ::RoundRect(hdc
, rt2
.left
, rt2
.top
, rt2
.right
, rt2
.bottom
, point
.x
, point
.y
);
480 ::SelectObject(hdc
, oldbrush
);
481 ::SelectObject(hdc
, oldpen
);
482 ::DeleteObject(nullPen
);
483 ::DeleteObject(darkBrush
);
486 void DrawLightning(HDC hdc
, CRect rect
, COLORREF color
, int bold
)
488 HPEN pen
= ::CreatePen(PS_SOLID
, bold
, color
);
489 HPEN oldpen
= (HPEN
)::SelectObject(hdc
, pen
);
490 ::MoveToEx(hdc
, rect
.left
+ 7, rect
.top
, nullptr);
491 ::LineTo(hdc
, rect
.left
+ 1, (rect
.top
+ rect
.bottom
) / 2);
492 ::LineTo(hdc
, rect
.left
+ 6, (rect
.top
+ rect
.bottom
) / 2);
493 ::LineTo(hdc
, rect
.left
, rect
.bottom
);
494 ::SelectObject(hdc
, oldpen
);
498 void DrawUpTriangle(HDC hdc
, CRect rect
, COLORREF color
, int bold
)
500 HPEN pen
= ::CreatePen(PS_SOLID
, bold
, color
);
501 HPEN oldpen
= (HPEN
)::SelectObject(hdc
, pen
);
502 ::MoveToEx(hdc
, (rect
.left
+ rect
.right
) / 2, rect
.top
, nullptr);
503 ::LineTo(hdc
, rect
.left
, rect
.bottom
);
504 ::LineTo(hdc
, rect
.right
, rect
.bottom
);
505 ::LineTo(hdc
, (rect
.left
+ rect
.right
) / 2, rect
.top
);
506 ::SelectObject(hdc
, oldpen
);
510 void CGitLogListBase::DrawTagBranchMessage(HDC hdc
, CRect
&rect
, INT_PTR index
, std::vector
<REFLABEL
> &refList
)
512 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(index
);
514 LVITEM rItem
= { 0 };
515 rItem
.mask
= LVIF_STATE
;
516 rItem
.iItem
= (int)index
;
517 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
523 HTHEME hTheme
= nullptr;
525 hTheme
= OpenThemeData(m_hWnd
, L
"Explorer::ListView;ListView");
528 if (m_bTagsBranchesOnRightSide
)
530 HFONT oldFont
= (HFONT
)SelectObject(hdc
, (HFONT
)GetStockObject(DEFAULT_GUI_FONT
));
531 GetTextExtentPoint32(hdc
, L
" ", 1, &oneSpaceSize
);
532 SelectObject(hdc
, oldFont
);
533 rt
.left
+= oneSpaceSize
.cx
* 2;
537 GetTextExtentPoint32(hdc
, L
" ", 1, &oneSpaceSize
);
538 DrawTagBranch(hdc
, W_Dc
, hTheme
, rect
, rt
, rItem
, data
, refList
);
539 rt
.left
+= oneSpaceSize
.cx
;
542 CString msg
= MessageDisplayStr(data
);
543 int action
= data
->GetRebaseAction();
544 bool skip
= !!(action
& (LOGACTIONS_REBASE_DONE
| LOGACTIONS_REBASE_SKIP
));
547 int txtState
= LISS_NORMAL
;
548 if (rItem
.state
& LVIS_SELECTED
)
549 txtState
= LISS_SELECTED
;
551 DTTOPTS opts
= { 0 };
552 opts
.dwSize
= sizeof(opts
);
553 opts
.crText
= skip
? RGB(128,128,128) : ::GetSysColor(COLOR_WINDOWTEXT
);
554 opts
.dwFlags
= DTT_TEXTCOLOR
;
555 DrawThemeTextEx(hTheme
, hdc
, LVP_LISTITEM
, txtState
, msg
, -1, DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
, &rt
, &opts
);
559 if ((rItem
.state
& LVIS_SELECTED
) && (::GetFocus() == m_hWnd
))
561 COLORREF clrOld
= ::SetTextColor(hdc
, skip
? RGB(128,128,128) : ::GetSysColor(COLOR_HIGHLIGHTTEXT
));
562 ::DrawText(hdc
,msg
, msg
.GetLength(), &rt
, DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
);
563 ::SetTextColor(hdc
, clrOld
);
567 COLORREF clrOld
= ::SetTextColor(hdc
, skip
? RGB(128,128,128) : ::GetSysColor(COLOR_WINDOWTEXT
));
568 ::DrawText(hdc
, msg
, msg
.GetLength(), &rt
, DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
);
569 ::SetTextColor(hdc
, clrOld
);
573 if (m_bTagsBranchesOnRightSide
)
576 GetTextExtentPoint32(hdc
, msg
, msg
.GetLength(), &size
);
578 rt
.left
+= oneSpaceSize
.cx
+ size
.cx
;
580 DrawTagBranch(hdc
, W_Dc
, hTheme
, rect
, rt
, rItem
, data
, refList
);
584 CloseThemeData(hTheme
);
589 void CGitLogListBase::DrawTagBranch(HDC hdc
, CDC
& W_Dc
, HTHEME hTheme
, CRect
& rect
, CRect
& rt
, LVITEM
& rItem
, GitRevLoglist
* data
, std::vector
<REFLABEL
>& refList
)
591 for (unsigned int i
= 0; i
< refList
.size(); ++i
)
593 CString shortname
= !refList
[i
].simplifiedName
.IsEmpty() ? refList
[i
].simplifiedName
: refList
[i
].name
;
595 COLORREF colRef
= refList
[i
].color
;
596 bool singleRemote
= refList
[i
].singleRemote
;
597 bool hasTracking
= refList
[i
].hasTracking
;
598 bool sameName
= refList
[i
].sameName
;
599 CGit::REF_TYPE refType
= refList
[i
].refType
;
601 //When row selected, ajust label color
604 if (rItem
.state
& LVIS_SELECTED
)
605 colRef
= CColors::MixColors(colRef
, ::GetSysColor(COLOR_HIGHLIGHT
), 150);
608 brush
= ::CreateSolidBrush(colRef
);
610 if (!shortname
.IsEmpty() && (rt
.left
< rect
.right
))
613 GetTextExtentPoint32(hdc
, shortname
, shortname
.GetLength(), &size
);
615 rt
.SetRect(rt
.left
, rt
.top
, rt
.left
+ size
.cx
, rt
.bottom
);
618 int textpos
= DT_CENTER
;
620 if (rt
.right
> rect
.right
)
622 rt
.right
= rect
.right
;
631 textRect
.OffsetRect(8, 0);
638 DrawTrackingRoundRect(hdc
, rt
, brush
, m_Colors
.Darken(colRef
, 100));
641 //Fill interior of ref label
642 ::FillRect(hdc
, &rt
, brush
);
650 W_Dc
.Draw3dRect(rectEdge
, m_Colors
.Lighten(colRef
, 100), m_Colors
.Darken(colRef
, 100));
651 rectEdge
.DeflateRect(1, 1);
652 W_Dc
.Draw3dRect(rectEdge
, m_Colors
.Lighten(colRef
, 50), m_Colors
.Darken(colRef
, 50));
655 if (refType
== CGit::REF_TYPE::ANNOTATED_TAG
)
658 POINT trianglept
[3] = { { rt
.right
- 8, rt
.top
}, { rt
.right
, (rt
.top
+ rt
.bottom
) / 2 }, { rt
.right
- 8, rt
.bottom
} };
659 HRGN hrgn
= ::CreatePolygonRgn(trianglept
, 3, ALTERNATE
);
660 ::FillRgn(hdc
, hrgn
, brush
);
661 ::DeleteObject(hrgn
);
662 ::MoveToEx(hdc
, trianglept
[0].x
- 1, trianglept
[0].y
, nullptr);
664 HPEN oldpen
= (HPEN
)SelectObject(hdc
, pen
= ::CreatePen(PS_SOLID
, 2, m_Colors
.Lighten(colRef
, 50)));
665 ::LineTo(hdc
, trianglept
[1].x
- 1, trianglept
[1].y
- 1);
667 SelectObject(hdc
, pen
= ::CreatePen(PS_SOLID
, 2, m_Colors
.Darken(colRef
, 50)));
668 ::LineTo(hdc
, trianglept
[2].x
- 1, trianglept
[2].y
- 1);
670 SelectObject(hdc
, pen
= ::CreatePen(PS_SOLID
, 2, colRef
));
671 ::MoveToEx(hdc
, trianglept
[0].x
- 1, trianglept
[2].y
- 3, nullptr);
672 ::LineTo(hdc
, trianglept
[0].x
- 1, trianglept
[0].y
);
674 SelectObject(hdc
, oldpen
);
677 //Draw text inside label
678 bool customColor
= (colRef
& 0xff) * 30 + ((colRef
>> 8) & 0xff) * 59 + ((colRef
>> 16) & 0xff) * 11 <= 12800; // check if dark background
679 if (!customColor
&& IsAppThemed())
681 int txtState
= LISS_NORMAL
;
682 if (rItem
.state
& LVIS_SELECTED
)
683 txtState
= LISS_SELECTED
;
685 DTTOPTS opts
= { 0 };
686 opts
.dwSize
= sizeof(opts
);
687 opts
.crText
= ::GetSysColor(COLOR_WINDOWTEXT
);
688 opts
.dwFlags
= DTT_TEXTCOLOR
;
689 DrawThemeTextEx(hTheme
, hdc
, LVP_LISTITEM
, txtState
, shortname
, -1, textpos
| DT_SINGLELINE
| DT_VCENTER
, &textRect
, &opts
);
693 W_Dc
.SetBkMode(TRANSPARENT
);
694 if (customColor
|| (rItem
.state
& LVIS_SELECTED
))
696 COLORREF clrNew
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
697 COLORREF clrOld
= ::SetTextColor(hdc
,clrNew
);
698 ::DrawText(hdc
, shortname
, shortname
.GetLength(), &textRect
, textpos
| DT_SINGLELINE
| DT_VCENTER
);
699 ::SetTextColor(hdc
,clrOld
);
703 COLORREF clrOld
= ::SetTextColor(hdc
, ::GetSysColor(COLOR_WINDOWTEXT
));
704 ::DrawText(hdc
, shortname
, shortname
.GetLength(), &textRect
, textpos
| DT_SINGLELINE
| DT_VCENTER
);
705 ::SetTextColor(hdc
, clrOld
);
711 COLORREF color
= ::GetSysColor(customColor
? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
);
712 int bold
= data
->m_CommitHash
== m_HeadHash
? 2 : 1;
714 newRect
.SetRect(rt
.left
+ 4, rt
.top
+ 4, rt
.left
+ 8, rt
.bottom
- 4);
715 DrawLightning(hdc
, newRect
, color
, bold
);
720 COLORREF color
= ::GetSysColor(customColor
? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
);
721 int bold
= data
->m_CommitHash
== m_HeadHash
? 2 : 1;
723 newRect
.SetRect(rt
.right
- 12, rt
.top
+ 4, rt
.right
- 4, rt
.bottom
- 4);
724 DrawUpTriangle(hdc
, newRect
, color
, bold
);
727 m_RefLabelPosMap
[refList
[i
].fullName
] = rt
;
729 rt
.left
= rt
.right
+ 1;
732 ::DeleteObject(brush
);
734 rt
.right
= rect
.right
;
737 static COLORREF
blend(const COLORREF
& col1
, const COLORREF
& col2
, int amount
= 128) {
738 // Returns ((256 - amount)*col1 + amount*col2) / 256;
739 return RGB(((256 - amount
)*GetRValue(col1
) + amount
*GetRValue(col2
) ) / 256,
740 ((256 - amount
)*GetGValue(col1
) + amount
*GetGValue(col2
) ) / 256,
741 ((256 - amount
)*GetBValue(col1
) + amount
*GetBValue(col2
) ) / 256);
744 Gdiplus::Color
GetGdiColor(COLORREF col
)
746 return Gdiplus::Color(GetRValue(col
),GetGValue(col
),GetBValue(col
));
748 void CGitLogListBase::paintGraphLane(HDC hdc
, int laneHeight
,int type
, int x1
, int x2
,
749 const COLORREF
& col
,const COLORREF
& activeColor
, int top
752 int h
= laneHeight
/ 2;
753 int m
= (x1
+ x2
) / 2;
754 int r
= (x2
- x1
) * m_NodeSize
/ 30;
757 #define P_CENTER m , h+top
758 #define P_0 x2, h+top
759 #define P_90 m , 0+top-1
760 #define P_180 x1, h+top
761 #define P_270 m , 2 * h+top +1
762 #define R_CENTER m - r, h - r+top, d, d
765 #define DELTA_UR_B 2*(x1 - m), 2*h +top
766 #define DELTA_UR_E 0*16, 90*16 +top // -,
768 #define DELTA_DR_B 2*(x1 - m), 2*-h +top
769 #define DELTA_DR_E 270*16, 90*16 +top // -'
771 #define DELTA_UL_B 2*(x2 - m), 2*h +top
772 #define DELTA_UL_E 90*16, 90*16 +top // ,-
774 #define DELTA_DL_B 2*(x2 - m),2*-h +top
775 #define DELTA_DL_E 180*16, 90*16 // '-
777 #define CENTER_UR x1, 2*h, 225
778 #define CENTER_DR x1, 0 , 135
779 #define CENTER_UL x2, 2*h, 315
780 #define CENTER_DL x2, 0 , 45
783 Gdiplus::Graphics
graphics( hdc
);
785 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
794 Gdiplus::LinearGradientBrush
gradient(
795 Gdiplus::Point(x1
-2, h
+top
-2),
796 Gdiplus::Point(P_270
),
797 GetGdiColor(activeColor
),GetGdiColor(col
));
800 Gdiplus::Pen
mypen(&gradient
, (Gdiplus::REAL
)m_LineWidth
);
801 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
803 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
804 graphics
.DrawArc(&mypen
,x1
-(x2
-x1
)/2-1,top
+h
-1, x2
-x1
,laneHeight
,270,90);
805 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
811 Gdiplus::LinearGradientBrush
gradient(
812 Gdiplus::Point(P_270
),
813 Gdiplus::Point(x2
+1, h
+top
-1),
814 GetGdiColor(col
),GetGdiColor(activeColor
));
817 Gdiplus::Pen
mypen(&gradient
, (Gdiplus::REAL
)m_LineWidth
);
818 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
820 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
821 graphics
.DrawArc(&mypen
,x1
+(x2
-x1
)/2,top
+h
-1, x2
-x1
,laneHeight
,180,90);
822 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
830 Gdiplus::LinearGradientBrush
gradient(
831 Gdiplus::Point(x1
-2, h
+top
-2),
832 Gdiplus::Point(P_90
),
833 GetGdiColor(activeColor
),GetGdiColor(col
));
835 Gdiplus::Pen
mypen(&gradient
, (Gdiplus::REAL
)m_LineWidth
);
837 graphics
.DrawArc(&mypen
,x1
-(x2
-x1
)/2-1,top
-h
-1, x2
-x1
,laneHeight
,0,90);
840 QConicalGradient
gradient(CENTER_DR
);
841 gradient
.setColorAt(0.375, activeCol
);
842 gradient
.setColorAt(0.625, col
);
843 myPen
.setBrush(gradient
);
845 p
->drawArc(P_CENTER
, DELTA_DR
);
854 //static QPen myPen(Qt::black, 2); // fast path here
856 pen
.CreatePen(PS_SOLID
,2,col
);
857 //myPen.setColor(col);
858 HPEN oldpen
=(HPEN
)::SelectObject(hdc
,(HPEN
)pen
);
860 Gdiplus::Pen
myPen(GetGdiColor(col
), (Gdiplus::REAL
)m_LineWidth
);
862 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
869 case Lanes::NOT_ACTIVE
:
870 case Lanes::MERGE_FORK
:
871 case Lanes::MERGE_FORK_R
:
872 case Lanes::MERGE_FORK_L
:
877 //DrawLine(hdc,P_90,P_270);
878 graphics
.DrawLine(&myPen
,P_90
,P_270
);
879 //p->drawLine(P_90, P_270);
883 //DrawLine(hdc,P_CENTER,P_270);
884 graphics
.DrawLine(&myPen
,P_CENTER
,P_270
);
885 //p->drawLine(P_CENTER, P_270);
889 case Lanes::BOUNDARY
:
890 case Lanes::BOUNDARY_C
:
891 case Lanes::BOUNDARY_R
:
892 case Lanes::BOUNDARY_L
:
893 //DrawLine(hdc,P_90, P_CENTER);
894 graphics
.DrawLine(&myPen
,P_90
,P_CENTER
);
895 //p->drawLine(P_90, P_CENTER);
901 myPen
.SetColor(GetGdiColor(activeColor
));
905 case Lanes::MERGE_FORK
:
910 case Lanes::CROSS_EMPTY
:
911 case Lanes::BOUNDARY_C
:
912 //DrawLine(hdc,P_180,P_0);
913 graphics
.DrawLine(&myPen
,P_180
,P_0
);
914 //p->drawLine(P_180, P_0);
916 case Lanes::MERGE_FORK_R
:
917 case Lanes::BOUNDARY_R
:
918 //DrawLine(hdc,P_180,P_CENTER);
919 graphics
.DrawLine(&myPen
,P_180
,P_CENTER
);
920 //p->drawLine(P_180, P_CENTER);
922 case Lanes::MERGE_FORK_L
:
925 case Lanes::BOUNDARY_L
:
926 //DrawLine(hdc,P_CENTER,P_0);
927 graphics
.DrawLine(&myPen
,P_CENTER
,P_0
);
928 //p->drawLine(P_CENTER, P_0);
934 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
937 brush
.CreateSolidBrush(col
);
938 HBRUSH oldbrush
=(HBRUSH
)::SelectObject(hdc
,(HBRUSH
)brush
);
940 Gdiplus::SolidBrush
myBrush(GetGdiColor(col
));
941 // center symbol, e.g. rect or ellipse
947 //p->setPen(Qt::NoPen);
949 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
950 graphics
.FillEllipse(&myBrush
, R_CENTER
);
951 //p->drawEllipse(R_CENTER);
953 case Lanes::MERGE_FORK
:
954 case Lanes::MERGE_FORK_R
:
955 case Lanes::MERGE_FORK_L
:
956 //p->setPen(Qt::NoPen);
958 //p->drawRect(R_CENTER);
959 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
960 graphics
.FillRectangle(&myBrush
, R_CENTER
);
962 case Lanes::UNAPPLIED
:
964 //p->setPen(Qt::NoPen);
965 //p->setBrush(Qt::red);
966 //p->drawRect(m - r, h - 1, d, 2);
967 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
968 graphics
.FillRectangle(&myBrush
,m
-r
,h
-1,d
,2);
972 //p->setPen(Qt::NoPen);
973 //p->setBrush(DARK_GREEN);
974 //p->drawRect(m - r, h - 1, d, 2);
975 //p->drawRect(m - 1, h - r, 2, d);
976 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
977 graphics
.FillRectangle(&myBrush
,m
-r
,h
-1,d
,2);
978 graphics
.FillRectangle(&myBrush
,m
-1,h
-r
,2,d
);
980 case Lanes::BOUNDARY
:
982 //p->drawEllipse(R_CENTER);
983 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
984 graphics
.DrawEllipse(&myPen
, R_CENTER
);
986 case Lanes::BOUNDARY_C
:
987 case Lanes::BOUNDARY_R
:
988 case Lanes::BOUNDARY_L
:
990 //p->drawRect(R_CENTER);
991 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
992 graphics
.FillRectangle(&myBrush
,R_CENTER
);
998 ::SelectObject(hdc
,oldpen
);
999 ::SelectObject(hdc
,oldbrush
);
1008 void CGitLogListBase::DrawGraph(HDC hdc
,CRect
&rect
,INT_PTR index
)
1012 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(index
);
1013 if(data
->m_CommitHash
.IsEmpty())
1017 LVITEM rItem
= { 0 };
1018 rItem
.mask
= LVIF_STATE
;
1019 rItem
.iItem
= (int)index
;
1020 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
1023 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
1025 if (data
->m_Lanes
.empty())
1026 m_logEntries
.setLane(data
->m_CommitHash
);
1028 std::vector
<int>& lanes
=data
->m_Lanes
;
1029 size_t laneNum
= lanes
.size();
1030 UINT activeLane
= 0;
1031 for (UINT i
= 0; i
< laneNum
; ++i
)
1032 if (Lanes::isMerge(lanes
[i
])) {
1038 int maxWidth
= rect
.Width();
1039 int lw
= 3 * rect
.Height() / 4; //laneWidth()
1041 COLORREF activeColor
= m_LineColors
[activeLane
% Lanes::COLORS_NUM
];
1042 //if (opt.state & QStyle::State_Selected)
1043 // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208);
1045 for (unsigned int i
= 0; i
< laneNum
&& x2
< maxWidth
; ++i
)
1051 if (ln
== Lanes::EMPTY
)
1054 COLORREF color
= i
== activeLane
? activeColor
: m_LineColors
[i
% Lanes::COLORS_NUM
];
1055 paintGraphLane(hdc
, rect
.Height(),ln
, x1
+rect
.left
, x2
+rect
.left
, color
,activeColor
, rect
.top
);
1059 for (UINT i
= 0; i
< laneNum
&& x2
< maxWidth
; ++i
) {
1064 if (ln
== Lanes::EMPTY
)
1067 UINT col
= ( Lanes:: isHead(ln
) ||Lanes:: isTail(ln
) || Lanes::isJoin(ln
)
1068 || ln
==Lanes:: CROSS_EMPTY
) ? activeLane
: i
;
1070 if (ln
== Lanes::CROSS
)
1072 paintGraphLane(hdc
, rect
.Height(),Lanes::NOT_ACTIVE
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
1073 paintGraphLane(hdc
, rect
.Height(),Lanes::CROSS
, x1
, x2
, m_LineColors
[activeLane
% Lanes::COLORS_NUM
],rect
.top
);
1076 paintGraphLane(hdc
, rect
.Height(),ln
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
1081 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1083 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
1084 // Take the default processing unless we set this to something else below.
1085 *pResult
= CDRF_DODEFAULT
;
1087 if (m_bNoDispUpdates
)
1090 switch (pLVCD
->nmcd
.dwDrawStage
)
1094 *pResult
= CDRF_NOTIFYITEMDRAW
;
1098 case CDDS_ITEMPREPAINT
:
1100 // This is the prepaint stage for an item. Here's where we set the
1101 // item's text color.
1103 // Tell Windows to send draw notifications for each subitem.
1104 *pResult
= CDRF_NOTIFYSUBITEMDRAW
;
1106 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
1108 if (m_arShownList
.size() > pLVCD
->nmcd
.dwItemSpec
)
1110 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1113 HGDIOBJ hGdiObj
= nullptr;
1114 int action
= data
->GetRebaseAction();
1115 if (action
& (LOGACTIONS_REBASE_DONE
| LOGACTIONS_REBASE_SKIP
))
1116 crText
= RGB(128,128,128);
1118 if (action
& LOGACTIONS_REBASE_SQUASH
)
1119 pLVCD
->clrTextBk
= RGB(156,156,156);
1120 else if (action
& LOGACTIONS_REBASE_EDIT
)
1121 pLVCD
->clrTextBk
= RGB(200,200,128);
1123 pLVCD
->clrTextBk
= ::GetSysColor(COLOR_WINDOW
);
1125 if (action
& LOGACTIONS_REBASE_CURRENT
)
1126 hGdiObj
= m_boldFont
.GetSafeHandle();
1128 BOOL isHeadHash
= data
->m_CommitHash
== m_HeadHash
&& m_bNoHightlightHead
== FALSE
;
1129 BOOL isHighlight
= data
->m_CommitHash
== m_highlight
&& !m_highlight
.IsEmpty();
1130 if (isHeadHash
&& isHighlight
)
1131 hGdiObj
= m_boldItalicsFont
.GetSafeHandle();
1132 else if (isHeadHash
)
1133 hGdiObj
= m_boldFont
.GetSafeHandle();
1134 else if (isHighlight
)
1135 hGdiObj
= m_FontItalics
.GetSafeHandle();
1139 SelectObject(pLVCD
->nmcd
.hdc
, hGdiObj
);
1140 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
1143 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
1144 // crText = GetSysColor(COLOR_GRAYTEXT);
1146 if (data
->m_CommitHash
.IsEmpty())
1148 //crText = GetSysColor(RGB(200,200,0));
1149 //SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1150 // We changed the font, so we're returning CDRF_NEWFONT. This
1151 // tells the control to recalculate the extent of the text.
1152 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
1156 if (m_arShownList
.size() == pLVCD
->nmcd
.dwItemSpec
)
1158 if (m_bStrictStopped
)
1159 crText
= GetSysColor(COLOR_GRAYTEXT
);
1161 // Store the color back in the NMLVCUSTOMDRAW struct.
1162 pLVCD
->clrText
= crText
;
1166 case CDDS_ITEMPREPAINT
|CDDS_ITEM
|CDDS_SUBITEM
:
1168 if (m_bStrictStopped
&& m_arShownList
.size() == pLVCD
->nmcd
.dwItemSpec
)
1170 pLVCD
->nmcd
.uItemState
&= ~(CDIS_SELECTED
|CDIS_FOCUS
);
1173 if (pLVCD
->iSubItem
== LOGLIST_GRAPH
&& !HasFilterText() && (m_ShowFilter
& FILTERSHOW_MERGEPOINTS
))
1175 if (m_arShownList
.size() > pLVCD
->nmcd
.dwItemSpec
&& !this->m_IsRebaseReplaceGraph
)
1178 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_LABEL
, rect
);
1180 //TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right);
1181 FillBackGround(pLVCD
->nmcd
.hdc
, pLVCD
->nmcd
.dwItemSpec
,rect
);
1183 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1184 if( !data
->m_CommitHash
.IsEmpty())
1185 DrawGraph(pLVCD
->nmcd
.hdc
,rect
,pLVCD
->nmcd
.dwItemSpec
);
1187 *pResult
= CDRF_SKIPDEFAULT
;
1192 if (pLVCD
->iSubItem
== LOGLIST_MESSAGE
)
1194 // If the top index of list is changed, the position map of reference label is outdated.
1195 if (m_OldTopIndex
!= GetTopIndex())
1197 m_OldTopIndex
= GetTopIndex();
1198 m_RefLabelPosMap
.clear();
1201 if (m_arShownList
.size() > pLVCD
->nmcd
.dwItemSpec
)
1203 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1205 if (!m_HashMap
[data
->m_CommitHash
].empty() && !(data
->GetRebaseAction() & LOGACTIONS_REBASE_DONE
))
1208 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1210 // BEGIN: extended redraw, HACK for issue #1618 and #2014
1211 // not in FillBackGround method, because this only affected the message subitem
1212 if (0 != pLVCD
->iStateId
) // don't know why, but this helps against loosing the focus rect
1215 int index
= (int)pLVCD
->nmcd
.dwItemSpec
;
1216 int state
= GetItemState(index
, LVIS_SELECTED
);
1217 int txtState
= LISS_NORMAL
;
1218 if (IsAppThemed() && GetHotItem() == (int)index
)
1220 if (state
& LVIS_SELECTED
)
1221 txtState
= LISS_HOTSELECTED
;
1223 txtState
= LISS_HOT
;
1225 else if (state
& LVIS_SELECTED
)
1227 if (::GetFocus() == m_hWnd
)
1228 txtState
= LISS_SELECTED
;
1230 txtState
= LISS_SELECTEDNOTFOCUS
;
1233 HTHEME hTheme
= nullptr;
1235 hTheme
= OpenThemeData(m_hWnd
, L
"Explorer::ListView;ListView");
1237 if (hTheme
&& IsThemeBackgroundPartiallyTransparent(hTheme
, LVP_LISTDETAIL
, txtState
))
1238 DrawThemeParentBackground(m_hWnd
, pLVCD
->nmcd
.hdc
, &rect
);
1241 HBRUSH brush
= ::CreateSolidBrush(pLVCD
->clrTextBk
);
1242 ::FillRect(pLVCD
->nmcd
.hdc
, rect
, brush
);
1243 ::DeleteObject(brush
);
1248 // get rect of whole line
1249 GetItemRect(index
, rt
, LVIR_BOUNDS
);
1251 if (txtState
== LISS_NORMAL
) // avoid drawing of grey borders
1252 rect2
.DeflateRect(1, 1, 1, 1);
1254 // calculate background for rect of whole line, but limit redrawing to SubItem rect
1255 DrawThemeBackground(hTheme
, pLVCD
->nmcd
.hdc
, LVP_LISTITEM
, txtState
, rt
, rect2
);
1257 CloseThemeData(hTheme
);
1259 // END: extended redraw
1261 FillBackGround(pLVCD
->nmcd
.hdc
, pLVCD
->nmcd
.dwItemSpec
,rect
);
1263 std::vector
<REFLABEL
> refsToShow
;
1264 STRING_VECTOR remoteTrackingList
;
1265 STRING_VECTOR refList
= m_HashMap
[data
->m_CommitHash
];
1266 for (unsigned int i
= 0; i
< refList
.size(); ++i
)
1268 CString str
= refList
[i
];
1271 refLabel
.color
= RGB(255, 255, 255);
1272 refLabel
.singleRemote
= false;
1273 refLabel
.hasTracking
= false;
1274 refLabel
.sameName
= false;
1275 refLabel
.name
= CGit::GetShortName(str
, &refLabel
.refType
);
1276 refLabel
.fullName
= str
;
1278 switch (refLabel
.refType
)
1280 case CGit::REF_TYPE::LOCAL_BRANCH
:
1282 if (!(m_ShowRefMask
& LOGLIST_SHOWLOCALBRANCHES
))
1284 if (refLabel
.name
== m_CurrentBranch
)
1285 refLabel
.color
= m_Colors
.GetColor(CColors::CurrentBranch
);
1287 refLabel
.color
= m_Colors
.GetColor(CColors::LocalBranch
);
1289 std::pair
<CString
, CString
> trackingEntry
= m_TrackingMap
[refLabel
.name
];
1290 CString pullRemote
= trackingEntry
.first
;
1291 CString pullBranch
= trackingEntry
.second
;
1292 if (!pullRemote
.IsEmpty() && !pullBranch
.IsEmpty())
1294 CString defaultUpstream
;
1295 defaultUpstream
.Format(_T("refs/remotes/%s/%s"), (LPCTSTR
)pullRemote
, (LPCTSTR
)pullBranch
);
1296 refLabel
.hasTracking
= true;
1297 if (m_ShowRefMask
& LOGLIST_SHOWREMOTEBRANCHES
)
1300 for (size_t j
= i
+ 1; j
< refList
.size(); ++j
)
1302 if (refList
[j
] == defaultUpstream
)
1311 bool sameName
= pullBranch
== refLabel
.name
;
1312 refsToShow
.push_back(refLabel
);
1313 CGit::GetShortName(defaultUpstream
, refLabel
.name
, _T("refs/remotes/"));
1314 refLabel
.color
= m_Colors
.GetColor(CColors::RemoteBranch
);
1315 if (m_bSymbolizeRefNames
)
1317 if (!m_SingleRemote
.IsEmpty() && m_SingleRemote
== pullRemote
)
1319 refLabel
.simplifiedName
= _T("/") + (sameName
? CString() : pullBranch
);
1320 refLabel
.singleRemote
= true;
1323 refLabel
.simplifiedName
= pullRemote
+ _T("/");
1324 refLabel
.sameName
= sameName
;
1326 refLabel
.fullName
= defaultUpstream
;
1327 refsToShow
.push_back(refLabel
);
1328 remoteTrackingList
.push_back(defaultUpstream
);
1335 case CGit::REF_TYPE::REMOTE_BRANCH
:
1337 if (!(m_ShowRefMask
& LOGLIST_SHOWREMOTEBRANCHES
))
1340 for (size_t j
= 0; j
< remoteTrackingList
.size(); ++j
)
1342 if (remoteTrackingList
[j
] == str
)
1351 refLabel
.color
= m_Colors
.GetColor(CColors::RemoteBranch
);
1352 if (m_bSymbolizeRefNames
)
1354 if (!m_SingleRemote
.IsEmpty() && refLabel
.name
.Left(m_SingleRemote
.GetLength() + 1) == m_SingleRemote
+ _T("/"))
1356 refLabel
.simplifiedName
= _T("/") + refLabel
.name
.Mid(m_SingleRemote
.GetLength() + 1);
1357 refLabel
.singleRemote
= true;
1362 case CGit::REF_TYPE::ANNOTATED_TAG
:
1363 case CGit::REF_TYPE::TAG
:
1364 if (!(m_ShowRefMask
& LOGLIST_SHOWTAGS
))
1366 refLabel
.color
= m_Colors
.GetColor(CColors::Tag
);
1368 case CGit::REF_TYPE::STASH
:
1369 if (!(m_ShowRefMask
& LOGLIST_SHOWSTASH
))
1371 refLabel
.color
= m_Colors
.GetColor(CColors::Stash
);
1373 case CGit::REF_TYPE::BISECT_GOOD
:
1374 case CGit::REF_TYPE::BISECT_BAD
:
1375 if (!(m_ShowRefMask
& LOGLIST_SHOWBISECT
))
1377 refLabel
.color
= (refLabel
.refType
== CGit::REF_TYPE::BISECT_GOOD
) ? m_Colors
.GetColor(CColors::BisectGood
): m_Colors
.GetColor(CColors::BisectBad
);
1382 refsToShow
.push_back(refLabel
);
1385 if (refsToShow
.empty())
1387 *pResult
= CDRF_DODEFAULT
;
1391 DrawTagBranchMessage(pLVCD
->nmcd
.hdc
, rect
, pLVCD
->nmcd
.dwItemSpec
, refsToShow
);
1393 *pResult
= CDRF_SKIPDEFAULT
;
1401 if (pLVCD
->iSubItem
== LOGLIST_ACTION
)
1403 if(this->m_IsIDReplaceAction
)
1405 *pResult
= CDRF_DODEFAULT
;
1408 *pResult
= CDRF_DODEFAULT
;
1410 if (m_arShownList
.size() <= pLVCD
->nmcd
.dwItemSpec
)
1414 int iconwidth
= ::GetSystemMetrics(SM_CXSMICON
);
1415 int iconheight
= ::GetSystemMetrics(SM_CYSMICON
);
1417 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1419 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1420 //TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right);
1421 // Get the selected state of the
1422 // item being drawn.
1424 // Fill the background if necessary
1425 FillBackGround(pLVCD
->nmcd
.hdc
, pLVCD
->nmcd
.dwItemSpec
, rect
);
1427 // Draw the icon(s) into the compatible DC
1428 int action
= pLogEntry
->GetAction(this);
1429 if (!pLogEntry
->m_IsDiffFiles
)
1431 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ ICONITEMBORDER
, rect
.top
, m_hFetchIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1432 *pResult
= CDRF_SKIPDEFAULT
;
1436 if (action
& CTGitPath::LOGACTIONS_MODIFIED
)
1437 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ ICONITEMBORDER
, rect
.top
, m_hModifiedIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1440 if (action
& (CTGitPath::LOGACTIONS_ADDED
| CTGitPath::LOGACTIONS_COPY
))
1441 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ nIcons
* iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hAddedIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1444 if (action
& CTGitPath::LOGACTIONS_DELETED
)
1445 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ nIcons
* iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hDeletedIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1448 if (action
& CTGitPath::LOGACTIONS_REPLACED
)
1449 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ nIcons
* iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hReplacedIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1452 if (action
& CTGitPath::LOGACTIONS_UNMERGED
)
1453 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ nIcons
* iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hConflictedIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1456 *pResult
= CDRF_SKIPDEFAULT
;
1462 *pResult
= CDRF_DODEFAULT
;
1465 CString
FindSVNRev(const CString
& msg
)
1469 const std::tr1::wsregex_iterator end
;
1470 std::wstring s
= msg
;
1471 std::tr1::wregex
regex1(_T("^\\s*git-svn-id:\\s+(.*)\\@(\\d+)\\s([a-f\\d\\-]+)$"));
1472 for (std::tr1::wsregex_iterator
it(s
.cbegin(), s
.cend(), regex1
); it
!= end
; ++it
)
1474 const std::tr1::wsmatch match
= *it
;
1475 if (match
.size() == 4)
1477 ATLTRACE(_T("matched rev: %s\n"), std::wstring(match
[2]).c_str());
1478 return std::wstring(match
[2]).c_str();
1481 std::tr1::wregex
regex2(_T("^\\s*git-svn-id:\\s(\\d+)\\@([a-f\\d\\-]+)$"));
1482 for (std::tr1::wsregex_iterator
it(s
.cbegin(), s
.cend(), regex2
); it
!= end
; ++it
)
1484 const std::tr1::wsmatch match
= *it
;
1485 if (match
.size() == 3)
1487 ATLTRACE(_T("matched rev: %s\n"), std::wstring(match
[1]).c_str());
1488 return std::wstring(match
[1]).c_str();
1492 catch (std::exception
) {}
1497 CString
CGitLogListBase::MessageDisplayStr(GitRev
* pLogEntry
)
1499 if (!m_bFullCommitMessageOnLogLine
|| pLogEntry
->GetBody().IsEmpty())
1500 return pLogEntry
->GetSubject();
1502 CString
txt(pLogEntry
->GetSubject());
1504 txt
+= pLogEntry
->GetBody();
1507 txt
.Replace(_T('\n'), _T(' '));
1508 txt
.Replace(_T('\r'), _T(' '));
1513 // CGitLogListBase message handlers
1515 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1517 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
1519 // Create a pointer to the item
1520 LV_ITEM
* pItem
= &(pDispInfo
)->item
;
1522 // Do the list need text information?
1523 if (!(pItem
->mask
& LVIF_TEXT
))
1526 // By default, clear text buffer.
1527 lstrcpyn(pItem
->pszText
, _T(""), pItem
->cchTextMax
- 1);
1529 bool bOutOfRange
= pItem
->iItem
>= ShownCountWithStopped();
1532 if (m_bNoDispUpdates
|| bOutOfRange
)
1535 // Which item number?
1536 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(pItem
->iItem
);
1540 temp
.Format(_T("%d"),pItem
->iItem
+1);
1542 temp
.Format(_T("%d"), m_arShownList
.size() - pItem
->iItem
);
1545 switch (pItem
->iSubItem
)
1547 case LOGLIST_GRAPH
: //Graphic
1549 case LOGLIST_REBASE
:
1551 if (this->m_IsRebaseReplaceGraph
&& pLogEntry
)
1552 lstrcpyn(pItem
->pszText
, GetRebaseActionName(pLogEntry
->GetRebaseAction() & LOGACTIONS_REBASE_MODE_MASK
), pItem
->cchTextMax
- 1);
1555 case LOGLIST_ACTION
: //action -- no text in the column
1559 lstrcpyn(pItem
->pszText
, pLogEntry
->m_CommitHash
.ToString(), pItem
->cchTextMax
- 1);
1562 if(this->m_IsIDReplaceAction
)
1563 lstrcpyn(pItem
->pszText
, temp
, pItem
->cchTextMax
- 1);
1565 case LOGLIST_MESSAGE
: //Message
1567 lstrcpyn(pItem
->pszText
, (LPCTSTR
)MessageDisplayStr(pLogEntry
), pItem
->cchTextMax
- 1);
1569 case LOGLIST_AUTHOR
: //Author
1571 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetAuthorName(), pItem
->cchTextMax
- 1);
1573 case LOGLIST_DATE
: //Date
1574 if ( pLogEntry
&& (!pLogEntry
->m_CommitHash
.IsEmpty()) )
1575 lstrcpyn(pItem
->pszText
,
1576 CLoglistUtils::FormatDateAndTime(pLogEntry
->GetAuthorDate(), m_DateFormat
, true, m_bRelativeTimes
),
1577 pItem
->cchTextMax
- 1);
1582 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetAuthorEmail(), pItem
->cchTextMax
- 1);
1585 case LOGLIST_COMMIT_NAME
: //Commit
1587 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetCommitterName(), pItem
->cchTextMax
- 1);
1590 case LOGLIST_COMMIT_EMAIL
: //Commit Email
1592 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetCommitterEmail(), pItem
->cchTextMax
- 1);
1595 case LOGLIST_COMMIT_DATE
: //Commit Date
1596 if (pLogEntry
&& (!pLogEntry
->m_CommitHash
.IsEmpty()))
1597 lstrcpyn(pItem
->pszText
,
1598 CLoglistUtils::FormatDateAndTime(pLogEntry
->GetCommitterDate(), m_DateFormat
, true, m_bRelativeTimes
),
1599 pItem
->cchTextMax
- 1);
1601 case LOGLIST_BUG
: //Bug ID
1603 lstrcpyn(pItem
->pszText
, (LPCTSTR
)this->m_ProjectProperties
.FindBugID(pLogEntry
->GetSubjectBody()), pItem
->cchTextMax
- 1);
1605 case LOGLIST_SVNREV
: //SVN revision
1607 lstrcpyn(pItem
->pszText
, (LPCTSTR
)FindSVNRev(pLogEntry
->GetSubjectBody()), pItem
->cchTextMax
- 1);
1615 bool CGitLogListBase::IsOnStash(int index
)
1617 GitRevLoglist
* rev
= m_arShownList
.SafeGetAt(index
);
1622 GitRevLoglist
* preRev
= m_arShownList
.SafeGetAt(index
- 1);
1623 if (IsStash(preRev
))
1624 return preRev
->m_ParentHash
.size() == 2 && preRev
->m_ParentHash
[1] == rev
->m_CommitHash
;
1629 bool CGitLogListBase::IsStash(const GitRev
* pSelLogEntry
)
1631 for (size_t i
= 0; i
< m_HashMap
[pSelLogEntry
->m_CommitHash
].size(); ++i
)
1633 if (m_HashMap
[pSelLogEntry
->m_CommitHash
][i
] == _T("refs/stash"))
1639 bool CGitLogListBase::IsBisect(const GitRev
* pSelLogEntry
)
1641 for (size_t i
= 0; i
< m_HashMap
[pSelLogEntry
->m_CommitHash
].size(); ++i
)
1643 if (m_HashMap
[pSelLogEntry
->m_CommitHash
][i
].Left(12) == _T("refs/bisect/"))
1649 void CGitLogListBase::GetParentHashes(GitRev
*pRev
, GIT_REV_LIST
&parentHash
)
1651 if (pRev
->m_ParentHash
.empty())
1653 if (pRev
->GetParentFromHash(pRev
->m_CommitHash
))
1654 MessageBox(pRev
->GetLastErr(), _T("TortoiseGit"), MB_ICONERROR
);
1656 parentHash
= pRev
->m_ParentHash
;
1659 void CGitLogListBase::OnContextMenu(CWnd
* pWnd
, CPoint point
)
1661 if (pWnd
== GetHeaderCtrl())
1662 return m_ColumnManager
.OnContextMenuHeader(pWnd
,point
,!!IsGroupViewEnabled());
1664 int selIndex
= GetSelectionMark();
1666 return; // nothing selected, nothing to do with a context menu
1668 // if the user selected the info text telling about not all revisions shown due to
1669 // the "stop on copy/rename" option, we also don't show the context menu
1670 if (m_bStrictStopped
&& selIndex
== (int)m_arShownList
.size())
1673 // if the context menu is invoked through the keyboard, we have to use
1674 // a calculated position on where to anchor the menu on
1675 if ((point
.x
== -1) && (point
.y
== -1))
1678 GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
1679 ClientToScreen(&rect
);
1680 point
= rect
.CenterPoint();
1682 m_nSearchIndex
= selIndex
;
1683 m_bCancelled
= FALSE
;
1685 // calculate some information the context menu commands can use
1686 // CString pathURL = GetURLFromPath(m_path);
1688 POSITION pos
= GetFirstSelectedItemPosition();
1689 int indexNext
= GetNextSelectedItem(pos
);
1693 GitRevLoglist
* pSelLogEntry
= m_arShownList
.SafeGetAt(indexNext
);
1694 if (pSelLogEntry
== nullptr)
1697 GitRev revSelected
= pSelLogEntry
->Rev
;
1698 GitRev revPrevious
= git_revnum_t(revSelected
)-1;
1699 if ((pSelLogEntry
->pArChangedPaths
)&&(pSelLogEntry
->pArChangedPaths
->GetCount() <= 2))
1701 for (int i
=0; i
<pSelLogEntry
->pArChangedPaths
->GetCount(); ++i
)
1703 LogChangedPath
* changedpath
= (LogChangedPath
*)pSelLogEntry
->pArChangedPaths
->SafeGetAt(i
);
1704 if (changedpath
->lCopyFromRev
)
1705 revPrevious
= changedpath
->lCopyFromRev
;
1708 GitRev revSelected2
;
1711 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
)));
1712 revSelected2
= pLogEntry
->Rev
;
1714 bool bAllFromTheSameAuthor
= true;
1715 CString firstAuthor
;
1716 CLogDataVector selEntries
;
1717 GitRev revLowest
, revHighest
;
1718 GitRevRangeArray revisionRanges
;
1720 POSITION pos
= GetFirstSelectedItemPosition();
1721 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
)));
1722 revisionRanges
.AddRevision(pLogEntry
->Rev
);
1723 selEntries
.push_back(pLogEntry
);
1724 firstAuthor
= pLogEntry
->sAuthor
;
1725 revLowest
= pLogEntry
->Rev
;
1726 revHighest
= pLogEntry
->Rev
;
1729 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
)));
1730 revisionRanges
.AddRevision(pLogEntry
->Rev
);
1731 selEntries
.push_back(pLogEntry
);
1732 if (firstAuthor
.Compare(pLogEntry
->sAuthor
))
1733 bAllFromTheSameAuthor
= false;
1734 revLowest
= (git_revnum_t(pLogEntry
->Rev
) > git_revnum_t(revLowest
) ? revLowest
: pLogEntry
->Rev
);
1735 revHighest
= (git_revnum_t(pLogEntry
->Rev
) < git_revnum_t(revHighest
) ? revHighest
: pLogEntry
->Rev
);
1741 bool showExtendedMenu
= (GetAsyncKeyState(VK_SHIFT
) & 0x8000) != 0;
1743 int FirstSelect
=-1, LastSelect
=-1;
1744 pos
= GetFirstSelectedItemPosition();
1745 FirstSelect
= GetNextSelectedItem(pos
);
1748 LastSelect
= GetNextSelectedItem(pos
);
1750 //entry is selected, now show the popup menu
1752 CIconMenu subbranchmenu
, submenu
, gnudiffmenu
, diffmenu
, blamemenu
, revertmenu
;
1754 if (popup
.CreatePopupMenu())
1756 bool isHeadCommit
= (pSelLogEntry
->m_CommitHash
== m_HeadHash
);
1757 CString currentBranch
= _T("refs/heads/") + g_Git
.GetCurrentBranch();
1758 bool isMergeActive
= CTGitPath(g_Git
.m_CurrentDir
).IsMergeActive();
1759 bool isStash
= IsOnStash(indexNext
);
1760 GIT_REV_LIST parentHash
;
1761 GetParentHashes(pSelLogEntry
, parentHash
);
1763 if (m_ContextMenuMask
& GetContextMenuBit(ID_REBASE_PICK
) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)))
1764 popup
.AppendMenuIcon(ID_REBASE_PICK
, IDS_REBASE_PICK
, IDI_PICK
);
1766 if (m_ContextMenuMask
& GetContextMenuBit(ID_REBASE_SQUASH
) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)) && FirstSelect
!= GetItemCount() - 1 && LastSelect
!= GetItemCount() - 1 && (m_bIsCherryPick
|| pSelLogEntry
->ParentsCount() == 1))
1767 popup
.AppendMenuIcon(ID_REBASE_SQUASH
, IDS_REBASE_SQUASH
, IDI_SQUASH
);
1769 if (m_ContextMenuMask
& GetContextMenuBit(ID_REBASE_EDIT
) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)))
1770 popup
.AppendMenuIcon(ID_REBASE_EDIT
, IDS_REBASE_EDIT
, IDI_EDIT
);
1772 if (m_ContextMenuMask
& GetContextMenuBit(ID_REBASE_SKIP
) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)))
1773 popup
.AppendMenuIcon(ID_REBASE_SKIP
, IDS_REBASE_SKIP
, IDI_SKIP
);
1775 if (m_ContextMenuMask
& (GetContextMenuBit(ID_REBASE_SKIP
) | GetContextMenuBit(ID_REBASE_EDIT
) | GetContextMenuBit(ID_REBASE_SQUASH
) | GetContextMenuBit(ID_REBASE_PICK
)) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)))
1776 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1778 if (GetSelectedCount() == 1)
1781 bool requiresSeparator
= false;
1782 if( !pSelLogEntry
->m_CommitHash
.IsEmpty())
1784 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPARE
) && m_hasWC
) // compare revision with WC
1786 popup
.AppendMenuIcon(ID_COMPARE
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
1787 requiresSeparator
= true;
1792 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMMIT
))
1794 popup
.AppendMenuIcon(ID_COMMIT
, IDS_LOG_POPUP_COMMIT
, IDI_COMMIT
);
1795 requiresSeparator
= true;
1797 if (isMergeActive
&& (m_ContextMenuMask
& GetContextMenuBit(ID_MERGE_ABORT
)))
1799 popup
.AppendMenuIcon(ID_MERGE_ABORT
, IDS_MENUMERGEABORT
, IDI_MERGEABORT
);
1800 requiresSeparator
= true;
1804 if (m_ContextMenuMask
& GetContextMenuBit(ID_BLAMEPREVIOUS
))
1806 if (parentHash
.size() == 1)
1808 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_LOG_POPUP_BLAMEPREVIOUS
, IDI_BLAME
);
1809 requiresSeparator
= true;
1811 else if (parentHash
.size() > 1)
1813 blamemenu
.CreatePopupMenu();
1814 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_LOG_POPUP_BLAMEPREVIOUS
, IDI_BLAME
, blamemenu
.m_hMenu
);
1815 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
1818 str
.Format(IDS_PARENT
, i
+ 1);
1819 blamemenu
.AppendMenuIcon(ID_BLAMEPREVIOUS
+((i
+ 1) << 16), str
);
1821 requiresSeparator
= true;
1825 if(m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF1
) && m_hasWC
) // compare with WC, unified
1827 if (parentHash
.size() == 1)
1829 popup
.AppendMenuIcon(ID_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF_CH
, IDI_DIFF
);
1830 requiresSeparator
= true;
1832 else if (parentHash
.size() > 1)
1834 gnudiffmenu
.CreatePopupMenu();
1835 popup
.AppendMenuIcon(ID_GNUDIFF1
,IDS_LOG_POPUP_GNUDIFF_PARENT
, IDI_DIFF
, gnudiffmenu
.m_hMenu
);
1837 gnudiffmenu
.AppendMenuIcon((UINT_PTR
)(ID_GNUDIFF1
+ (0xFFFF << 16)), CString(MAKEINTRESOURCE(IDS_ALLPARENTS
)));
1838 gnudiffmenu
.AppendMenuIcon((UINT_PTR
)(ID_GNUDIFF1
+ (0xFFFE << 16)), CString(MAKEINTRESOURCE(IDS_ONLYMERGEDFILES
)));
1839 gnudiffmenu
.AppendMenuIcon((UINT_PTR
)(ID_GNUDIFF1
+ (0xFFFD << 16)), CString(MAKEINTRESOURCE(IDS_DIFFWITHMERGE
)));
1841 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
1844 str
.Format(IDS_PARENT
, i
+ 1);
1845 gnudiffmenu
.AppendMenuIcon(ID_GNUDIFF1
+((i
+1)<<16),str
);
1847 requiresSeparator
= true;
1851 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPAREWITHPREVIOUS
))
1853 if (parentHash
.size() == 1)
1855 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_LOG_POPUP_COMPAREWITHPREVIOUS
, IDI_DIFF
);
1856 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1857 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
1858 requiresSeparator
= true;
1860 else if (parentHash
.size() > 1)
1862 diffmenu
.CreatePopupMenu();
1863 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_LOG_POPUP_COMPAREWITHPREVIOUS
, IDI_DIFF
, diffmenu
.m_hMenu
);
1864 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
1867 str
.Format(IDS_PARENT
, i
+ 1);
1868 diffmenu
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
+((i
+1)<<16),str
);
1869 if (i
== 0 && CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1871 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
1872 diffmenu
.SetDefaultItem((UINT
)(ID_COMPAREWITHPREVIOUS
+ ((i
+ 1) << 16)), FALSE
);
1875 requiresSeparator
= true;
1879 if(m_ContextMenuMask
&GetContextMenuBit(ID_BLAME
))
1881 popup
.AppendMenuIcon(ID_BLAME
, IDS_LOG_POPUP_BLAME
, IDI_BLAME
);
1882 requiresSeparator
= true;
1885 if (requiresSeparator
)
1887 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1888 requiresSeparator
= false;
1891 if (pSelLogEntry
->m_CommitHash
.IsEmpty() && !isMergeActive
)
1893 if(m_ContextMenuMask
&GetContextMenuBit(ID_STASH_SAVE
))
1895 popup
.AppendMenuIcon(ID_STASH_SAVE
, IDS_MENUSTASHSAVE
, IDI_COMMIT
);
1896 requiresSeparator
= true;
1900 if ((pSelLogEntry
->m_CommitHash
.IsEmpty() || isStash
) && CTGitPath(g_Git
.m_CurrentDir
).HasStashDir())
1902 if (m_ContextMenuMask
&GetContextMenuBit(ID_STASH_POP
))
1904 popup
.AppendMenuIcon(ID_STASH_POP
, IDS_MENUSTASHPOP
, IDI_RELOCATE
);
1905 requiresSeparator
= true;
1908 if (m_ContextMenuMask
&GetContextMenuBit(ID_STASH_LIST
))
1910 popup
.AppendMenuIcon(ID_STASH_LIST
, IDS_MENUSTASHLIST
, IDI_LOG
);
1911 requiresSeparator
= true;
1915 if (requiresSeparator
)
1917 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1918 requiresSeparator
= false;
1921 if (CTGitPath(g_Git
.m_CurrentDir
).IsBisectActive())
1923 GitRevLoglist
* pFirstEntry
= m_arShownList
.SafeGetAt(FirstSelect
);
1924 if (m_ContextMenuMask
&GetContextMenuBit(ID_BISECTGOOD
) && !IsBisect(pFirstEntry
))
1926 popup
.AppendMenuIcon(ID_BISECTGOOD
, IDS_MENUBISECTGOOD
, IDI_THUMB_UP
);
1927 requiresSeparator
= true;
1930 if (m_ContextMenuMask
&GetContextMenuBit(ID_BISECTBAD
) && !IsBisect(pFirstEntry
))
1932 popup
.AppendMenuIcon(ID_BISECTBAD
, IDS_MENUBISECTBAD
, IDI_THUMB_DOWN
);
1933 requiresSeparator
= true;
1937 if (pSelLogEntry
->m_CommitHash
.IsEmpty() && CTGitPath(g_Git
.m_CurrentDir
).IsBisectActive())
1939 if (m_ContextMenuMask
&GetContextMenuBit(ID_BISECTRESET
))
1941 popup
.AppendMenuIcon(ID_BISECTRESET
, IDS_MENUBISECTRESET
, IDI_BISECT_RESET
);
1942 requiresSeparator
= true;
1946 if (requiresSeparator
)
1948 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1949 requiresSeparator
= false;
1952 if (pSelLogEntry
->m_CommitHash
.IsEmpty())
1954 if (m_ContextMenuMask
& GetContextMenuBit(ID_PULL
) && !isMergeActive
)
1955 popup
.AppendMenuIcon(ID_PULL
, IDS_MENUPULL
, IDI_PULL
);
1957 if(m_ContextMenuMask
&GetContextMenuBit(ID_FETCH
))
1958 popup
.AppendMenuIcon(ID_FETCH
, IDS_MENUFETCH
, IDI_PULL
);
1960 if (CTGitPath(g_Git
.m_CurrentDir
).HasSubmodules() && m_ContextMenuMask
& GetContextMenuBit(ID_SUBMODULE_UPDATE
))
1961 popup
.AppendMenuIcon(ID_SUBMODULE_UPDATE
, IDS_PROC_SYNC_SUBKODULEUPDATE
, IDI_UPDATE
);
1963 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1965 if (m_ContextMenuMask
& GetContextMenuBit(ID_CLEANUP
))
1966 popup
.AppendMenuIcon(ID_CLEANUP
, IDS_MENUCLEANUP
, IDI_CLEANUP
);
1968 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1972 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
1974 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
1976 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
1978 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
1980 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
1981 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
1983 // popup.AppendMenu(MF_SEPARATOR, NULL);
1988 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
1990 if(!pSelLogEntry
->m_CommitHash
.IsEmpty())
1992 if((m_ContextMenuMask
&GetContextMenuBit(ID_LOG
)) &&
1993 GetSelectedCount() == 1)
1994 popup
.AppendMenuIcon(ID_LOG
, IDS_LOG_POPUP_LOG
, IDI_LOG
);
1996 if (m_ContextMenuMask
&GetContextMenuBit(ID_REPOBROWSE
))
1997 popup
.AppendMenuIcon(ID_REPOBROWSE
, IDS_LOG_BROWSEREPO
, IDI_REPOBROWSE
);
1999 str
.Format(IDS_LOG_POPUP_MERGEREV
, (LPCTSTR
)g_Git
.GetCurrentBranch());
2001 if (m_ContextMenuMask
&GetContextMenuBit(ID_MERGEREV
) && !isHeadCommit
&& m_hasWC
&& !isMergeActive
&& !isStash
)
2003 popup
.AppendMenuIcon(ID_MERGEREV
, str
, IDI_MERGE
);
2005 size_t index
= (size_t)-1;
2006 CGit::REF_TYPE type
= CGit::REF_TYPE::UNKNOWN
;
2007 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, nullptr, &index
))
2008 popup
.SetMenuItemData(ID_MERGEREV
, (ULONG_PTR
)&m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2011 str
.Format(IDS_RESET_TO_THIS_FORMAT
, (LPCTSTR
)g_Git
.GetCurrentBranch());
2013 if (m_ContextMenuMask
&GetContextMenuBit(ID_RESET
) && m_hasWC
&& !isStash
)
2014 popup
.AppendMenuIcon(ID_RESET
,str
,IDI_REVERT
);
2017 // Add Switch Branch express Menu
2018 if( this->m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.end()
2019 && (m_ContextMenuMask
&GetContextMenuBit(ID_SWITCHBRANCH
) && m_hasWC
&& !isStash
)
2022 std::vector
<const CString
*> branchs
;
2023 auto addCheck
= [&](const CString
& ref
)
2025 if (ref
.Find(_T("refs/heads/")) != 0 || ref
== currentBranch
)
2027 branchs
.push_back(&ref
);
2029 size_t index
= (size_t)-1;
2030 CGit::REF_TYPE type
= CGit::REF_TYPE::UNKNOWN
;
2031 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, nullptr, &index
))
2032 addCheck(m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2034 for_each(m_HashMap
[pSelLogEntry
->m_CommitHash
], addCheck
);
2037 str2
.LoadString(IDS_SWITCH_BRANCH
);
2039 if(branchs
.size() == 1)
2042 str2
+= _T('"') + branchs
[0]->Mid(11) + _T('"');
2043 popup
.AppendMenuIcon(ID_SWITCHBRANCH
, str2
, IDI_SWITCH
);
2045 popup
.SetMenuItemData(ID_SWITCHBRANCH
,(ULONG_PTR
)branchs
[0]);
2048 else if(branchs
.size() > 1)
2050 subbranchmenu
.CreatePopupMenu();
2051 for (size_t i
= 0 ; i
< branchs
.size(); ++i
)
2053 if (*branchs
[i
] != currentBranch
)
2055 subbranchmenu
.AppendMenuIcon(ID_SWITCHBRANCH
+(i
<<16), branchs
[i
]->Mid(11));
2056 subbranchmenu
.SetMenuItemData(ID_SWITCHBRANCH
+(i
<<16), (ULONG_PTR
) branchs
[i
]);
2060 popup
.AppendMenuIcon(ID_SWITCHBRANCH
, str2
, IDI_SWITCH
, subbranchmenu
.m_hMenu
);
2064 if (m_ContextMenuMask
&GetContextMenuBit(ID_SWITCHTOREV
) && !isHeadCommit
&& m_hasWC
&& !isStash
)
2066 popup
.AppendMenuIcon(ID_SWITCHTOREV
, IDS_SWITCH_TO_THIS
, IDI_SWITCH
);
2067 size_t index
= (size_t)-1;
2068 CGit::REF_TYPE type
= CGit::REF_TYPE::UNKNOWN
;
2069 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, nullptr, &index
))
2070 popup
.SetMenuItemData(ID_SWITCHTOREV
, (ULONG_PTR
)&m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2073 if (m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_BRANCH
) && !isStash
)
2075 popup
.AppendMenuIcon(ID_CREATE_BRANCH
, IDS_CREATE_BRANCH_AT_THIS
, IDI_COPY
);
2077 size_t index
= (size_t)-1;
2078 CGit::REF_TYPE type
= CGit::REF_TYPE::REMOTE_BRANCH
;
2079 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, nullptr, &index
))
2080 popup
.SetMenuItemData(ID_CREATE_BRANCH
, (ULONG_PTR
)&m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2083 if (m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_TAG
) && !isStash
)
2084 popup
.AppendMenuIcon(ID_CREATE_TAG
,IDS_CREATE_TAG_AT_THIS
, IDI_TAG
);
2086 str
.Format(IDS_REBASE_THIS_FORMAT
, (LPCTSTR
)g_Git
.GetCurrentBranch());
2088 if (pSelLogEntry
->m_CommitHash
!= m_HeadHash
&& m_hasWC
&& !isMergeActive
&& !isStash
)
2089 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_TO_VERSION
))
2090 popup
.AppendMenuIcon(ID_REBASE_TO_VERSION
, str
, IDI_REBASE
);
2092 if(m_ContextMenuMask
&GetContextMenuBit(ID_EXPORT
))
2093 popup
.AppendMenuIcon(ID_EXPORT
,IDS_EXPORT_TO_THIS
, IDI_EXPORT
);
2095 if (m_ContextMenuMask
&GetContextMenuBit(ID_REVERTREV
) && m_hasWC
&& !isMergeActive
&& !isStash
)
2097 if (parentHash
.size() == 1)
2098 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
);
2099 else if (parentHash
.size() > 1)
2101 revertmenu
.CreatePopupMenu();
2102 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
, revertmenu
.m_hMenu
);
2104 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
2107 str2
.Format(IDS_PARENT
, i
+ 1);
2108 revertmenu
.AppendMenuIcon(ID_REVERTREV
+ ((i
+ 1) << 16), str2
);
2113 if (m_ContextMenuMask
&GetContextMenuBit(ID_EDITNOTE
) && !isStash
)
2114 popup
.AppendMenuIcon(ID_EDITNOTE
, IDS_EDIT_NOTES
, IDI_EDIT
);
2116 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2120 if(!pSelLogEntry
->m_Ref
.IsEmpty())
2122 popup
.AppendMenuIcon(ID_REFLOG_DEL
, IDS_REFLOG_DEL
, IDI_DELETE
);
2123 if (GetSelectedCount() == 1 && pSelLogEntry
->m_Ref
.Find(_T("refs/stash")) == 0)
2124 popup
.AppendMenuIcon(ID_REFLOG_STASH_APPLY
, IDS_MENUSTASHAPPLY
, IDI_RELOCATE
);
2125 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2128 if (GetSelectedCount() >= 2)
2130 bool bAddSeparator
= false;
2131 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
2133 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPARETWO
)) // compare two revisions
2134 popup
.AppendMenuIcon(ID_COMPARETWO
, IDS_LOG_POPUP_COMPARETWO
, IDI_DIFF
);
2137 if (GetSelectedCount() == 2)
2139 if(m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF2
) && m_hasWC
) // compare two revisions, unified
2140 popup
.AppendMenuIcon(ID_GNUDIFF2
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
2142 if (!pSelLogEntry
->m_CommitHash
.IsEmpty())
2144 CString firstSelHash
= pSelLogEntry
->m_CommitHash
.ToString().Left(g_Git
.GetShortHASHLength());
2145 GitRevLoglist
* pLastEntry
= m_arShownList
.SafeGetAt(LastSelect
);
2146 CString lastSelHash
= pLastEntry
->m_CommitHash
.ToString().Left(g_Git
.GetShortHASHLength());
2148 menu
.Format(IDS_SHOWLOG_OF
, (LPCTSTR
)(lastSelHash
+ _T("..") + firstSelHash
));
2149 popup
.AppendMenuIcon(ID_LOG_VIEWRANGE
, menu
, IDI_LOG
);
2150 menu
.Format(IDS_SHOWLOG_OF
, (LPCTSTR
)(lastSelHash
+ _T("...") + firstSelHash
));
2151 popup
.AppendMenuIcon(ID_LOG_VIEWRANGE_REACHABLEFROMONLYONE
, menu
, IDI_LOG
);
2154 bAddSeparator
= true;
2158 bAddSeparator
= true;
2160 if (m_ContextMenuMask
&GetContextMenuBit(ID_REVERTREV
) && m_hasWC
&& !isMergeActive
)
2161 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREVS
, IDI_REVERT
);
2164 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2167 if ( GetSelectedCount() >0 && (!pSelLogEntry
->m_CommitHash
.IsEmpty()))
2169 bool bAddSeparator
= false;
2170 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
2172 if (m_ContextMenuMask
&GetContextMenuBit(ID_COMBINE_COMMIT
) && m_hasWC
&& !isMergeActive
)
2176 headindex
= this->GetHeadIndex();
2177 if(headindex
>=0 && LastSelect
>= headindex
&& FirstSelect
>= headindex
)
2179 head
.Format(_T("HEAD~%d"), FirstSelect
- headindex
);
2181 if (g_Git
.GetHash(hashFirst
, head
))
2182 MessageBox(g_Git
.GetGitLastErr(_T("Could not get hash of ") + head
+ _T(".")), _T("TortoiseGit"), MB_ICONERROR
);
2183 head
.Format(_T("HEAD~%d"),LastSelect
-headindex
);
2185 if (g_Git
.GetHash(hash
, head
))
2186 MessageBox(g_Git
.GetGitLastErr(_T("Could not get hash of ") + head
+ _T(".")), _T("TortoiseGit"), MB_ICONERROR
);
2187 GitRevLoglist
* pFirstEntry
= m_arShownList
.SafeGetAt(FirstSelect
);
2188 GitRevLoglist
* pLastEntry
= m_arShownList
.SafeGetAt(LastSelect
);
2189 if (pFirstEntry
->m_CommitHash
== hashFirst
&& pLastEntry
->m_CommitHash
== hash
) {
2190 popup
.AppendMenuIcon(ID_COMBINE_COMMIT
,IDS_COMBINE_TO_ONE
,IDI_COMBINE
);
2191 bAddSeparator
= true;
2196 if (m_ContextMenuMask
&GetContextMenuBit(ID_CHERRY_PICK
) && !isHeadCommit
&& m_hasWC
&& !isMergeActive
) {
2197 if (GetSelectedCount() >= 2)
2198 popup
.AppendMenuIcon(ID_CHERRY_PICK
, IDS_CHERRY_PICK_VERSIONS
, IDI_EXPORT
);
2200 popup
.AppendMenuIcon(ID_CHERRY_PICK
, IDS_CHERRY_PICK_VERSION
, IDI_EXPORT
);
2201 bAddSeparator
= true;
2204 if (GetSelectedCount() <= 2 || (IsSelectionContinuous() && GetSelectedCount() > 0 && !isStash
))
2205 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_PATCH
)) {
2206 popup
.AppendMenuIcon(ID_CREATE_PATCH
, IDS_CREATE_PATCH
, IDI_PATCH
);
2207 bAddSeparator
= true;
2211 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2214 if (m_hasWC
&& !isMergeActive
&& !isStash
&& (m_ContextMenuMask
& GetContextMenuBit(ID_BISECTSTART
)) && GetSelectedCount() == 2 && !m_arShownList
.SafeGetAt(FirstSelect
)->m_CommitHash
.IsEmpty() && !CTGitPath(g_Git
.m_CurrentDir
).IsBisectActive())
2216 popup
.AppendMenuIcon(ID_BISECTSTART
, IDS_MENUBISECTSTART
, IDI_BISECT
);
2217 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2220 if (GetSelectedCount() == 1)
2222 bool bAddSeparator
= false;
2223 if (m_ContextMenuMask
&GetContextMenuBit(ID_PUSH
) && ((!isStash
&& !m_HashMap
[pSelLogEntry
->m_CommitHash
].empty()) || showExtendedMenu
))
2225 // show the push-option only if the log entry has an associated local branch
2226 bool isLocal
= find_if(m_HashMap
[pSelLogEntry
->m_CommitHash
], [](const CString
& ref
) { return ref
.Find(_T("refs/heads/")) == 0; }) != m_HashMap
[pSelLogEntry
->m_CommitHash
].cend();
2227 if (isLocal
|| showExtendedMenu
)
2230 str
.LoadString(IDS_LOG_PUSH
);
2233 size_t index
= (size_t)-1;
2234 CGit::REF_TYPE type
= CGit::REF_TYPE::LOCAL_BRANCH
;
2235 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, &branch
, &index
))
2236 str
.Insert(str
.Find(L
'.'), L
" \"" + branch
+ L
'"');
2238 popup
.AppendMenuIcon(ID_PUSH
, str
, IDI_PUSH
);
2240 if (index
!= (size_t)-1 && index
< m_HashMap
[pSelLogEntry
->m_CommitHash
].size())
2241 popup
.SetMenuItemData(ID_PUSH
, (ULONG_PTR
)&m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2243 bAddSeparator
= true;
2246 if (m_ContextMenuMask
& GetContextMenuBit(ID_PULL
) && isHeadCommit
&& !isMergeActive
&& m_hasWC
)
2248 popup
.AppendMenuIcon(ID_PULL
, IDS_MENUPULL
, IDI_PULL
);
2249 bAddSeparator
= true;
2253 if(m_ContextMenuMask
&GetContextMenuBit(ID_DELETE
))
2255 if( this->m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.end() )
2257 std::vector
<const CString
*> branchs
;
2258 auto addCheck
= [&](const CString
& ref
)
2260 if (ref
== currentBranch
)
2262 branchs
.push_back(&ref
);
2264 size_t index
= (size_t)-1;
2265 CGit::REF_TYPE type
= CGit::REF_TYPE::UNKNOWN
;
2266 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, nullptr, &index
))
2267 addCheck(m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2269 for_each(m_HashMap
[pSelLogEntry
->m_CommitHash
], addCheck
);
2272 if (branchs
.size() == 1)
2274 str
.LoadString(IDS_DELETE_BRANCHTAG_SHORT
);
2277 popup
.AppendMenuIcon(ID_DELETE
, str
, IDI_DELETE
);
2278 popup
.SetMenuItemData(ID_DELETE
, (ULONG_PTR
)branchs
[0]);
2279 bAddSeparator
= true;
2281 else if (branchs
.size() > 1)
2283 str
.LoadString(IDS_DELETE_BRANCHTAG
);
2284 submenu
.CreatePopupMenu();
2285 for (size_t i
= 0; i
< branchs
.size(); ++i
)
2287 submenu
.AppendMenuIcon(ID_DELETE
+ (i
<< 16), *branchs
[i
]);
2288 submenu
.SetMenuItemData(ID_DELETE
+ (i
<< 16), (ULONG_PTR
)branchs
[i
]);
2290 submenu
.AppendMenuIcon(ID_DELETE
+ (branchs
.size() << 16), IDS_ALL
);
2291 submenu
.SetMenuItemData(ID_DELETE
+ (branchs
.size() << 16), (ULONG_PTR
)MAKEINTRESOURCE(IDS_ALL
));
2293 popup
.AppendMenuIcon(ID_DELETE
,str
, IDI_DELETE
, submenu
.m_hMenu
);
2294 bAddSeparator
= true;
2297 } // m_ContextMenuMask &GetContextMenuBit(ID_DELETE)
2299 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2300 } // GetSelectedCount() == 1
2302 if (GetSelectedCount() != 0)
2304 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYHASH
))
2305 popup
.AppendMenuIcon(ID_COPYHASH
, IDS_COPY_COMMIT_HASH
, IDI_COPYCLIP
);
2306 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYCLIPBOARD
))
2307 popup
.AppendMenuIcon(ID_COPYCLIPBOARD
, IDS_LOG_POPUP_COPYTOCLIPBOARD
, IDI_COPYCLIP
);
2308 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYCLIPBOARDMESSAGES
))
2309 popup
.AppendMenuIcon(ID_COPYCLIPBOARDMESSAGES
, IDS_LOG_POPUP_COPYTOCLIPBOARDMESSAGES
, IDI_COPYCLIP
);
2312 if(m_ContextMenuMask
&GetContextMenuBit(ID_FINDENTRY
))
2313 popup
.AppendMenuIcon(ID_FINDENTRY
, IDS_LOG_POPUP_FIND
, IDI_FILTEREDIT
);
2315 if (GetSelectedCount() == 1 && m_ContextMenuMask
& GetContextMenuBit(ID_SHOWBRANCHES
) && !pSelLogEntry
->m_CommitHash
.IsEmpty())
2316 popup
.AppendMenuIcon(ID_SHOWBRANCHES
, IDS_LOG_POPUP_SHOWBRANCHES
, IDI_SHOWBRANCHES
);
2318 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2319 // DialogEnableWindow(IDOK, FALSE);
2320 // SetPromptApp(&theApp);
2322 this->ContextMenuAction(cmd
, FirstSelect
, LastSelect
, &popup
);
2324 // EnableOKButton();
2325 } // if (popup.CreatePopupMenu())
2328 bool CGitLogListBase::IsSelectionContinuous()
2330 if ( GetSelectedCount()==1 )
2332 // if only one revision is selected, the selection is of course
2337 POSITION pos
= GetFirstSelectedItemPosition();
2338 bool bContinuous
= (m_arShownList
.size() == m_logEntries
.size());
2341 int itemindex
= GetNextSelectedItem(pos
);
2344 int nextindex
= GetNextSelectedItem(pos
);
2345 if (nextindex
- itemindex
> 1)
2347 bContinuous
= false;
2350 itemindex
= nextindex
;
2356 void CGitLogListBase::CopySelectionToClipBoard(int toCopy
)
2359 POSITION pos
= GetFirstSelectedItemPosition();
2363 sRev
.LoadString(IDS_LOG_REVISION
);
2365 sAuthor
.LoadString(IDS_LOG_AUTHOR
);
2367 sDate
.LoadString(IDS_LOG_DATE
);
2369 sMessage
.LoadString(IDS_LOG_MESSAGE
);
2373 CString sLogCopyText
;
2375 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
));
2377 if (toCopy
== ID_COPY_ALL
)
2379 //pLogEntry->GetFiles(this)
2380 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
2382 CString
from(MAKEINTRESOURCE(IDS_STATUSLIST_FROM
));
2383 for (int cpPathIndex
= 0; cpPathIndex
<pLogEntry
->GetFiles(this).GetCount(); ++cpPathIndex
)
2385 sPaths
+= ((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetActionName() + _T(": ") + pLogEntry
->GetFiles(this)[cpPathIndex
].GetGitPathString();
2386 if (((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).m_Action
& (CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_COPY
) && !((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetGitOldPathString().IsEmpty())
2389 sPaths
.AppendFormat(from
, (LPCTSTR
)((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetGitOldPathString());
2391 sPaths
+= _T("\r\n");
2394 CString body
= pLogEntry
->GetBody();
2395 body
.Replace(_T("\n"), _T("\r\n"));
2396 sLogCopyText
.Format(_T("%s: %s\r\n%s: %s <%s>\r\n%s: %s\r\n%s:\r\n%s\r\n----\r\n%s\r\n\r\n"),
2397 (LPCTSTR
)sRev
, (LPCTSTR
)pLogEntry
->m_CommitHash
.ToString(),
2398 (LPCTSTR
)sAuthor
, (LPCTSTR
)pLogEntry
->GetAuthorName(), (LPCTSTR
)pLogEntry
->GetAuthorEmail(),
2400 (LPCTSTR
)CLoglistUtils::FormatDateAndTime(pLogEntry
->GetAuthorDate(), m_DateFormat
, true, m_bRelativeTimes
),
2401 (LPCTSTR
)sMessage
, (LPCTSTR
)pLogEntry
->GetSubjectBody(true),
2403 sClipdata
+= sLogCopyText
;
2405 else if (toCopy
== ID_COPY_MESSAGE
)
2407 sClipdata
+= _T("* ");
2408 sClipdata
+= pLogEntry
->GetSubjectBody(true);
2409 sClipdata
+= _T("\r\n\r\n");
2411 else if (toCopy
== ID_COPY_SUBJECT
)
2413 sClipdata
+= _T("* ");
2414 sClipdata
+= pLogEntry
->GetSubject().Trim();
2415 sClipdata
+= _T("\r\n\r\n");
2420 sClipdata
+= _T("\r\n");
2421 sClipdata
+= pLogEntry
->m_CommitHash
;
2426 CStringUtils::WriteAsciiStringToClipboard(sClipdata
, GetSafeHwnd());
2430 void CGitLogListBase::DiffSelectedRevWithPrevious()
2432 if (m_bThreadRunning
)
2435 int FirstSelect
=-1, LastSelect
=-1;
2436 POSITION pos
= GetFirstSelectedItemPosition();
2437 FirstSelect
= GetNextSelectedItem(pos
);
2439 LastSelect
= GetNextSelectedItem(pos
);
2441 ContextMenuAction(ID_COMPAREWITHPREVIOUS
, FirstSelect
, LastSelect
, nullptr);
2444 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2446 LPNMLVFINDITEM pFindInfo
= reinterpret_cast<LPNMLVFINDITEM
>(pNMHDR
);
2449 if (pFindInfo
->lvfi
.flags
& LVFI_PARAM
)
2451 if (pFindInfo
->iStart
< 0 || pFindInfo
->iStart
>= (int)m_arShownList
.size())
2453 if (!pFindInfo
->lvfi
.psz
)
2456 CString sCmp
= pFindInfo
->lvfi
.psz
;
2458 for (int i
=pFindInfo
->iStart
; i
<m_arShownList
.GetCount(); ++i
)
2460 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(i
));
2461 sRev
.Format(_T("%ld"), pLogEntry
->Rev
);
2462 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
2464 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
2472 if (sCmp
.Compare(sRev
)==0)
2479 if (pFindInfo
->lvfi
.flags
& LVFI_WRAP
)
2481 for (int i
=0; i
<pFindInfo
->iStart
; ++i
)
2483 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(i
));
2484 sRev
.Format(_T("%ld"), pLogEntry
->Rev
);
2485 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
2487 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
2495 if (sCmp
.Compare(sRev
)==0)
2507 int CGitLogListBase::FillGitLog(CTGitPath
*path
, CString
*range
, int info
)
2511 this->m_arShownList
.SafeRemoveAll();
2513 this->m_logEntries
.ClearAll();
2514 if (this->m_logEntries
.ParserFromLog(path
, 0, info
, range
))
2517 SetItemCountEx((int)m_logEntries
.size());
2519 for (unsigned int i
= 0; i
< m_logEntries
.size(); ++i
)
2523 m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1).m_IsFull
=TRUE
;
2524 this->m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1));
2528 m_logEntries
.GetGitRevAt(i
).m_IsFull
=TRUE
;
2529 this->m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2540 int CGitLogListBase::FillGitLog(std::set
<CGitHash
>& hashes
)
2544 m_arShownList
.SafeRemoveAll();
2546 m_logEntries
.ClearAll();
2547 if (m_logEntries
.Fill(hashes
))
2550 SetItemCountEx((int)m_logEntries
.size());
2552 for (unsigned int i
= 0; i
< m_logEntries
.size(); ++i
)
2556 m_logEntries
.GetGitRevAt(m_logEntries
.size() - i
- 1).m_IsFull
= TRUE
;
2557 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(m_logEntries
.size() - i
- 1));
2561 m_logEntries
.GetGitRevAt(i
).m_IsFull
= TRUE
;
2562 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2571 int CGitLogListBase::BeginFetchLog()
2575 this->m_arShownList
.SafeRemoveAll();
2577 this->m_logEntries
.ClearAll();
2579 this->m_LogCache
.ClearAllParent();
2581 m_LogCache
.FetchCacheIndex(g_Git
.m_CurrentDir
);
2584 if(this->m_Path
.IsEmpty())
2590 mask
= CGit::LOG_INFO_ONLY_HASH
;
2591 if (m_bIncludeBoundaryCommits
)
2592 mask
|= CGit::LOG_INFO_BOUNDARY
;
2593 // if(this->m_bAllBranch)
2594 mask
|= m_ShowMask
;
2598 this->m_logEntries
.insert(m_logEntries
.cbegin(), m_wcRev
.m_CommitHash
);
2600 this->m_LogCache
.m_HashMap
[m_wcRev
.m_CommitHash
]=m_wcRev
;
2603 if (m_sRange
.IsEmpty())
2604 m_sRange
= _T("HEAD");
2606 #if 0 /* use tortoiegit filter */
2607 if (this->m_nSelectedFilter
== LOGFILTER_ALL
|| m_nSelectedFilter
== LOGFILTER_AUTHORS
)
2608 data
.m_Author
= this->m_sFilterText
;
2610 if(this->m_nSelectedFilter
== LOGFILTER_ALL
|| m_nSelectedFilter
== LOGFILTER_MESSAGES
)
2611 data
.m_MessageFilter
= this->m_sFilterText
;
2613 data
.m_IsRegex
= m_bFilterWithRegex
;
2616 // follow does not work for directories
2617 if (!path
|| path
->IsDirectory())
2618 mask
&= ~CGit::LOG_INFO_FOLLOW
;
2619 // follow does not work with all branches 8at least in TGit)
2620 if (mask
& CGit::LOG_INFO_FOLLOW
)
2621 mask
&= ~(CGit::LOG_INFO_ALL_BRANCH
| CGit::LOG_INFO_BASIC_REFS
| CGit::LOG_INFO_LOCAL_BRANCHES
);
2623 CString cmd
= g_Git
.GetLogCmd(m_sRange
, path
, mask
, &m_Filter
, CRegDWORD(L
"Software\\TortoiseGit\\LogOrderBy", CGit::LOG_ORDER_TOPOORDER
));
2625 //this->m_logEntries.ParserFromLog();
2626 if(IsInWorkingThread())
2628 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
);
2632 SetItemCountEx((int)m_logEntries
.size());
2637 [] { git_init(); } ();
2642 MessageBox(_T("Could not initialize libgit.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2646 if (!g_Git
.CanParseRev(m_sRange
))
2648 if (!(mask
& CGit::LOG_INFO_ALL_BRANCH
) && !(mask
& CGit::LOG_INFO_BASIC_REFS
) && !(mask
& CGit::LOG_INFO_LOCAL_BRANCHES
))
2651 // if show all branches, pick any ref as dummy entry ref
2653 if (g_Git
.GetRefList(list
))
2654 MessageBox(g_Git
.GetGitLastErr(_T("Could not get all refs.")), _T("TortoiseGit"), MB_ICONERROR
);
2658 cmd
= g_Git
.GetLogCmd(list
[0], path
, mask
, &m_Filter
, CRegDWORD(L
"Software\\TortoiseGit\\LogOrderBy", CGit::LOG_ORDER_TOPOORDER
));
2661 g_Git
.m_critGitDllSec
.Lock();
2663 if (git_open_log(&m_DllGitLog
, CUnicodeUtils::GetMulti(cmd
, CP_UTF8
).GetBuffer()))
2665 g_Git
.m_critGitDllSec
.Unlock();
2671 g_Git
.m_critGitDllSec
.Unlock();
2673 MessageBox(_T("Could not open log.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2676 g_Git
.m_critGitDllSec
.Unlock();
2681 BOOL
CGitLogListBase::PreTranslateMessage(MSG
* pMsg
)
2683 if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='\r')
2685 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
2687 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
2689 DiffSelectedRevWithPrevious();
2694 if (GetFocus()==GetDlgItem(IDC_LOGMSG
))
2701 else if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
== 'A' && GetAsyncKeyState(VK_CONTROL
)&0x8000)
2703 // select all entries
2704 for (int i
=0; i
<GetItemCount(); ++i
)
2705 SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
2710 if (m_hAccel
&& !bSkipAccelerator
)
2712 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
2718 //m_tooltips.RelayEvent(pMsg);
2719 return __super::PreTranslateMessage(pMsg
);
2722 void CGitLogListBase::OnNMDblclkLoglist(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2724 // a double click on an entry in the revision list has happened
2727 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
2728 DiffSelectedRevWithPrevious();
2731 void CGitLogListBase::FetchLogAsync(void* data
)
2735 StartLoadingThread();
2738 UINT
CGitLogListBase::LogThreadEntry(LPVOID pVoid
)
2740 return ((CGitLogListBase
*)pVoid
)->LogThread();
2743 void CGitLogListBase::GetTimeRange(CTime
&oldest
, CTime
&latest
)
2746 oldest
=CTime::GetCurrentTime();
2747 latest
=CTime(1971,1,2,0,0,0);
2748 for (unsigned int i
= 0; i
< m_logEntries
.size(); ++i
)
2750 if(m_logEntries
[i
].IsEmpty())
2753 if (m_logEntries
.GetGitRevAt(i
).GetCommitterDate().GetTime() < oldest
.GetTime())
2754 oldest
= m_logEntries
.GetGitRevAt(i
).GetCommitterDate().GetTime();
2756 if (m_logEntries
.GetGitRevAt(i
).GetCommitterDate().GetTime() > latest
.GetTime())
2757 latest
= m_logEntries
.GetGitRevAt(i
).GetCommitterDate().GetTime();
2765 UINT
CGitLogListBase::LogThread()
2767 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_START
,0);
2773 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2774 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2779 std::tr1::wregex pat
;//(_T("Remove"), tr1::regex_constants::icase);
2780 bool bRegex
= false;
2781 if (m_bFilterWithRegex
)
2782 bRegex
= ValidateRegexp(m_sFilterText
, pat
, false);
2784 TRACE(_T("\n===Begin===\n"));
2785 //Update work copy item;
2787 if (!m_logEntries
.empty())
2789 GitRevLoglist
* pRev
= &m_logEntries
.GetGitRevAt(0);
2791 m_arShownList
.SafeAdd(pRev
);
2795 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2797 // store commit number of the last selected commit/line before the refresh or -1
2798 int lastSelectedHashNItem
= -1;
2799 if (m_lastSelectedHash
.IsEmpty())
2800 lastSelectedHashNItem
= 0;
2804 bool shouldWalk
= true;
2805 if (!g_Git
.CanParseRev(m_sRange
))
2807 // walk revisions if show all branches and there exists any ref
2808 if (!(m_ShowMask
& CGit::LOG_INFO_ALL_BRANCH
) && !(m_ShowMask
& CGit::LOG_INFO_BASIC_REFS
) && !(m_ShowMask
& CGit::LOG_INFO_LOCAL_BRANCHES
))
2813 if (g_Git
.GetRefList(list
))
2814 MessageBox(g_Git
.GetGitLastErr(_T("Could not get all refs.")), _T("TortoiseGit"), MB_ICONERROR
);
2822 g_Git
.m_critGitDllSec
.Lock();
2826 [&] {git_get_log_firstcommit(m_DllGitLog
);}();
2827 total
= git_get_log_estimate_commit_count(m_DllGitLog
);
2832 MessageBox(_T("Could not get first commit.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2835 g_Git
.m_critGitDllSec
.Unlock();
2838 t2
= t1
= GetTickCount64();
2839 int oldprecentage
= 0;
2840 size_t oldsize
= m_logEntries
.size();
2841 std::map
<CGitHash
, std::set
<CGitHash
>> commitChildren
;
2842 while (ret
== 0 && !m_bExitThread
)
2844 g_Git
.m_critGitDllSec
.Lock();
2847 [&] { ret
= git_get_log_nextcommit(this->m_DllGitLog
, &commit
, m_ShowMask
& CGit::LOG_INFO_FOLLOW
); } ();
2851 g_Git
.m_critGitDllSec
.Unlock();
2853 MessageBox(_T("Could not get next commit.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2856 g_Git
.m_critGitDllSec
.Unlock();
2860 if (ret
!= -2) // other than end of revision walking
2861 MessageBox((_T("Could not get next commit.\nlibgit returns:") + std::to_wstring(ret
)).c_str(), _T("TortoiseGit"), MB_ICONERROR
);
2865 if (commit
.m_ignore
== 1)
2867 git_free_commit(&commit
);
2871 //printf("%s\r\n",commit.GetSubject());
2875 CGitHash hash
= (char*)commit
.m_hash
;
2877 GitRevLoglist
* pRev
= m_LogCache
.GetCacheData(hash
);
2878 pRev
->m_GitCommit
= commit
;
2879 InterlockedExchange(&pRev
->m_IsCommitParsed
, FALSE
);
2881 char* note
= nullptr;
2882 g_Git
.m_critGitDllSec
.Lock();
2885 git_get_notes(commit
.m_hash
, ¬e
);
2889 g_Git
.m_critGitDllSec
.Unlock();
2891 MessageBox(_T("Could not get commit notes.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2894 g_Git
.m_critGitDllSec
.Unlock();
2898 pRev
->m_Notes
= CUnicodeUtils::GetUnicode(note
);
2903 if(!pRev
->m_IsDiffFiles
)
2905 pRev
->m_CallDiffAsync
= DiffAsync
;
2908 pRev
->ParserParentFromCommit(&commit
);
2909 if (m_ShowFilter
& FILTERSHOW_MERGEPOINTS
) // See also ShouldShowFilter()
2911 for (size_t i
= 0; i
< pRev
->m_ParentHash
.size(); ++i
)
2913 const CGitHash
&parentHash
= pRev
->m_ParentHash
[i
];
2914 auto it
= commitChildren
.find(parentHash
);
2915 if (it
== commitChildren
.end())
2916 it
= commitChildren
.insert(make_pair(parentHash
, std::set
<CGitHash
>())).first
;
2917 it
->second
.insert(pRev
->m_CommitHash
);
2926 bool visible
= true;
2927 if (HasFilterText())
2929 if(!IsMatchFilter(bRegex
,pRev
,pat
))
2932 if (visible
&& !ShouldShowFilter(pRev
, commitChildren
))
2934 this->m_critSec
.Lock();
2935 m_logEntries
.append(hash
, visible
);
2937 m_arShownList
.SafeAdd(pRev
);
2938 this->m_critSec
.Unlock();
2943 if (lastSelectedHashNItem
== -1 && hash
== m_lastSelectedHash
)
2944 lastSelectedHashNItem
= (int)m_arShownList
.size() - 1;
2946 t2
= GetTickCount64();
2948 if (t2
- t1
> 500UL || (m_logEntries
.size() - oldsize
> 100))
2951 int percent
= (int)m_logEntries
.size() * 100 / total
+ GITLOG_START
+ 1;
2954 if(percent
< GITLOG_START
)
2955 percent
= GITLOG_START
+1;
2957 oldsize
= m_logEntries
.size();
2958 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
2960 //if( percent > oldprecentage )
2962 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) percent
,0);
2963 oldprecentage
= percent
;
2966 if (lastSelectedHashNItem
>= 0)
2967 PostMessage(m_ScrollToMessage
, lastSelectedHashNItem
);
2972 g_Git
.m_critGitDllSec
.Lock();
2973 git_close_log(m_DllGitLog
);
2974 g_Git
.m_critGitDllSec
.Unlock();
2980 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2985 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
2987 if (lastSelectedHashNItem
>= 0)
2988 PostMessage(m_ScrollToMessage
, lastSelectedHashNItem
);
2991 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_END
,0);
2993 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2998 void CGitLogListBase::FetchRemoteList()
3000 STRING_VECTOR remoteList
;
3001 m_SingleRemote
.Empty();
3002 if (!g_Git
.GetRemoteList(remoteList
) && remoteList
.size() == 1)
3003 m_SingleRemote
= remoteList
[0];
3006 void CGitLogListBase::FetchTrackingBranchList()
3008 m_TrackingMap
.clear();
3009 for (auto it
= m_HashMap
.cbegin(); it
!= m_HashMap
.cend(); ++it
)
3011 for (const auto& ref
: it
->second
)
3014 if (CGit::GetShortName(ref
, branchName
, _T("refs/heads/")))
3016 CString pullRemote
, pullBranch
;
3017 g_Git
.GetRemoteTrackedBranch(branchName
, pullRemote
, pullBranch
);
3018 if (!pullRemote
.IsEmpty() && !pullBranch
.IsEmpty())
3019 m_TrackingMap
[branchName
] = std::make_pair(pullRemote
, pullBranch
);
3025 void CGitLogListBase::Refresh(BOOL IsCleanFilter
)
3027 SafeTerminateThread();
3029 this->SetItemCountEx(0);
3034 ShowGraphColumn((m_ShowMask
& CGit::LOG_INFO_FOLLOW
) ? false : true);
3036 //Update branch and Tag info
3039 m_pFindDialog
->RefreshList();
3040 //Assume Thread have exited
3041 //if(!m_bThreadRunning)
3043 m_logEntries
.clear();
3047 m_sFilterText
.Empty();
3050 SafeTerminateAsyncDiffThread();
3051 m_AsynDiffListLock
.Lock();
3052 m_AsynDiffList
.clear();
3053 m_AsynDiffListLock
.Unlock();
3054 StartAsyncDiffThread();
3056 StartLoadingThread();
3060 void CGitLogListBase::StartAsyncDiffThread()
3062 if (m_AsyncThreadExit
)
3064 if (InterlockedExchange(&m_AsyncThreadRunning
, TRUE
) != FALSE
)
3066 m_DiffingThread
= AfxBeginThread(AsyncThread
, this, THREAD_PRIORITY_BELOW_NORMAL
);
3067 if (!m_DiffingThread
)
3069 InterlockedExchange(&m_AsyncThreadRunning
, FALSE
);
3070 CMessageBox::Show(GetSafeHwnd(), IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
3074 void CGitLogListBase::StartLoadingThread()
3076 if (InterlockedExchange(&m_bThreadRunning
, TRUE
) != FALSE
)
3078 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3079 InterlockedExchange(&m_bExitThread
, FALSE
);
3080 m_LoadingThread
= AfxBeginThread(LogThreadEntry
, this, THREAD_PRIORITY_LOWEST
);
3081 if (!m_LoadingThread
)
3083 InterlockedExchange(&m_bThreadRunning
, FALSE
);
3084 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3085 CMessageBox::Show(GetSafeHwnd(), IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
3089 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str
, std::tr1::wregex
& pat
, bool bMatchCase
/* = false */)
3093 std::tr1::regex_constants::syntax_option_type type
= std::tr1::regex_constants::ECMAScript
;
3095 type
|= std::tr1::regex_constants::icase
;
3096 pat
= std::tr1::wregex(regexp_str
, type
);
3099 catch (std::exception
) {}
3102 BOOL
CGitLogListBase::IsMatchFilter(bool bRegex
, GitRevLoglist
* pRev
, std::tr1::wregex
& pat
)
3105 std::tr1::regex_constants::match_flag_type flags
= std::tr1::regex_constants::match_any
;
3108 if ((bRegex
)&&(m_bFilterWithRegex
))
3110 if (m_SelectedFilters
& LOGFILTER_BUGID
)
3112 if(this->m_bShowBugtraqColumn
)
3114 CString sBugIds
= m_ProjectProperties
.FindBugID(pRev
->GetSubjectBody());
3116 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR
)sBugIds
);
3117 if (std::regex_search(std::wstring(sBugIds
), pat
, flags
))
3122 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
3124 ATLTRACE(_T("messge = \"%s\"\n"), (LPCTSTR
)pRev
->GetSubject());
3125 if (std::regex_search(std::wstring((LPCTSTR
)pRev
->GetSubject()), pat
, flags
))
3129 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
3131 ATLTRACE(_T("messge = \"%s\"\n"), (LPCTSTR
)pRev
->GetBody());
3132 if (std::regex_search(std::wstring((LPCTSTR
)pRev
->GetBody()), pat
, flags
))
3136 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
3138 if (std::regex_search(std::wstring(pRev
->GetAuthorName()), pat
, flags
))
3141 if (std::regex_search(std::wstring(pRev
->GetCommitterName()), pat
, flags
))
3145 if (m_SelectedFilters
& LOGFILTER_EMAILS
)
3147 if (std::regex_search(std::wstring(pRev
->GetAuthorEmail()), pat
, flags
))
3150 if (std::regex_search(std::wstring(pRev
->GetCommitterEmail()), pat
, flags
))
3154 if (m_SelectedFilters
& LOGFILTER_REVS
)
3156 sRev
= pRev
->m_CommitHash
.ToString();
3157 if (std::regex_search(std::wstring((LPCTSTR
)sRev
), pat
, flags
))
3163 if (m_SelectedFilters
& LOGFILTER_NOTES
)
3165 if (std::regex_search(std::wstring(pRev
->m_Notes
), pat
, flags
))
3169 if (m_SelectedFilters
& LOGFILTER_REFNAME
)
3171 STRING_VECTOR refs
= m_HashMap
[pRev
->m_CommitHash
];
3172 for (const auto& ref
: refs
)
3174 if (std::regex_search(std::wstring(ref
), pat
, flags
))
3179 if (m_SelectedFilters
& LOGFILTER_ANNOTATEDTAG
)
3181 if (std::regex_search(std::wstring(GetTagInfo(pRev
)), pat
, flags
))
3185 if (m_SelectedFilters
& LOGFILTER_PATHS
)
3187 CTGitPathList
* pathList
= nullptr;
3188 if( pRev
->m_IsDiffFiles
)
3189 pathList
= &pRev
->GetFiles(this);
3192 if(!pRev
->m_IsSimpleListReady
)
3193 pRev
->SafeGetSimpleList(&g_Git
);
3197 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
->GetCount(); ++cpPathIndex
)
3199 if (std::regex_search(std::wstring((LPCTSTR
)pathList
->m_paths
.at(cpPathIndex
).GetGitOldPathString()), pat
, flags
))
3201 if (std::regex_search(std::wstring((LPCTSTR
)pathList
->m_paths
.at(cpPathIndex
).GetGitPathString()), pat
, flags
))
3205 for (size_t i
= 0; i
< pRev
->m_SimpleFileList
.size(); ++i
)
3207 if (std::regex_search(std::wstring((LPCTSTR
)pRev
->m_SimpleFileList
[i
]), pat
, flags
))
3214 CString find
= m_sFilterText
;
3215 if (!m_bFilterCaseSensitively
)
3217 result
= find
[0] == '!' ? FALSE
: TRUE
;
3221 if (m_SelectedFilters
& LOGFILTER_BUGID
)
3223 if(this->m_bShowBugtraqColumn
)
3225 CString sBugIds
= m_ProjectProperties
.FindBugID(pRev
->GetSubjectBody());
3227 if (!m_bFilterCaseSensitively
)
3228 sBugIds
.MakeLower();
3229 if ((sBugIds
.Find(find
) >= 0))
3234 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
3236 CString msg
= pRev
->GetSubject();
3238 if (!m_bFilterCaseSensitively
)
3239 msg
= msg
.MakeLower();
3240 if ((msg
.Find(find
) >= 0))
3244 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
3246 CString msg
= pRev
->GetBody();
3248 if (!m_bFilterCaseSensitively
)
3249 msg
= msg
.MakeLower();
3250 if ((msg
.Find(find
) >= 0))
3254 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
3256 CString msg
= pRev
->GetAuthorName();
3257 if (!m_bFilterCaseSensitively
)
3258 msg
= msg
.MakeLower();
3259 if ((msg
.Find(find
) >= 0))
3263 if (m_SelectedFilters
& LOGFILTER_EMAILS
)
3265 CString msg
= pRev
->GetAuthorEmail();
3266 if (!m_bFilterCaseSensitively
)
3267 msg
= msg
.MakeLower();
3268 if ((msg
.Find(find
) >= 0))
3272 if (m_SelectedFilters
& LOGFILTER_NOTES
)
3274 CString msg
= pRev
->m_Notes
;
3275 if (!m_bFilterCaseSensitively
)
3276 msg
= msg
.MakeLower();
3277 if ((msg
.Find(find
) >= 0))
3281 if (m_SelectedFilters
& LOGFILTER_REVS
)
3283 sRev
= pRev
->m_CommitHash
.ToString();
3284 if ((sRev
.Find(find
) >= 0))
3288 if (m_SelectedFilters
& LOGFILTER_ANNOTATEDTAG
)
3290 CString msg
= GetTagInfo(pRev
);
3291 if (!m_bFilterCaseSensitively
)
3292 msg
= msg
.MakeLower();
3293 if ((msg
.Find(find
) >= 0))
3297 if (m_SelectedFilters
& LOGFILTER_REFNAME
)
3299 STRING_VECTOR refs
= m_HashMap
[pRev
->m_CommitHash
];
3300 for (auto it
= refs
.cbegin(); it
!= refs
.cend(); ++it
)
3302 if (it
->Find(find
) >= 0)
3307 if (m_SelectedFilters
& LOGFILTER_PATHS
)
3309 CTGitPathList
* pathList
= nullptr;
3310 if( pRev
->m_IsDiffFiles
)
3311 pathList
= &pRev
->GetFiles(this);
3314 if(!pRev
->m_IsSimpleListReady
)
3315 pRev
->SafeGetSimpleList(&g_Git
);
3318 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
->GetCount() ; ++cpPathIndex
)
3320 CTGitPath
*cpath
= &pathList
->m_paths
.at(cpPathIndex
);
3321 CString path
= cpath
->GetGitOldPathString();
3322 if (!m_bFilterCaseSensitively
)
3324 if ((path
.Find(find
)>=0))
3326 path
= cpath
->GetGitPathString();
3327 if (!m_bFilterCaseSensitively
)
3329 if ((path
.Find(find
)>=0))
3333 for (size_t i
= 0; i
< pRev
->m_SimpleFileList
.size(); ++i
)
3335 CString path
= pRev
->m_SimpleFileList
[i
];
3336 if (!m_bFilterCaseSensitively
)
3338 if ((path
.Find(find
)>=0))
3342 } // else (from if (bRegex))
3346 static bool CStringStartsWith(const CString
&str
, const CString
&prefix
)
3348 return str
.Left(prefix
.GetLength()) == prefix
;
3350 bool CGitLogListBase::ShouldShowFilter(GitRevLoglist
* pRev
, const std::map
<CGitHash
, std::set
<CGitHash
>>& commitChildren
)
3352 if (m_ShowFilter
& FILTERSHOW_ANYCOMMIT
)
3355 if (m_ShowFilter
& FILTERSHOW_REFS
)
3358 const STRING_VECTOR
&refList
= m_HashMap
[pRev
->m_CommitHash
];
3359 for (size_t i
= 0; i
< refList
.size(); ++i
)
3361 const CString
&str
= refList
[i
];
3362 if (CStringStartsWith(str
, _T("refs/heads/")))
3364 if (m_ShowRefMask
& LOGLIST_SHOWLOCALBRANCHES
)
3367 else if (CStringStartsWith(str
, _T("refs/remotes/")))
3369 if (m_ShowRefMask
& LOGLIST_SHOWREMOTEBRANCHES
)
3372 else if (CStringStartsWith(str
, _T("refs/tags/")))
3374 if (m_ShowRefMask
& LOGLIST_SHOWTAGS
)
3377 else if (CStringStartsWith(str
, _T("refs/stash")))
3379 if (m_ShowRefMask
& LOGLIST_SHOWSTASH
)
3382 else if (CStringStartsWith(str
, _T("refs/bisect/")))
3384 if (m_ShowRefMask
& LOGLIST_SHOWBISECT
)
3388 // Keep the head too.
3389 if (pRev
->m_CommitHash
== m_HeadHash
)
3393 if (m_ShowFilter
& FILTERSHOW_MERGEPOINTS
)
3395 if (pRev
->ParentsCount() > 1)
3397 auto childrenIt
= commitChildren
.find(pRev
->m_CommitHash
);
3398 if (childrenIt
!= commitChildren
.end())
3400 const std::set
<CGitHash
> &children
= childrenIt
->second
;
3401 if (children
.size() > 1)
3408 void CGitLogListBase::ShowGraphColumn(bool bShow
)
3410 // HACK to hide graph column
3412 SetColumnWidth(0, m_ColumnManager
.GetWidth(0, false));
3414 SetColumnWidth(0, 0);
3417 CString
CGitLogListBase::GetTagInfo(GitRev
* pLogEntry
)
3422 if (m_HashMap
.find(pLogEntry
->m_CommitHash
) != m_HashMap
.end())
3424 STRING_VECTOR
&vector
= m_HashMap
[pLogEntry
->m_CommitHash
];
3425 for (size_t i
= 0; i
< vector
.size(); ++i
)
3427 if (vector
[i
].Find(_T("refs/tags/")) == 0)
3429 CString tag
= vector
[i
];
3430 int start
= vector
[i
].Find(_T("^{}"));
3432 tag
= tag
.Left(start
);
3436 cmd
.Format(_T("git.exe cat-file tag %s"), (LPCTSTR
)tag
);
3437 if (g_Git
.Run(cmd
, &output
, nullptr, CP_UTF8
) == 0)
3438 output
.AppendChar(_T('\n'));
3446 void CGitLogListBase::RecalculateShownList(CThreadSafePtrArray
* pShownlist
)
3448 pShownlist
->SafeRemoveAll();
3450 std::tr1::wregex pat
;//(_T("Remove"), tr1::regex_constants::icase);
3451 bool bRegex
= false;
3452 if (m_bFilterWithRegex
)
3453 bRegex
= ValidateRegexp(m_sFilterText
, pat
, false);
3455 std::tr1::regex_constants::match_flag_type flags
= std::tr1::regex_constants::match_any
;
3457 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
3459 if ((bRegex
)&&(m_bFilterWithRegex
))
3462 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_BUGID
))
3464 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR
)m_logEntries
[i
]->sBugIDs
);
3465 if (std::regex_search(std::wstring((LPCTSTR
)m_logEntries
[i
]->sBugIDs
), pat
, flags
)&&IsEntryInDateRange(i
))
3467 pShownlist
->SafeAdd(m_logEntries
[i
]);
3472 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
3474 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries
.GetGitRevAt(i
).GetSubject());
3475 if (std::regex_search(std::wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).GetSubject()), pat
, flags
)&&IsEntryInDateRange(i
))
3477 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3481 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
3483 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries
.GetGitRevAt(i
).GetBody());
3484 if (std::regex_search(std::wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).GetBody()), pat
, flags
)&&IsEntryInDateRange(i
))
3486 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3490 if (m_SelectedFilters
& LOGFILTER_PATHS
)
3492 CTGitPathList pathList
= m_logEntries
.GetGitRevAt(i
).GetFiles(this);
3495 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
.GetCount() && bGoing
; ++cpPathIndex
)
3497 CTGitPath cpath
= pathList
[cpPathIndex
];
3498 if (std::regex_search(std::wstring((LPCTSTR
)cpath
.GetGitOldPathString()), pat
, flags
)&&IsEntryInDateRange(i
))
3500 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3504 if (std::regex_search(std::wstring((LPCTSTR
)cpath
.GetGitPathString()), pat
, flags
)&&IsEntryInDateRange(i
))
3506 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3510 if (std::regex_search(std::wstring((LPCTSTR
)cpath
.GetActionName()), pat
, flags
)&&IsEntryInDateRange(i
))
3512 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3518 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
3520 if (std::regex_search(std::wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).GetAuthorName()), pat
, flags
)&&IsEntryInDateRange(i
))
3522 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3526 if (m_SelectedFilters
& LOGFILTER_EMAILS
)
3528 if (std::regex_search(std::wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).GetAuthorEmail()), pat
, flags
) && IsEntryInDateRange(i
))
3530 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3534 if (m_SelectedFilters
& LOGFILTER_REVS
)
3536 sRev
= m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString();
3537 if (std::regex_search(std::wstring((LPCTSTR
)sRev
), pat
, flags
)&&IsEntryInDateRange(i
))
3539 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3543 if (m_SelectedFilters
& LOGFILTER_REFNAME
)
3545 STRING_VECTOR refs
= m_HashMap
[m_logEntries
.GetGitRevAt(i
).m_CommitHash
];
3546 for (auto it
= refs
.cbegin(); it
!= refs
.cend(); ++it
)
3548 if (std::regex_search(std::wstring((LPCTSTR
)*it
), pat
, flags
) && IsEntryInDateRange(i
))
3550 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3558 CString find
= m_sFilterText
;
3559 if (!m_bFilterCaseSensitively
)
3562 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_BUGID
))
3564 CString sBugIDs
= m_logEntries
[i
]->sBugIDs
;
3566 if (!m_bFilterCaseSensitively
)
3567 sBugIDs
= sBugIDs
.MakeLower();
3568 if ((sBugIDs
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3570 pShownlist
->SafeAdd(m_logEntries
[i
]);
3575 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
3577 CString msg
= m_logEntries
.GetGitRevAt(i
).GetSubject();
3579 if (!m_bFilterCaseSensitively
)
3580 msg
= msg
.MakeLower();
3581 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3583 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3587 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
3589 CString msg
= m_logEntries
.GetGitRevAt(i
).GetBody();
3591 if (!m_bFilterCaseSensitively
)
3592 msg
= msg
.MakeLower();
3593 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3595 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3599 if (m_SelectedFilters
& LOGFILTER_PATHS
)
3601 CTGitPathList pathList
= m_logEntries
.GetGitRevAt(i
).GetFiles(this);
3604 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
.GetCount() && bGoing
; ++cpPathIndex
)
3606 CTGitPath cpath
= pathList
[cpPathIndex
];
3607 CString path
= cpath
.GetGitOldPathString();
3608 if (!m_bFilterCaseSensitively
)
3610 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
3612 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3616 path
= cpath
.GetGitPathString();
3617 if (!m_bFilterCaseSensitively
)
3619 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
3621 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3625 path
= cpath
.GetActionName();
3626 if (!m_bFilterCaseSensitively
)
3628 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
3630 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3636 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
3638 CString msg
= m_logEntries
.GetGitRevAt(i
).GetAuthorName();
3639 if (!m_bFilterCaseSensitively
)
3640 msg
= msg
.MakeLower();
3641 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3643 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3647 if (m_SelectedFilters
& LOGFILTER_EMAILS
)
3649 CString msg
= m_logEntries
.GetGitRevAt(i
).GetAuthorEmail();
3650 if (!m_bFilterCaseSensitively
)
3651 msg
= msg
.MakeLower();
3652 if ((msg
.Find(find
) >= 0) && (IsEntryInDateRange(i
)))
3654 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3658 if (m_SelectedFilters
& LOGFILTER_REVS
)
3660 sRev
= m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString();
3661 if ((sRev
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3663 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3667 if (m_SelectedFilters
& LOGFILTER_REFNAME
)
3669 STRING_VECTOR refs
= m_HashMap
[m_logEntries
.GetGitRevAt(i
).m_CommitHash
];
3670 for (auto it
= refs
.cbegin(); it
!= refs
.cend(); ++it
)
3672 if (it
->Find(find
) >= 0 && IsEntryInDateRange(i
))
3674 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3679 } // else (from if (bRegex))
3680 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
3683 BOOL
CGitLogListBase::IsEntryInDateRange(int /*i*/)
3686 __time64_t time = m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime();
3692 return time <= m_To;
3695 return time >= m_From;
3697 return ((time >= m_From)&&(time <= m_To));
3699 return TRUE
; /* git dll will filter time range */
3704 void CGitLogListBase::StartFilter()
3706 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3707 RecalculateShownList(&m_arShownList
);
3708 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3712 SetItemCountEx(ShownCountWithStopped());
3713 RedrawItems(0, ShownCountWithStopped());
3717 void CGitLogListBase::RemoveFilter()
3719 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3721 m_arShownList
.SafeRemoveAll();
3723 // reset the time filter too
3725 m_timFrom
= (__time64_t(m_tFrom
));
3726 m_timTo
= (__time64_t(m_tTo
));
3727 m_DateFrom
.SetTime(&m_timFrom
);
3728 m_DateTo
.SetTime(&m_timTo
);
3729 m_DateFrom
.SetRange(&m_timFrom
, &m_timTo
);
3730 m_DateTo
.SetRange(&m_timFrom
, &m_timTo
);
3733 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
3735 if(this->m_IsOldFirst
)
3736 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1));
3738 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3740 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
3742 SetItemCountEx(ShownCountWithStopped());
3743 RedrawItems(0, ShownCountWithStopped());
3745 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3748 void CGitLogListBase::Clear()
3750 m_arShownList
.SafeRemoveAll();
3753 m_logEntries
.ClearAll();
3756 void CGitLogListBase::OnDestroy()
3758 // save the column widths to the registry
3761 SafeTerminateThread();
3762 SafeTerminateAsyncDiffThread();
3765 while(m_LogCache
.SaveCache())
3773 //if(CMessageBox::Show(nullptr, _T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."), _T("TortoiseGit"),
3774 // MB_YESNO) == IDNO)
3778 CHintListCtrl::OnDestroy();
3781 LRESULT
CGitLogListBase::OnLoad(WPARAM wParam
,LPARAM
/*lParam*/)
3785 this->GetItemRect(i
,&rect
,LVIR_BOUNDS
);
3786 this->InvalidateRect(rect
);
3792 * Save column widths to the registry
3794 void CGitLogListBase::SaveColumnWidths()
3796 int maxcol
= m_ColumnManager
.GetColumnCount();
3798 // HACK that graph column is always shown
3799 SetColumnWidth(0, m_ColumnManager
.GetWidth(0, false));
3801 for (int col
= 0; col
< maxcol
; ++col
)
3802 if (m_ColumnManager
.IsVisible (col
))
3803 m_ColumnManager
.ColumnResized (col
);
3805 m_ColumnManager
.WriteSettings();
3808 int CGitLogListBase::GetHeadIndex()
3810 if(m_HeadHash
.IsEmpty())
3813 for (size_t i
= 0; i
< m_arShownList
.size(); ++i
)
3815 GitRev
* pRev
= m_arShownList
.SafeGetAt(i
);
3818 if(pRev
->m_CommitHash
.ToString() == m_HeadHash
)
3824 void CGitLogListBase::OnFind()
3828 m_pFindDialog
= new CFindDlg(this);
3829 m_pFindDialog
->Create(this);
3832 void CGitLogListBase::OnHdnBegintrack(NMHDR
*pNMHDR
, LRESULT
*pResult
)
3834 m_ColumnManager
.OnHdnBegintrack(pNMHDR
, pResult
);
3836 void CGitLogListBase::OnHdnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
)
3838 if(!m_ColumnManager
.OnHdnItemchanging(pNMHDR
, pResult
))
3841 LRESULT
CGitLogListBase::OnScrollToMessage(WPARAM itemToSelect
, LPARAM
/*lParam*/)
3843 if (GetSelectedCount() != 0)
3846 CGitHash theSelectedHash
= m_lastSelectedHash
;
3847 SetItemState((int)itemToSelect
, LVIS_SELECTED
| LVIS_FOCUSED
, LVIS_SELECTED
| LVIS_FOCUSED
);
3848 m_lastSelectedHash
= theSelectedHash
;
3850 int countPerPage
= GetCountPerPage();
3851 EnsureVisible(max(0, (int)itemToSelect
-countPerPage
/2), FALSE
);
3852 EnsureVisible(min(GetItemCount(), (int)itemToSelect
+countPerPage
/2), FALSE
);
3853 EnsureVisible((int)itemToSelect
, FALSE
);
3856 LRESULT
CGitLogListBase::OnFindDialogMessage(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
3858 ASSERT(m_pFindDialog
);
3859 bool bFound
= false;
3862 if (m_pFindDialog
->IsTerminating())
3864 // invalidate the handle identifying the dialog box.
3865 m_pFindDialog
= nullptr;
3869 int cnt
= (int)m_arShownList
.size();
3871 if(m_pFindDialog
->IsRef())
3874 str
=m_pFindDialog
->GetFindString();
3880 if (g_Git
.GetHash(hash
, str
+ _T("^{}"))) // add ^{} in order to get the correct SHA-1 (especially for signed tags)
3881 MessageBox(g_Git
.GetGitLastErr(_T("Could not get hash of ref \"") + str
+ _T("^{}\".")), _T("TortoiseGit"), MB_ICONERROR
);
3886 for (i
= 0; i
< cnt
; ++i
)
3888 GitRev
* pLogEntry
= m_arShownList
.SafeGetAt(i
);
3889 if(pLogEntry
&& pLogEntry
->m_CommitHash
== hash
)
3898 m_pFindDialog
->FlashWindowEx(FLASHW_ALL
, 2, 100);
3903 if (m_pFindDialog
->FindNext() && !bFound
)
3905 //read data from dialog
3906 CString findText
= m_pFindDialog
->GetFindString();
3907 bool bMatchCase
= (m_pFindDialog
->MatchCase() == TRUE
);
3909 std::tr1::wregex pat
;
3910 bool bRegex
= false;
3911 if (m_pFindDialog
->Regex())
3912 bRegex
= ValidateRegexp(findText
, pat
, bMatchCase
);
3914 std::tr1::regex_constants::match_flag_type flags
= std::tr1::regex_constants::match_not_null
;
3916 for (i
= m_nSearchIndex
+ 1; ; ++i
)
3921 m_pFindDialog
->FlashWindowEx(FLASHW_ALL
, 2, 100);
3923 if (m_nSearchIndex
>= 0)
3925 if (i
== m_nSearchIndex
)
3927 ::MessageBeep(0xFFFFFFFF);
3928 m_pFindDialog
->FlashWindowEx(FLASHW_ALL
, 3, 100);
3933 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(i
);
3936 str
+=pLogEntry
->m_CommitHash
.ToString();
3939 for (size_t j
= 0; j
< this->m_HashMap
[pLogEntry
->m_CommitHash
].size(); ++j
)
3941 str
+=m_HashMap
[pLogEntry
->m_CommitHash
][j
];
3945 str
+=pLogEntry
->GetAuthorEmail();
3947 str
+=pLogEntry
->GetAuthorName();
3949 str
+=pLogEntry
->GetBody();
3951 str
+=pLogEntry
->GetCommitterEmail();
3953 str
+=pLogEntry
->GetCommitterName();
3955 str
+=pLogEntry
->GetSubject();
3957 str
+=pLogEntry
->m_Notes
;
3959 str
+=GetTagInfo(pLogEntry
);
3963 /*Because changed files list is loaded on demand when gui show,
3964 files will empty when files have not fetched.
3966 we can add it back by using one-way diff(with outnumber changed and rename detect.
3967 here just need changed filename list. one-way is much quicker.
3969 if(pLogEntry
->m_IsFull
)
3971 for (int j
= 0; j
< pLogEntry
->GetFiles(this).GetCount(); ++j
)
3973 str
+= pLogEntry
->GetFiles(this)[j
].GetWinPath();
3975 str
+= pLogEntry
->GetFiles(this)[j
].GetGitOldPathString();
3981 if(!pLogEntry
->m_IsSimpleListReady
)
3982 pLogEntry
->SafeGetSimpleList(&g_Git
);
3984 for (size_t j
= 0; j
< pLogEntry
->m_SimpleFileList
.size(); ++j
)
3986 str
+= pLogEntry
->m_SimpleFileList
[j
];
3993 if (std::regex_search(std::wstring(str
), pat
, flags
))
4003 if (str
.Find(findText
) >= 0)
4012 msg
= msg
.MakeLower();
4013 CString find
= findText
.MakeLower();
4014 if (msg
.Find(find
) >= 0)
4021 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; ++i)
4023 } // if(m_pFindDialog->FindNext())
4024 //UpdateLogInfoLabel();
4029 EnsureVisible(i
, FALSE
);
4030 if ((GetAsyncKeyState(VK_SHIFT
) & 0x8000) == 0)
4032 SetItemState(GetSelectionMark(), 0, LVIS_SELECTED
);
4033 SetItemState(i
, LVIS_SELECTED
| LVIS_FOCUSED
, LVIS_SELECTED
| LVIS_FOCUSED
);
4034 SetSelectionMark(i
);
4038 GitRev
* pLogEntry
= m_arShownList
.SafeGetAt(i
);
4040 m_highlight
= pLogEntry
->m_CommitHash
;
4043 //FillLogMessageCtrl();
4050 void CGitLogListBase::OnColumnResized(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4052 m_ColumnManager
.OnColumnResized(pNMHDR
,pResult
);
4057 void CGitLogListBase::OnColumnMoved(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4059 m_ColumnManager
.OnColumnMoved(pNMHDR
, pResult
);
4064 INT_PTR
CGitLogListBase::OnToolHitTest(CPoint point
, TOOLINFO
* pTI
) const
4066 LVHITTESTINFO lvhitTestInfo
;
4068 lvhitTestInfo
.pt
= point
;
4070 int nItem
= ListView_SubItemHitTest(m_hWnd
, &lvhitTestInfo
);
4071 int nSubItem
= lvhitTestInfo
.iSubItem
;
4073 UINT nFlags
= lvhitTestInfo
.flags
;
4075 // nFlags is 0 if the SubItemHitTest fails
4076 // Therefore, 0 & <anything> will equal false
4077 if (nFlags
& LVHT_ONITEM
)
4079 // Get the client area occupied by this control
4081 GetClientRect(&rcClient
);
4083 // Fill in the TOOLINFO structure
4085 pTI
->uId
= (UINT
)((nItem
<<10)+(nSubItem
&0x3ff)+1);
4086 pTI
->lpszText
= LPSTR_TEXTCALLBACK
;
4087 pTI
->rect
= rcClient
;
4089 return pTI
->uId
; // By returning a unique value per listItem,
4090 // we ensure that when the mouse moves over another list item,
4091 // the tooltip will change
4095 // Otherwise, we aren't interested, so let the message propagate
4100 BOOL
CGitLogListBase::OnToolTipText(UINT
/*id*/, NMHDR
* pNMHDR
, LRESULT
* pResult
)
4102 TOOLTIPTEXTA
* pTTTA
= (TOOLTIPTEXTA
*)pNMHDR
;
4103 TOOLTIPTEXTW
* pTTTW
= (TOOLTIPTEXTW
*)pNMHDR
;
4107 // Ignore messages from the built in tooltip, we are processing them internally
4108 if ((pNMHDR
->idFrom
== (UINT_PTR
)m_hWnd
) &&
4109 (((pNMHDR
->code
== TTN_NEEDTEXTA
) && (pTTTA
->uFlags
& TTF_IDISHWND
)) ||
4110 ((pNMHDR
->code
== TTN_NEEDTEXTW
) && (pTTTW
->uFlags
& TTF_IDISHWND
))))
4113 // Get the mouse position
4114 const MSG
* pMessage
= GetCurrentMessage();
4118 ScreenToClient(&pt
);
4120 // Check if the point falls onto a list item
4121 LVHITTESTINFO lvhitTestInfo
;
4122 lvhitTestInfo
.pt
= pt
;
4124 int nItem
= SubItemHitTest(&lvhitTestInfo
);
4126 if (lvhitTestInfo
.flags
& LVHT_ONITEM
)
4128 // Get branch description first
4130 if (lvhitTestInfo
.iSubItem
== LOGLIST_MESSAGE
)
4133 CGit::REF_TYPE type
= CGit::REF_TYPE::LOCAL_BRANCH
;
4134 if (IsMouseOnRefLabel(m_arShownList
.SafeGetAt(nItem
), lvhitTestInfo
.pt
, type
, &branch
))
4136 MAP_STRING_STRING descriptions
;
4137 g_Git
.GetBranchDescriptions(descriptions
);
4138 if (descriptions
.find(branch
) != descriptions
.cend())
4140 strTipText
.LoadString(IDS_DESCRIPTION
);
4141 strTipText
+= L
":\n";
4142 strTipText
+= descriptions
[branch
];
4147 bool followMousePos
= false;
4148 if (!strTipText
.IsEmpty())
4149 followMousePos
= true;
4151 strTipText
= GetToolTipText(nItem
, lvhitTestInfo
.iSubItem
);
4152 if (strTipText
.IsEmpty())
4155 // we want multiline tooltips
4156 ::SendMessage(pNMHDR
->hwndFrom
, TTM_SETMAXTIPWIDTH
, 0, INT_MAX
);
4158 wcscpy_s(m_wszTip
, strTipText
);
4159 // handle Unicode as well as non-Unicode requests
4160 if (pNMHDR
->code
== TTN_NEEDTEXTA
)
4162 pTTTA
->hinst
= nullptr;
4163 pTTTA
->lpszText
= m_szTip
;
4164 ::WideCharToMultiByte(CP_ACP
, 0, m_wszTip
, -1, m_szTip
, 8192, nullptr, nullptr);
4168 pTTTW
->hinst
= nullptr;
4169 pTTTW
->lpszText
= m_wszTip
;
4173 GetSubItemRect(nItem
, lvhitTestInfo
.iSubItem
, LVIR_LABEL
, rect
);
4175 rect
.MoveToXY(pt
.x
, pt
.y
+ 18); // 18: to act like a normal tooltip
4176 ClientToScreen(rect
);
4177 ::SetWindowPos(pNMHDR
->hwndFrom
, HWND_TOP
, rect
.left
, rect
.top
, 0, 0, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOOWNERZORDER
);
4179 return TRUE
; // We found a tool tip,
4180 // tell the framework this message has been handled
4183 return FALSE
; // We didn't handle the message,
4184 // let the framework continue propagating the message
4187 CString
CGitLogListBase::GetToolTipText(int nItem
, int nSubItem
)
4189 if (nSubItem
== LOGLIST_MESSAGE
&& !m_bTagsBranchesOnRightSide
)
4191 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(nItem
);
4192 if (pLogEntry
== nullptr)
4194 if (m_HashMap
[pLogEntry
->m_CommitHash
].empty())
4196 return pLogEntry
->GetSubject();
4198 else if (nSubItem
== LOGLIST_DATE
&& m_bRelativeTimes
)
4200 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(nItem
);
4201 if (pLogEntry
== nullptr)
4203 return CLoglistUtils::FormatDateAndTime(pLogEntry
->GetAuthorDate(), m_DateFormat
, true, false);
4205 else if (nSubItem
== LOGLIST_COMMIT_DATE
&& m_bRelativeTimes
)
4207 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(nItem
);
4208 if (pLogEntry
== nullptr)
4210 return CLoglistUtils::FormatDateAndTime(pLogEntry
->GetCommitterDate(), m_DateFormat
, true, false);
4212 else if (nSubItem
== LOGLIST_ACTION
)
4214 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(nItem
);
4215 if (pLogEntry
== nullptr)
4218 if (!pLogEntry
->m_IsDiffFiles
)
4219 return CString(MAKEINTRESOURCE(IDS_PROC_LOG_FETCHINGFILES
));
4221 int actions
= pLogEntry
->GetAction(this);
4222 CString sToolTipText
;
4225 if (actions
& CTGitPath::LOGACTIONS_MODIFIED
)
4226 actionText
+= CTGitPath::GetActionName(CTGitPath::LOGACTIONS_MODIFIED
);
4228 if (actions
& CTGitPath::LOGACTIONS_ADDED
)
4230 if (!actionText
.IsEmpty())
4231 actionText
+= L
"\r\n";
4232 actionText
+= CTGitPath::GetActionName(CTGitPath::LOGACTIONS_ADDED
);
4235 if (actions
& CTGitPath::LOGACTIONS_DELETED
)
4237 if (!actionText
.IsEmpty())
4238 actionText
+= L
"\r\n";
4239 actionText
+= CTGitPath::GetActionName(CTGitPath::LOGACTIONS_DELETED
);
4242 if (actions
& CTGitPath::LOGACTIONS_REPLACED
)
4244 if (!actionText
.IsEmpty())
4245 actionText
+= L
"\r\n";
4246 actionText
+= CTGitPath::GetActionName(CTGitPath::LOGACTIONS_REPLACED
);
4249 if (actions
& CTGitPath::LOGACTIONS_UNMERGED
)
4251 if (!actionText
.IsEmpty())
4252 actionText
+= L
"\r\n";
4253 actionText
+= CTGitPath::GetActionName(CTGitPath::LOGACTIONS_UNMERGED
);
4256 if (!actionText
.IsEmpty())
4258 CString
sTitle(MAKEINTRESOURCE(IDS_LOG_ACTIONS
));
4259 sToolTipText
= sTitle
+ L
":\r\n" + actionText
;
4261 return sToolTipText
;
4266 bool CGitLogListBase::IsMouseOnRefLabelFromPopupMenu(const GitRevLoglist
* pLogEntry
, const CPoint
& point
, CGit::REF_TYPE
& type
, CString
* pShortname
/*nullptr*/, size_t* pIndex
/*nullptr*/)
4269 ScreenToClient(&pt
);
4270 return IsMouseOnRefLabel(pLogEntry
, pt
, type
, pShortname
, pIndex
);
4273 bool CGitLogListBase::IsMouseOnRefLabel(const GitRevLoglist
* pLogEntry
, const POINT
& pt
, CGit::REF_TYPE
& type
, CString
* pShortname
/*nullptr*/, size_t* pIndex
/*nullptr*/)
4278 for (size_t i
= 0; i
< m_HashMap
[pLogEntry
->m_CommitHash
].size(); ++i
)
4280 const auto labelpos
= m_RefLabelPosMap
.find(m_HashMap
[pLogEntry
->m_CommitHash
][i
]);
4281 if (labelpos
== m_RefLabelPosMap
.cend() || !labelpos
->second
.PtInRect(pt
))
4284 CGit::REF_TYPE foundType
;
4286 *pShortname
= CGit::GetShortName(m_HashMap
[pLogEntry
->m_CommitHash
][i
], &foundType
);
4288 CGit::GetShortName(m_HashMap
[pLogEntry
->m_CommitHash
][i
], &foundType
);
4289 if (foundType
!= type
&& type
!= CGit::REF_TYPE::UNKNOWN
)