OSDN Git Service

BrowseRefDlg: Select current HEAD
authorJohan t Hart <johanthart@gmail.com>
Wed, 22 Apr 2009 22:51:36 +0000 (00:51 +0200)
committerFrank Li <lznuaa@gmail.com>
Fri, 24 Apr 2009 01:51:13 +0000 (09:51 +0800)
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/BrowseRefsDlg.cpp
src/TortoiseProc/BrowseRefsDlg.h

index 6ad4512..1831be1 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index 50a4fe6..16e77fd 100644 (file)
@@ -114,8 +114,39 @@ void CBrowseRefsDlg::Refresh()
                treeLeaf.m_csRef=iterRefName->second;\r
        }\r
 \r
                treeLeaf.m_csRef=iterRefName->second;\r
        }\r
 \r
-       m_RefTreeCtrl.Expand(m_TreeRoot.m_hTree,TVE_EXPAND);\r
+       CString currHead;\r
+       g_Git.Run(L"git symbolic-ref HEAD",&currHead,CP_UTF8);\r
 \r
 \r
+       currHead.Trim(L"\r\n\t ");\r
+\r
+       if(!SelectRef(currHead))\r
+               //Probably not on a branch. Select root node.\r
+               m_RefTreeCtrl.Expand(m_TreeRoot.m_hTree,TVE_EXPAND);\r
+\r
+}\r
+\r
+bool CBrowseRefsDlg::SelectRef(CString refName)\r
+{\r
+       if(wcsnicmp(refName,L"refs/",5)!=0)\r
+               return false; // Not a ref name\r
+\r
+       CShadowTree& treeLeafHead=GetTreeNode(refName);\r
+       if(treeLeafHead.m_pParent==NULL)\r
+               return false; //Weird... should not occur.\r
+\r
+       //This is the current head.\r
+       m_RefTreeCtrl.Select(treeLeafHead.m_pParent->m_hTree,TVGN_CARET);\r
+\r
+       for(int indexPos = 0; indexPos < m_ListRefLeafs.GetItemCount(); ++indexPos)\r
+       {\r
+               CShadowTree* pCurrShadowTree = (CShadowTree*)m_ListRefLeafs.GetItemData(indexPos);\r
+               if(pCurrShadowTree == &treeLeafHead)\r
+               {\r
+                       m_ListRefLeafs.SetItemState(indexPos,LVIS_SELECTED,LVIS_SELECTED);\r
+               }\r
+       }\r
+\r
+       return true;\r
 }\r
 \r
 CShadowTree& CBrowseRefsDlg::GetTreeNode(CString refName, CShadowTree* pTreePos)\r
 }\r
 \r
 CShadowTree& CBrowseRefsDlg::GetTreeNode(CString refName, CShadowTree* pTreePos)\r
index d1a1f4b..62ad450 100644 (file)
@@ -53,6 +53,8 @@ public:
 \r
        void                    FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);\r
 \r
 \r
        void                    FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);\r
 \r
+       bool                    SelectRef(CString refName);\r
+\r
 private:\r
        MAP_HASH_NAME   m_RefMap;\r
 \r
 private:\r
        MAP_HASH_NAME   m_RefMap;\r
 \r