1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2018 - 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
23 #include "GitLogListBase.h"
25 #include "GitProgressDlg.h"
26 #include "ProgressDlg.h"
27 #include "MessageBox.h"
28 #include "LoglistUtils.h"
29 #include "StringUtils.h"
30 #include "UnicodeUtils.h"
31 #include "../TortoiseShell/Resource.h"
32 #include "CommonAppUtils.h"
35 const UINT
CGitLogListBase::m_FindDialogMessage
= RegisterWindowMessage(FINDMSGSTRING
);
36 const UINT
CGitLogListBase::m_ScrollToMessage
= RegisterWindowMessage(L
"TORTOISEGIT_LOG_SCROLLTO");
37 const UINT
CGitLogListBase::m_ScrollToRef
= RegisterWindowMessage(L
"TORTOISEGIT_LOG_SCROLLTOREF");
38 const UINT
CGitLogListBase::m_RebaseActionMessage
= RegisterWindowMessage(L
"TORTOISEGIT_LOG_REBASEACTION");
39 const UINT
CGitLogListBase::LOGLIST_RESET_WCREV
= RegisterWindowMessage(L
"TORTOISEGIT_LOG_RESET_WCREV");
41 IMPLEMENT_DYNAMIC(CGitLogListBase
, CHintCtrl
<CResizableColumnsListCtrl
<CListCtrl
>>)
43 CGitLogListBase::CGitLogListBase() : CHintCtrl
<CResizableColumnsListCtrl
<CListCtrl
>>()
44 ,m_regMaxBugIDColWidth(L
"Software\\TortoiseGit\\MaxBugIDColWidth", 200)
46 ,m_bNoDispUpdates(FALSE
)
47 , m_bThreadRunning(FALSE
)
48 , m_SelectedFilters(LOGFILTER_ALL
)
49 , m_ShowFilter(FILTERSHOW_ALL
)
51 , m_logEntries(&m_LogCache
)
52 , m_pFindDialog(nullptr)
53 , m_dwDefaultColumns(0)
54 , m_arShownList(&m_critSec
)
56 , m_bNoHightlightHead(FALSE
)
57 , m_ShowRefMask(LOGLIST_SHOWALLREFS
)
58 , m_bFullCommitMessageOnLogLine(false)
60 , m_AsyncThreadRunning(FALSE
)
61 , m_AsyncThreadExit(FALSE
)
62 , m_bIsCherryPick(false)
64 , m_bShowBugtraqColumn(false)
65 , m_IsIDReplaceAction(FALSE
)
67 , m_LoadingThread(nullptr)
68 , m_bExitThread(FALSE
)
70 , m_IsRebaseReplaceGraph(FALSE
)
71 , m_ContextMenuMask(0xFFFFFFFFFFFFFFFF)
72 , m_bDragndropEnabled(false)
75 , m_nDropMarkerLast(-1)
76 , m_nDropMarkerLastHot(-1)
78 // use the default GUI font, create a copy of it and
79 // change the copy to BOLD (leave the rest of the font
82 this->m_critSec
.Init();
85 int cx
= GetSystemMetrics(SM_CXSMICON
);
86 int cy
= GetSystemMetrics(SM_CYSMICON
);
87 m_hModifiedIcon
= CCommonAppUtils::LoadIconEx(IDI_ACTIONMODIFIED
, cx
, cy
);
88 m_hReplacedIcon
= CCommonAppUtils::LoadIconEx(IDI_ACTIONREPLACED
, cx
, cy
);
89 m_hConflictedIcon
= CCommonAppUtils::LoadIconEx(IDI_ACTIONCONFLICTED
, cx
, cy
);
90 m_hAddedIcon
= CCommonAppUtils::LoadIconEx(IDI_ACTIONADDED
, cx
, cy
);
91 m_hDeletedIcon
= CCommonAppUtils::LoadIconEx(IDI_ACTIONDELETED
, cx
, cy
);
92 m_hFetchIcon
= CCommonAppUtils::LoadIconEx(IDI_ACTIONFETCHING
, cx
, cy
);
94 m_bFilterWithRegex
= !!CRegDWORD(L
"Software\\TortoiseGit\\UseRegexFilter", FALSE
);
95 m_bFilterCaseSensitively
= !!CRegDWORD(L
"Software\\TortoiseGit\\FilterCaseSensitively", FALSE
);
97 m_Filter
.m_NumberOfLogsScale
= (DWORD
)CRegDWORD(L
"Software\\TortoiseGit\\LogDialog\\NumberOfLogsScale", CFilterData::SHOW_NO_LIMIT
);
98 if (m_Filter
.m_NumberOfLogsScale
== CFilterData::SHOW_LAST_SEL_DATE
)
101 key
.Format(L
"Software\\TortoiseGit\\History\\LogDlg_Limits\\%s\\FromDate", (LPCTSTR
)g_Git
.m_CurrentDir
);
102 key
.Replace(L
':', L
'_');
103 CString lastSelFromDate
= CRegString(key
);
104 if (lastSelFromDate
.GetLength() == 10)
106 CTime time
= CTime(_wtoi((LPCTSTR
)lastSelFromDate
.Mid(0, 4)), _wtoi((LPCTSTR
)lastSelFromDate
.Mid(5, 2)), _wtoi((LPCTSTR
)lastSelFromDate
.Mid(8, 2)), 0, 0, 0);
107 m_Filter
.m_From
= (DWORD
)time
.GetTime();
110 m_Filter
.m_NumberOfLogs
= (DWORD
)CRegDWORD(L
"Software\\TortoiseGit\\LogDialog\\NumberOfLogs", 1);
112 for (int i
= 0; i
< Lanes::COLORS_NUM
; ++i
)
114 m_LineColors
[i
] = m_Colors
.GetColor((CColors::Colors
)(CColors::BranchLine1
+i
));
116 // get short/long datetime setting from registry
117 DWORD RegUseShortDateFormat
= CRegDWORD(L
"Software\\TortoiseGit\\LogDateFormat", TRUE
);
118 if ( RegUseShortDateFormat
)
120 m_DateFormat
= DATE_SHORTDATE
;
124 m_DateFormat
= DATE_LONGDATE
;
126 // get relative time display setting from registry
127 DWORD regRelativeTimes
= CRegDWORD(L
"Software\\TortoiseGit\\RelativeTimes", FALSE
);
128 m_bRelativeTimes
= (regRelativeTimes
!= 0);
130 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_PICK
);
131 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_SQUASH
);
132 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_EDIT
);
133 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_SKIP
);
134 m_ContextMenuMask
&= ~GetContextMenuBit(ID_LOG
);
135 m_ContextMenuMask
&= ~GetContextMenuBit(ID_BLAME
);
136 m_ContextMenuMask
&= ~GetContextMenuBit(ID_BLAMEPREVIOUS
);
138 m_ColumnRegKey
= L
"log";
140 m_bTagsBranchesOnRightSide
= !!CRegDWORD(L
"Software\\TortoiseGit\\DrawTagsBranchesOnRightSide", FALSE
);
141 m_bSymbolizeRefNames
= !!CRegDWORD(L
"Software\\TortoiseGit\\SymbolizeRefNames", FALSE
);
142 m_bIncludeBoundaryCommits
= !!CRegDWORD(L
"Software\\TortoiseGit\\LogIncludeBoundaryCommits", FALSE
);
143 m_bFullCommitMessageOnLogLine
= !!CRegDWORD(L
"Software\\TortoiseGit\\FullCommitMessageOnLogLine", FALSE
);
145 m_LineWidth
= max(1, CRegDWORD(L
"Software\\TortoiseGit\\TortoiseProc\\Graph\\LogLineWidth", 2));
146 m_NodeSize
= max(1, CRegDWORD(L
"Software\\TortoiseGit\\TortoiseProc\\Graph\\LogNodeSize", 10));
148 if (CRegDWORD(L
"Software\\TortoiseGit\\LogDialog\\UseMailmap", FALSE
) == TRUE
)
149 git_read_mailmap(&m_pMailmap
);
151 m_AsyncDiffEvent
= ::CreateEvent(nullptr, FALSE
, TRUE
, nullptr);
152 m_AsynDiffListLock
.Init();
153 StartAsyncDiffThread();
156 HWND
CGitLogListBase::GetParentHWND()
158 auto owner
= GetSafeOwner();
160 return GetSafeHwnd();
161 return owner
->GetSafeHwnd();
164 int CGitLogListBase::AsyncDiffThread()
166 while(!m_AsyncThreadExit
)
168 ::WaitForSingleObject(m_AsyncDiffEvent
, INFINITE
);
170 GitRevLoglist
* pRev
= nullptr;
171 while(!m_AsyncThreadExit
&& !m_AsynDiffList
.empty())
173 m_AsynDiffListLock
.Lock();
174 pRev
= m_AsynDiffList
.back();
175 m_AsynDiffList
.pop_back();
176 m_AsynDiffListLock
.Unlock();
178 if( pRev
->m_CommitHash
.IsEmpty() )
180 if(pRev
->m_IsDiffFiles
)
183 CTGitPathList
& files
= pRev
->GetFiles(this);
185 pRev
->m_ParentHash
.clear();
186 pRev
->m_ParentHash
.push_back(m_HeadHash
);
187 g_Git
.RefreshGitIndex();
188 g_Git
.GetWorkingTreeChanges(files
);
189 auto& action
= pRev
->GetAction(this);
191 for (int j
= 0; j
< files
.GetCount(); ++j
)
192 action
|= files
[j
].m_Action
;
195 if (pRev
->GetUnRevFiles().FillUnRev(CTGitPath::LOGACTIONS_UNVER
, nullptr, &err
))
197 MessageBox(L
"Failed to get UnRev file list\n" + err
, L
"TortoiseGit", MB_OK
| MB_ICONERROR
);
198 InterlockedExchange(&m_AsyncThreadRunning
, FALSE
);
202 InterlockedExchange(&pRev
->m_IsDiffFiles
, TRUE
);
203 InterlockedExchange(&pRev
->m_IsFull
, TRUE
);
205 CString body
= L
"\n";
206 body
.AppendFormat(IDS_FILESCHANGES
, files
.GetCount());
207 pRev
->GetBody() = body
;
208 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)0,0);
209 this->GetParent()->PostMessage(WM_COMMAND
, MSG_FETCHED_DIFF
, 0);
212 if (!pRev
->CheckAndDiff())
213 { // fetch change file list
214 for (int i
= GetTopIndex(); !m_AsyncThreadExit
&& i
<= GetTopIndex() + GetCountPerPage(); ++i
)
216 if (i
< (int)m_arShownList
.size())
218 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(i
);
219 if(data
->m_CommitHash
== pRev
->m_CommitHash
)
221 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)i
,0);
227 if(!m_AsyncThreadExit
&& GetSelectedCount() == 1)
229 POSITION pos
= GetFirstSelectedItemPosition();
230 int nItem
= GetNextSelectedItem(pos
);
234 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(nItem
);
236 if(data
->m_CommitHash
== pRev
->m_CommitHash
)
237 this->GetParent()->PostMessage(WM_COMMAND
, MSG_FETCHED_DIFF
, 0);
243 InterlockedExchange(&m_AsyncThreadRunning
, FALSE
);
246 void CGitLogListBase::hideFromContextMenu(unsigned __int64 hideMask
, bool exclusivelyShow
)
249 m_ContextMenuMask
&= hideMask
;
251 m_ContextMenuMask
&= ~hideMask
;
254 CGitLogListBase::~CGitLogListBase()
256 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
257 this->m_arShownList
.SafeRemoveAll();
259 DestroyIcon(m_hModifiedIcon
);
260 DestroyIcon(m_hReplacedIcon
);
261 DestroyIcon(m_hConflictedIcon
);
262 DestroyIcon(m_hAddedIcon
);
263 DestroyIcon(m_hDeletedIcon
);
264 m_logEntries
.ClearAll();
266 git_free_mailmap(m_pMailmap
);
268 SafeTerminateThread();
269 SafeTerminateAsyncDiffThread();
272 CloseHandle(m_AsyncDiffEvent
);
276 BEGIN_MESSAGE_MAP(CGitLogListBase
, CHintCtrl
<CResizableColumnsListCtrl
<CListCtrl
>>)
277 ON_REGISTERED_MESSAGE(m_FindDialogMessage
, OnFindDialogMessage
)
278 ON_REGISTERED_MESSAGE(m_ScrollToMessage
, OnScrollToMessage
)
279 ON_REGISTERED_MESSAGE(m_ScrollToRef
, OnScrollToRef
)
280 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW
, OnNMCustomdrawLoglist
)
281 ON_NOTIFY_REFLECT(LVN_GETDISPINFO
, OnLvnGetdispinfoLoglist
)
283 ON_NOTIFY_REFLECT(NM_DBLCLK
, OnNMDblclkLoglist
)
284 ON_NOTIFY_REFLECT(LVN_ODFINDITEM
,OnLvnOdfinditemLoglist
)
287 ON_MESSAGE(MSG_LOADED
,OnLoad
)
289 ON_WM_MEASUREITEM_REFLECT()
290 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW
, 0, 0xFFFF, &OnToolTipText
)
291 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA
, 0, 0xFFFF, &OnToolTipText
)
294 ON_NOTIFY_REFLECT(LVN_BEGINDRAG
, OnBeginDrag
)
297 void CGitLogListBase::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct
)
299 //if (m_nRowHeight>0)
300 lpMeasureItemStruct
->itemHeight
= CDPIAware::Instance().ScaleY(50);
303 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct
)
306 return __super::OnCreate(lpCreateStruct
);
309 void CGitLogListBase::SetStyle()
311 SetExtendedStyle(LVS_EX_INFOTIP
| LVS_EX_DOUBLEBUFFER
| LVS_EX_SUBITEMIMAGES
| LVS_EX_FULLROWSELECT
);
314 void CGitLogListBase::PreSubclassWindow()
317 // load the icons for the action columns
318 // m_Theme.Open(m_hWnd, L"ListView");
319 SetWindowTheme(m_hWnd
, L
"Explorer", nullptr);
320 __super::PreSubclassWindow();
323 CString
CGitLogListBase::GetRebaseActionName(int action
)
325 if (action
& LOGACTIONS_REBASE_EDIT
)
326 return MAKEINTRESOURCE(IDS_PATHACTIONS_EDIT
);
327 if (action
& LOGACTIONS_REBASE_SQUASH
)
328 return MAKEINTRESOURCE(IDS_PATHACTIONS_SQUASH
);
329 if (action
& LOGACTIONS_REBASE_PICK
)
330 return MAKEINTRESOURCE(IDS_PATHACTIONS_PICK
);
331 if (action
& LOGACTIONS_REBASE_SKIP
)
332 return MAKEINTRESOURCE(IDS_PATHACTIONS_SKIP
);
334 return MAKEINTRESOURCE(IDS_PATHACTIONS_UNKNOWN
);
337 void CGitLogListBase::InsertGitColumn()
343 // use the default font, create a copy of it and
344 // change the copy to BOLD (leave the rest of the font
347 GetFont()->GetLogFont(&lf
);
348 lf
.lfWeight
= FW_BOLD
;
349 m_boldFont
.CreateFontIndirect(&lf
);
350 lf
.lfWeight
= FW_DONTCARE
;
352 m_FontItalics
.CreateFontIndirect(&lf
);
353 lf
.lfWeight
= FW_BOLD
;
354 m_boldItalicsFont
.CreateFontIndirect(&lf
);
356 // only load properties if we have a repository
357 if (GitAdminDir::IsWorkingTreeOrBareRepo(g_Git
.m_CurrentDir
))
358 UpdateProjectProperties();
360 static UINT normal
[] =
372 IDS_LOG_COMMIT_EMAIL
,
378 auto iconItemBorder
= CDPIAware::Instance().ScaleX(ICONITEMBORDER
);
379 auto columnWidth
= CDPIAware::Instance().ScaleX(ICONITEMBORDER
+ 16 * 4);
386 2 * iconItemBorder
+ GetSystemMetrics(SM_CXSMICON
) * 5,
387 CDPIAware::Instance().ScaleX(LOGLIST_MESSAGE_MIN
),
397 m_dwDefaultColumns
= GIT_LOG_GRAPH
|GIT_LOG_ACTIONS
|GIT_LOG_MESSAGE
|GIT_LOG_AUTHOR
|GIT_LOG_DATE
;
399 DWORD hideColumns
= 0;
400 if(this->m_IsRebaseReplaceGraph
)
402 hideColumns
|= GIT_LOG_GRAPH
;
403 m_dwDefaultColumns
|= GIT_LOG_REBASE
;
406 hideColumns
|= GIT_LOG_REBASE
;
408 if(this->m_IsIDReplaceAction
)
410 hideColumns
|= GIT_LOG_ACTIONS
;
411 m_dwDefaultColumns
|= GIT_LOG_ID
;
412 m_dwDefaultColumns
|= GIT_LOG_HASH
;
415 hideColumns
|= GIT_LOG_ID
;
416 if(this->m_bShowBugtraqColumn
)
417 m_dwDefaultColumns
|= GIT_LOGLIST_BUG
;
419 hideColumns
|= GIT_LOGLIST_BUG
;
420 if (CTGitPath(g_Git
.m_CurrentDir
).HasGitSVNDir())
421 m_dwDefaultColumns
|= GIT_LOGLIST_SVNREV
;
423 hideColumns
|= GIT_LOGLIST_SVNREV
;
426 m_ColumnManager
.SetNames(normal
, _countof(normal
));
427 m_ColumnManager
.ReadSettings(m_dwDefaultColumns
, hideColumns
, m_ColumnRegKey
+ L
"loglist", _countof(normal
), with
);
428 m_ColumnManager
.SetRightAlign(LOGLIST_ID
);
430 if (!(hideColumns
& GIT_LOG_ACTIONS
))
432 // Configure fake a imagelist for LogList with 1px width and height = GetSystemMetrics(SM_CYSMICON)
433 // to set the minimum item height: we draw icons in the actions column, but on High-DPI the
434 // display's font height may be less than small icon height.
435 ASSERT((GetStyle() & LVS_SHAREIMAGELISTS
) == 0);
436 HIMAGELIST hImageList
= ImageList_Create(1, GetSystemMetrics(SM_CYSMICON
), 0, 1, 0);
437 ListView_SetImageList(GetSafeHwnd(), hImageList
, LVSIL_SMALL
);
443 void CGitLogListBase::FillBackGround(HDC hdc
, DWORD_PTR Index
, CRect
&rect
)
445 LVITEM rItem
= { 0 };
446 rItem
.mask
= LVIF_STATE
;
447 rItem
.iItem
= (int)Index
;
448 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
451 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(Index
);
452 HBRUSH brush
= nullptr;
454 if (!(rItem
.state
& LVIS_SELECTED
))
456 int action
= pLogEntry
->GetRebaseAction();
457 if (action
& LOGACTIONS_REBASE_SQUASH
)
458 brush
= ::CreateSolidBrush(RGB(156,156,156));
459 else if (action
& LOGACTIONS_REBASE_EDIT
)
460 brush
= ::CreateSolidBrush(RGB(200,200,128));
462 else if (!IsAppThemed())
464 if (rItem
.state
& LVIS_SELECTED
)
466 if (::GetFocus() == m_hWnd
)
467 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT
));
469 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE
));
474 ::FillRect(hdc
, &rect
, brush
);
475 ::DeleteObject(brush
);
479 void DrawTrackingRoundRect(HDC hdc
, CRect rect
, HBRUSH brush
, COLORREF darkColor
)
481 POINT point
= { 4, 4 };
483 rt2
.DeflateRect(1, 1);
484 rt2
.OffsetRect(2, 2);
486 HPEN nullPen
= ::CreatePen(PS_NULL
, 0, 0);
487 HPEN oldpen
= (HPEN
)::SelectObject(hdc
, nullPen
);
488 HBRUSH darkBrush
= (HBRUSH
)::CreateSolidBrush(darkColor
);
489 HBRUSH oldbrush
= (HBRUSH
)::SelectObject(hdc
, darkBrush
);
490 ::RoundRect(hdc
, rt2
.left
, rt2
.top
, rt2
.right
, rt2
.bottom
, point
.x
, point
.y
);
492 ::SelectObject(hdc
, brush
);
493 rt2
.OffsetRect(-2, -2);
494 ::RoundRect(hdc
, rt2
.left
, rt2
.top
, rt2
.right
, rt2
.bottom
, point
.x
, point
.y
);
495 ::SelectObject(hdc
, oldbrush
);
496 ::SelectObject(hdc
, oldpen
);
497 ::DeleteObject(nullPen
);
498 ::DeleteObject(darkBrush
);
501 void DrawUpstream(HDC hdc
, CRect rect
, COLORREF color
, int bold
)
503 HPEN pen
= ::CreatePen(PS_SOLID
, bold
, color
);
504 HPEN oldpen
= (HPEN
)::SelectObject(hdc
, pen
);
505 ::MoveToEx(hdc
, rect
.left
+ 2 + bold
, rect
.top
+ 2 - bold
, nullptr);
506 ::LineTo(hdc
, rect
.left
+ 2 + bold
, rect
.bottom
+ 1 - bold
);
507 ::MoveToEx(hdc
, rect
.left
+ 3, rect
.top
+ 1, nullptr);
508 ::LineTo(hdc
, rect
.left
, rect
.top
+ 4);
509 ::MoveToEx(hdc
, rect
.left
+ 2 + bold
, rect
.top
+ 1, nullptr);
510 ::LineTo(hdc
, rect
.right
+ 1 + bold
, rect
.top
+ 4);
511 ::MoveToEx(hdc
, rect
.left
+ 1, rect
.top
+ 2 + bold
, nullptr);
512 ::LineTo(hdc
, rect
.right
+ 1 + bold
, rect
.top
+ 2 + bold
);
513 ::SelectObject(hdc
, oldpen
);
517 void CGitLogListBase::DrawTagBranchMessage(HDC hdc
, CRect
&rect
, INT_PTR index
, std::vector
<REFLABEL
> &refList
)
519 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(index
);
521 LVITEM rItem
= { 0 };
522 rItem
.mask
= LVIF_STATE
;
523 rItem
.iItem
= (int)index
;
524 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
530 HTHEME hTheme
= nullptr;
532 hTheme
= OpenThemeData(m_hWnd
, L
"Explorer::ListView;ListView");
535 if (m_bTagsBranchesOnRightSide
)
537 HFONT oldFont
= (HFONT
)SelectObject(hdc
, (HFONT
)GetStockObject(DEFAULT_GUI_FONT
));
538 GetTextExtentPoint32(hdc
, L
" ", 1, &oneSpaceSize
);
539 SelectObject(hdc
, oldFont
);
540 rt
.left
+= oneSpaceSize
.cx
* 2;
544 GetTextExtentPoint32(hdc
, L
" ", 1, &oneSpaceSize
);
545 DrawTagBranch(hdc
, W_Dc
, hTheme
, rect
, rt
, rItem
, data
, refList
);
546 rt
.left
+= oneSpaceSize
.cx
;
549 CString msg
= MessageDisplayStr(data
);
550 int action
= data
->GetRebaseAction();
551 bool skip
= !!(action
& (LOGACTIONS_REBASE_DONE
| LOGACTIONS_REBASE_SKIP
));
554 int txtState
= LISS_NORMAL
;
555 if (rItem
.state
& LVIS_SELECTED
)
556 txtState
= LISS_SELECTED
;
558 DTTOPTS opts
= { 0 };
559 opts
.dwSize
= sizeof(opts
);
560 opts
.crText
= skip
? RGB(128,128,128) : ::GetSysColor(COLOR_WINDOWTEXT
);
561 opts
.dwFlags
= DTT_TEXTCOLOR
;
562 DrawThemeTextEx(hTheme
, hdc
, LVP_LISTITEM
, txtState
, msg
, -1, DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
, &rt
, &opts
);
566 if ((rItem
.state
& LVIS_SELECTED
) && (::GetFocus() == m_hWnd
))
568 COLORREF clrOld
= ::SetTextColor(hdc
, skip
? RGB(128,128,128) : ::GetSysColor(COLOR_HIGHLIGHTTEXT
));
569 ::DrawText(hdc
,msg
, msg
.GetLength(), &rt
, DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
);
570 ::SetTextColor(hdc
, clrOld
);
574 COLORREF clrOld
= ::SetTextColor(hdc
, skip
? RGB(128,128,128) : ::GetSysColor(COLOR_WINDOWTEXT
));
575 ::DrawText(hdc
, msg
, msg
.GetLength(), &rt
, DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
);
576 ::SetTextColor(hdc
, clrOld
);
580 if (m_bTagsBranchesOnRightSide
)
583 GetTextExtentPoint32(hdc
, msg
, msg
.GetLength(), &size
);
585 rt
.left
+= oneSpaceSize
.cx
+ size
.cx
;
587 DrawTagBranch(hdc
, W_Dc
, hTheme
, rect
, rt
, rItem
, data
, refList
);
591 CloseThemeData(hTheme
);
596 void CGitLogListBase::DrawTagBranch(HDC hdc
, CDC
& W_Dc
, HTHEME hTheme
, CRect
& rect
, CRect
& rt
, LVITEM
& rItem
, GitRevLoglist
* data
, std::vector
<REFLABEL
>& refList
)
598 for (unsigned int i
= 0; i
< refList
.size(); ++i
)
600 CString shortname
= !refList
[i
].simplifiedName
.IsEmpty() ? refList
[i
].simplifiedName
: refList
[i
].name
;
602 COLORREF colRef
= refList
[i
].color
;
603 bool singleRemote
= refList
[i
].singleRemote
;
604 bool hasTracking
= refList
[i
].hasTracking
;
605 CGit::REF_TYPE refType
= refList
[i
].refType
;
607 //When row selected, ajust label color
610 if (rItem
.state
& LVIS_SELECTED
)
611 colRef
= CColors::MixColors(colRef
, ::GetSysColor(COLOR_HIGHLIGHT
), 150);
614 brush
= ::CreateSolidBrush(colRef
);
616 if (!shortname
.IsEmpty() && (rt
.left
< rect
.right
))
619 GetTextExtentPoint32(hdc
, shortname
, shortname
.GetLength(), &size
);
621 rt
.SetRect(rt
.left
, rt
.top
, rt
.left
+ size
.cx
, rt
.bottom
);
624 int textpos
= DT_CENTER
;
626 if (rt
.right
> rect
.right
)
628 rt
.right
= rect
.right
;
637 textRect
.OffsetRect(5, 0);
641 DrawTrackingRoundRect(hdc
, rt
, brush
, m_Colors
.Darken(colRef
, 100));
644 //Fill interior of ref label
645 ::FillRect(hdc
, &rt
, brush
);
653 W_Dc
.Draw3dRect(rectEdge
, m_Colors
.Lighten(colRef
, 100), m_Colors
.Darken(colRef
, 100));
654 rectEdge
.DeflateRect(1, 1);
655 W_Dc
.Draw3dRect(rectEdge
, m_Colors
.Lighten(colRef
, 50), m_Colors
.Darken(colRef
, 50));
658 if (refType
== CGit::REF_TYPE::ANNOTATED_TAG
)
661 POINT trianglept
[3] = { { rt
.right
- 8, rt
.top
}, { rt
.right
, (rt
.top
+ rt
.bottom
) / 2 }, { rt
.right
- 8, rt
.bottom
} };
662 HRGN hrgn
= ::CreatePolygonRgn(trianglept
, 3, ALTERNATE
);
663 ::FillRgn(hdc
, hrgn
, brush
);
664 ::DeleteObject(hrgn
);
665 ::MoveToEx(hdc
, trianglept
[0].x
- 1, trianglept
[0].y
, nullptr);
667 HPEN oldpen
= (HPEN
)SelectObject(hdc
, pen
= ::CreatePen(PS_SOLID
, 2, m_Colors
.Lighten(colRef
, 50)));
668 ::LineTo(hdc
, trianglept
[1].x
- 1, trianglept
[1].y
- 1);
670 SelectObject(hdc
, pen
= ::CreatePen(PS_SOLID
, 2, m_Colors
.Darken(colRef
, 50)));
671 ::LineTo(hdc
, trianglept
[2].x
- 1, trianglept
[2].y
- 1);
673 SelectObject(hdc
, pen
= ::CreatePen(PS_SOLID
, 2, colRef
));
674 ::MoveToEx(hdc
, trianglept
[0].x
- 1, trianglept
[2].y
- 3, nullptr);
675 ::LineTo(hdc
, trianglept
[0].x
- 1, trianglept
[0].y
);
677 SelectObject(hdc
, oldpen
);
680 //Draw text inside label
681 bool customColor
= (colRef
& 0xff) * 30 + ((colRef
>> 8) & 0xff) * 59 + ((colRef
>> 16) & 0xff) * 11 <= 12800; // check if dark background
682 if (!customColor
&& IsAppThemed())
684 int txtState
= LISS_NORMAL
;
685 if (rItem
.state
& LVIS_SELECTED
)
686 txtState
= LISS_SELECTED
;
688 DTTOPTS opts
= { 0 };
689 opts
.dwSize
= sizeof(opts
);
690 opts
.crText
= ::GetSysColor(COLOR_WINDOWTEXT
);
691 opts
.dwFlags
= DTT_TEXTCOLOR
;
692 DrawThemeTextEx(hTheme
, hdc
, LVP_LISTITEM
, txtState
, shortname
, -1, textpos
| DT_SINGLELINE
| DT_VCENTER
, &textRect
, &opts
);
696 W_Dc
.SetBkMode(TRANSPARENT
);
697 if (customColor
|| (rItem
.state
& LVIS_SELECTED
))
699 COLORREF clrNew
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
700 COLORREF clrOld
= ::SetTextColor(hdc
,clrNew
);
701 ::DrawText(hdc
, shortname
, shortname
.GetLength(), &textRect
, textpos
| DT_SINGLELINE
| DT_VCENTER
);
702 ::SetTextColor(hdc
,clrOld
);
706 COLORREF clrOld
= ::SetTextColor(hdc
, ::GetSysColor(COLOR_WINDOWTEXT
));
707 ::DrawText(hdc
, shortname
, shortname
.GetLength(), &textRect
, textpos
| DT_SINGLELINE
| DT_VCENTER
);
708 ::SetTextColor(hdc
, clrOld
);
714 COLORREF color
= ::GetSysColor(customColor
? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
);
715 int bold
= data
->m_CommitHash
== m_HeadHash
? 2 : 1;
717 newRect
.SetRect(rt
.left
+ 2, rt
.top
+ 4, rt
.left
+ 6, rt
.bottom
- 4);
718 DrawUpstream(hdc
, newRect
, color
, bold
);
721 if (!refList
[i
].fullName
.IsEmpty())
722 m_RefLabelPosMap
[refList
[i
].fullName
] = rt
;
724 rt
.left
= rt
.right
+ 1;
727 ::DeleteObject(brush
);
729 rt
.right
= rect
.right
;
732 static COLORREF
blend(const COLORREF
& col1
, const COLORREF
& col2
, int amount
= 128) {
733 // Returns ((256 - amount)*col1 + amount*col2) / 256;
734 return RGB(((256 - amount
)*GetRValue(col1
) + amount
*GetRValue(col2
) ) / 256,
735 ((256 - amount
)*GetGValue(col1
) + amount
*GetGValue(col2
) ) / 256,
736 ((256 - amount
)*GetBValue(col1
) + amount
*GetBValue(col2
) ) / 256);
739 Gdiplus::Color
GetGdiColor(COLORREF col
)
741 return Gdiplus::Color(GetRValue(col
),GetGValue(col
),GetBValue(col
));
743 void CGitLogListBase::paintGraphLane(HDC hdc
, int laneHeight
,int type
, int x1
, int x2
,
744 const COLORREF
& col
,const COLORREF
& activeColor
, int top
747 int h
= laneHeight
/ 2;
748 int m
= (x1
+ x2
) / 2;
749 int r
= (x2
- x1
) * m_NodeSize
/ 30;
752 #define P_CENTER m , h+top
753 #define P_0 x2, h+top
754 #define P_90 m , 0+top-1
755 #define P_180 x1, h+top
756 #define P_270 m , 2 * h+top +1
757 #define R_CENTER m - r, h - r+top, d, d
760 #define DELTA_UR_B 2*(x1 - m), 2*h +top
761 #define DELTA_UR_E 0*16, 90*16 +top // -,
763 #define DELTA_DR_B 2*(x1 - m), 2*-h +top
764 #define DELTA_DR_E 270*16, 90*16 +top // -'
766 #define DELTA_UL_B 2*(x2 - m), 2*h +top
767 #define DELTA_UL_E 90*16, 90*16 +top // ,-
769 #define DELTA_DL_B 2*(x2 - m),2*-h +top
770 #define DELTA_DL_E 180*16, 90*16 // '-
772 #define CENTER_UR x1, 2*h, 225
773 #define CENTER_DR x1, 0 , 135
774 #define CENTER_UL x2, 2*h, 315
775 #define CENTER_DL x2, 0 , 45
778 Gdiplus::Graphics
graphics( hdc
);
780 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
789 Gdiplus::LinearGradientBrush
gradient(
790 Gdiplus::Point(x1
-2, h
+top
-2),
791 Gdiplus::Point(P_270
),
792 GetGdiColor(activeColor
),GetGdiColor(col
));
795 Gdiplus::Pen
mypen(&gradient
, (Gdiplus::REAL
)m_LineWidth
);
796 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
798 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
799 graphics
.DrawArc(&mypen
,x1
-(x2
-x1
)/2-1,top
+h
-1, x2
-x1
,laneHeight
,270,90);
800 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
806 Gdiplus::LinearGradientBrush
gradient(
807 Gdiplus::Point(P_270
),
808 Gdiplus::Point(x2
+1, h
+top
-1),
809 GetGdiColor(col
),GetGdiColor(activeColor
));
812 Gdiplus::Pen
mypen(&gradient
, (Gdiplus::REAL
)m_LineWidth
);
813 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
815 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
816 graphics
.DrawArc(&mypen
,x1
+(x2
-x1
)/2,top
+h
-1, x2
-x1
,laneHeight
,180,90);
817 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
825 Gdiplus::LinearGradientBrush
gradient(
826 Gdiplus::Point(x1
-2, h
+top
-2),
827 Gdiplus::Point(P_90
),
828 GetGdiColor(activeColor
),GetGdiColor(col
));
830 Gdiplus::Pen
mypen(&gradient
, (Gdiplus::REAL
)m_LineWidth
);
832 graphics
.DrawArc(&mypen
,x1
-(x2
-x1
)/2-1,top
-h
-1, x2
-x1
,laneHeight
,0,90);
835 QConicalGradient
gradient(CENTER_DR
);
836 gradient
.setColorAt(0.375, activeCol
);
837 gradient
.setColorAt(0.625, col
);
838 myPen
.setBrush(gradient
);
840 p
->drawArc(P_CENTER
, DELTA_DR
);
849 //static QPen myPen(Qt::black, 2); // fast path here
851 pen
.CreatePen(PS_SOLID
,2,col
);
852 //myPen.setColor(col);
853 HPEN oldpen
=(HPEN
)::SelectObject(hdc
,(HPEN
)pen
);
855 Gdiplus::Pen
myPen(GetGdiColor(col
), (Gdiplus::REAL
)m_LineWidth
);
857 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
864 case Lanes::NOT_ACTIVE
:
865 case Lanes::MERGE_FORK
:
866 case Lanes::MERGE_FORK_R
:
867 case Lanes::MERGE_FORK_L
:
872 //DrawLine(hdc,P_90,P_270);
873 graphics
.DrawLine(&myPen
,P_90
,P_270
);
874 //p->drawLine(P_90, P_270);
878 //DrawLine(hdc,P_CENTER,P_270);
879 graphics
.DrawLine(&myPen
,P_CENTER
,P_270
);
880 //p->drawLine(P_CENTER, P_270);
884 case Lanes::MERGE_FORK_L_INITIAL
:
885 case Lanes::BOUNDARY
:
886 case Lanes::BOUNDARY_C
:
887 case Lanes::BOUNDARY_R
:
888 case Lanes::BOUNDARY_L
:
889 //DrawLine(hdc,P_90, P_CENTER);
890 graphics
.DrawLine(&myPen
,P_90
,P_CENTER
);
891 //p->drawLine(P_90, P_CENTER);
897 myPen
.SetColor(GetGdiColor(activeColor
));
901 case Lanes::MERGE_FORK
:
906 case Lanes::CROSS_EMPTY
:
907 case Lanes::BOUNDARY_C
:
908 //DrawLine(hdc,P_180,P_0);
909 graphics
.DrawLine(&myPen
,P_180
,P_0
);
910 //p->drawLine(P_180, P_0);
912 case Lanes::MERGE_FORK_R
:
913 case Lanes::BOUNDARY_R
:
914 //DrawLine(hdc,P_180,P_CENTER);
915 graphics
.DrawLine(&myPen
,P_180
,P_CENTER
);
916 //p->drawLine(P_180, P_CENTER);
918 case Lanes::MERGE_FORK_L
:
919 case Lanes::MERGE_FORK_L_INITIAL
:
922 case Lanes::BOUNDARY_L
:
923 //DrawLine(hdc,P_CENTER,P_0);
924 graphics
.DrawLine(&myPen
,P_CENTER
,P_0
);
925 //p->drawLine(P_CENTER, P_0);
931 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
934 brush
.CreateSolidBrush(col
);
935 HBRUSH oldbrush
=(HBRUSH
)::SelectObject(hdc
,(HBRUSH
)brush
);
937 Gdiplus::SolidBrush
myBrush(GetGdiColor(col
));
938 // center symbol, e.g. rect or ellipse
944 //p->setPen(Qt::NoPen);
946 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
947 graphics
.FillEllipse(&myBrush
, R_CENTER
);
948 //p->drawEllipse(R_CENTER);
950 case Lanes::MERGE_FORK
:
951 case Lanes::MERGE_FORK_R
:
952 case Lanes::MERGE_FORK_L
:
953 case Lanes::MERGE_FORK_L_INITIAL
:
954 //p->setPen(Qt::NoPen);
956 //p->drawRect(R_CENTER);
957 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
958 graphics
.FillRectangle(&myBrush
, R_CENTER
);
960 case Lanes::UNAPPLIED
:
962 //p->setPen(Qt::NoPen);
963 //p->setBrush(Qt::red);
964 //p->drawRect(m - r, h - 1, d, 2);
965 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
966 graphics
.FillRectangle(&myBrush
,m
-r
,h
-1,d
,2);
970 //p->setPen(Qt::NoPen);
971 //p->setBrush(DARK_GREEN);
972 //p->drawRect(m - r, h - 1, d, 2);
973 //p->drawRect(m - 1, h - r, 2, d);
974 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
975 graphics
.FillRectangle(&myBrush
,m
-r
,h
-1,d
,2);
976 graphics
.FillRectangle(&myBrush
,m
-1,h
-r
,2,d
);
978 case Lanes::BOUNDARY
:
980 //p->drawEllipse(R_CENTER);
981 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
982 graphics
.DrawEllipse(&myPen
, R_CENTER
);
984 case Lanes::BOUNDARY_C
:
985 case Lanes::BOUNDARY_R
:
986 case Lanes::BOUNDARY_L
:
988 //p->drawRect(R_CENTER);
989 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
990 graphics
.FillRectangle(&myBrush
,R_CENTER
);
996 ::SelectObject(hdc
,oldpen
);
997 ::SelectObject(hdc
,oldbrush
);
1006 void CGitLogListBase::DrawGraph(HDC hdc
,CRect
&rect
,INT_PTR index
)
1010 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(index
);
1011 if(data
->m_CommitHash
.IsEmpty())
1015 LVITEM rItem
= { 0 };
1016 rItem
.mask
= LVIF_STATE
;
1017 rItem
.iItem
= (int)index
;
1018 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
1021 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
1023 if (data
->m_Lanes
.empty())
1024 m_logEntries
.setLane(data
->m_CommitHash
);
1026 std::vector
<int>& lanes
=data
->m_Lanes
;
1027 size_t laneNum
= lanes
.size();
1028 UINT activeLane
= 0;
1029 for (UINT i
= 0; i
< laneNum
; ++i
)
1030 if (Lanes::isMerge(lanes
[i
])) {
1036 int maxWidth
= rect
.Width();
1037 int lw
= 3 * rect
.Height() / 4; //laneWidth()
1039 COLORREF activeColor
= m_LineColors
[activeLane
% Lanes::COLORS_NUM
];
1040 //if (opt.state & QStyle::State_Selected)
1041 // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208);
1043 for (unsigned int i
= 0; i
< laneNum
&& x2
< maxWidth
; ++i
)
1049 if (ln
== Lanes::EMPTY
)
1052 COLORREF color
= i
== activeLane
? activeColor
: m_LineColors
[i
% Lanes::COLORS_NUM
];
1053 paintGraphLane(hdc
, rect
.Height(),ln
, x1
+rect
.left
, x2
+rect
.left
, color
,activeColor
, rect
.top
);
1057 for (UINT i
= 0; i
< laneNum
&& x2
< maxWidth
; ++i
) {
1062 if (ln
== Lanes::EMPTY
)
1065 UINT col
= ( Lanes:: isHead(ln
) ||Lanes:: isTail(ln
) || Lanes::isJoin(ln
)
1066 || ln
==Lanes:: CROSS_EMPTY
) ? activeLane
: i
;
1068 if (ln
== Lanes::CROSS
)
1070 paintGraphLane(hdc
, rect
.Height(),Lanes::NOT_ACTIVE
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
1071 paintGraphLane(hdc
, rect
.Height(),Lanes::CROSS
, x1
, x2
, m_LineColors
[activeLane
% Lanes::COLORS_NUM
],rect
.top
);
1074 paintGraphLane(hdc
, rect
.Height(),ln
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
1079 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1081 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
1082 // Take the default processing unless we set this to something else below.
1083 *pResult
= CDRF_DODEFAULT
;
1085 if (m_bNoDispUpdates
)
1088 switch (pLVCD
->nmcd
.dwDrawStage
)
1092 *pResult
= CDRF_NOTIFYITEMDRAW
;
1096 case CDDS_ITEMPREPAINT
:
1098 // This is the prepaint stage for an item. Here's where we set the
1099 // item's text color.
1101 // Tell Windows to send draw notifications for each subitem.
1102 *pResult
= CDRF_NOTIFYSUBITEMDRAW
;
1104 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
1106 if (m_arShownList
.size() > pLVCD
->nmcd
.dwItemSpec
)
1108 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1111 HGDIOBJ hGdiObj
= nullptr;
1112 int action
= data
->GetRebaseAction();
1113 if (action
& (LOGACTIONS_REBASE_DONE
| LOGACTIONS_REBASE_SKIP
))
1114 crText
= RGB(128,128,128);
1116 if (action
& LOGACTIONS_REBASE_SQUASH
)
1117 pLVCD
->clrTextBk
= RGB(156,156,156);
1118 else if (action
& LOGACTIONS_REBASE_EDIT
)
1119 pLVCD
->clrTextBk
= RGB(200,200,128);
1121 pLVCD
->clrTextBk
= ::GetSysColor(COLOR_WINDOW
);
1123 if (action
& LOGACTIONS_REBASE_CURRENT
)
1124 hGdiObj
= m_boldFont
.GetSafeHandle();
1126 BOOL isHeadHash
= data
->m_CommitHash
== m_HeadHash
&& m_bNoHightlightHead
== FALSE
;
1127 BOOL isHighlight
= data
->m_CommitHash
== m_highlight
&& !m_highlight
.IsEmpty();
1128 if (isHeadHash
&& isHighlight
)
1129 hGdiObj
= m_boldItalicsFont
.GetSafeHandle();
1130 else if (isHeadHash
)
1131 hGdiObj
= m_boldFont
.GetSafeHandle();
1132 else if (isHighlight
)
1133 hGdiObj
= m_FontItalics
.GetSafeHandle();
1137 SelectObject(pLVCD
->nmcd
.hdc
, hGdiObj
);
1138 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
1141 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
1142 // crText = GetSysColor(COLOR_GRAYTEXT);
1144 if (data
->m_CommitHash
.IsEmpty())
1146 //crText = GetSysColor(RGB(200,200,0));
1147 //SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1148 // We changed the font, so we're returning CDRF_NEWFONT. This
1149 // tells the control to recalculate the extent of the text.
1150 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
1154 // Store the color back in the NMLVCUSTOMDRAW struct.
1155 pLVCD
->clrText
= crText
;
1159 case CDDS_ITEMPREPAINT
|CDDS_ITEM
|CDDS_SUBITEM
:
1161 if (pLVCD
->iSubItem
== LOGLIST_GRAPH
&& !HasFilterText() && (m_ShowFilter
& FILTERSHOW_MERGEPOINTS
))
1163 if (m_arShownList
.size() > pLVCD
->nmcd
.dwItemSpec
&& !this->m_IsRebaseReplaceGraph
)
1166 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_LABEL
, rect
);
1168 //TRACE(L"A Graphic left %d right %d\r\n", rect.left, rect.right);
1169 FillBackGround(pLVCD
->nmcd
.hdc
, pLVCD
->nmcd
.dwItemSpec
,rect
);
1171 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1172 if( !data
->m_CommitHash
.IsEmpty())
1173 DrawGraph(pLVCD
->nmcd
.hdc
,rect
,pLVCD
->nmcd
.dwItemSpec
);
1175 *pResult
= CDRF_SKIPDEFAULT
;
1180 if (pLVCD
->iSubItem
== LOGLIST_MESSAGE
)
1182 // If the top index of list is changed, the position map of reference label is outdated.
1183 if (m_OldTopIndex
!= GetTopIndex())
1185 m_OldTopIndex
= GetTopIndex();
1186 m_RefLabelPosMap
.clear();
1189 if (m_arShownList
.size() > pLVCD
->nmcd
.dwItemSpec
)
1191 GitRevLoglist
* data
= m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1193 if ((m_HashMap
.find(data
->m_CommitHash
) != m_HashMap
.cend() || (!m_superProjectHash
.IsEmpty() && data
->m_CommitHash
== m_superProjectHash
)) && !(data
->GetRebaseAction() & LOGACTIONS_REBASE_DONE
))
1196 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1198 // BEGIN: extended redraw, HACK for issue #1618 and #2014
1199 // not in FillBackGround method, because this only affected the message subitem
1200 if (0 != pLVCD
->iStateId
) // don't know why, but this helps against loosing the focus rect
1203 int index
= (int)pLVCD
->nmcd
.dwItemSpec
;
1204 int state
= GetItemState(index
, LVIS_SELECTED
);
1205 int txtState
= LISS_NORMAL
;
1206 if (IsAppThemed() && GetHotItem() == (int)index
)
1208 if (state
& LVIS_SELECTED
)
1209 txtState
= LISS_HOTSELECTED
;
1211 txtState
= LISS_HOT
;
1213 else if (state
& LVIS_SELECTED
)
1215 if (::GetFocus() == m_hWnd
)
1216 txtState
= LISS_SELECTED
;
1218 txtState
= LISS_SELECTEDNOTFOCUS
;
1221 HTHEME hTheme
= nullptr;
1223 hTheme
= OpenThemeData(m_hWnd
, L
"Explorer::ListView;ListView");
1225 if (hTheme
&& IsThemeBackgroundPartiallyTransparent(hTheme
, LVP_LISTDETAIL
, txtState
))
1226 DrawThemeParentBackground(m_hWnd
, pLVCD
->nmcd
.hdc
, &rect
);
1229 HBRUSH brush
= ::CreateSolidBrush(pLVCD
->clrTextBk
);
1230 ::FillRect(pLVCD
->nmcd
.hdc
, rect
, brush
);
1231 ::DeleteObject(brush
);
1233 if (hTheme
&& txtState
!= LISS_NORMAL
)
1236 // get rect of whole line
1237 GetItemRect(index
, rt
, LVIR_BOUNDS
);
1240 // calculate background for rect of whole line, but limit redrawing to SubItem rect
1241 DrawThemeBackground(hTheme
, pLVCD
->nmcd
.hdc
, LVP_LISTITEM
, txtState
, rt
, rect2
);
1243 CloseThemeData(hTheme
);
1245 // END: extended redraw
1247 FillBackGround(pLVCD
->nmcd
.hdc
, pLVCD
->nmcd
.dwItemSpec
,rect
);
1249 std::vector
<REFLABEL
> refsToShow
;
1250 STRING_VECTOR remoteTrackingList
;
1251 const STRING_VECTOR
& refList
= m_HashMap
[data
->m_CommitHash
];
1252 for (unsigned int i
= 0; i
< refList
.size(); ++i
)
1254 CString str
= refList
[i
];
1257 refLabel
.color
= RGB(255, 255, 255);
1258 refLabel
.singleRemote
= false;
1259 refLabel
.hasTracking
= false;
1260 refLabel
.sameName
= false;
1261 refLabel
.name
= CGit::GetShortName(str
, &refLabel
.refType
);
1262 refLabel
.fullName
= str
;
1264 switch (refLabel
.refType
)
1266 case CGit::REF_TYPE::LOCAL_BRANCH
:
1268 if (!(m_ShowRefMask
& LOGLIST_SHOWLOCALBRANCHES
))
1270 if (refLabel
.name
== m_CurrentBranch
)
1271 refLabel
.color
= m_Colors
.GetColor(CColors::CurrentBranch
);
1273 refLabel
.color
= m_Colors
.GetColor(CColors::LocalBranch
);
1275 std::pair
<CString
, CString
> trackingEntry
= m_TrackingMap
[refLabel
.name
];
1276 CString pullRemote
= trackingEntry
.first
;
1277 CString pullBranch
= trackingEntry
.second
;
1278 if (!pullRemote
.IsEmpty() && !pullBranch
.IsEmpty())
1280 CString defaultUpstream
;
1281 defaultUpstream
.Format(L
"refs/remotes/%s/%s", (LPCTSTR
)pullRemote
, (LPCTSTR
)pullBranch
);
1282 refLabel
.hasTracking
= true;
1283 if (m_ShowRefMask
& LOGLIST_SHOWREMOTEBRANCHES
)
1286 for (size_t j
= i
+ 1; j
< refList
.size(); ++j
)
1288 if (refList
[j
] == defaultUpstream
)
1297 bool sameName
= pullBranch
== refLabel
.name
;
1298 refsToShow
.push_back(refLabel
);
1299 CGit::GetShortName(defaultUpstream
, refLabel
.name
, L
"refs/remotes/");
1300 refLabel
.color
= m_Colors
.GetColor(CColors::RemoteBranch
);
1301 if (m_bSymbolizeRefNames
)
1303 if (!m_SingleRemote
.IsEmpty() && m_SingleRemote
== pullRemote
)
1305 refLabel
.simplifiedName
= L
'/';
1307 refLabel
.simplifiedName
+= L
'≡';
1309 refLabel
.simplifiedName
+= pullBranch
;
1310 refLabel
.singleRemote
= true;
1313 refLabel
.simplifiedName
= pullRemote
+ L
"/≡";
1314 refLabel
.sameName
= sameName
;
1316 refLabel
.fullName
= defaultUpstream
;
1317 refsToShow
.push_back(refLabel
);
1318 remoteTrackingList
.push_back(defaultUpstream
);
1325 case CGit::REF_TYPE::REMOTE_BRANCH
:
1327 if (!(m_ShowRefMask
& LOGLIST_SHOWREMOTEBRANCHES
))
1330 for (size_t j
= 0; j
< remoteTrackingList
.size(); ++j
)
1332 if (remoteTrackingList
[j
] == str
)
1341 refLabel
.color
= m_Colors
.GetColor(CColors::RemoteBranch
);
1342 if (m_bSymbolizeRefNames
)
1344 if (!m_SingleRemote
.IsEmpty() && CStringUtils::StartsWith(refLabel
.name
, m_SingleRemote
+ L
"/"))
1346 refLabel
.simplifiedName
= L
'/' + refLabel
.name
.Mid(m_SingleRemote
.GetLength() + 1);
1347 refLabel
.singleRemote
= true;
1352 case CGit::REF_TYPE::ANNOTATED_TAG
:
1353 case CGit::REF_TYPE::TAG
:
1354 if (!(m_ShowRefMask
& LOGLIST_SHOWTAGS
))
1356 refLabel
.color
= m_Colors
.GetColor(CColors::Tag
);
1358 case CGit::REF_TYPE::STASH
:
1359 if (!(m_ShowRefMask
& LOGLIST_SHOWSTASH
))
1361 refLabel
.color
= m_Colors
.GetColor(CColors::Stash
);
1363 case CGit::REF_TYPE::BISECT_GOOD
:
1364 case CGit::REF_TYPE::BISECT_BAD
:
1365 case CGit::REF_TYPE::BISECT_SKIP
:
1366 if (!(m_ShowRefMask
& LOGLIST_SHOWBISECT
))
1368 refLabel
.color
= (refLabel
.refType
== CGit::REF_TYPE::BISECT_GOOD
) ? m_Colors
.GetColor(CColors::BisectGood
) : ((refLabel
.refType
== CGit::REF_TYPE::BISECT_SKIP
) ? m_Colors
.GetColor(CColors::BisectSkip
) : m_Colors
.GetColor(CColors::BisectBad
));
1370 case CGit::REF_TYPE::NOTES
:
1371 if (!(m_ShowRefMask
& LOGLIST_SHOWOTHERREFS
))
1373 refLabel
.color
= m_Colors
.GetColor(CColors::NoteNode
);
1376 if (!(m_ShowRefMask
& LOGLIST_SHOWOTHERREFS
))
1378 refLabel
.color
= m_Colors
.GetColor(CColors::OtherRef
);
1381 refsToShow
.push_back(refLabel
);
1383 if (!m_superProjectHash
.IsEmpty() && data
->m_CommitHash
== m_superProjectHash
)
1386 refLabel
.color
= RGB(246, 153, 253);
1387 refLabel
.singleRemote
= false;
1388 refLabel
.hasTracking
= false;
1389 refLabel
.sameName
= false;
1390 refLabel
.name
= L
"super-project-pointer";
1391 refLabel
.fullName
= "";
1392 refsToShow
.push_back(refLabel
);
1395 if (refsToShow
.empty())
1397 *pResult
= CDRF_DODEFAULT
;
1401 DrawTagBranchMessage(pLVCD
->nmcd
.hdc
, rect
, pLVCD
->nmcd
.dwItemSpec
, refsToShow
);
1403 *pResult
= CDRF_SKIPDEFAULT
;
1411 if (pLVCD
->iSubItem
== LOGLIST_ACTION
)
1413 if (m_IsIDReplaceAction
|| !m_ColumnManager
.IsVisible(LOGLIST_ACTION
))
1415 *pResult
= CDRF_DODEFAULT
;
1418 *pResult
= CDRF_DODEFAULT
;
1420 if (m_arShownList
.size() <= pLVCD
->nmcd
.dwItemSpec
)
1424 int iconwidth
= ::GetSystemMetrics(SM_CXSMICON
);
1425 int iconheight
= ::GetSystemMetrics(SM_CYSMICON
);
1427 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1429 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1430 //TRACE(L"Action left %d right %d\r\n", rect.left, rect.right);
1431 // Get the selected state of the
1432 // item being drawn.
1434 CMemDC
myDC(*CDC::FromHandle(pLVCD
->nmcd
.hdc
), rect
);
1435 BitBlt(myDC
.GetDC(), rect
.left
, rect
.top
, rect
.Width(), rect
.Height(), pLVCD
->nmcd
.hdc
, rect
.left
, rect
.top
, SRCCOPY
);
1437 // Fill the background if necessary
1438 FillBackGround(myDC
.GetDC(), pLVCD
->nmcd
.dwItemSpec
, rect
);
1440 // Draw the icon(s) into the compatible DC
1441 int action
= pLogEntry
->GetAction(this);
1442 auto iconItemBorder
= CDPIAware::Instance().ScaleX(ICONITEMBORDER
);
1443 if (!pLogEntry
->m_IsDiffFiles
)
1445 ::DrawIconEx(myDC
.GetDC(), rect
.left
+ iconItemBorder
, rect
.top
, m_hFetchIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1446 *pResult
= CDRF_SKIPDEFAULT
;
1450 if (action
& CTGitPath::LOGACTIONS_MODIFIED
)
1451 ::DrawIconEx(myDC
.GetDC(), rect
.left
+ iconItemBorder
, rect
.top
, m_hModifiedIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1454 if (action
& (CTGitPath::LOGACTIONS_ADDED
| CTGitPath::LOGACTIONS_COPY
))
1455 ::DrawIconEx(myDC
.GetDC(), rect
.left
+ nIcons
* iconwidth
+ iconItemBorder
, rect
.top
, m_hAddedIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1458 if (action
& CTGitPath::LOGACTIONS_DELETED
)
1459 ::DrawIconEx(myDC
.GetDC(), rect
.left
+ nIcons
* iconwidth
+ iconItemBorder
, rect
.top
, m_hDeletedIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1462 if (action
& CTGitPath::LOGACTIONS_REPLACED
)
1463 ::DrawIconEx(myDC
.GetDC(), rect
.left
+ nIcons
* iconwidth
+ iconItemBorder
, rect
.top
, m_hReplacedIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1466 if (action
& CTGitPath::LOGACTIONS_UNMERGED
)
1467 ::DrawIconEx(myDC
.GetDC(), rect
.left
+ nIcons
* iconwidth
+ iconItemBorder
, rect
.top
, m_hConflictedIcon
, iconwidth
, iconheight
, 0, nullptr, DI_NORMAL
);
1470 *pResult
= CDRF_SKIPDEFAULT
;
1476 *pResult
= CDRF_DODEFAULT
;
1479 CString
FindSVNRev(const CString
& msg
)
1483 const std::wsregex_iterator end
;
1484 std::wstring s
= msg
;
1485 std::wregex
regex1(L
"^\\s*git-svn-id:\\s+(.*)\\@(\\d+)\\s([a-f\\d\\-]+)$");
1486 for (std::wsregex_iterator
it(s
.cbegin(), s
.cend(), regex1
); it
!= end
; ++it
)
1488 const std::wsmatch match
= *it
;
1489 if (match
.size() == 4)
1491 ATLTRACE(L
"matched rev: %s\n", std::wstring(match
[2]).c_str());
1492 return std::wstring(match
[2]).c_str();
1495 std::wregex
regex2(L
"^\\s*git-svn-id:\\s(\\d+)\\@([a-f\\d\\-]+)$");
1496 for (std::wsregex_iterator
it(s
.cbegin(), s
.cend(), regex2
); it
!= end
; ++it
)
1498 const std::wsmatch match
= *it
;
1499 if (match
.size() == 3)
1501 ATLTRACE(L
"matched rev: %s\n", std::wstring(match
[1]).c_str());
1502 return std::wstring(match
[1]).c_str();
1506 catch (std::exception
&) {}
1511 CString
CGitLogListBase::MessageDisplayStr(GitRev
* pLogEntry
)
1513 if (!m_bFullCommitMessageOnLogLine
|| pLogEntry
->GetBody().IsEmpty())
1514 return pLogEntry
->GetSubject();
1516 CString
txt(pLogEntry
->GetSubject());
1518 txt
+= pLogEntry
->GetBody();
1521 txt
.Replace(L
'\n', L
' ');
1522 txt
.Replace(L
'\r', L
' ');
1527 // CGitLogListBase message handlers
1529 static const char* GetMailmapMapping(GIT_MAILMAP mailmap
, const CString
& email
, const CString
& name
, bool returnEmail
)
1531 struct payload_struct
{ const CString
* name
; const char* authorName
; };
1532 payload_struct payload
= { &name
, nullptr };
1533 const char* author1
= nullptr;
1534 const char* email1
= nullptr;
1535 git_lookup_mailmap(mailmap
, &email1
, &author1
, CUnicodeUtils::GetUTF8(email
), &payload
,
1536 [](void* payload
) -> const char* { return reinterpret_cast<payload_struct
*>(payload
)->authorName
= _strdup(CUnicodeUtils::GetUTF8(*reinterpret_cast<payload_struct
*>(payload
)->name
)); });
1537 free((void *)payload
.authorName
);
1543 static void CopyMailmapProcessedData(GIT_MAILMAP mailmap
, LV_ITEM
* pItem
, const CString
& email
, const CString
& name
, bool returnEmail
)
1547 const char* translated
= GetMailmapMapping(mailmap
, email
, name
, returnEmail
);
1550 lstrcpyn(pItem
->pszText
, CUnicodeUtils::GetUnicode(translated
), pItem
->cchTextMax
- 1);
1555 lstrcpyn(pItem
->pszText
, (LPCTSTR
)email
, pItem
->cchTextMax
- 1);
1557 lstrcpyn(pItem
->pszText
, (LPCTSTR
)name
, pItem
->cchTextMax
- 1);
1560 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1562 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
1564 // Create a pointer to the item
1565 LV_ITEM
* pItem
= &(pDispInfo
)->item
;
1567 // Do the list need text information?
1568 if (!(pItem
->mask
& LVIF_TEXT
))
1571 // By default, clear text buffer.
1572 lstrcpyn(pItem
->pszText
, L
"", pItem
->cchTextMax
- 1);
1574 bool bOutOfRange
= pItem
->iItem
>= m_arShownList
.size();
1577 if (m_bNoDispUpdates
|| bOutOfRange
)
1580 // Which item number?
1581 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(pItem
->iItem
);
1585 temp
.Format(L
"%d", pItem
->iItem
+ 1);
1587 temp
.Format(L
"%zu", m_arShownList
.size() - pItem
->iItem
);
1593 switch (pItem
->iSubItem
)
1595 case LOGLIST_GRAPH
: //Graphic
1597 case LOGLIST_REBASE
:
1598 if (m_IsRebaseReplaceGraph
)
1599 lstrcpyn(pItem
->pszText
, GetRebaseActionName(pLogEntry
->GetRebaseAction() & LOGACTIONS_REBASE_MODE_MASK
), pItem
->cchTextMax
- 1);
1601 case LOGLIST_ACTION
: //action -- no text in the column
1604 lstrcpyn(pItem
->pszText
, pLogEntry
->m_CommitHash
.ToString(), pItem
->cchTextMax
- 1);
1607 if (this->m_IsIDReplaceAction
)
1608 lstrcpyn(pItem
->pszText
, temp
, pItem
->cchTextMax
- 1);
1610 case LOGLIST_MESSAGE
: //Message
1611 lstrcpyn(pItem
->pszText
, (LPCTSTR
)MessageDisplayStr(pLogEntry
), pItem
->cchTextMax
- 1);
1613 case LOGLIST_AUTHOR
: //Author
1614 CopyMailmapProcessedData(m_pMailmap
, pItem
, pLogEntry
->GetAuthorEmail(), pLogEntry
->GetAuthorName(), false);
1616 case LOGLIST_DATE
: //Date
1617 if (!pLogEntry
->m_CommitHash
.IsEmpty())
1618 lstrcpyn(pItem
->pszText
,
1619 CLoglistUtils::FormatDateAndTime(pLogEntry
->GetAuthorDate(), m_DateFormat
, true, m_bRelativeTimes
),
1620 pItem
->cchTextMax
- 1);
1624 CopyMailmapProcessedData(m_pMailmap
, pItem
, pLogEntry
->GetAuthorEmail(), pLogEntry
->GetAuthorName(), true);
1627 case LOGLIST_COMMIT_NAME
: //Commit
1628 CopyMailmapProcessedData(m_pMailmap
, pItem
, pLogEntry
->GetCommitterEmail(), pLogEntry
->GetCommitterName(), false);
1631 case LOGLIST_COMMIT_EMAIL
: //Commit Email
1632 CopyMailmapProcessedData(m_pMailmap
, pItem
, pLogEntry
->GetCommitterEmail(), pLogEntry
->GetCommitterName(), true);
1635 case LOGLIST_COMMIT_DATE
: //Commit Date
1636 if (!pLogEntry
->m_CommitHash
.IsEmpty())
1637 lstrcpyn(pItem
->pszText
,
1638 CLoglistUtils::FormatDateAndTime(pLogEntry
->GetCommitterDate(), m_DateFormat
, true, m_bRelativeTimes
),
1639 pItem
->cchTextMax
- 1);
1641 case LOGLIST_BUG
: //Bug ID
1642 lstrcpyn(pItem
->pszText
, (LPCTSTR
)this->m_ProjectProperties
.FindBugID(pLogEntry
->GetSubjectBody()), pItem
->cchTextMax
- 1);
1644 case LOGLIST_SVNREV
: //SVN revision
1645 lstrcpyn(pItem
->pszText
, (LPCTSTR
)FindSVNRev(pLogEntry
->GetSubjectBody()), pItem
->cchTextMax
- 1);
1653 bool CGitLogListBase::IsOnStash(int index
)
1655 GitRevLoglist
* rev
= m_arShownList
.SafeGetAt(index
);
1660 GitRevLoglist
* preRev
= m_arShownList
.SafeGetAt(index
- 1);
1661 if (IsStash(preRev
))
1662 return preRev
->m_ParentHash
.size() == 2 && preRev
->m_ParentHash
[1] == rev
->m_CommitHash
;
1667 bool CGitLogListBase::IsStash(const GitRev
* pSelLogEntry
)
1669 auto refList
= m_HashMap
.find(pSelLogEntry
->m_CommitHash
);
1670 if (refList
== m_HashMap
.cend())
1672 return find_if((*refList
).second
, [](const auto& ref
) { return ref
== L
"refs/stash"; }) != (*refList
).second
.cend();
1675 bool CGitLogListBase::IsBisect(const GitRev
* pSelLogEntry
)
1677 auto refList
= m_HashMap
.find(pSelLogEntry
->m_CommitHash
);
1678 if (refList
== m_HashMap
.cend())
1680 return find_if((*refList
).second
, [](const auto& ref
) { return CStringUtils::StartsWith(ref
, L
"refs/bisect/"); }) != (*refList
).second
.cend();
1683 void CGitLogListBase::GetParentHashes(GitRev
*pRev
, GIT_REV_LIST
&parentHash
)
1685 if (pRev
->m_ParentHash
.empty())
1687 if (pRev
->GetParentFromHash(pRev
->m_CommitHash
))
1688 MessageBox(pRev
->GetLastErr(), L
"TortoiseGit", MB_ICONERROR
);
1690 parentHash
= pRev
->m_ParentHash
;
1693 void CGitLogListBase::OnContextMenu(CWnd
* pWnd
, CPoint point
)
1695 __super::OnContextMenu(pWnd
, point
);
1700 int selIndex
= GetSelectionMark();
1702 return; // nothing selected, nothing to do with a context menu
1704 // if the context menu is invoked through the keyboard, we have to use
1705 // a calculated position on where to anchor the menu on
1706 if ((point
.x
== -1) && (point
.y
== -1))
1709 GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
1710 ClientToScreen(&rect
);
1711 point
= rect
.CenterPoint();
1713 m_nSearchIndex
= selIndex
;
1715 bool showExtendedMenu
= (GetAsyncKeyState(VK_SHIFT
) & 0x8000) != 0;
1717 POSITION pos
= GetFirstSelectedItemPosition();
1718 int FirstSelect
= GetNextSelectedItem(pos
);
1719 if (FirstSelect
< 0)
1722 GitRevLoglist
* pSelLogEntry
= m_arShownList
.SafeGetAt(FirstSelect
);
1723 if (pSelLogEntry
== nullptr)
1726 int LastSelect
= -1;
1727 UINT selectedCount
= 1;
1730 LastSelect
= GetNextSelectedItem(pos
);
1734 ASSERT(GetSelectedCount() == selectedCount
);
1736 //entry is selected, now show the popup menu
1738 CIconMenu subbranchmenu
, submenu
, gnudiffmenu
, diffmenu
, blamemenu
, revertmenu
;
1740 if (popup
.CreatePopupMenu())
1743 if (g_Git
.GetHash(headHash
, L
"HEAD"))
1745 MessageBox(g_Git
.GetGitLastErr(L
"Could not get HEAD hash."), L
"TortoiseGit", MB_ICONERROR
);
1748 bool isHeadCommit
= (pSelLogEntry
->m_CommitHash
== headHash
);
1749 CString currentBranch
= L
"refs/heads/" + g_Git
.GetCurrentBranch();
1750 CTGitPath
workingTree(g_Git
.m_CurrentDir
);
1751 bool isMergeActive
= workingTree
.IsMergeActive();
1752 bool isBisectActive
= workingTree
.IsBisectActive();
1753 bool isStash
= IsOnStash(FirstSelect
);
1754 GIT_REV_LIST parentHash
;
1755 GetParentHashes(pSelLogEntry
, parentHash
);
1757 if (m_ContextMenuMask
& GetContextMenuBit(ID_REBASE_PICK
) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)))
1758 popup
.AppendMenuIcon(ID_REBASE_PICK
, IDS_REBASE_PICK
, IDI_PICK
);
1760 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))
1761 popup
.AppendMenuIcon(ID_REBASE_SQUASH
, IDS_REBASE_SQUASH
, IDI_SQUASH
);
1763 if (m_ContextMenuMask
& GetContextMenuBit(ID_REBASE_EDIT
) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)))
1764 popup
.AppendMenuIcon(ID_REBASE_EDIT
, IDS_REBASE_EDIT
, IDI_EDIT
);
1766 if (m_ContextMenuMask
& GetContextMenuBit(ID_REBASE_SKIP
) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)))
1767 popup
.AppendMenuIcon(ID_REBASE_SKIP
, IDS_REBASE_SKIP
, IDI_SKIP
);
1769 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
)))
1770 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1772 if (selectedCount
== 1)
1775 bool requiresSeparator
= false;
1776 if( !pSelLogEntry
->m_CommitHash
.IsEmpty())
1778 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPARE
) && m_hasWC
) // compare revision with WC
1780 popup
.AppendMenuIcon(ID_COMPARE
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
1781 requiresSeparator
= true;
1786 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMMIT
))
1788 popup
.AppendMenuIcon(ID_COMMIT
, IDS_LOG_POPUP_COMMIT
, IDI_COMMIT
);
1789 requiresSeparator
= true;
1791 if (isMergeActive
&& (m_ContextMenuMask
& GetContextMenuBit(ID_MERGE_ABORT
)))
1793 popup
.AppendMenuIcon(ID_MERGE_ABORT
, IDS_MENUMERGEABORT
, IDI_MERGEABORT
);
1794 requiresSeparator
= true;
1798 if (m_ContextMenuMask
& GetContextMenuBit(ID_BLAMEPREVIOUS
))
1800 if (parentHash
.size() == 1)
1802 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_LOG_POPUP_BLAMEPREVIOUS
, IDI_BLAME
);
1803 requiresSeparator
= true;
1805 else if (parentHash
.size() > 1)
1807 blamemenu
.CreatePopupMenu();
1808 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_LOG_POPUP_BLAMEPREVIOUS
, IDI_BLAME
, blamemenu
.m_hMenu
);
1809 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
1812 str
.Format(IDS_PARENT
, i
+ 1);
1813 blamemenu
.AppendMenuIcon(ID_BLAMEPREVIOUS
+((i
+ 1) << 16), str
);
1815 requiresSeparator
= true;
1819 if(m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF1
) && m_hasWC
) // compare with WC, unified
1821 if (parentHash
.size() == 1)
1823 popup
.AppendMenuIcon(ID_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
1824 requiresSeparator
= true;
1826 else if (parentHash
.size() > 1)
1828 gnudiffmenu
.CreatePopupMenu();
1829 popup
.AppendMenuIcon(ID_GNUDIFF1
,IDS_LOG_POPUP_GNUDIFF_PARENT
, IDI_DIFF
, gnudiffmenu
.m_hMenu
);
1831 gnudiffmenu
.AppendMenuIcon((UINT_PTR
)(ID_GNUDIFF1
+ (0xFFFF << 16)), CString(MAKEINTRESOURCE(IDS_ALLPARENTS
)));
1832 gnudiffmenu
.AppendMenuIcon((UINT_PTR
)(ID_GNUDIFF1
+ (0xFFFE << 16)), CString(MAKEINTRESOURCE(IDS_ONLYMERGEDFILES
)));
1833 gnudiffmenu
.AppendMenuIcon((UINT_PTR
)(ID_GNUDIFF1
+ (0xFFFD << 16)), CString(MAKEINTRESOURCE(IDS_DIFFWITHMERGE
)));
1835 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
1838 str
.Format(IDS_PARENT
, i
+ 1);
1839 gnudiffmenu
.AppendMenuIcon(ID_GNUDIFF1
+((i
+1)<<16),str
);
1841 requiresSeparator
= true;
1845 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPAREWITHPREVIOUS
))
1847 if (parentHash
.size() == 1)
1849 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_LOG_POPUP_COMPAREWITHPREVIOUS
, IDI_DIFF
);
1850 if (CRegDWORD(L
"Software\\TortoiseGit\\DiffByDoubleClickInLog", FALSE
))
1851 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
1852 requiresSeparator
= true;
1854 else if (parentHash
.size() > 1)
1856 diffmenu
.CreatePopupMenu();
1857 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_LOG_POPUP_COMPAREWITHPREVIOUS
, IDI_DIFF
, diffmenu
.m_hMenu
);
1858 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
1861 str
.Format(IDS_PARENT
, i
+ 1);
1862 diffmenu
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
+((i
+1)<<16),str
);
1863 if (i
== 0 && CRegDWORD(L
"Software\\TortoiseGit\\DiffByDoubleClickInLog", FALSE
))
1865 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
1866 diffmenu
.SetDefaultItem((UINT
)(ID_COMPAREWITHPREVIOUS
+ ((i
+ 1) << 16)), FALSE
);
1869 requiresSeparator
= true;
1873 if(m_ContextMenuMask
&GetContextMenuBit(ID_BLAME
))
1875 popup
.AppendMenuIcon(ID_BLAME
, IDS_LOG_POPUP_BLAME
, IDI_BLAME
);
1876 requiresSeparator
= true;
1879 if (requiresSeparator
)
1881 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1882 requiresSeparator
= false;
1885 if (pSelLogEntry
->m_CommitHash
.IsEmpty() && !isMergeActive
)
1887 if(m_ContextMenuMask
&GetContextMenuBit(ID_STASH_SAVE
))
1889 popup
.AppendMenuIcon(ID_STASH_SAVE
, IDS_MENUSTASHSAVE
, IDI_SHELVE
);
1890 requiresSeparator
= true;
1894 if ((pSelLogEntry
->m_CommitHash
.IsEmpty() || isStash
) && workingTree
.HasStashDir())
1896 if (m_ContextMenuMask
&GetContextMenuBit(ID_STASH_POP
))
1898 popup
.AppendMenuIcon(ID_STASH_POP
, IDS_MENUSTASHPOP
, IDI_UNSHELVE
);
1899 requiresSeparator
= true;
1902 if (m_ContextMenuMask
&GetContextMenuBit(ID_STASH_LIST
))
1904 popup
.AppendMenuIcon(ID_STASH_LIST
, IDS_MENUSTASHLIST
, IDI_LOG
);
1905 requiresSeparator
= true;
1909 if (requiresSeparator
)
1911 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1912 requiresSeparator
= false;
1917 GitRevLoglist
* pFirstEntry
= m_arShownList
.SafeGetAt(FirstSelect
);
1918 if (m_ContextMenuMask
&GetContextMenuBit(ID_BISECTGOOD
) && !IsBisect(pFirstEntry
))
1920 popup
.AppendMenuIcon(ID_BISECTGOOD
, IDS_MENUBISECTGOOD
, IDI_THUMB_UP
);
1921 requiresSeparator
= true;
1924 if (m_ContextMenuMask
&GetContextMenuBit(ID_BISECTBAD
) && !IsBisect(pFirstEntry
))
1926 popup
.AppendMenuIcon(ID_BISECTBAD
, IDS_MENUBISECTBAD
, IDI_THUMB_DOWN
);
1927 requiresSeparator
= true;
1929 if (m_ContextMenuMask
&GetContextMenuBit(ID_BISECTSKIP
) && !IsBisect(pFirstEntry
))
1931 popup
.AppendMenuIcon(ID_BISECTSKIP
, IDS_MENUBISECTSKIP
, IDI_BISECT
);
1932 requiresSeparator
= true;
1936 if (pSelLogEntry
->m_CommitHash
.IsEmpty() && isBisectActive
)
1938 if (m_ContextMenuMask
&GetContextMenuBit(ID_BISECTRESET
))
1940 popup
.AppendMenuIcon(ID_BISECTRESET
, IDS_MENUBISECTRESET
, IDI_BISECT_RESET
);
1941 requiresSeparator
= true;
1945 if (requiresSeparator
)
1947 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1948 requiresSeparator
= false;
1951 if (pSelLogEntry
->m_CommitHash
.IsEmpty())
1953 if (m_ContextMenuMask
& GetContextMenuBit(ID_PULL
) && !isMergeActive
)
1954 popup
.AppendMenuIcon(ID_PULL
, IDS_MENUPULL
, IDI_PULL
);
1956 if(m_ContextMenuMask
&GetContextMenuBit(ID_FETCH
))
1957 popup
.AppendMenuIcon(ID_FETCH
, IDS_MENUFETCH
, IDI_UPDATE
);
1959 if ((m_ContextMenuMask
& GetContextMenuBit(ID_SUBMODULE_UPDATE
)) && workingTree
.HasSubmodules())
1960 popup
.AppendMenuIcon(ID_SUBMODULE_UPDATE
, IDS_PROC_SYNC_SUBKODULEUPDATE
, IDI_UPDATE
);
1962 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1964 if (m_ContextMenuMask
& GetContextMenuBit(ID_CLEANUP
))
1965 popup
.AppendMenuIcon(ID_CLEANUP
, IDS_MENUCLEANUP
, IDI_CLEANUP
);
1967 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1971 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
1973 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
1975 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
1977 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
1979 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
1980 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
1982 // popup.AppendMenu(MF_SEPARATOR, NULL);
1987 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
1989 if(!pSelLogEntry
->m_CommitHash
.IsEmpty())
1991 if ((m_ContextMenuMask
& GetContextMenuBit(ID_LOG
)) && selectedCount
== 1)
1992 popup
.AppendMenuIcon(ID_LOG
, IDS_LOG_POPUP_LOG
, IDI_LOG
);
1994 if (m_ContextMenuMask
&GetContextMenuBit(ID_REPOBROWSE
))
1995 popup
.AppendMenuIcon(ID_REPOBROWSE
, IDS_LOG_BROWSEREPO
, IDI_REPOBROWSE
);
1997 str
.Format(IDS_LOG_POPUP_MERGEREV
, (LPCTSTR
)g_Git
.GetCurrentBranch());
1999 if (m_ContextMenuMask
&GetContextMenuBit(ID_MERGEREV
) && !isHeadCommit
&& m_hasWC
&& !isMergeActive
&& !isStash
)
2001 popup
.AppendMenuIcon(ID_MERGEREV
, str
, IDI_MERGE
);
2003 size_t index
= (size_t)-1;
2004 CGit::REF_TYPE type
= CGit::REF_TYPE::UNKNOWN
;
2005 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, nullptr, &index
))
2006 popup
.SetMenuItemData(ID_MERGEREV
, (ULONG_PTR
)&m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2009 str
.Format(IDS_RESET_TO_THIS_FORMAT
, (LPCTSTR
)g_Git
.GetCurrentBranch());
2011 if (m_ContextMenuMask
&GetContextMenuBit(ID_RESET
) && m_hasWC
&& !isStash
)
2012 popup
.AppendMenuIcon(ID_RESET
, str
, IDI_RESET
);
2015 // Add Switch Branch express Menu
2016 if( this->m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.end()
2017 && (m_ContextMenuMask
&GetContextMenuBit(ID_SWITCHBRANCH
) && m_hasWC
&& !isStash
)
2020 std::vector
<const CString
*> branchs
;
2021 auto addCheck
= [&](const CString
& ref
)
2023 if (!CStringUtils::StartsWith(ref
, L
"refs/heads/") || ref
== currentBranch
)
2025 branchs
.push_back(&ref
);
2027 size_t index
= (size_t)-1;
2028 CGit::REF_TYPE type
= CGit::REF_TYPE::UNKNOWN
;
2029 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, nullptr, &index
))
2030 addCheck(m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2032 for_each(m_HashMap
[pSelLogEntry
->m_CommitHash
], addCheck
);
2035 str2
.LoadString(IDS_SWITCH_BRANCH
);
2037 if(branchs
.size() == 1)
2040 str2
+= L
'"' + branchs
[0]->Mid((int)wcslen(L
"refs/heads/")) + L
'"';
2041 popup
.AppendMenuIcon(ID_SWITCHBRANCH
, str2
, IDI_SWITCH
);
2043 popup
.SetMenuItemData(ID_SWITCHBRANCH
,(ULONG_PTR
)branchs
[0]);
2046 else if(branchs
.size() > 1)
2048 subbranchmenu
.CreatePopupMenu();
2049 for (size_t i
= 0 ; i
< branchs
.size(); ++i
)
2051 if (*branchs
[i
] != currentBranch
)
2053 subbranchmenu
.AppendMenuIcon(ID_SWITCHBRANCH
+(i
<<16), branchs
[i
]->Mid(11));
2054 subbranchmenu
.SetMenuItemData(ID_SWITCHBRANCH
+(i
<<16), (ULONG_PTR
) branchs
[i
]);
2058 popup
.AppendMenuIcon(ID_SWITCHBRANCH
, str2
, IDI_SWITCH
, subbranchmenu
.m_hMenu
);
2062 if (m_ContextMenuMask
&GetContextMenuBit(ID_SWITCHTOREV
) && !isHeadCommit
&& m_hasWC
&& !isStash
)
2064 popup
.AppendMenuIcon(ID_SWITCHTOREV
, IDS_SWITCH_TO_THIS
, IDI_SWITCH
);
2065 size_t index
= (size_t)-1;
2066 CGit::REF_TYPE type
= CGit::REF_TYPE::UNKNOWN
;
2067 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, nullptr, &index
))
2068 popup
.SetMenuItemData(ID_SWITCHTOREV
, (ULONG_PTR
)&m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2071 if (m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_BRANCH
) && !isStash
)
2073 popup
.AppendMenuIcon(ID_CREATE_BRANCH
, IDS_CREATE_BRANCH_AT_THIS
, IDI_COPY
);
2075 size_t index
= (size_t)-1;
2076 CGit::REF_TYPE type
= CGit::REF_TYPE::REMOTE_BRANCH
;
2077 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, nullptr, &index
))
2078 popup
.SetMenuItemData(ID_CREATE_BRANCH
, (ULONG_PTR
)&m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2081 if (m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_TAG
) && !isStash
)
2082 popup
.AppendMenuIcon(ID_CREATE_TAG
,IDS_CREATE_TAG_AT_THIS
, IDI_TAG
);
2084 str
.Format(IDS_REBASE_THIS_FORMAT
, (LPCTSTR
)g_Git
.GetCurrentBranch());
2086 if (pSelLogEntry
->m_CommitHash
!= headHash
&& m_hasWC
&& !isMergeActive
&& !isStash
)
2087 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_TO_VERSION
))
2088 popup
.AppendMenuIcon(ID_REBASE_TO_VERSION
, str
, IDI_REBASE
);
2090 if(m_ContextMenuMask
&GetContextMenuBit(ID_EXPORT
))
2091 popup
.AppendMenuIcon(ID_EXPORT
,IDS_EXPORT_TO_THIS
, IDI_EXPORT
);
2093 if (m_ContextMenuMask
&GetContextMenuBit(ID_REVERTREV
) && m_hasWC
&& !isMergeActive
&& !isStash
)
2095 if (parentHash
.size() == 1)
2096 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
);
2097 else if (parentHash
.size() > 1)
2099 revertmenu
.CreatePopupMenu();
2100 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
, revertmenu
.m_hMenu
);
2102 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
2105 str2
.Format(IDS_PARENT
, i
+ 1);
2106 revertmenu
.AppendMenuIcon(ID_REVERTREV
+ ((i
+ 1) << 16), str2
);
2111 if (m_ContextMenuMask
&GetContextMenuBit(ID_EDITNOTE
) && !isStash
)
2112 popup
.AppendMenuIcon(ID_EDITNOTE
, IDS_EDIT_NOTES
, IDI_EDIT
);
2114 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2118 if(!pSelLogEntry
->m_Ref
.IsEmpty())
2120 popup
.AppendMenuIcon(ID_REFLOG_DEL
, IDS_REFLOG_DEL
, IDI_DELETE
);
2121 if (selectedCount
== 1 && CStringUtils::StartsWith(pSelLogEntry
->m_Ref
, L
"refs/stash"))
2122 popup
.AppendMenuIcon(ID_REFLOG_STASH_APPLY
, IDS_MENUSTASHAPPLY
, IDI_UNSHELVE
);
2123 if (selectedCount
<= 2)
2124 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2127 if (selectedCount
>= 2)
2129 bool bAddSeparator
= false;
2130 if ((selectedCount
== 2) || IsSelectionContinuous())
2132 if (m_ContextMenuMask
&GetContextMenuBit(ID_COMPARETWO
)) // compare two revisions
2134 popup
.AppendMenuIcon(ID_COMPARETWO
, IDS_LOG_POPUP_COMPARETWO
, IDI_DIFF
);
2135 bAddSeparator
= true;
2139 if (selectedCount
== 2)
2141 if (m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF2
) && m_hasWC
) // compare two revisions, unified
2143 popup
.AppendMenuIcon(ID_GNUDIFF2
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
2144 bAddSeparator
= true;
2147 if (!pSelLogEntry
->m_CommitHash
.IsEmpty())
2149 CString firstSelHash
= pSelLogEntry
->m_CommitHash
.ToString().Left(g_Git
.GetShortHASHLength());
2150 GitRevLoglist
* pLastEntry
= m_arShownList
.SafeGetAt(LastSelect
);
2151 CString lastSelHash
= pLastEntry
->m_CommitHash
.ToString().Left(g_Git
.GetShortHASHLength());
2153 menu
.Format(IDS_SHOWLOG_OF
, (LPCTSTR
)(lastSelHash
+ L
".." + firstSelHash
));
2154 popup
.AppendMenuIcon(ID_LOG_VIEWRANGE
, menu
, IDI_LOG
);
2155 menu
.Format(IDS_SHOWLOG_OF
, (LPCTSTR
)(lastSelHash
+ L
"..." + firstSelHash
));
2156 popup
.AppendMenuIcon(ID_LOG_VIEWRANGE_REACHABLEFROMONLYONE
, menu
, IDI_LOG
);
2157 bAddSeparator
= true;
2161 if ((m_ContextMenuMask
& GetContextMenuBit(ID_COMPARETWOCOMMITCHANGES
)) && selectedCount
== 2 && !IsSelectionContinuous())
2163 bAddSeparator
= true;
2164 popup
.AppendMenuIcon(ID_COMPARETWOCOMMITCHANGES
, IDS_LOG_POPUP_COMPARECHANGESET
, IDI_DIFF
);
2169 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2170 bAddSeparator
= false;
2173 if (m_ContextMenuMask
&GetContextMenuBit(ID_REVERTREV
) && m_hasWC
&& !isMergeActive
)
2174 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREVS
, IDI_REVERT
);
2177 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2180 if (selectedCount
> 1 && isBisectActive
&& (m_ContextMenuMask
& GetContextMenuBit(ID_BISECTSKIP
)) && !IsBisect(pSelLogEntry
))
2182 popup
.AppendMenuIcon(ID_BISECTSKIP
, IDS_MENUBISECTSKIP
, IDI_BISECT
);
2183 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2186 if (!pSelLogEntry
->m_CommitHash
.IsEmpty())
2188 bool bAddSeparator
= false;
2189 if (selectedCount
>= 2 && IsSelectionContinuous())
2191 if (m_ContextMenuMask
&GetContextMenuBit(ID_COMBINE_COMMIT
) && m_hasWC
&& !isMergeActive
)
2195 headindex
= this->GetHeadIndex();
2196 if(headindex
>=0 && LastSelect
>= headindex
&& FirstSelect
>= headindex
)
2198 head
.Format(L
"HEAD~%d", FirstSelect
- headindex
);
2200 int ret
= g_Git
.GetHash(hashFirst
, head
);
2201 head
.Format(L
"HEAD~%d",LastSelect
-headindex
);
2203 ret
= ret
|| g_Git
.GetHash(hash
, head
);
2204 GitRevLoglist
* pFirstEntry
= m_arShownList
.SafeGetAt(FirstSelect
);
2205 GitRevLoglist
* pLastEntry
= m_arShownList
.SafeGetAt(LastSelect
);
2206 if (!ret
&& pFirstEntry
->m_CommitHash
== hashFirst
&& pLastEntry
->m_CommitHash
== hash
)
2208 popup
.AppendMenuIcon(ID_COMBINE_COMMIT
,IDS_COMBINE_TO_ONE
,IDI_COMBINE
);
2209 bAddSeparator
= true;
2214 if (m_ContextMenuMask
&GetContextMenuBit(ID_CHERRY_PICK
) && !isHeadCommit
&& m_hasWC
&& !isMergeActive
) {
2215 if (selectedCount
>= 2)
2216 popup
.AppendMenuIcon(ID_CHERRY_PICK
, IDS_CHERRY_PICK_VERSIONS
, IDI_PICK
);
2218 popup
.AppendMenuIcon(ID_CHERRY_PICK
, IDS_CHERRY_PICK_VERSION
, IDI_PICK
);
2219 bAddSeparator
= true;
2222 if (selectedCount
<= 2 || (IsSelectionContinuous() && !isStash
))
2223 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_PATCH
)) {
2224 popup
.AppendMenuIcon(ID_CREATE_PATCH
, IDS_CREATE_PATCH
, IDI_PATCH
);
2225 bAddSeparator
= true;
2229 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2232 if (m_hasWC
&& !isMergeActive
&& !isStash
&& (m_ContextMenuMask
& GetContextMenuBit(ID_BISECTSTART
)) && selectedCount
== 2 && !m_arShownList
.SafeGetAt(FirstSelect
)->m_CommitHash
.IsEmpty() && !isBisectActive
)
2234 popup
.AppendMenuIcon(ID_BISECTSTART
, IDS_MENUBISECTSTART
, IDI_BISECT
);
2235 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2238 if (selectedCount
== 1)
2240 bool bAddSeparator
= false;
2241 if ((m_ContextMenuMask
& GetContextMenuBit(ID_PUSH
)) && ((!isStash
&& m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.cend()) || showExtendedMenu
))
2243 // show the push-option only if the log entry has an associated local branch
2244 bool isLocal
= find_if(m_HashMap
[pSelLogEntry
->m_CommitHash
], [](const CString
& ref
) { return CStringUtils::StartsWith(ref
, L
"refs/heads/") || CStringUtils::StartsWith(ref
, L
"refs/tags/"); }) != m_HashMap
[pSelLogEntry
->m_CommitHash
].cend();
2245 if (isLocal
|| showExtendedMenu
)
2248 str
.LoadString(IDS_MENUPUSH
);
2251 size_t index
= (size_t)-1;
2252 CGit::REF_TYPE type
= CGit::REF_TYPE::UNKNOWN
;
2253 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, &branch
, &index
))
2254 if (type
== CGit::REF_TYPE::LOCAL_BRANCH
|| type
== CGit::REF_TYPE::ANNOTATED_TAG
|| type
== CGit::REF_TYPE::TAG
)
2255 str
.Insert(str
.Find(L
'.'), L
" \"" + branch
+ L
'"');
2257 popup
.AppendMenuIcon(ID_PUSH
, str
, IDI_PUSH
);
2259 if (index
!= (size_t)-1 && index
< m_HashMap
[pSelLogEntry
->m_CommitHash
].size())
2260 popup
.SetMenuItemData(ID_PUSH
, (ULONG_PTR
)&m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2262 if (m_ContextMenuMask
& GetContextMenuBit(ID_SVNDCOMMIT
) && workingTree
.HasGitSVNDir())
2263 popup
.AppendMenuIcon(ID_SVNDCOMMIT
, IDS_MENUSVNDCOMMIT
, IDI_COMMIT
);
2265 bAddSeparator
= true;
2268 if (m_ContextMenuMask
& GetContextMenuBit(ID_PULL
) && isHeadCommit
&& !isMergeActive
&& m_hasWC
)
2270 popup
.AppendMenuIcon(ID_PULL
, IDS_MENUPULL
, IDI_PULL
);
2271 bAddSeparator
= true;
2275 if(m_ContextMenuMask
&GetContextMenuBit(ID_DELETE
))
2277 if( this->m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.end() )
2279 std::vector
<const CString
*> branchs
;
2280 auto addCheck
= [&](const CString
& ref
)
2282 if (ref
== currentBranch
)
2284 branchs
.push_back(&ref
);
2286 size_t index
= (size_t)-1;
2287 CGit::REF_TYPE type
= CGit::REF_TYPE::UNKNOWN
;
2288 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, nullptr, &index
))
2289 addCheck(m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2291 for_each(m_HashMap
[pSelLogEntry
->m_CommitHash
], addCheck
);
2294 if (branchs
.size() == 1)
2296 str
.LoadString(IDS_DELETE_BRANCHTAG_SHORT
);
2299 popup
.AppendMenuIcon(ID_DELETE
, str
, IDI_DELETE
);
2300 popup
.SetMenuItemData(ID_DELETE
, (ULONG_PTR
)branchs
[0]);
2301 bAddSeparator
= true;
2303 else if (branchs
.size() > 1)
2305 str
.LoadString(IDS_DELETE_BRANCHTAG
);
2306 submenu
.CreatePopupMenu();
2307 for (size_t i
= 0; i
< branchs
.size(); ++i
)
2309 submenu
.AppendMenuIcon(ID_DELETE
+ (i
<< 16), *branchs
[i
]);
2310 submenu
.SetMenuItemData(ID_DELETE
+ (i
<< 16), (ULONG_PTR
)branchs
[i
]);
2312 submenu
.AppendMenuIcon(ID_DELETE
+ (branchs
.size() << 16), IDS_ALL
);
2313 submenu
.SetMenuItemData(ID_DELETE
+ (branchs
.size() << 16), (ULONG_PTR
)MAKEINTRESOURCE(IDS_ALL
));
2315 popup
.AppendMenuIcon(ID_DELETE
,str
, IDI_DELETE
, submenu
.m_hMenu
);
2316 bAddSeparator
= true;
2319 } // m_ContextMenuMask &GetContextMenuBit(ID_DELETE)
2321 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2322 } // selectedCount == 1
2324 CIconMenu clipSubMenu
;
2325 if (!clipSubMenu
.CreatePopupMenu())
2327 if (m_ContextMenuMask
& GetContextMenuBit(ID_COPYCLIPBOARD
))
2329 clipSubMenu
.AppendMenuIcon(ID_COPYCLIPBOARDFULL
, IDS_LOG_POPUP_CLIPBOARD_FULL
, IDI_COPYCLIP
);
2330 clipSubMenu
.AppendMenuIcon(ID_COPYCLIPBOARDFULLNOPATHS
, IDS_LOG_POPUP_CLIPBOARD_FULLNOPATHS
, IDI_COPYCLIP
);
2331 clipSubMenu
.AppendMenuIcon(ID_COPYCLIPBOARDHASH
, IDS_LOG_HASH
, IDI_COPYCLIP
);
2332 clipSubMenu
.AppendMenuIcon(ID_COPYCLIPBOARDAUTHORSFULL
, IDS_LOG_POPUP_CLIPBOARD_AUTHORSFULL
, IDI_COPYCLIP
);
2333 clipSubMenu
.AppendMenuIcon(ID_COPYCLIPBOARDAUTHORSNAME
, IDS_LOG_POPUP_CLIPBOARD_AUTHORSNAME
, IDI_COPYCLIP
);
2334 clipSubMenu
.AppendMenuIcon(ID_COPYCLIPBOARDAUTHORSEMAIL
, IDS_LOG_POPUP_CLIPBOARD_AUTHORSEMAIL
, IDI_COPYCLIP
);
2335 clipSubMenu
.AppendMenuIcon(ID_COPYCLIPBOARDSUBJECTS
, IDS_LOG_POPUP_CLIPBOARD_SUBJECTS
, IDI_COPYCLIP
);
2336 clipSubMenu
.AppendMenuIcon(ID_COPYCLIPBOARDMESSAGES
, IDS_LOG_POPUP_CLIPBOARD_MSGS
, IDI_COPYCLIP
);
2337 if (m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.cend() && selectedCount
== 1)
2339 clipSubMenu
.AppendMenuIcon(ID_COPYCLIPBOARDBRANCHTAG
, IDS_LOG_POPUP_CLIPBOARD_TAGBRANCHES
, IDI_COPYCLIP
);
2340 size_t index
= (size_t)-1;
2341 CGit::REF_TYPE type
= CGit::REF_TYPE::UNKNOWN
;
2342 if (IsMouseOnRefLabelFromPopupMenu(pSelLogEntry
, point
, type
, nullptr, &index
))
2343 clipSubMenu
.SetMenuItemData(ID_COPYCLIPBOARDBRANCHTAG
, (ULONG_PTR
)&m_HashMap
[pSelLogEntry
->m_CommitHash
][index
]);
2347 temp
.LoadString(IDS_LOG_POPUP_COPYTOCLIPBOARD
);
2348 popup
.InsertMenu((UINT
)-1, MF_BYPOSITION
| MF_POPUP
, (UINT_PTR
)clipSubMenu
.m_hMenu
, temp
);
2351 if(m_ContextMenuMask
&GetContextMenuBit(ID_FINDENTRY
))
2352 popup
.AppendMenuIcon(ID_FINDENTRY
, IDS_LOG_POPUP_FIND
, IDI_FILTEREDIT
);
2354 if (selectedCount
== 1 && (m_ContextMenuMask
& GetContextMenuBit(ID_SHOWBRANCHES
)) && !pSelLogEntry
->m_CommitHash
.IsEmpty())
2355 popup
.AppendMenuIcon(ID_SHOWBRANCHES
, IDS_LOG_POPUP_SHOWBRANCHES
, IDI_SHOWBRANCHES
);
2357 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this);
2358 // DialogEnableWindow(IDOK, FALSE);
2359 // SetPromptApp(&theApp);
2361 this->ContextMenuAction(cmd
, FirstSelect
, LastSelect
, &popup
);
2363 // EnableOKButton();
2364 } // if (popup.CreatePopupMenu())
2367 bool CGitLogListBase::IsSelectionContinuous()
2369 if ( GetSelectedCount()==1 )
2371 // if only one revision is selected, the selection is of course
2376 POSITION pos
= GetFirstSelectedItemPosition();
2377 bool bContinuous
= (m_arShownList
.size() == m_logEntries
.size());
2380 int itemindex
= GetNextSelectedItem(pos
);
2383 int nextindex
= GetNextSelectedItem(pos
);
2384 if (nextindex
- itemindex
> 1)
2386 bContinuous
= false;
2389 itemindex
= nextindex
;
2395 void CGitLogListBase::CopySelectionToClipBoard(int toCopy
)
2398 POSITION pos
= GetFirstSelectedItemPosition();
2402 sRev
.LoadString(IDS_LOG_REVISION
);
2404 sAuthor
.LoadString(IDS_LOG_AUTHOR
);
2406 sDate
.LoadString(IDS_LOG_DATE
);
2408 sMessage
.LoadString(IDS_LOG_MESSAGE
);
2409 CString
from(MAKEINTRESOURCE(IDS_STATUSLIST_FROM
));
2413 CString sLogCopyText
;
2415 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
));
2417 if (toCopy
== ID_COPYCLIPBOARDFULL
)
2419 sPaths
= L
"----\r\n";
2420 for (int cpPathIndex
= 0; cpPathIndex
<pLogEntry
->GetFiles(this).GetCount(); ++cpPathIndex
)
2422 sPaths
+= ((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetActionName() + L
": " + pLogEntry
->GetFiles(this)[cpPathIndex
].GetGitPathString();
2423 if (((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).m_Action
& (CTGitPath::LOGACTIONS_REPLACED
| CTGitPath::LOGACTIONS_COPY
) && !((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetGitOldPathString().IsEmpty())
2426 sPaths
.AppendFormat(from
, (LPCTSTR
)((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetGitOldPathString());
2434 if (toCopy
== ID_COPYCLIPBOARDFULL
|| toCopy
== ID_COPYCLIPBOARDFULLNOPATHS
)
2437 if (!pLogEntry
->m_Notes
.IsEmpty())
2439 sNotesTags
= L
"----\n" + CString(MAKEINTRESOURCE(IDS_NOTES
));
2440 sNotesTags
+= L
":\n";
2441 sNotesTags
+= pLogEntry
->m_Notes
;
2442 sNotesTags
.Replace(L
"\n", L
"\r\n");
2444 CString tagInfo
= GetTagInfo(pLogEntry
);
2445 if (!tagInfo
.IsEmpty())
2447 sNotesTags
+= L
"----\r\n" + CString(MAKEINTRESOURCE(IDS_PROC_LOG_TAGINFO
)) + L
":\r\n";
2448 tagInfo
.Replace(L
"\n", L
"\r\n");
2449 sNotesTags
+= tagInfo
;
2452 sLogCopyText
.Format(L
"%s: %s\r\n%s: %s <%s>\r\n%s: %s\r\n%s:\r\n%s\r\n%s%s\r\n",
2453 (LPCTSTR
)sRev
, (LPCTSTR
)pLogEntry
->m_CommitHash
.ToString(),
2454 (LPCTSTR
)sAuthor
, (LPCTSTR
)pLogEntry
->GetAuthorName(), (LPCTSTR
)pLogEntry
->GetAuthorEmail(),
2456 (LPCTSTR
)CLoglistUtils::FormatDateAndTime(pLogEntry
->GetAuthorDate(), m_DateFormat
, true, m_bRelativeTimes
),
2457 (LPCTSTR
)sMessage
, (LPCTSTR
)pLogEntry
->GetSubjectBody(true),
2458 (LPCTSTR
)sNotesTags
,
2460 sClipdata
+= sLogCopyText
;
2462 else if (toCopy
== ID_COPYCLIPBOARDAUTHORSFULL
)
2465 sClipdata
+= L
"\r\n";
2466 sClipdata
+= pLogEntry
->GetAuthorName();
2468 sClipdata
+= pLogEntry
->GetAuthorEmail();
2471 else if (toCopy
== ID_COPYCLIPBOARDAUTHORSNAME
)
2474 sClipdata
+= L
"\r\n";
2475 sClipdata
+= pLogEntry
->GetAuthorName();
2477 else if (toCopy
== ID_COPYCLIPBOARDAUTHORSEMAIL
)
2480 sClipdata
+= L
"\r\n";
2481 sClipdata
+= pLogEntry
->GetAuthorEmail();
2484 else if (toCopy
== ID_COPYCLIPBOARDMESSAGES
)
2487 sClipdata
+= pLogEntry
->GetSubjectBody(true);
2488 sClipdata
+= L
"\r\n\r\n";
2490 else if (toCopy
== ID_COPYCLIPBOARDSUBJECTS
)
2493 sClipdata
+= pLogEntry
->GetSubject().Trim();
2494 sClipdata
+= L
"\r\n\r\n";
2499 sClipdata
+= L
"\r\n";
2500 sClipdata
+= pLogEntry
->m_CommitHash
.ToString();
2505 CStringUtils::WriteAsciiStringToClipboard(sClipdata
, GetSafeHwnd());
2509 void CGitLogListBase::DiffSelectedRevWithPrevious()
2511 if (m_bThreadRunning
)
2514 int FirstSelect
=-1, LastSelect
=-1;
2515 POSITION pos
= GetFirstSelectedItemPosition();
2516 FirstSelect
= GetNextSelectedItem(pos
);
2518 LastSelect
= GetNextSelectedItem(pos
);
2520 ContextMenuAction(ID_COMPAREWITHPREVIOUS
, FirstSelect
, LastSelect
, nullptr);
2523 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2525 LPNMLVFINDITEM pFindInfo
= reinterpret_cast<LPNMLVFINDITEM
>(pNMHDR
);
2528 if (pFindInfo
->lvfi
.flags
& LVFI_PARAM
)
2530 if (pFindInfo
->iStart
< 0 || pFindInfo
->iStart
>= (int)m_arShownList
.size())
2532 if (!pFindInfo
->lvfi
.psz
)
2535 CString sCmp
= pFindInfo
->lvfi
.psz
;
2537 for (int i
=pFindInfo
->iStart
; i
<m_arShownList
.GetCount(); ++i
)
2539 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(i
));
2540 sRev
.Format(L
"%ld", pLogEntry
->Rev
);
2541 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
2543 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
2551 if (sCmp
.Compare(sRev
)==0)
2558 if (pFindInfo
->lvfi
.flags
& LVFI_WRAP
)
2560 for (int i
=0; i
<pFindInfo
->iStart
; ++i
)
2562 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(i
));
2563 sRev
.Format(L
"%ld", pLogEntry
->Rev
);
2564 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
2566 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
2574 if (sCmp
.Compare(sRev
)==0)
2586 int CGitLogListBase::FillGitLog(CTGitPath
*path
, CString
*range
, int info
)
2590 this->m_arShownList
.SafeRemoveAll();
2592 this->m_logEntries
.ClearAll();
2593 if (this->m_logEntries
.ParserFromLog(path
, 0, info
, range
))
2596 SetItemCountEx((int)m_logEntries
.size());
2598 for (unsigned int i
= 0; i
< m_logEntries
.size(); ++i
)
2602 m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1).m_IsFull
=TRUE
;
2603 this->m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1));
2607 m_logEntries
.GetGitRevAt(i
).m_IsFull
=TRUE
;
2608 this->m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2619 int CGitLogListBase::FillGitLog(std::unordered_set
<CGitHash
>& hashes
)
2623 m_arShownList
.SafeRemoveAll();
2625 m_logEntries
.ClearAll();
2626 if (m_logEntries
.Fill(hashes
))
2629 SetItemCountEx((int)m_logEntries
.size());
2631 for (unsigned int i
= 0; i
< m_logEntries
.size(); ++i
)
2635 m_logEntries
.GetGitRevAt(m_logEntries
.size() - i
- 1).m_IsFull
= TRUE
;
2636 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(m_logEntries
.size() - i
- 1));
2640 m_logEntries
.GetGitRevAt(i
).m_IsFull
= TRUE
;
2641 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2650 int CGitLogListBase::BeginFetchLog()
2654 this->m_arShownList
.SafeRemoveAll();
2656 this->m_logEntries
.ClearAll();
2658 this->m_LogCache
.ClearAllParent();
2660 m_LogCache
.FetchCacheIndex(g_Git
.m_CurrentDir
);
2663 if(this->m_Path
.IsEmpty())
2669 mask
= CGit::LOG_INFO_ONLY_HASH
;
2670 if (m_bIncludeBoundaryCommits
)
2671 mask
|= CGit::LOG_INFO_BOUNDARY
;
2672 // if(this->m_bAllBranch)
2673 mask
|= m_ShowMask
;
2677 this->m_logEntries
.insert(m_logEntries
.cbegin(), m_wcRev
.m_CommitHash
);
2679 this->m_LogCache
.m_HashMap
[m_wcRev
.m_CommitHash
]=m_wcRev
;
2682 if (m_sRange
.IsEmpty())
2685 // follow does not work for directories
2686 if (!path
|| path
->IsDirectory())
2687 mask
&= ~CGit::LOG_INFO_FOLLOW
;
2688 // follow does not work with all branches 8at least in TGit)
2689 if (mask
& CGit::LOG_INFO_FOLLOW
)
2690 mask
&= ~(CGit::LOG_INFO_ALL_BRANCH
| CGit::LOG_INFO_BASIC_REFS
| CGit::LOG_INFO_LOCAL_BRANCHES
);
2692 CString cmd
= g_Git
.GetLogCmd(m_sRange
, path
, mask
, &m_Filter
, CRegDWORD(L
"Software\\TortoiseGit\\LogOrderBy", CGit::LOG_ORDER_TOPOORDER
));
2694 //this->m_logEntries.ParserFromLog();
2695 if(IsInWorkingThread())
2697 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
);
2701 SetItemCountEx((int)m_logEntries
.size());
2706 [] { git_init(); } ();
2711 MessageBox(L
"Could not initialize libgit.\nlibgit reports:\n" + err
, L
"TortoiseGit", MB_ICONERROR
);
2715 if (!g_Git
.CanParseRev(m_sRange
))
2717 if (!(mask
& CGit::LOG_INFO_ALL_BRANCH
) && !(mask
& CGit::LOG_INFO_BASIC_REFS
) && !(mask
& CGit::LOG_INFO_LOCAL_BRANCHES
))
2720 // if show all branches, pick any ref as dummy entry ref
2722 if (g_Git
.GetRefList(list
))
2723 MessageBox(g_Git
.GetGitLastErr(L
"Could not get all refs."), L
"TortoiseGit", MB_ICONERROR
);
2727 cmd
= g_Git
.GetLogCmd(list
[0], path
, mask
, &m_Filter
, CRegDWORD(L
"Software\\TortoiseGit\\LogOrderBy", CGit::LOG_ORDER_TOPOORDER
));
2730 g_Git
.m_critGitDllSec
.Lock();
2732 if (git_open_log(&m_DllGitLog
, CUnicodeUtils::GetMulti(cmd
, CP_UTF8
)))
2734 g_Git
.m_critGitDllSec
.Unlock();
2740 g_Git
.m_critGitDllSec
.Unlock();
2742 MessageBox(L
"Could not open log.\nlibgit reports:\n" + err
, L
"TortoiseGit", MB_ICONERROR
);
2745 g_Git
.m_critGitDllSec
.Unlock();
2750 BOOL
CGitLogListBase::PreTranslateMessage(MSG
* pMsg
)
2752 if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='\r')
2754 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
2756 if (CRegDWORD(L
"Software\\TortoiseGit\\DiffByDoubleClickInLog", FALSE
))
2758 DiffSelectedRevWithPrevious();
2763 if (GetFocus()==GetDlgItem(IDC_LOGMSG
))
2770 else if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
== 'A' && GetAsyncKeyState(VK_CONTROL
)&0x8000)
2772 // select all entries
2773 for (int i
=0; i
<GetItemCount(); ++i
)
2774 SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
2779 if (m_hAccel
&& !bSkipAccelerator
)
2781 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
2787 //m_tooltips.RelayEvent(pMsg);
2788 return __super::PreTranslateMessage(pMsg
);
2791 void CGitLogListBase::OnNMDblclkLoglist(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2793 // a double click on an entry in the revision list has happened
2796 if (CRegDWORD(L
"Software\\TortoiseGit\\DiffByDoubleClickInLog", FALSE
))
2797 DiffSelectedRevWithPrevious();
2800 void CGitLogListBase::FetchLogAsync(void* data
)
2804 StartLoadingThread();
2807 UINT
CGitLogListBase::LogThreadEntry(LPVOID pVoid
)
2809 return ((CGitLogListBase
*)pVoid
)->LogThread();
2812 void CGitLogListBase::GetTimeRange(CTime
&oldest
, CTime
&latest
)
2815 oldest
=CTime::GetCurrentTime();
2816 latest
=CTime(1971,1,2,0,0,0);
2817 for (unsigned int i
= 0; i
< m_logEntries
.size(); ++i
)
2819 if(m_logEntries
[i
].IsEmpty())
2822 if (m_logEntries
.GetGitRevAt(i
).GetCommitterDate().GetTime() < oldest
.GetTime())
2823 oldest
= m_logEntries
.GetGitRevAt(i
).GetCommitterDate().GetTime();
2825 if (m_logEntries
.GetGitRevAt(i
).GetCommitterDate().GetTime() > latest
.GetTime())
2826 latest
= m_logEntries
.GetGitRevAt(i
).GetCommitterDate().GetTime();
2834 UINT
CGitLogListBase::LogThread()
2836 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_START
,0);
2842 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2843 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2848 std::wregex pat
;//(L"Remove", regex_constants::icase);
2849 bool bRegex
= false;
2850 if (m_bFilterWithRegex
)
2851 bRegex
= ValidateRegexp(m_sFilterText
[0] == '!' ? m_sFilterText
.Mid(1) : m_sFilterText
, pat
, false);
2853 TRACE(L
"\n===Begin===\n");
2854 //Update work copy item;
2856 if (!m_logEntries
.empty())
2858 GitRevLoglist
* pRev
= &m_logEntries
.GetGitRevAt(0);
2860 m_arShownList
.SafeAdd(pRev
);
2864 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2866 // store commit number of the last selected commit/line before the refresh or -1
2867 int lastSelectedHashNItem
= -1;
2868 if (m_lastSelectedHash
.IsEmpty())
2869 lastSelectedHashNItem
= 0;
2873 bool shouldWalk
= true;
2874 if (!g_Git
.CanParseRev(m_sRange
))
2876 // walk revisions if show all branches and there exists any ref
2877 if (!(m_ShowMask
& CGit::LOG_INFO_ALL_BRANCH
) && !(m_ShowMask
& CGit::LOG_INFO_BASIC_REFS
) && !(m_ShowMask
& CGit::LOG_INFO_LOCAL_BRANCHES
))
2882 if (g_Git
.GetRefList(list
))
2883 MessageBox(g_Git
.GetGitLastErr(L
"Could not get all refs."), L
"TortoiseGit", MB_ICONERROR
);
2891 g_Git
.m_critGitDllSec
.Lock();
2894 MessageBox(L
"Opening log failed.", L
"TortoiseGit", MB_ICONERROR
);
2895 g_Git
.m_critGitDllSec
.Unlock();
2896 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2897 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2903 [&] {git_get_log_firstcommit(m_DllGitLog
);}();
2904 total
= git_get_log_estimate_commit_count(m_DllGitLog
);
2909 MessageBox(L
"Could not get first commit.\nlibgit reports:\n" + err
, L
"TortoiseGit", MB_ICONERROR
);
2912 g_Git
.m_critGitDllSec
.Unlock();
2915 t2
= t1
= GetTickCount64();
2916 int oldprecentage
= 0;
2917 size_t oldsize
= m_logEntries
.size();
2918 std::unordered_map
<CGitHash
, std::unordered_set
<CGitHash
>> commitChildren
;
2919 while (ret
== 0 && !m_bExitThread
)
2921 g_Git
.m_critGitDllSec
.Lock();
2924 [&] { ret
= git_get_log_nextcommit(this->m_DllGitLog
, &commit
, m_ShowMask
& CGit::LOG_INFO_FOLLOW
); } ();
2928 g_Git
.m_critGitDllSec
.Unlock();
2930 MessageBox(L
"Could not get next commit.\nlibgit reports:\n" + err
, L
"TortoiseGit", MB_ICONERROR
);
2933 g_Git
.m_critGitDllSec
.Unlock();
2937 if (ret
!= -2) // other than end of revision walking
2938 MessageBox((L
"Could not get next commit.\nlibgit returns:" + std::to_wstring(ret
)).c_str(), L
"TortoiseGit", MB_ICONERROR
);
2942 if (commit
.m_ignore
== 1)
2944 git_free_commit(&commit
);
2948 //printf("%s\r\n",commit.GetSubject());
2952 CGitHash
hash(commit
.m_hash
);
2954 GitRevLoglist
* pRev
= m_LogCache
.GetCacheData(hash
);
2955 pRev
->m_GitCommit
= commit
;
2956 InterlockedExchange(&pRev
->m_IsCommitParsed
, FALSE
);
2958 char* note
= nullptr;
2959 g_Git
.m_critGitDllSec
.Lock();
2962 git_get_notes(commit
.m_hash
, ¬e
);
2966 g_Git
.m_critGitDllSec
.Unlock();
2968 MessageBox(L
"Could not get commit notes.\nlibgit reports:\n" + err
, L
"TortoiseGit", MB_ICONERROR
);
2971 g_Git
.m_critGitDllSec
.Unlock();
2975 pRev
->m_Notes
= CUnicodeUtils::GetUnicode(note
);
2980 if(!pRev
->m_IsDiffFiles
)
2982 pRev
->m_CallDiffAsync
= DiffAsync
;
2985 pRev
->ParserParentFromCommit(&commit
);
2986 if (m_ShowFilter
& FILTERSHOW_MERGEPOINTS
) // See also ShouldShowFilter()
2988 for (size_t i
= 0; i
< pRev
->m_ParentHash
.size(); ++i
)
2990 const CGitHash
&parentHash
= pRev
->m_ParentHash
[i
];
2991 auto it
= commitChildren
.find(parentHash
);
2992 if (it
== commitChildren
.end())
2993 it
= commitChildren
.insert(make_pair(parentHash
, std::unordered_set
<CGitHash
>())).first
;
2994 it
->second
.insert(pRev
->m_CommitHash
);
3003 bool visible
= true;
3004 if (HasFilterText())
3006 if(!IsMatchFilter(bRegex
,pRev
,pat
))
3009 if (visible
&& !ShouldShowFilter(pRev
, commitChildren
))
3011 this->m_critSec
.Lock();
3012 m_logEntries
.append(hash
, visible
);
3014 m_arShownList
.SafeAdd(pRev
);
3015 this->m_critSec
.Unlock();
3020 if (lastSelectedHashNItem
== -1 && hash
== m_lastSelectedHash
)
3021 lastSelectedHashNItem
= (int)m_arShownList
.size() - 1;
3023 t2
= GetTickCount64();
3025 if (t2
- t1
> 500UL || (m_logEntries
.size() - oldsize
> 100))
3028 int percent
= (int)m_logEntries
.size() * 100 / total
+ GITLOG_START
+ 1;
3031 if(percent
< GITLOG_START
)
3032 percent
= GITLOG_START
+1;
3034 oldsize
= m_logEntries
.size();
3035 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
3037 //if( percent > oldprecentage )
3039 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) percent
,0);
3040 oldprecentage
= percent
;
3043 if (lastSelectedHashNItem
>= 0)
3044 PostMessage(m_ScrollToMessage
, lastSelectedHashNItem
);
3049 g_Git
.m_critGitDllSec
.Lock();
3050 git_close_log(m_DllGitLog
);
3051 g_Git
.m_critGitDllSec
.Unlock();
3057 InterlockedExchange(&m_bThreadRunning
, FALSE
);
3062 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
3064 if (lastSelectedHashNItem
>= 0)
3065 PostMessage(m_ScrollToMessage
, lastSelectedHashNItem
);
3068 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_END
,0);
3070 InterlockedExchange(&m_bThreadRunning
, FALSE
);
3075 void CGitLogListBase::FetchRemoteList()
3077 STRING_VECTOR remoteList
;
3078 m_SingleRemote
.Empty();
3079 if (!g_Git
.GetRemoteList(remoteList
) && remoteList
.size() == 1)
3080 m_SingleRemote
= remoteList
[0];
3083 void CGitLogListBase::FetchTrackingBranchList()
3085 m_TrackingMap
.clear();
3086 for (auto it
= m_HashMap
.cbegin(); it
!= m_HashMap
.cend(); ++it
)
3088 for (const auto& ref
: it
->second
)
3091 if (CGit::GetShortName(ref
, branchName
, L
"refs/heads/"))
3093 CString pullRemote
, pullBranch
;
3094 g_Git
.GetRemoteTrackedBranch(branchName
, pullRemote
, pullBranch
);
3095 if (!pullRemote
.IsEmpty() && !pullBranch
.IsEmpty())
3096 m_TrackingMap
[branchName
] = std::make_pair(pullRemote
, pullBranch
);
3102 void CGitLogListBase::Refresh(BOOL IsCleanFilter
)
3104 SafeTerminateThread();
3106 this->SetItemCountEx(0);
3111 ShowGraphColumn((m_ShowMask
& CGit::LOG_INFO_FOLLOW
) ? false : true);
3115 git_free_mailmap(m_pMailmap
);
3116 git_read_mailmap(&m_pMailmap
);
3119 //Update branch and Tag info
3122 m_pFindDialog
->RefreshList();
3123 //Assume Thread have exited
3124 //if(!m_bThreadRunning)
3126 m_logEntries
.clear();
3130 m_sFilterText
.Empty();
3133 SafeTerminateAsyncDiffThread();
3134 m_AsynDiffListLock
.Lock();
3135 m_AsynDiffList
.clear();
3136 m_AsynDiffListLock
.Unlock();
3137 StartAsyncDiffThread();
3139 StartLoadingThread();
3143 void CGitLogListBase::StartAsyncDiffThread()
3145 if (m_AsyncThreadExit
)
3147 if (InterlockedExchange(&m_AsyncThreadRunning
, TRUE
) != FALSE
)
3149 m_DiffingThread
= AfxBeginThread(AsyncThread
, this, THREAD_PRIORITY_BELOW_NORMAL
);
3150 if (!m_DiffingThread
)
3152 InterlockedExchange(&m_AsyncThreadRunning
, FALSE
);
3153 CMessageBox::Show(GetSafeHwnd(), IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
3157 void CGitLogListBase::StartLoadingThread()
3159 if (InterlockedExchange(&m_bThreadRunning
, TRUE
) != FALSE
)
3161 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3162 InterlockedExchange(&m_bExitThread
, FALSE
);
3163 m_LoadingThread
= AfxBeginThread(LogThreadEntry
, this, THREAD_PRIORITY_LOWEST
);
3164 if (!m_LoadingThread
)
3166 InterlockedExchange(&m_bThreadRunning
, FALSE
);
3167 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3168 CMessageBox::Show(GetSafeHwnd(), IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
3172 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str
, std::wregex
& pat
, bool bMatchCase
/* = false */)
3176 std::regex_constants::syntax_option_type type
= std::regex_constants::ECMAScript
;
3178 type
|= std::regex_constants::icase
;
3179 pat
= std::wregex(regexp_str
, type
);
3182 catch (std::exception
&) {}
3185 BOOL
CGitLogListBase::IsMatchFilter(bool bRegex
, GitRevLoglist
* pRev
, std::wregex
& pat
)
3187 BOOL result
= m_sFilterText
[0] == '!' ? FALSE
: TRUE
;
3188 std::regex_constants::match_flag_type flags
= std::regex_constants::match_any
;
3191 if ((bRegex
)&&(m_bFilterWithRegex
))
3193 if (m_SelectedFilters
& LOGFILTER_BUGID
)
3195 if(this->m_bShowBugtraqColumn
)
3197 CString sBugIds
= m_ProjectProperties
.FindBugID(pRev
->GetSubjectBody());
3199 ATLTRACE(L
"bugID = \"%s\"\n", (LPCTSTR
)sBugIds
);
3200 if (std::regex_search(std::wstring(sBugIds
), pat
, flags
))
3205 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
3207 ATLTRACE(L
"messge = \"%s\"\n", (LPCTSTR
)pRev
->GetSubject());
3208 if (std::regex_search(std::wstring((LPCTSTR
)pRev
->GetSubject()), pat
, flags
))
3212 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
3214 ATLTRACE(L
"messge = \"%s\"\n", (LPCTSTR
)pRev
->GetBody());
3215 if (std::regex_search(std::wstring((LPCTSTR
)pRev
->GetBody()), pat
, flags
))
3219 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
3221 if (std::regex_search(std::wstring(pRev
->GetAuthorName()), pat
, flags
))
3224 if (std::regex_search(std::wstring(pRev
->GetCommitterName()), pat
, flags
))
3228 if (m_SelectedFilters
& LOGFILTER_EMAILS
)
3230 if (std::regex_search(std::wstring(pRev
->GetAuthorEmail()), pat
, flags
))
3233 if (std::regex_search(std::wstring(pRev
->GetCommitterEmail()), pat
, flags
))
3237 if (m_SelectedFilters
& LOGFILTER_REVS
)
3239 sRev
= pRev
->m_CommitHash
.ToString();
3240 if (std::regex_search(std::wstring((LPCTSTR
)sRev
), pat
, flags
))
3246 if (m_SelectedFilters
& LOGFILTER_NOTES
)
3248 if (std::regex_search(std::wstring(pRev
->m_Notes
), pat
, flags
))
3252 if ((m_SelectedFilters
& LOGFILTER_REFNAME
) && m_HashMap
.find(pRev
->m_CommitHash
) != m_HashMap
.cend())
3254 const STRING_VECTOR
& refs
= m_HashMap
[pRev
->m_CommitHash
];
3255 for (const auto& ref
: refs
)
3257 if (std::regex_search(std::wstring(ref
), pat
, flags
))
3262 if (m_SelectedFilters
& LOGFILTER_ANNOTATEDTAG
)
3264 if (std::regex_search(std::wstring(GetTagInfo(pRev
)), pat
, flags
))
3268 if (m_SelectedFilters
& LOGFILTER_PATHS
)
3270 CTGitPathList
* pathList
= nullptr;
3271 if( pRev
->m_IsDiffFiles
)
3272 pathList
= &pRev
->GetFiles(this);
3275 if(!pRev
->m_IsSimpleListReady
)
3276 pRev
->SafeGetSimpleList(&g_Git
);
3280 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
->GetCount(); ++cpPathIndex
)
3282 if (std::regex_search(std::wstring((LPCTSTR
)pathList
->m_paths
[cpPathIndex
].GetGitOldPathString()), pat
, flags
))
3284 if (std::regex_search(std::wstring((LPCTSTR
)pathList
->m_paths
[cpPathIndex
].GetGitPathString()), pat
, flags
))
3288 for (size_t i
= 0; i
< pRev
->m_SimpleFileList
.size(); ++i
)
3290 if (std::regex_search(std::wstring((LPCTSTR
)pRev
->m_SimpleFileList
[i
]), pat
, flags
))
3297 CString find
= m_sFilterText
;
3298 if (!m_bFilterCaseSensitively
)
3300 result
= find
[0] == '!' ? FALSE
: TRUE
;
3304 if (m_SelectedFilters
& LOGFILTER_BUGID
)
3306 if(this->m_bShowBugtraqColumn
)
3308 CString sBugIds
= m_ProjectProperties
.FindBugID(pRev
->GetSubjectBody());
3310 if (!m_bFilterCaseSensitively
)
3311 sBugIds
.MakeLower();
3312 if ((sBugIds
.Find(find
) >= 0))
3317 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
3319 CString msg
= pRev
->GetSubject();
3321 if (!m_bFilterCaseSensitively
)
3322 msg
= msg
.MakeLower();
3323 if ((msg
.Find(find
) >= 0))
3327 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
3329 CString msg
= pRev
->GetBody();
3331 if (!m_bFilterCaseSensitively
)
3332 msg
= msg
.MakeLower();
3333 if ((msg
.Find(find
) >= 0))
3337 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
3339 CString msg
= pRev
->GetAuthorName();
3340 if (!m_bFilterCaseSensitively
)
3341 msg
= msg
.MakeLower();
3342 if ((msg
.Find(find
) >= 0))
3346 if (m_SelectedFilters
& LOGFILTER_EMAILS
)
3348 CString msg
= pRev
->GetAuthorEmail();
3349 if (!m_bFilterCaseSensitively
)
3350 msg
= msg
.MakeLower();
3351 if ((msg
.Find(find
) >= 0))
3355 if (m_SelectedFilters
& LOGFILTER_NOTES
)
3357 CString msg
= pRev
->m_Notes
;
3358 if (!m_bFilterCaseSensitively
)
3359 msg
= msg
.MakeLower();
3360 if ((msg
.Find(find
) >= 0))
3364 if (m_SelectedFilters
& LOGFILTER_REVS
)
3366 sRev
= pRev
->m_CommitHash
.ToString();
3367 if ((sRev
.Find(find
) >= 0))
3371 if (m_SelectedFilters
& LOGFILTER_ANNOTATEDTAG
)
3373 CString msg
= GetTagInfo(pRev
);
3374 if (!m_bFilterCaseSensitively
)
3375 msg
= msg
.MakeLower();
3376 if ((msg
.Find(find
) >= 0))
3380 if ((m_SelectedFilters
& LOGFILTER_REFNAME
) && m_HashMap
.find(pRev
->m_CommitHash
) != m_HashMap
.cend())
3382 const STRING_VECTOR
& refs
= m_HashMap
[pRev
->m_CommitHash
];
3383 for (auto it
= refs
.cbegin(); it
!= refs
.cend(); ++it
)
3385 if (it
->Find(find
) >= 0)
3390 if (m_SelectedFilters
& LOGFILTER_PATHS
)
3392 CTGitPathList
* pathList
= nullptr;
3393 if( pRev
->m_IsDiffFiles
)
3394 pathList
= &pRev
->GetFiles(this);
3397 if(!pRev
->m_IsSimpleListReady
)
3398 pRev
->SafeGetSimpleList(&g_Git
);
3401 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
->GetCount() ; ++cpPathIndex
)
3403 CTGitPath
* cpath
= &pathList
->m_paths
[cpPathIndex
];
3404 CString path
= cpath
->GetGitOldPathString();
3405 if (!m_bFilterCaseSensitively
)
3407 if ((path
.Find(find
)>=0))
3409 path
= cpath
->GetGitPathString();
3410 if (!m_bFilterCaseSensitively
)
3412 if ((path
.Find(find
)>=0))
3416 for (size_t i
= 0; i
< pRev
->m_SimpleFileList
.size(); ++i
)
3418 CString path
= pRev
->m_SimpleFileList
[i
];
3419 if (!m_bFilterCaseSensitively
)
3421 if ((path
.Find(find
)>=0))
3425 } // else (from if (bRegex))
3429 static bool CStringStartsWith(const CString
&str
, const CString
&prefix
)
3431 return str
.Left(prefix
.GetLength()) == prefix
;
3433 bool CGitLogListBase::ShouldShowFilter(GitRevLoglist
* pRev
, const std::unordered_map
<CGitHash
, std::unordered_set
<CGitHash
>>& commitChildren
)
3435 if (m_ShowFilter
& FILTERSHOW_ANYCOMMIT
)
3438 if ((m_ShowFilter
& FILTERSHOW_REFS
) && m_HashMap
.find(pRev
->m_CommitHash
) != m_HashMap
.cend())
3441 const STRING_VECTOR
&refList
= m_HashMap
[pRev
->m_CommitHash
];
3442 for (size_t i
= 0; i
< refList
.size(); ++i
)
3444 const CString
&str
= refList
[i
];
3445 if (CStringStartsWith(str
, L
"refs/heads/"))
3447 if (m_ShowRefMask
& LOGLIST_SHOWLOCALBRANCHES
)
3450 else if (CStringStartsWith(str
, L
"refs/remotes/"))
3452 if (m_ShowRefMask
& LOGLIST_SHOWREMOTEBRANCHES
)
3455 else if (CStringStartsWith(str
, L
"refs/tags/"))
3457 if (m_ShowRefMask
& LOGLIST_SHOWTAGS
)
3460 else if (CStringStartsWith(str
, L
"refs/stash"))
3462 if (m_ShowRefMask
& LOGLIST_SHOWSTASH
)
3465 else if (CStringStartsWith(str
, L
"refs/bisect/"))
3467 if (m_ShowRefMask
& LOGLIST_SHOWBISECT
)
3471 // Keep the head too.
3472 if (pRev
->m_CommitHash
== m_HeadHash
)
3476 if (m_ShowFilter
& FILTERSHOW_MERGEPOINTS
)
3478 if (pRev
->ParentsCount() > 1)
3480 auto childrenIt
= commitChildren
.find(pRev
->m_CommitHash
);
3481 if (childrenIt
!= commitChildren
.end())
3483 const std::unordered_set
<CGitHash
> &children
= childrenIt
->second
;
3484 if (children
.size() > 1)
3491 void CGitLogListBase::ShowGraphColumn(bool bShow
)
3493 // HACK to hide graph column
3495 SetColumnWidth(0, m_ColumnManager
.GetWidth(0, false));
3497 SetColumnWidth(0, 0);
3500 CString
CGitLogListBase::GetTagInfo(GitRev
* pLogEntry
)
3502 if (m_HashMap
.find(pLogEntry
->m_CommitHash
) == m_HashMap
.end())
3506 const STRING_VECTOR
& vector
= m_HashMap
[pLogEntry
->m_CommitHash
];
3507 for (auto it
= vector
.cbegin(); it
!= vector
.cend(); ++it
)
3509 if (!CStringUtils::StartsWith((*it
), L
"refs/tags/"))
3511 if (!CStringUtils::EndsWith((*it
), L
"^{}"))
3515 cmd
.Format(L
"git.exe cat-file tag %s", (LPCTSTR
)(*it
).Left((*it
).GetLength() - (int)wcslen(L
"^{}")));
3517 if (g_Git
.Run(cmd
, &output
, nullptr, CP_UTF8
) != 0)
3523 // this assumes that in the header of the tag there is no ">" before the "tagger " header entry
3524 int pos1
= output
.Find(L
'>');
3528 if (output
[pos1
] == L
' ')
3530 int pos2
= output
.Find(L
'\n', pos1
);
3534 CString str
= output
.Mid(pos1
, pos2
- pos1
);
3535 wchar_t* pEnd
= nullptr;
3537 auto number
= wcstoumax(str
.GetBuffer(), &pEnd
, 10);
3538 if (str
.GetBuffer() == pEnd
)
3540 if (errno
== ERANGE
)
3543 output
.Delete(pos1
, pos2
- pos1
);
3544 output
.Insert(pos1
, (LPCWSTR
)CLoglistUtils::FormatDateAndTime(CTime(number
), m_DateFormat
, true, m_bRelativeTimes
));
3546 output
.Trim().AppendChar(L
'\n');
3552 void CGitLogListBase::RecalculateShownList(CThreadSafePtrArray
* pShownlist
)
3554 pShownlist
->SafeRemoveAll();
3555 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
3556 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3559 void CGitLogListBase::StartFilter()
3561 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3562 RecalculateShownList(&m_arShownList
);
3563 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3567 SetItemCountEx(m_arShownList
.size());
3568 RedrawItems(0, m_arShownList
.size());
3572 void CGitLogListBase::Clear()
3574 m_arShownList
.SafeRemoveAll();
3577 m_logEntries
.ClearAll();
3580 void CGitLogListBase::OnDestroy()
3582 SafeTerminateThread();
3583 SafeTerminateAsyncDiffThread();
3586 while(m_LogCache
.SaveCache())
3594 //if(CMessageBox::Show(nullptr, L"Cannot Save Log Cache to Disk. To retry click yes. To give up click no.", L"TortoiseGit",
3595 // MB_YESNO) == IDNO)
3599 __super::OnDestroy();
3602 LRESULT
CGitLogListBase::OnLoad(WPARAM wParam
,LPARAM
/*lParam*/)
3606 this->GetItemRect(i
,&rect
,LVIR_BOUNDS
);
3607 this->InvalidateRect(rect
);
3613 * Save column widths to the registry
3615 void CGitLogListBase::SaveColumnWidths()
3617 // HACK that graph column is always shown
3618 SetColumnWidth(0, m_ColumnManager
.GetWidth(0, false));
3620 __super::SaveColumnWidths();
3623 int CGitLogListBase::GetHeadIndex()
3625 if(m_HeadHash
.IsEmpty())
3628 for (size_t i
= 0; i
< m_arShownList
.size(); ++i
)
3630 GitRev
* pRev
= m_arShownList
.SafeGetAt(i
);
3633 if (pRev
->m_CommitHash
== m_HeadHash
)
3639 void CGitLogListBase::OnFind()
3643 m_pFindDialog
= new CFindDlg(this);
3644 m_pFindDialog
->Create(this);
3648 LRESULT
CGitLogListBase::OnScrollToMessage(WPARAM itemToSelect
, LPARAM
/*lParam*/)
3650 if (GetSelectedCount() != 0)
3653 CGitHash theSelectedHash
= m_lastSelectedHash
;
3654 SetItemState((int)itemToSelect
, LVIS_SELECTED
| LVIS_FOCUSED
, LVIS_SELECTED
| LVIS_FOCUSED
);
3655 m_lastSelectedHash
= theSelectedHash
;
3657 int countPerPage
= GetCountPerPage();
3658 EnsureVisible(max(0, (int)itemToSelect
-countPerPage
/2), FALSE
);
3659 EnsureVisible(min(GetItemCount(), (int)itemToSelect
+countPerPage
/2), FALSE
);
3660 EnsureVisible((int)itemToSelect
, FALSE
);
3664 LRESULT
CGitLogListBase::OnScrollToRef(WPARAM wParam
, LPARAM
/*lParam*/)
3666 CString
* ref
= reinterpret_cast<CString
*>(wParam
);
3667 if (!ref
|| ref
->IsEmpty())
3670 bool bShift
= (GetAsyncKeyState(VK_SHIFT
) & 0x8000) != 0;
3673 if (g_Git
.GetHash(hash
, *ref
+ L
"^{}")) // add ^{} in order to get the correct SHA-1 (especially for signed tags)
3674 MessageBox(g_Git
.GetGitLastErr(L
"Could not get hash of ref \"" + *ref
+ L
"^{}\"."), L
"TortoiseGit", MB_ICONERROR
);
3679 bool bFound
= false;
3680 int cnt
= (int)m_arShownList
.size();
3682 for (i
= 0; i
< cnt
; ++i
)
3684 GitRev
* pLogEntry
= m_arShownList
.SafeGetAt(i
);
3685 if (pLogEntry
&& pLogEntry
->m_CommitHash
== hash
)
3694 EnsureVisible(i
, FALSE
);
3697 SetItemState(GetSelectionMark(), 0, LVIS_SELECTED
);
3698 SetItemState(i
, LVIS_SELECTED
| LVIS_FOCUSED
, LVIS_SELECTED
| LVIS_FOCUSED
);
3699 SetSelectionMark(i
);
3703 GitRev
* pLogEntry
= m_arShownList
.SafeGetAt(i
);
3705 m_highlight
= pLogEntry
->m_CommitHash
;
3713 LRESULT
CGitLogListBase::OnFindDialogMessage(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
3715 ASSERT(m_pFindDialog
);
3716 bool bFound
= false;
3719 if (m_pFindDialog
->IsTerminating())
3721 // invalidate the handle identifying the dialog box.
3722 m_pFindDialog
= nullptr;
3726 int cnt
= (int)m_arShownList
.size();
3727 bool bShift
= (GetAsyncKeyState(VK_SHIFT
) & 0x8000) != 0;
3729 if(m_pFindDialog
->IsRef())
3732 str
=m_pFindDialog
->GetFindString();
3738 if (g_Git
.GetHash(hash
, str
+ L
"^{}")) // add ^{} in order to get the correct SHA-1 (especially for signed tags)
3739 MessageBox(g_Git
.GetGitLastErr(L
"Could not get hash of ref \"" + str
+ L
"^{}\"."), L
"TortoiseGit", MB_ICONERROR
);
3744 for (i
= 0; i
< cnt
; ++i
)
3746 GitRev
* pLogEntry
= m_arShownList
.SafeGetAt(i
);
3747 if(pLogEntry
&& pLogEntry
->m_CommitHash
== hash
)
3756 m_pFindDialog
->FlashWindowEx(FLASHW_ALL
, 2, 100);
3761 if (m_pFindDialog
->FindNext() && !bFound
)
3763 //read data from dialog
3764 CString findText
= m_pFindDialog
->GetFindString();
3765 bool bMatchCase
= (m_pFindDialog
->MatchCase() == TRUE
);
3768 bool bRegex
= false;
3769 if (m_pFindDialog
->Regex())
3770 bRegex
= ValidateRegexp(findText
, pat
, bMatchCase
);
3772 std::regex_constants::match_flag_type flags
= std::regex_constants::match_not_null
;
3774 for (i
= m_nSearchIndex
+ 1; ; ++i
)
3779 m_pFindDialog
->FlashWindowEx(FLASHW_ALL
, 2, 100);
3781 if (m_nSearchIndex
>= 0)
3783 if (i
== m_nSearchIndex
)
3785 ::MessageBeep(0xFFFFFFFF);
3786 m_pFindDialog
->FlashWindowEx(FLASHW_ALL
, 3, 100);
3791 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(i
);
3794 str
+=pLogEntry
->m_CommitHash
.ToString();
3797 auto refList
= m_HashMap
.find(pLogEntry
->m_CommitHash
);
3798 if (refList
!= m_HashMap
.cend())
3800 for (const auto& ref
: (*refList
).second
)
3807 str
+=pLogEntry
->GetAuthorEmail();
3809 str
+=pLogEntry
->GetAuthorName();
3811 str
+=pLogEntry
->GetBody();
3813 str
+=pLogEntry
->GetCommitterEmail();
3815 str
+=pLogEntry
->GetCommitterName();
3817 str
+=pLogEntry
->GetSubject();
3819 str
+=pLogEntry
->m_Notes
;
3821 str
+=GetTagInfo(pLogEntry
);
3825 /*Because changed files list is loaded on demand when gui show,
3826 files will empty when files have not fetched.
3828 we can add it back by using one-way diff(with outnumber changed and rename detect.
3829 here just need changed filename list. one-way is much quicker.
3831 if(pLogEntry
->m_IsFull
)
3833 for (int j
= 0; j
< pLogEntry
->GetFiles(this).GetCount(); ++j
)
3835 str
+= pLogEntry
->GetFiles(this)[j
].GetWinPath();
3837 str
+= pLogEntry
->GetFiles(this)[j
].GetGitOldPathString();
3843 if(!pLogEntry
->m_IsSimpleListReady
)
3844 pLogEntry
->SafeGetSimpleList(&g_Git
);
3846 for (size_t j
= 0; j
< pLogEntry
->m_SimpleFileList
.size(); ++j
)
3848 str
+= pLogEntry
->m_SimpleFileList
[j
];
3855 if (std::regex_search(std::wstring(str
), pat
, flags
))
3865 if (str
.Find(findText
) >= 0)
3874 msg
= msg
.MakeLower();
3875 CString find
= findText
.MakeLower();
3876 if (msg
.Find(find
) >= 0)
3883 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; ++i)
3885 } // if(m_pFindDialog->FindNext())
3886 //UpdateLogInfoLabel();
3891 EnsureVisible(i
, FALSE
);
3894 SetItemState(GetSelectionMark(), 0, LVIS_SELECTED
);
3895 SetItemState(i
, LVIS_SELECTED
| LVIS_FOCUSED
, LVIS_SELECTED
| LVIS_FOCUSED
);
3896 SetSelectionMark(i
);
3900 GitRev
* pLogEntry
= m_arShownList
.SafeGetAt(i
);
3902 m_highlight
= pLogEntry
->m_CommitHash
;
3905 //FillLogMessageCtrl();
3912 INT_PTR
CGitLogListBase::OnToolHitTest(CPoint point
, TOOLINFO
* pTI
) const
3914 LVHITTESTINFO lvhitTestInfo
;
3916 lvhitTestInfo
.pt
= point
;
3918 int nItem
= ListView_SubItemHitTest(m_hWnd
, &lvhitTestInfo
);
3919 int nSubItem
= lvhitTestInfo
.iSubItem
;
3921 UINT nFlags
= lvhitTestInfo
.flags
;
3923 // nFlags is 0 if the SubItemHitTest fails
3924 // Therefore, 0 & <anything> will equal false
3925 if (nFlags
& LVHT_ONITEM
)
3927 // Get the client area occupied by this control
3929 GetClientRect(&rcClient
);
3931 // Fill in the TOOLINFO structure
3933 pTI
->uId
= (UINT
)((nItem
<<10)+(nSubItem
&0x3ff)+1);
3934 pTI
->lpszText
= LPSTR_TEXTCALLBACK
;
3935 pTI
->rect
= rcClient
;
3937 return pTI
->uId
; // By returning a unique value per listItem,
3938 // we ensure that when the mouse moves over another list item,
3939 // the tooltip will change
3943 // Otherwise, we aren't interested, so let the message propagate
3948 BOOL
CGitLogListBase::OnToolTipText(UINT
/*id*/, NMHDR
* pNMHDR
, LRESULT
* pResult
)
3950 TOOLTIPTEXTA
* pTTTA
= (TOOLTIPTEXTA
*)pNMHDR
;
3951 TOOLTIPTEXTW
* pTTTW
= (TOOLTIPTEXTW
*)pNMHDR
;
3955 // Ignore messages from the built in tooltip, we are processing them internally
3956 if ((pNMHDR
->idFrom
== (UINT_PTR
)m_hWnd
) &&
3957 (((pNMHDR
->code
== TTN_NEEDTEXTA
) && (pTTTA
->uFlags
& TTF_IDISHWND
)) ||
3958 ((pNMHDR
->code
== TTN_NEEDTEXTW
) && (pTTTW
->uFlags
& TTF_IDISHWND
))))
3961 // Get the mouse position
3962 const MSG
* pMessage
= GetCurrentMessage();
3966 ScreenToClient(&pt
);
3968 // Check if the point falls onto a list item
3969 LVHITTESTINFO lvhitTestInfo
;
3970 lvhitTestInfo
.pt
= pt
;
3972 int nItem
= SubItemHitTest(&lvhitTestInfo
);
3974 if (lvhitTestInfo
.flags
& LVHT_ONITEM
)
3976 // Get branch description first
3978 if (lvhitTestInfo
.iSubItem
== LOGLIST_MESSAGE
)
3981 CGit::REF_TYPE type
= CGit::REF_TYPE::LOCAL_BRANCH
;
3982 if (IsMouseOnRefLabel(m_arShownList
.SafeGetAt(nItem
), lvhitTestInfo
.pt
, type
, &branch
))
3984 MAP_STRING_STRING descriptions
;
3985 g_Git
.GetBranchDescriptions(descriptions
);
3986 if (descriptions
.find(branch
) != descriptions
.cend())
3988 strTipText
.LoadString(IDS_DESCRIPTION
);
3989 strTipText
+= L
":\n";
3990 strTipText
+= descriptions
[branch
];
3995 bool followMousePos
= false;
3996 if (!strTipText
.IsEmpty())
3997 followMousePos
= true;
3999 strTipText
= GetToolTipText(nItem
, lvhitTestInfo
.iSubItem
);
4000 if (strTipText
.IsEmpty())
4003 // we want multiline tooltips
4004 ::SendMessage(pNMHDR
->hwndFrom
, TTM_SETMAXTIPWIDTH
, 0, SHRT_MAX
);
4006 wcscpy_s(m_wszTip
, strTipText
);
4007 // handle Unicode as well as non-Unicode requests
4008 if (pNMHDR
->code
== TTN_NEEDTEXTA
)
4010 pTTTA
->hinst
= nullptr;
4011 pTTTA
->lpszText
= m_szTip
;
4012 ::WideCharToMultiByte(CP_ACP
, 0, m_wszTip
, -1, m_szTip
, 8192, nullptr, nullptr);
4016 pTTTW
->hinst
= nullptr;
4017 pTTTW
->lpszText
= m_wszTip
;
4021 GetSubItemRect(nItem
, lvhitTestInfo
.iSubItem
, LVIR_LABEL
, rect
);
4023 rect
.MoveToXY(pt
.x
, pt
.y
+ 18); // 18: to act like a normal tooltip
4024 ClientToScreen(rect
);
4025 ::SetWindowPos(pNMHDR
->hwndFrom
, HWND_TOP
, rect
.left
, rect
.top
, 0, 0, SWP_NOACTIVATE
|SWP_NOSIZE
|SWP_NOOWNERZORDER
);
4027 return TRUE
; // We found a tool tip,
4028 // tell the framework this message has been handled
4031 return FALSE
; // We didn't handle the message,
4032 // let the framework continue propagating the message
4035 CString
CGitLogListBase::GetToolTipText(int nItem
, int nSubItem
)
4037 if (nSubItem
== LOGLIST_MESSAGE
&& !m_bTagsBranchesOnRightSide
)
4039 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(nItem
);
4040 if (pLogEntry
== nullptr)
4042 if (m_HashMap
.find(pLogEntry
->m_CommitHash
) == m_HashMap
.cend() && (m_superProjectHash
.IsEmpty() || pLogEntry
->m_CommitHash
!= m_superProjectHash
))
4044 return pLogEntry
->GetSubject();
4046 else if (nSubItem
== LOGLIST_DATE
&& m_bRelativeTimes
)
4048 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(nItem
);
4049 if (pLogEntry
== nullptr)
4051 return CLoglistUtils::FormatDateAndTime(pLogEntry
->GetAuthorDate(), m_DateFormat
, true, false);
4053 else if (nSubItem
== LOGLIST_COMMIT_DATE
&& m_bRelativeTimes
)
4055 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(nItem
);
4056 if (pLogEntry
== nullptr)
4058 return CLoglistUtils::FormatDateAndTime(pLogEntry
->GetCommitterDate(), m_DateFormat
, true, false);
4060 else if (nSubItem
== LOGLIST_ACTION
)
4062 GitRevLoglist
* pLogEntry
= m_arShownList
.SafeGetAt(nItem
);
4063 if (pLogEntry
== nullptr)
4066 if (!pLogEntry
->m_IsDiffFiles
)
4067 return CString(MAKEINTRESOURCE(IDS_PROC_LOG_FETCHINGFILES
));
4069 int actions
= pLogEntry
->GetAction(this);
4070 CString sToolTipText
;
4073 if (actions
& CTGitPath::LOGACTIONS_MODIFIED
)
4074 actionText
+= CTGitPath::GetActionName(CTGitPath::LOGACTIONS_MODIFIED
);
4076 if (actions
& CTGitPath::LOGACTIONS_ADDED
)
4078 if (!actionText
.IsEmpty())
4079 actionText
+= L
"\r\n";
4080 actionText
+= CTGitPath::GetActionName(CTGitPath::LOGACTIONS_ADDED
);
4083 if (actions
& CTGitPath::LOGACTIONS_DELETED
)
4085 if (!actionText
.IsEmpty())
4086 actionText
+= L
"\r\n";
4087 actionText
+= CTGitPath::GetActionName(CTGitPath::LOGACTIONS_DELETED
);
4090 if (actions
& CTGitPath::LOGACTIONS_REPLACED
)
4092 if (!actionText
.IsEmpty())
4093 actionText
+= L
"\r\n";
4094 actionText
+= CTGitPath::GetActionName(CTGitPath::LOGACTIONS_REPLACED
);
4097 if (actions
& CTGitPath::LOGACTIONS_UNMERGED
)
4099 if (!actionText
.IsEmpty())
4100 actionText
+= L
"\r\n";
4101 actionText
+= CTGitPath::GetActionName(CTGitPath::LOGACTIONS_UNMERGED
);
4104 if (!actionText
.IsEmpty())
4106 CString
sTitle(MAKEINTRESOURCE(IDS_LOG_ACTIONS
));
4107 sToolTipText
= sTitle
+ L
":\r\n" + actionText
;
4109 return sToolTipText
;
4114 bool CGitLogListBase::IsMouseOnRefLabelFromPopupMenu(const GitRevLoglist
* pLogEntry
, const CPoint
& point
, CGit::REF_TYPE
& type
, CString
* pShortname
/*nullptr*/, size_t* pIndex
/*nullptr*/)
4117 ScreenToClient(&pt
);
4118 return IsMouseOnRefLabel(pLogEntry
, pt
, type
, pShortname
, pIndex
);
4121 bool CGitLogListBase::IsMouseOnRefLabel(const GitRevLoglist
* pLogEntry
, const POINT
& pt
, CGit::REF_TYPE
& type
, CString
* pShortname
/*nullptr*/, size_t* pIndex
/*nullptr*/)
4126 auto refList
= m_HashMap
.find(pLogEntry
->m_CommitHash
);
4127 if (refList
== m_HashMap
.cend())
4130 for (size_t i
= 0; i
< m_HashMap
[pLogEntry
->m_CommitHash
].size(); ++i
)
4132 const auto labelpos
= m_RefLabelPosMap
.find(m_HashMap
[pLogEntry
->m_CommitHash
][i
]);
4133 if (labelpos
== m_RefLabelPosMap
.cend() || !labelpos
->second
.PtInRect(pt
))
4136 CGit::REF_TYPE foundType
;
4138 *pShortname
= CGit::GetShortName(m_HashMap
[pLogEntry
->m_CommitHash
][i
], &foundType
);
4140 CGit::GetShortName(m_HashMap
[pLogEntry
->m_CommitHash
][i
], &foundType
);
4141 if (foundType
!= type
&& type
!= CGit::REF_TYPE::UNKNOWN
)
4152 void CGitLogListBase::OnBeginDrag(NMHDR
* /*pnmhdr*/, LRESULT
* pResult
)
4156 if (!m_bDragndropEnabled
|| GetSelectedCount() == 0 || !IsSelectionContinuous())
4161 m_nDropMarkerLast
= -1;
4162 m_nDropMarkerLastHot
= GetHotItem();
4166 void CGitLogListBase::OnMouseMove(UINT nFlags
, CPoint point
)
4168 __super::OnMouseMove(nFlags
, point
);
4173 CPoint dropPoint
= point
;
4174 ClientToScreen(&dropPoint
);
4176 if (WindowFromPoint(dropPoint
) != this)
4178 SetCursor(LoadCursor(nullptr, IDC_NO
));
4180 DrawDropInsertMarker(m_nDropIndex
);
4184 SetCursor(LoadCursor(nullptr, IDC_ARROW
));
4185 ScreenToClient(&dropPoint
);
4188 m_nDropIndex
= HitTest(dropPoint
);
4190 if (m_nDropIndex
== -1) // might be last item, allow to move past last item
4193 m_nDropIndex
= HitTest(dropPoint
);
4194 if (m_nDropIndex
!= -1)
4195 m_nDropIndex
= GetItemCount();
4198 POSITION pos
= GetFirstSelectedItemPosition();
4199 int first
= GetNextSelectedItem(pos
);
4202 last
= GetNextSelectedItem(pos
);
4203 if (m_nDropIndex
== -1 || (m_nDropIndex
>= first
&& m_nDropIndex
- 1 <= last
))
4205 SetCursor(LoadCursor(nullptr, IDC_NO
));
4209 // handle auto scrolling
4210 int hotItem
= GetHotItem();
4211 int topindex
= GetTopIndex();
4212 if (hotItem
== topindex
&& hotItem
!= 0)
4213 EnsureVisible(hotItem
- 1, FALSE
);
4214 else if (hotItem
>= topindex
+ GetCountPerPage() - 1 && hotItem
+ 1 < GetItemCount())
4215 EnsureVisible(hotItem
+ 1, FALSE
);
4217 DrawDropInsertMarker(m_nDropIndex
);
4220 void CGitLogListBase::OnLButtonUp(UINT nFlags
, CPoint point
)
4225 SetCursor(LoadCursor(nullptr, IDC_HAND
));
4226 m_bDragging
= FALSE
;
4229 GetItemRect(m_nDropMarkerLast
, &rect
, 0);
4230 rect
.bottom
= rect
.top
+ 2;
4232 InvalidateRect(&rect
, 0);
4235 ClientToScreen(&pt
);
4236 if (WindowFromPoint(pt
) == this && m_nDropIndex
!= -1)
4237 GetParent()->PostMessage(MSG_COMMITS_REORDERED
, m_nDropIndex
, 0);
4240 __super::OnLButtonUp(nFlags
, point
);
4243 void CGitLogListBase::DrawDropInsertMarker(int nIndex
)
4245 if (m_nDropMarkerLast
!= nIndex
)
4248 if (GetItemRect(m_nDropMarkerLast
, &rect
, 0))
4250 rect
.bottom
= rect
.top
+ 2;
4252 InvalidateRect(&rect
, 0);
4254 else if (m_nDropMarkerLast
== GetItemCount())
4255 DrawDropInsertMarkerLine(m_nDropMarkerLast
); // double painting = removal
4256 m_nDropMarkerLast
= nIndex
;
4261 DrawDropInsertMarkerLine(m_nDropMarkerLast
);
4263 else if (m_nDropMarkerLastHot
!= GetHotItem())
4265 m_nDropMarkerLastHot
= GetHotItem();
4266 m_nDropMarkerLast
= -1;
4270 void CGitLogListBase::DrawDropInsertMarkerLine(int nIndex
)
4272 CBrush
* pBrush
= CDC::GetHalftoneBrush();
4276 if (nIndex
< GetItemCount())
4278 GetItemRect(nIndex
, &rect
, 0);
4279 rect
.bottom
= rect
.top
+ 2;
4284 GetItemRect(nIndex
- 1, &rect
, 0);
4285 rect
.top
= rect
.bottom
- 2;
4289 CBrush
* pBrushOld
= pDC
->SelectObject(pBrush
);
4290 pDC
->PatBlt(rect
.left
, rect
.top
, rect
.Width(), rect
.Height(), PATINVERT
);
4291 pDC
->SelectObject(pBrushOld
);
4296 ULONG
CGitLogListBase::GetGestureStatus(CPoint
/*ptTouch*/)