1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2005-2007 Marco Costalba
5 // Copyright (C) 2011-2012 - 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"
27 //#include "VssStyle.h"
32 #include "GITProgressDlg.h"
33 #include "ProgressDlg.h"
34 //#include "RepositoryBrowser.h"
35 //#include "CopyDlg.h"
36 //#include "StatGraphDlg.h"
38 #include "MessageBox.h"
40 #include "LoglistUtils.h"
41 #include "PathUtils.h"
42 #include "StringUtils.h"
43 #include "UnicodeUtils.h"
45 //#include "GitInfo.h"
46 //#include "GitDiff.h"
48 //#include "RevisionRangeDlg.h"
49 //#include "BrowseFolder.h"
50 //#include "BlameDlg.h"
52 //#include "GitHelpers.h"
53 #include "GitStatus.h"
54 //#include "LogDlgHelper.h"
55 //#include "CachedLogInfo.h"
56 //#include "RepositoryInfo.h"
57 //#include "EditPropertiesDlg.h"
58 #include "FileDiffDlg.h"
59 #include "..\\TortoiseShell\\Resource.h"
63 const UINT
CGitLogListBase::m_FindDialogMessage
= RegisterWindowMessage(FINDMSGSTRING
);
64 const UINT
CGitLogListBase::m_ScrollToMessage
= RegisterWindowMessage(_T("TORTOISEGIT_LOG_SCROLLTO"));
66 IMPLEMENT_DYNAMIC(CGitLogListBase
, CHintListCtrl
)
68 CGitLogListBase::CGitLogListBase():CHintListCtrl()
69 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
71 ,m_bNoDispUpdates(FALSE
)
72 , m_bThreadRunning(FALSE
)
73 , m_bStrictStopped(false)
74 , m_pStoreSelection(NULL
)
75 , m_SelectedFilters(LOGFILTER_ALL
)
77 , m_logEntries(&m_LogCache
)
79 , m_ColumnManager(this)
80 , m_dwDefaultColumns(0)
81 , m_arShownList(&m_critSec
)
83 , m_bNoHightlightHead(FALSE
)
84 , m_ShowRefMask(LOGLIST_SHOWALLREFS
)
86 // use the default GUI font, create a copy of it and
87 // change the copy to BOLD (leave the rest of the font
89 HFONT hFont
= (HFONT
)GetStockObject(DEFAULT_GUI_FONT
);
91 GetObject(hFont
, sizeof(LOGFONT
), &lf
);
92 lf
.lfWeight
= FW_BOLD
;
93 m_boldFont
= CreateFontIndirect(&lf
);
95 m_bShowBugtraqColumn
=false;
97 m_IsIDReplaceAction
=FALSE
;
99 this->m_critSec
.Init();
100 m_wcRev
.m_CommitHash
.Empty();
101 m_wcRev
.GetSubject() = CString(MAKEINTRESOURCE(IDS_LOG_WORKINGDIRCHANGES
));
102 m_wcRev
.m_ParentHash
.clear();
103 m_wcRev
.m_Mark
=_T('-');
104 m_wcRev
.m_IsUpdateing
=FALSE
;
105 m_wcRev
.m_IsFull
= TRUE
;
107 m_hModifiedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
108 m_hReplacedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
109 m_hAddedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
110 m_hDeletedIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
111 m_hFetchIcon
= (HICON
)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONFETCHING
), IMAGE_ICON
, 0, 0, LR_DEFAULTSIZE
);
113 m_bFilterWithRegex
= !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE
);
115 g_Git
.GetMapHashToFriendName(m_HashMap
);
116 if (CTGitPath(g_Git
.m_CurrentDir
).HasAdminDir())
118 m_CurrentBranch
=g_Git
.GetCurrentBranch();
120 m_HeadHash
=g_Git
.GetHash(_T("HEAD"));
125 MessageBox(_T("Could not get HEAD hash. Quitting...\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
134 m_LoadingThread
= NULL
;
136 InterlockedExchange(&m_bExitThread
,FALSE
);
137 m_IsOldFirst
= FALSE
;
138 m_IsRebaseReplaceGraph
= FALSE
;
141 for(int i
=0;i
<Lanes::COLORS_NUM
;i
++)
143 m_LineColors
[i
] = m_Colors
.GetColor((CColors::Colors
)(CColors::BranchLine1
+i
));
145 // get short/long datetime setting from registry
146 DWORD RegUseShortDateFormat
= CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE
);
147 if ( RegUseShortDateFormat
)
149 m_DateFormat
= DATE_SHORTDATE
;
153 m_DateFormat
= DATE_LONGDATE
;
155 // get relative time display setting from registry
156 DWORD regRelativeTimes
= CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE
);
157 m_bRelativeTimes
= (regRelativeTimes
!= 0);
158 m_ContextMenuMask
= 0xFFFFFFFFFFFFFFFF;
160 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_PICK
);
161 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_SQUASH
);
162 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_EDIT
);
163 m_ContextMenuMask
&= ~GetContextMenuBit(ID_REBASE_SKIP
);
164 m_ContextMenuMask
&= ~GetContextMenuBit(ID_LOG
);
165 m_ContextMenuMask
&= ~GetContextMenuBit(ID_BLAME
);
167 m_ColumnRegKey
=_T("log");
169 m_AsyncThreadExit
= FALSE
;
170 m_AsyncDiffEvent
= ::CreateEvent(NULL
,FALSE
,TRUE
,NULL
);
171 m_AsynDiffListLock
.Init();
173 m_DiffingThread
= AfxBeginThread(AsyncThread
, this, THREAD_PRIORITY_BELOW_NORMAL
);
174 if (m_DiffingThread
==NULL
)
176 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
182 int CGitLogListBase::AsyncDiffThread()
184 m_AsyncThreadExited
= false;
185 while(!m_AsyncThreadExit
)
187 ::WaitForSingleObject(m_AsyncDiffEvent
, INFINITE
);
190 while(!m_AsyncThreadExit
&& !m_AsynDiffList
.empty())
192 m_AsynDiffListLock
.Lock();
193 pRev
= m_AsynDiffList
.back();
194 m_AsynDiffList
.pop_back();
195 m_AsynDiffListLock
.Unlock();
197 if( pRev
->m_CommitHash
.IsEmpty() )
199 if(pRev
->m_IsDiffFiles
)
202 pRev
->GetFiles(this).Clear();
203 pRev
->m_ParentHash
.clear();
204 pRev
->m_ParentHash
.push_back(m_HeadHash
);
205 if(g_Git
.IsInitRepos())
207 g_Git
.GetInitAddList(pRev
->GetFiles(this));
212 g_Git
.GetCommitDiffList(pRev
->m_CommitHash
.ToString(),this->m_HeadHash
.ToString(), pRev
->GetFiles(this));
214 pRev
->GetAction(this) = 0;
216 for(int j
=0;j
< pRev
->GetFiles(this).GetCount();j
++)
217 pRev
->GetAction(this) |= pRev
->GetFiles(this)[j
].m_Action
;
219 pRev
->GetUnRevFiles().FillUnRev(CTGitPath::LOGACTIONS_UNVER
);
221 InterlockedExchange(&pRev
->m_IsDiffFiles
, TRUE
);
222 InterlockedExchange(&pRev
->m_IsFull
, TRUE
);
224 pRev
->GetBody().Format(IDS_FILESCHANGES
, pRev
->GetFiles(this).GetCount());
225 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)0,0);
226 this->GetParent()->PostMessage(WM_COMMAND
, MSG_FETCHED_DIFF
, 0);
229 if(!pRev
->CheckAndDiff())
230 { // fetch change file list
231 for(int i
=GetTopIndex(); !m_AsyncThreadExit
&& i
<= GetTopIndex()+GetCountPerPage(); i
++)
233 if(i
< m_arShownList
.GetCount())
235 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(i
);
236 if(data
->m_CommitHash
== pRev
->m_CommitHash
)
238 ::PostMessage(m_hWnd
,MSG_LOADED
,(WPARAM
)i
,0);
244 if(!m_AsyncThreadExit
&& GetSelectedCount() == 1)
246 POSITION pos
= GetFirstSelectedItemPosition();
247 int nItem
= GetNextSelectedItem(pos
);
251 GitRev
* data
= (GitRev
*)m_arShownList
[nItem
];
253 if(data
->m_CommitHash
== pRev
->m_CommitHash
)
255 this->GetParent()->PostMessage(WM_COMMAND
, MSG_FETCHED_DIFF
, 0);
262 m_AsyncThreadExited
= true;
265 void CGitLogListBase::hideFromContextMenu(unsigned __int64 hideMask
, bool exclusivelyShow
)
269 m_ContextMenuMask
&= hideMask
;
273 m_ContextMenuMask
&= ~hideMask
;
277 CGitLogListBase::~CGitLogListBase()
279 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
280 this->m_arShownList
.SafeRemoveAll();
282 DestroyIcon(m_hModifiedIcon
);
283 DestroyIcon(m_hReplacedIcon
);
284 DestroyIcon(m_hAddedIcon
);
285 DestroyIcon(m_hDeletedIcon
);
286 m_logEntries
.ClearAll();
289 DeleteObject(m_boldFont
);
291 if ( m_pStoreSelection
)
293 delete m_pStoreSelection
;
294 m_pStoreSelection
= NULL
;
297 SafeTerminateThread();
298 SafeTerminateAsyncDiffThread();
301 CloseHandle(m_AsyncDiffEvent
);
305 BEGIN_MESSAGE_MAP(CGitLogListBase
, CHintListCtrl
)
306 ON_REGISTERED_MESSAGE(m_FindDialogMessage
, OnFindDialogMessage
)
307 ON_REGISTERED_MESSAGE(m_ScrollToMessage
, OnScrollToMessage
)
308 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW
, OnNMCustomdrawLoglist
)
309 ON_NOTIFY_REFLECT(LVN_GETDISPINFO
, OnLvnGetdispinfoLoglist
)
311 ON_NOTIFY_REFLECT(NM_DBLCLK
, OnNMDblclkLoglist
)
312 ON_NOTIFY_REFLECT(LVN_ODFINDITEM
,OnLvnOdfinditemLoglist
)
315 ON_MESSAGE(MSG_LOADED
,OnLoad
)
317 ON_WM_MEASUREITEM_REFLECT()
318 ON_NOTIFY(HDN_BEGINTRACKA
, 0, OnHdnBegintrack
)
319 ON_NOTIFY(HDN_BEGINTRACKW
, 0, OnHdnBegintrack
)
320 ON_NOTIFY(HDN_ITEMCHANGINGA
, 0, OnHdnItemchanging
)
321 ON_NOTIFY(HDN_ITEMCHANGINGW
, 0, OnHdnItemchanging
)
322 ON_NOTIFY(HDN_ENDTRACK
, 0, OnColumnResized
)
323 ON_NOTIFY(HDN_ENDDRAG
, 0, OnColumnMoved
)
326 void CGitLogListBase::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct
)
328 //if (m_nRowHeight>0)
330 lpMeasureItemStruct
->itemHeight
= 50;
334 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct
)
337 return CHintListCtrl::OnCreate(lpCreateStruct
);
340 void CGitLogListBase::PreSubclassWindow()
342 SetExtendedStyle(LVS_EX_FULLROWSELECT
| LVS_EX_SUBITEMIMAGES
);
343 // load the icons for the action columns
344 // m_Theme.Open(m_hWnd, L"ListView");
345 SetWindowTheme(m_hWnd
, L
"Explorer", NULL
);
346 CHintListCtrl::PreSubclassWindow();
349 void CGitLogListBase::InsertGitColumn()
353 CRegDWORD
regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE
);
354 DWORD exStyle
= LVS_EX_HEADERDRAGDROP
| LVS_EX_DOUBLEBUFFER
| LVS_EX_INFOTIP
| LVS_EX_SUBITEMIMAGES
;
355 if (DWORD(regFullRowSelect
))
356 exStyle
|= LVS_EX_FULLROWSELECT
;
357 SetExtendedStyle(exStyle
);
359 // only load properties if we have a repository
360 if (GitAdminDir().HasAdminDir(g_Git
.m_CurrentDir
) || GitAdminDir().IsBareRepo(g_Git
.m_CurrentDir
))
361 UpdateProjectProperties();
363 static UINT normal
[] =
375 IDS_LOG_COMMIT_EMAIL
,
396 m_dwDefaultColumns
= GIT_LOG_GRAPH
|GIT_LOG_ACTIONS
|GIT_LOG_MESSAGE
|GIT_LOG_AUTHOR
|GIT_LOG_DATE
;
398 DWORD hideColumns
= 0;
399 if(this->m_IsRebaseReplaceGraph
)
401 hideColumns
|= GIT_LOG_GRAPH
;
402 m_dwDefaultColumns
|= GIT_LOG_REBASE
;
406 hideColumns
|= GIT_LOG_REBASE
;
409 if(this->m_IsIDReplaceAction
)
411 hideColumns
|= GIT_LOG_ACTIONS
;
412 m_dwDefaultColumns
|= GIT_LOG_ID
;
413 m_dwDefaultColumns
|= GIT_LOG_HASH
;
417 hideColumns
|= GIT_LOG_ID
;
419 if(this->m_bShowBugtraqColumn
)
421 m_dwDefaultColumns
|= GIT_LOGLIST_BUG
;
425 hideColumns
|= GIT_LOGLIST_BUG
;
429 m_ColumnManager
.SetNames(normal
, _countof(normal
));
430 m_ColumnManager
.ReadSettings(m_dwDefaultColumns
, hideColumns
, m_ColumnRegKey
+_T("loglist"), _countof(normal
), with
);
437 * Resizes all columns in a list control to values in registry.
439 void CGitLogListBase::ResizeAllListCtrlCols()
441 // column max and min widths to allow
442 static const int nMinimumWidth
= 10;
443 static const int nMaximumWidth
= 1000;
444 CHeaderCtrl
* pHdrCtrl
= (CHeaderCtrl
*)(GetDlgItem(0));
447 int numcols
= pHdrCtrl
->GetItemCount();
448 for (int col
= 0; col
< numcols
; col
++)
450 // get width for this col last time from registry
452 regentry
.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey
, col
);
453 CRegDWORD
regwidth(regentry
, 0);
457 // no saved value, setup sensible defaults
458 if (col
== this->LOGLIST_MESSAGE
)
460 cx
= LOGLIST_MESSAGE_MIN
;
464 cx
= ICONITEMBORDER
+16*4;
467 if (cx
< nMinimumWidth
)
471 else if (cx
> nMaximumWidth
)
476 SetColumnWidth(col
, cx
);
483 void CGitLogListBase::FillBackGround(HDC hdc
, DWORD_PTR Index
, CRect
&rect
)
486 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
487 rItem
.mask
= LVIF_STATE
;
488 rItem
.iItem
= (int)Index
;
489 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
492 GitRev
* pLogEntry
= (GitRev
*)m_arShownList
.SafeGetAt(Index
);
495 if (!(rItem
.state
& LVIS_SELECTED
))
497 if(pLogEntry
->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_SQUASH
)
498 brush
= ::CreateSolidBrush(RGB(156,156,156));
499 else if(pLogEntry
->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_EDIT
)
500 brush
= ::CreateSolidBrush(RGB(200,200,128));
502 else if (!(IsAppThemed() && SysInfo::Instance().IsVistaOrLater()))
504 if (rItem
.state
& LVIS_SELECTED
)
506 if (::GetFocus() == m_hWnd
)
507 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT
));
509 brush
= ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE
));
515 ::FillRect(hdc
, &rect
, brush
);
516 ::DeleteObject(brush
);
520 void CGitLogListBase::DrawTagBranch(HDC hdc
,CRect
&rect
,INT_PTR index
)
522 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(index
);
525 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
526 rItem
.mask
= LVIF_STATE
;
527 rItem
.iItem
= (int)index
;
528 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
534 HTHEME hTheme
= NULL
;
535 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
536 hTheme
= OpenThemeData(m_hWnd
, L
"Explorer::ListView;ListView");
538 for(unsigned int i
=0;i
<m_HashMap
[data
->m_CommitHash
].size();i
++)
541 str
=m_HashMap
[data
->m_CommitHash
][i
];
548 //Determine label color
549 if(CGit::GetShortName(str
,shortname
,_T("refs/heads/")))
551 if (!(m_ShowRefMask
& LOGLIST_SHOWLOCALBRANCHES
))
553 if( shortname
== m_CurrentBranch
)
554 colRef
= m_Colors
.GetColor(CColors::CurrentBranch
);
556 colRef
= m_Colors
.GetColor(CColors::LocalBranch
);
559 else if(CGit::GetShortName(str
,shortname
,_T("refs/remotes/")))
561 if (!(m_ShowRefMask
& LOGLIST_SHOWREMOTEBRANCHES
))
563 colRef
= m_Colors
.GetColor(CColors::RemoteBranch
);
565 else if(CGit::GetShortName(str
,shortname
,_T("refs/tags/")))
567 if (!(m_ShowRefMask
& LOGLIST_SHOWTAGS
))
569 colRef
= m_Colors
.GetColor(CColors::Tag
);
571 else if(CGit::GetShortName(str
,shortname
,_T("refs/stash")))
573 if (!(m_ShowRefMask
& LOGLIST_SHOWSTASH
))
575 colRef
= m_Colors
.GetColor(CColors::Stash
);
576 shortname
=_T("stash");
578 else if(CGit::GetShortName(str
,shortname
,_T("refs/bisect/")))
580 if (!(m_ShowRefMask
& LOGLIST_SHOWBISECT
))
582 if(shortname
.Find(_T("good")) == 0)
584 colRef
= m_Colors
.GetColor(CColors::BisectGood
);
585 shortname
= _T("good");
588 if(shortname
.Find(_T("bad")) == 0)
590 colRef
= m_Colors
.GetColor(CColors::BisectBad
);
591 shortname
= _T("bad");
595 //When row selected, ajust label color
596 if (!(IsAppThemed() && SysInfo::Instance().IsVistaOrLater()))
597 if (rItem
.state
& LVIS_SELECTED
)
598 colRef
= CColors::MixColors(colRef
, ::GetSysColor(COLOR_HIGHLIGHT
), 150);
600 brush
= ::CreateSolidBrush(colRef
);
602 if(!shortname
.IsEmpty() && (rt
.left
<rect
.right
) )
605 memset(&size
,0,sizeof(SIZE
));
606 GetTextExtentPoint32(hdc
, shortname
,shortname
.GetLength(),&size
);
608 rt
.SetRect(rt
.left
,rt
.top
,rt
.left
+size
.cx
,rt
.bottom
);
611 int textpos
= DT_CENTER
;
613 if(rt
.right
> rect
.right
)
615 rt
.right
= rect
.right
;
619 //Fill interior of ref label
620 ::FillRect(hdc
, &rt
, brush
);
626 W_Dc
.Draw3dRect(rectEdge
, m_Colors
.Lighten(colRef
,100), m_Colors
.Darken(colRef
,100));
627 rectEdge
.DeflateRect(1,1);
628 W_Dc
.Draw3dRect(rectEdge
, m_Colors
.Lighten(colRef
,50), m_Colors
.Darken(colRef
,50));
630 //Draw text inside label
631 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
633 int txtState
= LISS_NORMAL
;
634 if (rItem
.state
& LVIS_SELECTED
)
635 txtState
= LISS_SELECTED
;
637 DrawThemeText(hTheme
,hdc
, LVP_LISTITEM
, txtState
, shortname
, -1, textpos
| DT_SINGLELINE
| DT_VCENTER
, 0, &rt
);
641 W_Dc
.SetBkMode(TRANSPARENT
);
642 if (rItem
.state
& LVIS_SELECTED
)
644 COLORREF clrNew
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
645 COLORREF clrOld
= ::SetTextColor(hdc
,clrNew
);
646 ::DrawText(hdc
,shortname
,shortname
.GetLength(),&rt
,textpos
| DT_SINGLELINE
| DT_VCENTER
);
647 ::SetTextColor(hdc
,clrOld
);
651 ::DrawText(hdc
,shortname
,shortname
.GetLength(),&rt
,textpos
| DT_SINGLELINE
| DT_VCENTER
);
655 //::MoveToEx(hdc,rt.left,rt.top,NULL);
656 //::LineTo(hdc,rt.right,rt.top);
657 //::LineTo(hdc,rt.right,rt.bottom);
658 //::LineTo(hdc,rt.left,rt.bottom);
659 //::LineTo(hdc,rt.left,rt.top);
664 ::DeleteObject(brush
);
668 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
670 int txtState
= LISS_NORMAL
;
671 if (rItem
.state
& LVIS_SELECTED
)
672 txtState
= LISS_SELECTED
;
674 DrawThemeText(hTheme
,hdc
, LVP_LISTITEM
, txtState
, data
->GetSubject(), -1, DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
, 0, &rt
);
678 if (rItem
.state
& LVIS_SELECTED
)
680 COLORREF clrOld
= ::SetTextColor(hdc
,::GetSysColor(COLOR_HIGHLIGHTTEXT
));
681 ::DrawText(hdc
,data
->GetSubject(),data
->GetSubject().GetLength(),&rt
,DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
);
682 ::SetTextColor(hdc
,clrOld
);
686 ::DrawText(hdc
,data
->GetSubject(),data
->GetSubject().GetLength(),&rt
,DT_NOPREFIX
| DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_END_ELLIPSIS
);
691 CloseThemeData(hTheme
);
696 static COLORREF
blend(const COLORREF
& col1
, const COLORREF
& col2
, int amount
= 128) {
698 // Returns ((256 - amount)*col1 + amount*col2) / 256;
699 return RGB(((256 - amount
)*GetRValue(col1
) + amount
*GetRValue(col2
) ) / 256,
700 ((256 - amount
)*GetGValue(col1
) + amount
*GetGValue(col2
) ) / 256,
701 ((256 - amount
)*GetBValue(col1
) + amount
*GetBValue(col2
) ) / 256);
704 Gdiplus::Color
GetGdiColor(COLORREF col
)
706 return Gdiplus::Color(GetRValue(col
),GetGValue(col
),GetBValue(col
));
708 void CGitLogListBase::paintGraphLane(HDC hdc
, int laneHeight
,int type
, int x1
, int x2
,
709 const COLORREF
& col
,const COLORREF
& activeColor
, int top
712 int h
= laneHeight
/ 2;
713 int m
= (x1
+ x2
) / 2;
714 int r
= (x2
- x1
) / 3;
717 #define P_CENTER m , h+top
718 #define P_0 x2, h+top
719 #define P_90 m , 0+top-1
720 #define P_180 x1, h+top
721 #define P_270 m , 2 * h+top +1
722 #define R_CENTER m - r, h - r+top, d, d
725 #define DELTA_UR_B 2*(x1 - m), 2*h +top
726 #define DELTA_UR_E 0*16, 90*16 +top // -,
728 #define DELTA_DR_B 2*(x1 - m), 2*-h +top
729 #define DELTA_DR_E 270*16, 90*16 +top // -'
731 #define DELTA_UL_B 2*(x2 - m), 2*h +top
732 #define DELTA_UL_E 90*16, 90*16 +top // ,-
734 #define DELTA_DL_B 2*(x2 - m),2*-h +top
735 #define DELTA_DL_E 180*16, 90*16 // '-
737 #define CENTER_UR x1, 2*h, 225
738 #define CENTER_DR x1, 0 , 135
739 #define CENTER_UL x2, 2*h, 315
740 #define CENTER_DL x2, 0 , 45
743 Gdiplus::Graphics
graphics( hdc
);
745 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
754 Gdiplus::LinearGradientBrush
gradient(
755 Gdiplus::Point(x1
-2, h
+top
-2),
756 Gdiplus::Point(P_270
),
757 GetGdiColor(activeColor
),GetGdiColor(col
));
760 Gdiplus::Pen
mypen(&gradient
,2);
761 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
763 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
764 graphics
.DrawArc(&mypen
,x1
-(x2
-x1
)/2-1,top
+h
-1, x2
-x1
,laneHeight
,270,90);
765 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
772 Gdiplus::LinearGradientBrush
gradient(
773 Gdiplus::Point(P_270
),
774 Gdiplus::Point(x2
+1, h
+top
-1),
775 GetGdiColor(col
),GetGdiColor(activeColor
));
778 Gdiplus::Pen
mypen(&gradient
,2);
779 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
781 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
782 graphics
.DrawArc(&mypen
,x1
+(x2
-x1
)/2,top
+h
-1, x2
-x1
,laneHeight
,180,90);
783 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
792 Gdiplus::LinearGradientBrush
gradient(
793 Gdiplus::Point(x1
-2, h
+top
-2),
794 Gdiplus::Point(P_90
),
795 GetGdiColor(activeColor
),GetGdiColor(col
));
797 Gdiplus::Pen
mypen(&gradient
,2);
799 graphics
.DrawArc(&mypen
,x1
-(x2
-x1
)/2-1,top
-h
-1, x2
-x1
,laneHeight
,0,90);
802 QConicalGradient
gradient(CENTER_DR
);
803 gradient
.setColorAt(0.375, activeCol
);
804 gradient
.setColorAt(0.625, col
);
805 myPen
.setBrush(gradient
);
807 p
->drawArc(P_CENTER
, DELTA_DR
);
816 //static QPen myPen(Qt::black, 2); // fast path here
818 pen
.CreatePen(PS_SOLID
,2,col
);
819 //myPen.setColor(col);
820 HPEN oldpen
=(HPEN
)::SelectObject(hdc
,(HPEN
)pen
);
822 Gdiplus::Pen
myPen(GetGdiColor(col
),2);
824 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
831 case Lanes::NOT_ACTIVE
:
832 case Lanes::MERGE_FORK
:
833 case Lanes::MERGE_FORK_R
:
834 case Lanes::MERGE_FORK_L
:
839 //DrawLine(hdc,P_90,P_270);
840 graphics
.DrawLine(&myPen
,P_90
,P_270
);
841 //p->drawLine(P_90, P_270);
845 //DrawLine(hdc,P_CENTER,P_270);
846 graphics
.DrawLine(&myPen
,P_CENTER
,P_270
);
847 //p->drawLine(P_CENTER, P_270);
851 case Lanes::BOUNDARY
:
852 case Lanes::BOUNDARY_C
:
853 case Lanes::BOUNDARY_R
:
854 case Lanes::BOUNDARY_L
:
855 //DrawLine(hdc,P_90, P_CENTER);
856 graphics
.DrawLine(&myPen
,P_90
,P_CENTER
);
857 //p->drawLine(P_90, P_CENTER);
863 myPen
.SetColor(GetGdiColor(activeColor
));
867 case Lanes::MERGE_FORK
:
872 case Lanes::CROSS_EMPTY
:
873 case Lanes::BOUNDARY_C
:
874 //DrawLine(hdc,P_180,P_0);
875 graphics
.DrawLine(&myPen
,P_180
,P_0
);
876 //p->drawLine(P_180, P_0);
878 case Lanes::MERGE_FORK_R
:
879 case Lanes::BOUNDARY_R
:
880 //DrawLine(hdc,P_180,P_CENTER);
881 graphics
.DrawLine(&myPen
,P_180
,P_CENTER
);
882 //p->drawLine(P_180, P_CENTER);
884 case Lanes::MERGE_FORK_L
:
887 case Lanes::BOUNDARY_L
:
888 //DrawLine(hdc,P_CENTER,P_0);
889 graphics
.DrawLine(&myPen
,P_CENTER
,P_0
);
890 //p->drawLine(P_CENTER, P_0);
896 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
899 brush
.CreateSolidBrush(col
);
900 HBRUSH oldbrush
=(HBRUSH
)::SelectObject(hdc
,(HBRUSH
)brush
);
902 Gdiplus::SolidBrush
myBrush(GetGdiColor(col
));
903 // center symbol, e.g. rect or ellipse
909 //p->setPen(Qt::NoPen);
911 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
912 graphics
.FillEllipse(&myBrush
, R_CENTER
);
913 //p->drawEllipse(R_CENTER);
915 case Lanes::MERGE_FORK
:
916 case Lanes::MERGE_FORK_R
:
917 case Lanes::MERGE_FORK_L
:
918 //p->setPen(Qt::NoPen);
920 //p->drawRect(R_CENTER);
921 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
922 graphics
.FillRectangle(&myBrush
, R_CENTER
);
924 case Lanes::UNAPPLIED
:
926 //p->setPen(Qt::NoPen);
927 //p->setBrush(Qt::red);
928 //p->drawRect(m - r, h - 1, d, 2);
929 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
930 graphics
.FillRectangle(&myBrush
,m
-r
,h
-1,d
,2);
934 //p->setPen(Qt::NoPen);
935 //p->setBrush(DARK_GREEN);
936 //p->drawRect(m - r, h - 1, d, 2);
937 //p->drawRect(m - 1, h - r, 2, d);
938 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
939 graphics
.FillRectangle(&myBrush
,m
-r
,h
-1,d
,2);
940 graphics
.FillRectangle(&myBrush
,m
-1,h
-r
,2,d
);
942 case Lanes::BOUNDARY
:
944 //p->drawEllipse(R_CENTER);
945 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias
);
946 graphics
.DrawEllipse(&myPen
, R_CENTER
);
948 case Lanes::BOUNDARY_C
:
949 case Lanes::BOUNDARY_R
:
950 case Lanes::BOUNDARY_L
:
952 //p->drawRect(R_CENTER);
953 graphics
.SetSmoothingMode(Gdiplus::SmoothingModeNone
);
954 graphics
.FillRectangle(&myBrush
,R_CENTER
);
960 ::SelectObject(hdc
,oldpen
);
961 ::SelectObject(hdc
,oldbrush
);
970 void CGitLogListBase::DrawGraph(HDC hdc
,CRect
&rect
,INT_PTR index
)
974 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(index
);
975 if(data
->m_CommitHash
.IsEmpty())
980 SecureZeroMemory(&rItem
, sizeof(LVITEM
));
981 rItem
.mask
= LVIF_STATE
;
982 rItem
.iItem
= (int)index
;
983 rItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
986 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
988 if (data
->m_Lanes
.empty())
989 m_logEntries
.setLane(data
->m_CommitHash
);
991 std::vector
<int>& lanes
=data
->m_Lanes
;
992 size_t laneNum
= lanes
.size();
994 for (UINT i
= 0; i
< laneNum
; i
++)
995 if (Lanes::isMerge(lanes
[i
])) {
1001 int maxWidth
= rect
.Width();
1002 int lw
= 3 * rect
.Height() / 4; //laneWidth()
1004 COLORREF activeColor
= m_LineColors
[activeLane
% Lanes::COLORS_NUM
];
1005 //if (opt.state & QStyle::State_Selected)
1006 // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208);
1008 for (unsigned int i
= 0; i
< laneNum
&& x2
< maxWidth
; i
++)
1015 if (ln
== Lanes::EMPTY
)
1018 COLORREF color
= i
== activeLane
? activeColor
: m_LineColors
[i
% Lanes::COLORS_NUM
];
1019 paintGraphLane(hdc
, rect
.Height(),ln
, x1
+rect
.left
, x2
+rect
.left
, color
,activeColor
, rect
.top
);
1023 for (UINT i
= 0; i
< laneNum
&& x2
< maxWidth
; i
++) {
1029 if (ln
== Lanes::EMPTY
)
1032 UINT col
= ( Lanes:: isHead(ln
) ||Lanes:: isTail(ln
) || Lanes::isJoin(ln
)
1033 || ln
==Lanes:: CROSS_EMPTY
) ? activeLane
: i
;
1035 if (ln
== Lanes::CROSS
)
1037 paintGraphLane(hdc
, rect
.Height(),Lanes::NOT_ACTIVE
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
1038 paintGraphLane(hdc
, rect
.Height(),Lanes::CROSS
, x1
, x2
, m_LineColors
[activeLane
% Lanes::COLORS_NUM
],rect
.top
);
1041 paintGraphLane(hdc
, rect
.Height(),ln
, x1
, x2
, m_LineColors
[col
% Lanes::COLORS_NUM
],rect
.top
);
1047 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1050 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
1051 // Take the default processing unless we set this to something else below.
1052 *pResult
= CDRF_DODEFAULT
;
1054 if (m_bNoDispUpdates
)
1057 switch (pLVCD
->nmcd
.dwDrawStage
)
1061 *pResult
= CDRF_NOTIFYITEMDRAW
;
1065 case CDDS_ITEMPREPAINT
:
1067 // This is the prepaint stage for an item. Here's where we set the
1068 // item's text color.
1070 // Tell Windows to send draw notifications for each subitem.
1071 *pResult
= CDRF_NOTIFYSUBITEMDRAW
;
1073 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
1075 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1077 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1080 if (data
->GetAction(this)& (CTGitPath::LOGACTIONS_REBASE_DONE
| CTGitPath::LOGACTIONS_REBASE_SKIP
) )
1081 crText
= RGB(128,128,128);
1083 if(data
->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_SQUASH
)
1084 pLVCD
->clrTextBk
= RGB(156,156,156);
1085 else if(data
->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_EDIT
)
1086 pLVCD
->clrTextBk
= RGB(200,200,128);
1088 pLVCD
->clrTextBk
= ::GetSysColor(COLOR_WINDOW
);
1090 if(data
->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_CURRENT
)
1092 SelectObject(pLVCD
->nmcd
.hdc
, m_boldFont
);
1093 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
1096 if (data
->m_CommitHash
== m_HeadHash
&& m_bNoHightlightHead
== FALSE
)
1098 SelectObject(pLVCD
->nmcd
.hdc
, m_boldFont
);
1099 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
1102 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
1103 // crText = GetSysColor(COLOR_GRAYTEXT);
1105 if (data
->m_CommitHash
.IsEmpty())
1107 //crText = GetSysColor(RGB(200,200,0));
1108 //SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1109 // We changed the font, so we're returning CDRF_NEWFONT. This
1110 // tells the control to recalculate the extent of the text.
1111 *pResult
= CDRF_NOTIFYSUBITEMDRAW
| CDRF_NEWFONT
;
1115 if (m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1117 if (m_bStrictStopped
)
1118 crText
= GetSysColor(COLOR_GRAYTEXT
);
1120 // Store the color back in the NMLVCUSTOMDRAW struct.
1121 pLVCD
->clrText
= crText
;
1125 case CDDS_ITEMPREPAINT
|CDDS_ITEM
|CDDS_SUBITEM
:
1127 if ((m_bStrictStopped
)&&(m_arShownList
.GetCount() == (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
))
1129 pLVCD
->nmcd
.uItemState
&= ~(CDIS_SELECTED
|CDIS_FOCUS
);
1132 if (pLVCD
->iSubItem
== LOGLIST_GRAPH
&& m_sFilterText
.IsEmpty())
1134 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
&& (!this->m_IsRebaseReplaceGraph
) )
1137 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_LABEL
, rect
);
1139 //TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right);
1140 FillBackGround(pLVCD
->nmcd
.hdc
, pLVCD
->nmcd
.dwItemSpec
,rect
);
1142 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1143 if( !data
->m_CommitHash
.IsEmpty())
1144 DrawGraph(pLVCD
->nmcd
.hdc
,rect
,pLVCD
->nmcd
.dwItemSpec
);
1146 *pResult
= CDRF_SKIPDEFAULT
;
1151 if (pLVCD
->iSubItem
== LOGLIST_MESSAGE
)
1153 if (m_arShownList
.GetCount() > (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1155 GitRev
* data
= (GitRev
*)m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
);
1156 //if(!data->m_IsFull)
1158 //if(data->SafeFetchFullInfo(&g_Git))
1159 // this->Invalidate();
1160 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
1163 if (!m_HashMap
[data
->m_CommitHash
].empty())
1167 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1169 FillBackGround(pLVCD
->nmcd
.hdc
, pLVCD
->nmcd
.dwItemSpec
,rect
);
1170 int displayedRefs
= 0;
1171 for (unsigned int i
= 0; i
< m_HashMap
[data
->m_CommitHash
].size(); i
++)
1173 CString str
= m_HashMap
[data
->m_CommitHash
][i
];
1176 if (CGit::GetShortName(str
, shortname
, _T("refs/heads/")))
1178 if (!(m_ShowRefMask
& LOGLIST_SHOWLOCALBRANCHES
))
1181 else if (CGit::GetShortName(str
, shortname
, _T("refs/remotes/")))
1183 if (!(m_ShowRefMask
& LOGLIST_SHOWREMOTEBRANCHES
))
1186 else if (CGit::GetShortName(str
, shortname
, _T("refs/tags/")))
1188 if (!(m_ShowRefMask
& LOGLIST_SHOWTAGS
))
1191 else if (CGit::GetShortName(str
, shortname
, _T("refs/stash")))
1193 if (!(m_ShowRefMask
& LOGLIST_SHOWSTASH
))
1196 else if (CGit::GetShortName(str
, shortname
, _T("refs/bisect/")))
1198 if (!(m_ShowRefMask
& LOGLIST_SHOWBISECT
))
1204 if (displayedRefs
== 0)
1206 *pResult
= CDRF_DODEFAULT
;
1210 DrawTagBranch(pLVCD
->nmcd
.hdc
,rect
,pLVCD
->nmcd
.dwItemSpec
);
1212 *pResult
= CDRF_SKIPDEFAULT
;
1220 if (pLVCD
->iSubItem
== LOGLIST_ACTION
)
1222 if(this->m_IsIDReplaceAction
)
1224 *pResult
= CDRF_DODEFAULT
;
1227 *pResult
= CDRF_DODEFAULT
;
1229 if (m_arShownList
.GetCount() <= (INT_PTR
)pLVCD
->nmcd
.dwItemSpec
)
1233 int iconwidth
= ::GetSystemMetrics(SM_CXSMICON
);
1234 int iconheight
= ::GetSystemMetrics(SM_CYSMICON
);
1236 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(pLVCD
->nmcd
.dwItemSpec
));
1238 GetSubItemRect((int)pLVCD
->nmcd
.dwItemSpec
, pLVCD
->iSubItem
, LVIR_BOUNDS
, rect
);
1239 //TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right);
1240 // Get the selected state of the
1241 // item being drawn.
1243 // Fill the background if necessary
1244 FillBackGround(pLVCD
->nmcd
.hdc
, pLVCD
->nmcd
.dwItemSpec
, rect
);
1246 // Draw the icon(s) into the compatible DC
1247 pLogEntry
->GetAction(this);
1249 if (!pLogEntry
->m_IsDiffFiles
)
1250 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ ICONITEMBORDER
, rect
.top
, m_hFetchIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1252 if (pLogEntry
->GetAction(this) & CTGitPath::LOGACTIONS_MODIFIED
)
1253 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+ ICONITEMBORDER
, rect
.top
, m_hModifiedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1256 if (pLogEntry
->GetAction(this) & (CTGitPath::LOGACTIONS_ADDED
|CTGitPath::LOGACTIONS_COPY
) )
1257 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hAddedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1260 if (pLogEntry
->GetAction(this) & CTGitPath::LOGACTIONS_DELETED
)
1261 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hDeletedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1264 if (pLogEntry
->GetAction(this) & CTGitPath::LOGACTIONS_REPLACED
)
1265 ::DrawIconEx(pLVCD
->nmcd
.hdc
, rect
.left
+nIcons
*iconwidth
+ ICONITEMBORDER
, rect
.top
, m_hReplacedIcon
, iconwidth
, iconheight
, 0, NULL
, DI_NORMAL
);
1267 *pResult
= CDRF_SKIPDEFAULT
;
1273 *pResult
= CDRF_DODEFAULT
;
1276 // CGitLogListBase message handlers
1278 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1280 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
1282 // Create a pointer to the item
1283 LV_ITEM
* pItem
= &(pDispInfo
)->item
;
1285 // Do the list need text information?
1286 if (!(pItem
->mask
& LVIF_TEXT
))
1289 // By default, clear text buffer.
1290 lstrcpyn(pItem
->pszText
, _T(""), pItem
->cchTextMax
);
1292 bool bOutOfRange
= pItem
->iItem
>= ShownCountWithStopped();
1295 if (m_bNoDispUpdates
|| bOutOfRange
)
1298 // Which item number?
1299 int itemid
= pItem
->iItem
;
1300 GitRev
* pLogEntry
= NULL
;
1301 if (itemid
< m_arShownList
.GetCount())
1302 pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(pItem
->iItem
));
1307 temp
.Format(_T("%d"),pItem
->iItem
+1);
1312 temp
.Format(_T("%d"),m_arShownList
.GetCount()-pItem
->iItem
);
1316 switch (pItem
->iSubItem
)
1318 case this->LOGLIST_GRAPH
: //Graphic
1320 case this->LOGLIST_REBASE
:
1322 if(this->m_IsRebaseReplaceGraph
)
1325 path
.m_Action
=pLogEntry
->GetAction(this)&CTGitPath::LOGACTIONS_REBASE_MODE_MASK
;
1326 lstrcpyn(pItem
->pszText
,path
.GetActionName(), pItem
->cchTextMax
);
1330 case this->LOGLIST_ACTION
: //action -- no text in the column
1332 case this->LOGLIST_HASH
:
1334 lstrcpyn(pItem
->pszText
, pLogEntry
->m_CommitHash
.ToString(), pItem
->cchTextMax
);
1336 case this->LOGLIST_ID
:
1337 if(this->m_IsIDReplaceAction
)
1338 lstrcpyn(pItem
->pszText
, temp
, pItem
->cchTextMax
);
1340 case this->LOGLIST_MESSAGE
: //Message
1342 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetSubject(), pItem
->cchTextMax
);
1344 case this->LOGLIST_AUTHOR
: //Author
1346 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetAuthorName(), pItem
->cchTextMax
);
1348 case this->LOGLIST_DATE
: //Date
1349 if ( pLogEntry
&& (!pLogEntry
->m_CommitHash
.IsEmpty()) )
1350 lstrcpyn(pItem
->pszText
,
1351 CLoglistUtils::FormatDateAndTime(pLogEntry
->GetAuthorDate(), m_DateFormat
, true, m_bRelativeTimes
),
1355 case this->LOGLIST_EMAIL
:
1357 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetAuthorEmail(), pItem
->cchTextMax
);
1360 case this->LOGLIST_COMMIT_NAME
: //Commit
1362 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetCommitterName(), pItem
->cchTextMax
);
1365 case this->LOGLIST_COMMIT_EMAIL
: //Commit Email
1367 lstrcpyn(pItem
->pszText
, (LPCTSTR
)pLogEntry
->GetCommitterEmail(), pItem
->cchTextMax
);
1370 case this->LOGLIST_COMMIT_DATE
: //Commit Date
1371 if (pLogEntry
&& (!pLogEntry
->m_CommitHash
.IsEmpty()))
1372 lstrcpyn(pItem
->pszText
,
1373 CLoglistUtils::FormatDateAndTime(pLogEntry
->GetCommitterDate(), m_DateFormat
, true, m_bRelativeTimes
),
1376 case this->LOGLIST_BUG
: //Bug ID
1378 lstrcpyn(pItem
->pszText
, (LPCTSTR
)this->m_ProjectProperties
.FindBugID(pLogEntry
->GetSubject() + _T("\r\n\r\n") + pLogEntry
->GetBody()), pItem
->cchTextMax
);
1386 void CGitLogListBase::OnContextMenu(CWnd
* pWnd
, CPoint point
)
1389 if (pWnd
== GetHeaderCtrl())
1391 return m_ColumnManager
.OnContextMenuHeader(pWnd
,point
,!!IsGroupViewEnabled());
1394 int selIndex
= GetSelectionMark();
1396 return; // nothing selected, nothing to do with a context menu
1398 // if the user selected the info text telling about not all revisions shown due to
1399 // the "stop on copy/rename" option, we also don't show the context menu
1400 if ((m_bStrictStopped
)&&(selIndex
== m_arShownList
.GetCount()))
1403 // if the context menu is invoked through the keyboard, we have to use
1404 // a calculated position on where to anchor the menu on
1405 if ((point
.x
== -1) && (point
.y
== -1))
1408 GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
1409 ClientToScreen(&rect
);
1410 point
= rect
.CenterPoint();
1412 m_nSearchIndex
= selIndex
;
1413 m_bCancelled
= FALSE
;
1415 // calculate some information the context menu commands can use
1416 // CString pathURL = GetURLFromPath(m_path);
1418 POSITION pos
= GetFirstSelectedItemPosition();
1419 int indexNext
= GetNextSelectedItem(pos
);
1423 GitRev
* pSelLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(indexNext
));
1425 GitRev revSelected
= pSelLogEntry
->Rev
;
1426 GitRev revPrevious
= git_revnum_t(revSelected
)-1;
1427 if ((pSelLogEntry
->pArChangedPaths
)&&(pSelLogEntry
->pArChangedPaths
->GetCount() <= 2))
1429 for (int i
=0; i
<pSelLogEntry
->pArChangedPaths
->GetCount(); ++i
)
1431 LogChangedPath
* changedpath
= (LogChangedPath
*)pSelLogEntry
->pArChangedPaths
->SafeGetAt(i
);
1432 if (changedpath
->lCopyFromRev
)
1433 revPrevious
= changedpath
->lCopyFromRev
;
1436 GitRev revSelected2
;
1439 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
)));
1440 revSelected2
= pLogEntry
->Rev
;
1442 bool bAllFromTheSameAuthor
= true;
1443 CString firstAuthor
;
1444 CLogDataVector selEntries
;
1445 GitRev revLowest
, revHighest
;
1446 GitRevRangeArray revisionRanges
;
1448 POSITION pos
= GetFirstSelectedItemPosition();
1449 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
)));
1450 revisionRanges
.AddRevision(pLogEntry
->Rev
);
1451 selEntries
.push_back(pLogEntry
);
1452 firstAuthor
= pLogEntry
->sAuthor
;
1453 revLowest
= pLogEntry
->Rev
;
1454 revHighest
= pLogEntry
->Rev
;
1457 pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
)));
1458 revisionRanges
.AddRevision(pLogEntry
->Rev
);
1459 selEntries
.push_back(pLogEntry
);
1460 if (firstAuthor
.Compare(pLogEntry
->sAuthor
))
1461 bAllFromTheSameAuthor
= false;
1462 revLowest
= (git_revnum_t(pLogEntry
->Rev
) > git_revnum_t(revLowest
) ? revLowest
: pLogEntry
->Rev
);
1463 revHighest
= (git_revnum_t(pLogEntry
->Rev
) < git_revnum_t(revHighest
) ? revHighest
: pLogEntry
->Rev
);
1469 int FirstSelect
=-1, LastSelect
=-1;
1470 pos
= GetFirstSelectedItemPosition();
1471 FirstSelect
= GetNextSelectedItem(pos
);
1474 LastSelect
= GetNextSelectedItem(pos
);
1476 //entry is selected, now show the popup menu
1478 CIconMenu subbranchmenu
, submenu
, gnudiffmenu
, diffmenu
, revertmenu
;
1480 if (popup
.CreatePopupMenu())
1482 bool isHeadCommit
= (pSelLogEntry
->m_CommitHash
== m_HeadHash
);
1483 CString currentBranch
= _T("refs/heads/") + g_Git
.GetCurrentBranch();
1485 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_PICK
))
1486 popup
.AppendMenuIcon(ID_REBASE_PICK
, IDS_REBASE_PICK
, IDI_PICK
);
1488 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_SQUASH
))
1489 popup
.AppendMenuIcon(ID_REBASE_SQUASH
, IDS_REBASE_SQUASH
, IDI_SQUASH
);
1491 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_EDIT
))
1492 popup
.AppendMenuIcon(ID_REBASE_EDIT
, IDS_REBASE_EDIT
, IDI_EDIT
);
1494 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_SKIP
))
1495 popup
.AppendMenuIcon(ID_REBASE_SKIP
, IDS_REBASE_SKIP
, IDI_SKIP
);
1497 if(m_ContextMenuMask
&(GetContextMenuBit(ID_REBASE_SKIP
)|GetContextMenuBit(ID_REBASE_EDIT
)|
1498 GetContextMenuBit(ID_REBASE_SQUASH
)|GetContextMenuBit(ID_REBASE_PICK
)))
1499 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1501 if (GetSelectedCount() == 1)
1505 if( !pSelLogEntry
->m_CommitHash
.IsEmpty())
1507 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPARE
) && m_hasWC
) // compare revision with WC
1508 popup
.AppendMenuIcon(ID_COMPARE
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
1512 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMMIT
))
1513 popup
.AppendMenuIcon(ID_COMMIT
, IDS_LOG_POPUP_COMMIT
, IDI_COMMIT
);
1515 if(m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF1
) && m_hasWC
) // compare with WC, unified
1517 GitRev
*pRev
=pSelLogEntry
;
1518 if (pSelLogEntry
->m_ParentHash
.empty())
1520 pRev
->GetParentFromHash(pRev
->m_CommitHash
);
1522 if(pRev
->m_ParentHash
.size()<=1)
1524 popup
.AppendMenuIcon(ID_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF_CH
, IDI_DIFF
);
1529 gnudiffmenu
.CreatePopupMenu();
1530 popup
.AppendMenuIcon(ID_GNUDIFF1
,IDS_LOG_POPUP_GNUDIFF_PARENT
, IDI_DIFF
, gnudiffmenu
.m_hMenu
);
1532 gnudiffmenu
.AppendMenuIcon((UINT_PTR
)(ID_GNUDIFF1
+ (0xFFFF << 16)), CString(MAKEINTRESOURCE(IDS_ALLPARENTS
)));
1533 gnudiffmenu
.AppendMenuIcon((UINT_PTR
)(ID_GNUDIFF1
+ (0xFFFE << 16)), CString(MAKEINTRESOURCE(IDS_ONLYMERGEDFILES
)));
1535 for(int i
=0;i
<pRev
->m_ParentHash
.size();i
++)
1538 str
.Format(IDS_PARENT
, i
+ 1);
1539 gnudiffmenu
.AppendMenuIcon(ID_GNUDIFF1
+((i
+1)<<16),str
);
1544 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPAREWITHPREVIOUS
))
1547 GitRev
*pRev
=pSelLogEntry
;
1548 if (pSelLogEntry
->m_ParentHash
.empty())
1550 pRev
->GetParentFromHash(pRev
->m_CommitHash
);
1552 if(pRev
->m_ParentHash
.size()<=1)
1554 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_LOG_POPUP_COMPAREWITHPREVIOUS
, IDI_DIFF
);
1555 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1556 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
1560 diffmenu
.CreatePopupMenu();
1561 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_LOG_POPUP_COMPAREWITHPREVIOUS
, IDI_DIFF
, diffmenu
.m_hMenu
);
1562 for(int i
=0;i
<pRev
->m_ParentHash
.size();i
++)
1565 str
.Format(IDS_PARENT
, i
+ 1);
1566 diffmenu
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
+((i
+1)<<16),str
);
1567 if (i
== 0 && CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
1569 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
1570 diffmenu
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
+((i
+1)<<16), FALSE
);
1576 if(m_ContextMenuMask
&GetContextMenuBit(ID_BLAME
))
1577 popup
.AppendMenuIcon(ID_BLAME
, IDS_LOG_POPUP_BLAME
, IDI_BLAME
);
1579 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
1580 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1582 if (pSelLogEntry
->m_CommitHash
.IsEmpty())
1584 if(m_ContextMenuMask
&GetContextMenuBit(ID_STASH_SAVE
))
1585 popup
.AppendMenuIcon(ID_STASH_SAVE
, IDS_MENUSTASHSAVE
, IDI_COMMIT
);
1588 bool isStash
= false;
1589 for (int i
= 0; i
< m_HashMap
[pSelLogEntry
->m_CommitHash
].size(); i
++)
1591 if (m_HashMap
[pSelLogEntry
->m_CommitHash
][i
] == _T("refs/stash"))
1598 if (CTGitPath(g_Git
.m_CurrentDir
).HasStashDir() && (pSelLogEntry
->m_CommitHash
.IsEmpty() || isStash
))
1600 if (m_ContextMenuMask
&GetContextMenuBit(ID_STASH_POP
))
1601 popup
.AppendMenuIcon(ID_STASH_POP
, IDS_MENUSTASHPOP
, IDI_RELOCATE
);
1603 if (m_ContextMenuMask
&GetContextMenuBit(ID_STASH_LIST
))
1604 popup
.AppendMenuIcon(ID_STASH_LIST
, IDS_MENUSTASHLIST
, IDI_LOG
);
1606 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1609 if (pSelLogEntry
->m_CommitHash
.IsEmpty())
1611 if(m_ContextMenuMask
&GetContextMenuBit(ID_FETCH
))
1612 popup
.AppendMenuIcon(ID_FETCH
, IDS_MENUFETCH
, IDI_PULL
);
1614 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1618 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
1620 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
1622 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
1624 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
1626 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
1627 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
1629 // popup.AppendMenu(MF_SEPARATOR, NULL);
1634 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
1636 if(!pSelLogEntry
->m_CommitHash
.IsEmpty())
1638 if((m_ContextMenuMask
&GetContextMenuBit(ID_LOG
)) &&
1639 GetSelectedCount() == 1)
1640 popup
.AppendMenuIcon(ID_LOG
, IDS_LOG_POPUP_LOG
, IDI_LOG
);
1642 if (m_ContextMenuMask
&GetContextMenuBit(ID_REPOBROWSE
))
1643 popup
.AppendMenuIcon(ID_REPOBROWSE
, IDS_LOG_BROWSEREPO
, IDI_REPOBROWSE
);
1645 format
.LoadString(IDS_LOG_POPUP_MERGEREV
);
1646 str
.Format(format
,g_Git
.GetCurrentBranch());
1648 if (m_ContextMenuMask
&GetContextMenuBit(ID_MERGEREV
) && !isHeadCommit
&& m_hasWC
)
1649 popup
.AppendMenuIcon(ID_MERGEREV
, str
, IDI_MERGE
);
1651 format
.LoadString(IDS_RESET_TO_THIS_FORMAT
);
1652 str
.Format(format
,g_Git
.GetCurrentBranch());
1654 if(m_ContextMenuMask
&GetContextMenuBit(ID_RESET
) && m_hasWC
)
1655 popup
.AppendMenuIcon(ID_RESET
,str
,IDI_REVERT
);
1658 // Add Switch Branch express Menu
1659 if( this->m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.end()
1660 && (m_ContextMenuMask
&GetContextMenuBit(ID_SWITCHBRANCH
) && m_hasWC
)
1663 std::vector
<CString
*> branchs
;
1664 for(int i
=0;i
<m_HashMap
[pSelLogEntry
->m_CommitHash
].size();i
++)
1666 CString ref
= m_HashMap
[pSelLogEntry
->m_CommitHash
][i
];
1667 if(ref
.Find(_T("refs/heads/")) == 0 && ref
!= currentBranch
)
1669 branchs
.push_back(&m_HashMap
[pSelLogEntry
->m_CommitHash
][i
]);
1674 str
.LoadString(IDS_SWITCH_BRANCH
);
1676 if(branchs
.size() == 1)
1679 str
+= _T('"') + branchs
[0]->Mid(11) + _T('"');
1680 popup
.AppendMenuIcon(ID_SWITCHBRANCH
,str
,IDI_SWITCH
);
1682 popup
.SetMenuItemData(ID_SWITCHBRANCH
,(ULONG_PTR
)branchs
[0]);
1685 else if(branchs
.size() > 1)
1687 subbranchmenu
.CreatePopupMenu();
1688 for(int i
=0;i
<branchs
.size();i
++)
1690 if (*branchs
[i
] != currentBranch
)
1692 subbranchmenu
.AppendMenuIcon(ID_SWITCHBRANCH
+(i
<<16), branchs
[i
]->Mid(11));
1693 subbranchmenu
.SetMenuItemData(ID_SWITCHBRANCH
+(i
<<16), (ULONG_PTR
) branchs
[i
]);
1697 popup
.AppendMenuIcon(ID_SWITCHBRANCH
, str
, IDI_SWITCH
, subbranchmenu
.m_hMenu
);
1701 if(m_ContextMenuMask
&GetContextMenuBit(ID_SWITCHTOREV
) && !isHeadCommit
&& m_hasWC
)
1702 popup
.AppendMenuIcon(ID_SWITCHTOREV
, IDS_SWITCH_TO_THIS
, IDI_SWITCH
);
1704 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_BRANCH
))
1705 popup
.AppendMenuIcon(ID_CREATE_BRANCH
, IDS_CREATE_BRANCH_AT_THIS
, IDI_COPY
);
1707 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_TAG
))
1708 popup
.AppendMenuIcon(ID_CREATE_TAG
,IDS_CREATE_TAG_AT_THIS
, IDI_TAG
);
1710 format
.LoadString(IDS_REBASE_THIS_FORMAT
);
1711 str
.Format(format
,g_Git
.GetCurrentBranch());
1713 if(pSelLogEntry
->m_CommitHash
!= m_HeadHash
&& m_hasWC
)
1714 if(m_ContextMenuMask
&GetContextMenuBit(ID_REBASE_TO_VERSION
))
1715 popup
.AppendMenuIcon(ID_REBASE_TO_VERSION
, str
, IDI_REBASE
);
1717 if(m_ContextMenuMask
&GetContextMenuBit(ID_EXPORT
))
1718 popup
.AppendMenuIcon(ID_EXPORT
,IDS_EXPORT_TO_THIS
, IDI_EXPORT
);
1720 if (m_ContextMenuMask
&GetContextMenuBit(ID_REVERTREV
) && m_hasWC
)
1722 GitRev
*pRev
= pSelLogEntry
;
1723 if (pSelLogEntry
->m_ParentHash
.empty())
1725 pRev
->GetParentFromHash(pRev
->m_CommitHash
);
1727 if (pRev
->m_ParentHash
.size() == 1)
1729 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
);
1733 revertmenu
.CreatePopupMenu();
1734 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREV
, IDI_REVERT
, revertmenu
.m_hMenu
);
1736 for (int i
= 0; i
< pRev
->m_ParentHash
.size(); i
++)
1739 str
.Format(IDS_PARENT
, i
+ 1);
1740 revertmenu
.AppendMenuIcon(ID_REVERTREV
+ ((i
+ 1) << 16), str
);
1745 if (m_ContextMenuMask
&GetContextMenuBit(ID_EDITNOTE
))
1746 popup
.AppendMenuIcon(ID_EDITNOTE
, IDS_EDIT_NOTES
, IDI_EDIT
);
1748 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1753 if(!pSelLogEntry
->m_Ref
.IsEmpty())
1755 popup
.AppendMenuIcon(ID_REFLOG_DEL
, IDS_REFLOG_DEL
, IDI_DELETE
);
1756 if (GetSelectedCount() == 1 && pSelLogEntry
->m_Ref
.Find(_T("refs/stash")) == 0)
1757 popup
.AppendMenuIcon(ID_REFLOG_STASH_APPLY
, IDS_MENUSTASHAPPLY
, IDI_RELOCATE
);
1758 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1761 if (GetSelectedCount() >= 2)
1763 bool bAddSeparator
= false;
1764 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
1766 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMPARETWO
)) // compare two revisions
1767 popup
.AppendMenuIcon(ID_COMPARETWO
, IDS_LOG_POPUP_COMPARETWO
, IDI_DIFF
);
1770 if (GetSelectedCount() == 2)
1772 if(m_ContextMenuMask
&GetContextMenuBit(ID_GNUDIFF2
) && m_hasWC
) // compare two revisions, unified
1773 popup
.AppendMenuIcon(ID_GNUDIFF2
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
1774 bAddSeparator
= true;
1779 bAddSeparator
= true;
1782 if (m_ContextMenuMask
&GetContextMenuBit(ID_REVERTREV
) && m_hasWC
)
1783 popup
.AppendMenuIcon(ID_REVERTREV
, IDS_LOG_POPUP_REVERTREVS
, IDI_REVERT
);
1786 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1789 if ( GetSelectedCount() >0 && (!pSelLogEntry
->m_CommitHash
.IsEmpty()))
1791 bool bAddSeparator
= false;
1792 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
1794 if(m_ContextMenuMask
&GetContextMenuBit(ID_COMBINE_COMMIT
) && m_hasWC
)
1798 headindex
= this->GetHeadIndex();
1801 head
.Format(_T("HEAD~%d"),LastSelect
-headindex
);
1802 CGitHash hash
=g_Git
.GetHash(head
);
1803 GitRev
* pLastEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(LastSelect
));
1804 if(pLastEntry
->m_CommitHash
== hash
) {
1805 popup
.AppendMenuIcon(ID_COMBINE_COMMIT
,IDS_COMBINE_TO_ONE
,IDI_COMBINE
);
1806 bAddSeparator
= true;
1811 if(m_ContextMenuMask
&GetContextMenuBit(ID_CHERRY_PICK
) && !isHeadCommit
&& m_hasWC
) {
1812 if (GetSelectedCount() >= 2)
1813 popup
.AppendMenuIcon(ID_CHERRY_PICK
, IDS_CHERRY_PICK_VERSIONS
, IDI_EXPORT
);
1815 popup
.AppendMenuIcon(ID_CHERRY_PICK
, IDS_CHERRY_PICK_VERSION
, IDI_EXPORT
);
1816 bAddSeparator
= true;
1819 if(GetSelectedCount()<=2 || (IsSelectionContinuous() && GetSelectedCount() > 0))
1820 if(m_ContextMenuMask
&GetContextMenuBit(ID_CREATE_PATCH
)) {
1821 popup
.AppendMenuIcon(ID_CREATE_PATCH
, IDS_CREATE_PATCH
, IDI_PATCH
);
1822 bAddSeparator
= true;
1826 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1829 if (m_hasWC
&& (m_ContextMenuMask
& GetContextMenuBit(ID_BISECTSTART
)) && GetSelectedCount() == 2 && !reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(FirstSelect
))->m_CommitHash
.IsEmpty() && !CTGitPath(g_Git
.m_CurrentDir
).IsBisectActive())
1831 popup
.AppendMenuIcon(ID_BISECTSTART
, IDS_MENUBISECTSTART
);
1832 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1835 if (GetSelectedCount() == 1)
1837 bool bAddSeparator
= false;
1838 if(m_ContextMenuMask
&GetContextMenuBit(ID_PUSH
) && !m_HashMap
[pSelLogEntry
->m_CommitHash
].empty())
1840 // show the push-option only if the log entry has an associated local branch
1841 bool isLocal
= false;
1842 for(int i
=0; isLocal
== false && i
< m_HashMap
[pSelLogEntry
->m_CommitHash
].size(); i
++)
1844 if (m_HashMap
[pSelLogEntry
->m_CommitHash
][i
].Find(_T("refs/heads/")) == 0)
1849 popup
.AppendMenuIcon(ID_PUSH
, IDS_LOG_PUSH
, IDI_PUSH
);
1850 bAddSeparator
= true;
1854 if(m_ContextMenuMask
&GetContextMenuBit(ID_DELETE
))
1856 if( this->m_HashMap
.find(pSelLogEntry
->m_CommitHash
) != m_HashMap
.end() )
1858 std::vector
<CString
*> branchs
;
1859 for (int i
= 0; i
< m_HashMap
[pSelLogEntry
->m_CommitHash
].size(); i
++)
1861 if(m_HashMap
[pSelLogEntry
->m_CommitHash
][i
] != currentBranch
)
1862 branchs
.push_back(&m_HashMap
[pSelLogEntry
->m_CommitHash
][i
]);
1865 if (branchs
.size() == 1)
1867 str
.LoadString(IDS_DELETE_BRANCHTAG_SHORT
);
1870 popup
.AppendMenuIcon(ID_DELETE
, str
, IDI_DELETE
);
1871 popup
.SetMenuItemData(ID_DELETE
, (ULONG_PTR
)branchs
[0]);
1872 bAddSeparator
= true;
1874 else if (branchs
.size() > 1)
1876 str
.LoadString(IDS_DELETE_BRANCHTAG
);
1877 submenu
.CreatePopupMenu();
1878 for (int i
= 0; i
< branchs
.size(); i
++)
1880 submenu
.AppendMenuIcon(ID_DELETE
+ (i
<< 16), *branchs
[i
]);
1881 submenu
.SetMenuItemData(ID_DELETE
+ (i
<< 16), (ULONG_PTR
)branchs
[i
]);
1884 popup
.AppendMenuIcon(ID_DELETE
,str
, IDI_DELETE
, submenu
.m_hMenu
);
1885 bAddSeparator
= true;
1888 } // m_ContextMenuMask &GetContextMenuBit(ID_DELETE)
1890 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
1891 } // GetSelectedCount() == 1
1893 if (GetSelectedCount() != 0)
1895 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYHASH
))
1896 popup
.AppendMenuIcon(ID_COPYHASH
, IDS_COPY_COMMIT_HASH
, IDI_COPYCLIP
);
1897 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYCLIPBOARD
))
1898 popup
.AppendMenuIcon(ID_COPYCLIPBOARD
, IDS_LOG_POPUP_COPYTOCLIPBOARD
, IDI_COPYCLIP
);
1899 if(m_ContextMenuMask
&GetContextMenuBit(ID_COPYCLIPBOARDMESSAGES
))
1900 popup
.AppendMenuIcon(ID_COPYCLIPBOARDMESSAGES
, IDS_LOG_POPUP_COPYTOCLIPBOARDMESSAGES
, IDI_COPYCLIP
);
1903 if(m_ContextMenuMask
&GetContextMenuBit(ID_FINDENTRY
))
1904 popup
.AppendMenuIcon(ID_FINDENTRY
, IDS_LOG_POPUP_FIND
, IDI_FILTEREDIT
);
1906 if (GetSelectedCount() == 1 && m_ContextMenuMask
& GetContextMenuBit(ID_SHOWBRANCHES
) && !pSelLogEntry
->m_CommitHash
.IsEmpty())
1907 popup
.AppendMenuIcon(ID_SHOWBRANCHES
, IDS_LOG_POPUP_SHOWBRANCHES
, IDI_SHOWBRANCHES
);
1909 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
1910 // DialogEnableWindow(IDOK, FALSE);
1911 // SetPromptApp(&theApp);
1913 this->ContextMenuAction(cmd
, FirstSelect
, LastSelect
, &popup
);
1915 // EnableOKButton();
1916 } // if (popup.CreatePopupMenu())
1920 bool CGitLogListBase::IsSelectionContinuous()
1922 if ( GetSelectedCount()==1 )
1924 // if only one revision is selected, the selection is of course
1929 POSITION pos
= GetFirstSelectedItemPosition();
1930 bool bContinuous
= (m_arShownList
.GetCount() == (INT_PTR
)m_logEntries
.size());
1933 int itemindex
= GetNextSelectedItem(pos
);
1936 int nextindex
= GetNextSelectedItem(pos
);
1937 if (nextindex
- itemindex
> 1)
1939 bContinuous
= false;
1942 itemindex
= nextindex
;
1948 void CGitLogListBase::CopySelectionToClipBoard(int toCopy
)
1952 POSITION pos
= GetFirstSelectedItemPosition();
1956 sRev
.LoadString(IDS_LOG_REVISION
);
1958 sAuthor
.LoadString(IDS_LOG_AUTHOR
);
1960 sDate
.LoadString(IDS_LOG_DATE
);
1962 sMessage
.LoadString(IDS_LOG_MESSAGE
);
1966 CString sLogCopyText
;
1968 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(GetNextSelectedItem(pos
)));
1970 if (toCopy
== ID_COPY_ALL
)
1972 //pLogEntry->GetFiles(this)
1973 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
1975 CString
from(MAKEINTRESOURCE(IDS_STATUSLIST_FROM
));
1976 for (int cpPathIndex
= 0; cpPathIndex
<pLogEntry
->GetFiles(this).GetCount(); ++cpPathIndex
)
1978 sPaths
+= ((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetActionName() + _T(": ") + pLogEntry
->GetFiles(this)[cpPathIndex
].GetGitPathString();
1979 if (((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).m_Action
& (CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_COPY
) && !((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetGitOldPathString().IsEmpty())
1982 rename
.Format(from
, ((CTGitPath
&)pLogEntry
->GetFiles(this)[cpPathIndex
]).GetGitOldPathString());
1983 sPaths
+= _T(" ") + rename
;
1985 sPaths
+= _T("\r\n");
1988 CString body
= pLogEntry
->GetBody();
1989 body
.Replace(_T("\n"), _T("\r\n"));
1990 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"),
1991 (LPCTSTR
)sRev
, pLogEntry
->m_CommitHash
.ToString(),
1992 (LPCTSTR
)sAuthor
, (LPCTSTR
)pLogEntry
->GetAuthorName(), (LPCTSTR
)pLogEntry
->GetAuthorEmail(),
1994 (LPCTSTR
)CLoglistUtils::FormatDateAndTime(pLogEntry
->GetAuthorDate(), m_DateFormat
, true, m_bRelativeTimes
),
1995 (LPCTSTR
)sMessage
, (pLogEntry
->GetSubject().Trim() + _T("\r\n\r\n") + body
.Trim()).Trim(),
1997 sClipdata
+= sLogCopyText
;
1999 else if (toCopy
== ID_COPY_MESSAGE
)
2001 CString body
= pLogEntry
->GetBody();
2002 body
.Replace(_T("\n"), _T("\r\n"));
2003 sClipdata
+= _T("* ") + (pLogEntry
->GetSubject().Trim() + _T("\r\n\r\n") + body
.Trim()).Trim() + _T("\r\n\r\n");
2005 else if (toCopy
== ID_COPY_SUBJECT
)
2007 sClipdata
+= _T("* ") + pLogEntry
->GetSubject().Trim() + _T("\r\n\r\n");
2012 sClipdata
+= _T("\r\n");
2013 sClipdata
+= pLogEntry
->m_CommitHash
;
2018 CStringUtils::WriteAsciiStringToClipboard(sClipdata
, GetSafeHwnd());
2023 void CGitLogListBase::DiffSelectedRevWithPrevious()
2025 if (m_bThreadRunning
)
2028 int FirstSelect
=-1, LastSelect
=-1;
2029 POSITION pos
= GetFirstSelectedItemPosition();
2030 FirstSelect
= GetNextSelectedItem(pos
);
2033 LastSelect
= GetNextSelectedItem(pos
);
2036 ContextMenuAction(ID_COMPAREWITHPREVIOUS
,FirstSelect
,LastSelect
, NULL
);
2039 UpdateLogInfoLabel();
2040 int selIndex
= m_LogList
.GetSelectionMark();
2043 int selCount
= m_LogList
.GetSelectedCount();
2047 // Find selected entry in the log list
2048 POSITION pos
= m_LogList
.GetFirstSelectedItemPosition();
2049 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(m_LogList
.GetNextSelectedItem(pos
)));
2050 long rev1
= pLogEntry
->Rev
;
2052 CTGitPath path
= m_path
;
2054 // See how many files under the relative root were changed in selected revision
2056 LogChangedPath
* changed
= NULL
;
2057 for (INT_PTR c
= 0; c
< pLogEntry
->pArChangedPaths
->GetCount(); ++c
)
2059 LogChangedPath
* cpath
= pLogEntry
->pArChangedPaths
->SafeGetAt(c
);
2060 if (cpath
&& cpath
-> sPath
.Left(m_sRelativeRoot
.GetLength()).Compare(m_sRelativeRoot
)==0)
2067 if (m_path
.IsDirectory() && nChanged
== 1)
2069 // We're looking at the log for a directory and only one file under dir was changed in the revision
2070 // Do diff on that file instead of whole directory
2071 path
.AppendPathString(changed
->sPath
.Mid(m_sRelativeRoot
.GetLength()));
2074 m_bCancelled
= FALSE
;
2075 DialogEnableWindow(IDOK
, FALSE
);
2076 SetPromptApp(&theApp
);
2077 theApp
.DoWaitCursor(1);
2081 GitDiff
diff(this, m_hWnd
, true);
2082 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
2083 diff
.SetHEADPeg(m_LogRevision
);
2084 diff
.ShowCompare(path
, rev2
, path
, rev1
);
2088 CAppUtils::StartShowCompare(m_hWnd
, path
, rev2
, path
, rev1
, GitRev(), m_LogRevision
, !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
2091 theApp
.DoWaitCursor(-1);
2096 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR
*pNMHDR
, LRESULT
*pResult
)
2098 LPNMLVFINDITEM pFindInfo
= reinterpret_cast<LPNMLVFINDITEM
>(pNMHDR
);
2101 if (pFindInfo
->lvfi
.flags
& LVFI_PARAM
)
2103 if ((pFindInfo
->iStart
< 0)||(pFindInfo
->iStart
>= m_arShownList
.GetCount()))
2105 if (pFindInfo
->lvfi
.psz
== 0)
2108 CString sCmp
= pFindInfo
->lvfi
.psz
;
2110 for (int i
=pFindInfo
->iStart
; i
<m_arShownList
.GetCount(); ++i
)
2112 GitRev
* pLogEntry
= reinterpret_cast<GitRev
*>(m_arShownList
.SafeGetAt(i
));
2113 sRev
.Format(_T("%ld"), pLogEntry
->Rev
);
2114 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
2116 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
2124 if (sCmp
.Compare(sRev
)==0)
2131 if (pFindInfo
->lvfi
.flags
& LVFI_WRAP
)
2133 for (int i
=0; i
<pFindInfo
->iStart
; ++i
)
2135 PLOGENTRYDATA pLogEntry
= reinterpret_cast<PLOGENTRYDATA
>(m_arShownList
.SafeGetAt(i
));
2136 sRev
.Format(_T("%ld"), pLogEntry
->Rev
);
2137 if (pFindInfo
->lvfi
.flags
& LVFI_PARTIAL
)
2139 if (sCmp
.Compare(sRev
.Left(sCmp
.GetLength()))==0)
2147 if (sCmp
.Compare(sRev
)==0)
2159 int CGitLogListBase::FillGitLog(CTGitPath
*path
,int info
,CString
*from
,CString
*to
)
2163 this->m_arShownList
.SafeRemoveAll();
2165 this->m_logEntries
.ClearAll();
2166 if (this->m_logEntries
.ParserFromLog(path
,-1,info
,from
,to
))
2169 //this->m_logEntries.ParserFromLog();
2170 SetItemCountEx((int)m_logEntries
.size());
2172 for(unsigned int i
=0;i
<m_logEntries
.size();i
++)
2176 m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1).m_IsFull
=TRUE
;
2177 this->m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1));
2182 m_logEntries
.GetGitRevAt(i
).m_IsFull
=TRUE
;
2183 this->m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2195 int CGitLogListBase::BeginFetchLog()
2199 this->m_arShownList
.SafeRemoveAll();
2201 this->m_logEntries
.ClearAll();
2203 this->m_LogCache
.ClearAllParent();
2205 m_LogCache
.FetchCacheIndex(g_Git
.m_CurrentDir
);
2208 if(this->m_Path
.IsEmpty())
2215 mask
= CGit::LOG_INFO_ONLY_HASH
| CGit::LOG_INFO_BOUNDARY
;
2216 // if(this->m_bAllBranch)
2217 mask
|= m_ShowMask
;
2221 this->m_logEntries
.insert(m_logEntries
.begin(),this->m_wcRev
.m_CommitHash
);
2223 this->m_LogCache
.m_HashMap
[m_wcRev
.m_CommitHash
]=m_wcRev
;
2226 CString
*pFrom
, *pTo
;
2228 CString
head(_T("HEAD"));
2229 if(!this->m_startrev
.IsEmpty())
2231 pFrom
= &this->m_startrev
;
2232 if(!this->m_endrev
.IsEmpty())
2233 pTo
= &this->m_endrev
;
2239 data
.m_From
= m_From
;
2242 #if 0 /* use tortoiegit filter */
2243 if(this->m_nSelectedFilter
== LOGFILTER_ALL
|| m_nSelectedFilter
== LOGFILTER_AUTHORS
)
2244 data
.m_Author
= this->m_sFilterText
;
2246 if(this->m_nSelectedFilter
== LOGFILTER_ALL
|| m_nSelectedFilter
== LOGFILTER_MESSAGES
)
2247 data
.m_MessageFilter
= this->m_sFilterText
;
2249 data
.m_IsRegex
= m_bFilterWithRegex
;
2252 // follow does not work for directories
2253 if (!path
|| path
->IsDirectory())
2254 mask
&= ~CGit::LOG_INFO_FOLLOW
;
2255 // follow does not work with all branches 8at least in TGit)
2256 if (mask
& CGit::LOG_INFO_FOLLOW
)
2257 mask
&= ~CGit::LOG_INFO_ALL_BRANCH
;
2259 CString cmd
=g_Git
.GetLogCmd(m_StartRef
,path
,-1,mask
,pFrom
,pTo
,true,&data
);
2261 //this->m_logEntries.ParserFromLog();
2262 if(IsInWorkingThread())
2264 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
);
2268 SetItemCountEx((int)m_logEntries
.size());
2278 MessageBox(_T("Could not initialize libgit.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2282 if (g_Git
.IsOrphanBranch(m_StartRef
))
2284 if (!(mask
& CGit::LOG_INFO_ALL_BRANCH
))
2287 // if show all branches, pick any ref as dummy entry ref
2289 g_Git
.GetRefList(list
);
2290 if (list
.size() == 0)
2293 cmd
= g_Git
.GetLogCmd(list
[0], path
, -1, mask
, pFrom
, pTo
, true, &data
);
2297 if (git_open_log(&m_DllGitLog
, CUnicodeUtils::GetMulti(cmd
, CP_UTF8
).GetBuffer()))
2305 MessageBox(_T("Could not open log.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2312 BOOL
CGitLogListBase::PreTranslateMessage(MSG
* pMsg
)
2314 if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
=='\r')
2316 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
2318 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
2320 DiffSelectedRevWithPrevious();
2325 if (GetFocus()==GetDlgItem(IDC_LOGMSG
))
2332 else if (pMsg
->message
== WM_KEYDOWN
&& pMsg
->wParam
== 'A' && GetAsyncKeyState(VK_CONTROL
)&0x8000)
2334 // select all entries
2335 for (int i
=0; i
<GetItemCount(); ++i
)
2337 SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
2343 if (m_hAccel
&& !bSkipAccelerator
)
2345 int ret
= TranslateAccelerator(m_hWnd
, m_hAccel
, pMsg
);
2351 //m_tooltips.RelayEvent(pMsg);
2352 return __super::PreTranslateMessage(pMsg
);
2355 void CGitLogListBase::OnNMDblclkLoglist(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
2357 // a double click on an entry in the revision list has happened
2360 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
2361 DiffSelectedRevWithPrevious();
2364 int CGitLogListBase::FetchLogAsync(void * data
)
2367 m_bExitThread
=FALSE
;
2368 InterlockedExchange(&m_bThreadRunning
, TRUE
);
2369 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2370 m_LoadingThread
= AfxBeginThread(LogThreadEntry
, this, THREAD_PRIORITY_LOWEST
);
2371 if (m_LoadingThread
==NULL
)
2373 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2374 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2375 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
2381 //this is the thread function which calls the subversion function
2382 UINT
CGitLogListBase::LogThreadEntry(LPVOID pVoid
)
2384 return ((CGitLogListBase
*)pVoid
)->LogThread();
2387 void CGitLogListBase::GetTimeRange(CTime
&oldest
, CTime
&latest
)
2390 oldest
=CTime::GetCurrentTime();
2391 latest
=CTime(1971,1,2,0,0,0);
2392 for(unsigned int i
=0;i
<m_logEntries
.size();i
++)
2394 if(m_logEntries
[i
].IsEmpty())
2397 if(m_logEntries
.GetGitRevAt(i
).GetAuthorDate().GetTime() < oldest
.GetTime())
2398 oldest
= m_logEntries
.GetGitRevAt(i
).GetAuthorDate().GetTime();
2400 if(m_logEntries
.GetGitRevAt(i
).GetAuthorDate().GetTime() > latest
.GetTime())
2401 latest
= m_logEntries
.GetGitRevAt(i
).GetAuthorDate().GetTime();
2409 UINT
CGitLogListBase::LogThread()
2411 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_START
,0);
2413 InterlockedExchange(&m_bThreadRunning
, TRUE
);
2414 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2420 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2421 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2426 tr1::wregex pat
;//(_T("Remove"), tr1::regex_constants::icase);
2427 bool bRegex
= false;
2428 if (m_bFilterWithRegex
)
2429 bRegex
= ValidateRegexp(m_sFilterText
, pat
, false);
2431 TRACE(_T("\n===Begin===\n"));
2432 //Update work copy item;
2434 if (!m_logEntries
.empty())
2436 GitRev
*pRev
= &m_logEntries
.GetGitRevAt(0);
2438 m_arShownList
.SafeAdd(pRev
);
2442 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2444 // store commit number of the last selected commit/line before the refresh or -1
2445 int lastSelectedHashNItem
= -1;
2448 bool shouldWalk
= true;
2449 if (g_Git
.IsOrphanBranch(m_StartRef
))
2451 // walk revisions if show all branches and there exists any ref
2452 if (!(m_ShowMask
& CGit::LOG_INFO_ALL_BRANCH
))
2457 g_Git
.GetRefList(list
);
2458 if (list
.size() == 0)
2465 g_Git
.m_critGitDllSec
.Lock();
2469 git_get_log_firstcommit(m_DllGitLog
);
2470 total
= git_get_log_estimate_commit_count(m_DllGitLog
);
2475 MessageBox(_T("Could not get first commit.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2478 g_Git
.m_critGitDllSec
.Unlock();
2481 t2
=t1
=GetTickCount();
2482 int oldprecentage
= 0;
2483 size_t oldsize
= m_logEntries
.size();
2484 while (ret
== 0 && !m_bExitThread
)
2486 g_Git
.m_critGitDllSec
.Lock();
2489 ret
= git_get_log_nextcommit(this->m_DllGitLog
, &commit
, m_ShowMask
& CGit::LOG_INFO_FOLLOW
);
2493 g_Git
.m_critGitDllSec
.Unlock();
2495 MessageBox(_T("Could not get next commit.\nlibgit reports:\n") + err
, _T("TortoiseGit"), MB_ICONERROR
);
2498 g_Git
.m_critGitDllSec
.Unlock();
2503 if (commit
.m_ignore
== 1)
2505 git_free_commit(&commit
);
2509 //printf("%s\r\n",commit.GetSubject());
2513 CGitHash hash
= (char*)commit
.m_hash
;
2515 GitRev
*pRev
= m_LogCache
.GetCacheData(hash
);
2516 pRev
->m_GitCommit
= commit
;
2517 InterlockedExchange(&pRev
->m_IsCommitParsed
, FALSE
);
2520 g_Git
.m_critGitDllSec
.Lock();
2521 git_get_notes(commit
.m_hash
,¬e
);
2522 g_Git
.m_critGitDllSec
.Unlock();
2526 pRev
->m_Notes
.Empty();
2527 g_Git
.StringAppend(&pRev
->m_Notes
,(BYTE
*)note
);
2530 if(!pRev
->m_IsDiffFiles
)
2532 pRev
->m_CallDiffAsync
= DiffAsync
;
2535 pRev
->ParserParentFromCommit(&commit
);
2542 if(!m_sFilterText
.IsEmpty())
2544 if(!IsMatchFilter(bRegex
,pRev
,pat
))
2547 this->m_critSec
.Lock();
2548 m_logEntries
.push_back(hash
);
2549 m_arShownList
.SafeAdd(pRev
);
2550 this->m_critSec
.Unlock();
2552 if (lastSelectedHashNItem
== -1 && hash
== m_lastSelectedHash
)
2553 lastSelectedHashNItem
= (int)m_arShownList
.GetCount() - 1;
2557 if(t2
-t1
>500 || (m_logEntries
.size()-oldsize
>100))
2560 int percent
= (int)m_logEntries
.size() * 100 / total
+ GITLOG_START
+ 1;
2563 if(percent
< GITLOG_START
)
2564 percent
= GITLOG_START
+1;
2566 oldsize
= m_logEntries
.size();
2567 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
2569 //if( percent > oldprecentage )
2571 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) percent
,0);
2572 oldprecentage
= percent
;
2577 g_Git
.m_critGitDllSec
.Lock();
2578 git_close_log(m_DllGitLog
);
2579 g_Git
.m_critGitDllSec
.Unlock();
2585 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2590 PostMessage(LVM_SETITEMCOUNT
, (WPARAM
) this->m_logEntries
.size(),(LPARAM
) LVSICF_NOINVALIDATEALL
|LVSICF_NOSCROLL
);
2592 if (lastSelectedHashNItem
>= 0)
2593 PostMessage(m_ScrollToMessage
, lastSelectedHashNItem
);
2596 ::PostMessage(this->GetParent()->m_hWnd
,MSG_LOAD_PERCENTAGE
,(WPARAM
) GITLOG_END
,0);
2598 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2603 void CGitLogListBase::Refresh(BOOL IsCleanFilter
)
2605 SafeTerminateThread();
2607 this->SetItemCountEx(0);
2612 // HACK to hide graph column
2613 if (m_ShowMask
& CGit::LOG_INFO_FOLLOW
)
2614 SetColumnWidth(0, 0);
2616 SetColumnWidth(0, m_ColumnManager
.GetWidth(0, false));
2618 //Update branch and Tag info
2620 //Assume Thread have exited
2621 //if(!m_bThreadRunning)
2623 m_logEntries
.clear();
2627 m_sFilterText
.Empty();
2632 InterlockedExchange(&m_bExitThread
,FALSE
);
2634 InterlockedExchange(&m_bThreadRunning
, TRUE
);
2635 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
2636 if ( (m_LoadingThread
=AfxBeginThread(LogThreadEntry
, this)) ==NULL
)
2638 InterlockedExchange(&m_bThreadRunning
, FALSE
);
2639 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
2640 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
2644 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str
, tr1::wregex
& pat
, bool bMatchCase
/* = false */)
2648 tr1::regex_constants::syntax_option_type type
= tr1::regex_constants::ECMAScript
;
2650 type
|= tr1::regex_constants::icase
;
2651 pat
= tr1::wregex(regexp_str
, type
);
2654 catch (exception
) {}
2657 BOOL
CGitLogListBase::IsMatchFilter(bool bRegex
, GitRev
*pRev
, tr1::wregex
&pat
)
2660 tr1::regex_constants::match_flag_type flags
= tr1::regex_constants::match_any
;
2663 if ((bRegex
)&&(m_bFilterWithRegex
))
2665 if (m_SelectedFilters
& LOGFILTER_BUGID
)
2667 if(this->m_bShowBugtraqColumn
)
2669 CString sBugIds
= m_ProjectProperties
.FindBugID(pRev
->GetSubject() + _T("\r\n\r\n") + pRev
->GetBody());
2671 ATLTRACE(_T("bugID = \"%s\"\n"), sBugIds
);
2672 if (regex_search(wstring(sBugIds
), pat
, flags
))
2679 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
2681 ATLTRACE(_T("messge = \"%s\"\n"), pRev
->GetSubject());
2682 if (regex_search(wstring((LPCTSTR
)pRev
->GetSubject()), pat
, flags
))
2688 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
2690 ATLTRACE(_T("messge = \"%s\"\n"),pRev
->GetBody());
2691 if (regex_search(wstring((LPCTSTR
)pRev
->GetBody()), pat
, flags
))
2697 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
2699 if (regex_search(wstring(pRev
->GetAuthorName()), pat
, flags
))
2704 if (regex_search(wstring(pRev
->GetCommitterName()), pat
, flags
))
2710 if (m_SelectedFilters
& LOGFILTER_REVS
)
2712 sRev
.Format(_T("%s"), pRev
->m_CommitHash
.ToString());
2713 if (regex_search(wstring((LPCTSTR
)sRev
), pat
, flags
))
2719 if (m_SelectedFilters
& LOGFILTER_PATHS
)
2721 CTGitPathList
*pathList
=NULL
;
2722 if( pRev
->m_IsDiffFiles
)
2723 pathList
= &pRev
->GetFiles(this);
2726 if(!pRev
->m_IsSimpleListReady
)
2727 pRev
->SafeGetSimpleList(&g_Git
);
2731 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
->GetCount(); ++cpPathIndex
)
2733 if (regex_search(wstring((LPCTSTR
)pathList
->m_paths
.at(cpPathIndex
).GetGitOldPathString()), pat
, flags
))
2737 if (regex_search(wstring((LPCTSTR
)pathList
->m_paths
.at(cpPathIndex
).GetGitPathString()), pat
, flags
))
2743 for(size_t i
= 0; i
< pRev
->m_SimpleFileList
.size(); i
++)
2745 if (regex_search(wstring((LPCTSTR
)pRev
->m_SimpleFileList
[i
]), pat
, flags
))
2754 CString find
= m_sFilterText
;
2757 if (m_SelectedFilters
& LOGFILTER_BUGID
)
2759 if(this->m_bShowBugtraqColumn
)
2761 CString sBugIds
= m_ProjectProperties
.FindBugID(pRev
->GetSubject() + _T("\r\n\r\n") + pRev
->GetBody());
2763 sBugIds
.MakeLower();
2764 if ((sBugIds
.Find(find
) >= 0))
2771 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
2773 CString msg
= pRev
->GetSubject();
2775 msg
= msg
.MakeLower();
2776 if ((msg
.Find(find
) >= 0))
2782 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
2784 CString msg
= pRev
->GetBody();
2786 msg
= msg
.MakeLower();
2787 if ((msg
.Find(find
) >= 0))
2793 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
2795 CString msg
= pRev
->GetAuthorName();
2796 msg
= msg
.MakeLower();
2797 if ((msg
.Find(find
) >= 0))
2803 if (m_SelectedFilters
& LOGFILTER_REVS
)
2805 sRev
.Format(_T("%s"), pRev
->m_CommitHash
.ToString());
2806 if ((sRev
.Find(find
) >= 0))
2812 if (m_SelectedFilters
& LOGFILTER_PATHS
)
2814 CTGitPathList
*pathList
=NULL
;
2815 if( pRev
->m_IsDiffFiles
)
2816 pathList
= &pRev
->GetFiles(this);
2819 if(!pRev
->m_IsSimpleListReady
)
2820 pRev
->SafeGetSimpleList(&g_Git
);
2823 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
->GetCount() ; ++cpPathIndex
)
2825 CTGitPath
*cpath
= &pathList
->m_paths
.at(cpPathIndex
);
2826 CString path
= cpath
->GetGitOldPathString();
2828 if ((path
.Find(find
)>=0))
2832 path
= cpath
->GetGitPathString();
2834 if ((path
.Find(find
)>=0))
2840 for (size_t i
= 0; i
< pRev
->m_SimpleFileList
.size(); i
++)
2842 CString path
= pRev
->m_SimpleFileList
[i
];
2844 if ((path
.Find(find
)>=0))
2850 } // else (from if (bRegex))
2855 void CGitLogListBase::RecalculateShownList(CThreadSafePtrArray
* pShownlist
)
2858 pShownlist
->SafeRemoveAll();
2860 tr1::wregex pat
;//(_T("Remove"), tr1::regex_constants::icase);
2861 bool bRegex
= false;
2862 if (m_bFilterWithRegex
)
2863 bRegex
= ValidateRegexp(m_sFilterText
, pat
, false);
2865 tr1::regex_constants::match_flag_type flags
= tr1::regex_constants::match_any
;
2867 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
2869 if ((bRegex
)&&(m_bFilterWithRegex
))
2872 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_BUGID
))
2874 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR
)m_logEntries
[i
]->sBugIDs
);
2875 if (regex_search(wstring((LPCTSTR
)m_logEntries
[i
]->sBugIDs
), pat
, flags
)&&IsEntryInDateRange(i
))
2877 pShownlist
->SafeAdd(m_logEntries
[i
]);
2882 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
2884 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries
.GetGitRevAt(i
).GetSubject());
2885 if (regex_search(wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).GetSubject()), pat
, flags
)&&IsEntryInDateRange(i
))
2887 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2891 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
2893 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries
.GetGitRevAt(i
).GetBody());
2894 if (regex_search(wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).GetBody()), pat
, flags
)&&IsEntryInDateRange(i
))
2896 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2900 if (m_SelectedFilters
& LOGFILTER_PATHS
)
2902 CTGitPathList pathList
= m_logEntries
.GetGitRevAt(i
).GetFiles(this);
2905 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
.GetCount() && bGoing
; ++cpPathIndex
)
2907 CTGitPath cpath
= pathList
[cpPathIndex
];
2908 if (regex_search(wstring((LPCTSTR
)cpath
.GetGitOldPathString()), pat
, flags
)&&IsEntryInDateRange(i
))
2910 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2914 if (regex_search(wstring((LPCTSTR
)cpath
.GetGitPathString()), pat
, flags
)&&IsEntryInDateRange(i
))
2916 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2920 if (regex_search(wstring((LPCTSTR
)cpath
.GetActionName()), pat
, flags
)&&IsEntryInDateRange(i
))
2922 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2928 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
2930 if (regex_search(wstring((LPCTSTR
)m_logEntries
.GetGitRevAt(i
).GetAuthorName()), pat
, flags
)&&IsEntryInDateRange(i
))
2932 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2936 if (m_SelectedFilters
& LOGFILTER_REVS
)
2938 sRev
.Format(_T("%s"), m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString());
2939 if (regex_search(wstring((LPCTSTR
)sRev
), pat
, flags
)&&IsEntryInDateRange(i
))
2941 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2948 CString find
= m_sFilterText
;
2951 if ((m_nSelectedFilter
== LOGFILTER_ALL
)||(m_nSelectedFilter
== LOGFILTER_BUGID
))
2953 CString sBugIDs
= m_logEntries
[i
]->sBugIDs
;
2955 sBugIDs
= sBugIDs
.MakeLower();
2956 if ((sBugIDs
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2958 pShownlist
->SafeAdd(m_logEntries
[i
]);
2963 if ((m_SelectedFilters
& LOGFILTER_SUBJECT
) || (m_SelectedFilters
& LOGFILTER_MESSAGES
))
2965 CString msg
= m_logEntries
.GetGitRevAt(i
).GetSubject();
2967 msg
= msg
.MakeLower();
2968 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2970 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2974 if (m_SelectedFilters
& LOGFILTER_MESSAGES
)
2976 CString msg
= m_logEntries
.GetGitRevAt(i
).GetBody();
2978 msg
= msg
.MakeLower();
2979 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
2981 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
2985 if (m_SelectedFilters
& LOGFILTER_PATHS
)
2987 CTGitPathList pathList
= m_logEntries
.GetGitRevAt(i
).GetFiles(this);
2990 for (INT_PTR cpPathIndex
= 0; cpPathIndex
< pathList
.GetCount() && bGoing
; ++cpPathIndex
)
2992 CTGitPath cpath
= pathList
[cpPathIndex
];
2993 CString path
= cpath
.GetGitOldPathString();
2995 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
2997 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3001 path
= cpath
.GetGitPathString();
3003 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
3005 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3009 path
= cpath
.GetActionName();
3011 if ((path
.Find(find
)>=0)&&(IsEntryInDateRange(i
)))
3013 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3019 if (m_SelectedFilters
& LOGFILTER_AUTHORS
)
3021 CString msg
= m_logEntries
.GetGitRevAt(i
).GetAuthorName();
3022 msg
= msg
.MakeLower();
3023 if ((msg
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3025 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3029 if (m_SelectedFilters
& LOGFILTER_REVS
)
3031 sRev
.Format(_T("%s"), m_logEntries
.GetGitRevAt(i
).m_CommitHash
.ToString());
3032 if ((sRev
.Find(find
) >= 0)&&(IsEntryInDateRange(i
)))
3034 pShownlist
->SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3038 } // else (from if (bRegex))
3039 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
3043 BOOL
CGitLogListBase::IsEntryInDateRange(int /*i*/)
3046 __time64_t time = m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime();
3052 return time <= m_To;
3055 return time >= m_From;
3057 return ((time >= m_From)&&(time <= m_To));
3059 return TRUE
; /* git dll will filter time range */
3063 void CGitLogListBase::StartFilter()
3065 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3066 RecalculateShownList(&m_arShownList
);
3067 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3071 SetItemCountEx(ShownCountWithStopped());
3072 RedrawItems(0, ShownCountWithStopped());
3076 void CGitLogListBase::RemoveFilter()
3079 InterlockedExchange(&m_bNoDispUpdates
, TRUE
);
3081 m_arShownList
.SafeRemoveAll();
3083 // reset the time filter too
3085 m_timFrom
= (__time64_t(m_tFrom
));
3086 m_timTo
= (__time64_t(m_tTo
));
3087 m_DateFrom
.SetTime(&m_timFrom
);
3088 m_DateTo
.SetTime(&m_timTo
);
3089 m_DateFrom
.SetRange(&m_timFrom
, &m_timTo
);
3090 m_DateTo
.SetRange(&m_timFrom
, &m_timTo
);
3093 for (DWORD i
=0; i
<m_logEntries
.size(); ++i
)
3095 if(this->m_IsOldFirst
)
3097 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(m_logEntries
.size()-i
-1));
3101 m_arShownList
.SafeAdd(&m_logEntries
.GetGitRevAt(i
));
3104 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
3106 SetItemCountEx(ShownCountWithStopped());
3107 RedrawItems(0, ShownCountWithStopped());
3109 InterlockedExchange(&m_bNoDispUpdates
, FALSE
);
3112 void CGitLogListBase::Clear()
3114 m_arShownList
.SafeRemoveAll();
3117 m_logEntries
.ClearAll();
3121 void CGitLogListBase::OnDestroy()
3123 // save the column widths to the registry
3126 SafeTerminateThread();
3127 SafeTerminateAsyncDiffThread();
3130 while(m_LogCache
.SaveCache())
3138 //if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
3139 // MB_YESNO) == IDNO)
3143 CHintListCtrl::OnDestroy();
3146 LRESULT
CGitLogListBase::OnLoad(WPARAM wParam
,LPARAM lParam
)
3148 UNREFERENCED_PARAMETER(lParam
);
3151 this->GetItemRect(i
,&rect
,LVIR_BOUNDS
);
3152 this->InvalidateRect(rect
);
3158 * Save column widths to the registry
3160 void CGitLogListBase::SaveColumnWidths()
3162 int maxcol
= m_ColumnManager
.GetColumnCount();
3164 // HACK that graph column is always shown
3165 SetColumnWidth(0, m_ColumnManager
.GetWidth(0, false));
3167 for (int col
= 0; col
< maxcol
; col
++)
3168 if (m_ColumnManager
.IsVisible (col
))
3169 m_ColumnManager
.ColumnResized (col
);
3171 m_ColumnManager
.WriteSettings();
3174 int CGitLogListBase::GetHeadIndex()
3176 if(m_HeadHash
.IsEmpty())
3179 for(int i
=0;i
<m_arShownList
.GetCount();i
++)
3181 GitRev
*pRev
= (GitRev
*)m_arShownList
[i
];
3184 if(pRev
->m_CommitHash
.ToString() == m_HeadHash
)
3190 void CGitLogListBase::OnFind()
3194 m_pFindDialog
= new CFindDlg(this);
3195 m_pFindDialog
->Create(this);
3198 void CGitLogListBase::OnHdnBegintrack(NMHDR
*pNMHDR
, LRESULT
*pResult
)
3200 m_ColumnManager
.OnHdnBegintrack(pNMHDR
, pResult
);
3202 void CGitLogListBase::OnHdnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
)
3204 if(!m_ColumnManager
.OnHdnItemchanging(pNMHDR
, pResult
))
3207 LRESULT
CGitLogListBase::OnScrollToMessage(WPARAM itemToSelect
, LPARAM
/*lParam*/)
3209 SetItemState((int)itemToSelect
, LVIS_SELECTED
, LVIS_SELECTED
);
3210 EnsureVisible((int)itemToSelect
, FALSE
);
3213 LRESULT
CGitLogListBase::OnFindDialogMessage(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
3216 ASSERT(m_pFindDialog
!= NULL
);
3217 bool bFound
= false;
3220 if (m_pFindDialog
->IsTerminating())
3222 // invalidate the handle identifying the dialog box.
3223 m_pFindDialog
= NULL
;
3227 if(m_pFindDialog
->IsRef())
3230 str
=m_pFindDialog
->GetFindString();
3235 hash
= g_Git
.GetHash(str
+ _T("^{}")); // add ^{} in order to get the correct SHA-1 (especially for signed tags)
3239 for (i
= 0; i
<m_arShownList
.GetCount(); i
++)
3241 GitRev
* pLogEntry
= (GitRev
*)m_arShownList
.SafeGetAt(i
);
3242 if(pLogEntry
&& pLogEntry
->m_CommitHash
== hash
)
3252 if(m_pFindDialog
->FindNext())
3254 //read data from dialog
3255 CString FindText
= m_pFindDialog
->GetFindString();
3256 bool bMatchCase
= (m_pFindDialog
->MatchCase() == TRUE
);
3259 bool bRegex
= ValidateRegexp(FindText
, pat
, bMatchCase
);
3261 tr1::regex_constants::match_flag_type flags
= tr1::regex_constants::match_not_null
;
3264 for (i
= this->m_nSearchIndex
; i
<m_arShownList
.GetCount()&&!bFound
; i
++)
3266 GitRev
* pLogEntry
= (GitRev
*)m_arShownList
.SafeGetAt(i
);
3269 str
+=pLogEntry
->m_CommitHash
.ToString();
3272 for(int j
=0;j
<this->m_HashMap
[pLogEntry
->m_CommitHash
].size();j
++)
3274 str
+=m_HashMap
[pLogEntry
->m_CommitHash
][j
];
3278 str
+=pLogEntry
->GetAuthorEmail();
3280 str
+=pLogEntry
->GetAuthorName();
3282 str
+=pLogEntry
->GetBody();
3284 str
+=pLogEntry
->GetCommitterEmail();
3286 str
+=pLogEntry
->GetCommitterName();
3288 str
+=pLogEntry
->GetSubject();
3292 /*Because changed files list is loaded on demand when gui show,
3293 files will empty when files have not fetched.
3295 we can add it back by using one-way diff(with outnumber changed and rename detect.
3296 here just need changed filename list. one-way is much quicker.
3298 if(pLogEntry
->m_IsFull
)
3300 for(int i
=0;i
<pLogEntry
->GetFiles(this).GetCount();i
++)
3302 str
+=pLogEntry
->GetFiles(this)[i
].GetWinPath();
3304 str
+=pLogEntry
->GetFiles(this)[i
].GetGitOldPathString();
3310 if(!pLogEntry
->m_IsSimpleListReady
)
3311 pLogEntry
->SafeGetSimpleList(&g_Git
);
3313 for(int i
=0;i
<pLogEntry
->m_SimpleFileList
.size();i
++)
3315 str
+=pLogEntry
->m_SimpleFileList
[i
];
3324 if (regex_search(wstring(str
), pat
, flags
))
3334 if (str
.Find(FindText
) >= 0)
3344 msg
= msg
.MakeLower();
3345 CString find
= FindText
.MakeLower();
3346 if (msg
.Find(find
) >= 0)
3353 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; i++)
3355 } // if(m_pFindDialog->FindNext())
3356 //UpdateLogInfoLabel();
3360 this->m_nSearchIndex
= i
;
3361 EnsureVisible(i
, FALSE
);
3362 SetItemState(GetSelectionMark(), 0, LVIS_SELECTED
);
3363 SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
3364 SetSelectionMark(i
);
3365 //FillLogMessageCtrl();
3368 if (m_nSearchIndex
>= m_arShownList
.GetCount())
3369 m_nSearchIndex
= (int)m_arShownList
.GetCount()-1;
3375 void CGitLogListBase::OnColumnResized(NMHDR
*pNMHDR
, LRESULT
*pResult
)
3377 m_ColumnManager
.OnColumnResized(pNMHDR
,pResult
);
3382 void CGitLogListBase::OnColumnMoved(NMHDR
*pNMHDR
, LRESULT
*pResult
)
3384 m_ColumnManager
.OnColumnMoved(pNMHDR
, pResult
);