#include "PullFetchDlg.h"\r
#include "Git.h"\r
#include "AppUtils.h"\r
-\r
+#include "BrowseRefsDlg.h"\r
// CPullFetchDlg dialog\r
\r
IMPLEMENT_DYNAMIC(CPullFetchDlg, CResizableStandAloneDialog)\r
\r
CPullFetchDlg::CPullFetchDlg(CWnd* pParent /*=NULL*/)\r
- : CResizableStandAloneDialog(CPullFetchDlg::IDD, pParent)\r
+ : CResizableStandAloneDialog(CPullFetchDlg::IDD, pParent),\r
+ m_bRebase(false)\r
{\r
m_IsPull=TRUE;\r
m_bAutoLoad = CAppUtils::IsSSHPutty();\r
DDX_Control(pDX, IDC_REMOTE_BRANCH, this->m_RemoteBranch);\r
DDX_Control(pDX,IDC_REMOTE_MANAGE, this->m_RemoteManage);\r
DDX_Check(pDX,IDC_PUTTYKEY_AUTOLOAD,m_bAutoLoad);\r
+ DDX_Check(pDX,IDC_CHECK_REBASE,m_bRebase);\r
\r
}\r
\r
ON_BN_CLICKED(IDC_OTHER_RD, &CPullFetchDlg::OnBnClickedRd)\r
ON_BN_CLICKED(IDOK, &CPullFetchDlg::OnBnClickedOk)\r
ON_STN_CLICKED(IDC_REMOTE_MANAGE, &CPullFetchDlg::OnStnClickedRemoteManage)\r
+ ON_BN_CLICKED(IDC_BUTTON_BROWSE_REF, &CPullFetchDlg::OnBnClickedButtonBrowseRef)\r
END_MESSAGE_MAP()\r
\r
BOOL CPullFetchDlg::OnInitDialog()\r
AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
AddAnchor(IDC_GROUPT_REMOTE,TOP_LEFT,BOTTOM_RIGHT);\r
AddAnchor(IDC_PUTTYKEY_AUTOLOAD,BOTTOM_LEFT);\r
+ AddAnchor(IDC_CHECK_REBASE,BOTTOM_LEFT);\r
AddAnchor(IDC_REMOTE_MANAGE,BOTTOM_LEFT);\r
AddAnchor(IDHELP, BOTTOM_RIGHT);\r
\r
CheckRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD,IDC_REMOTE_RD);\r
m_Remote.EnableWindow(TRUE);\r
m_Other.EnableWindow(FALSE);\r
- m_RemoteBranch.EnableWindow(FALSE);\r
+ if(!m_IsPull)\r
+ m_RemoteBranch.EnableWindow(FALSE);\r
+\r
+// if(!m_IsPull)\r
+ //Todo: implement rebase option sometime with rebase dialog\r
+ GetDlgItem(IDC_CHECK_REBASE)->ShowWindow(SW_HIDE);\r
\r
m_Other.SetURLHistory(TRUE);\r
m_Other.LoadHistory(_T("Software\\TortoiseGit\\History\\PullURLS"), _T("url"));\r
m_RemoteReg = remote;\r
int sel=0;\r
\r
+ //Select pull-remote from current branch\r
+ CString currentBranch = g_Git.GetSymbolicRef();\r
+ CString configName;\r
+ configName.Format(L"branch.%s.remote", currentBranch);\r
+ CString pullRemote = g_Git.GetConfigValue(configName);\r
+\r
+ //Select pull-branch from current branch\r
+ configName.Format(L"branch.%s.merge", currentBranch);\r
+ CString pullBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));\r
+ m_RemoteBranch.AddString(pullBranch);\r
+\r
+ if(pullRemote.IsEmpty())\r
+ pullRemote = remote;\r
+\r
if(!g_Git.GetRemoteList(list))\r
{ \r
for(unsigned int i=0;i<list.size();i++)\r
{\r
m_Remote.AddString(list[i]);\r
- if(list[i] == remote)\r
+ if(list[i] == pullRemote)\r
sel = i;\r
}\r
}\r
{\r
m_Remote.EnableWindow(TRUE);\r
m_Other.EnableWindow(FALSE);\r
- m_RemoteBranch.EnableWindow(FALSE);\r
-\r
+ if(!m_IsPull)\r
+ m_RemoteBranch.EnableWindow(FALSE);\r
}\r
if( GetCheckedRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD) == IDC_OTHER_RD)\r
{\r
m_Remote.EnableWindow(FALSE);\r
m_Other.EnableWindow(TRUE);;\r
- m_RemoteBranch.EnableWindow(TRUE);\r
+ if(!m_IsPull)\r
+ m_RemoteBranch.EnableWindow(TRUE);\r
}\r
\r
\r
if( GetCheckedRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD) == IDC_REMOTE_RD)\r
{\r
m_RemoteURL=m_Remote.GetString();\r
- m_RemoteBranchName.Empty();\r
+ if(!m_IsPull)\r
+ m_RemoteBranchName.Empty();\r
+ else\r
+ m_RemoteBranchName=m_RemoteBranch.GetString();\r
\r
}\r
if( GetCheckedRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD) == IDC_OTHER_RD)\r
// TODO: Add your control notification handler code here\r
CAppUtils::LaunchRemoteSetting();\r
}\r
+\r
+void CPullFetchDlg::OnBnClickedButtonBrowseRef()\r
+{\r
+ CString initialRef;\r
+ initialRef.Format(L"refs/remotes/%s/%s", m_Remote.GetString(), m_RemoteBranch.GetString());\r
+ CString selectedRef = CBrowseRefsDlg::PickRef(false, initialRef, gPickRef_Remote);\r
+ if(selectedRef.Left(13) != "refs/remotes/")\r
+ return;\r
+\r
+ selectedRef = selectedRef.Mid(13);\r
+ int ixSlash = selectedRef.Find('/');\r
+\r
+ CString remoteName = selectedRef.Left(ixSlash);\r
+ CString remoteBranch = selectedRef.Mid(ixSlash + 1);\r
+ \r
+ int ixFound = m_Remote.FindStringExact(0, remoteName);\r
+ if(ixFound >= 0)\r
+ m_Remote.SetCurSel(ixFound);\r
+ m_RemoteBranch.AddString(remoteBranch);\r
+\r
+ CheckRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD,IDC_REMOTE_RD);\r
+}\r