1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2014 - TortoiseGit
4 // Copyright (C) 2005-2007 Marco Costalba
5 // Copyright (C) 2011-2013 - Sven Strickroth <email@cs-ware.de>
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software Foundation,
19 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 // GitLogList.cpp : implementation file
25 #include "GitLogListBase.h"
30 #include "GitProgressDlg.h"
31 #include "ProgressDlg.h"
33 #include "MessageBox.h"
35 #include "LoglistUtils.h"
36 #include "PathUtils.h"
37 #include "StringUtils.h"
38 #include "UnicodeUtils.h"
41 #include "GitStatus.h"
42 #include "..\\TortoiseShell\\Resource.h"
46 const UINT
CGitLogListBase::m_FindDialogMessage
= RegisterWindowMessage(FINDMSGSTRING
);
47 const UINT
CGitLogListBase::m_ScrollToMessage
= RegisterWindowMessage(_T("TORTOISEGIT_LOG_SCROLLTO"));
48 const UINT
CGitLogListBase::m_RebaseActionMessage
= RegisterWindowMessage(_T("TORTOISEGIT_LOG_REBASEACTION"));
50 IMPLEMENT_DYNAMIC(CGitLogListBase
, CHintListCtrl
)
52 CGitLogListBase::CGitLogListBase():CHintListCtrl()
53 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
55 ,m_bNoDispUpdates(FALSE
)
56 , m_bThreadRunning(FALSE
)
57 , m_bStrictStopped(false)
58 , m_pStoreSelection(NULL
)
59 , m_SelectedFilters(LOGFILTER_ALL
)
60 , m_ShowFilter(FILTERSHOW_ALL
)
62 , m_logEntries(&m_LogCache
)
64 , m_ColumnManager(this)
65 , m_dwDefaultColumns(0)
66 , m_arShownList(&m_critSec
)
68 , m_bNoHightlightHead(FALSE
)
69 , m_ShowRefMask(LOGLIST_SHOWALLREFS
)
71 // use the default GUI font, create a copy of it and
72 // change the copy to BOLD (leave the rest of the font
74 HFONT hFont
= (HFONT
)GetStockObject(DEFAULT_GUI_FONT
);
76 GetObject(hFont
, sizeof(LOGFONT
), &lf
);
77 lf
.lfWeight
= FW_BOLD
;
78 m_boldFont
= CreateFontIndirect(&lf
);
80 m_bShowBugtraqColumn
=false;
82 m_IsIDReplaceAction
=FALSE
;
84 this->m_critSec
.Init();
85 m_critSec_AsyncDiff
.Init();
86 m_wcRev
.m_CommitHash
.Empty();
87 m_wcRev
.GetSubject() = CString(MAKEINTRESOURCE(IDS_LOG_WORKINGDIRCHANGES
));
88 m_wcRev
.m_ParentHash
.clear();
89 m_wcRev
.m_Mark
=_T('-');
90 m_wcRev
.m_IsUpdateing
=FALSE
;
91 m_wcRev
.m_IsFull
= TRUE
;
93 m_hModifiedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
94 m_hReplacedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
95 m_hAddedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
96 m_hDeletedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
97 m_hFetchIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONFETCHING
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
99 m_bFilterWithRegex
= !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE
);
105 m_LoadingThread
= NULL
;
107 InterlockedExchange(&m_bExitThread
,FALSE
);
108 m_IsOldFirst
= FALSE
;
109 m_IsRebaseReplaceGraph
= FALSE
;
111 for (int i
= 0; i
< Lanes::COLORS_NUM
; ++i
)
113 m_LineColors
[i
] = m_Colors
.GetColor((CColors::Colors
)(CColors::BranchLine1
+i
));
115 // get short/long datetime setting from registry
116 DWORD RegUseShortDateFormat
= CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE
);
117 if ( RegUseShortDateFormat
)
119 m_DateFormat
= DATE_SHORTDATE
;
123 m_DateFormat
= DATE_LONGDATE
;
125 // get relative time display setting from registry
126 DWORD regRelativeTimes
= CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE
);
127 m_bRelativeTimes
= (regRelativeTimes
!= 0);
128 m_ContextMenuMask
= 0xFFFFFFFFFFFFFFFF;
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
=_T("log");
140 m_bTagsBranchesOnRightSide
= !!CRegDWORD(_T("Software\\TortoiseGit\\DrawTagsBranchesOnRightSide"), FALSE
);
141 m_bSymbolizeRefNames
= !!CRegDWORD(_T("Software\\TortoiseGit\\SymbolizeRefNames"), FALSE
);
142 m_bIncludeBoundaryCommits
= !!CRegDWORD(_T("Software\\TortoiseGit\\LogIncludeBoundaryCommits"), FALSE
);
144 m_LineWidth
= max(1, CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Graph\\LogLineWidth"), 2));
145 m_NodeSize
= max(1, CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Graph\\LogNodeSize"), 10));
147 m_AsyncThreadExit
= FALSE
;
148 m_AsyncDiffEvent
= ::CreateEvent(NULL
,FALSE
,TRUE
,NULL
);
149 m_AsynDiffListLock
.Init();
151 m_DiffingThread
= AfxBeginThread(AsyncThread
, this, THREAD_PRIORITY_BELOW_NORMAL
);
152 if (m_DiffingThread
==NULL
)
154 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
160 int CGitLogListBase::AsyncDiffThread()
162 m_AsyncThreadExited
= false;
163 while(!m_AsyncThreadExit
)
165 ::WaitForSingleObject(m_AsyncDiffEvent
, INFINITE
);
168 while(!m_AsyncThreadExit
&& !m_AsynDiffList
.empty())
170 m_AsynDiffListLock
.Lock();
171 pRev
= m_AsynDiffList
.back();
172 m_AsynDiffList
.pop_back();
173 m_AsynDiffListLock
.Unlock();
175 if( pRev
->m_CommitHash
.IsEmpty() )
177 if(pRev
->m_IsDiffFiles
)
180 pRev
->GetFiles(this).Clear();
181 pRev
->m_ParentHash
.clear();
182 pRev
->m_ParentHash
.push_back(m_HeadHash
);
183 if(g_Git
.IsInitRepos())
185 if (g_Git
.GetInitAddList(pRev
->GetFiles(this)))
186 CMessageBox::Show(NULL
, _T("Run ls-files failed!"), _T("TortoiseGit"), MB_OK
| MB_ICONERROR
);
191 g_Git
.GetCommitDiffList(pRev
->m_CommitHash
.ToString(),this->m_HeadHash
.ToString(), pRev
->GetFiles(this));
194 int *action
= &dummyAction
;
195 SafeGetAction(pRev
, &action
);
198 for (int j
= 0; j
< pRev
->GetFiles(this).GetCount(); ++j
)
199 *action
|= pRev
->GetFiles(this)[j
].m_Action
;
202 if (pRev
->GetUnRevFiles().FillUnRev(CTGitPath::LOGACTIONS_UNVER
, nullptr, &err
))
204 CMessageBox::Show(NULL
, _T("Failed to get UnRev file list\n") + err
, _T("TortoiseGit"), MB_OK
);
208 InterlockedExchange(&pRev
->m_IsDiffFiles
, TRUE
);
209 InterlockedExchange(&pRev
->m_IsFull
, TRUE
);
211 pRev
->GetBody().Format(IDS_FILESCHANGES
, pRev
->GetFiles(this).GetCount());
212 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)0,0);
213 this->GetParent()->PostMessage(WM_COMMAND
, MSG_FETCHED_DIFF
, 0);
216 m_critSec_AsyncDiff
.Lock();
217 int ret
= pRev
->CheckAndDiff();
218 m_critSec_AsyncDiff
.Unlock();
220 { // fetch change file list
221 for (int i
= GetTopIndex(); !m_AsyncThreadExit
&& i
<= GetTopIndex() + GetCountPerPage(); ++i
)
223 if(i
< m_arShownList
.GetCount())
225 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(i
);
226 if(data
->m_CommitHash
== pRev
->m_CommitHash
)
228 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)i
,0);
234 if(!m_AsyncThreadExit
&& GetSelectedCount() == 1)
236 POSITION pos
= GetFirstSelectedItemPosition();
237 int nItem
= GetNextSelectedItem(pos
);
241 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(nItem
);
243 if(data
->m_CommitHash
== pRev
->m_CommitHash
)
245 this->GetParent()->PostMessage(WM_COMMAND
, MSG_FETCHED_DIFF
, 0);
252 m_AsyncThreadExited
= true;
255 void CGitLogListBase::hideFromContextMenu(unsigned __int64 hideMask
, bool exclusivelyShow
)
259 m_ContextMenuMask
&= hideMask
;
263 m_ContextMenuMask
&= ~hideMask
;
267 CGitLogListBase::~CGitLogListBase()
269 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
270 this->m_arShownList
.SafeRemoveAll();
272 DestroyIcon(m_hModifiedIcon
);
273 DestroyIcon(m_hReplacedIcon
);
274 DestroyIcon(m_hAddedIcon
);
275 DestroyIcon(m_hDeletedIcon
);
276 m_logEntries
.ClearAll();
279 DeleteObject(m_boldFont
);
281 if ( m_pStoreSelection
)
283 delete m_pStoreSelection
;
284 m_pStoreSelection
= NULL
;
287 SafeTerminateThread();
288 SafeTerminateAsyncDiffThread();
291 CloseHandle(m_AsyncDiffEvent
);
295 BEGIN_MESSAGE_MAP(CGitLogListBase
, CHintListCtrl
)
296 ON_REGISTERED_MESSAGE(m_FindDialogMessage
, OnFindDialogMessage
)
297 ON_REGISTERED_MESSAGE(m_ScrollToMessage
, OnScrollToMessage
)
298 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW
, OnNMCustomdrawLoglist
)
299 ON_NOTIFY_REFLECT(LVN_GETDISPINFO
, OnLvnGetdispinfoLoglist
)
301 ON_NOTIFY_REFLECT(NM_DBLCLK
, OnNMDblclkLoglist
)
302 ON_NOTIFY_REFLECT(LVN_ODFINDITEM
,OnLvnOdfinditemLoglist
)
305 ON_MESSAGE(MSG_LOADED
,OnLoad
)
307 ON_WM_MEASUREITEM_REFLECT()
308 ON_NOTIFY(HDN_BEGINTRACKA
, 0, OnHdnBegintrack
)
309 ON_NOTIFY(HDN_BEGINTRACKW
, 0, OnHdnBegintrack
)
310 ON_NOTIFY(HDN_ITEMCHANGINGA
, 0, OnHdnItemchanging
)
311 ON_NOTIFY(HDN_ITEMCHANGINGW
, 0, OnHdnItemchanging
)
312 ON_NOTIFY(HDN_ENDTRACK
, 0, OnColumnResized
)
313 ON_NOTIFY(HDN_ENDDRAG
, 0, OnColumnMoved
)
316 void CGitLogListBase::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct
)
318 //if (m_nRowHeight>0)
320 lpMeasureItemStruct
->itemHeight
= 50;
324 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct
)
327 return CHintListCtrl::OnCreate(lpCreateStruct
);
330 void CGitLogListBase::PreSubclassWindow()
332 SetExtendedStyle(LVS_EX_FULLROWSELECT
| LVS_EX_SUBITEMIMAGES
);
333 // load the icons for the action columns
334 // m_Theme.Open(m_hWnd, L"ListView");
335 SetWindowTheme(m_hWnd
, L
"Explorer", NULL
);
336 CHintListCtrl::PreSubclassWindow();
339 CString
CGitLogListBase::GetRebaseActionName(int action
)
341 if (action
& LOGACTIONS_REBASE_EDIT
)
342 return MAKEINTRESOURCE(IDS_PATHACTIONS_EDIT
);
343 if (action
& LOGACTIONS_REBASE_SQUASH
)
344 return MAKEINTRESOURCE(IDS_PATHACTIONS_SQUASH
);
345 if (action
& LOGACTIONS_REBASE_PICK
)
346 return MAKEINTRESOURCE(IDS_PATHACTIONS_PICK
);
347 if (action
& LOGACTIONS_REBASE_SKIP
)
348 return MAKEINTRESOURCE(IDS_PATHACTIONS_SKIP
);
350 return MAKEINTRESOURCE(IDS_PATHACTIONS_UNKNOWN
);
353 void CGitLogListBase::InsertGitColumn()
357 CRegDWORD
regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE
);
358 DWORD exStyle
= LVS_EX_HEADERDRAGDROP
| LVS_EX_DOUBLEBUFFER
| LVS_EX_INFOTIP
| LVS_EX_SUBITEMIMAGES
;
359 if (DWORD(regFullRowSelect
))
360 exStyle
|= LVS_EX_FULLROWSELECT
;
361 SetExtendedStyle(exStyle
);
363 // only load properties if we have a repository
364 if (GitAdminDir().HasAdminDir(g_Git
.m_CurrentDir
) || GitAdminDir().IsBareRepo(g_Git
.m_CurrentDir
))
365 UpdateProjectProperties();
367 static UINT normal
[] =
379 IDS_LOG_COMMIT_EMAIL
,
402 m_dwDefaultColumns
= GIT_LOG_GRAPH
|GIT_LOG_ACTIONS
|GIT_LOG_MESSAGE
|GIT_LOG_AUTHOR
|GIT_LOG_DATE
;
404 DWORD hideColumns
= 0;
405 if(this->m_IsRebaseReplaceGraph
)
407 hideColumns
|= GIT_LOG_GRAPH
;
408 m_dwDefaultColumns
|= GIT_LOG_REBASE
;
412 hideColumns
|= GIT_LOG_REBASE
;
415 if(this->m_IsIDReplaceAction
)
417 hideColumns
|= GIT_LOG_ACTIONS
;
418 m_dwDefaultColumns
|= GIT_LOG_ID
;
419 m_dwDefaultColumns
|= GIT_LOG_HASH
;
423 hideColumns
|= GIT_LOG_ID
;
425 if(this->m_bShowBugtraqColumn
)
427 m_dwDefaultColumns
|= GIT_LOGLIST_BUG
;
431 hideColumns
|= GIT_LOGLIST_BUG
;
433 if (CTGitPath(g_Git
.m_CurrentDir
).HasGitSVNDir())
434 m_dwDefaultColumns
|= GIT_LOGLIST_SVNREV
;
436 hideColumns
|= GIT_LOGLIST_SVNREV
;
439 m_ColumnManager
.SetNames(normal
, _countof(normal
));
440 m_ColumnManager
.ReadSettings(m_dwDefaultColumns
, hideColumns
, m_ColumnRegKey
+_T("loglist"), _countof(normal
), with
);
446 * Resizes all columns in a list control to values in registry.
448 void CGitLogListBase::ResizeAllListCtrlCols()
450 // column max and min widths to allow
451 static const int nMinimumWidth
= 10;
452 static const int nMaximumWidth
= 1000;
453 CHeaderCtrl
* pHdrCtrl
= (CHeaderCtrl
*)(GetDlgItem(0));
456 int numcols
= pHdrCtrl
->GetItemCount();
457 for (int col
= 0; col
< numcols
; ++col
)
459 // get width for this col last time from registry
461 regentry
.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey
, col
);
462 CRegDWORD
regwidth(regentry
, 0);
466 // no saved value, setup sensible defaults
467 if (col
== this->LOGLIST_MESSAGE
)
469 cx
= LOGLIST_MESSAGE_MIN
;
473 cx
= ICONITEMBORDER
+16*4;
476 if (cx
< nMinimumWidth
)
480 else if (cx
> nMaximumWidth
)
485 SetColumnWidth(col
, cx
);
492 void CGitLogListBase::FillBackGround(HDC hdc
, DWORD_PTR Index
, CRect
&rect
)
495 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
496 rItem
.mask
= LVIF_STATE
;
497 rItem
.iItem
= (int)Index
;
498 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
501 GitRev
* pLogEntry
= (GitRev
*)m_arShownList
.SafeGetAt(Index
);
504 if (!(rItem
.state
& LVIS_SELECTED
))
506 int action
= pLogEntry
->GetRebaseAction();
507 if (action
& LOGACTIONS_REBASE_SQUASH
)
508 brush
= ::CreateSolidBrush(RGB(156,156,156));
509 else if (action
& LOGACTIONS_REBASE_EDIT
)
510 brush
= ::CreateSolidBrush(RGB(200,200,128));
512 else if (!(IsAppThemed() && SysInfo::Instance().IsVistaOrLater()))
514 if (rItem
.state
& LVIS_SELECTED
)
516 if (::GetFocus() == m_hWnd
)
517 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT
));
519 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE
));
524 ::FillRect(hdc
, &rect
, brush
);
525 ::DeleteObject(brush
);
529 void DrawTrackingRoundRect(HDC hdc
, CRect rect
, HBRUSH brush
, COLORREF darkColor
)
531 POINT point
= { 4, 4 };
533 rt2
.DeflateRect(1, 1);
534 rt2
.OffsetRect(2, 2);
536 HPEN nullPen
= ::CreatePen(PS_NULL
, 0, 0);
537 HPEN oldpen
= (HPEN
)::SelectObject(hdc
, nullPen
);
538 HBRUSH darkBrush
= (HBRUSH
)::CreateSolidBrush(darkColor
);
539 HBRUSH oldbrush
= (HBRUSH
)::SelectObject(hdc
, darkBrush
);
540 ::RoundRect(hdc
, rt2
.left
, rt2
.top
, rt2
.right
, rt2
.bottom
, point
.x
, point
.y
);
542 ::SelectObject(hdc
, brush
);
543 rt2
.OffsetRect(-2, -2);
544 ::RoundRect(hdc
, rt2
.left
, rt2
.top
, rt2
.right
, rt2
.bottom
, point
.x
, point
.y
);
545 ::SelectObject(hdc
, oldbrush
);
546 ::SelectObject(hdc
, oldpen
);
547 ::DeleteObject(nullPen
);
548 ::DeleteObject(darkBrush
);
551 void DrawLightning(HDC hdc
, CRect rect
, COLORREF color
, int bold
)
553 HPEN pen
= ::CreatePen(PS_SOLID
, bold
, color
);
554 HPEN oldpen
= (HPEN
)::SelectObject(hdc
, pen
);
555 ::MoveToEx(hdc
, rect
.left
+ 7, rect
.top
, NULL
);
556 ::LineTo(hdc
, rect
.left
+ 1, (rect
.top
+ rect
.bottom
) / 2);
557 ::LineTo(hdc
, rect
.left
+ 6, (rect
.top
+ rect
.bottom
) / 2);
558 ::LineTo(hdc
, rect
.left
, rect
.bottom
);
559 ::SelectObject(hdc
, oldpen
);
563 void DrawUpTriangle(HDC hdc
, CRect rect
, COLORREF color
, int bold
)
565 HPEN pen
= ::CreatePen(PS_SOLID
, bold
, color
);
566 HPEN oldpen
= (HPEN
)::SelectObject(hdc
, pen
);
567 ::MoveToEx(hdc
, (rect
.left
+ rect
.right
) / 2, rect
.top
, NULL
);
568 ::LineTo(hdc
, rect
.left
, rect
.bottom
);
569 ::LineTo(hdc
, rect
.right
, rect
.bottom
);
570 ::LineTo(hdc
, (rect
.left
+ rect
.right
) / 2, rect
.top
);
571 ::SelectObject(hdc
, oldpen
);
575 void CGitLogListBase::DrawTagBranchMessage(HDC hdc
, CRect
&rect
, INT_PTR index
, std::vector
<REFLABEL
> &refList
)
577 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(index
);
580 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
581 rItem
.mask
= LVIF_STATE
;
582 rItem
.iItem
= (int)index
;
583 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
589 HTHEME hTheme
= NULL
;
590 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
591 hTheme
= OpenThemeData(m_hWnd
, L
"Explorer::ListView;ListView");
594 if (m_bTagsBranchesOnRightSide
)
596 HFONT oldFont
= (HFONT
)SelectObject(hdc
, (HFONT
)GetStockObject(DEFAULT_GUI_FONT
));
597 GetTextExtentPoint32(hdc
, L
" ", 1, &oneSpaceSize
);
598 SelectObject(hdc
, oldFont
);
599 rt
.left
+= oneSpaceSize
.cx
* 2;
603 GetTextExtentPoint32(hdc
, L
" ", 1, &oneSpaceSize
);
604 DrawTagBranch(hdc
, W_Dc
, hTheme
, rect
, rt
, rItem
, data
, refList
);
605 rt
.left
+= oneSpaceSize
.cx
;
608 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
610 int txtState
= LISS_NORMAL
;
611 if (rItem
.state
& LVIS_SELECTED
)
612 txtState
= LISS_SELECTED
;
614 DrawThemeText(hTheme
, hdc
, LVP_LISTITEM
, txtState
, data
->GetSubject(), -1, DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
, 0, &rt
);
618 if (rItem
.state
& LVIS_SELECTED
)
620 COLORREF clrOld
= ::SetTextColor(hdc
,::GetSysColor(COLOR_HIGHLIGHTTEXT
));
621 ::DrawText(hdc
,data
->GetSubject(), data
->GetSubject().GetLength(), &rt
, DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
);
622 ::SetTextColor(hdc
, clrOld
);
626 ::DrawText(hdc
, data
->GetSubject(), data
->GetSubject().GetLength(), &rt
, DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
);
630 if (m_bTagsBranchesOnRightSide
)
633 GetTextExtentPoint32(hdc
, data
->GetSubject(), data
->GetSubject().GetLength(), &size
);
635 rt
.left
+= oneSpaceSize
.cx
+ size
.cx
;
637 DrawTagBranch(hdc
, W_Dc
, hTheme
, rect
, rt
, rItem
, data
, refList
);
641 CloseThemeData(hTheme
);
646 void CGitLogListBase::DrawTagBranch(HDC hdc
, CDC
&W_Dc
, HTHEME hTheme
, CRect
&rect
, CRect
&rt
, LVITEM
&rItem
, GitRev
* data
, std::vector
<REFLABEL
> &refList
)
648 for (unsigned int i
= 0; i
< refList
.size(); ++i
)
650 CString shortname
= !refList
[i
].simplifiedName
.IsEmpty() ? refList
[i
].simplifiedName
: refList
[i
].name
;
652 COLORREF colRef
= refList
[i
].color
;
653 bool singleRemote
= refList
[i
].singleRemote
;
654 bool hasTracking
= refList
[i
].hasTracking
;
655 bool sameName
= refList
[i
].sameName
;
656 bool annotatedTag
= refList
[i
].annotatedTag
;
658 //When row selected, ajust label color
659 if (!(IsAppThemed() && SysInfo::Instance().IsVistaOrLater()))
661 if (rItem
.state
& LVIS_SELECTED
)
662 colRef
= CColors::MixColors(colRef
, ::GetSysColor(COLOR_HIGHLIGHT
), 150);
665 brush
= ::CreateSolidBrush(colRef
);
667 if (!shortname
.IsEmpty() && (rt
.left
< rect
.right
))
670 memset(&size
,0,sizeof(SIZE
));
671 GetTextExtentPoint32(hdc
, shortname
, shortname
.GetLength(), &size
);
673 rt
.SetRect(rt
.left
, rt
.top
, rt
.left
+ size
.cx
, rt
.bottom
);
676 int textpos
= DT_CENTER
;
678 if (rt
.right
> rect
.right
)
680 rt
.right
= rect
.right
;
689 textRect
.OffsetRect(8, 0);
697 DrawTrackingRoundRect(hdc
, rt
, brush
, m_Colors
.Darken(colRef
, 100));
701 //Fill interior of ref label
702 ::FillRect(hdc
, &rt
, brush
);
710 W_Dc
.Draw3dRect(rectEdge
, m_Colors
.Lighten(colRef
, 100), m_Colors
.Darken(colRef
, 100));
711 rectEdge
.DeflateRect(1, 1);
712 W_Dc
.Draw3dRect(rectEdge
, m_Colors
.Lighten(colRef
, 50), m_Colors
.Darken(colRef
, 50));
718 POINT trianglept
[3] = { { rt
.right
- 8, rt
.top
}, { rt
.right
, (rt
.top
+ rt
.bottom
) / 2 }, { rt
.right
- 8, rt
.bottom
} };
719 HRGN hrgn
= ::CreatePolygonRgn(trianglept
, 3, ALTERNATE
);
720 ::FillRgn(hdc
, hrgn
, brush
);
721 ::DeleteObject(hrgn
);
722 ::MoveToEx(hdc
, trianglept
[0].x
- 1, trianglept
[0].y
, NULL
);
724 HPEN oldpen
= (HPEN
)SelectObject(hdc
, pen
= ::CreatePen(PS_SOLID
, 2, m_Colors
.Lighten(colRef
, 50)));
725 ::LineTo(hdc
, trianglept
[1].x
- 1, trianglept
[1].y
- 1);
727 SelectObject(hdc
, pen
= ::CreatePen(PS_SOLID
, 2, m_Colors
.Darken(colRef
, 50)));
728 ::LineTo(hdc
, trianglept
[2].x
- 1, trianglept
[2].y
- 1);
730 SelectObject(hdc
, pen
= ::CreatePen(PS_SOLID
, 2, colRef
));
731 ::MoveToEx(hdc
, trianglept
[0].x
- 1, trianglept
[2].y
- 3, NULL
);
732 ::LineTo(hdc
, trianglept
[0].x
- 1, trianglept
[0].y
);
734 SelectObject(hdc
, oldpen
);
737 //Draw text inside label
738 bool customColor
= (colRef
& 0xff) * 30 + ((colRef
>> 8) & 0xff) * 59 + ((colRef
>> 16) & 0xff) * 11 <= 12800; // check if dark background
739 if (!customColor
&& IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
741 int txtState
= LISS_NORMAL
;
742 if (rItem
.state
& LVIS_SELECTED
)
743 txtState
= LISS_SELECTED
;
745 DrawThemeText(hTheme
, hdc
, LVP_LISTITEM
, txtState
, shortname
, -1, textpos
| DT_SINGLELINE
| DT_VCENTER
, 0, &textRect
);
749 W_Dc
.SetBkMode(TRANSPARENT
);
750 if (customColor
|| (rItem
.state
& LVIS_SELECTED
))
752 COLORREF clrNew
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
753 COLORREF clrOld
= ::SetTextColor(hdc
,clrNew
);
754 ::DrawText(hdc
, shortname
, shortname
.GetLength(), &textRect
, textpos
| DT_SINGLELINE
| DT_VCENTER
);
755 ::SetTextColor(hdc
,clrOld
);
759 ::DrawText(hdc
, shortname
, shortname
.GetLength(), &textRect
, textpos
| DT_SINGLELINE
| DT_VCENTER
);
765 COLORREF color
= ::GetSysColor(customColor
? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
);
766 int bold
= data
->m_CommitHash
== m_HeadHash
? 2 : 1;
768 newRect
.SetRect(rt
.left
+ 4, rt
.top
+ 4, rt
.left
+ 8, rt
.bottom
- 4);
769 DrawLightning(hdc
, newRect
, color
, bold
);
774 COLORREF color
= ::GetSysColor(customColor
? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT
);
775 int bold
= data
->m_CommitHash
== m_HeadHash
? 2 : 1;
777 newRect
.SetRect(rt
.right
- 12, rt
.top
+ 4, rt
.right
- 4, rt
.bottom
- 4);
778 DrawUpTriangle(hdc
, newRect
, color
, bold
);
781 rt
.left
= rt
.right
+ 1;
784 ::DeleteObject(brush
);
786 rt
.right
= rect
.right
;
789 static COLORREF
blend(const COLORREF
& col1
, const COLORREF
& col2
, int amount
= 128) {
791 // Returns ((256 - amount)*col1 + amount*col2) / 256;
792 return RGB(((256 - amount
)*GetRValue(col1
) + amount
*GetRValue(col2
) ) / 256,
793 ((256 - amount
)*GetGValue(col1
) + amount
*GetGValue(col2
) ) / 256,
794 ((256 - amount
)*GetBValue(col1
) + amount
*GetBValue(col2
) ) / 256);
797 Gdiplus::Color
GetGdiColor(COLORREF col
)
799 return Gdiplus::Color(GetRValue(col
),GetGValue(col
),GetBValue(col
));
801 void CGitLogListBase::paintGraphLane(HDC hdc
, int laneHeight
,int type
, int x1
, int x2
,
802 const COLORREF
& col
,const COLORREF
& activeColor
, int top
805 int h
= laneHeight
/ 2;
806 int m
= (x1
+ x2
) / 2;
807 int r
= (x2
- x1
) * m_NodeSize
/ 30;
810 #define P_CENTER m , h+top
811 #define P_0 x2, h+top
812 #define P_90 m , 0+top-1
813 #define P_180 x1, h+top
814 #define P_270 m , 2 * h+top +1
815 #define R_CENTER m - r, h - r+top, d, d
818 #define DELTA_UR_B 2*(x1 - m), 2*h +top
819 #define DELTA_UR_E 0*16, 90*16 +top // -,
821 #define DELTA_DR_B 2*(x1 - m), 2*-h +top
822 #define DELTA_DR_E 270*16, 90*16 +top // -'
824 #define DELTA_UL_B 2*(x2 - m), 2*h +top
825 #define DELTA_UL_E 90*16, 90*16 +top // ,-
827 #define DELTA_DL_B 2*(x2 - m),2*-h +top
828 #define DELTA_DL_E 180*16, 90*16 // '-
830 #define CENTER_UR x1, 2*h, 225
831 #define CENTER_DR x1, 0 , 135
832 #define CENTER_UL x2, 2*h, 315
833 #define CENTER_DL x2, 0 , 45
836 Gdiplus::Graphics
graphics( hdc
);
838 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
847 Gdiplus::LinearGradientBrush
gradient(
848 Gdiplus::Point(x1
-2, h
+top
-2),
849 Gdiplus::Point(P_270
),
850 GetGdiColor(activeColor
),GetGdiColor(col
));
853 Gdiplus::Pen
mypen(&gradient
, (Gdiplus::REAL
)m_LineWidth
);
854 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
856 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
857 graphics
.DrawArc(&mypen
,x1
-(x2
-x1
)/2-1,top
+h
-1, x2
-x1
,laneHeight
,270,90);
858 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
865 Gdiplus::LinearGradientBrush
gradient(
866 Gdiplus::Point(P_270
),
867 Gdiplus::Point(x2
+1, h
+top
-1),
868 GetGdiColor(col
),GetGdiColor(activeColor
));
871 Gdiplus::Pen
mypen(&gradient
, (Gdiplus::REAL
)m_LineWidth
);
872 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
874 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
875 graphics
.DrawArc(&mypen
,x1
+(x2
-x1
)/2,top
+h
-1, x2
-x1
,laneHeight
,180,90);
876 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
885 Gdiplus::LinearGradientBrush
gradient(
886 Gdiplus::Point(x1
-2, h
+top
-2),
887 Gdiplus::Point(P_90
),
888 GetGdiColor(activeColor
),GetGdiColor(col
));
890 Gdiplus::Pen
mypen(&gradient
, (Gdiplus::REAL
)m_LineWidth
);
892 graphics
.DrawArc(&mypen
,x1
-(x2
-x1
)/2-1,top
-h
-1, x2
-x1
,laneHeight
,0,90);
895 QConicalGradient
gradient(CENTER_DR
);
896 gradient
.setColorAt(0.375, activeCol
);
897 gradient
.setColorAt(0.625, col
);
898 myPen
.setBrush(gradient
);
900 p
->drawArc(P_CENTER
, DELTA_DR
);
909 //static QPen myPen(Qt::black, 2); // fast path here
911 pen
.CreatePen(PS_SOLID
,2,col
);
912 //myPen.setColor(col);
913 HPEN oldpen
=(HPEN
)::SelectObject(hdc
,(HPEN
)pen
);
915 Gdiplus::Pen
myPen(GetGdiColor(col
), (Gdiplus::REAL
)m_LineWidth
);
917 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
924 case Lanes::NOT_ACTIVE
:
925 case Lanes::MERGE_FORK
:
926 case Lanes::MERGE_FORK_R
:
927 case Lanes::MERGE_FORK_L
:
932 //DrawLine(hdc,P_90,P_270);
933 graphics
.DrawLine(&myPen
,P_90
,P_270
);
934 //p->drawLine(P_90, P_270);
938 //DrawLine(hdc,P_CENTER,P_270);
939 graphics
.DrawLine(&myPen
,P_CENTER
,P_270
);
940 //p->drawLine(P_CENTER, P_270);
944 case Lanes::BOUNDARY
:
945 case Lanes::BOUNDARY_C
:
946 case Lanes::BOUNDARY_R
:
947 case Lanes::BOUNDARY_L
:
948 //DrawLine(hdc,P_90, P_CENTER);
949 graphics
.DrawLine(&myPen
,P_90
,P_CENTER
);
950 //p->drawLine(P_90, P_CENTER);
956 myPen
.SetColor(GetGdiColor(activeColor
));
960 case Lanes::MERGE_FORK
:
965 case Lanes::CROSS_EMPTY
:
966 case Lanes::BOUNDARY_C
:
967 //DrawLine(hdc,P_180,P_0);
968 graphics
.DrawLine(&myPen
,P_180
,P_0
);
969 //p->drawLine(P_180, P_0);
971 case Lanes::MERGE_FORK_R
:
972 case Lanes::BOUNDARY_R
:
973 //DrawLine(hdc,P_180,P_CENTER);
974 graphics
.DrawLine(&myPen
,P_180
,P_CENTER
);
975 //p->drawLine(P_180, P_CENTER);
977 case Lanes::MERGE_FORK_L
:
980 case Lanes::BOUNDARY_L
:
981 //DrawLine(hdc,P_CENTER,P_0);
982 graphics
.DrawLine(&myPen
,P_CENTER
,P_0
);
983 //p->drawLine(P_CENTER, P_0);
989 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
992 brush
.CreateSolidBrush(col
);
993 HBRUSH oldbrush
=(HBRUSH
)::SelectObject(hdc
,(HBRUSH
)brush
);
995 Gdiplus::SolidBrush
myBrush(GetGdiColor(col
));
996 // center symbol, e.g. rect or ellipse
1002 //p->setPen(Qt::NoPen);
1004 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
1005 graphics
.FillEllipse(&myBrush
, R_CENTER
);
1006 //p->drawEllipse(R_CENTER);
1008 case Lanes::MERGE_FORK
:
1009 case Lanes::MERGE_FORK_R
:
1010 case Lanes::MERGE_FORK_L
:
1011 //p->setPen(Qt::NoPen);
1013 //p->drawRect(R_CENTER);
1014 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
1015 graphics
.FillRectangle(&myBrush
, R_CENTER
);
1017 case Lanes::UNAPPLIED
:
1019 //p->setPen(Qt::NoPen);
1020 //p->setBrush(Qt::red);
1021 //p->drawRect(m - r, h - 1, d, 2);
1022 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
1023 graphics
.FillRectangle(&myBrush
,m
-r
,h
-1,d
,2);
1025 case Lanes::APPLIED
:
1027 //p->setPen(Qt::NoPen);
1028 //p->setBrush(DARK_GREEN);
1029 //p->drawRect(m - r, h - 1, d, 2);
1030 //p->drawRect(m - 1, h - r, 2, d);
1031 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
1032 graphics
.FillRectangle(&myBrush
,m
-r
,h
-1,d
,2);
1033 graphics
.FillRectangle(&myBrush
,m
-1,h
-r
,2,d
);
1035 case Lanes::BOUNDARY
:
1036 //p->setBrush(back);
1037 //p->drawEllipse(R_CENTER);
1038 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
1039 graphics
.DrawEllipse(&myPen
, R_CENTER
);
1041 case Lanes::BOUNDARY_C
:
1042 case Lanes::BOUNDARY_R
:
1043 case Lanes::BOUNDARY_L
:
1044 //p->setBrush(back);
1045 //p->drawRect(R_CENTER);
1046 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
1047 graphics
.FillRectangle(&myBrush
,R_CENTER
);
1053 ::SelectObject(hdc
,oldpen
);
1054 ::SelectObject(hdc
,oldbrush
);
1063 void CGitLogListBase::DrawGraph(HDC hdc
,CRect
&rect
,INT_PTR index
)
1067 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(index
);
1068 if(data
->m_CommitHash
.IsEmpty())
1073 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
1074 rItem
.mask
= LVIF_STATE
;
1075 rItem
.iItem
= (int)index
;
1076 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
1079 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
1081 if (data
->m_Lanes
.empty())
1082 m_logEntries
.setLane(data
->m_CommitHash
);
1084 std::vector
<int>& lanes
=data
->m_Lanes
;
1085 size_t laneNum
= lanes
.size();
1086 UINT activeLane
= 0;
1087 for (UINT i
= 0; i
< laneNum
; ++i
)
1088 if (Lanes::isMerge(lanes
[i
])) {
1094 int maxWidth
= rect
.Width();
1095 int lw
= 3 * rect
.Height() / 4; //laneWidth()
1097 COLORREF activeColor
= m_LineColors
[activeLane
% Lanes::COLORS_NUM
];
1098 //if (opt.state & QStyle::State_Selected)
1099 // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208);
1101 for (unsigned int i
= 0; i
< laneNum
&& x2
< maxWidth
; ++i
)
1108 if (ln
== Lanes::EMPTY
)
1111 COLORREF color
= i
== activeLane
? activeColor
: m_LineColors
[i
% Lanes::COLORS_NUM
];
1112 paintGraphLane(hdc
, rect
.Height(),ln
, x1
+rect
.left
, x2
+rect
.left
, color
,activeColor
, rect
.top
);
1116 for (UINT i
= 0; i
< laneNum
&& x2
< maxWidth
; ++i
) {
1122 if (ln
== Lanes::EMPTY
)
1125 UINT col
= ( Lanes:: isHead(ln
) ||Lanes:: isTail(ln
) || Lanes::isJoin(ln
)
1126 || ln
==Lanes:: CROSS_EMPTY
) ? activeLane
: i
;
1128 if (ln
== Lanes::CROSS
)
1130 paintGraphLane(hdc
, rect
.Height(),Lanes::NOT_ACTIVE
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
1131 paintGraphLane(hdc
, rect
.Height(),Lanes::CROSS
, x1
, x2
, m_LineColors
[activeLane
% Lanes::COLORS_NUM
],rect
.top
);
1134 paintGraphLane(hdc
, rect
.Height(),ln
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
1140 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1143 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
1144 // Take the default processing unless we set this to something else below.
1145 *pResult
= CDRF_DODEFAULT
;
1147 if (m_bNoDispUpdates
)
1150 switch (pLVCD
->nmcd
.dwDrawStage
)
1154 *pResult
= CDRF_NOTIFYITEMDRAW
;
1158 case CDDS_ITEMPREPAINT
:
1160 // This is the prepaint stage for an item. Here's where we set the
1161 // item's text color.
1163 // Tell Windows to send draw notifications for each subitem.
1164 *pResult
= CDRF_NOTIFYSUBITEMDRAW
;
1166 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
1168 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1170 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1173 int action
= data
->GetRebaseAction();
1174 if (action
& (LOGACTIONS_REBASE_DONE
| LOGACTIONS_REBASE_SKIP
))
1175 crText
= RGB(128,128,128);
1177 if (action
& LOGACTIONS_REBASE_SQUASH
)
1178 pLVCD
->clrTextBk
= RGB(156,156,156);
1179 else if (action
& LOGACTIONS_REBASE_EDIT
)
1180 pLVCD
->clrTextBk
= RGB(200,200,128);
1182 pLVCD
->clrTextBk
= ::GetSysColor(COLOR_WINDOW
);
1184 if (action
& LOGACTIONS_REBASE_CURRENT
)
1186 SelectObject(pLVCD
->nmcd
.hdc
, m_boldFont
);
1187 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
1190 if (data
->m_CommitHash
== m_HeadHash
&& m_bNoHightlightHead
== FALSE
)
1192 SelectObject(pLVCD
->nmcd
.hdc
, m_boldFont
);
1193 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
1196 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
1197 // crText = GetSysColor(COLOR_GRAYTEXT);
1199 if (data
->m_CommitHash
.IsEmpty())
1201 //crText = GetSysColor(RGB(200,200,0));
1202 //SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1203 // We changed the font, so we're returning CDRF_NEWFONT. This
1204 // tells the control to recalculate the extent of the text.
1205 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
1209 if (m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1211 if (m_bStrictStopped
)
1212 crText
= GetSysColor(COLOR_GRAYTEXT
);
1214 // Store the color back in the NMLVCUSTOMDRAW struct.
1215 pLVCD
->clrText
= crText
;
1219 case CDDS_ITEMPREPAINT
|CDDS_ITEM
|CDDS_SUBITEM
:
1221 if ((m_bStrictStopped
)&&(m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
))
1223 pLVCD
->nmcd
.uItemState
&= ~(CDIS_SELECTED
|CDIS_FOCUS
);
1226 if (pLVCD
->iSubItem
== LOGLIST_GRAPH
&& !HasFilterText() && (m_ShowFilter
& FILTERSHOW_MERGEPOINTS
))
1228 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
&& (!this->m_IsRebaseReplaceGraph
) )
1231 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_LABEL
, rect
);
1233 //TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right);
1234 FillBackGround(pLVCD
->nmcd
.hdc
, pLVCD
->nmcd
.dwItemSpec
,rect
);
1236 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1237 if( !data
->m_CommitHash
.IsEmpty())
1238 DrawGraph(pLVCD
->nmcd
.hdc
,rect
,pLVCD
->nmcd
.dwItemSpec
);
1240 *pResult
= CDRF_SKIPDEFAULT
;
1245 if (pLVCD
->iSubItem
== LOGLIST_MESSAGE
)
1247 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1249 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1251 if (!m_HashMap
[data
->m_CommitHash
].empty() && !(data
->GetRebaseAction() & LOGACTIONS_REBASE_DONE
))
1254 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1256 // BEGIN: extended redraw, HACK for issue #1618 and #2014
1257 // not in FillBackGround method, because this only affected the message subitem
1258 if (0 != pLVCD
->iStateId
) // don't know why, but this helps against loosing the focus rect
1261 int index
= (int)pLVCD
->nmcd
.dwItemSpec
;
1262 int state
= GetItemState(index
, LVIS_SELECTED
);
1263 int txtState
= LISS_NORMAL
;
1264 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater() && GetHotItem() == (int)index
)
1266 if (state
& LVIS_SELECTED
)
1267 txtState
= LISS_HOTSELECTED
;
1269 txtState
= LISS_HOT
;
1271 else if (state
& LVIS_SELECTED
)
1273 if (::GetFocus() == m_hWnd
)
1274 txtState
= LISS_SELECTED
;
1276 txtState
= LISS_SELECTEDNOTFOCUS
;
1279 HTHEME hTheme
= nullptr;
1280 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
1281 hTheme
= OpenThemeData(m_hWnd
, L
"Explorer::ListView;ListView");
1283 if (hTheme
&& IsThemeBackgroundPartiallyTransparent(hTheme
, LVP_LISTDETAIL
, txtState
))
1284 DrawThemeParentBackground(m_hWnd
, pLVCD
->nmcd
.hdc
, &rect
);
1287 HBRUSH brush
= ::CreateSolidBrush(pLVCD
->clrTextBk
);
1288 ::FillRect(pLVCD
->nmcd
.hdc
, rect
, brush
);
1289 ::DeleteObject(brush
);
1294 // get rect of whole line
1295 GetItemRect(index
, rt
, LVIR_BOUNDS
);
1297 if (txtState
== LISS_NORMAL
) // avoid drawing of grey borders
1298 rect2
.DeflateRect(1, 1, 1, 1);
1300 // calculate background for rect of whole line, but limit redrawing to SubItem rect
1301 DrawThemeBackground(hTheme
, pLVCD
->nmcd
.hdc
, LVP_LISTITEM
, txtState
, rt
, rect2
);
1303 CloseThemeData(hTheme
);
1305 // END: extended redraw
1307 FillBackGround(pLVCD
->nmcd
.hdc
, pLVCD
->nmcd
.dwItemSpec
,rect
);
1309 std::vector
<REFLABEL
> refsToShow
;
1310 STRING_VECTOR remoteTrackingList
;
1311 STRING_VECTOR refList
= m_HashMap
[data
->m_CommitHash
];
1312 for (unsigned int i
= 0; i
< refList
.size(); ++i
)
1314 CString str
= refList
[i
];
1317 refLabel
.color
= RGB(255, 255, 255);
1318 refLabel
.singleRemote
= false;
1319 refLabel
.hasTracking
= false;
1320 refLabel
.sameName
= false;
1321 refLabel
.annotatedTag
= false;
1322 if (CGit::GetShortName(str
, refLabel
.name
, _T("refs/heads/")))
1324 if (!(m_ShowRefMask
& LOGLIST_SHOWLOCALBRANCHES
))
1326 if (refLabel
.name
== m_CurrentBranch
)
1327 refLabel
.color
= m_Colors
.GetColor(CColors::CurrentBranch
);
1329 refLabel
.color
= m_Colors
.GetColor(CColors::LocalBranch
);
1331 std::pair
<CString
, CString
> trackingEntry
= m_TrackingMap
[refLabel
.name
];
1332 CString pullRemote
= trackingEntry
.first
;
1333 CString pullBranch
= trackingEntry
.second
;
1334 if (!pullRemote
.IsEmpty() && !pullBranch
.IsEmpty())
1336 CString defaultUpstream
;
1337 defaultUpstream
.Format(_T("refs/remotes/%s/%s"), pullRemote
, pullBranch
);
1338 refLabel
.hasTracking
= true;
1339 if (m_ShowRefMask
& LOGLIST_SHOWREMOTEBRANCHES
)
1342 for (size_t j
= i
+ 1; j
< refList
.size(); ++j
)
1344 if (refList
[j
] == defaultUpstream
)
1353 bool sameName
= pullBranch
== refLabel
.name
;
1354 refsToShow
.push_back(refLabel
);
1355 CGit::GetShortName(defaultUpstream
, refLabel
.name
, _T("refs/remotes/"));
1356 refLabel
.color
= m_Colors
.GetColor(CColors::RemoteBranch
);
1357 if (m_bSymbolizeRefNames
)
1359 if (!m_SingleRemote
.IsEmpty() && m_SingleRemote
== pullRemote
)
1361 refLabel
.simplifiedName
= _T("/") + (sameName
? CString() : pullBranch
);
1362 refLabel
.singleRemote
= true;
1365 refLabel
.simplifiedName
= pullRemote
+ _T("/");
1366 refLabel
.sameName
= sameName
;
1368 refsToShow
.push_back(refLabel
);
1369 remoteTrackingList
.push_back(defaultUpstream
);
1375 else if (CGit::GetShortName(str
, refLabel
.name
, _T("refs/remotes/")))
1377 if (!(m_ShowRefMask
& LOGLIST_SHOWREMOTEBRANCHES
))
1381 for (size_t j
= 0; j
< remoteTrackingList
.size(); ++j
)
1383 if (remoteTrackingList
[j
] == str
)
1392 refLabel
.color
= m_Colors
.GetColor(CColors::RemoteBranch
);
1393 if (m_bSymbolizeRefNames
)
1395 if (!m_SingleRemote
.IsEmpty() && refLabel
.name
.Left(m_SingleRemote
.GetLength() + 1) == m_SingleRemote
+ _T("/"))
1397 refLabel
.simplifiedName
= _T("/") + refLabel
.name
.Mid(m_SingleRemote
.GetLength() + 1);
1398 refLabel
.singleRemote
= true;
1402 else if (CGit::GetShortName(str
, refLabel
.name
, _T("refs/tags/")))
1404 if (!(m_ShowRefMask
& LOGLIST_SHOWTAGS
))
1406 refLabel
.color
= m_Colors
.GetColor(CColors::Tag
);
1407 refLabel
.annotatedTag
= str
.Right(3) == _T("^{}");
1409 else if (CGit::GetShortName(str
, refLabel
.name
, _T("refs/stash")))
1411 if (!(m_ShowRefMask
& LOGLIST_SHOWSTASH
))
1413 refLabel
.color
= m_Colors
.GetColor(CColors::Stash
);
1414 refLabel
.name
= _T("stash");
1416 else if (CGit::GetShortName(str
, refLabel
.name
, _T("refs/bisect/")))
1418 if (!(m_ShowRefMask
& LOGLIST_SHOWBISECT
))
1420 if (refLabel
.name
.Find(_T("good")) == 0)
1422 refLabel
.color
= m_Colors
.GetColor(CColors::BisectGood
);
1423 refLabel
.name
= _T("good");
1425 if (refLabel
.name
.Find(_T("bad")) == 0)
1427 refLabel
.color
= m_Colors
.GetColor(CColors::BisectBad
);
1428 refLabel
.name
= _T("bad");
1434 refsToShow
.push_back(refLabel
);
1437 if (refsToShow
.empty())
1439 *pResult
= CDRF_DODEFAULT
;
1443 DrawTagBranchMessage(pLVCD
->nmcd
.hdc
, rect
, pLVCD
->nmcd
.dwItemSpec
, refsToShow
);
1445 *pResult
= CDRF_SKIPDEFAULT
;
1453 if (pLVCD
->iSubItem
== LOGLIST_ACTION
)
1455 if(this->m_IsIDReplaceAction
)
1457 *pResult
= CDRF_DODEFAULT
;
1460 *pResult
= CDRF_DODEFAULT
;
1462 if (m_arShownList
.GetCount() <= (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1466 int iconwidth
= ::GetSystemMetrics(SM_CXSMICON
);
1467 int iconheight
= ::GetSystemMetrics(SM_CYSMICON
);
1469 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
));
1471 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1472 //TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right);
1473 // Get the selected state of the
1474 // item being drawn.
1476 // Fill the background if necessary
1477 FillBackGround(pLVCD
->nmcd
.hdc
, pLVCD
->nmcd
.dwItemSpec
, rect
);
1479 // Draw the icon(s) into the compatible DC
1480 int action
= SafeGetAction(pLogEntry
);
1482 if (!pLogEntry
->m_IsDiffFiles
)
1483 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ ICONITEMBORDER
, rect
.top
, m_hFetchIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1485 if (action
& CTGitPath::LOGACTIONS_MODIFIED
)
1486 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ ICONITEMBORDER
, rect
.top
, m_hModifiedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1489 if (action
& (CTGitPath::LOGACTIONS_ADDED
| CTGitPath::LOGACTIONS_COPY
))
1490 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hAddedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1493 if (action
& CTGitPath::LOGACTIONS_DELETED
)
1494 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hDeletedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1497 if (action
& CTGitPath::LOGACTIONS_REPLACED
)
1498 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hReplacedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1500 *pResult
= CDRF_SKIPDEFAULT
;
1506 *pResult
= CDRF_DODEFAULT
;
1509 CString
FindSVNRev(const CString
& msg
)
1513 const std::tr1::wsregex_iterator end
;
1514 std::wstring s
= msg
;
1515 for (std::tr1::wsregex_iterator
it(s
.begin(), s
.end(), std::tr1::wregex(_T("^\\s*git-svn-id:\\s+(.*)\\@(\\d+)\\s([a-f\\d\\-]+)$"))); it
!= end
; ++it
)
1517 const std::tr1::wsmatch match
= *it
;
1518 if (match
.size() == 4)
1520 ATLTRACE(_T("matched rev: %s\n"), std::wstring(match
[2]).c_str());
1521 return std::wstring(match
[2]).c_str();
1524 for (std::tr1::wsregex_iterator
it(s
.begin(), s
.end(), std::tr1::wregex(_T("^\\s*git-svn-id:\\s(\\d+)\\@([a-f\\d\\-]+"))); it
!= end
; ++it
)
1526 const std::tr1::wsmatch match
= *it
;
1527 if (match
.size() == 3)
1529 ATLTRACE(_T("matched rev: %s\n"), std::wstring(match
[1]).c_str());
1530 return std::wstring(match
[1]).c_str();
1534 catch (std::exception
) {}
1539 // CGitLogListBase message handlers
1541 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1543 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
1545 // Create a pointer to the item
1546 LV_ITEM
* pItem
= &(pDispInfo
)->item
;
1548 // Do the list need text information?
1549 if (!(pItem
->mask
& LVIF_TEXT
))
1552 // By default, clear text buffer.
1553 lstrcpyn(pItem
->pszText
, _T(""), pItem
->cchTextMax
);
1555 bool bOutOfRange
= pItem
->iItem
>= ShownCountWithStopped();
1558 if (m_bNoDispUpdates
|| bOutOfRange
)
1561 // Which item number?
1562 int itemid
= pItem
->iItem
;
1563 GitRev
* pLogEntry
= NULL
;
1564 if (itemid
< m_arShownList
.GetCount())
1565 pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(pItem
->iItem
));
1570 temp
.Format(_T("%d"),pItem
->iItem
+1);
1575 temp
.Format(_T("%d"),m_arShownList
.GetCount()-pItem
->iItem
);
1579 switch (pItem
->iSubItem
)
1581 case this->LOGLIST_GRAPH
: //Graphic
1583 case this->LOGLIST_REBASE
:
1585 if (this->m_IsRebaseReplaceGraph
&& pLogEntry
)
1586 lstrcpyn(pItem
->pszText
, GetRebaseActionName(pLogEntry
->GetRebaseAction() & LOGACTIONS_REBASE_MODE_MASK
), pItem
->cchTextMax
);
1589 case this->LOGLIST_ACTION
: //action -- no text in the column
1591 case this->LOGLIST_HASH
:
1593 lstrcpyn(pItem
->pszText
, pLogEntry
->m_CommitHash
.ToString(), pItem
->cchTextMax
);
1595 case this->LOGLIST_ID
:
1596 if(this->m_IsIDReplaceAction
)
1597 lstrcpyn(pItem
->pszText
, temp
, pItem
->cchTextMax
);
1599 case this->LOGLIST_MESSAGE
: //Message
1601 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetSubject(), pItem
->cchTextMax
);
1603 case this->LOGLIST_AUTHOR
: //Author
1605 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetAuthorName(), pItem
->cchTextMax
);
1607 case this->LOGLIST_DATE
: //Date
1608 if ( pLogEntry
&& (!pLogEntry
->m_CommitHash
.IsEmpty()) )
1609 lstrcpyn(pItem
->pszText
,
1610 CLoglistUtils::FormatDateAndTime(pLogEntry
->GetAuthorDate(), m_DateFormat
, true, m_bRelativeTimes
),
1614 case this->LOGLIST_EMAIL
:
1616 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetAuthorEmail(), pItem
->cchTextMax
);
1619 case this->LOGLIST_COMMIT_NAME
: //Commit
1621 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetCommitterName(), pItem
->cchTextMax
);
1624 case this->LOGLIST_COMMIT_EMAIL
: //Commit Email
1626 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetCommitterEmail(), pItem
->cchTextMax
);
1629 case this->LOGLIST_COMMIT_DATE
: //Commit Date
1630 if (pLogEntry
&& (!pLogEntry
->m_CommitHash
.IsEmpty()))
1631 lstrcpyn(pItem
->pszText
,
1632 CLoglistUtils::FormatDateAndTime(pLogEntry
->GetCommitterDate(), m_DateFormat
, true, m_bRelativeTimes
),
1635 case this->LOGLIST_BUG
: //Bug ID
1637 lstrcpyn(pItem
->pszText
, (LPCTSTR
)this->m_ProjectProperties
.FindBugID(pLogEntry
->GetSubject() + _T("\r\n\r\n") + pLogEntry
->GetBody()), pItem
->cchTextMax
);
1639 case this->LOGLIST_SVNREV
: //SVN revision
1641 lstrcpyn(pItem
->pszText
, (LPCTSTR
)FindSVNRev(pLogEntry
->GetSubject() + _T("\r\n\r\n") + pLogEntry
->GetBody()), pItem
->cchTextMax
);
1649 bool CGitLogListBase::IsOnStash(int index
)
1651 GitRev
*rev
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(index
));
1656 GitRev
*preRev
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(index
- 1));
1657 if (IsStash(preRev
))
1658 return preRev
->m_ParentHash
.size() == 2 && preRev
->m_ParentHash
[1] == rev
->m_CommitHash
;
1663 bool CGitLogListBase::IsStash(const GitRev
* pSelLogEntry
)
1665 for (size_t i
= 0; i
< m_HashMap
[pSelLogEntry
->m_CommitHash
].size(); ++i
)
1667 if (m_HashMap
[pSelLogEntry
->m_CommitHash
][i
] == _T("refs/stash"))
1673 void CGitLogListBase::GetParentHashes(GitRev
*pRev
, GIT_REV_LIST
&parentHash
)
1675 if (pRev
->m_ParentHash
.empty())
1679 pRev
->GetParentFromHash(pRev
->m_CommitHash
);
1681 catch (const char* msg
)
1683 MessageBox(_T("Could not get parent.\nlibgit reports:\n") + CString(msg
), _T("TortoiseGit"), MB_ICONERROR
);
1686 parentHash
= pRev
->m_ParentHash
;
1689 void CGitLogListBase::OnContextMenu(CWnd
* pWnd
, CPoint point
)
1692 if (pWnd
== GetHeaderCtrl())
1694 return m_ColumnManager
.OnContextMenuHeader(pWnd
,point
,!!IsGroupViewEnabled());
1697 int selIndex
= GetSelectionMark();
1699 return; // nothing selected, nothing to do with a context menu
1701 // if the user selected the info text telling about not all revisions shown due to
1702 // the "stop on copy/rename" option, we also don't show the context menu
1703 if ((m_bStrictStopped
)&&(selIndex
== m_arShownList
.GetCount()))
1706 // if the context menu is invoked through the keyboard, we have to use
1707 // a calculated position on where to anchor the menu on
1708 if ((point
.x
== -1) && (point
.y
== -1))
1711 GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
1712 ClientToScreen(&rect
);
1713 point
= rect
.CenterPoint();
1715 m_nSearchIndex
= selIndex
;
1716 m_bCancelled
= FALSE
;
1718 // calculate some information the context menu commands can use
1719 // CString pathURL = GetURLFromPath(m_path);
1721 POSITION pos
= GetFirstSelectedItemPosition();
1722 int indexNext
= GetNextSelectedItem(pos
);
1726 GitRev
* pSelLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(indexNext
));
1727 if (pSelLogEntry
== nullptr)
1730 GitRev revSelected
= pSelLogEntry
->Rev
;
1731 GitRev revPrevious
= git_revnum_t(revSelected
)-1;
1732 if ((pSelLogEntry
->pArChangedPaths
)&&(pSelLogEntry
->pArChangedPaths
->GetCount() <= 2))
1734 for (int i
=0; i
<pSelLogEntry
->pArChangedPaths
->GetCount(); ++i
)
1736 LogChangedPath
* changedpath
= (LogChangedPath
*)pSelLogEntry
->pArChangedPaths
->SafeGetAt(i
);
1737 if (changedpath
->lCopyFromRev
)
1738 revPrevious
= changedpath
->lCopyFromRev
;
1741 GitRev revSelected2
;
1744 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
)));
1745 revSelected2
= pLogEntry
->Rev
;
1747 bool bAllFromTheSameAuthor
= true;
1748 CString firstAuthor
;
1749 CLogDataVector selEntries
;
1750 GitRev revLowest
, revHighest
;
1751 GitRevRangeArray revisionRanges
;
1753 POSITION pos
= GetFirstSelectedItemPosition();
1754 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
)));
1755 revisionRanges
.AddRevision(pLogEntry
->Rev
);
1756 selEntries
.push_back(pLogEntry
);
1757 firstAuthor
= pLogEntry
->sAuthor
;
1758 revLowest
= pLogEntry
->Rev
;
1759 revHighest
= pLogEntry
->Rev
;
1762 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
)));
1763 revisionRanges
.AddRevision(pLogEntry
->Rev
);
1764 selEntries
.push_back(pLogEntry
);
1765 if (firstAuthor
.Compare(pLogEntry
->sAuthor
))
1766 bAllFromTheSameAuthor
= false;
1767 revLowest
= (git_revnum_t(pLogEntry
->Rev
) > git_revnum_t(revLowest
) ? revLowest
: pLogEntry
->Rev
);
1768 revHighest
= (git_revnum_t(pLogEntry
->Rev
) < git_revnum_t(revHighest
) ? revHighest
: pLogEntry
->Rev
);
1774 int FirstSelect
=-1, LastSelect
=-1;
1775 pos
= GetFirstSelectedItemPosition();
1776 FirstSelect
= GetNextSelectedItem(pos
);
1779 LastSelect
= GetNextSelectedItem(pos
);
1781 //entry is selected, now show the popup menu
1783 CIconMenu subbranchmenu
, submenu
, gnudiffmenu
, diffmenu
, blamemenu
, revertmenu
;
1785 if (popup
.CreatePopupMenu())
1787 bool isHeadCommit
= (pSelLogEntry
->m_CommitHash
== m_HeadHash
);
1788 CString currentBranch
= _T("refs/heads/") + g_Git
.GetCurrentBranch();
1789 bool isMergeActive
= CTGitPath(g_Git
.m_CurrentDir
).IsMergeActive();
1790 bool isStash
= IsOnStash(indexNext
);
1791 GIT_REV_LIST parentHash
;
1792 GetParentHashes(pSelLogEntry
, parentHash
);
1794 if (m_ContextMenuMask
& GetContextMenuBit(ID_REBASE_PICK
) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)))
1795 popup
.AppendMenuIcon(ID_REBASE_PICK
, IDS_REBASE_PICK
, IDI_PICK
);
1797 if (m_ContextMenuMask
& GetContextMenuBit(ID_REBASE_SQUASH
) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)))
1798 popup
.AppendMenuIcon(ID_REBASE_SQUASH
, IDS_REBASE_SQUASH
, IDI_SQUASH
);
1800 if (m_ContextMenuMask
& GetContextMenuBit(ID_REBASE_EDIT
) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)))
1801 popup
.AppendMenuIcon(ID_REBASE_EDIT
, IDS_REBASE_EDIT
, IDI_EDIT
);
1803 if (m_ContextMenuMask
& GetContextMenuBit(ID_REBASE_SKIP
) && !(pSelLogEntry
->GetRebaseAction() & (LOGACTIONS_REBASE_CURRENT
| LOGACTIONS_REBASE_DONE
)))
1804 popup
.AppendMenuIcon(ID_REBASE_SKIP
, IDS_REBASE_SKIP
, IDI_SKIP
);
1806 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
)))
1807 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1809 if (GetSelectedCount() == 1)
1812 bool requiresSeparator
= false;
1813 if( !pSelLogEntry
->m_CommitHash
.IsEmpty())
1815 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPARE
) && m_hasWC
) // compare revision with WC
1817 popup
.AppendMenuIcon(ID_COMPARE
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
1818 requiresSeparator
= true;
1823 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMMIT
))
1825 popup
.AppendMenuIcon(ID_COMMIT
, IDS_LOG_POPUP_COMMIT
, IDI_COMMIT
);
1826 requiresSeparator
= true;
1828 if (isMergeActive
&& (m_ContextMenuMask
& GetContextMenuBit(ID_MERGE_ABORT
)))
1830 popup
.AppendMenuIcon(ID_MERGE_ABORT
, IDS_MENUMERGEABORT
, IDI_MERGEABORT
);
1831 requiresSeparator
= true;
1835 if (m_ContextMenuMask
& GetContextMenuBit(ID_BLAMEPREVIOUS
))
1837 if (parentHash
.size() == 1)
1839 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_LOG_POPUP_BLAMEPREVIOUS
, IDI_BLAME
);
1840 requiresSeparator
= true;
1842 else if (parentHash
.size() > 1)
1844 blamemenu
.CreatePopupMenu();
1845 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_LOG_POPUP_BLAMEPREVIOUS
, IDI_BLAME
, blamemenu
.m_hMenu
);
1846 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
1849 str
.Format(IDS_PARENT
, i
+ 1);
1850 blamemenu
.AppendMenuIcon(ID_BLAMEPREVIOUS
+((i
+ 1) << 16), str
);
1852 requiresSeparator
= true;
1856 if(m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF1
) && m_hasWC
) // compare with WC, unified
1858 if (parentHash
.size() == 1)
1860 popup
.AppendMenuIcon(ID_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF_CH
, IDI_DIFF
);
1861 requiresSeparator
= true;
1863 else if (parentHash
.size() > 1)
1865 gnudiffmenu
.CreatePopupMenu();
1866 popup
.AppendMenuIcon(ID_GNUDIFF1
,IDS_LOG_POPUP_GNUDIFF_PARENT
, IDI_DIFF
, gnudiffmenu
.m_hMenu
);
1868 gnudiffmenu
.AppendMenuIcon((UINT_PTR
)(ID_GNUDIFF1
+ (0xFFFF << 16)), CString(MAKEINTRESOURCE(IDS_ALLPARENTS
)));
1869 gnudiffmenu
.AppendMenuIcon((UINT_PTR
)(ID_GNUDIFF1
+ (0xFFFE << 16)), CString(MAKEINTRESOURCE(IDS_ONLYMERGEDFILES
)));
1871 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
1874 str
.Format(IDS_PARENT
, i
+ 1);
1875 gnudiffmenu
.AppendMenuIcon(ID_GNUDIFF1
+((i
+1)<<16),str
);
1877 requiresSeparator
= true;
1881 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPAREWITHPREVIOUS
))
1883 if (parentHash
.size() == 1)
1885 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_LOG_POPUP_COMPAREWITHPREVIOUS
, IDI_DIFF
);
1886 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1887 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
1888 requiresSeparator
= true;
1890 else if (parentHash
.size() > 1)
1892 diffmenu
.CreatePopupMenu();
1893 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_LOG_POPUP_COMPAREWITHPREVIOUS
, IDI_DIFF
, diffmenu
.m_hMenu
);
1894 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
1897 str
.Format(IDS_PARENT
, i
+ 1);
1898 diffmenu
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
+((i
+1)<<16),str
);
1899 if (i
== 0 && CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1901 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
1902 diffmenu
.SetDefaultItem((UINT
)(ID_COMPAREWITHPREVIOUS
+ ((i
+ 1) << 16)), FALSE
);
1905 requiresSeparator
= true;
1909 if(m_ContextMenuMask
&GetContextMenuBit(ID_BLAME
))
1911 popup
.AppendMenuIcon(ID_BLAME
, IDS_LOG_POPUP_BLAME
, IDI_BLAME
);
1912 requiresSeparator
= true;
1915 if (requiresSeparator
)
1916 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1918 if (pSelLogEntry
->m_CommitHash
.IsEmpty() && !isMergeActive
)
1920 if(m_ContextMenuMask
&GetContextMenuBit(ID_STASH_SAVE
))
1921 popup
.AppendMenuIcon(ID_STASH_SAVE
, IDS_MENUSTASHSAVE
, IDI_COMMIT
);
1924 if (CTGitPath(g_Git
.m_CurrentDir
).HasStashDir() && (pSelLogEntry
->m_CommitHash
.IsEmpty() || isStash
))
1926 if (m_ContextMenuMask
&GetContextMenuBit(ID_STASH_POP
))
1927 popup
.AppendMenuIcon(ID_STASH_POP
, IDS_MENUSTASHPOP
, IDI_RELOCATE
);
1929 if (m_ContextMenuMask
&GetContextMenuBit(ID_STASH_LIST
))
1930 popup
.AppendMenuIcon(ID_STASH_LIST
, IDS_MENUSTASHLIST
, IDI_LOG
);
1932 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1935 if (pSelLogEntry
->m_CommitHash
.IsEmpty())
1937 if (m_ContextMenuMask
& GetContextMenuBit(ID_PULL
) && !isMergeActive
)
1938 popup
.AppendMenuIcon(ID_PULL
, IDS_MENUPULL
, IDI_PULL
);
1940 if(m_ContextMenuMask
&GetContextMenuBit(ID_FETCH
))
1941 popup
.AppendMenuIcon(ID_FETCH
, IDS_MENUFETCH
, IDI_PULL
);
1943 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1947 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
1949 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
1951 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
1953 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
1955 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
1956 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
1958 // popup.AppendMenu(MF_SEPARATOR, NULL);
1963 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
1965 if(!pSelLogEntry
->m_CommitHash
.IsEmpty())
1967 if((m_ContextMenuMask
&GetContextMenuBit(ID_LOG
)) &&
1968 GetSelectedCount() == 1)
1969 popup
.AppendMenuIcon(ID_LOG
, IDS_LOG_POPUP_LOG
, IDI_LOG
);
1971 if (m_ContextMenuMask
&GetContextMenuBit(ID_REPOBROWSE
))
1972 popup
.AppendMenuIcon(ID_REPOBROWSE
, IDS_LOG_BROWSEREPO
, IDI_REPOBROWSE
);
1974 format
.LoadString(IDS_LOG_POPUP_MERGEREV
);
1975 str
.Format(format
,g_Git
.GetCurrentBranch());
1977 if (m_ContextMenuMask
&GetContextMenuBit(ID_MERGEREV
) && !isHeadCommit
&& m_hasWC
&& !isMergeActive
&& !isStash
)
1978 popup
.AppendMenuIcon(ID_MERGEREV
, str
, IDI_MERGE
);
1980 format
.LoadString(IDS_RESET_TO_THIS_FORMAT
);
1981 str
.Format(format
,g_Git
.GetCurrentBranch());
1983 if (m_ContextMenuMask
&GetContextMenuBit(ID_RESET
) && m_hasWC
&& !isStash
)
1984 popup
.AppendMenuIcon(ID_RESET
,str
,IDI_REVERT
);
1987 // Add Switch Branch express Menu
1988 if( this->m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.end()
1989 && (m_ContextMenuMask
&GetContextMenuBit(ID_SWITCHBRANCH
) && m_hasWC
&& !isStash
)
1992 std::vector
<CString
*> branchs
;
1993 for (size_t i
= 0; i
< m_HashMap
[pSelLogEntry
->m_CommitHash
].size(); ++i
)
1995 CString ref
= m_HashMap
[pSelLogEntry
->m_CommitHash
][i
];
1996 if(ref
.Find(_T("refs/heads/")) == 0 && ref
!= currentBranch
)
1998 branchs
.push_back(&m_HashMap
[pSelLogEntry
->m_CommitHash
][i
]);
2003 str
.LoadString(IDS_SWITCH_BRANCH
);
2005 if(branchs
.size() == 1)
2008 str
+= _T('"') + branchs
[0]->Mid(11) + _T('"');
2009 popup
.AppendMenuIcon(ID_SWITCHBRANCH
,str
,IDI_SWITCH
);
2011 popup
.SetMenuItemData(ID_SWITCHBRANCH
,(ULONG_PTR
)branchs
[0]);
2014 else if(branchs
.size() > 1)
2016 subbranchmenu
.CreatePopupMenu();
2017 for (size_t i
= 0 ; i
< branchs
.size(); ++i
)
2019 if (*branchs
[i
] != currentBranch
)
2021 subbranchmenu
.AppendMenuIcon(ID_SWITCHBRANCH
+(i
<<16), branchs
[i
]->Mid(11));
2022 subbranchmenu
.SetMenuItemData(ID_SWITCHBRANCH
+(i
<<16), (ULONG_PTR
) branchs
[i
]);
2026 popup
.AppendMenuIcon(ID_SWITCHBRANCH
, str
, IDI_SWITCH
, subbranchmenu
.m_hMenu
);
2030 if (m_ContextMenuMask
&GetContextMenuBit(ID_SWITCHTOREV
) && !isHeadCommit
&& m_hasWC
&& !isStash
)
2031 popup
.AppendMenuIcon(ID_SWITCHTOREV
, IDS_SWITCH_TO_THIS
, IDI_SWITCH
);
2033 if (m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_BRANCH
) && !isStash
)
2034 popup
.AppendMenuIcon(ID_CREATE_BRANCH
, IDS_CREATE_BRANCH_AT_THIS
, IDI_COPY
);
2036 if (m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_TAG
) && !isStash
)
2037 popup
.AppendMenuIcon(ID_CREATE_TAG
,IDS_CREATE_TAG_AT_THIS
, IDI_TAG
);
2039 format
.LoadString(IDS_REBASE_THIS_FORMAT
);
2040 str
.Format(format
,g_Git
.GetCurrentBranch());
2042 if (pSelLogEntry
->m_CommitHash
!= m_HeadHash
&& m_hasWC
&& !isMergeActive
&& !isStash
)
2043 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_TO_VERSION
))
2044 popup
.AppendMenuIcon(ID_REBASE_TO_VERSION
, str
, IDI_REBASE
);
2046 if(m_ContextMenuMask
&GetContextMenuBit(ID_EXPORT
))
2047 popup
.AppendMenuIcon(ID_EXPORT
,IDS_EXPORT_TO_THIS
, IDI_EXPORT
);
2049 if (m_ContextMenuMask
&GetContextMenuBit(ID_REVERTREV
) && m_hasWC
&& !isMergeActive
&& !isStash
)
2051 if (parentHash
.size() == 1)
2053 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
);
2055 else if (parentHash
.size() > 1)
2057 revertmenu
.CreatePopupMenu();
2058 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
, revertmenu
.m_hMenu
);
2060 for (size_t i
= 0; i
< parentHash
.size(); ++i
)
2063 str
.Format(IDS_PARENT
, i
+ 1);
2064 revertmenu
.AppendMenuIcon(ID_REVERTREV
+ ((i
+ 1) << 16), str
);
2069 if (m_ContextMenuMask
&GetContextMenuBit(ID_EDITNOTE
) && !isStash
)
2070 popup
.AppendMenuIcon(ID_EDITNOTE
, IDS_EDIT_NOTES
, IDI_EDIT
);
2072 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2077 if(!pSelLogEntry
->m_Ref
.IsEmpty())
2079 popup
.AppendMenuIcon(ID_REFLOG_DEL
, IDS_REFLOG_DEL
, IDI_DELETE
);
2080 if (GetSelectedCount() == 1 && pSelLogEntry
->m_Ref
.Find(_T("refs/stash")) == 0)
2081 popup
.AppendMenuIcon(ID_REFLOG_STASH_APPLY
, IDS_MENUSTASHAPPLY
, IDI_RELOCATE
);
2082 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2085 if (GetSelectedCount() >= 2)
2087 bool bAddSeparator
= false;
2088 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
2090 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPARETWO
)) // compare two revisions
2091 popup
.AppendMenuIcon(ID_COMPARETWO
, IDS_LOG_POPUP_COMPARETWO
, IDI_DIFF
);
2094 if (GetSelectedCount() == 2)
2096 if(m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF2
) && m_hasWC
) // compare two revisions, unified
2097 popup
.AppendMenuIcon(ID_GNUDIFF2
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
2099 if (!pSelLogEntry
->m_CommitHash
.IsEmpty())
2101 CString firstSelHash
= pSelLogEntry
->m_CommitHash
.ToString().Left(g_Git
.GetShortHASHLength());
2102 GitRev
* pLastEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(LastSelect
));
2103 CString lastSelHash
= pLastEntry
->m_CommitHash
.ToString().Left(g_Git
.GetShortHASHLength());
2105 menu
.Format(IDS_SHOWLOG_OF
, lastSelHash
+ _T("..") + firstSelHash
);
2106 popup
.AppendMenuIcon(ID_LOG_VIEWRANGE
, menu
, IDI_LOG
);
2107 menu
.Format(IDS_SHOWLOG_OF
, lastSelHash
+ _T("...") + firstSelHash
);
2108 popup
.AppendMenuIcon(ID_LOG_VIEWRANGE_REACHABLEFROMONLYONE
, menu
, IDI_LOG
);
2111 bAddSeparator
= true;
2116 bAddSeparator
= true;
2119 if (m_ContextMenuMask
&GetContextMenuBit(ID_REVERTREV
) && m_hasWC
&& !isMergeActive
)
2120 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREVS
, IDI_REVERT
);
2123 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2126 if ( GetSelectedCount() >0 && (!pSelLogEntry
->m_CommitHash
.IsEmpty()))
2128 bool bAddSeparator
= false;
2129 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
2131 if (m_ContextMenuMask
&GetContextMenuBit(ID_COMBINE_COMMIT
) && m_hasWC
&& !isMergeActive
)
2135 headindex
= this->GetHeadIndex();
2136 if(headindex
>=0 && LastSelect
>= headindex
&& FirstSelect
>= headindex
)
2138 head
.Format(_T("HEAD~%d"), FirstSelect
- headindex
);
2140 if (g_Git
.GetHash(hashFirst
, head
))
2141 MessageBox(g_Git
.GetGitLastErr(_T("Could not get hash of ") + head
+ _T(".")), _T("TortoiseGit"), MB_ICONERROR
);
2142 head
.Format(_T("HEAD~%d"),LastSelect
-headindex
);
2144 if (g_Git
.GetHash(hash
, head
))
2145 MessageBox(g_Git
.GetGitLastErr(_T("Could not get hash of ") + head
+ _T(".")), _T("TortoiseGit"), MB_ICONERROR
);
2146 GitRev
* pFirstEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(FirstSelect
));
2147 GitRev
* pLastEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(LastSelect
));
2148 if (pFirstEntry
->m_CommitHash
== hashFirst
&& pLastEntry
->m_CommitHash
== hash
) {
2149 popup
.AppendMenuIcon(ID_COMBINE_COMMIT
,IDS_COMBINE_TO_ONE
,IDI_COMBINE
);
2150 bAddSeparator
= true;
2155 if (m_ContextMenuMask
&GetContextMenuBit(ID_CHERRY_PICK
) && !isHeadCommit
&& m_hasWC
&& !isMergeActive
) {
2156 if (GetSelectedCount() >= 2)
2157 popup
.AppendMenuIcon(ID_CHERRY_PICK
, IDS_CHERRY_PICK_VERSIONS
, IDI_EXPORT
);
2159 popup
.AppendMenuIcon(ID_CHERRY_PICK
, IDS_CHERRY_PICK_VERSION
, IDI_EXPORT
);
2160 bAddSeparator
= true;
2163 if (GetSelectedCount() <= 2 || (IsSelectionContinuous() && GetSelectedCount() > 0 && !isStash
))
2164 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_PATCH
)) {
2165 popup
.AppendMenuIcon(ID_CREATE_PATCH
, IDS_CREATE_PATCH
, IDI_PATCH
);
2166 bAddSeparator
= true;
2170 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2173 if (m_hasWC
&& !isMergeActive
&& !isStash
&& (m_ContextMenuMask
& GetContextMenuBit(ID_BISECTSTART
)) && GetSelectedCount() == 2 && !reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(FirstSelect
))->m_CommitHash
.IsEmpty() && !CTGitPath(g_Git
.m_CurrentDir
).IsBisectActive())
2175 popup
.AppendMenuIcon(ID_BISECTSTART
, IDS_MENUBISECTSTART
);
2176 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2179 if (GetSelectedCount() == 1)
2181 bool bAddSeparator
= false;
2182 if (m_ContextMenuMask
&GetContextMenuBit(ID_PUSH
) && !isStash
&& !m_HashMap
[pSelLogEntry
->m_CommitHash
].empty())
2184 // show the push-option only if the log entry has an associated local branch
2185 bool isLocal
= false;
2186 for (size_t i
= 0; isLocal
== false && i
< m_HashMap
[pSelLogEntry
->m_CommitHash
].size(); ++i
)
2188 if (m_HashMap
[pSelLogEntry
->m_CommitHash
][i
].Find(_T("refs/heads/")) == 0)
2193 popup
.AppendMenuIcon(ID_PUSH
, IDS_LOG_PUSH
, IDI_PUSH
);
2194 bAddSeparator
= true;
2197 if (m_ContextMenuMask
& GetContextMenuBit(ID_PULL
) && isHeadCommit
&& !isMergeActive
)
2199 popup
.AppendMenuIcon(ID_PULL
, IDS_MENUPULL
, IDI_PULL
);
2200 bAddSeparator
= true;
2204 if(m_ContextMenuMask
&GetContextMenuBit(ID_DELETE
))
2206 if( this->m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.end() )
2208 std::vector
<CString
*> branchs
;
2209 for (size_t i
= 0; i
< m_HashMap
[pSelLogEntry
->m_CommitHash
].size(); ++i
)
2211 if(m_HashMap
[pSelLogEntry
->m_CommitHash
][i
] != currentBranch
)
2212 branchs
.push_back(&m_HashMap
[pSelLogEntry
->m_CommitHash
][i
]);
2215 if (branchs
.size() == 1)
2217 str
.LoadString(IDS_DELETE_BRANCHTAG_SHORT
);
2220 popup
.AppendMenuIcon(ID_DELETE
, str
, IDI_DELETE
);
2221 popup
.SetMenuItemData(ID_DELETE
, (ULONG_PTR
)branchs
[0]);
2222 bAddSeparator
= true;
2224 else if (branchs
.size() > 1)
2226 str
.LoadString(IDS_DELETE_BRANCHTAG
);
2227 submenu
.CreatePopupMenu();
2228 for (size_t i
= 0; i
< branchs
.size(); ++i
)
2230 submenu
.AppendMenuIcon(ID_DELETE
+ (i
<< 16), *branchs
[i
]);
2231 submenu
.SetMenuItemData(ID_DELETE
+ (i
<< 16), (ULONG_PTR
)branchs
[i
]);
2234 popup
.AppendMenuIcon(ID_DELETE
,str
, IDI_DELETE
, submenu
.m_hMenu
);
2235 bAddSeparator
= true;
2238 } // m_ContextMenuMask &GetContextMenuBit(ID_DELETE)
2240 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
2241 } // GetSelectedCount() == 1
2243 if (GetSelectedCount() != 0)
2245 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYHASH
))
2246 popup
.AppendMenuIcon(ID_COPYHASH
, IDS_COPY_COMMIT_HASH
, IDI_COPYCLIP
);
2247 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYCLIPBOARD
))
2248 popup
.AppendMenuIcon(ID_COPYCLIPBOARD
, IDS_LOG_POPUP_COPYTOCLIPBOARD
, IDI_COPYCLIP
);
2249 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYCLIPBOARDMESSAGES
))
2250 popup
.AppendMenuIcon(ID_COPYCLIPBOARDMESSAGES
, IDS_LOG_POPUP_COPYTOCLIPBOARDMESSAGES
, IDI_COPYCLIP
);
2253 if(m_ContextMenuMask
&GetContextMenuBit(ID_FINDENTRY
))
2254 popup
.AppendMenuIcon(ID_FINDENTRY
, IDS_LOG_POPUP_FIND
, IDI_FILTEREDIT
);
2256 if (GetSelectedCount() == 1 && m_ContextMenuMask
& GetContextMenuBit(ID_SHOWBRANCHES
) && !pSelLogEntry
->m_CommitHash
.IsEmpty())
2257 popup
.AppendMenuIcon(ID_SHOWBRANCHES
, IDS_LOG_POPUP_SHOWBRANCHES
, IDI_SHOWBRANCHES
);
2259 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2260 // DialogEnableWindow(IDOK, FALSE);
2261 // SetPromptApp(&theApp);
2263 this->ContextMenuAction(cmd
, FirstSelect
, LastSelect
, &popup
);
2265 // EnableOKButton();
2266 } // if (popup.CreatePopupMenu())
2270 bool CGitLogListBase::IsSelectionContinuous()
2272 if ( GetSelectedCount()==1 )
2274 // if only one revision is selected, the selection is of course
2279 POSITION pos
= GetFirstSelectedItemPosition();
2280 bool bContinuous
= (m_arShownList
.GetCount() == (INT_PTR
)m_logEntries
.size());
2283 int itemindex
= GetNextSelectedItem(pos
);
2286 int nextindex
= GetNextSelectedItem(pos
);
2287 if (nextindex
- itemindex
> 1)
2289 bContinuous
= false;
2292 itemindex
= nextindex
;
2298 void CGitLogListBase::CopySelectionToClipBoard(int toCopy
)
2302 POSITION pos
= GetFirstSelectedItemPosition();
2306 sRev
.LoadString(IDS_LOG_REVISION
);
2308 sAuthor
.LoadString(IDS_LOG_AUTHOR
);
2310 sDate
.LoadString(IDS_LOG_DATE
);
2312 sMessage
.LoadString(IDS_LOG_MESSAGE
);
2316 CString sLogCopyText
;
2318 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
)));
2320 if (toCopy
== ID_COPY_ALL
)
2322 //pLogEntry->GetFiles(this)
2323 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
2325 CString
from(MAKEINTRESOURCE(IDS_STATUSLIST_FROM
));
2326 for (int cpPathIndex
= 0; cpPathIndex
<pLogEntry
->GetFiles(this).GetCount(); ++cpPathIndex
)
2328 sPaths
+= ((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetActionName() + _T(": ") + pLogEntry
->GetFiles(this)[cpPathIndex
].GetGitPathString();
2329 if (((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).m_Action
& (CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_COPY
) && !((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetGitOldPathString().IsEmpty())
2332 rename
.Format(from
, ((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetGitOldPathString());
2333 sPaths
+= _T(" ") + rename
;
2335 sPaths
+= _T("\r\n");
2338 CString body
= pLogEntry
->GetBody();
2339 body
.Replace(_T("\n"), _T("\r\n"));
2340 sLogCopyText
.Format(_T("%s: %s\r\n%s: %s <%s>\r\n%s: %s\r\n%s:\r\n%s\r\n----\r\n%s\r\n\r\n"),
2341 (LPCTSTR
)sRev
, pLogEntry
->m_CommitHash
.ToString(),
2342 (LPCTSTR
)sAuthor
, (LPCTSTR
)pLogEntry
->GetAuthorName(), (LPCTSTR
)pLogEntry
->GetAuthorEmail(),
2344 (LPCTSTR
)CLoglistUtils::FormatDateAndTime(pLogEntry
->GetAuthorDate(), m_DateFormat
, true, m_bRelativeTimes
),
2345 (LPCTSTR
)sMessage
, (pLogEntry
->GetSubject().Trim() + _T("\r\n\r\n") + body
.Trim()).Trim(),
2347 sClipdata
+= sLogCopyText
;
2349 else if (toCopy
== ID_COPY_MESSAGE
)
2351 CString body
= pLogEntry
->GetBody();
2352 body
.Replace(_T("\n"), _T("\r\n"));
2353 sClipdata
+= _T("* ") + (pLogEntry
->GetSubject().Trim() + _T("\r\n\r\n") + body
.Trim()).Trim() + _T("\r\n\r\n");
2355 else if (toCopy
== ID_COPY_SUBJECT
)
2357 sClipdata
+= _T("* ") + pLogEntry
->GetSubject().Trim() + _T("\r\n\r\n");
2362 sClipdata
+= _T("\r\n");
2363 sClipdata
+= pLogEntry
->m_CommitHash
;
2368 CStringUtils::WriteAsciiStringToClipboard(sClipdata
, GetSafeHwnd());
2373 void CGitLogListBase::DiffSelectedRevWithPrevious()
2375 if (m_bThreadRunning
)
2378 int FirstSelect
=-1, LastSelect
=-1;
2379 POSITION pos
= GetFirstSelectedItemPosition();
2380 FirstSelect
= GetNextSelectedItem(pos
);
2383 LastSelect
= GetNextSelectedItem(pos
);
2386 ContextMenuAction(ID_COMPAREWITHPREVIOUS
,FirstSelect
,LastSelect
, NULL
);
2389 UpdateLogInfoLabel();
2390 int selIndex
= m_LogList
.GetSelectionMark();
2393 int selCount
= m_LogList
.GetSelectedCount();
2397 // Find selected entry in the log list
2398 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2399 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(m_LogList
.GetNextSelectedItem(pos
)));
2400 long rev1
= pLogEntry
->Rev
;
2402 CTGitPath path
= m_path
;
2404 // See how many files under the relative root were changed in selected revision
2406 LogChangedPath
* changed
= NULL
;
2407 for (INT_PTR c
= 0; c
< pLogEntry
->pArChangedPaths
->GetCount(); ++c
)
2409 LogChangedPath
* cpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(c
);
2410 if (cpath
&& cpath
-> sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
2417 if (m_path
.IsDirectory() && nChanged
== 1)
2419 // We're looking at the log for a directory and only one file under dir was changed in the revision
2420 // Do diff on that file instead of whole directory
2421 path
.AppendPathString(changed
->sPath
.Mid(m_sRelativeRoot
.GetLength()));
2424 m_bCancelled
= FALSE
;
2425 DialogEnableWindow(IDOK
, FALSE
);
2426 SetPromptApp(&theApp
);
2427 theApp
.DoWaitCursor(1);
2431 GitDiff
diff(this, m_hWnd
, true);
2432 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
2433 diff
.SetHEADPeg(m_LogRevision
);
2434 diff
.ShowCompare(path
, rev2
, path
, rev1
);
2438 CAppUtils::StartShowCompare(m_hWnd
, path
, rev2
, path
, rev1
, GitRev(), m_LogRevision
, !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
2441 theApp
.DoWaitCursor(-1);
2446 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2448 LPNMLVFINDITEM pFindInfo
= reinterpret_cast<LPNMLVFINDITEM
>(pNMHDR
);
2451 if (pFindInfo
->lvfi
.flags
& LVFI_PARAM
)
2453 if ((pFindInfo
->iStart
< 0)||(pFindInfo
->iStart
>= m_arShownList
.GetCount()))
2455 if (pFindInfo
->lvfi
.psz
== 0)
2458 CString sCmp
= pFindInfo
->lvfi
.psz
;
2460 for (int i
=pFindInfo
->iStart
; i
<m_arShownList
.GetCount(); ++i
)
2462 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(i
));
2463 sRev
.Format(_T("%ld"), pLogEntry
->Rev
);
2464 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
2466 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
2474 if (sCmp
.Compare(sRev
)==0)
2481 if (pFindInfo
->lvfi
.flags
& LVFI_WRAP
)
2483 for (int i
=0; i
<pFindInfo
->iStart
; ++i
)
2485 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(i
));
2486 sRev
.Format(_T("%ld"), pLogEntry
->Rev
);
2487 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
2489 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
2497 if (sCmp
.Compare(sRev
)==0)
2509 int CGitLogListBase::FillGitLog(CTGitPath
*path
, CString
*range
, int info
)
2513 this->m_arShownList
.SafeRemoveAll();
2515 this->m_logEntries
.ClearAll();
2516 if (this->m_logEntries
.ParserFromLog(path
, -1, info
, range
))
2519 //this->m_logEntries.ParserFromLog();
2520 SetItemCountEx((int)m_logEntries
.size());
2522 for (unsigned int i
= 0; i
< m_logEntries
.size(); ++i
)
2526 m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1).m_IsFull
=TRUE
;
2527 this->m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1));
2532 m_logEntries
.GetGitRevAt(i
).m_IsFull
=TRUE
;
2533 this->m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2545 int CGitLogListBase::FillGitLog(std::set
<CGitHash
>& hashes
)
2549 m_arShownList
.SafeRemoveAll();
2551 m_logEntries
.ClearAll();
2552 if (m_logEntries
.Fill(hashes
))
2555 SetItemCountEx((int)m_logEntries
.size());
2557 for (unsigned int i
= 0; i
< m_logEntries
.size(); ++i
)
2561 m_logEntries
.GetGitRevAt(m_logEntries
.size() - i
- 1).m_IsFull
= TRUE
;
2562 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(m_logEntries
.size() - i
- 1));
2566 m_logEntries
.GetGitRevAt(i
).m_IsFull
= TRUE
;
2567 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2576 int CGitLogListBase::BeginFetchLog()
2580 this->m_arShownList
.SafeRemoveAll();
2582 this->m_logEntries
.ClearAll();
2584 this->m_LogCache
.ClearAllParent();
2586 m_LogCache
.FetchCacheIndex(g_Git
.m_CurrentDir
);
2589 if(this->m_Path
.IsEmpty())
2595 mask
= CGit::LOG_INFO_ONLY_HASH
;
2596 if (m_bIncludeBoundaryCommits
)
2597 mask
|= CGit::LOG_INFO_BOUNDARY
;
2598 // if(this->m_bAllBranch)
2599 mask
|= m_ShowMask
;
2603 this->m_logEntries
.insert(m_logEntries
.begin(),this->m_wcRev
.m_CommitHash
);
2605 this->m_LogCache
.m_HashMap
[m_wcRev
.m_CommitHash
]=m_wcRev
;
2608 if (m_sRange
.IsEmpty())
2609 m_sRange
= _T("HEAD");
2612 data
.m_From
= m_From
;
2615 #if 0 /* use tortoiegit filter */
2616 if(this->m_nSelectedFilter
== LOGFILTER_ALL
|| m_nSelectedFilter
== LOGFILTER_AUTHORS
)
2617 data
.m_Author
= this->m_sFilterText
;
2619 if(this->m_nSelectedFilter
== LOGFILTER_ALL
|| m_nSelectedFilter
== LOGFILTER_MESSAGES
)
2620 data
.m_MessageFilter
= this->m_sFilterText
;
2622 data
.m_IsRegex
= m_bFilterWithRegex
;
2625 // follow does not work for directories
2626 if (!path
|| path
->IsDirectory())
2627 mask
&= ~CGit::LOG_INFO_FOLLOW
;
2628 // follow does not work with all branches 8at least in TGit)
2629 if (mask
& CGit::LOG_INFO_FOLLOW
)
2630 mask
&= ~CGit::LOG_INFO_ALL_BRANCH
| CGit::LOG_INFO_LOCAL_BRANCHES
;
2632 CString cmd
= g_Git
.GetLogCmd(m_sRange
, path
, -1, mask
, true, &data
);
2634 //this->m_logEntries.ParserFromLog();
2635 if(IsInWorkingThread())
2637 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
);
2641 SetItemCountEx((int)m_logEntries
.size());
2646 [] { git_init(); } ();
2651 MessageBox(_T("Could not initialize libgit.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2655 if (!g_Git
.CanParseRev(m_sRange
))
2657 if (!(mask
& CGit::LOG_INFO_ALL_BRANCH
) && !(mask
& CGit::LOG_INFO_LOCAL_BRANCHES
))
2660 // if show all branches, pick any ref as dummy entry ref
2662 if (g_Git
.GetRefList(list
))
2663 MessageBox(g_Git
.GetGitLastErr(_T("Could not get all refs.")), _T("TortoiseGit"), MB_ICONERROR
);
2664 if (list
.size() == 0)
2667 cmd
= g_Git
.GetLogCmd(list
[0], path
, -1, mask
, true, &data
);
2670 g_Git
.m_critGitDllSec
.Lock();
2672 if (git_open_log(&m_DllGitLog
, CUnicodeUtils::GetMulti(cmd
, CP_UTF8
).GetBuffer()))
2674 g_Git
.m_critGitDllSec
.Unlock();
2680 g_Git
.m_critGitDllSec
.Unlock();
2682 MessageBox(_T("Could not open log.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2685 g_Git
.m_critGitDllSec
.Unlock();
2690 BOOL
CGitLogListBase::PreTranslateMessage(MSG
* pMsg
)
2692 if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='\r')
2694 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
2696 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
2698 DiffSelectedRevWithPrevious();
2703 if (GetFocus()==GetDlgItem(IDC_LOGMSG
))
2710 else if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
== 'A' && GetAsyncKeyState(VK_CONTROL
)&0x8000)
2712 // select all entries
2713 for (int i
=0; i
<GetItemCount(); ++i
)
2715 SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
2721 if (m_hAccel
&& !bSkipAccelerator
)
2723 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
2729 //m_tooltips.RelayEvent(pMsg);
2730 return __super::PreTranslateMessage(pMsg
);
2733 void CGitLogListBase::OnNMDblclkLoglist(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2735 // a double click on an entry in the revision list has happened
2738 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
2739 DiffSelectedRevWithPrevious();
2742 int CGitLogListBase::FetchLogAsync(void * data
)
2746 m_bExitThread
=FALSE
;
2747 InterlockedExchange(&m_bThreadRunning
, TRUE
);
2748 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2749 m_LoadingThread
= AfxBeginThread(LogThreadEntry
, this, THREAD_PRIORITY_LOWEST
);
2750 if (m_LoadingThread
==NULL
)
2752 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2753 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2754 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
2760 UINT
CGitLogListBase::LogThreadEntry(LPVOID pVoid
)
2762 return ((CGitLogListBase
*)pVoid
)->LogThread();
2765 void CGitLogListBase::GetTimeRange(CTime
&oldest
, CTime
&latest
)
2768 oldest
=CTime::GetCurrentTime();
2769 latest
=CTime(1971,1,2,0,0,0);
2770 for (unsigned int i
= 0; i
< m_logEntries
.size(); ++i
)
2772 if(m_logEntries
[i
].IsEmpty())
2775 if(m_logEntries
.GetGitRevAt(i
).GetAuthorDate().GetTime() < oldest
.GetTime())
2776 oldest
= m_logEntries
.GetGitRevAt(i
).GetAuthorDate().GetTime();
2778 if(m_logEntries
.GetGitRevAt(i
).GetAuthorDate().GetTime() > latest
.GetTime())
2779 latest
= m_logEntries
.GetGitRevAt(i
).GetAuthorDate().GetTime();
2787 UINT
CGitLogListBase::LogThread()
2789 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_START
,0);
2791 InterlockedExchange(&m_bThreadRunning
, TRUE
);
2792 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2798 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2799 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2804 std::tr1::wregex pat
;//(_T("Remove"), tr1::regex_constants::icase);
2805 bool bRegex
= false;
2806 if (m_bFilterWithRegex
)
2807 bRegex
= ValidateRegexp(m_sFilterText
, pat
, false);
2809 TRACE(_T("\n===Begin===\n"));
2810 //Update work copy item;
2812 if (!m_logEntries
.empty())
2814 GitRev
*pRev
= &m_logEntries
.GetGitRevAt(0);
2816 m_arShownList
.SafeAdd(pRev
);
2820 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2822 // store commit number of the last selected commit/line before the refresh or -1
2823 int lastSelectedHashNItem
= -1;
2826 bool shouldWalk
= true;
2827 if (!g_Git
.CanParseRev(m_sRange
))
2829 // walk revisions if show all branches and there exists any ref
2830 if (!(m_ShowMask
& CGit::LOG_INFO_ALL_BRANCH
) && !(m_ShowMask
& CGit::LOG_INFO_LOCAL_BRANCHES
))
2835 if (g_Git
.GetRefList(list
))
2836 MessageBox(g_Git
.GetGitLastErr(_T("Could not get all refs.")), _T("TortoiseGit"), MB_ICONERROR
);
2837 if (list
.size() == 0)
2844 g_Git
.m_critGitDllSec
.Lock();
2848 [&] {git_get_log_firstcommit(m_DllGitLog
);}();
2849 total
= git_get_log_estimate_commit_count(m_DllGitLog
);
2854 MessageBox(_T("Could not get first commit.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2857 g_Git
.m_critGitDllSec
.Unlock();
2860 t2
=t1
=GetTickCount();
2861 int oldprecentage
= 0;
2862 size_t oldsize
= m_logEntries
.size();
2863 std::map
<CGitHash
, std::set
<CGitHash
>> commitChildren
;
2864 while (ret
== 0 && !m_bExitThread
)
2866 g_Git
.m_critGitDllSec
.Lock();
2869 [&] { ret
= git_get_log_nextcommit(this->m_DllGitLog
, &commit
, m_ShowMask
& CGit::LOG_INFO_FOLLOW
); } ();
2873 g_Git
.m_critGitDllSec
.Unlock();
2875 MessageBox(_T("Could not get next commit.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2878 g_Git
.m_critGitDllSec
.Unlock();
2882 if (ret
!= -2) // other than end of revision walking
2883 MessageBox((_T("Could not get next commit.\nlibgit returns:") + std::to_wstring(ret
)).c_str(), _T("TortoiseGit"), MB_ICONERROR
);
2887 if (commit
.m_ignore
== 1)
2889 git_free_commit(&commit
);
2893 //printf("%s\r\n",commit.GetSubject());
2897 CGitHash hash
= (char*)commit
.m_hash
;
2899 GitRev
*pRev
= m_LogCache
.GetCacheData(hash
);
2900 pRev
->m_GitCommit
= commit
;
2901 InterlockedExchange(&pRev
->m_IsCommitParsed
, FALSE
);
2904 g_Git
.m_critGitDllSec
.Lock();
2907 git_get_notes(commit
.m_hash
, ¬e
);
2911 g_Git
.m_critGitDllSec
.Unlock();
2913 MessageBox(_T("Could not get commit notes.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2916 g_Git
.m_critGitDllSec
.Unlock();
2920 pRev
->m_Notes
.Empty();
2921 g_Git
.StringAppend(&pRev
->m_Notes
,(BYTE
*)note
);
2926 if(!pRev
->m_IsDiffFiles
)
2928 pRev
->m_CallDiffAsync
= DiffAsync
;
2931 pRev
->ParserParentFromCommit(&commit
);
2932 if (m_ShowFilter
& FILTERSHOW_MERGEPOINTS
) // See also ShouldShowFilter()
2934 for (size_t i
= 0; i
< pRev
->m_ParentHash
.size(); ++i
)
2936 const CGitHash
&parentHash
= pRev
->m_ParentHash
[i
];
2937 auto it
= commitChildren
.find(parentHash
);
2938 if (it
== commitChildren
.end())
2940 it
= commitChildren
.insert(make_pair(parentHash
, std::set
<CGitHash
>())).first
;
2942 it
->second
.insert(pRev
->m_CommitHash
);
2951 bool visible
= true;
2952 if (HasFilterText())
2954 if(!IsMatchFilter(bRegex
,pRev
,pat
))
2957 if (visible
&& !ShouldShowFilter(pRev
, commitChildren
))
2959 this->m_critSec
.Lock();
2960 m_logEntries
.append(hash
, visible
);
2962 m_arShownList
.SafeAdd(pRev
);
2963 this->m_critSec
.Unlock();
2968 if (lastSelectedHashNItem
== -1 && hash
== m_lastSelectedHash
)
2969 lastSelectedHashNItem
= (int)m_arShownList
.GetCount() - 1;
2973 if(t2
-t1
>500 || (m_logEntries
.size()-oldsize
>100))
2976 int percent
= (int)m_logEntries
.size() * 100 / total
+ GITLOG_START
+ 1;
2979 if(percent
< GITLOG_START
)
2980 percent
= GITLOG_START
+1;
2982 oldsize
= m_logEntries
.size();
2983 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
2985 //if( percent > oldprecentage )
2987 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) percent
,0);
2988 oldprecentage
= percent
;
2991 if (lastSelectedHashNItem
>= 0)
2992 PostMessage(m_ScrollToMessage
, lastSelectedHashNItem
);
2997 g_Git
.m_critGitDllSec
.Lock();
2998 git_close_log(m_DllGitLog
);
2999 g_Git
.m_critGitDllSec
.Unlock();
3005 InterlockedExchange(&m_bThreadRunning
, FALSE
);
3010 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
3012 if (lastSelectedHashNItem
>= 0)
3013 PostMessage(m_ScrollToMessage
, lastSelectedHashNItem
);
3016 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_END
,0);
3018 InterlockedExchange(&m_bThreadRunning
, FALSE
);
3023 void CGitLogListBase::FetchRemoteList()
3025 STRING_VECTOR remoteList
;
3026 if (!g_Git
.GetRemoteList(remoteList
))
3027 m_SingleRemote
= remoteList
.size() == 1 ? remoteList
[0] : _T("");
3029 m_SingleRemote
= _T("");
3032 void CGitLogListBase::FetchTrackingBranchList()
3034 m_TrackingMap
.clear();
3035 for (MAP_HASH_NAME::iterator it
= m_HashMap
.begin(); it
!= m_HashMap
.end(); ++it
)
3037 for (size_t j
= 0; j
< it
->second
.size(); ++j
)
3040 if (CGit::GetShortName(it
->second
[j
], branchName
, _T("refs/heads/")))
3042 CString pullRemote
, pullBranch
;
3043 g_Git
.GetRemoteTrackedBranch(branchName
, pullRemote
, pullBranch
);
3044 if (!pullRemote
.IsEmpty() && !pullBranch
.IsEmpty())
3046 m_TrackingMap
[branchName
] = std::make_pair(pullRemote
, pullBranch
);
3053 void CGitLogListBase::Refresh(BOOL IsCleanFilter
)
3055 SafeTerminateThread();
3057 this->SetItemCountEx(0);
3062 // HACK to hide graph column
3063 if (m_ShowMask
& CGit::LOG_INFO_FOLLOW
)
3064 SetColumnWidth(0, 0);
3066 SetColumnWidth(0, m_ColumnManager
.GetWidth(0, false));
3068 //Update branch and Tag info
3070 //Assume Thread have exited
3071 //if(!m_bThreadRunning)
3073 m_logEntries
.clear();
3077 m_sFilterText
.Empty();
3082 InterlockedExchange(&m_bExitThread
,FALSE
);
3084 InterlockedExchange(&m_bThreadRunning
, TRUE
);
3085 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3086 if ( (m_LoadingThread
=AfxBeginThread(LogThreadEntry
, this)) ==NULL
)
3088 InterlockedExchange(&m_bThreadRunning
, FALSE
);
3089 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3090 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
3094 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str
, std::tr1::wregex
& pat
, bool bMatchCase
/* = false */)
3098 std::tr1::regex_constants::syntax_option_type type
= std::tr1::regex_constants::ECMAScript
;
3100 type
|= std::tr1::regex_constants::icase
;
3101 pat
= std::tr1::wregex(regexp_str
, type
);
3104 catch (std::exception
) {}
3107 BOOL
CGitLogListBase::IsMatchFilter(bool bRegex
, GitRev
*pRev
, std::tr1::wregex
&pat
)
3110 std::tr1::regex_constants::match_flag_type flags
= std::tr1::regex_constants::match_any
;
3113 if ((bRegex
)&&(m_bFilterWithRegex
))
3115 if (m_SelectedFilters
& LOGFILTER_BUGID
)
3117 if(this->m_bShowBugtraqColumn
)
3119 CString sBugIds
= m_ProjectProperties
.FindBugID(pRev
->GetSubject() + _T("\r\n\r\n") + pRev
->GetBody());
3121 ATLTRACE(_T("bugID = \"%s\"\n"), sBugIds
);
3122 if (std::regex_search(std::wstring(sBugIds
), pat
, flags
))
3129 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
3131 ATLTRACE(_T("messge = \"%s\"\n"), pRev
->GetSubject());
3132 if (std::regex_search(std::wstring((LPCTSTR
)pRev
->GetSubject()), pat
, flags
))
3138 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
3140 ATLTRACE(_T("messge = \"%s\"\n"),pRev
->GetBody());
3141 if (std::regex_search(std::wstring((LPCTSTR
)pRev
->GetBody()), pat
, flags
))
3147 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
3149 if (std::regex_search(std::wstring(pRev
->GetAuthorName()), pat
, flags
))
3154 if (std::regex_search(std::wstring(pRev
->GetCommitterName()), pat
, flags
))
3160 if (m_SelectedFilters
& LOGFILTER_EMAILS
)
3162 if (std::regex_search(std::wstring(pRev
->GetAuthorEmail()), pat
, flags
))
3167 if (std::regex_search(std::wstring(pRev
->GetCommitterEmail()), pat
, flags
))
3173 if (m_SelectedFilters
& LOGFILTER_REVS
)
3175 sRev
.Format(_T("%s"), pRev
->m_CommitHash
.ToString());
3176 if (std::regex_search(std::wstring((LPCTSTR
)sRev
), pat
, flags
))
3182 if (m_SelectedFilters
& LOGFILTER_REFNAME
)
3184 STRING_VECTOR refs
= m_HashMap
[pRev
->m_CommitHash
];
3185 for (auto it
= refs
.cbegin(); it
!= refs
.cend(); ++it
)
3187 if (std::regex_search(std::wstring((LPCTSTR
)*it
), pat
, flags
))
3194 if (m_SelectedFilters
& LOGFILTER_PATHS
)
3196 CTGitPathList
*pathList
=NULL
;
3197 if( pRev
->m_IsDiffFiles
)
3198 pathList
= &pRev
->GetFiles(this);
3201 if(!pRev
->m_IsSimpleListReady
)
3202 pRev
->SafeGetSimpleList(&g_Git
);
3206 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
->GetCount(); ++cpPathIndex
)
3208 if (std::regex_search(std::wstring((LPCTSTR
)pathList
->m_paths
.at(cpPathIndex
).GetGitOldPathString()), pat
, flags
))
3212 if (std::regex_search(std::wstring((LPCTSTR
)pathList
->m_paths
.at(cpPathIndex
).GetGitPathString()), pat
, flags
))
3218 for (size_t i
= 0; i
< pRev
->m_SimpleFileList
.size(); ++i
)
3220 if (std::regex_search(std::wstring((LPCTSTR
)pRev
->m_SimpleFileList
[i
]), pat
, flags
))
3229 CString find
= m_sFilterText
;
3231 result
= find
[0] == '!' ? FALSE
: TRUE
;
3235 if (m_SelectedFilters
& LOGFILTER_BUGID
)
3237 if(this->m_bShowBugtraqColumn
)
3239 CString sBugIds
= m_ProjectProperties
.FindBugID(pRev
->GetSubject() + _T("\r\n\r\n") + pRev
->GetBody());
3241 sBugIds
.MakeLower();
3242 if ((sBugIds
.Find(find
) >= 0))
3249 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
3251 CString msg
= pRev
->GetSubject();
3253 msg
= msg
.MakeLower();
3254 if ((msg
.Find(find
) >= 0))
3260 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
3262 CString msg
= pRev
->GetBody();
3264 msg
= msg
.MakeLower();
3265 if ((msg
.Find(find
) >= 0))
3271 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
3273 CString msg
= pRev
->GetAuthorName();
3274 msg
= msg
.MakeLower();
3275 if ((msg
.Find(find
) >= 0))
3281 if (m_SelectedFilters
& LOGFILTER_EMAILS
)
3283 CString msg
= pRev
->GetAuthorEmail();
3284 msg
= msg
.MakeLower();
3285 if ((msg
.Find(find
) >= 0))
3291 if (m_SelectedFilters
& LOGFILTER_REVS
)
3293 sRev
.Format(_T("%s"), pRev
->m_CommitHash
.ToString());
3294 if ((sRev
.Find(find
) >= 0))
3300 if (m_SelectedFilters
& LOGFILTER_REFNAME
)
3302 STRING_VECTOR refs
= m_HashMap
[pRev
->m_CommitHash
];
3303 for (auto it
= refs
.cbegin(); it
!= refs
.cend(); ++it
)
3305 if (it
->Find(find
) >= 0)
3312 if (m_SelectedFilters
& LOGFILTER_PATHS
)
3314 CTGitPathList
*pathList
=NULL
;
3315 if( pRev
->m_IsDiffFiles
)
3316 pathList
= &pRev
->GetFiles(this);
3319 if(!pRev
->m_IsSimpleListReady
)
3320 pRev
->SafeGetSimpleList(&g_Git
);
3323 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
->GetCount() ; ++cpPathIndex
)
3325 CTGitPath
*cpath
= &pathList
->m_paths
.at(cpPathIndex
);
3326 CString path
= cpath
->GetGitOldPathString();
3328 if ((path
.Find(find
)>=0))
3332 path
= cpath
->GetGitPathString();
3334 if ((path
.Find(find
)>=0))
3340 for (size_t i
= 0; i
< pRev
->m_SimpleFileList
.size(); ++i
)
3342 CString path
= pRev
->m_SimpleFileList
[i
];
3344 if ((path
.Find(find
)>=0))
3350 } // else (from if (bRegex))
3354 static bool CStringStartsWith(const CString
&str
, const CString
&prefix
)
3356 return str
.Left(prefix
.GetLength()) == prefix
;
3358 bool CGitLogListBase::ShouldShowFilter(GitRev
*pRev
, const std::map
<CGitHash
, std::set
<CGitHash
>> &commitChildren
)
3360 if (m_ShowFilter
& FILTERSHOW_ANYCOMMIT
)
3363 if (m_ShowFilter
& FILTERSHOW_REFS
)
3366 const STRING_VECTOR
&refList
= m_HashMap
[pRev
->m_CommitHash
];
3367 for (size_t i
= 0; i
< refList
.size(); ++i
)
3369 const CString
&str
= refList
[i
];
3370 if (CStringStartsWith(str
, _T("refs/heads/")))
3372 if (m_ShowRefMask
& LOGLIST_SHOWLOCALBRANCHES
)
3375 else if (CStringStartsWith(str
, _T("refs/remotes/")))
3377 if (m_ShowRefMask
& LOGLIST_SHOWREMOTEBRANCHES
)
3380 else if (CStringStartsWith(str
, _T("refs/tags/")))
3382 if (m_ShowRefMask
& LOGLIST_SHOWTAGS
)
3385 else if (CStringStartsWith(str
, _T("refs/stash")))
3387 if (m_ShowRefMask
& LOGLIST_SHOWSTASH
)
3390 else if (CStringStartsWith(str
, _T("refs/bisect/")))
3392 if (m_ShowRefMask
& LOGLIST_SHOWBISECT
)
3396 // Keep the head too.
3397 if (pRev
->m_CommitHash
== m_HeadHash
)
3401 if (m_ShowFilter
& FILTERSHOW_MERGEPOINTS
)
3403 if (pRev
->ParentsCount() > 1)
3405 auto childrenIt
= commitChildren
.find(pRev
->m_CommitHash
);
3406 if (childrenIt
!= commitChildren
.end())
3408 const std::set
<CGitHash
> &children
= childrenIt
->second
;
3409 if (children
.size() > 1)
3416 void CGitLogListBase::ShowGraphColumn(bool bShow
)
3418 // HACK to hide graph column
3420 SetColumnWidth(0, m_ColumnManager
.GetWidth(0, false));
3422 SetColumnWidth(0, 0);
3425 CString
CGitLogListBase::GetTagInfo(GitRev
* pLogEntry
)
3430 if (m_HashMap
.find(pLogEntry
->m_CommitHash
) != m_HashMap
.end())
3432 STRING_VECTOR
&vector
= m_HashMap
[pLogEntry
->m_CommitHash
];
3433 for (size_t i
= 0; i
< vector
.size(); ++i
)
3435 if (vector
[i
].Find(_T("refs/tags/")) == 0)
3437 CString tag
= vector
[i
];
3438 int start
= vector
[i
].Find(_T("^{}"));
3440 tag
= tag
.Left(start
);
3444 cmd
.Format(_T("git.exe cat-file tag %s"), tag
);
3445 if (g_Git
.Run(cmd
, &output
, nullptr, CP_UTF8
) == 0)
3446 output
.AppendChar(_T('\n'));
3454 void CGitLogListBase::RecalculateShownList(CThreadSafePtrArray
* pShownlist
)
3457 pShownlist
->SafeRemoveAll();
3459 std::tr1::wregex pat
;//(_T("Remove"), tr1::regex_constants::icase);
3460 bool bRegex
= false;
3461 if (m_bFilterWithRegex
)
3462 bRegex
= ValidateRegexp(m_sFilterText
, pat
, false);
3464 std::tr1::regex_constants::match_flag_type flags
= std::tr1::regex_constants::match_any
;
3466 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
3468 if ((bRegex
)&&(m_bFilterWithRegex
))
3471 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_BUGID
))
3473 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR
)m_logEntries
[i
]->sBugIDs
);
3474 if (std::regex_search(std::wstring((LPCTSTR
)m_logEntries
[i
]->sBugIDs
), pat
, flags
)&&IsEntryInDateRange(i
))
3476 pShownlist
->SafeAdd(m_logEntries
[i
]);
3481 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
3483 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries
.GetGitRevAt(i
).GetSubject());
3484 if (std::regex_search(std::wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).GetSubject()), pat
, flags
)&&IsEntryInDateRange(i
))
3486 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3490 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
3492 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries
.GetGitRevAt(i
).GetBody());
3493 if (std::regex_search(std::wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).GetBody()), pat
, flags
)&&IsEntryInDateRange(i
))
3495 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3499 if (m_SelectedFilters
& LOGFILTER_PATHS
)
3501 CTGitPathList pathList
= m_logEntries
.GetGitRevAt(i
).GetFiles(this);
3504 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
.GetCount() && bGoing
; ++cpPathIndex
)
3506 CTGitPath cpath
= pathList
[cpPathIndex
];
3507 if (std::regex_search(std::wstring((LPCTSTR
)cpath
.GetGitOldPathString()), pat
, flags
)&&IsEntryInDateRange(i
))
3509 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3513 if (std::regex_search(std::wstring((LPCTSTR
)cpath
.GetGitPathString()), pat
, flags
)&&IsEntryInDateRange(i
))
3515 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3519 if (std::regex_search(std::wstring((LPCTSTR
)cpath
.GetActionName()), pat
, flags
)&&IsEntryInDateRange(i
))
3521 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3527 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
3529 if (std::regex_search(std::wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).GetAuthorName()), pat
, flags
)&&IsEntryInDateRange(i
))
3531 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3535 if (m_SelectedFilters
& LOGFILTER_EMAILS
)
3537 if (std::regex_search(std::wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).GetAuthorEmail()), pat
, flags
) && IsEntryInDateRange(i
))
3539 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3543 if (m_SelectedFilters
& LOGFILTER_REVS
)
3545 sRev
.Format(_T("%s"), m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString());
3546 if (std::regex_search(std::wstring((LPCTSTR
)sRev
), pat
, flags
)&&IsEntryInDateRange(i
))
3548 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3552 if (m_SelectedFilters
& LOGFILTER_REFNAME
)
3554 STRING_VECTOR refs
= m_HashMap
[m_logEntries
.GetGitRevAt(i
).m_CommitHash
];
3555 for (auto it
= refs
.cbegin(); it
!= refs
.cend(); ++it
)
3557 if (std::regex_search(std::wstring((LPCTSTR
)*it
), pat
, flags
) && IsEntryInDateRange(i
))
3559 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3567 CString find
= m_sFilterText
;
3570 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_BUGID
))
3572 CString sBugIDs
= m_logEntries
[i
]->sBugIDs
;
3574 sBugIDs
= sBugIDs
.MakeLower();
3575 if ((sBugIDs
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3577 pShownlist
->SafeAdd(m_logEntries
[i
]);
3582 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
3584 CString msg
= m_logEntries
.GetGitRevAt(i
).GetSubject();
3586 msg
= msg
.MakeLower();
3587 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3589 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3593 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
3595 CString msg
= m_logEntries
.GetGitRevAt(i
).GetBody();
3597 msg
= msg
.MakeLower();
3598 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3600 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3604 if (m_SelectedFilters
& LOGFILTER_PATHS
)
3606 CTGitPathList pathList
= m_logEntries
.GetGitRevAt(i
).GetFiles(this);
3609 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
.GetCount() && bGoing
; ++cpPathIndex
)
3611 CTGitPath cpath
= pathList
[cpPathIndex
];
3612 CString path
= cpath
.GetGitOldPathString();
3614 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
3616 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3620 path
= cpath
.GetGitPathString();
3622 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
3624 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3628 path
= cpath
.GetActionName();
3630 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
3632 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3638 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
3640 CString msg
= m_logEntries
.GetGitRevAt(i
).GetAuthorName();
3641 msg
= msg
.MakeLower();
3642 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3644 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3648 if (m_SelectedFilters
& LOGFILTER_EMAILS
)
3650 CString msg
= m_logEntries
.GetGitRevAt(i
).GetAuthorEmail();
3651 msg
= msg
.MakeLower();
3652 if ((msg
.Find(find
) >= 0) && (IsEntryInDateRange(i
)))
3654 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3658 if (m_SelectedFilters
& LOGFILTER_REVS
)
3660 sRev
.Format(_T("%s"), m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString());
3661 if ((sRev
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3663 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3667 if (m_SelectedFilters
& LOGFILTER_REFNAME
)
3669 STRING_VECTOR refs
= m_HashMap
[m_logEntries
.GetGitRevAt(i
).m_CommitHash
];
3670 for (auto it
= refs
.cbegin(); it
!= refs
.cend(); ++it
)
3672 if (it
->Find(find
) >= 0 && IsEntryInDateRange(i
))
3674 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3679 } // else (from if (bRegex))
3680 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
3684 BOOL
CGitLogListBase::IsEntryInDateRange(int /*i*/)
3687 __time64_t time = m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime();
3693 return time <= m_To;
3696 return time >= m_From;
3698 return ((time >= m_From)&&(time <= m_To));
3700 return TRUE
; /* git dll will filter time range */
3704 void CGitLogListBase::StartFilter()
3706 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3707 RecalculateShownList(&m_arShownList
);
3708 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3712 SetItemCountEx(ShownCountWithStopped());
3713 RedrawItems(0, ShownCountWithStopped());
3717 void CGitLogListBase::RemoveFilter()
3720 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3722 m_arShownList
.SafeRemoveAll();
3724 // reset the time filter too
3726 m_timFrom
= (__time64_t(m_tFrom
));
3727 m_timTo
= (__time64_t(m_tTo
));
3728 m_DateFrom
.SetTime(&m_timFrom
);
3729 m_DateTo
.SetTime(&m_timTo
);
3730 m_DateFrom
.SetRange(&m_timFrom
, &m_timTo
);
3731 m_DateTo
.SetRange(&m_timFrom
, &m_timTo
);
3734 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
3736 if(this->m_IsOldFirst
)
3738 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1));
3742 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3745 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
3747 SetItemCountEx(ShownCountWithStopped());
3748 RedrawItems(0, ShownCountWithStopped());
3750 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3753 void CGitLogListBase::Clear()
3755 m_arShownList
.SafeRemoveAll();
3758 m_logEntries
.ClearAll();
3762 void CGitLogListBase::OnDestroy()
3764 // save the column widths to the registry
3767 SafeTerminateThread();
3768 SafeTerminateAsyncDiffThread();
3771 while(m_LogCache
.SaveCache())
3779 //if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
3780 // MB_YESNO) == IDNO)
3784 CHintListCtrl::OnDestroy();
3787 LRESULT
CGitLogListBase::OnLoad(WPARAM wParam
,LPARAM
/*lParam*/)
3791 this->GetItemRect(i
,&rect
,LVIR_BOUNDS
);
3792 this->InvalidateRect(rect
);
3798 * Save column widths to the registry
3800 void CGitLogListBase::SaveColumnWidths()
3802 int maxcol
= m_ColumnManager
.GetColumnCount();
3804 // HACK that graph column is always shown
3805 SetColumnWidth(0, m_ColumnManager
.GetWidth(0, false));
3807 for (int col
= 0; col
< maxcol
; ++col
)
3808 if (m_ColumnManager
.IsVisible (col
))
3809 m_ColumnManager
.ColumnResized (col
);
3811 m_ColumnManager
.WriteSettings();
3814 int CGitLogListBase::GetHeadIndex()
3816 if(m_HeadHash
.IsEmpty())
3819 for (int i
= 0; i
< m_arShownList
.GetCount(); ++i
)
3821 GitRev
*pRev
= (GitRev
*)m_arShownList
.SafeGetAt(i
);
3824 if(pRev
->m_CommitHash
.ToString() == m_HeadHash
)
3830 void CGitLogListBase::OnFind()
3834 m_pFindDialog
= new CFindDlg(this);
3835 m_pFindDialog
->Create(this);
3838 void CGitLogListBase::OnHdnBegintrack(NMHDR
*pNMHDR
, LRESULT
*pResult
)
3840 m_ColumnManager
.OnHdnBegintrack(pNMHDR
, pResult
);
3842 void CGitLogListBase::OnHdnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
)
3844 if(!m_ColumnManager
.OnHdnItemchanging(pNMHDR
, pResult
))
3847 LRESULT
CGitLogListBase::OnScrollToMessage(WPARAM itemToSelect
, LPARAM
/*lParam*/)
3849 if (GetSelectedCount() != 0)
3852 CGitHash theSelectedHash
= m_lastSelectedHash
;
3853 SetItemState((int)itemToSelect
, LVIS_SELECTED
| LVIS_FOCUSED
, LVIS_SELECTED
| LVIS_FOCUSED
);
3854 m_lastSelectedHash
= theSelectedHash
;
3856 int countPerPage
= GetCountPerPage();
3857 EnsureVisible(max(0, (int)itemToSelect
-countPerPage
/2), FALSE
);
3858 EnsureVisible(min(GetItemCount(), (int)itemToSelect
+countPerPage
/2), FALSE
);
3859 EnsureVisible((int)itemToSelect
, FALSE
);
3862 LRESULT
CGitLogListBase::OnFindDialogMessage(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
3865 ASSERT(m_pFindDialog
!= NULL
);
3866 bool bFound
= false;
3869 if (m_pFindDialog
->IsTerminating())
3871 // invalidate the handle identifying the dialog box.
3872 m_pFindDialog
= NULL
;
3876 INT_PTR cnt
= m_arShownList
.GetCount();
3878 if(m_pFindDialog
->IsRef())
3881 str
=m_pFindDialog
->GetFindString();
3887 if (g_Git
.GetHash(hash
, str
+ _T("^{}"))) // add ^{} in order to get the correct SHA-1 (especially for signed tags)
3888 MessageBox(g_Git
.GetGitLastErr(_T("Could not get hash of ref \"") + str
+ _T("^{}\".")), _T("TortoiseGit"), MB_ICONERROR
);
3893 for (i
= 0; i
< cnt
; ++i
)
3895 GitRev
* pLogEntry
= (GitRev
*)m_arShownList
.SafeGetAt(i
);
3896 if(pLogEntry
&& pLogEntry
->m_CommitHash
== hash
)
3905 m_pFindDialog
->FlashWindowEx(FLASHW_ALL
, 2, 100);
3910 if (m_pFindDialog
->FindNext() && !bFound
)
3912 //read data from dialog
3913 CString FindText
= m_pFindDialog
->GetFindString();
3914 bool bMatchCase
= (m_pFindDialog
->MatchCase() == TRUE
);
3916 std::tr1::wregex pat
;
3917 bool bRegex
= false;
3918 if (m_pFindDialog
->Regex())
3919 bRegex
= ValidateRegexp(FindText
, pat
, bMatchCase
);
3921 std::tr1::regex_constants::match_flag_type flags
= std::tr1::regex_constants::match_not_null
;
3923 for (i
= m_nSearchIndex
+ 1; ; ++i
)
3928 m_pFindDialog
->FlashWindowEx(FLASHW_ALL
, 2, 100);
3930 if (m_nSearchIndex
>= 0)
3932 if (i
== m_nSearchIndex
)
3934 ::MessageBeep(0xFFFFFFFF);
3935 m_pFindDialog
->FlashWindowEx(FLASHW_ALL
, 3, 100);
3940 GitRev
* pLogEntry
= (GitRev
*)m_arShownList
.SafeGetAt(i
);
3943 str
+=pLogEntry
->m_CommitHash
.ToString();
3946 for (size_t j
= 0; j
< this->m_HashMap
[pLogEntry
->m_CommitHash
].size(); ++j
)
3948 str
+=m_HashMap
[pLogEntry
->m_CommitHash
][j
];
3952 str
+=pLogEntry
->GetAuthorEmail();
3954 str
+=pLogEntry
->GetAuthorName();
3956 str
+=pLogEntry
->GetBody();
3958 str
+=pLogEntry
->GetCommitterEmail();
3960 str
+=pLogEntry
->GetCommitterName();
3962 str
+=pLogEntry
->GetSubject();
3964 str
+=pLogEntry
->m_Notes
;
3966 str
+=GetTagInfo(pLogEntry
);
3970 /*Because changed files list is loaded on demand when gui show,
3971 files will empty when files have not fetched.
3973 we can add it back by using one-way diff(with outnumber changed and rename detect.
3974 here just need changed filename list. one-way is much quicker.
3976 if(pLogEntry
->m_IsFull
)
3978 for (int i
= 0; i
< pLogEntry
->GetFiles(this).GetCount(); ++i
)
3980 str
+=pLogEntry
->GetFiles(this)[i
].GetWinPath();
3982 str
+=pLogEntry
->GetFiles(this)[i
].GetGitOldPathString();
3988 if(!pLogEntry
->m_IsSimpleListReady
)
3989 pLogEntry
->SafeGetSimpleList(&g_Git
);
3991 for (size_t i
= 0; i
< pLogEntry
->m_SimpleFileList
.size(); ++i
)
3993 str
+=pLogEntry
->m_SimpleFileList
[i
];
4002 if (std::regex_search(std::wstring(str
), pat
, flags
))
4012 if (str
.Find(FindText
) >= 0)
4022 msg
= msg
.MakeLower();
4023 CString find
= FindText
.MakeLower();
4024 if (msg
.Find(find
) >= 0)
4031 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; ++i)
4033 } // if(m_pFindDialog->FindNext())
4034 //UpdateLogInfoLabel();
4039 EnsureVisible(i
, FALSE
);
4040 SetItemState(GetSelectionMark(), 0, LVIS_SELECTED
);
4041 SetItemState(i
, LVIS_SELECTED
| LVIS_FOCUSED
, LVIS_SELECTED
| LVIS_FOCUSED
);
4042 SetSelectionMark(i
);
4043 //FillLogMessageCtrl();
4050 void CGitLogListBase::OnColumnResized(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4052 m_ColumnManager
.OnColumnResized(pNMHDR
,pResult
);
4057 void CGitLogListBase::OnColumnMoved(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4059 m_ColumnManager
.OnColumnMoved(pNMHDR
, pResult
);