OSDN Git Service

PushDlg: Fix: Wrong remote selected after selection via ref-browser.
authorJohan 't Hart <johanthart@gmail.com>
Tue, 16 Jun 2009 23:06:17 +0000 (01:06 +0200)
committerJohan 't Hart <johanthart@gmail.com>
Tue, 16 Jun 2009 23:06:17 +0000 (01:06 +0200)
src/TortoiseProc/PushDlg.cpp
src/Utils/MiscUI/HistoryCombo.cpp

index e26b462..fc606fe 100644 (file)
@@ -157,7 +157,7 @@ void CPushDlg::OnBnClickedRd()
 void CPushDlg::OnCbnSelchangeBranchSource()\r
 {\r
        // TODO: Add your control notification handler code here\r
 void CPushDlg::OnCbnSelchangeBranchSource()\r
 {\r
        // TODO: Add your control notification handler code here\r
-       m_BranchRemote.SetWindowTextW(m_BranchSource.GetString());\r
+       m_BranchRemote.AddString(m_BranchSource.GetString());\r
 }\r
 \r
 void CPushDlg::OnBnClickedOk()\r
 }\r
 \r
 void CPushDlg::OnBnClickedOk()\r
@@ -200,12 +200,23 @@ void CPushDlg::OnBnClickedButtonBrowseSourceBranch()
 void CPushDlg::OnBnClickedButtonBrowseDestBranch()\r
 {\r
        CString remoteBranchName;\r
 void CPushDlg::OnBnClickedButtonBrowseDestBranch()\r
 {\r
        CString remoteBranchName;\r
+       CString remoteName;\r
        m_BranchRemote.GetWindowText(remoteBranchName);\r
        m_BranchRemote.GetWindowText(remoteBranchName);\r
+       remoteName = m_Remote.GetString();\r
+       remoteBranchName = remoteName + '/' + remoteBranchName;\r
        remoteBranchName = CBrowseRefsDlg::PickRef(false, remoteBranchName, gPickRef_Remote);\r
        if(remoteBranchName.IsEmpty())\r
                return; //Canceled\r
        remoteBranchName = remoteBranchName.Mid(13);//Strip 'refs/remotes/'\r
        remoteBranchName = CBrowseRefsDlg::PickRef(false, remoteBranchName, gPickRef_Remote);\r
        if(remoteBranchName.IsEmpty())\r
                return; //Canceled\r
        remoteBranchName = remoteBranchName.Mid(13);//Strip 'refs/remotes/'\r
-       remoteBranchName = remoteBranchName.Mid(remoteBranchName.Find('/') + 1); //Strip remote name (for example 'origin/')\r
+       int slashPlace = remoteBranchName.Find('/');\r
+       remoteName = remoteBranchName.Left(slashPlace);\r
+       remoteBranchName = remoteBranchName.Mid(slashPlace + 1); //Strip remote name (for example 'origin/')\r
 \r
 \r
-       m_BranchRemote.SetWindowText(remoteBranchName);\r
+       //Select remote\r
+       int remoteSel = m_Remote.FindStringExact(0,remoteName);\r
+       if(remoteSel >= 0)\r
+               m_Remote.SetCurSel(remoteSel);\r
+\r
+       //Select branch\r
+       m_BranchRemote.AddString(remoteBranchName);\r
 }\r
 }\r
index ce82cd1..9040a5f 100644 (file)
@@ -152,6 +152,8 @@ int CHistoryCombo::AddString(CString str, INT_PTR pos)
        {\r
                DeleteItem(nIndex);\r
                m_arEntries.RemoveAt(nIndex);\r
        {\r
                DeleteItem(nIndex);\r
                m_arEntries.RemoveAt(nIndex);\r
+               //nRet is now (potentially) invalid. Reset it.\r
+               nRet = FindStringExact(0, str);\r
        }\r
 \r
        //truncate list to m_nMaxHistoryItems\r
        }\r
 \r
        //truncate list to m_nMaxHistoryItems\r