OSDN Git Service

Fixed issue #150: When pushing, 'remote' should default to the tracked branch, or...
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / PushDlg.cpp
index fc606fe..22557d0 100644 (file)
@@ -80,6 +80,7 @@ BOOL CPushDlg::OnInitDialog()
     AddAnchor(IDC_PUTTYKEY_AUTOLOAD,TOP_LEFT);\r
 \r
     AddAnchor(IDC_REMOTE_MANAGE,TOP_RIGHT);\r
+       AddAnchor(IDHELP, BOTTOM_RIGHT);\r
 \r
        AddOthersToAnchor();\r
 \r
@@ -101,11 +102,51 @@ BOOL CPushDlg::OnInitDialog()
        m_RemoteURL.EnableWindow(FALSE);\r
        CheckRadioButton(IDC_RD_REMOTE,IDC_RD_URL,IDC_RD_REMOTE);\r
 \r
-       STRING_VECTOR list;\r
+\r
+       Refresh();\r
+\r
+\r
+       //m_BranchRemote.SetWindowTextW(m_BranchSource.GetString());\r
+\r
+       \r
+       return TRUE;\r
+}\r
+\r
+void CPushDlg::Refresh()\r
+{\r
+       CString WorkingDir=g_Git.m_CurrentDir;\r
+       WorkingDir.Replace(_T(':'),_T('_'));\r
+\r
        CRegString remote(CString(_T("Software\\TortoiseGit\\History\\PushRemote\\")+WorkingDir));\r
        m_RemoteReg = remote;\r
        int sel=0;\r
 \r
+       CString currentBranch = g_Git.GetSymbolicRef();\r
+       CString configName;\r
+\r
+       configName.Format(L"branch.%s.pushremote", currentBranch);\r
+       CString pushRemote = g_Git.GetConfigValue(configName);\r
+       if( pushRemote.IsEmpty() )\r
+       {\r
+               configName.Format(L"branch.%s.remote", currentBranch);\r
+               pushRemote = g_Git.GetConfigValue(configName);\r
+       }\r
+\r
+       if( !pushRemote.IsEmpty() )\r
+               remote=pushRemote;\r
+\r
+       //Select pull-branch from current branch\r
+       configName.Format(L"branch.%s.pushbranch", currentBranch);\r
+       CString pushBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));\r
+       if( pushBranch.IsEmpty() )\r
+       {\r
+               configName.Format(L"branch.%s.merge", currentBranch);\r
+               pushBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));              \r
+       }\r
+\r
+       STRING_VECTOR list;\r
+       m_Remote.Reset();\r
+\r
        if(!g_Git.GetRemoteList(list))\r
        {       \r
                for(unsigned int i=0;i<list.size();i++)\r
@@ -119,22 +160,24 @@ BOOL CPushDlg::OnInitDialog()
 \r
        int current=0;\r
        list.clear();\r
+       m_BranchSource.Reset();\r
        if(!g_Git.GetBranchList(list,&current))\r
        {\r
                for(unsigned int i=0;i<list.size();i++)\r
                        m_BranchSource.AddString(list[i]);\r
        }\r
        m_BranchSource.SetCurSel(current);\r
-       \r
-       m_BranchRemote.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\RemoteBranch\\"))+WorkingDir, _T("branch"));\r
-       m_BranchRemote.SetCurSel(0);\r
 \r
-       //m_BranchRemote.SetWindowTextW(m_BranchSource.GetString());\r
+       m_BranchRemote.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\RemoteBranch\\"))+WorkingDir, _T("branch"));\r
+       if( !pushBranch.IsEmpty() )\r
+       {\r
+               m_BranchRemote.AddString(pushBranch);\r
+               m_BranchRemote.SetCurSel(0);    \r
+       }\r
+       else\r
+               m_BranchRemote.SetCurSel(-1);\r
 \r
-       \r
-       return TRUE;\r
 }\r
-\r
 // CPushDlg message handlers\r
 \r
 void CPushDlg::OnBnClickedRd()\r
@@ -220,3 +263,20 @@ void CPushDlg::OnBnClickedButtonBrowseDestBranch()
        //Select branch\r
        m_BranchRemote.AddString(remoteBranchName);\r
 }\r
+\r
+BOOL CPushDlg::PreTranslateMessage(MSG* pMsg)\r
+{\r
+       if (pMsg->message == WM_KEYDOWN)\r
+       {\r
+               switch (pMsg->wParam)\r
+               {\r
+               case VK_F5:\r
+                       {\r
+                               Refresh();\r
+                       }\r
+                       break;\r
+               }\r
+       }\r
+\r
+       return CResizableStandAloneDialog::PreTranslateMessage(pMsg);\r
+}\r