From 1b4a44a48ef3788af9d0d7db82715039e25e0929 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Thu, 6 Oct 2011 22:55:12 +0200 Subject: [PATCH] allow to preselect local branch on push dialog Signed-off-by: Sven Strickroth --- src/TortoiseProc/AppUtils.cpp | 3 +- src/TortoiseProc/AppUtils.h | 2 +- src/TortoiseProc/Commands/PushCommand.cpp | 5 ++- src/TortoiseProc/PushDlg.cpp | 74 ++++++++++++++++++------------- src/TortoiseProc/PushDlg.h | 1 + 5 files changed, 52 insertions(+), 33 deletions(-) diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index d9dfaa2e0..a360db82b 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -2256,9 +2256,10 @@ bool CAppUtils::Fetch(CString remoteName, bool allowRebase, bool autoClose) return FALSE; } -bool CAppUtils::Push(bool autoClose) +bool CAppUtils::Push(CString selectLocalBranch, bool autoClose) { CPushDlg dlg; + dlg.m_BranchSourceName = selectLocalBranch; CString error; DWORD exitcode = 0xFFFFFFFF; CTGitPathList list; diff --git a/src/TortoiseProc/AppUtils.h b/src/TortoiseProc/AppUtils.h index c342757e0..5570132d9 100644 --- a/src/TortoiseProc/AppUtils.h +++ b/src/TortoiseProc/AppUtils.h @@ -209,7 +209,7 @@ public: static int GetLogOutputEncode(CGit *pGit=&g_Git); static bool Fetch(CString remoteName = _T(""), bool allowRebase = false, bool autoClose = false); - static bool Push(bool autoClose = false); + static bool Push(CString selectLocalBranch = CString(), bool autoClose = false); static bool RequestPull(CString endrevision = _T(""), CString repositoryUrl = _T("")); static bool CreateMultipleDirectory(const CString &dir); diff --git a/src/TortoiseProc/Commands/PushCommand.cpp b/src/TortoiseProc/Commands/PushCommand.cpp index 94b3c9e67..120b54954 100644 --- a/src/TortoiseProc/Commands/PushCommand.cpp +++ b/src/TortoiseProc/Commands/PushCommand.cpp @@ -34,5 +34,8 @@ bool PushCommand::Execute() bool autoCloseOnSuccess = false; if (parser.HasVal(_T("closeonend"))) autoCloseOnSuccess = !!parser.GetLongVal(_T("closeonend")); - return CAppUtils::Push(autoCloseOnSuccess); + CString branch; + if (parser.HasVal(_T("branch"))) + branch = parser.GetVal(_T("branch")); + return CAppUtils::Push(branch, autoCloseOnSuccess); } diff --git a/src/TortoiseProc/PushDlg.cpp b/src/TortoiseProc/PushDlg.cpp index 688afa7f0..2ef266040 100644 --- a/src/TortoiseProc/PushDlg.cpp +++ b/src/TortoiseProc/PushDlg.cpp @@ -158,29 +158,6 @@ void CPushDlg::Refresh() m_RemoteReg = remote; int sel=0; - CString currentBranch = g_Git.GetSymbolicRef(); - CString configName; - - configName.Format(L"branch.%s.pushremote", currentBranch); - CString pushRemote = g_Git.GetConfigValue(configName); - if( pushRemote.IsEmpty() ) - { - configName.Format(L"branch.%s.remote", currentBranch); - pushRemote = g_Git.GetConfigValue(configName); - } - - if( !pushRemote.IsEmpty() ) - remote=pushRemote; - - //Select pull-branch from current branch - configName.Format(L"branch.%s.pushbranch", currentBranch); - CString pushBranch = CGit::StripRefName(g_Git.GetConfigValue(configName)); - if( pushBranch.IsEmpty() ) - { - configName.Format(L"branch.%s.merge", currentBranch); - pushBranch = CGit::StripRefName(g_Git.GetConfigValue(configName)); - } - STRING_VECTOR list; m_Remote.Reset(); @@ -204,18 +181,55 @@ void CPushDlg::Refresh() for(unsigned int i=0;i