Refresh(m_initialRef);\r
\r
\r
- return TRUE;\r
+ m_ListRefLeafs.SetFocus();\r
+ return FALSE;\r
}\r
\r
CShadowTree* CShadowTree::GetNextSub(CString& nameLeft, bool bCreateIfNotExist)\r
return &nextNode;\r
}\r
\r
+CShadowTree* CShadowTree::FindLeaf(CString partialRefName)\r
+{\r
+ if(IsLeaf())\r
+ {\r
+ if(m_csRefName.GetLength() > partialRefName.GetLength())\r
+ return NULL;\r
+ if(partialRefName.Right(m_csRefName.GetLength()) == m_csRefName)\r
+ {\r
+ //Match of leaf name. Try match on total name.\r
+ CString totalRefName = GetRefName();\r
+ if(totalRefName.Right(partialRefName.GetLength()) == partialRefName)\r
+ return this; //Also match. Found.\r
+ }\r
+ }\r
+ else\r
+ {\r
+ //Not a leaf. Search all nodes.\r
+ for(TShadowTreeMap::iterator itShadowTree = m_ShadowTree.begin(); itShadowTree != m_ShadowTree.end(); ++itShadowTree)\r
+ {\r
+ CShadowTree* pSubtree = itShadowTree->second.FindLeaf(partialRefName);\r
+ if(pSubtree != NULL)\r
+ return pSubtree; //Found\r
+ }\r
+ }\r
+ return NULL;//Not found\r
+}\r
+\r
+\r
typedef std::map<CString,CString> MAP_STRING_STRING;\r
\r
CString CBrowseRefsDlg::GetSelectedRef(bool onlyIfLeaf)\r
}\r
\r
\r
- if(selectRef.IsEmpty() || !SelectRef(selectRef))\r
+ if(selectRef.IsEmpty() || !SelectRef(selectRef, false))\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
+bool CBrowseRefsDlg::SelectRef(CString refName, bool bExactMatch)\r
{\r
+ if(!bExactMatch)\r
+ refName = GetFullRefName(refName);\r
if(wcsnicmp(refName,L"refs/",5)!=0)\r
return false; // Not a ref name\r
\r
return true;\r
}\r
\r
+CString CBrowseRefsDlg::GetFullRefName(CString partialRefName)\r
+{\r
+ CShadowTree* pLeaf = m_TreeRoot.FindLeaf(partialRefName);\r
+ if(pLeaf == NULL)\r
+ return CString();\r
+ return pLeaf->GetRefName();\r
+}\r
+\r
+\r
void CBrowseRefsDlg::OnContextMenu(CWnd* pWndFrom, CPoint point)\r
{\r
if(pWndFrom==&m_RefTreeCtrl) OnContextMenu_RefTreeCtrl(point);\r
return wcsncmp(GetRefName(),from,wcslen(from))==0;\r
}\r
\r
+ CShadowTree* FindLeaf(CString partialRefName);\r
+\r
CString m_csRefName;\r
CString m_csRefHash;\r
CString m_csDate;\r
\r
void FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);\r
\r
- bool SelectRef(CString refName);\r
+ bool SelectRef(CString refName, bool bExactMatch);\r
\r
bool ConfirmDeleteRef(CString completeRefName);\r
bool DoDeleteRef(CString completeRefName, bool bForce);\r
\r
+ CString GetFullRefName(CString partialRefName);\r
+\r
private:\r
CString m_cmdPath;\r
\r