OSDN Git Service

BranchView: Show commit subject and date
authorJohan t Hart <johanthart@gmail.com>
Thu, 23 Apr 2009 23:09:29 +0000 (01:09 +0200)
committerFrank Li <lznuaa@gmail.com>
Fri, 24 Apr 2009 01:51:14 +0000 (09:51 +0800)
src/TortoiseProc/BrowseRefsDlg.cpp
src/TortoiseProc/BrowseRefsDlg.h

index 16e77fd..25f77f2 100644 (file)
@@ -90,8 +90,9 @@ typedef std::map<CString,CString> MAP_STRING_STRING;
 \r
 void CBrowseRefsDlg::Refresh()\r
 {\r
-       m_RefMap.clear();\r
-       g_Git.GetMapHashToFriendName(m_RefMap);\r
+//     m_RefMap.clear();\r
+//     g_Git.GetMapHashToFriendName(m_RefMap);\r
+               \r
 \r
        m_RefTreeCtrl.DeleteAllItems();\r
        m_TreeRoot.m_ShadowTree.clear();\r
@@ -99,19 +100,46 @@ void CBrowseRefsDlg::Refresh()
        m_TreeRoot.m_hTree=m_RefTreeCtrl.InsertItem(L"Refs",NULL,NULL);\r
        m_RefTreeCtrl.SetItemData(m_TreeRoot.m_hTree,(DWORD_PTR)&m_TreeRoot);\r
 \r
+       CString allRefs;\r
+       g_Git.Run(L"git for-each-ref --format="\r
+                         L"%(refname)%04"\r
+                         L"%(objectname)%04"\r
+                         L"%(authordate:relative)%04"\r
+                         L"%(subject)%04"\r
+                         L"%(authorname)",\r
+                         &allRefs,CP_UTF8);\r
 \r
-       MAP_STRING_STRING refName;\r
+       int linePos=0;\r
+       CString singleRef;\r
+\r
+       MAP_STRING_STRING refMap;\r
 \r
        //First sort on ref name\r
-       for(MAP_HASH_NAME::iterator iterRef=m_RefMap.begin();iterRef!=m_RefMap.end();++iterRef)\r
-               for(STRING_VECTOR::iterator iterRefName=iterRef->second.begin();iterRefName!=iterRef->second.end();++iterRefName)\r
-                       refName[*iterRefName]=iterRef->first;\r
+       while(!(singleRef=allRefs.Tokenize(L"\r\n",linePos)).IsEmpty())\r
+       {\r
+               int valuePos=0;\r
+               CString refName=singleRef.Tokenize(L"\04",valuePos);\r
+               CString refRest=singleRef.Mid(valuePos);\r
+               refMap[refName]=refRest;\r
+       }\r
+\r
+\r
+\r
+//     for(MAP_HASH_NAME::iterator iterRef=m_RefMap.begin();iterRef!=m_RefMap.end();++iterRef)\r
+//             for(STRING_VECTOR::iterator iterRefName=iterRef->second.begin();iterRefName!=iterRef->second.end();++iterRefName)\r
+//                     refName[*iterRefName]=iterRef->first;\r
 \r
        //Populate ref tree\r
-       for(MAP_STRING_STRING::iterator iterRefName=refName.begin();iterRefName!=refName.end();++iterRefName)\r
+       for(MAP_STRING_STRING::iterator iterRefMap=refMap.begin();iterRefMap!=refMap.end();++iterRefMap)\r
        {\r
-               CShadowTree& treeLeaf=GetTreeNode(iterRefName->first);\r
-               treeLeaf.m_csRef=iterRefName->second;\r
+               CShadowTree& treeLeaf=GetTreeNode(iterRefMap->first);\r
+               CString values=iterRefMap->second;\r
+\r
+               int valuePos=0;\r
+               treeLeaf.m_csRef=     values.Tokenize(L"\04",valuePos);\r
+               treeLeaf.m_csDate=    values.Tokenize(L"\04",valuePos);\r
+               treeLeaf.m_csSubject= values.Tokenize(L"\04",valuePos);\r
+               treeLeaf.m_csAuthor=  values.Tokenize(L"\04",valuePos);\r
        }\r
 \r
        CString currHead;\r
@@ -213,6 +241,8 @@ void CBrowseRefsDlg::FillListCtrlForShadowTree(CShadowTree* pTree, CString refNa
 \r
                m_ListRefLeafs.SetItemData(indexItem,(DWORD_PTR)pTree);\r
                m_ListRefLeafs.SetItemText(indexItem,0,refNamePrefix+pTree->m_csName);\r
+               m_ListRefLeafs.SetItemText(indexItem,1,refNamePrefix+pTree->m_csDate);\r
+               m_ListRefLeafs.SetItemText(indexItem,2,refNamePrefix+pTree->m_csSubject);\r
                m_ListRefLeafs.SetItemText(indexItem,3,pTree->m_csRef);\r
        }\r
        else\r
index 62ad450..28e7d9a 100644 (file)
@@ -19,6 +19,9 @@ public:
 \r
        CString                 m_csName;\r
        CString                 m_csRef;\r
+       CString                 m_csDate;\r
+       CString                 m_csAuthor;\r
+       CString                 m_csSubject;\r
 \r
        HTREEITEM               m_hTree;\r
 \r
@@ -56,7 +59,7 @@ public:
        bool                    SelectRef(CString refName);\r
 \r
 private:\r
-       MAP_HASH_NAME   m_RefMap;\r
+//     MAP_HASH_NAME   m_RefMap;\r
 \r
        CShadowTree             m_TreeRoot;\r
        CTreeCtrl               m_RefTreeCtrl;\r