return dlg.m_pickedRef;\r
}\r
\r
+bool CBrowseRefsDlg::PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind)\r
+{\r
+ CString origRef;\r
+ pComboBox->GetLBText(pComboBox->GetCurSel(), origRef);\r
+ CString resultRef = PickRef(false,origRef,pickRef_Kind);\r
+ if(resultRef.IsEmpty())\r
+ return false;\r
+ if(wcsncmp(resultRef,L"refs/",5)==0)\r
+ resultRef = resultRef.Mid(5);\r
+// if(wcsncmp(resultRef,L"heads/",6)==0)\r
+// resultRef = resultRef.Mid(6);\r
+\r
+ //Find closest match of choice in combobox\r
+ int ixFound = -1;\r
+ int matchLength = 0;\r
+ CString comboRefName;\r
+ for(int i = 0; i < pComboBox->GetCount(); ++i)\r
+ {\r
+ pComboBox->GetLBText(i, comboRefName);\r
+ if(matchLength < comboRefName.GetLength() && resultRef.Right(comboRefName.GetLength()) == comboRefName)\r
+ {\r
+ matchLength = comboRefName.GetLength();\r
+ ixFound = i;\r
+ }\r
+ }\r
+ if(ixFound >= 0)\r
+ pComboBox->SetCurSel(ixFound);\r
+ else\r
+ ASSERT(FALSE);//No match found. So either pickRef_Kind is wrong or the combobox does not contain the ref specified in the picker (which it should unless the repo has changed before creating the CBrowseRef dialog)\r
+\r
+ return true;\r
+}\r
CString m_pickedRef;\r
\r
static CString PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All); \r
+ static bool PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All); \r
};\r
#include "Git.h"\r
#include "registry.h"\r
#include "AppUtils.h"\r
+#include "BrowseRefsDlg.h"\r
\r
// CPushDlg dialog\r
\r
ON_CBN_SELCHANGE(IDC_BRANCH_SOURCE, &CPushDlg::OnCbnSelchangeBranchSource)\r
ON_BN_CLICKED(IDOK, &CPushDlg::OnBnClickedOk)\r
ON_BN_CLICKED(IDC_REMOTE_MANAGE, &CPushDlg::OnBnClickedRemoteManage)\r
+ ON_BN_CLICKED(IDC_BUTTON_BROWSE_SOURCE_BRANCH, &CPushDlg::OnBnClickedButtonBrowseSourceBranch)\r
+ ON_BN_CLICKED(IDC_BUTTON_BROWSE_DEST_BRANCH, &CPushDlg::OnBnClickedButtonBrowseDestBranch)\r
END_MESSAGE_MAP()\r
\r
BOOL CPushDlg::OnInitDialog()\r
AddAnchor(IDC_STATIC_SOURCE, TOP_LEFT);\r
\r
AddAnchor(IDC_BRANCH_REMOTE, TOP_RIGHT);\r
+ AddAnchor(IDC_BUTTON_BROWSE_DEST_BRANCH, TOP_RIGHT);\r
AddAnchor(IDC_BRANCH_SOURCE, TOP_LEFT);\r
+ AddAnchor(IDC_BUTTON_BROWSE_SOURCE_BRANCH, TOP_LEFT);\r
\r
AddAnchor(IDC_URL_GROUP, TOP_LEFT,TOP_RIGHT);\r
AddAnchor(IDC_RD_REMOTE, TOP_LEFT);\r
// TODO: Add your control notification handler code here\r
CAppUtils::LaunchRemoteSetting();\r
}\r
+\r
+void CPushDlg::OnBnClickedButtonBrowseSourceBranch()\r
+{\r
+ if(CBrowseRefsDlg::PickRefForCombo(&m_BranchSource, gPickRef_Head))\r
+ OnCbnSelchangeBranchSource();\r
+}\r
+\r
+void CPushDlg::OnBnClickedButtonBrowseDestBranch()\r
+{\r
+ CString remoteBranchName;\r
+ m_BranchRemote.GetWindowText(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 = remoteBranchName.Mid(remoteBranchName.Find('/') + 1); //Strip remote name (for example 'origin/')\r
+\r
+ m_BranchRemote.SetWindowText(remoteBranchName);\r
+}\r
afx_msg void OnCbnSelchangeBranchSource();\r
afx_msg void OnBnClickedOk();\r
afx_msg void OnBnClickedRemoteManage();\r
+ afx_msg void OnBnClickedButtonBrowseSourceBranch();\r
+ afx_msg void OnBnClickedButtonBrowseDestBranch();\r
};\r
\r
void CRebaseDlg::OnBnClickedButtonBrowse()\r
{\r
- CString origRef;\r
- m_UpstreamCtrl.GetLBText(m_UpstreamCtrl.GetCurSel(), origRef);\r
- CString resultRef = CBrowseRefsDlg::PickRef(false,origRef,gPickRef_NoTag);\r
- if(resultRef.IsEmpty())\r
- return;\r
- if(wcsncmp(resultRef,L"refs/",5)==0)\r
- resultRef = resultRef.Mid(5);\r
- if(wcsncmp(resultRef,L"heads/",6)==0)\r
- resultRef = resultRef.Mid(6);\r
- m_UpstreamCtrl.SetCurSel(m_UpstreamCtrl.FindStringExact(0,resultRef));\r
-\r
+ CBrowseRefsDlg::PickRefForCombo(&m_UpstreamCtrl, gPickRef_NoTag);\r
}\r