Handle libgit exception when calling git_get_notes
[TortoiseGit.git] / src / TortoiseProc / GitLogListBase.cpp
blob2fdb25486db9f2c8e7afbc96756d144d4465c798
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013 - 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
23 #include "stdafx.h"
24 #include "resource.h"
25 #include "GitLogListBase.h"
26 #include "GitRev.h"
27 #include "IconMenu.h"
28 #include "cursor.h"
29 #include "InputDlg.h"
30 #include "GitProgressDlg.h"
31 #include "ProgressDlg.h"
32 #include "LogDlg.h"
33 #include "MessageBox.h"
34 #include "registry.h"
35 #include "LoglistUtils.h"
36 #include "PathUtils.h"
37 #include "StringUtils.h"
38 #include "UnicodeUtils.h"
39 #include "TempFile.h"
40 #include "IconMenu.h"
41 #include "GitStatus.h"
42 #include "..\\TortoiseShell\\Resource.h"
43 #include "FindDlg.h"
44 #include "SysInfo.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)
54 ,m_nSearchIndex(0)
55 ,m_bNoDispUpdates(FALSE)
56 , m_bThreadRunning(FALSE)
57 , m_bStrictStopped(false)
58 , m_pStoreSelection(NULL)
59 , m_SelectedFilters(LOGFILTER_ALL)
60 , m_bShowWC(false)
61 , m_logEntries(&m_LogCache)
62 , m_pFindDialog(NULL)
63 , m_ColumnManager(this)
64 , m_dwDefaultColumns(0)
65 , m_arShownList(&m_critSec)
66 , m_hasWC(true)
67 , m_bNoHightlightHead(FALSE)
68 , m_ShowRefMask(LOGLIST_SHOWALLREFS)
70 // use the default GUI font, create a copy of it and
71 // change the copy to BOLD (leave the rest of the font
72 // the same)
73 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
74 LOGFONT lf = {0};
75 GetObject(hFont, sizeof(LOGFONT), &lf);
76 lf.lfWeight = FW_BOLD;
77 m_boldFont = CreateFontIndirect(&lf);
79 m_bShowBugtraqColumn=false;
81 m_IsIDReplaceAction=FALSE;
83 this->m_critSec.Init();
84 m_critSec_AsyncDiff.Init();
85 m_wcRev.m_CommitHash.Empty();
86 m_wcRev.GetSubject() = CString(MAKEINTRESOURCE(IDS_LOG_WORKINGDIRCHANGES));
87 m_wcRev.m_ParentHash.clear();
88 m_wcRev.m_Mark=_T('-');
89 m_wcRev.m_IsUpdateing=FALSE;
90 m_wcRev.m_IsFull = TRUE;
92 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
93 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
94 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
95 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
96 m_hFetchIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONFETCHING), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
98 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
100 m_From = -1;
101 m_To = -1;
103 m_ShowMask = 0;
104 m_LoadingThread = NULL;
106 InterlockedExchange(&m_bExitThread,FALSE);
107 m_IsOldFirst = FALSE;
108 m_IsRebaseReplaceGraph = FALSE;
110 for (int i = 0; i < Lanes::COLORS_NUM; ++i)
112 m_LineColors[i] = m_Colors.GetColor((CColors::Colors)(CColors::BranchLine1+i));
114 // get short/long datetime setting from registry
115 DWORD RegUseShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE);
116 if ( RegUseShortDateFormat )
118 m_DateFormat = DATE_SHORTDATE;
120 else
122 m_DateFormat = DATE_LONGDATE;
124 // get relative time display setting from registry
125 DWORD regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE);
126 m_bRelativeTimes = (regRelativeTimes != 0);
127 m_ContextMenuMask = 0xFFFFFFFFFFFFFFFF;
129 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_PICK);
130 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SQUASH);
131 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_EDIT);
132 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SKIP);
133 m_ContextMenuMask &= ~GetContextMenuBit(ID_LOG);
134 m_ContextMenuMask &= ~GetContextMenuBit(ID_BLAME);
136 m_ColumnRegKey=_T("log");
138 m_bTagsBranchesOnRightSide = !!CRegDWORD(_T("Software\\TortoiseGit\\DrawTagsBranchesOnRightSide"), FALSE);
139 m_bSymbolizeRefNames = !!CRegDWORD(_T("Software\\TortoiseGit\\SymbolizeRefNames"), FALSE);
140 m_bIncludeBoundaryCommits = !!CRegDWORD(_T("Software\\TortoiseGit\\LogIncludeBoundaryCommits"), FALSE);
142 m_LineWidth = max(1, CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Graph\\LogLineWidth"), 2));
143 m_NodeSize = max(1, CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Graph\\LogNodeSize"), 10));
145 m_AsyncThreadExit = FALSE;
146 m_AsyncDiffEvent = ::CreateEvent(NULL,FALSE,TRUE,NULL);
147 m_AsynDiffListLock.Init();
149 m_DiffingThread = AfxBeginThread(AsyncThread, this, THREAD_PRIORITY_BELOW_NORMAL);
150 if (m_DiffingThread ==NULL)
152 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
153 return;
158 int CGitLogListBase::AsyncDiffThread()
160 m_AsyncThreadExited = false;
161 while(!m_AsyncThreadExit)
163 ::WaitForSingleObject(m_AsyncDiffEvent, INFINITE);
165 GitRev *pRev = NULL;
166 while(!m_AsyncThreadExit && !m_AsynDiffList.empty())
168 m_AsynDiffListLock.Lock();
169 pRev = m_AsynDiffList.back();
170 m_AsynDiffList.pop_back();
171 m_AsynDiffListLock.Unlock();
173 if( pRev->m_CommitHash.IsEmpty() )
175 if(pRev->m_IsDiffFiles)
176 continue;
178 pRev->GetFiles(this).Clear();
179 pRev->m_ParentHash.clear();
180 pRev->m_ParentHash.push_back(m_HeadHash);
181 if(g_Git.IsInitRepos())
183 if (g_Git.GetInitAddList(pRev->GetFiles(this)))
184 CMessageBox::Show(NULL, _T("Run ls-files failed!"), _T("TortoiseGit"), MB_OK | MB_ICONERROR);
187 else
189 g_Git.GetCommitDiffList(pRev->m_CommitHash.ToString(),this->m_HeadHash.ToString(), pRev->GetFiles(this));
191 int dummyAction = 0;
192 int *action = &dummyAction;
193 SafeGetAction(pRev, &action);
194 *action = 0;
196 for (int j = 0; j < pRev->GetFiles(this).GetCount(); ++j)
197 *action |= pRev->GetFiles(this)[j].m_Action;
199 pRev->GetUnRevFiles().FillUnRev(CTGitPath::LOGACTIONS_UNVER);
201 InterlockedExchange(&pRev->m_IsDiffFiles, TRUE);
202 InterlockedExchange(&pRev->m_IsFull, TRUE);
204 pRev->GetBody().Format(IDS_FILESCHANGES, pRev->GetFiles(this).GetCount());
205 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)0,0);
206 this->GetParent()->PostMessage(WM_COMMAND, MSG_FETCHED_DIFF, 0);
209 m_critSec_AsyncDiff.Lock();
210 int ret = pRev->CheckAndDiff();
211 m_critSec_AsyncDiff.Unlock();
212 if (!ret)
213 { // fetch change file list
214 for (int i = GetTopIndex(); !m_AsyncThreadExit && i <= GetTopIndex() + GetCountPerPage(); ++i)
216 if(i < m_arShownList.GetCount())
218 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(i);
219 if(data->m_CommitHash == pRev->m_CommitHash)
221 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)i,0);
222 break;
227 if(!m_AsyncThreadExit && GetSelectedCount() == 1)
229 POSITION pos = GetFirstSelectedItemPosition();
230 int nItem = GetNextSelectedItem(pos);
232 if(nItem>=0)
234 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(nItem);
235 if(data)
236 if(data->m_CommitHash == pRev->m_CommitHash)
238 this->GetParent()->PostMessage(WM_COMMAND, MSG_FETCHED_DIFF, 0);
245 m_AsyncThreadExited = true;
246 return 0;
248 void CGitLogListBase::hideFromContextMenu(unsigned __int64 hideMask, bool exclusivelyShow)
250 if (exclusivelyShow)
252 m_ContextMenuMask &= hideMask;
254 else
256 m_ContextMenuMask &= ~hideMask;
260 CGitLogListBase::~CGitLogListBase()
262 InterlockedExchange(&m_bNoDispUpdates, TRUE);
263 this->m_arShownList.SafeRemoveAll();
265 DestroyIcon(m_hModifiedIcon);
266 DestroyIcon(m_hReplacedIcon);
267 DestroyIcon(m_hAddedIcon);
268 DestroyIcon(m_hDeletedIcon);
269 m_logEntries.ClearAll();
271 if (m_boldFont)
272 DeleteObject(m_boldFont);
274 if ( m_pStoreSelection )
276 delete m_pStoreSelection;
277 m_pStoreSelection = NULL;
280 SafeTerminateThread();
281 SafeTerminateAsyncDiffThread();
283 if(m_AsyncDiffEvent)
284 CloseHandle(m_AsyncDiffEvent);
288 BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
289 ON_REGISTERED_MESSAGE(m_FindDialogMessage, OnFindDialogMessage)
290 ON_REGISTERED_MESSAGE(m_ScrollToMessage, OnScrollToMessage)
291 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
292 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
293 ON_WM_CONTEXTMENU()
294 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
295 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
296 ON_WM_CREATE()
297 ON_WM_DESTROY()
298 ON_MESSAGE(MSG_LOADED,OnLoad)
299 ON_WM_MEASUREITEM()
300 ON_WM_MEASUREITEM_REFLECT()
301 ON_NOTIFY(HDN_BEGINTRACKA, 0, OnHdnBegintrack)
302 ON_NOTIFY(HDN_BEGINTRACKW, 0, OnHdnBegintrack)
303 ON_NOTIFY(HDN_ITEMCHANGINGA, 0, OnHdnItemchanging)
304 ON_NOTIFY(HDN_ITEMCHANGINGW, 0, OnHdnItemchanging)
305 ON_NOTIFY(HDN_ENDTRACK, 0, OnColumnResized)
306 ON_NOTIFY(HDN_ENDDRAG, 0, OnColumnMoved)
307 END_MESSAGE_MAP()
309 void CGitLogListBase::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
311 //if (m_nRowHeight>0)
313 lpMeasureItemStruct->itemHeight = 50;
317 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
319 PreSubclassWindow();
320 return CHintListCtrl::OnCreate(lpCreateStruct);
323 void CGitLogListBase::PreSubclassWindow()
325 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
326 // load the icons for the action columns
327 // m_Theme.Open(m_hWnd, L"ListView");
328 SetWindowTheme(m_hWnd, L"Explorer", NULL);
329 CHintListCtrl::PreSubclassWindow();
332 void CGitLogListBase::InsertGitColumn()
334 CString temp;
336 CRegDWORD regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE);
337 DWORD exStyle = LVS_EX_HEADERDRAGDROP | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_SUBITEMIMAGES;
338 if (DWORD(regFullRowSelect))
339 exStyle |= LVS_EX_FULLROWSELECT;
340 SetExtendedStyle(exStyle);
342 // only load properties if we have a repository
343 if (GitAdminDir().HasAdminDir(g_Git.m_CurrentDir) || GitAdminDir().IsBareRepo(g_Git.m_CurrentDir))
344 UpdateProjectProperties();
346 static UINT normal[] =
348 IDS_LOG_GRAPH,
349 IDS_LOG_REBASE,
350 IDS_LOG_ID,
351 IDS_LOG_HASH,
352 IDS_LOG_ACTIONS,
353 IDS_LOG_MESSAGE,
354 IDS_LOG_AUTHOR,
355 IDS_LOG_DATE,
356 IDS_LOG_EMAIL,
357 IDS_LOG_COMMIT_NAME,
358 IDS_LOG_COMMIT_EMAIL,
359 IDS_LOG_COMMIT_DATE,
360 IDS_LOG_BUGIDS,
363 static int with[] =
365 ICONITEMBORDER+16*4,
366 ICONITEMBORDER+16*4,
367 ICONITEMBORDER+16*4,
368 ICONITEMBORDER+16*4,
369 ICONITEMBORDER+16*4,
370 LOGLIST_MESSAGE_MIN,
371 ICONITEMBORDER+16*4,
372 ICONITEMBORDER+16*4,
373 ICONITEMBORDER+16*4,
374 ICONITEMBORDER+16*4,
375 ICONITEMBORDER+16*4,
376 ICONITEMBORDER+16*4,
377 ICONITEMBORDER+16*4,
379 m_dwDefaultColumns = GIT_LOG_GRAPH|GIT_LOG_ACTIONS|GIT_LOG_MESSAGE|GIT_LOG_AUTHOR|GIT_LOG_DATE;
381 DWORD hideColumns = 0;
382 if(this->m_IsRebaseReplaceGraph)
384 hideColumns |= GIT_LOG_GRAPH;
385 m_dwDefaultColumns |= GIT_LOG_REBASE;
387 else
389 hideColumns |= GIT_LOG_REBASE;
392 if(this->m_IsIDReplaceAction)
394 hideColumns |= GIT_LOG_ACTIONS;
395 m_dwDefaultColumns |= GIT_LOG_ID;
396 m_dwDefaultColumns |= GIT_LOG_HASH;
398 else
400 hideColumns |= GIT_LOG_ID;
402 if(this->m_bShowBugtraqColumn)
404 m_dwDefaultColumns |= GIT_LOGLIST_BUG;
406 else
408 hideColumns |= GIT_LOGLIST_BUG;
410 SetRedraw(false);
412 m_ColumnManager.SetNames(normal, _countof(normal));
413 m_ColumnManager.ReadSettings(m_dwDefaultColumns, hideColumns, m_ColumnRegKey+_T("loglist"), _countof(normal), with);
415 SetRedraw(true);
419 * Resizes all columns in a list control to values in registry.
421 void CGitLogListBase::ResizeAllListCtrlCols()
423 // column max and min widths to allow
424 static const int nMinimumWidth = 10;
425 static const int nMaximumWidth = 1000;
426 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
427 if (pHdrCtrl)
429 int numcols = pHdrCtrl->GetItemCount();
430 for (int col = 0; col < numcols; ++col)
432 // get width for this col last time from registry
433 CString regentry;
434 regentry.Format( _T("Software\\TortoiseGit\\%s\\ColWidth%d"),m_ColumnRegKey, col);
435 CRegDWORD regwidth(regentry, 0);
436 int cx = regwidth;
437 if ( cx == 0 )
439 // no saved value, setup sensible defaults
440 if (col == this->LOGLIST_MESSAGE)
442 cx = LOGLIST_MESSAGE_MIN;
444 else
446 cx = ICONITEMBORDER+16*4;
449 if (cx < nMinimumWidth)
451 cx = nMinimumWidth;
453 else if (cx > nMaximumWidth)
455 cx = nMaximumWidth;
458 SetColumnWidth(col, cx);
465 void CGitLogListBase::FillBackGround(HDC hdc, DWORD_PTR Index, CRect &rect)
467 LVITEM rItem;
468 SecureZeroMemory(&rItem, sizeof(LVITEM));
469 rItem.mask = LVIF_STATE;
470 rItem.iItem = (int)Index;
471 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
472 GetItem(&rItem);
474 GitRev* pLogEntry = (GitRev*)m_arShownList.SafeGetAt(Index);
475 HBRUSH brush = NULL;
477 if (!(rItem.state & LVIS_SELECTED))
479 int action = SafeGetAction(pLogEntry);
480 if (action & CTGitPath::LOGACTIONS_REBASE_SQUASH)
481 brush = ::CreateSolidBrush(RGB(156,156,156));
482 else if (action & CTGitPath::LOGACTIONS_REBASE_EDIT)
483 brush = ::CreateSolidBrush(RGB(200,200,128));
485 else if (!(IsAppThemed() && SysInfo::Instance().IsVistaOrLater()))
487 if (rItem.state & LVIS_SELECTED)
489 if (::GetFocus() == m_hWnd)
490 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
491 else
492 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
495 InvalidateRect(rect);
496 if (brush != NULL)
498 ::FillRect(hdc, &rect, brush);
499 ::DeleteObject(brush);
503 void DrawTrackingRoundRect(HDC hdc, CRect rect, HBRUSH brush, COLORREF darkColor)
505 POINT point = { 4, 4 };
506 CRect rt2 = rect;
507 rt2.DeflateRect(1, 1);
508 rt2.OffsetRect(2, 2);
510 HPEN nullPen = ::CreatePen(PS_NULL, 0, 0);
511 HPEN oldpen = (HPEN)::SelectObject(hdc, nullPen);
512 HBRUSH darkBrush = (HBRUSH)::CreateSolidBrush(darkColor);
513 HBRUSH oldbrush = (HBRUSH)::SelectObject(hdc, darkBrush);
514 ::RoundRect(hdc, rt2.left, rt2.top, rt2.right, rt2.bottom, point.x, point.y);
516 ::SelectObject(hdc, brush);
517 rt2.OffsetRect(-2, -2);
518 ::RoundRect(hdc, rt2.left, rt2.top, rt2.right, rt2.bottom, point.x, point.y);
519 ::SelectObject(hdc, oldbrush);
520 ::SelectObject(hdc, oldpen);
521 ::DeleteObject(nullPen);
522 ::DeleteObject(darkBrush);
525 void DrawLightning(HDC hdc, CRect rect, COLORREF color, int bold)
527 HPEN pen = ::CreatePen(PS_SOLID, bold, color);
528 HPEN oldpen = (HPEN)::SelectObject(hdc, pen);
529 ::MoveToEx(hdc, rect.left + 7, rect.top, NULL);
530 ::LineTo(hdc, rect.left + 1, (rect.top + rect.bottom) / 2);
531 ::LineTo(hdc, rect.left + 6, (rect.top + rect.bottom) / 2);
532 ::LineTo(hdc, rect.left, rect.bottom);
533 ::SelectObject(hdc, oldpen);
534 ::DeleteObject(pen);
537 void DrawUpTriangle(HDC hdc, CRect rect, COLORREF color, int bold)
539 HPEN pen = ::CreatePen(PS_SOLID, bold, color);
540 HPEN oldpen = (HPEN)::SelectObject(hdc, pen);
541 ::MoveToEx(hdc, (rect.left + rect.right) / 2, rect.top, NULL);
542 ::LineTo(hdc, rect.left, rect.bottom);
543 ::LineTo(hdc, rect.right, rect.bottom);
544 ::LineTo(hdc, (rect.left + rect.right) / 2, rect.top);
545 ::SelectObject(hdc, oldpen);
546 ::DeleteObject(pen);
549 void CGitLogListBase::DrawTagBranchMessage(HDC hdc, CRect &rect, INT_PTR index, std::vector<REFLABEL> &refList)
551 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(index);
552 CRect rt=rect;
553 LVITEM rItem;
554 SecureZeroMemory(&rItem, sizeof(LVITEM));
555 rItem.mask = LVIF_STATE;
556 rItem.iItem = (int)index;
557 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
558 GetItem(&rItem);
560 CDC W_Dc;
561 W_Dc.Attach(hdc);
563 HTHEME hTheme = NULL;
564 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
565 hTheme = OpenThemeData(m_hWnd, L"Explorer::ListView;ListView");
567 if (!m_bTagsBranchesOnRightSide)
568 DrawTagBranch(hdc, W_Dc, hTheme, rect, rt, rItem, data, refList);
570 SIZE oneSpaceSize;
571 GetTextExtentPoint32(hdc, L" ", 1, &oneSpaceSize);
572 rt.left += oneSpaceSize.cx;
574 if (IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
576 int txtState = LISS_NORMAL;
577 if (rItem.state & LVIS_SELECTED)
578 txtState = LISS_SELECTED;
580 DrawThemeText(hTheme, hdc, LVP_LISTITEM, txtState, data->GetSubject(), -1, DT_NOPREFIX | DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS, 0, &rt);
582 else
584 if (rItem.state & LVIS_SELECTED)
586 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
587 ::DrawText(hdc,data->GetSubject(), data->GetSubject().GetLength(), &rt, DT_NOPREFIX | DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS);
588 ::SetTextColor(hdc, clrOld);
590 else
592 ::DrawText(hdc, data->GetSubject(), data->GetSubject().GetLength(), &rt, DT_NOPREFIX | DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS);
596 if (m_bTagsBranchesOnRightSide)
598 SIZE size;
599 GetTextExtentPoint32(hdc, data->GetSubject(), data->GetSubject().GetLength(), &size);
601 rt.left += oneSpaceSize.cx + size.cx;
603 DrawTagBranch(hdc, W_Dc, hTheme, rect, rt, rItem, data, refList);
606 if (hTheme)
607 CloseThemeData(hTheme);
609 W_Dc.Detach();
612 void CGitLogListBase::DrawTagBranch(HDC hdc, CDC &W_Dc, HTHEME hTheme, CRect &rect, CRect &rt, LVITEM &rItem, GitRev* data, std::vector<REFLABEL> &refList)
614 for (unsigned int i = 0; i < refList.size(); ++i)
616 CString shortname = !refList[i].simplifiedName.IsEmpty() ? refList[i].simplifiedName : refList[i].name;
617 HBRUSH brush = 0;
618 COLORREF colRef = refList[i].color;
619 bool singleRemote = refList[i].singleRemote;
620 bool hasTracking = refList[i].hasTracking;
621 bool sameName = refList[i].sameName;
622 bool annotatedTag = refList[i].annotatedTag;
624 //When row selected, ajust label color
625 if (!(IsAppThemed() && SysInfo::Instance().IsVistaOrLater()))
627 if (rItem.state & LVIS_SELECTED)
628 colRef = CColors::MixColors(colRef, ::GetSysColor(COLOR_HIGHLIGHT), 150);
631 brush = ::CreateSolidBrush(colRef);
633 if (!shortname.IsEmpty() && (rt.left < rect.right))
635 SIZE size;
636 memset(&size,0,sizeof(SIZE));
637 GetTextExtentPoint32(hdc, shortname, shortname.GetLength(), &size);
639 rt.SetRect(rt.left, rt.top, rt.left + size.cx, rt.bottom);
640 rt.right += 8;
642 int textpos = DT_CENTER;
644 if (rt.right > rect.right)
646 rt.right = rect.right;
647 textpos = 0;
650 CRect textRect = rt;
652 if (singleRemote)
654 rt.right += 8;
655 textRect.OffsetRect(8, 0);
658 if (sameName)
659 rt.right += 8;
661 if (hasTracking)
663 DrawTrackingRoundRect(hdc, rt, brush, m_Colors.Darken(colRef, 100));
665 else
667 //Fill interior of ref label
668 ::FillRect(hdc, &rt, brush);
671 //Draw edge of label
672 CRect rectEdge = rt;
674 if (!hasTracking)
676 W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef, 100), m_Colors.Darken(colRef, 100));
677 rectEdge.DeflateRect(1, 1);
678 W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef, 50), m_Colors.Darken(colRef, 50));
681 if (annotatedTag)
683 rt.right += 8;
684 POINT trianglept[3] = { { rt.right - 8, rt.top }, { rt.right, (rt.top + rt.bottom) / 2 }, { rt.right - 8, rt.bottom } };
685 HRGN hrgn = ::CreatePolygonRgn(trianglept, 3, ALTERNATE);
686 ::FillRgn(hdc, hrgn, brush);
687 ::DeleteObject(hrgn);
688 ::MoveToEx(hdc, trianglept[0].x - 1, trianglept[0].y, NULL);
689 HPEN pen;
690 HPEN oldpen = (HPEN)SelectObject(hdc, pen = ::CreatePen(PS_SOLID, 2, m_Colors.Lighten(colRef, 50)));
691 ::LineTo(hdc, trianglept[1].x - 1, trianglept[1].y - 1);
692 ::DeleteObject(pen);
693 SelectObject(hdc, pen = ::CreatePen(PS_SOLID, 2, m_Colors.Darken(colRef, 50)));
694 ::LineTo(hdc, trianglept[2].x - 1, trianglept[2].y - 1);
695 ::DeleteObject(pen);
696 SelectObject(hdc, pen = ::CreatePen(PS_SOLID, 2, colRef));
697 ::MoveToEx(hdc, trianglept[0].x - 1, trianglept[2].y - 3, NULL);
698 ::LineTo(hdc, trianglept[0].x - 1, trianglept[0].y);
699 ::DeleteObject(pen);
700 SelectObject(hdc, oldpen);
703 //Draw text inside label
704 bool customColor = (colRef & 0xff) * 30 + ((colRef >> 8) & 0xff) * 59 + ((colRef >> 16) & 0xff) * 11 <= 12800; // check if dark background
705 if (!customColor && IsAppThemed() && SysInfo::Instance().IsVistaOrLater())
707 int txtState = LISS_NORMAL;
708 if (rItem.state & LVIS_SELECTED)
709 txtState = LISS_SELECTED;
711 DrawThemeText(hTheme, hdc, LVP_LISTITEM, txtState, shortname, -1, textpos | DT_SINGLELINE | DT_VCENTER, 0, &textRect);
713 else
715 W_Dc.SetBkMode(TRANSPARENT);
716 if (customColor || (rItem.state & LVIS_SELECTED))
718 COLORREF clrNew = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
719 COLORREF clrOld = ::SetTextColor(hdc,clrNew);
720 ::DrawText(hdc, shortname, shortname.GetLength(), &textRect, textpos | DT_SINGLELINE | DT_VCENTER);
721 ::SetTextColor(hdc,clrOld);
723 else
725 ::DrawText(hdc, shortname, shortname.GetLength(), &textRect, textpos | DT_SINGLELINE | DT_VCENTER);
729 if (singleRemote)
731 COLORREF color = ::GetSysColor(customColor ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
732 int bold = data->m_CommitHash == m_HeadHash ? 2 : 1;
733 CRect newRect;
734 newRect.SetRect(rt.left + 4, rt.top + 4, rt.left + 8, rt.bottom - 4);
735 DrawLightning(hdc, newRect, color, bold);
738 if (sameName)
740 COLORREF color = ::GetSysColor(customColor ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
741 int bold = data->m_CommitHash == m_HeadHash ? 2 : 1;
742 CRect newRect;
743 newRect.SetRect(rt.right - 12, rt.top + 4, rt.right - 4, rt.bottom - 4);
744 DrawUpTriangle(hdc, newRect, color, bold);
747 rt.left = rt.right + 1;
749 if (brush)
750 ::DeleteObject(brush);
752 rt.right = rect.right;
755 static COLORREF blend(const COLORREF& col1, const COLORREF& col2, int amount = 128) {
757 // Returns ((256 - amount)*col1 + amount*col2) / 256;
758 return RGB(((256 - amount)*GetRValue(col1) + amount*GetRValue(col2) ) / 256,
759 ((256 - amount)*GetGValue(col1) + amount*GetGValue(col2) ) / 256,
760 ((256 - amount)*GetBValue(col1) + amount*GetBValue(col2) ) / 256);
763 Gdiplus::Color GetGdiColor(COLORREF col)
765 return Gdiplus::Color(GetRValue(col),GetGValue(col),GetBValue(col));
767 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
768 const COLORREF& col,const COLORREF& activeColor, int top
771 int h = laneHeight / 2;
772 int m = (x1 + x2) / 2;
773 int r = (x2 - x1) * m_NodeSize / 30;
774 int d = 2 * r;
776 #define P_CENTER m , h+top
777 #define P_0 x2, h+top
778 #define P_90 m , 0+top-1
779 #define P_180 x1, h+top
780 #define P_270 m , 2 * h+top +1
781 #define R_CENTER m - r, h - r+top, d, d
784 #define DELTA_UR_B 2*(x1 - m), 2*h +top
785 #define DELTA_UR_E 0*16, 90*16 +top // -,
787 #define DELTA_DR_B 2*(x1 - m), 2*-h +top
788 #define DELTA_DR_E 270*16, 90*16 +top // -'
790 #define DELTA_UL_B 2*(x2 - m), 2*h +top
791 #define DELTA_UL_E 90*16, 90*16 +top // ,-
793 #define DELTA_DL_B 2*(x2 - m),2*-h +top
794 #define DELTA_DL_E 180*16, 90*16 // '-
796 #define CENTER_UR x1, 2*h, 225
797 #define CENTER_DR x1, 0 , 135
798 #define CENTER_UL x2, 2*h, 315
799 #define CENTER_DL x2, 0 , 45
802 Gdiplus::Graphics graphics( hdc );
804 graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
806 // arc
807 switch (type) {
808 case Lanes::JOIN:
809 case Lanes::JOIN_R:
810 case Lanes::HEAD:
811 case Lanes::HEAD_R:
813 Gdiplus::LinearGradientBrush gradient(
814 Gdiplus::Point(x1-2, h+top-2),
815 Gdiplus::Point(P_270),
816 GetGdiColor(activeColor),GetGdiColor(col));
819 Gdiplus::Pen mypen(&gradient, m_LineWidth);
820 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
822 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
823 graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top+h-1, x2-x1,laneHeight,270,90);
824 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
826 break;
828 case Lanes::JOIN_L:
831 Gdiplus::LinearGradientBrush gradient(
832 Gdiplus::Point(P_270),
833 Gdiplus::Point(x2+1, h+top-1),
834 GetGdiColor(col),GetGdiColor(activeColor));
837 Gdiplus::Pen mypen(&gradient, m_LineWidth);
838 //Gdiplus::Pen mypen(Gdiplus::Color(0,0,0),2);
840 //graphics.DrawRectangle(&mypen,x1-(x2-x1)/2,top+h, x2-x1,laneHeight);
841 graphics.DrawArc(&mypen,x1+(x2-x1)/2,top+h-1, x2-x1,laneHeight,180,90);
842 //graphics.DrawLine(&mypen,x1-1,h+top,P_270);
845 break;
847 case Lanes::TAIL:
848 case Lanes::TAIL_R:
851 Gdiplus::LinearGradientBrush gradient(
852 Gdiplus::Point(x1-2, h+top-2),
853 Gdiplus::Point(P_90),
854 GetGdiColor(activeColor),GetGdiColor(col));
856 Gdiplus::Pen mypen(&gradient, m_LineWidth);
858 graphics.DrawArc(&mypen,x1-(x2-x1)/2-1,top-h-1, x2-x1,laneHeight,0,90);
860 #if 0
861 QConicalGradient gradient(CENTER_DR);
862 gradient.setColorAt(0.375, activeCol);
863 gradient.setColorAt(0.625, col);
864 myPen.setBrush(gradient);
865 p->setPen(myPen);
866 p->drawArc(P_CENTER, DELTA_DR);
867 #endif
868 break;
870 default:
871 break;
875 //static QPen myPen(Qt::black, 2); // fast path here
876 CPen pen;
877 pen.CreatePen(PS_SOLID,2,col);
878 //myPen.setColor(col);
879 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
881 Gdiplus::Pen myPen(GetGdiColor(col), m_LineWidth);
883 graphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
885 //p->setPen(myPen);
887 // vertical line
888 switch (type) {
889 case Lanes::ACTIVE:
890 case Lanes::NOT_ACTIVE:
891 case Lanes::MERGE_FORK:
892 case Lanes::MERGE_FORK_R:
893 case Lanes::MERGE_FORK_L:
894 case Lanes::JOIN:
895 case Lanes::JOIN_R:
896 case Lanes::JOIN_L:
897 case Lanes::CROSS:
898 //DrawLine(hdc,P_90,P_270);
899 graphics.DrawLine(&myPen,P_90,P_270);
900 //p->drawLine(P_90, P_270);
901 break;
902 case Lanes::HEAD_L:
903 case Lanes::BRANCH:
904 //DrawLine(hdc,P_CENTER,P_270);
905 graphics.DrawLine(&myPen,P_CENTER,P_270);
906 //p->drawLine(P_CENTER, P_270);
907 break;
908 case Lanes::TAIL_L:
909 case Lanes::INITIAL:
910 case Lanes::BOUNDARY:
911 case Lanes::BOUNDARY_C:
912 case Lanes::BOUNDARY_R:
913 case Lanes::BOUNDARY_L:
914 //DrawLine(hdc,P_90, P_CENTER);
915 graphics.DrawLine(&myPen,P_90,P_CENTER);
916 //p->drawLine(P_90, P_CENTER);
917 break;
918 default:
919 break;
922 myPen.SetColor(GetGdiColor(activeColor));
924 // horizontal line
925 switch (type) {
926 case Lanes::MERGE_FORK:
927 case Lanes::JOIN:
928 case Lanes::HEAD:
929 case Lanes::TAIL:
930 case Lanes::CROSS:
931 case Lanes::CROSS_EMPTY:
932 case Lanes::BOUNDARY_C:
933 //DrawLine(hdc,P_180,P_0);
934 graphics.DrawLine(&myPen,P_180,P_0);
935 //p->drawLine(P_180, P_0);
936 break;
937 case Lanes::MERGE_FORK_R:
938 case Lanes::BOUNDARY_R:
939 //DrawLine(hdc,P_180,P_CENTER);
940 graphics.DrawLine(&myPen,P_180,P_CENTER);
941 //p->drawLine(P_180, P_CENTER);
942 break;
943 case Lanes::MERGE_FORK_L:
944 case Lanes::HEAD_L:
945 case Lanes::TAIL_L:
946 case Lanes::BOUNDARY_L:
947 //DrawLine(hdc,P_CENTER,P_0);
948 graphics.DrawLine(&myPen,P_CENTER,P_0);
949 //p->drawLine(P_CENTER, P_0);
950 break;
951 default:
952 break;
955 graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
957 CBrush brush;
958 brush.CreateSolidBrush(col);
959 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
961 Gdiplus::SolidBrush myBrush(GetGdiColor(col));
962 // center symbol, e.g. rect or ellipse
963 switch (type) {
964 case Lanes::ACTIVE:
965 case Lanes::INITIAL:
966 case Lanes::BRANCH:
968 //p->setPen(Qt::NoPen);
969 //p->setBrush(col);
970 graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
971 graphics.FillEllipse(&myBrush, R_CENTER);
972 //p->drawEllipse(R_CENTER);
973 break;
974 case Lanes::MERGE_FORK:
975 case Lanes::MERGE_FORK_R:
976 case Lanes::MERGE_FORK_L:
977 //p->setPen(Qt::NoPen);
978 //p->setBrush(col);
979 //p->drawRect(R_CENTER);
980 graphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
981 graphics.FillRectangle(&myBrush, R_CENTER);
982 break;
983 case Lanes::UNAPPLIED:
984 // Red minus sign
985 //p->setPen(Qt::NoPen);
986 //p->setBrush(Qt::red);
987 //p->drawRect(m - r, h - 1, d, 2);
988 graphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
989 graphics.FillRectangle(&myBrush,m-r,h-1,d,2);
990 break;
991 case Lanes::APPLIED:
992 // Green plus sign
993 //p->setPen(Qt::NoPen);
994 //p->setBrush(DARK_GREEN);
995 //p->drawRect(m - r, h - 1, d, 2);
996 //p->drawRect(m - 1, h - r, 2, d);
997 graphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
998 graphics.FillRectangle(&myBrush,m-r,h-1,d,2);
999 graphics.FillRectangle(&myBrush,m-1,h-r,2,d);
1000 break;
1001 case Lanes::BOUNDARY:
1002 //p->setBrush(back);
1003 //p->drawEllipse(R_CENTER);
1004 graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
1005 graphics.DrawEllipse(&myPen, R_CENTER);
1006 break;
1007 case Lanes::BOUNDARY_C:
1008 case Lanes::BOUNDARY_R:
1009 case Lanes::BOUNDARY_L:
1010 //p->setBrush(back);
1011 //p->drawRect(R_CENTER);
1012 graphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
1013 graphics.FillRectangle(&myBrush,R_CENTER);
1014 break;
1015 default:
1016 break;
1019 ::SelectObject(hdc,oldpen);
1020 ::SelectObject(hdc,oldbrush);
1021 #undef P_CENTER
1022 #undef P_0
1023 #undef P_90
1024 #undef P_180
1025 #undef P_270
1026 #undef R_CENTER
1029 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
1031 // TODO: unfinished
1032 // return;
1033 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(index);
1034 if(data->m_CommitHash.IsEmpty())
1035 return;
1037 CRect rt=rect;
1038 LVITEM rItem;
1039 SecureZeroMemory(&rItem, sizeof(LVITEM));
1040 rItem.mask = LVIF_STATE;
1041 rItem.iItem = (int)index;
1042 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
1043 GetItem(&rItem);
1045 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
1047 if (data->m_Lanes.empty())
1048 m_logEntries.setLane(data->m_CommitHash);
1050 std::vector<int>& lanes=data->m_Lanes;
1051 size_t laneNum = lanes.size();
1052 UINT activeLane = 0;
1053 for (UINT i = 0; i < laneNum; ++i)
1054 if (Lanes::isMerge(lanes[i])) {
1055 activeLane = i;
1056 break;
1059 int x1 = 0, x2 = 0;
1060 int maxWidth = rect.Width();
1061 int lw = 3 * rect.Height() / 4; //laneWidth()
1063 COLORREF activeColor = m_LineColors[activeLane % Lanes::COLORS_NUM];
1064 //if (opt.state & QStyle::State_Selected)
1065 // activeColor = blend(activeColor, opt.palette.highlightedText().color(), 208);
1067 for (unsigned int i = 0; i < laneNum && x2 < maxWidth; ++i)
1070 x1 = x2;
1071 x2 += lw;
1073 int ln = lanes[i];
1074 if (ln == Lanes::EMPTY)
1075 continue;
1077 COLORREF color = i == activeLane ? activeColor : m_LineColors[i % Lanes::COLORS_NUM];
1078 paintGraphLane(hdc, rect.Height(),ln, x1+rect.left, x2+rect.left, color,activeColor, rect.top);
1081 #if 0
1082 for (UINT i = 0; i < laneNum && x2 < maxWidth; ++i) {
1084 x1 = x2;
1085 x2 += lw;
1087 int ln = lanes[i];
1088 if (ln == Lanes::EMPTY)
1089 continue;
1091 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
1092 || ln ==Lanes:: CROSS_EMPTY) ? activeLane : i;
1094 if (ln == Lanes::CROSS)
1096 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
1097 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[activeLane % Lanes::COLORS_NUM],rect.top);
1099 else
1100 paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
1102 #endif
1106 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
1109 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
1110 // Take the default processing unless we set this to something else below.
1111 *pResult = CDRF_DODEFAULT;
1113 if (m_bNoDispUpdates)
1114 return;
1116 switch (pLVCD->nmcd.dwDrawStage)
1118 case CDDS_PREPAINT:
1120 *pResult = CDRF_NOTIFYITEMDRAW;
1121 return;
1123 break;
1124 case CDDS_ITEMPREPAINT:
1126 // This is the prepaint stage for an item. Here's where we set the
1127 // item's text color.
1129 // Tell Windows to send draw notifications for each subitem.
1130 *pResult = CDRF_NOTIFYSUBITEMDRAW;
1132 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
1134 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
1136 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(pLVCD->nmcd.dwItemSpec);
1137 if (data)
1139 int action = SafeGetAction(data);
1140 if (action & (CTGitPath::LOGACTIONS_REBASE_DONE | CTGitPath::LOGACTIONS_REBASE_SKIP))
1141 crText = RGB(128,128,128);
1143 if (action & CTGitPath::LOGACTIONS_REBASE_SQUASH)
1144 pLVCD->clrTextBk = RGB(156,156,156);
1145 else if (action & CTGitPath::LOGACTIONS_REBASE_EDIT)
1146 pLVCD->clrTextBk = RGB(200,200,128);
1147 else
1148 pLVCD->clrTextBk = ::GetSysColor(COLOR_WINDOW);
1150 if (action & CTGitPath::LOGACTIONS_REBASE_CURRENT)
1152 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1153 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
1156 if (data->m_CommitHash == m_HeadHash && m_bNoHightlightHead == FALSE)
1158 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1159 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
1162 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
1163 // crText = GetSysColor(COLOR_GRAYTEXT);
1165 if (data->m_CommitHash.IsEmpty())
1167 //crText = GetSysColor(RGB(200,200,0));
1168 //SelectObject(pLVCD->nmcd.hdc, m_boldFont);
1169 // We changed the font, so we're returning CDRF_NEWFONT. This
1170 // tells the control to recalculate the extent of the text.
1171 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
1175 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
1177 if (m_bStrictStopped)
1178 crText = GetSysColor(COLOR_GRAYTEXT);
1180 // Store the color back in the NMLVCUSTOMDRAW struct.
1181 pLVCD->clrText = crText;
1182 return;
1184 break;
1185 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
1187 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
1189 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
1192 if (pLVCD->iSubItem == LOGLIST_GRAPH && m_sFilterText.IsEmpty())
1194 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec && (!this->m_IsRebaseReplaceGraph) )
1196 CRect rect;
1197 GetSubItemRect((int)pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_LABEL, rect);
1199 //TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right);
1200 FillBackGround(pLVCD->nmcd.hdc, pLVCD->nmcd.dwItemSpec,rect);
1202 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(pLVCD->nmcd.dwItemSpec);
1203 if( !data ->m_CommitHash.IsEmpty())
1204 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
1206 *pResult = CDRF_SKIPDEFAULT;
1207 return;
1211 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
1213 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
1215 GitRev* data = (GitRev*)m_arShownList.SafeGetAt(pLVCD->nmcd.dwItemSpec);
1216 //if(!data->m_IsFull)
1218 //if(data->SafeFetchFullInfo(&g_Git))
1219 // this->Invalidate();
1220 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
1223 if (!m_HashMap[data->m_CommitHash].empty())
1225 CRect rect;
1227 GetSubItemRect((int)pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
1229 FillBackGround(pLVCD->nmcd.hdc, pLVCD->nmcd.dwItemSpec,rect);
1231 std::vector<REFLABEL> refsToShow;
1232 STRING_VECTOR remoteTrackingList;
1233 STRING_VECTOR refList = m_HashMap[data->m_CommitHash];
1234 for (unsigned int i = 0; i < refList.size(); ++i)
1236 CString str = refList[i];
1238 REFLABEL refLabel;
1239 refLabel.color = RGB(255, 255, 255);
1240 refLabel.singleRemote = false;
1241 refLabel.hasTracking = false;
1242 refLabel.sameName = false;
1243 refLabel.annotatedTag = false;
1244 if (CGit::GetShortName(str, refLabel.name, _T("refs/heads/")))
1246 if (!(m_ShowRefMask & LOGLIST_SHOWLOCALBRANCHES))
1247 continue;
1248 if (refLabel.name == m_CurrentBranch )
1249 refLabel.color = m_Colors.GetColor(CColors::CurrentBranch);
1250 else
1251 refLabel.color = m_Colors.GetColor(CColors::LocalBranch);
1253 std::pair<CString, CString> trackingEntry = m_TrackingMap[refLabel.name];
1254 CString pullRemote = trackingEntry.first;
1255 CString pullBranch = trackingEntry.second;
1256 if (!pullRemote.IsEmpty() && !pullBranch.IsEmpty())
1258 CString defaultUpstream;
1259 defaultUpstream.Format(_T("refs/remotes/%s/%s"), pullRemote, pullBranch);
1260 refLabel.hasTracking = true;
1261 if (m_ShowRefMask & LOGLIST_SHOWREMOTEBRANCHES)
1263 bool found = false;
1264 for (int j = i + 1; j < refList.size(); ++j)
1266 if (refList[j] == defaultUpstream)
1268 found = true;
1269 break;
1273 if (found)
1275 bool sameName = pullBranch == refLabel.name;
1276 refsToShow.push_back(refLabel);
1277 CGit::GetShortName(defaultUpstream, refLabel.name, _T("refs/remotes/"));
1278 refLabel.color = m_Colors.GetColor(CColors::RemoteBranch);
1279 if (m_bSymbolizeRefNames)
1281 if (!m_SingleRemote.IsEmpty() && m_SingleRemote == pullRemote)
1283 refLabel.simplifiedName = _T("/") + (sameName ? CString() : pullBranch);
1284 refLabel.singleRemote = true;
1286 else if (sameName)
1287 refLabel.simplifiedName = pullRemote + _T("/");
1288 refLabel.sameName = sameName;
1290 refsToShow.push_back(refLabel);
1291 remoteTrackingList.push_back(defaultUpstream);
1292 continue;
1297 else if (CGit::GetShortName(str, refLabel.name, _T("refs/remotes/")))
1299 if (!(m_ShowRefMask & LOGLIST_SHOWREMOTEBRANCHES))
1300 continue;
1302 bool found = false;
1303 for (int j = 0; j < remoteTrackingList.size(); ++j)
1305 if (remoteTrackingList[j] == str)
1307 found = true;
1308 break;
1311 if (found)
1312 continue;
1314 refLabel.color = m_Colors.GetColor(CColors::RemoteBranch);
1315 if (m_bSymbolizeRefNames)
1317 if (!m_SingleRemote.IsEmpty() && refLabel.name.Left(m_SingleRemote.GetLength() + 1) == m_SingleRemote + _T("/"))
1319 refLabel.simplifiedName = _T("/") + refLabel.name.Mid(m_SingleRemote.GetLength() + 1);
1320 refLabel.singleRemote = true;
1324 else if (CGit::GetShortName(str, refLabel.name, _T("refs/tags/")))
1326 if (!(m_ShowRefMask & LOGLIST_SHOWTAGS))
1327 continue;
1328 refLabel.color = m_Colors.GetColor(CColors::Tag);
1329 refLabel.annotatedTag = str.Right(3) == _T("^{}");
1331 else if (CGit::GetShortName(str, refLabel.name, _T("refs/stash")))
1333 if (!(m_ShowRefMask & LOGLIST_SHOWSTASH))
1334 continue;
1335 refLabel.color = m_Colors.GetColor(CColors::Stash);
1336 refLabel.name = _T("stash");
1338 else if (CGit::GetShortName(str, refLabel.name, _T("refs/bisect/")))
1340 if (!(m_ShowRefMask & LOGLIST_SHOWBISECT))
1341 continue;
1342 if (refLabel.name.Find(_T("good")) == 0)
1344 refLabel.color = m_Colors.GetColor(CColors::BisectGood);
1345 refLabel.name = _T("good");
1347 if (refLabel.name.Find(_T("bad")) == 0)
1349 refLabel.color = m_Colors.GetColor(CColors::BisectBad);
1350 refLabel.name = _T("bad");
1353 else
1354 continue;
1356 refsToShow.push_back(refLabel);
1359 if (refsToShow.empty())
1361 *pResult = CDRF_DODEFAULT;
1362 return;
1365 DrawTagBranchMessage(pLVCD->nmcd.hdc, rect, pLVCD->nmcd.dwItemSpec, refsToShow);
1367 *pResult = CDRF_SKIPDEFAULT;
1368 return;
1375 if (pLVCD->iSubItem == LOGLIST_ACTION)
1377 if(this->m_IsIDReplaceAction)
1379 *pResult = CDRF_DODEFAULT;
1380 return;
1382 *pResult = CDRF_DODEFAULT;
1384 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
1385 return;
1387 int nIcons = 0;
1388 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
1389 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
1391 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.SafeGetAt(pLVCD->nmcd.dwItemSpec));
1392 CRect rect;
1393 GetSubItemRect((int)pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
1394 //TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right);
1395 // Get the selected state of the
1396 // item being drawn.
1398 // Fill the background if necessary
1399 FillBackGround(pLVCD->nmcd.hdc, pLVCD->nmcd.dwItemSpec, rect);
1401 // Draw the icon(s) into the compatible DC
1402 int action = SafeGetAction(pLogEntry);
1404 if (!pLogEntry->m_IsDiffFiles)
1405 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hFetchIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
1407 if (action & CTGitPath::LOGACTIONS_MODIFIED)
1408 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
1409 ++nIcons;
1411 if (action & (CTGitPath::LOGACTIONS_ADDED | CTGitPath::LOGACTIONS_COPY))
1412 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
1413 ++nIcons;
1415 if (action & CTGitPath::LOGACTIONS_DELETED)
1416 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
1417 ++nIcons;
1419 if (action & CTGitPath::LOGACTIONS_REPLACED)
1420 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
1421 ++nIcons;
1422 *pResult = CDRF_SKIPDEFAULT;
1423 return;
1426 break;
1428 *pResult = CDRF_DODEFAULT;
1431 // CGitLogListBase message handlers
1433 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
1435 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
1437 // Create a pointer to the item
1438 LV_ITEM* pItem = &(pDispInfo)->item;
1440 // Do the list need text information?
1441 if (!(pItem->mask & LVIF_TEXT))
1442 return;
1444 // By default, clear text buffer.
1445 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
1447 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
1449 *pResult = 0;
1450 if (m_bNoDispUpdates || bOutOfRange)
1451 return;
1453 // Which item number?
1454 int itemid = pItem->iItem;
1455 GitRev * pLogEntry = NULL;
1456 if (itemid < m_arShownList.GetCount())
1457 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.SafeGetAt(pItem->iItem));
1459 CString temp;
1460 if(m_IsOldFirst)
1462 temp.Format(_T("%d"),pItem->iItem+1);
1465 else
1467 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
1470 // Which column?
1471 switch (pItem->iSubItem)
1473 case this->LOGLIST_GRAPH: //Graphic
1474 break;
1475 case this->LOGLIST_REBASE:
1477 if (this->m_IsRebaseReplaceGraph && pLogEntry)
1479 CTGitPath path;
1480 path.m_Action = SafeGetAction(pLogEntry) & CTGitPath::LOGACTIONS_REBASE_MODE_MASK;
1481 lstrcpyn(pItem->pszText,path.GetActionName(), pItem->cchTextMax);
1484 break;
1485 case this->LOGLIST_ACTION: //action -- no text in the column
1486 break;
1487 case this->LOGLIST_HASH:
1488 if(pLogEntry)
1489 lstrcpyn(pItem->pszText, pLogEntry->m_CommitHash.ToString(), pItem->cchTextMax);
1490 break;
1491 case this->LOGLIST_ID:
1492 if(this->m_IsIDReplaceAction)
1493 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
1494 break;
1495 case this->LOGLIST_MESSAGE: //Message
1496 if (pLogEntry)
1497 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetSubject(), pItem->cchTextMax);
1498 break;
1499 case this->LOGLIST_AUTHOR: //Author
1500 if (pLogEntry)
1501 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetAuthorName(), pItem->cchTextMax);
1502 break;
1503 case this->LOGLIST_DATE: //Date
1504 if ( pLogEntry && (!pLogEntry->m_CommitHash.IsEmpty()) )
1505 lstrcpyn(pItem->pszText,
1506 CLoglistUtils::FormatDateAndTime(pLogEntry->GetAuthorDate(), m_DateFormat, true, m_bRelativeTimes),
1507 pItem->cchTextMax);
1508 break;
1510 case this->LOGLIST_EMAIL:
1511 if (pLogEntry)
1512 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetAuthorEmail(), pItem->cchTextMax);
1513 break;
1515 case this->LOGLIST_COMMIT_NAME: //Commit
1516 if (pLogEntry)
1517 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetCommitterName(), pItem->cchTextMax);
1518 break;
1520 case this->LOGLIST_COMMIT_EMAIL: //Commit Email
1521 if (pLogEntry)
1522 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetCommitterEmail(), pItem->cchTextMax);
1523 break;
1525 case this->LOGLIST_COMMIT_DATE: //Commit Date
1526 if (pLogEntry && (!pLogEntry->m_CommitHash.IsEmpty()))
1527 lstrcpyn(pItem->pszText,
1528 CLoglistUtils::FormatDateAndTime(pLogEntry->GetCommitterDate(), m_DateFormat, true, m_bRelativeTimes),
1529 pItem->cchTextMax);
1530 break;
1531 case this->LOGLIST_BUG: //Bug ID
1532 if(pLogEntry)
1533 lstrcpyn(pItem->pszText, (LPCTSTR)this->m_ProjectProperties.FindBugID(pLogEntry->GetSubject() + _T("\r\n\r\n") + pLogEntry->GetBody()), pItem->cchTextMax);
1534 break;
1536 default:
1537 ASSERT(false);
1541 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
1544 if (pWnd == GetHeaderCtrl())
1546 return m_ColumnManager.OnContextMenuHeader(pWnd,point,!!IsGroupViewEnabled());
1549 int selIndex = GetSelectionMark();
1550 if (selIndex < 0)
1551 return; // nothing selected, nothing to do with a context menu
1553 // if the user selected the info text telling about not all revisions shown due to
1554 // the "stop on copy/rename" option, we also don't show the context menu
1555 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
1556 return;
1558 // if the context menu is invoked through the keyboard, we have to use
1559 // a calculated position on where to anchor the menu on
1560 if ((point.x == -1) && (point.y == -1))
1562 CRect rect;
1563 GetItemRect(selIndex, &rect, LVIR_LABEL);
1564 ClientToScreen(&rect);
1565 point = rect.CenterPoint();
1567 m_nSearchIndex = selIndex;
1568 m_bCancelled = FALSE;
1570 // calculate some information the context menu commands can use
1571 // CString pathURL = GetURLFromPath(m_path);
1573 POSITION pos = GetFirstSelectedItemPosition();
1574 int indexNext = GetNextSelectedItem(pos);
1575 if (indexNext < 0)
1576 return;
1578 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.SafeGetAt(indexNext));
1579 #if 0
1580 GitRev revSelected = pSelLogEntry->Rev;
1581 GitRev revPrevious = git_revnum_t(revSelected)-1;
1582 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
1584 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
1586 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->SafeGetAt(i);
1587 if (changedpath->lCopyFromRev)
1588 revPrevious = changedpath->lCopyFromRev;
1591 GitRev revSelected2;
1592 if (pos)
1594 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(GetNextSelectedItem(pos)));
1595 revSelected2 = pLogEntry->Rev;
1597 bool bAllFromTheSameAuthor = true;
1598 CString firstAuthor;
1599 CLogDataVector selEntries;
1600 GitRev revLowest, revHighest;
1601 GitRevRangeArray revisionRanges;
1603 POSITION pos = GetFirstSelectedItemPosition();
1604 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(GetNextSelectedItem(pos)));
1605 revisionRanges.AddRevision(pLogEntry->Rev);
1606 selEntries.push_back(pLogEntry);
1607 firstAuthor = pLogEntry->sAuthor;
1608 revLowest = pLogEntry->Rev;
1609 revHighest = pLogEntry->Rev;
1610 while (pos)
1612 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(GetNextSelectedItem(pos)));
1613 revisionRanges.AddRevision(pLogEntry->Rev);
1614 selEntries.push_back(pLogEntry);
1615 if (firstAuthor.Compare(pLogEntry->sAuthor))
1616 bAllFromTheSameAuthor = false;
1617 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
1618 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
1622 #endif
1624 int FirstSelect=-1, LastSelect=-1;
1625 pos = GetFirstSelectedItemPosition();
1626 FirstSelect = GetNextSelectedItem(pos);
1627 while(pos)
1629 LastSelect = GetNextSelectedItem(pos);
1631 //entry is selected, now show the popup menu
1632 CIconMenu popup;
1633 CIconMenu subbranchmenu, submenu, gnudiffmenu, diffmenu, revertmenu;
1635 if (popup.CreatePopupMenu())
1637 bool isHeadCommit = (pSelLogEntry->m_CommitHash == m_HeadHash);
1638 CString currentBranch = _T("refs/heads/") + g_Git.GetCurrentBranch();
1639 bool isMergeActive = CTGitPath(g_Git.m_CurrentDir).IsMergeActive();
1641 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_PICK))
1642 popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_PICK, IDI_PICK);
1644 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SQUASH))
1645 popup.AppendMenuIcon(ID_REBASE_SQUASH, IDS_REBASE_SQUASH, IDI_SQUASH);
1647 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_EDIT))
1648 popup.AppendMenuIcon(ID_REBASE_EDIT, IDS_REBASE_EDIT, IDI_EDIT);
1650 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SKIP))
1651 popup.AppendMenuIcon(ID_REBASE_SKIP, IDS_REBASE_SKIP, IDI_SKIP);
1653 if(m_ContextMenuMask&(GetContextMenuBit(ID_REBASE_SKIP)|GetContextMenuBit(ID_REBASE_EDIT)|
1654 GetContextMenuBit(ID_REBASE_SQUASH)|GetContextMenuBit(ID_REBASE_PICK)))
1655 popup.AppendMenu(MF_SEPARATOR, NULL);
1657 if (GetSelectedCount() == 1)
1661 if( !pSelLogEntry->m_CommitHash.IsEmpty())
1663 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE) && m_hasWC) // compare revision with WC
1664 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
1666 else
1668 if(m_ContextMenuMask&GetContextMenuBit(ID_COMMIT))
1669 popup.AppendMenuIcon(ID_COMMIT, IDS_LOG_POPUP_COMMIT, IDI_COMMIT);
1670 if (isMergeActive && (m_ContextMenuMask & GetContextMenuBit(ID_MERGE_ABORT)))
1671 popup.AppendMenuIcon(ID_MERGE_ABORT, IDS_MENUMERGEABORT, IDI_MERGEABORT);
1673 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1) && m_hasWC) // compare with WC, unified
1675 GitRev *pRev=pSelLogEntry;
1676 if (pSelLogEntry->m_ParentHash.empty())
1680 pRev->GetParentFromHash(pRev->m_CommitHash);
1682 catch (const char* msg)
1684 MessageBox(_T("Could not get parent.\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
1687 if(pRev->m_ParentHash.size()<=1)
1689 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
1692 else
1694 gnudiffmenu.CreatePopupMenu();
1695 popup.AppendMenuIcon(ID_GNUDIFF1,IDS_LOG_POPUP_GNUDIFF_PARENT, IDI_DIFF, gnudiffmenu.m_hMenu);
1697 gnudiffmenu.AppendMenuIcon((UINT_PTR)(ID_GNUDIFF1 + (0xFFFF << 16)), CString(MAKEINTRESOURCE(IDS_ALLPARENTS)));
1698 gnudiffmenu.AppendMenuIcon((UINT_PTR)(ID_GNUDIFF1 + (0xFFFE << 16)), CString(MAKEINTRESOURCE(IDS_ONLYMERGEDFILES)));
1700 for (size_t i = 0; i < pRev->m_ParentHash.size(); ++i)
1702 CString str;
1703 str.Format(IDS_PARENT, i + 1);
1704 gnudiffmenu.AppendMenuIcon(ID_GNUDIFF1+((i+1)<<16),str);
1709 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPAREWITHPREVIOUS))
1712 GitRev *pRev=pSelLogEntry;
1713 if (pSelLogEntry->m_ParentHash.empty())
1717 pRev->GetParentFromHash(pRev->m_CommitHash);
1719 catch (const char* msg)
1721 MessageBox(_T("Could not get parent.\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
1724 if(pRev->m_ParentHash.size()<=1)
1726 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
1727 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
1728 popup.SetDefaultItem(ID_COMPAREWITHPREVIOUS, FALSE);
1730 else
1732 diffmenu.CreatePopupMenu();
1733 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF, diffmenu.m_hMenu);
1734 for (size_t i = 0; i < pRev->m_ParentHash.size(); ++i)
1736 CString str;
1737 str.Format(IDS_PARENT, i + 1);
1738 diffmenu.AppendMenuIcon(ID_COMPAREWITHPREVIOUS +((i+1)<<16),str);
1739 if (i == 0 && CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
1741 popup.SetDefaultItem(ID_COMPAREWITHPREVIOUS, FALSE);
1742 diffmenu.SetDefaultItem((UINT)(ID_COMPAREWITHPREVIOUS + ((i + 1) << 16)), FALSE);
1748 if(m_ContextMenuMask&GetContextMenuBit(ID_BLAME))
1749 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
1751 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
1752 popup.AppendMenu(MF_SEPARATOR, NULL);
1754 if (pSelLogEntry->m_CommitHash.IsEmpty() && !isMergeActive)
1756 if(m_ContextMenuMask&GetContextMenuBit(ID_STASH_SAVE))
1757 popup.AppendMenuIcon(ID_STASH_SAVE, IDS_MENUSTASHSAVE, IDI_COMMIT);
1760 bool isStash = false;
1761 for (size_t i = 0; i < m_HashMap[pSelLogEntry->m_CommitHash].size(); ++i)
1763 if (m_HashMap[pSelLogEntry->m_CommitHash][i] == _T("refs/stash"))
1765 isStash = true;
1766 break;
1770 if (CTGitPath(g_Git.m_CurrentDir).HasStashDir() && (pSelLogEntry->m_CommitHash.IsEmpty() || isStash))
1772 if (m_ContextMenuMask&GetContextMenuBit(ID_STASH_POP))
1773 popup.AppendMenuIcon(ID_STASH_POP, IDS_MENUSTASHPOP, IDI_RELOCATE);
1775 if (m_ContextMenuMask&GetContextMenuBit(ID_STASH_LIST))
1776 popup.AppendMenuIcon(ID_STASH_LIST, IDS_MENUSTASHLIST, IDI_LOG);
1778 popup.AppendMenu(MF_SEPARATOR, NULL);
1781 if (pSelLogEntry->m_CommitHash.IsEmpty())
1783 if(m_ContextMenuMask&GetContextMenuBit(ID_FETCH))
1784 popup.AppendMenuIcon(ID_FETCH, IDS_MENUFETCH, IDI_PULL);
1786 popup.AppendMenu(MF_SEPARATOR, NULL);
1790 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
1791 // {
1792 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
1793 // }
1794 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
1795 // {
1796 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
1797 // }
1798 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
1799 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
1800 // {
1801 // popup.AppendMenu(MF_SEPARATOR, NULL);
1802 // }
1804 CString str,format;
1805 //if (m_hasWC)
1806 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
1808 if(!pSelLogEntry->m_CommitHash.IsEmpty())
1810 if((m_ContextMenuMask&GetContextMenuBit(ID_LOG)) &&
1811 GetSelectedCount() == 1)
1812 popup.AppendMenuIcon(ID_LOG, IDS_LOG_POPUP_LOG, IDI_LOG);
1814 if (m_ContextMenuMask&GetContextMenuBit(ID_REPOBROWSE))
1815 popup.AppendMenuIcon(ID_REPOBROWSE, IDS_LOG_BROWSEREPO, IDI_REPOBROWSE);
1817 format.LoadString(IDS_LOG_POPUP_MERGEREV);
1818 str.Format(format,g_Git.GetCurrentBranch());
1820 if (m_ContextMenuMask&GetContextMenuBit(ID_MERGEREV) && !isHeadCommit && m_hasWC && !isMergeActive)
1821 popup.AppendMenuIcon(ID_MERGEREV, str, IDI_MERGE);
1823 format.LoadString(IDS_RESET_TO_THIS_FORMAT);
1824 str.Format(format,g_Git.GetCurrentBranch());
1826 if (m_ContextMenuMask&GetContextMenuBit(ID_RESET) && m_hasWC)
1827 popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);
1830 // Add Switch Branch express Menu
1831 if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) != m_HashMap.end()
1832 && (m_ContextMenuMask&GetContextMenuBit(ID_SWITCHBRANCH) && m_hasWC)
1835 std::vector<CString *> branchs;
1836 for (size_t i = 0; i < m_HashMap[pSelLogEntry->m_CommitHash].size(); ++i)
1838 CString ref = m_HashMap[pSelLogEntry->m_CommitHash][i];
1839 if(ref.Find(_T("refs/heads/")) == 0 && ref != currentBranch)
1841 branchs.push_back(&m_HashMap[pSelLogEntry->m_CommitHash][i]);
1845 CString str;
1846 str.LoadString(IDS_SWITCH_BRANCH);
1848 if(branchs.size() == 1)
1850 str+=_T(" ");
1851 str+= _T('"') + branchs[0]->Mid(11) + _T('"');
1852 popup.AppendMenuIcon(ID_SWITCHBRANCH,str,IDI_SWITCH);
1854 popup.SetMenuItemData(ID_SWITCHBRANCH,(ULONG_PTR)branchs[0]);
1857 else if(branchs.size() > 1)
1859 subbranchmenu.CreatePopupMenu();
1860 for (size_t i = 0 ; i < branchs.size(); ++i)
1862 if (*branchs[i] != currentBranch)
1864 subbranchmenu.AppendMenuIcon(ID_SWITCHBRANCH+(i<<16), branchs[i]->Mid(11));
1865 subbranchmenu.SetMenuItemData(ID_SWITCHBRANCH+(i<<16), (ULONG_PTR) branchs[i]);
1869 popup.AppendMenuIcon(ID_SWITCHBRANCH, str, IDI_SWITCH, subbranchmenu.m_hMenu);
1873 if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV) && !isHeadCommit && m_hasWC)
1874 popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH);
1876 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH))
1877 popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY);
1879 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG))
1880 popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_TAG);
1882 format.LoadString(IDS_REBASE_THIS_FORMAT);
1883 str.Format(format,g_Git.GetCurrentBranch());
1885 if (pSelLogEntry->m_CommitHash != m_HeadHash && m_hasWC && !isMergeActive)
1886 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION))
1887 popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE);
1889 if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT))
1890 popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT);
1892 if (m_ContextMenuMask&GetContextMenuBit(ID_REVERTREV) && m_hasWC && !isMergeActive)
1894 GitRev *pRev = pSelLogEntry;
1895 if (pSelLogEntry->m_ParentHash.empty())
1899 pRev->GetParentFromHash(pRev->m_CommitHash);
1901 catch (const char* msg)
1903 MessageBox(_T("Could not get parent.\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
1906 if (pRev->m_ParentHash.size() == 1)
1908 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
1910 else
1912 revertmenu.CreatePopupMenu();
1913 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT, revertmenu.m_hMenu);
1915 for (size_t i = 0; i < pRev->m_ParentHash.size(); ++i)
1917 CString str;
1918 str.Format(IDS_PARENT, i + 1);
1919 revertmenu.AppendMenuIcon(ID_REVERTREV + ((i + 1) << 16), str);
1924 if (m_ContextMenuMask&GetContextMenuBit(ID_EDITNOTE))
1925 popup.AppendMenuIcon(ID_EDITNOTE, IDS_EDIT_NOTES, IDI_EDIT);
1927 popup.AppendMenu(MF_SEPARATOR, NULL);
1932 if(!pSelLogEntry->m_Ref.IsEmpty())
1934 popup.AppendMenuIcon(ID_REFLOG_DEL, IDS_REFLOG_DEL, IDI_DELETE);
1935 if (GetSelectedCount() == 1 && pSelLogEntry->m_Ref.Find(_T("refs/stash")) == 0)
1936 popup.AppendMenuIcon(ID_REFLOG_STASH_APPLY, IDS_MENUSTASHAPPLY, IDI_RELOCATE);
1937 popup.AppendMenu(MF_SEPARATOR, NULL);
1940 if (GetSelectedCount() >= 2)
1942 bool bAddSeparator = false;
1943 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
1945 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARETWO)) // compare two revisions
1946 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
1949 if (GetSelectedCount() == 2)
1951 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF2) && m_hasWC) // compare two revisions, unified
1952 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
1954 if (!pSelLogEntry->m_CommitHash.IsEmpty())
1956 CString firstSelHash = pSelLogEntry->m_CommitHash.ToString().Left(g_Git.GetShortHASHLength());
1957 GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.SafeGetAt(LastSelect));
1958 CString lastSelHash = pLastEntry->m_CommitHash.ToString().Left(g_Git.GetShortHASHLength());
1959 CString menu;
1960 menu.Format(IDS_SHOWLOG_OF, lastSelHash + _T("..") + firstSelHash);
1961 popup.AppendMenuIcon(ID_LOG_VIEWRANGE, menu, IDI_LOG);
1962 menu.Format(IDS_SHOWLOG_OF, lastSelHash + _T("...") + firstSelHash);
1963 popup.AppendMenuIcon(ID_LOG_VIEWRANGE_REACHABLEFROMONLYONE, menu, IDI_LOG);
1966 bAddSeparator = true;
1969 if (m_hasWC)
1971 bAddSeparator = true;
1974 if (m_ContextMenuMask&GetContextMenuBit(ID_REVERTREV) && m_hasWC && !isMergeActive)
1975 popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
1977 if (bAddSeparator)
1978 popup.AppendMenu(MF_SEPARATOR, NULL);
1981 if ( GetSelectedCount() >0 && (!pSelLogEntry->m_CommitHash.IsEmpty()))
1983 bool bAddSeparator = false;
1984 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
1986 if (m_ContextMenuMask&GetContextMenuBit(ID_COMBINE_COMMIT) && m_hasWC && !isMergeActive)
1988 CString head;
1989 int headindex;
1990 headindex = this->GetHeadIndex();
1991 if(headindex>=0 && LastSelect >= headindex)
1993 head.Format(_T("HEAD~%d"),LastSelect-headindex);
1994 CGitHash hash;
1995 if (g_Git.GetHash(hash, head))
1996 MessageBox(g_Git.GetGitLastErr(_T("Could not get hash of ") + head + _T(".")), _T("TortoiseGit"), MB_ICONERROR);
1997 GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.SafeGetAt(LastSelect));
1998 if(pLastEntry->m_CommitHash == hash) {
1999 popup.AppendMenuIcon(ID_COMBINE_COMMIT,IDS_COMBINE_TO_ONE,IDI_COMBINE);
2000 bAddSeparator = true;
2005 if (m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK) && !isHeadCommit && m_hasWC && !isMergeActive) {
2006 if (GetSelectedCount() >= 2)
2007 popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSIONS, IDI_EXPORT);
2008 else
2009 popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT);
2010 bAddSeparator = true;
2013 if(GetSelectedCount()<=2 || (IsSelectionContinuous() && GetSelectedCount() > 0))
2014 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_PATCH)) {
2015 popup.AppendMenuIcon(ID_CREATE_PATCH, IDS_CREATE_PATCH, IDI_PATCH);
2016 bAddSeparator = true;
2019 if (bAddSeparator)
2020 popup.AppendMenu(MF_SEPARATOR, NULL);
2023 if (m_hasWC && !isMergeActive && (m_ContextMenuMask & GetContextMenuBit(ID_BISECTSTART)) && GetSelectedCount() == 2 && !reinterpret_cast<GitRev*>(m_arShownList.SafeGetAt(FirstSelect))->m_CommitHash.IsEmpty() && !CTGitPath(g_Git.m_CurrentDir).IsBisectActive())
2025 popup.AppendMenuIcon(ID_BISECTSTART, IDS_MENUBISECTSTART);
2026 popup.AppendMenu(MF_SEPARATOR, NULL);
2029 if (GetSelectedCount() == 1)
2031 bool bAddSeparator = false;
2032 if(m_ContextMenuMask&GetContextMenuBit(ID_PUSH) && !m_HashMap[pSelLogEntry->m_CommitHash].empty())
2034 // show the push-option only if the log entry has an associated local branch
2035 bool isLocal = false;
2036 for (size_t i = 0; isLocal == false && i < m_HashMap[pSelLogEntry->m_CommitHash].size(); ++i)
2038 if (m_HashMap[pSelLogEntry->m_CommitHash][i].Find(_T("refs/heads/")) == 0)
2039 isLocal = true;
2041 if (isLocal)
2043 popup.AppendMenuIcon(ID_PUSH, IDS_LOG_PUSH, IDI_PUSH);
2044 bAddSeparator = true;
2048 if(m_ContextMenuMask &GetContextMenuBit(ID_DELETE))
2050 if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) != m_HashMap.end() )
2052 std::vector<CString *> branchs;
2053 for (size_t i = 0; i < m_HashMap[pSelLogEntry->m_CommitHash].size(); ++i)
2055 if(m_HashMap[pSelLogEntry->m_CommitHash][i] != currentBranch)
2056 branchs.push_back(&m_HashMap[pSelLogEntry->m_CommitHash][i]);
2058 CString str;
2059 if (branchs.size() == 1)
2061 str.LoadString(IDS_DELETE_BRANCHTAG_SHORT);
2062 str+=_T(" ");
2063 str += *branchs[0];
2064 popup.AppendMenuIcon(ID_DELETE, str, IDI_DELETE);
2065 popup.SetMenuItemData(ID_DELETE, (ULONG_PTR)branchs[0]);
2066 bAddSeparator = true;
2068 else if (branchs.size() > 1)
2070 str.LoadString(IDS_DELETE_BRANCHTAG);
2071 submenu.CreatePopupMenu();
2072 for (size_t i = 0; i < branchs.size(); ++i)
2074 submenu.AppendMenuIcon(ID_DELETE + (i << 16), *branchs[i]);
2075 submenu.SetMenuItemData(ID_DELETE + (i << 16), (ULONG_PTR)branchs[i]);
2078 popup.AppendMenuIcon(ID_DELETE,str, IDI_DELETE, submenu.m_hMenu);
2079 bAddSeparator = true;
2082 } // m_ContextMenuMask &GetContextMenuBit(ID_DELETE)
2083 if (bAddSeparator)
2084 popup.AppendMenu(MF_SEPARATOR, NULL);
2085 } // GetSelectedCount() == 1
2087 if (GetSelectedCount() != 0)
2089 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYHASH))
2090 popup.AppendMenuIcon(ID_COPYHASH, IDS_COPY_COMMIT_HASH, IDI_COPYCLIP);
2091 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYCLIPBOARD))
2092 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD, IDI_COPYCLIP);
2093 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYCLIPBOARDMESSAGES))
2094 popup.AppendMenuIcon(ID_COPYCLIPBOARDMESSAGES, IDS_LOG_POPUP_COPYTOCLIPBOARDMESSAGES, IDI_COPYCLIP);
2097 if(m_ContextMenuMask&GetContextMenuBit(ID_FINDENTRY))
2098 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND, IDI_FILTEREDIT);
2100 if (GetSelectedCount() == 1 && m_ContextMenuMask & GetContextMenuBit(ID_SHOWBRANCHES) && !pSelLogEntry->m_CommitHash.IsEmpty())
2101 popup.AppendMenuIcon(ID_SHOWBRANCHES, IDS_LOG_POPUP_SHOWBRANCHES, IDI_SHOWBRANCHES);
2103 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
2104 // DialogEnableWindow(IDOK, FALSE);
2105 // SetPromptApp(&theApp);
2107 this->ContextMenuAction(cmd, FirstSelect, LastSelect, &popup);
2109 // EnableOKButton();
2110 } // if (popup.CreatePopupMenu())
2114 bool CGitLogListBase::IsSelectionContinuous()
2116 if ( GetSelectedCount()==1 )
2118 // if only one revision is selected, the selection is of course
2119 // continuous
2120 return true;
2123 POSITION pos = GetFirstSelectedItemPosition();
2124 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
2125 if (bContinuous)
2127 int itemindex = GetNextSelectedItem(pos);
2128 while (pos)
2130 int nextindex = GetNextSelectedItem(pos);
2131 if (nextindex - itemindex > 1)
2133 bContinuous = false;
2134 break;
2136 itemindex = nextindex;
2139 return bContinuous;
2142 void CGitLogListBase::CopySelectionToClipBoard(int toCopy)
2145 CString sClipdata;
2146 POSITION pos = GetFirstSelectedItemPosition();
2147 if (pos != NULL)
2149 CString sRev;
2150 sRev.LoadString(IDS_LOG_REVISION);
2151 CString sAuthor;
2152 sAuthor.LoadString(IDS_LOG_AUTHOR);
2153 CString sDate;
2154 sDate.LoadString(IDS_LOG_DATE);
2155 CString sMessage;
2156 sMessage.LoadString(IDS_LOG_MESSAGE);
2157 bool first = true;
2158 while (pos)
2160 CString sLogCopyText;
2161 CString sPaths;
2162 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.SafeGetAt(GetNextSelectedItem(pos)));
2164 if (toCopy == ID_COPY_ALL)
2166 //pLogEntry->GetFiles(this)
2167 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
2169 CString from(MAKEINTRESOURCE(IDS_STATUSLIST_FROM));
2170 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->GetFiles(this).GetCount(); ++cpPathIndex)
2172 sPaths += ((CTGitPath&)pLogEntry->GetFiles(this)[cpPathIndex]).GetActionName() + _T(": ") + pLogEntry->GetFiles(this)[cpPathIndex].GetGitPathString();
2173 if (((CTGitPath&)pLogEntry->GetFiles(this)[cpPathIndex]).m_Action & (CTGitPath::LOGACTIONS_REPLACED|CTGitPath::LOGACTIONS_COPY) && !((CTGitPath&)pLogEntry->GetFiles(this)[cpPathIndex]).GetGitOldPathString().IsEmpty())
2175 CString rename;
2176 rename.Format(from, ((CTGitPath&)pLogEntry->GetFiles(this)[cpPathIndex]).GetGitOldPathString());
2177 sPaths += _T(" ") + rename;
2179 sPaths += _T("\r\n");
2181 sPaths.Trim();
2182 CString body = pLogEntry->GetBody();
2183 body.Replace(_T("\n"), _T("\r\n"));
2184 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"),
2185 (LPCTSTR)sRev, pLogEntry->m_CommitHash.ToString(),
2186 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->GetAuthorName(), (LPCTSTR)pLogEntry->GetAuthorEmail(),
2187 (LPCTSTR)sDate,
2188 (LPCTSTR)CLoglistUtils::FormatDateAndTime(pLogEntry->GetAuthorDate(), m_DateFormat, true, m_bRelativeTimes),
2189 (LPCTSTR)sMessage, (pLogEntry->GetSubject().Trim() + _T("\r\n\r\n") + body.Trim()).Trim(),
2190 (LPCTSTR)sPaths);
2191 sClipdata += sLogCopyText;
2193 else if (toCopy == ID_COPY_MESSAGE)
2195 CString body = pLogEntry->GetBody();
2196 body.Replace(_T("\n"), _T("\r\n"));
2197 sClipdata += _T("* ") + (pLogEntry->GetSubject().Trim() + _T("\r\n\r\n") + body.Trim()).Trim() + _T("\r\n\r\n");
2199 else if (toCopy == ID_COPY_SUBJECT)
2201 sClipdata += _T("* ") + pLogEntry->GetSubject().Trim() + _T("\r\n\r\n");
2203 else
2205 if (!first)
2206 sClipdata += _T("\r\n");
2207 sClipdata += pLogEntry->m_CommitHash;
2210 first = false;
2212 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
2217 void CGitLogListBase::DiffSelectedRevWithPrevious()
2219 if (m_bThreadRunning)
2220 return;
2222 int FirstSelect=-1, LastSelect=-1;
2223 POSITION pos = GetFirstSelectedItemPosition();
2224 FirstSelect = GetNextSelectedItem(pos);
2225 while(pos)
2227 LastSelect = GetNextSelectedItem(pos);
2230 ContextMenuAction(ID_COMPAREWITHPREVIOUS,FirstSelect,LastSelect, NULL);
2232 #if 0
2233 UpdateLogInfoLabel();
2234 int selIndex = m_LogList.GetSelectionMark();
2235 if (selIndex < 0)
2236 return;
2237 int selCount = m_LogList.GetSelectedCount();
2238 if (selCount != 1)
2239 return;
2241 // Find selected entry in the log list
2242 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
2243 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(m_LogList.GetNextSelectedItem(pos)));
2244 long rev1 = pLogEntry->Rev;
2245 long rev2 = rev1-1;
2246 CTGitPath path = m_path;
2248 // See how many files under the relative root were changed in selected revision
2249 int nChanged = 0;
2250 LogChangedPath * changed = NULL;
2251 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
2253 LogChangedPath * cpath = pLogEntry->pArChangedPaths->SafeGetAt(c);
2254 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
2256 ++nChanged;
2257 changed = cpath;
2261 if (m_path.IsDirectory() && nChanged == 1)
2263 // We're looking at the log for a directory and only one file under dir was changed in the revision
2264 // Do diff on that file instead of whole directory
2265 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
2268 m_bCancelled = FALSE;
2269 DialogEnableWindow(IDOK, FALSE);
2270 SetPromptApp(&theApp);
2271 theApp.DoWaitCursor(1);
2273 if (PromptShown())
2275 GitDiff diff(this, m_hWnd, true);
2276 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
2277 diff.SetHEADPeg(m_LogRevision);
2278 diff.ShowCompare(path, rev2, path, rev1);
2280 else
2282 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
2285 theApp.DoWaitCursor(-1);
2286 EnableOKButton();
2287 #endif
2290 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
2292 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
2293 *pResult = -1;
2295 if (pFindInfo->lvfi.flags & LVFI_PARAM)
2296 return;
2297 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
2298 return;
2299 if (pFindInfo->lvfi.psz == 0)
2300 return;
2301 #if 0
2302 CString sCmp = pFindInfo->lvfi.psz;
2303 CString sRev;
2304 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
2306 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.SafeGetAt(i));
2307 sRev.Format(_T("%ld"), pLogEntry->Rev);
2308 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
2310 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
2312 *pResult = i;
2313 return;
2316 else
2318 if (sCmp.Compare(sRev)==0)
2320 *pResult = i;
2321 return;
2325 if (pFindInfo->lvfi.flags & LVFI_WRAP)
2327 for (int i=0; i<pFindInfo->iStart; ++i)
2329 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.SafeGetAt(i));
2330 sRev.Format(_T("%ld"), pLogEntry->Rev);
2331 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
2333 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
2335 *pResult = i;
2336 return;
2339 else
2341 if (sCmp.Compare(sRev)==0)
2343 *pResult = i;
2344 return;
2349 #endif
2350 *pResult = -1;
2353 int CGitLogListBase::FillGitLog(CTGitPath *path, CString *range, int info)
2355 ClearText();
2357 this->m_arShownList.SafeRemoveAll();
2359 this->m_logEntries.ClearAll();
2360 if (this->m_logEntries.ParserFromLog(path, -1, info, range))
2361 return -1;
2363 //this->m_logEntries.ParserFromLog();
2364 SetItemCountEx((int)m_logEntries.size());
2366 for (unsigned int i = 0; i < m_logEntries.size(); ++i)
2368 if(m_IsOldFirst)
2370 m_logEntries.GetGitRevAt(m_logEntries.size()-i-1).m_IsFull=TRUE;
2371 this->m_arShownList.SafeAdd(&m_logEntries.GetGitRevAt(m_logEntries.size()-i-1));
2374 else
2376 m_logEntries.GetGitRevAt(i).m_IsFull=TRUE;
2377 this->m_arShownList.SafeAdd(&m_logEntries.GetGitRevAt(i));
2381 ReloadHashMap();
2383 if(path)
2384 m_Path=*path;
2385 return 0;
2389 int CGitLogListBase::BeginFetchLog()
2391 ClearText();
2393 this->m_arShownList.SafeRemoveAll();
2395 this->m_logEntries.ClearAll();
2397 this->m_LogCache.ClearAllParent();
2399 m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir);
2401 CTGitPath *path;
2402 if(this->m_Path.IsEmpty())
2403 path=NULL;
2404 else
2405 path=&this->m_Path;
2407 int mask;
2408 mask = CGit::LOG_INFO_ONLY_HASH;
2409 if (m_bIncludeBoundaryCommits)
2410 mask |= CGit::LOG_INFO_BOUNDARY;
2411 // if(this->m_bAllBranch)
2412 mask |= m_ShowMask ;
2414 if(m_bShowWC)
2416 this->m_logEntries.insert(m_logEntries.begin(),this->m_wcRev.m_CommitHash);
2417 ResetWcRev();
2418 this->m_LogCache.m_HashMap[m_wcRev.m_CommitHash]=m_wcRev;
2421 if (m_sRange.IsEmpty())
2422 m_sRange = _T("HEAD");
2424 CFilterData data;
2425 data.m_From = m_From;
2426 data.m_To =m_To;
2428 #if 0 /* use tortoiegit filter */
2429 if(this->m_nSelectedFilter == LOGFILTER_ALL || m_nSelectedFilter == LOGFILTER_AUTHORS)
2430 data.m_Author = this->m_sFilterText;
2432 if(this->m_nSelectedFilter == LOGFILTER_ALL || m_nSelectedFilter == LOGFILTER_MESSAGES)
2433 data.m_MessageFilter = this->m_sFilterText;
2435 data.m_IsRegex = m_bFilterWithRegex;
2436 #endif
2438 // follow does not work for directories
2439 if (!path || path->IsDirectory())
2440 mask &= ~CGit::LOG_INFO_FOLLOW;
2441 // follow does not work with all branches 8at least in TGit)
2442 if (mask & CGit::LOG_INFO_FOLLOW)
2443 mask &= ~CGit::LOG_INFO_ALL_BRANCH;
2445 CString cmd = g_Git.GetLogCmd(m_sRange, path, -1, mask, true, &data);
2447 //this->m_logEntries.ParserFromLog();
2448 if(IsInWorkingThread())
2450 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);
2452 else
2454 SetItemCountEx((int)m_logEntries.size());
2459 [] { git_init(); } ();
2461 catch (char* msg)
2463 CString err(msg);
2464 MessageBox(_T("Could not initialize libgit.\nlibgit reports:\n") + err, _T("TortoiseGit"), MB_ICONERROR);
2465 return -1;
2468 if (!g_Git.CanParseRev(m_sRange))
2470 if (!(mask & CGit::LOG_INFO_ALL_BRANCH))
2471 return 0;
2473 // if show all branches, pick any ref as dummy entry ref
2474 STRING_VECTOR list;
2475 if (g_Git.GetRefList(list))
2476 MessageBox(g_Git.GetGitLastErr(_T("Could not get all refs.")), _T("TortoiseGit"), MB_ICONERROR);
2477 if (list.size() == 0)
2478 return 0;
2480 cmd = g_Git.GetLogCmd(list[0], path, -1, mask, true, &data);
2483 g_Git.m_critGitDllSec.Lock();
2484 try {
2485 if (git_open_log(&m_DllGitLog, CUnicodeUtils::GetMulti(cmd, CP_UTF8).GetBuffer()))
2487 g_Git.m_critGitDllSec.Unlock();
2488 return -1;
2491 catch (char* msg)
2493 g_Git.m_critGitDllSec.Unlock();
2494 CString err(msg);
2495 MessageBox(_T("Could not open log.\nlibgit reports:\n") + err, _T("TortoiseGit"), MB_ICONERROR);
2496 return -1;
2498 g_Git.m_critGitDllSec.Unlock();
2500 return 0;
2503 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
2505 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
2507 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
2509 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
2511 DiffSelectedRevWithPrevious();
2512 return TRUE;
2515 #if 0
2516 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
2518 DiffSelectedFile();
2519 return TRUE;
2521 #endif
2523 else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 'A' && GetAsyncKeyState(VK_CONTROL)&0x8000)
2525 // select all entries
2526 for (int i=0; i<GetItemCount(); ++i)
2528 SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
2530 return TRUE;
2533 #if 0
2534 if (m_hAccel && !bSkipAccelerator)
2536 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
2537 if (ret)
2538 return TRUE;
2541 #endif
2542 //m_tooltips.RelayEvent(pMsg);
2543 return __super::PreTranslateMessage(pMsg);
2546 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
2548 // a double click on an entry in the revision list has happened
2549 *pResult = 0;
2551 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
2552 DiffSelectedRevWithPrevious();
2555 int CGitLogListBase::FetchLogAsync(void * data)
2557 ReloadHashMap();
2558 m_ProcData=data;
2559 m_bExitThread=FALSE;
2560 InterlockedExchange(&m_bThreadRunning, TRUE);
2561 InterlockedExchange(&m_bNoDispUpdates, TRUE);
2562 m_LoadingThread = AfxBeginThread(LogThreadEntry, this, THREAD_PRIORITY_LOWEST);
2563 if (m_LoadingThread ==NULL)
2565 InterlockedExchange(&m_bThreadRunning, FALSE);
2566 InterlockedExchange(&m_bNoDispUpdates, FALSE);
2567 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
2568 return -1;
2570 return 0;
2573 //this is the thread function which calls the subversion function
2574 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
2576 return ((CGitLogListBase*)pVoid)->LogThread();
2579 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
2581 //CTime time;
2582 oldest=CTime::GetCurrentTime();
2583 latest=CTime(1971,1,2,0,0,0);
2584 for (unsigned int i = 0; i < m_logEntries.size(); ++i)
2586 if(m_logEntries[i].IsEmpty())
2587 continue;
2589 if(m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime() < oldest.GetTime())
2590 oldest = m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime();
2592 if(m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime() > latest.GetTime())
2593 latest = m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime();
2597 if(latest<oldest)
2598 latest=oldest;
2601 UINT CGitLogListBase::LogThread()
2603 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0);
2605 InterlockedExchange(&m_bThreadRunning, TRUE);
2606 InterlockedExchange(&m_bNoDispUpdates, TRUE);
2608 ULONGLONG t1,t2;
2610 if(BeginFetchLog())
2612 InterlockedExchange(&m_bThreadRunning, FALSE);
2613 InterlockedExchange(&m_bNoDispUpdates, FALSE);
2615 return 1;
2618 std::tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
2619 bool bRegex = false;
2620 if (m_bFilterWithRegex)
2621 bRegex = ValidateRegexp(m_sFilterText, pat, false);
2623 TRACE(_T("\n===Begin===\n"));
2624 //Update work copy item;
2626 if (!m_logEntries.empty())
2628 GitRev *pRev = &m_logEntries.GetGitRevAt(0);
2630 m_arShownList.SafeAdd(pRev);
2634 InterlockedExchange(&m_bNoDispUpdates, FALSE);
2636 // store commit number of the last selected commit/line before the refresh or -1
2637 int lastSelectedHashNItem = -1;
2638 int ret = 0;
2640 bool shouldWalk = true;
2641 if (!g_Git.CanParseRev(m_sRange))
2643 // walk revisions if show all branches and there exists any ref
2644 if (!(m_ShowMask & CGit::LOG_INFO_ALL_BRANCH))
2645 shouldWalk = false;
2646 else
2648 STRING_VECTOR list;
2649 if (g_Git.GetRefList(list))
2650 MessageBox(g_Git.GetGitLastErr(_T("Could not get all refs.")), _T("TortoiseGit"), MB_ICONERROR);
2651 if (list.size() == 0)
2652 shouldWalk = false;
2656 if (shouldWalk)
2658 g_Git.m_critGitDllSec.Lock();
2659 int total = 0;
2662 [&] {git_get_log_firstcommit(m_DllGitLog);}();
2663 total = git_get_log_estimate_commit_count(m_DllGitLog);
2665 catch (char* msg)
2667 CString err(msg);
2668 MessageBox(_T("Could not get first commit.\nlibgit reports:\n") + err, _T("TortoiseGit"), MB_ICONERROR);
2669 ret = -1;
2671 g_Git.m_critGitDllSec.Unlock();
2673 GIT_COMMIT commit;
2674 t2=t1=GetTickCount();
2675 int oldprecentage = 0;
2676 size_t oldsize = m_logEntries.size();
2677 while (ret== 0 && !m_bExitThread)
2679 g_Git.m_critGitDllSec.Lock();
2682 [&] { ret = git_get_log_nextcommit(this->m_DllGitLog, &commit, m_ShowMask & CGit::LOG_INFO_FOLLOW); } ();
2684 catch (char* msg)
2686 g_Git.m_critGitDllSec.Unlock();
2687 CString err(msg);
2688 MessageBox(_T("Could not get next commit.\nlibgit reports:\n") + err, _T("TortoiseGit"), MB_ICONERROR);
2689 break;
2691 g_Git.m_critGitDllSec.Unlock();
2693 if(ret)
2694 break;
2696 if (commit.m_ignore == 1)
2698 git_free_commit(&commit);
2699 continue;
2702 //printf("%s\r\n",commit.GetSubject());
2703 if(m_bExitThread)
2704 break;
2706 CGitHash hash = (char*)commit.m_hash ;
2708 GitRev *pRev = m_LogCache.GetCacheData(hash);
2709 pRev->m_GitCommit = commit;
2710 InterlockedExchange(&pRev->m_IsCommitParsed, FALSE);
2712 char *note=NULL;
2713 g_Git.m_critGitDllSec.Lock();
2716 git_get_notes(commit.m_hash, &note);
2718 catch (char* msg)
2720 g_Git.m_critGitDllSec.Unlock();
2721 CString err(msg);
2722 MessageBox(_T("Could not get commit notes.\nlibgit reports:\n") + err, _T("TortoiseGit"), MB_ICONERROR);
2723 break;
2725 g_Git.m_critGitDllSec.Unlock();
2727 if(note)
2729 pRev->m_Notes.Empty();
2730 g_Git.StringAppend(&pRev->m_Notes,(BYTE*)note);
2733 if(!pRev->m_IsDiffFiles)
2735 pRev->m_CallDiffAsync = DiffAsync;
2738 pRev->ParserParentFromCommit(&commit);
2740 #ifdef DEBUG
2741 pRev->DbgPrint();
2742 TRACE(_T("\n"));
2743 #endif
2745 if(!m_sFilterText.IsEmpty())
2747 if(!IsMatchFilter(bRegex,pRev,pat))
2748 continue;
2750 this->m_critSec.Lock();
2751 m_logEntries.push_back(hash);
2752 m_arShownList.SafeAdd(pRev);
2753 this->m_critSec.Unlock();
2755 if (lastSelectedHashNItem == -1 && hash == m_lastSelectedHash)
2756 lastSelectedHashNItem = (int)m_arShownList.GetCount() - 1;
2758 t2=GetTickCount();
2760 if(t2-t1>500 || (m_logEntries.size()-oldsize >100))
2762 //update UI
2763 int percent = (int)m_logEntries.size() * 100 / total + GITLOG_START + 1;
2764 if(percent > 99)
2765 percent =99;
2766 if(percent < GITLOG_START)
2767 percent = GITLOG_START +1;
2769 oldsize = m_logEntries.size();
2770 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL|LVSICF_NOSCROLL);
2772 //if( percent > oldprecentage )
2774 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0);
2775 oldprecentage = percent;
2777 t1 = t2;
2780 g_Git.m_critGitDllSec.Lock();
2781 git_close_log(m_DllGitLog);
2782 g_Git.m_critGitDllSec.Unlock();
2786 if (m_bExitThread)
2788 InterlockedExchange(&m_bThreadRunning, FALSE);
2789 return 0;
2792 //Update UI;
2793 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL|LVSICF_NOSCROLL);
2795 if (lastSelectedHashNItem >= 0)
2796 PostMessage(m_ScrollToMessage, lastSelectedHashNItem);
2798 if (this->m_hWnd)
2799 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);
2801 InterlockedExchange(&m_bThreadRunning, FALSE);
2803 return 0;
2806 void CGitLogListBase::FetchRemoteList()
2808 STRING_VECTOR remoteList;
2809 if (!g_Git.GetRemoteList(remoteList))
2810 m_SingleRemote = remoteList.size() == 1 ? remoteList[0] : _T("");
2811 else
2812 m_SingleRemote = _T("");
2815 void CGitLogListBase::FetchTrackingBranchList()
2817 m_TrackingMap.clear();
2818 for (MAP_HASH_NAME::iterator it = m_HashMap.begin(); it != m_HashMap.end(); ++it)
2820 for (int j = 0; j < it->second.size(); ++j)
2822 CString branchName;
2823 if (CGit::GetShortName(it->second[j], branchName, _T("refs/heads/")))
2825 CString configName;
2826 configName.Format(_T("branch.%s.remote"), branchName);
2827 CString pullRemote = g_Git.GetConfigValue(configName);
2829 configName.Format(_T("branch.%s.merge"), branchName);
2830 CString pullBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));
2832 if (!pullRemote.IsEmpty() && !pullBranch.IsEmpty())
2834 m_TrackingMap[branchName] = std::make_pair(pullRemote, pullBranch);
2841 void CGitLogListBase::Refresh(BOOL IsCleanFilter)
2843 SafeTerminateThread();
2845 this->SetItemCountEx(0);
2846 this->Clear();
2848 ResetWcRev();
2850 // HACK to hide graph column
2851 if (m_ShowMask & CGit::LOG_INFO_FOLLOW)
2852 SetColumnWidth(0, 0);
2853 else
2854 SetColumnWidth(0, m_ColumnManager.GetWidth(0, false));
2856 //Update branch and Tag info
2857 ReloadHashMap();
2858 //Assume Thread have exited
2859 //if(!m_bThreadRunning)
2861 m_logEntries.clear();
2863 if(IsCleanFilter)
2865 m_sFilterText.Empty();
2866 m_From=-1;
2867 m_To=-1;
2870 InterlockedExchange(&m_bExitThread,FALSE);
2872 InterlockedExchange(&m_bThreadRunning, TRUE);
2873 InterlockedExchange(&m_bNoDispUpdates, TRUE);
2874 if ( (m_LoadingThread=AfxBeginThread(LogThreadEntry, this)) ==NULL)
2876 InterlockedExchange(&m_bThreadRunning, FALSE);
2877 InterlockedExchange(&m_bNoDispUpdates, FALSE);
2878 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
2882 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, std::tr1::wregex& pat, bool bMatchCase /* = false */)
2886 std::tr1::regex_constants::syntax_option_type type = std::tr1::regex_constants::ECMAScript;
2887 if (!bMatchCase)
2888 type |= std::tr1::regex_constants::icase;
2889 pat = std::tr1::wregex(regexp_str, type);
2890 return true;
2892 catch (std::exception) {}
2893 return false;
2895 BOOL CGitLogListBase::IsMatchFilter(bool bRegex, GitRev *pRev, std::tr1::wregex &pat)
2898 std::tr1::regex_constants::match_flag_type flags = std::tr1::regex_constants::match_any;
2899 CString sRev;
2901 if ((bRegex)&&(m_bFilterWithRegex))
2903 if (m_SelectedFilters & LOGFILTER_BUGID)
2905 if(this->m_bShowBugtraqColumn)
2907 CString sBugIds = m_ProjectProperties.FindBugID(pRev->GetSubject() + _T("\r\n\r\n") + pRev->GetBody());
2909 ATLTRACE(_T("bugID = \"%s\"\n"), sBugIds);
2910 if (std::regex_search(std::wstring(sBugIds), pat, flags))
2912 return TRUE;
2917 if ((m_SelectedFilters & LOGFILTER_SUBJECT) || (m_SelectedFilters & LOGFILTER_MESSAGES))
2919 ATLTRACE(_T("messge = \"%s\"\n"), pRev->GetSubject());
2920 if (std::regex_search(std::wstring((LPCTSTR)pRev->GetSubject()), pat, flags))
2922 return TRUE;
2926 if (m_SelectedFilters & LOGFILTER_MESSAGES)
2928 ATLTRACE(_T("messge = \"%s\"\n"),pRev->GetBody());
2929 if (std::regex_search(std::wstring((LPCTSTR)pRev->GetBody()), pat, flags))
2931 return TRUE;
2935 if (m_SelectedFilters & LOGFILTER_AUTHORS)
2937 if (std::regex_search(std::wstring(pRev->GetAuthorName()), pat, flags))
2939 return TRUE;
2942 if (std::regex_search(std::wstring(pRev->GetCommitterName()), pat, flags))
2944 return TRUE;
2948 if (m_SelectedFilters & LOGFILTER_EMAILS)
2950 if (std::regex_search(std::wstring(pRev->GetAuthorEmail()), pat, flags))
2952 return TRUE;
2955 if (std::regex_search(std::wstring(pRev->GetCommitterEmail()), pat, flags))
2957 return TRUE;
2961 if (m_SelectedFilters & LOGFILTER_REVS)
2963 sRev.Format(_T("%s"), pRev->m_CommitHash.ToString());
2964 if (std::regex_search(std::wstring((LPCTSTR)sRev), pat, flags))
2966 return TRUE;
2970 if (m_SelectedFilters & LOGFILTER_REFNAME)
2972 STRING_VECTOR refs = m_HashMap[pRev->m_CommitHash];
2973 for (auto it = refs.cbegin(); it != refs.cend(); ++it)
2975 if (std::regex_search(std::wstring((LPCTSTR)*it), pat, flags))
2977 return TRUE;
2982 if (m_SelectedFilters & LOGFILTER_PATHS)
2984 CTGitPathList *pathList=NULL;
2985 if( pRev->m_IsDiffFiles)
2986 pathList = &pRev->GetFiles(this);
2987 else
2989 if(!pRev->m_IsSimpleListReady)
2990 pRev->SafeGetSimpleList(&g_Git);
2993 if(pathList)
2994 for (INT_PTR cpPathIndex = 0; cpPathIndex < pathList->GetCount(); ++cpPathIndex)
2996 if (std::regex_search(std::wstring((LPCTSTR)pathList->m_paths.at(cpPathIndex).GetGitOldPathString()), pat, flags))
2998 return true;
3000 if (std::regex_search(std::wstring((LPCTSTR)pathList->m_paths.at(cpPathIndex).GetGitPathString()), pat, flags))
3002 return true;
3006 for (size_t i = 0; i < pRev->m_SimpleFileList.size(); ++i)
3008 if (std::regex_search(std::wstring((LPCTSTR)pRev->m_SimpleFileList[i]), pat, flags))
3010 return true;
3015 else
3017 CString find = m_sFilterText;
3018 find.MakeLower();
3020 if (m_SelectedFilters & LOGFILTER_BUGID)
3022 if(this->m_bShowBugtraqColumn)
3024 CString sBugIds = m_ProjectProperties.FindBugID(pRev->GetSubject() + _T("\r\n\r\n") + pRev->GetBody());
3026 sBugIds.MakeLower();
3027 if ((sBugIds.Find(find) >= 0))
3029 return TRUE;
3034 if ((m_SelectedFilters & LOGFILTER_SUBJECT) || (m_SelectedFilters & LOGFILTER_MESSAGES))
3036 CString msg = pRev->GetSubject();
3038 msg = msg.MakeLower();
3039 if ((msg.Find(find) >= 0))
3041 return TRUE;
3045 if (m_SelectedFilters & LOGFILTER_MESSAGES)
3047 CString msg = pRev->GetBody();
3049 msg = msg.MakeLower();
3050 if ((msg.Find(find) >= 0))
3052 return TRUE;
3056 if (m_SelectedFilters & LOGFILTER_AUTHORS)
3058 CString msg = pRev->GetAuthorName();
3059 msg = msg.MakeLower();
3060 if ((msg.Find(find) >= 0))
3062 return TRUE;
3066 if (m_SelectedFilters & LOGFILTER_EMAILS)
3068 CString msg = pRev->GetAuthorEmail();
3069 msg = msg.MakeLower();
3070 if ((msg.Find(find) >= 0))
3072 return TRUE;
3076 if (m_SelectedFilters & LOGFILTER_REVS)
3078 sRev.Format(_T("%s"), pRev->m_CommitHash.ToString());
3079 if ((sRev.Find(find) >= 0))
3081 return TRUE;
3085 if (m_SelectedFilters & LOGFILTER_REFNAME)
3087 STRING_VECTOR refs = m_HashMap[pRev->m_CommitHash];
3088 for (auto it = refs.cbegin(); it != refs.cend(); ++it)
3090 if (it->Find(find) >= 0)
3092 return TRUE;
3097 if (m_SelectedFilters & LOGFILTER_PATHS)
3099 CTGitPathList *pathList=NULL;
3100 if( pRev->m_IsDiffFiles)
3101 pathList = &pRev->GetFiles(this);
3102 else
3104 if(!pRev->m_IsSimpleListReady)
3105 pRev->SafeGetSimpleList(&g_Git);
3107 if(pathList)
3108 for (INT_PTR cpPathIndex = 0; cpPathIndex < pathList->GetCount() ; ++cpPathIndex)
3110 CTGitPath *cpath = &pathList->m_paths.at(cpPathIndex);
3111 CString path = cpath->GetGitOldPathString();
3112 path.MakeLower();
3113 if ((path.Find(find)>=0))
3115 return true;
3117 path = cpath->GetGitPathString();
3118 path.MakeLower();
3119 if ((path.Find(find)>=0))
3121 return true;
3125 for (size_t i = 0; i < pRev->m_SimpleFileList.size(); ++i)
3127 CString path = pRev->m_SimpleFileList[i];
3128 path.MakeLower();
3129 if ((path.Find(find)>=0))
3131 return true;
3135 } // else (from if (bRegex))
3136 return FALSE;
3140 void CGitLogListBase::RecalculateShownList(CThreadSafePtrArray * pShownlist)
3143 pShownlist->SafeRemoveAll();
3145 std::tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
3146 bool bRegex = false;
3147 if (m_bFilterWithRegex)
3148 bRegex = ValidateRegexp(m_sFilterText, pat, false);
3150 std::tr1::regex_constants::match_flag_type flags = std::tr1::regex_constants::match_any;
3151 CString sRev;
3152 for (DWORD i=0; i<m_logEntries.size(); ++i)
3154 if ((bRegex)&&(m_bFilterWithRegex))
3156 #if 0
3157 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
3159 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
3160 if (std::regex_search(std::wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
3162 pShownlist->SafeAdd(m_logEntries[i]);
3163 continue;
3166 #endif
3167 if ((m_SelectedFilters & LOGFILTER_SUBJECT) || (m_SelectedFilters & LOGFILTER_MESSAGES))
3169 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries.GetGitRevAt(i).GetSubject());
3170 if (std::regex_search(std::wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).GetSubject()), pat, flags)&&IsEntryInDateRange(i))
3172 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3173 continue;
3176 if (m_SelectedFilters & LOGFILTER_MESSAGES)
3178 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries.GetGitRevAt(i).GetBody());
3179 if (std::regex_search(std::wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).GetBody()), pat, flags)&&IsEntryInDateRange(i))
3181 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3182 continue;
3185 if (m_SelectedFilters & LOGFILTER_PATHS)
3187 CTGitPathList pathList = m_logEntries.GetGitRevAt(i).GetFiles(this);
3189 bool bGoing = true;
3190 for (INT_PTR cpPathIndex = 0; cpPathIndex < pathList.GetCount() && bGoing; ++cpPathIndex)
3192 CTGitPath cpath = pathList[cpPathIndex];
3193 if (std::regex_search(std::wstring((LPCTSTR)cpath.GetGitOldPathString()), pat, flags)&&IsEntryInDateRange(i))
3195 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3196 bGoing = false;
3197 continue;
3199 if (std::regex_search(std::wstring((LPCTSTR)cpath.GetGitPathString()), pat, flags)&&IsEntryInDateRange(i))
3201 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3202 bGoing = false;
3203 continue;
3205 if (std::regex_search(std::wstring((LPCTSTR)cpath.GetActionName()), pat, flags)&&IsEntryInDateRange(i))
3207 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3208 bGoing = false;
3209 continue;
3213 if (m_SelectedFilters & LOGFILTER_AUTHORS)
3215 if (std::regex_search(std::wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).GetAuthorName()), pat, flags)&&IsEntryInDateRange(i))
3217 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3218 continue;
3221 if (m_SelectedFilters & LOGFILTER_EMAILS)
3223 if (std::regex_search(std::wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).GetAuthorEmail()), pat, flags) && IsEntryInDateRange(i))
3225 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3226 continue;
3229 if (m_SelectedFilters & LOGFILTER_REVS)
3231 sRev.Format(_T("%s"), m_logEntries.GetGitRevAt(i).m_CommitHash.ToString());
3232 if (std::regex_search(std::wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
3234 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3235 continue;
3238 if (m_SelectedFilters & LOGFILTER_REFNAME)
3240 STRING_VECTOR refs = m_HashMap[m_logEntries.GetGitRevAt(i).m_CommitHash];
3241 for (auto it = refs.cbegin(); it != refs.cend(); ++it)
3243 if (std::regex_search(std::wstring((LPCTSTR)*it), pat, flags) && IsEntryInDateRange(i))
3245 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3246 continue;
3250 } // if (bRegex)
3251 else
3253 CString find = m_sFilterText;
3254 find.MakeLower();
3255 #if 0
3256 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
3258 CString sBugIDs = m_logEntries[i]->sBugIDs;
3260 sBugIDs = sBugIDs.MakeLower();
3261 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
3263 pShownlist->SafeAdd(m_logEntries[i]);
3264 continue;
3267 #endif
3268 if ((m_SelectedFilters & LOGFILTER_SUBJECT) || (m_SelectedFilters & LOGFILTER_MESSAGES))
3270 CString msg = m_logEntries.GetGitRevAt(i).GetSubject();
3272 msg = msg.MakeLower();
3273 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
3275 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3276 continue;
3279 if (m_SelectedFilters & LOGFILTER_MESSAGES)
3281 CString msg = m_logEntries.GetGitRevAt(i).GetBody();
3283 msg = msg.MakeLower();
3284 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
3286 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3287 continue;
3290 if (m_SelectedFilters & LOGFILTER_PATHS)
3292 CTGitPathList pathList = m_logEntries.GetGitRevAt(i).GetFiles(this);
3294 bool bGoing = true;
3295 for (INT_PTR cpPathIndex = 0; cpPathIndex < pathList.GetCount() && bGoing; ++cpPathIndex)
3297 CTGitPath cpath = pathList[cpPathIndex];
3298 CString path = cpath.GetGitOldPathString();
3299 path.MakeLower();
3300 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
3302 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3303 bGoing = false;
3304 continue;
3306 path = cpath.GetGitPathString();
3307 path.MakeLower();
3308 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
3310 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3311 bGoing = false;
3312 continue;
3314 path = cpath.GetActionName();
3315 path.MakeLower();
3316 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
3318 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3319 bGoing = false;
3320 continue;
3324 if (m_SelectedFilters & LOGFILTER_AUTHORS)
3326 CString msg = m_logEntries.GetGitRevAt(i).GetAuthorName();
3327 msg = msg.MakeLower();
3328 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
3330 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3331 continue;
3334 if (m_SelectedFilters & LOGFILTER_EMAILS)
3336 CString msg = m_logEntries.GetGitRevAt(i).GetAuthorEmail();
3337 msg = msg.MakeLower();
3338 if ((msg.Find(find) >= 0) && (IsEntryInDateRange(i)))
3340 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3341 continue;
3344 if (m_SelectedFilters & LOGFILTER_REVS)
3346 sRev.Format(_T("%s"), m_logEntries.GetGitRevAt(i).m_CommitHash.ToString());
3347 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
3349 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3350 continue;
3353 if (m_SelectedFilters & LOGFILTER_REFNAME)
3355 STRING_VECTOR refs = m_HashMap[m_logEntries.GetGitRevAt(i).m_CommitHash];
3356 for (auto it = refs.cbegin(); it != refs.cend(); ++it)
3358 if (it->Find(find) >= 0 && IsEntryInDateRange(i))
3360 pShownlist->SafeAdd(&m_logEntries.GetGitRevAt(i));
3361 continue;
3365 } // else (from if (bRegex))
3366 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
3370 BOOL CGitLogListBase::IsEntryInDateRange(int /*i*/)
3373 __time64_t time = m_logEntries.GetGitRevAt(i).GetAuthorDate().GetTime();
3375 if(m_From == -1)
3376 if(m_To == -1)
3377 return true;
3378 else
3379 return time <= m_To;
3380 else
3381 if(m_To == -1)
3382 return time >= m_From;
3383 else
3384 return ((time >= m_From)&&(time <= m_To));
3386 return TRUE; /* git dll will filter time range */
3388 // return TRUE;
3390 void CGitLogListBase::StartFilter()
3392 InterlockedExchange(&m_bNoDispUpdates, TRUE);
3393 RecalculateShownList(&m_arShownList);
3394 InterlockedExchange(&m_bNoDispUpdates, FALSE);
3397 DeleteAllItems();
3398 SetItemCountEx(ShownCountWithStopped());
3399 RedrawItems(0, ShownCountWithStopped());
3400 Invalidate();
3403 void CGitLogListBase::RemoveFilter()
3406 InterlockedExchange(&m_bNoDispUpdates, TRUE);
3408 m_arShownList.SafeRemoveAll();
3410 // reset the time filter too
3411 #if 0
3412 m_timFrom = (__time64_t(m_tFrom));
3413 m_timTo = (__time64_t(m_tTo));
3414 m_DateFrom.SetTime(&m_timFrom);
3415 m_DateTo.SetTime(&m_timTo);
3416 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
3417 m_DateTo.SetRange(&m_timFrom, &m_timTo);
3418 #endif
3420 for (DWORD i=0; i<m_logEntries.size(); ++i)
3422 if(this->m_IsOldFirst)
3424 m_arShownList.SafeAdd(&m_logEntries.GetGitRevAt(m_logEntries.size()-i-1));
3426 else
3428 m_arShownList.SafeAdd(&m_logEntries.GetGitRevAt(i));
3431 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
3432 DeleteAllItems();
3433 SetItemCountEx(ShownCountWithStopped());
3434 RedrawItems(0, ShownCountWithStopped());
3436 InterlockedExchange(&m_bNoDispUpdates, FALSE);
3439 void CGitLogListBase::Clear()
3441 m_arShownList.SafeRemoveAll();
3442 DeleteAllItems();
3444 m_logEntries.ClearAll();
3448 void CGitLogListBase::OnDestroy()
3450 // save the column widths to the registry
3451 SaveColumnWidths();
3453 SafeTerminateThread();
3454 SafeTerminateAsyncDiffThread();
3456 int retry = 0;
3457 while(m_LogCache.SaveCache())
3459 if(retry > 5)
3460 break;
3461 Sleep(1000);
3463 ++retry;
3465 //if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
3466 // MB_YESNO) == IDNO)
3467 // break;
3470 CHintListCtrl::OnDestroy();
3473 LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM /*lParam*/)
3475 CRect rect;
3476 int i=(int)wParam;
3477 this->GetItemRect(i,&rect,LVIR_BOUNDS);
3478 this->InvalidateRect(rect);
3480 return 0;
3484 * Save column widths to the registry
3486 void CGitLogListBase::SaveColumnWidths()
3488 int maxcol = m_ColumnManager.GetColumnCount();
3490 // HACK that graph column is always shown
3491 SetColumnWidth(0, m_ColumnManager.GetWidth(0, false));
3493 for (int col = 0; col < maxcol; ++col)
3494 if (m_ColumnManager.IsVisible (col))
3495 m_ColumnManager.ColumnResized (col);
3497 m_ColumnManager.WriteSettings();
3500 int CGitLogListBase::GetHeadIndex()
3502 if(m_HeadHash.IsEmpty())
3503 return -1;
3505 for (int i = 0; i < m_arShownList.GetCount(); ++i)
3507 GitRev *pRev = (GitRev*)m_arShownList.SafeGetAt(i);
3508 if(pRev)
3510 if(pRev->m_CommitHash.ToString() == m_HeadHash )
3511 return i;
3514 return -1;
3516 void CGitLogListBase::OnFind()
3518 if (!m_pFindDialog)
3520 m_pFindDialog = new CFindDlg(this);
3521 m_pFindDialog->Create(this);
3524 void CGitLogListBase::OnHdnBegintrack(NMHDR *pNMHDR, LRESULT *pResult)
3526 m_ColumnManager.OnHdnBegintrack(pNMHDR, pResult);
3528 void CGitLogListBase::OnHdnItemchanging(NMHDR *pNMHDR, LRESULT *pResult)
3530 if(!m_ColumnManager.OnHdnItemchanging(pNMHDR, pResult))
3531 Default();
3533 LRESULT CGitLogListBase::OnScrollToMessage(WPARAM itemToSelect, LPARAM /*lParam*/)
3535 if (GetSelectedCount() != 0)
3536 return 0;
3537 SetItemState((int)itemToSelect, LVIS_SELECTED, LVIS_SELECTED);
3538 EnsureVisible((int)itemToSelect, FALSE);
3539 return 0;
3541 LRESULT CGitLogListBase::OnFindDialogMessage(WPARAM /*wParam*/, LPARAM /*lParam*/)
3544 ASSERT(m_pFindDialog != NULL);
3545 bool bFound = false;
3546 int i=0;
3548 if (m_pFindDialog->IsTerminating())
3550 // invalidate the handle identifying the dialog box.
3551 m_pFindDialog = NULL;
3552 return 0;
3555 if(m_pFindDialog->IsRef())
3557 CString str;
3558 str=m_pFindDialog->GetFindString();
3560 CGitHash hash;
3562 if(!str.IsEmpty())
3564 if (g_Git.GetHash(hash, str + _T("^{}"))) // add ^{} in order to get the correct SHA-1 (especially for signed tags)
3565 MessageBox(g_Git.GetGitLastErr(_T("Could not get hash of ref \"") + str + _T("^{}\".")), _T("TortoiseGit"), MB_ICONERROR);
3568 if(!hash.IsEmpty())
3570 for (i = 0; i<m_arShownList.GetCount(); ++i)
3572 GitRev* pLogEntry = (GitRev*)m_arShownList.SafeGetAt(i);
3573 if(pLogEntry && pLogEntry->m_CommitHash == hash)
3575 bFound = true;
3576 break;
3583 if(m_pFindDialog->FindNext())
3585 //read data from dialog
3586 CString FindText = m_pFindDialog->GetFindString();
3587 bool bMatchCase = (m_pFindDialog->MatchCase() == TRUE);
3589 std::tr1::wregex pat;
3590 bool bRegex = ValidateRegexp(FindText, pat, bMatchCase);
3592 std::tr1::regex_constants::match_flag_type flags = std::tr1::regex_constants::match_not_null;
3595 for (i = this->m_nSearchIndex; i < m_arShownList.GetCount() && !bFound; ++i)
3597 GitRev* pLogEntry = (GitRev*)m_arShownList.SafeGetAt(i);
3599 CString str;
3600 str+=pLogEntry->m_CommitHash.ToString();
3601 str+=_T("\n");
3603 for (size_t j = 0; j < this->m_HashMap[pLogEntry->m_CommitHash].size(); ++j)
3605 str+=m_HashMap[pLogEntry->m_CommitHash][j];
3606 str+=_T("\n");
3609 str+=pLogEntry->GetAuthorEmail();
3610 str+=_T("\n");
3611 str+=pLogEntry->GetAuthorName();
3612 str+=_T("\n");
3613 str+=pLogEntry->GetBody();
3614 str+=_T("\n");
3615 str+=pLogEntry->GetCommitterEmail();
3616 str+=_T("\n");
3617 str+=pLogEntry->GetCommitterName();
3618 str+=_T("\n");
3619 str+=pLogEntry->GetSubject();
3620 str+=_T("\n");
3623 /*Because changed files list is loaded on demand when gui show,
3624 files will empty when files have not fetched.
3626 we can add it back by using one-way diff(with outnumber changed and rename detect.
3627 here just need changed filename list. one-way is much quicker.
3629 if(pLogEntry->m_IsFull)
3631 for (int i = 0; i < pLogEntry->GetFiles(this).GetCount(); ++i)
3633 str+=pLogEntry->GetFiles(this)[i].GetWinPath();
3634 str+=_T("\n");
3635 str+=pLogEntry->GetFiles(this)[i].GetGitOldPathString();
3636 str+=_T("\n");
3639 else
3641 if(!pLogEntry->m_IsSimpleListReady)
3642 pLogEntry->SafeGetSimpleList(&g_Git);
3644 for (size_t i = 0; i < pLogEntry->m_SimpleFileList.size(); ++i)
3646 str+=pLogEntry->m_SimpleFileList[i];
3647 str+=_T("\n");
3653 if (bRegex)
3655 if (std::regex_search(std::wstring(str), pat, flags))
3657 bFound = true;
3658 break;
3661 else
3663 if (bMatchCase)
3665 if (str.Find(FindText) >= 0)
3667 bFound = true;
3668 break;
3672 else
3674 CString msg = str;
3675 msg = msg.MakeLower();
3676 CString find = FindText.MakeLower();
3677 if (msg.Find(find) >= 0)
3679 bFound = TRUE;
3680 break;
3684 } // for (i = this->m_nSearchIndex; i<m_arShownList.GetItemCount()&&!bFound; ++i)
3686 } // if(m_pFindDialog->FindNext())
3687 //UpdateLogInfoLabel();
3689 if (bFound)
3691 this->m_nSearchIndex = i;
3692 EnsureVisible(i, FALSE);
3693 SetItemState(GetSelectionMark(), 0, LVIS_SELECTED);
3694 SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
3695 SetSelectionMark(i);
3696 //FillLogMessageCtrl();
3697 UpdateData(FALSE);
3698 ++m_nSearchIndex;
3699 if (m_nSearchIndex >= m_arShownList.GetCount())
3700 m_nSearchIndex = (int)m_arShownList.GetCount()-1;
3703 return 0;
3706 void CGitLogListBase::OnColumnResized(NMHDR *pNMHDR, LRESULT *pResult)
3708 m_ColumnManager.OnColumnResized(pNMHDR,pResult);
3710 *pResult = FALSE;
3713 void CGitLogListBase::OnColumnMoved(NMHDR *pNMHDR, LRESULT *pResult)
3715 m_ColumnManager.OnColumnMoved(pNMHDR, pResult);
3717 Invalidate(FALSE);