Fixed issue #2495: "Show Reflog" dialog shows empty action for "push" entries
[TortoiseGit.git] / src / TortoiseProc / refloglist.cpp
blob7a37fcba3c091208e124e7a80ee096d1837bba24
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2011,2013,2015 TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 #include "resource.h"
21 #include "RefLogDlg.h"
22 #include "Git.h"
23 #include "refloglist.h"
24 #include "LoglistUtils.h"
26 IMPLEMENT_DYNAMIC(CRefLogList, CGitLogList)
28 CRefLogList::CRefLogList()
30 m_ColumnRegKey=_T("reflog");
31 this->m_ContextMenuMask |= this->GetContextMenuBit(ID_LOG);
34 void CRefLogList::InsertRefLogColumn()
36 CString temp;
38 CRegDWORD regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE);
39 DWORD exStyle = LVS_EX_HEADERDRAGDROP | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_SUBITEMIMAGES;
40 if (DWORD(regFullRowSelect))
41 exStyle |= LVS_EX_FULLROWSELECT;
42 SetExtendedStyle(exStyle);
44 static UINT normal[] =
46 IDS_HASH,
47 IDS_REF,
48 IDS_ACTION,
49 IDS_MESSAGE,
50 IDS_STATUSLIST_COLDATE,
53 static int with[] =
55 ICONITEMBORDER+16*4,
56 ICONITEMBORDER+16*4,
57 ICONITEMBORDER+16*4,
58 LOGLIST_MESSAGE_MIN,
59 ICONITEMBORDER+16*4,
61 m_dwDefaultColumns = 0xFFFF;
63 SetRedraw(false);
65 m_ColumnManager.SetNames(normal, _countof(normal));
66 m_ColumnManager.ReadSettings(m_dwDefaultColumns,0, m_ColumnRegKey+_T("loglist"), _countof(normal), with);
68 SetRedraw(true);
72 void CRefLogList::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
74 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
76 // Create a pointer to the item
77 LV_ITEM* pItem = &(pDispInfo)->item;
79 // Do the list need text information?
80 if (!(pItem->mask & LVIF_TEXT))
81 return;
83 // By default, clear text buffer.
84 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
86 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
88 *pResult = 0;
89 if (m_bNoDispUpdates || bOutOfRange)
90 return;
92 // Which item number?
93 int itemid = pItem->iItem;
94 GitRevLoglist* pLogEntry = nullptr;
95 if (itemid < m_arShownList.GetCount())
96 pLogEntry = reinterpret_cast<GitRevLoglist*>(m_arShownList.GetAt(pItem->iItem));
98 CString temp;
100 // Which column?
101 switch (pItem->iSubItem)
103 case REFLOG_HASH:
104 if (pLogEntry)
106 lstrcpyn(pItem->pszText,pLogEntry->m_CommitHash.ToString(), pItem->cchTextMax);
108 break;
109 case REFLOG_REF:
110 if(pLogEntry)
111 lstrcpyn(pItem->pszText, pLogEntry->m_Ref, pItem->cchTextMax);
112 break;
113 case REFLOG_ACTION:
114 if (pLogEntry)
115 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_RefAction, pItem->cchTextMax);
116 break;
117 case REFLOG_MESSAGE:
118 if (pLogEntry)
119 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->GetSubject().Trim(), pItem->cchTextMax);
120 break;
121 case REFLOG_DATE:
122 if (pLogEntry)
123 lstrcpyn(pItem->pszText, (LPCTSTR)CLoglistUtils::FormatDateAndTime(pLogEntry->GetCommitterDate(), m_DateFormat, true, m_bRelativeTimes), pItem->cchTextMax);
124 break;
126 default:
127 ASSERT(false);
131 void CRefLogList::OnNMCustomdrawLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
133 // Take the default processing unless we set this to something else below.
134 *pResult = CDRF_DODEFAULT;