No need for an extra lookup for HEAD
[TortoiseGit.git] / src / TortoiseProc / PushDlg.cpp
blobd6c4938808ec9f80e49aafb45e89b3c0744d6cc1
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // PushDlg.cpp : implementation file
23 #include "stdafx.h"
24 #include "TortoiseProc.h"
25 #include "PushDlg.h"
27 #include "Git.h"
28 #include "registry.h"
29 #include "AppUtils.h"
30 #include "LogDlg.h"
31 #include "BrowseRefsDlg.h"
32 #include "RefLogDlg.h"
33 #include "MessageBox.h"
35 // CPushDlg dialog
37 IMPLEMENT_DYNAMIC(CPushDlg, CHorizontalResizableStandAloneDialog)
39 CPushDlg::CPushDlg(CWnd* pParent /*=NULL*/)
40 : CHorizontalResizableStandAloneDialog(CPushDlg::IDD, pParent)
41 , m_bPushAllBranches(FALSE)
42 , m_bForce(FALSE)
43 , m_bPack(FALSE)
44 , m_bTags(FALSE)
45 , m_bAutoLoad(FALSE)
46 , m_bPushAllRemotes(FALSE)
47 , m_bSetPushBranch(FALSE)
48 , m_bSetPushRemote(FALSE)
49 , m_bSetUpstream(FALSE)
50 , m_RecurseSubmodules(0)
52 m_bAutoLoad = CAppUtils::IsSSHPutty();
55 CPushDlg::~CPushDlg()
59 void CPushDlg::DoDataExchange(CDataExchange* pDX)
61 CHorizontalResizableStandAloneDialog::DoDataExchange(pDX);
62 DDX_Control(pDX, IDC_BRANCH_REMOTE, this->m_BranchRemote);
63 DDX_Control(pDX, IDC_BRANCH_SOURCE, this->m_BranchSource);
64 DDX_Control(pDX, IDC_REMOTE, this->m_Remote);
65 DDX_Control(pDX, IDC_URL, this->m_RemoteURL);
66 DDX_Control(pDX, IDC_BUTTON_BROWSE_SOURCE_BRANCH, m_BrowseLocalRef);
67 DDX_Control(pDX, IDC_COMBOBOX_RECURSE_SUBMODULES, m_RecurseSubmodulesCombo);
68 DDX_Check(pDX,IDC_FORCE,this->m_bForce);
69 DDX_Check(pDX,IDC_PUSHALL,this->m_bPushAllBranches);
70 DDX_Check(pDX,IDC_PACK,this->m_bPack);
71 DDX_Check(pDX,IDC_TAGS,this->m_bTags);
72 DDX_Check(pDX,IDC_PUTTYKEY_AUTOLOAD,this->m_bAutoLoad);
73 DDX_Check(pDX, IDC_PROC_PUSH_SET_PUSHREMOTE, m_bSetPushRemote);
74 DDX_Check(pDX, IDC_PROC_PUSH_SET_PUSHBRANCH, m_bSetPushBranch);
75 DDX_Check(pDX, IDC_PROC_PUSH_SET_UPSTREAM, m_bSetUpstream);
78 BEGIN_MESSAGE_MAP(CPushDlg, CHorizontalResizableStandAloneDialog)
79 ON_BN_CLICKED(IDC_RD_REMOTE, &CPushDlg::OnBnClickedRd)
80 ON_BN_CLICKED(IDC_RD_URL, &CPushDlg::OnBnClickedRd)
81 ON_CBN_SELCHANGE(IDC_BRANCH_SOURCE, &CPushDlg::OnCbnSelchangeBranchSource)
82 ON_CBN_SELCHANGE(IDC_REMOTE, &CPushDlg::EnDisablePushRemoteArchiveBranch)
83 ON_BN_CLICKED(IDOK, &CPushDlg::OnBnClickedOk)
84 ON_BN_CLICKED(IDC_REMOTE_MANAGE, &CPushDlg::OnBnClickedRemoteManage)
85 ON_BN_CLICKED(IDC_BUTTON_BROWSE_SOURCE_BRANCH, &CPushDlg::OnBnClickedButtonBrowseSourceBranch)
86 ON_BN_CLICKED(IDC_BUTTON_BROWSE_DEST_BRANCH, &CPushDlg::OnBnClickedButtonBrowseDestBranch)
87 ON_BN_CLICKED(IDC_PUSHALL, &CPushDlg::OnBnClickedPushall)
88 ON_BN_CLICKED(IDC_PROC_PUSH_SET_UPSTREAM, &CPushDlg::OnBnClickedProcPushSetUpstream)
89 ON_BN_CLICKED(IDC_PROC_PUSH_SET_PUSHREMOTE, &CPushDlg::OnBnClickedProcPushSetPushremote)
90 ON_BN_CLICKED(IDC_PROC_PUSH_SET_PUSHBRANCH, &CPushDlg::OnBnClickedProcPushSetPushremote)
91 END_MESSAGE_MAP()
93 BOOL CPushDlg::OnInitDialog()
95 CHorizontalResizableStandAloneDialog::OnInitDialog();
96 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
98 AddAnchor(IDOK,BOTTOM_RIGHT);
99 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
100 AddAnchor(IDC_BRANCH_GROUP, TOP_LEFT,TOP_RIGHT);
101 AddAnchor(IDC_STATIC_REMOTE, TOP_LEFT);
102 AddAnchor(IDC_STATIC_SOURCE, TOP_LEFT);
104 AddAnchor(IDC_PUSHALL, TOP_LEFT);
105 AddAnchor(IDC_BRANCH_REMOTE, TOP_LEFT, TOP_RIGHT);
106 AddAnchor(IDC_BUTTON_BROWSE_DEST_BRANCH, TOP_RIGHT);
107 AddAnchor(IDC_BRANCH_SOURCE, TOP_LEFT, TOP_RIGHT);
108 AddAnchor(IDC_BUTTON_BROWSE_SOURCE_BRANCH, TOP_RIGHT);
110 AddAnchor(IDC_URL_GROUP, TOP_LEFT,TOP_RIGHT);
111 AddAnchor(IDC_RD_REMOTE, TOP_LEFT);
112 AddAnchor(IDC_RD_URL, TOP_LEFT);
114 AddAnchor(IDC_REMOTE, TOP_LEFT, TOP_RIGHT);
116 AddAnchor(IDC_URL, TOP_LEFT,TOP_RIGHT);
118 AddAnchor(IDC_OPTION_GROUP, TOP_LEFT,TOP_RIGHT);
120 AddAnchor(IDC_FORCE, TOP_LEFT);
121 AddAnchor(IDC_PACK, TOP_LEFT);
122 AddAnchor(IDC_TAGS, TOP_LEFT);
123 AddAnchor(IDC_PUTTYKEY_AUTOLOAD,TOP_LEFT);
124 AddAnchor(IDC_PROC_PUSH_SET_PUSHBRANCH, TOP_LEFT);
125 AddAnchor(IDC_PROC_PUSH_SET_PUSHREMOTE, TOP_LEFT);
126 AddAnchor(IDC_PROC_PUSH_SET_UPSTREAM, TOP_LEFT);
127 AddAnchor(IDC_STATIC_RECURSE_SUBMODULES, TOP_LEFT);
128 AddAnchor(IDC_COMBOBOX_RECURSE_SUBMODULES, TOP_LEFT);
130 AddAnchor(IDC_REMOTE_MANAGE,TOP_RIGHT);
131 AddAnchor(IDHELP, BOTTOM_RIGHT);
133 AddOthersToAnchor();
135 AdjustControlSize(IDC_RD_REMOTE);
136 AdjustControlSize(IDC_RD_URL);
137 AdjustControlSize(IDC_PUSHALL);
138 AdjustControlSize(IDC_FORCE);
139 AdjustControlSize(IDC_PACK);
140 AdjustControlSize(IDC_TAGS);
141 AdjustControlSize(IDC_PUTTYKEY_AUTOLOAD);
142 AdjustControlSize(IDC_PROC_PUSH_SET_PUSHBRANCH);
143 AdjustControlSize(IDC_PROC_PUSH_SET_PUSHREMOTE);
144 AdjustControlSize(IDC_PROC_PUSH_SET_UPSTREAM);
145 AdjustControlSize(IDC_STATIC_RECURSE_SUBMODULES);
147 CString sWindowTitle;
148 GetWindowText(sWindowTitle);
149 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
151 this->GetDlgItem(IDC_PUTTYKEY_AUTOLOAD)->EnableWindow(CAppUtils::IsSSHPutty());
153 EnableSaveRestore(_T("PushDlg"));
155 m_RemoteURL.SetCaseSensitive(TRUE);
156 m_RemoteURL.SetURLHistory(TRUE);
158 CString WorkingDir=g_Git.m_CurrentDir;
159 WorkingDir.Replace(_T(':'),_T('_'));
160 m_regPushAllRemotes = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Push\\") + WorkingDir + _T("\\AllRemotes"), FALSE);
161 m_bPushAllRemotes = m_regPushAllRemotes;
162 m_regPushAllBranches = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Push\\") + WorkingDir + _T("\\AllBranches"), FALSE);
163 m_bPushAllBranches = m_regPushAllBranches;
164 m_RemoteURL.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\PushURLS\\"))+WorkingDir, _T("url"));
165 m_RemoteURL.EnableWindow(FALSE);
166 CheckRadioButton(IDC_RD_REMOTE,IDC_RD_URL,IDC_RD_REMOTE);
169 m_regThinPack = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Push\\") + WorkingDir + _T("\\ThinPack"), FALSE);
170 m_bPack = m_regThinPack;
171 this->m_regAutoLoad = CRegDWORD(CString(_T("Software\\TortoiseGit\\History\\PushDlgAutoLoad\\"))+WorkingDir,
172 m_bAutoLoad);
173 m_bAutoLoad = this->m_regAutoLoad;
174 if(!CAppUtils::IsSSHPutty())
175 m_bAutoLoad = false;
177 m_BrowseLocalRef.m_bRightArrow = TRUE;
178 m_BrowseLocalRef.m_bDefaultClick = FALSE;
179 m_BrowseLocalRef.m_bMarkDefault = FALSE;
180 m_BrowseLocalRef.AddEntry(CString(MAKEINTRESOURCE(IDS_REFBROWSE)));
181 m_BrowseLocalRef.AddEntry(CString(MAKEINTRESOURCE(IDS_LOG)));
182 m_BrowseLocalRef.AddEntry(CString(MAKEINTRESOURCE(IDS_REFLOG)));
184 m_tooltips.Create(this);
185 m_tooltips.AddTool(IDC_PROC_PUSH_SET_PUSHBRANCH, IDS_PUSHDLG_PUSHBRANCH_TT);
186 m_tooltips.AddTool(IDC_PROC_PUSH_SET_PUSHREMOTE, IDS_PUSHDLG_PUSHREMOTE_TT);
188 m_regRecurseSubmodules = CRegDWORD(
189 CString(_T("Software\\TortoiseGit\\History\\PushRecurseSubmodules\\")) + WorkingDir, m_RecurseSubmodules);
190 m_RecurseSubmodules = m_regRecurseSubmodules;
191 m_RecurseSubmodulesCombo.AddString(CString(MAKEINTRESOURCE(IDS_NONE)));
192 m_RecurseSubmodulesCombo.AddString(CString(MAKEINTRESOURCE(IDS_RECURSE_SUBMODULES_CHECK)));
193 m_RecurseSubmodulesCombo.AddString(CString(MAKEINTRESOURCE(IDS_RECURSE_SUBMODULES_ONDEMAND)));
194 m_RecurseSubmodulesCombo.SetCurSel(m_RecurseSubmodules);
196 Refresh();
198 this->UpdateData(false);
200 OnBnClickedPushall();
201 return TRUE;
204 void CPushDlg::Refresh()
206 CString WorkingDir=g_Git.m_CurrentDir;
207 WorkingDir.Replace(_T(':'),_T('_'));
209 CRegString remote(CString(_T("Software\\TortoiseGit\\History\\PushRemote\\")+WorkingDir));
210 m_RemoteReg = remote;
211 int sel = -1;
213 STRING_VECTOR list;
214 m_Remote.Reset();
216 list.push_back(CString(MAKEINTRESOURCE(IDS_PROC_PUSHFETCH_ALLREMOTES)));
217 if(!g_Git.GetRemoteList(list))
219 if (list.size() <= 2)
220 list.erase(list.begin());
222 for (unsigned int i = 0; i < list.size(); ++i)
224 m_Remote.AddString(list[i]);
225 if(list[i] == remote)
226 sel = i;
229 // if the last selected remote was "- All -" and "- All -" is still in the list -> select it
230 if (list.size() > 1 && remote == CString(MAKEINTRESOURCE(IDS_PROC_PUSHFETCH_ALLREMOTES)))
231 sel = 0;
232 m_Remote.SetCurSel(sel);
234 int current=0;
235 list.clear();
236 m_BranchSource.Reset();
237 m_BranchSource.AddString(_T(" ")); // empty string does not work, for removal of remote branches/tags
238 m_BranchSource.SetMaxHistoryItems(0x7FFFFFFF);
239 if(!g_Git.GetBranchList(list,&current))
241 for (unsigned int i = 0; i < list.size(); ++i)
242 m_BranchSource.AddString(list[i]);
243 ++current; // shift for " "
245 if (wcsncmp(m_BranchSourceName, _T("refs/"), 5) == 0)
246 m_BranchSourceName = m_BranchSourceName.Mid(5);
247 if (wcsncmp(m_BranchSourceName, _T("heads/"), 6) == 0)
249 m_BranchSourceName = m_BranchSourceName.Mid(6);
250 m_BranchSource.SetCurSel(m_BranchSource.FindStringExact(-1, m_BranchSourceName));
252 else if (wcsncmp(m_BranchSourceName, _T("remotes/"), 8) == 0)
253 m_BranchSource.SetCurSel(m_BranchSource.FindStringExact(-1, m_BranchSourceName));
254 else
255 m_BranchSource.SetCurSel(current);
257 GetRemoteBranch(m_BranchSource.GetString());
259 this->GetDlgItem(IDOK)->EnableWindow(m_BranchSource.GetCount() != 0);
261 if (list.size() > 1 && m_bPushAllRemotes)
262 m_Remote.SetCurSel(0);
263 m_bPushAllRemotes = FALSE; // reset to FALSE, so that a refresh does not reselect all even if it was already deselected by user; correct value will be set in OnBnClickedOk method
266 void CPushDlg::GetRemoteBranch(CString currentBranch)
268 CString WorkingDir=g_Git.m_CurrentDir;
269 WorkingDir.Replace(_T(':'), _T('_'));
271 if (currentBranch.IsEmpty())
273 EnDisablePushRemoteArchiveBranch();
274 return;
277 CString configName;
279 configName.Format(L"branch.%s.pushremote", currentBranch);
280 CString pushRemote = g_Git.GetConfigValue(configName);
281 if( pushRemote.IsEmpty() )
283 pushRemote = g_Git.GetConfigValue(L"remote.pushdefault");
284 if (pushRemote.IsEmpty())
286 configName.Format(L"branch.%s.remote", currentBranch);
287 pushRemote = g_Git.GetConfigValue(configName);
291 CRegString remote(CString(_T("Software\\TortoiseGit\\History\\PushRemote\\")+WorkingDir));
293 if (!pushRemote.IsEmpty())
295 remote = pushRemote;
296 // if a pushRemote exists, select it
297 for (int i = 0; i < m_Remote.GetCount(); ++i)
299 CString str;
300 int n = m_Remote.GetLBTextLen(i);
301 m_Remote.GetLBText(i, str.GetBuffer(n));
302 str.ReleaseBuffer();
303 if (str == pushRemote)
305 m_Remote.SetCurSel(i);
306 break;
310 // select the only remote if only one exists
311 else if (m_Remote.GetCount() == 1)
312 m_Remote.SetCurSel(0);
313 // select no remote if no push-remote is specified AND push to all remotes is not selected
314 else if (!(m_Remote.GetCount() > 1 && m_Remote.GetCurSel() == 0))
316 m_Remote.SetCurSel(-1);
319 //Select pull-branch from current branch
320 configName.Format(L"branch.%s.pushbranch", currentBranch);
321 CString pushBranch = g_Git.GetConfigValue(configName); // do not strip branch name (for gerrit), see issue #1609)
322 if( pushBranch.IsEmpty() )
324 configName.Format(L"branch.%s.merge", currentBranch);
325 pushBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));
328 m_BranchRemote.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\RemoteBranch\\"))+WorkingDir, _T("branch"));
329 if( !pushBranch.IsEmpty() )
330 m_BranchRemote.AddString(pushBranch);
332 EnDisablePushRemoteArchiveBranch();
335 void CPushDlg::EnDisablePushRemoteArchiveBranch()
337 if ((m_Remote.GetCount() > 1 && m_Remote.GetCurSel() == 0) || m_bPushAllBranches || GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_URL || m_BranchSource.GetString().Trim().IsEmpty())
339 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHBRANCH, FALSE);
340 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHREMOTE, FALSE);
341 bool enableUpstream = (GetCheckedRadioButton(IDC_RD_REMOTE, IDC_RD_URL) != IDC_RD_URL && (!m_BranchSource.GetString().Trim().IsEmpty() || m_bPushAllBranches));
342 DialogEnableWindow(IDC_PROC_PUSH_SET_UPSTREAM, enableUpstream);
343 if (m_bSetUpstream && !enableUpstream)
344 m_bSetUpstream = FALSE;
345 m_bSetPushRemote = FALSE;
346 m_bSetPushBranch = FALSE;
347 UpdateData(FALSE);
349 else
351 DialogEnableWindow(IDC_PROC_PUSH_SET_UPSTREAM, TRUE);
352 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHBRANCH, !m_bSetUpstream);
353 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHREMOTE, !m_bSetUpstream);
357 // CPushDlg message handlers
359 void CPushDlg::OnBnClickedRd()
361 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_REMOTE)
363 m_Remote.EnableWindow(TRUE);
364 GetDlgItem(IDC_REMOTE_MANAGE)->EnableWindow(TRUE);
365 m_RemoteURL.EnableWindow(FALSE);
367 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_URL)
369 CString clippath = CAppUtils::GetClipboardLink();
370 if (clippath.IsEmpty())
371 m_RemoteURL.SetCurSel(0);
372 else
373 m_RemoteURL.SetWindowText(clippath);
374 m_Remote.EnableWindow(FALSE);
375 GetDlgItem(IDC_REMOTE_MANAGE)->EnableWindow(FALSE);
376 m_RemoteURL.EnableWindow(TRUE);
378 EnDisablePushRemoteArchiveBranch();
382 void CPushDlg::OnCbnSelchangeBranchSource()
384 GetRemoteBranch(m_BranchSource.GetString());
387 void CPushDlg::OnBnClickedOk()
389 CHorizontalResizableStandAloneDialog::UpdateData(TRUE);
391 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_REMOTE)
393 m_URL=m_Remote.GetString();
394 if (m_URL.IsEmpty())
396 CMessageBox::Show(NULL, IDS_PROC_GITCONFIG_REMOTEEMPTY, IDS_APPNAME, MB_OK);
397 return;
399 m_bPushAllRemotes = (m_Remote.GetCurSel() == 0 && m_Remote.GetCount() > 1);
401 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_URL)
403 m_URL=m_RemoteURL.GetString();
406 if (!m_bPushAllBranches)
408 this->m_BranchRemoteName=m_BranchRemote.GetString().Trim();
409 this->m_BranchSourceName=m_BranchSource.GetString().Trim();
411 if (m_BranchSourceName.IsEmpty() && m_BranchRemoteName.IsEmpty())
413 if (CMessageBox::Show(NULL, IDS_B_T_BOTHEMPTY, IDS_APPNAME, MB_ICONQUESTION | MB_YESNO) == IDNO)
414 return;
416 if (m_BranchSourceName.IsEmpty() && !m_BranchRemoteName.IsEmpty())
418 if (CMessageBox::Show(NULL, IDS_B_T_LOCALEMPTY, IDS_APPNAME, MB_ICONEXCLAMATION | MB_YESNO) == IDNO)
419 return;
421 else if (!m_BranchRemoteName.IsEmpty() && !g_Git.IsBranchNameValid(this->m_BranchRemoteName))
423 CMessageBox::Show(NULL, IDS_B_T_INVALID, IDS_APPNAME, MB_OK);
424 return;
426 else if (!m_BranchSourceName.IsEmpty() && !g_Git.IsBranchTagNameUnique(m_BranchSourceName))
428 CMessageBox::Show(NULL, IDS_B_T_NOT_UNIQUE, IDS_APPNAME, MB_OK | MB_ICONEXCLAMATION);
429 return;
431 else
433 // do not store branch names on removal
434 if (m_RemoteURL.IsWindowEnabled())
435 m_RemoteURL.SaveHistory(); // do not store Remote URLs if not used
436 this->m_BranchRemote.SaveHistory();
437 m_RemoteReg = m_Remote.GetString();
439 if (!m_BranchSourceName.IsEmpty())
441 CString configName;
442 if (m_bSetPushBranch)
444 configName.Format(L"branch.%s.pushbranch", m_BranchSourceName);
445 if (!m_BranchRemoteName.IsEmpty())
446 g_Git.SetConfigValue(configName, m_BranchRemoteName);
447 else
448 g_Git.UnsetConfigValue(configName);
450 if (m_bSetPushRemote)
452 configName.Format(L"branch.%s.pushremote", m_BranchSourceName);
453 if (!m_URL.IsEmpty())
454 g_Git.SetConfigValue(configName, m_URL);
455 else
456 g_Git.UnsetConfigValue(configName);
462 m_regPushAllBranches = m_bPushAllBranches;
463 m_regPushAllRemotes = m_bPushAllRemotes;
464 m_regThinPack = m_bPack;
465 this->m_regAutoLoad = m_bAutoLoad ;
466 m_RecurseSubmodules = m_RecurseSubmodulesCombo.GetCurSel();
467 if (m_RecurseSubmodules == 2 && CAppUtils::GetMsysgitVersion() < 0x01070b00)
469 CString gitver;
470 gitver.Format(IDS_GITVER_REQUIRED, _T("--recurse-submodules=on-demand"), _T("1.7.11"));
471 CMessageBox::Show(m_hWnd, gitver, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
472 return;
474 m_regRecurseSubmodules = m_RecurseSubmodules;
476 CHorizontalResizableStandAloneDialog::OnOK();
479 void CPushDlg::OnBnClickedRemoteManage()
481 CAppUtils::LaunchRemoteSetting();
482 Refresh();
485 void CPushDlg::OnBnClickedButtonBrowseSourceBranch()
487 switch (m_BrowseLocalRef.GetCurrentEntry())
489 case 0: /* Browse Refence*/
491 if(CBrowseRefsDlg::PickRefForCombo(&m_BranchSource, gPickRef_Head))
492 OnCbnSelchangeBranchSource();
494 break;
496 case 1: /* Log */
498 CLogDlg dlg;
499 dlg.SetSelect(true);
500 if(dlg.DoModal() == IDOK)
502 if (dlg.GetSelectedHash().IsEmpty())
503 return;
505 m_BranchSource.SetWindowText(dlg.GetSelectedHash());
506 OnCbnSelchangeBranchSource();
509 break;
511 case 2: /*RefLog*/
513 CRefLogDlg dlg;
514 if(dlg.DoModal() == IDOK)
516 m_BranchSource.SetWindowText(dlg.m_SelectedHash);
517 OnCbnSelchangeBranchSource();
520 break;
524 void CPushDlg::OnBnClickedButtonBrowseDestBranch()
526 CString remoteBranchName;
527 CString remoteName;
528 m_BranchRemote.GetWindowText(remoteBranchName);
529 remoteName = m_Remote.GetString();
530 remoteBranchName = remoteName + '/' + remoteBranchName;
531 remoteBranchName = CBrowseRefsDlg::PickRef(false, remoteBranchName, gPickRef_Remote);
532 if(remoteBranchName.IsEmpty())
533 return; //Canceled
534 remoteBranchName = remoteBranchName.Mid(13);//Strip 'refs/remotes/'
535 int slashPlace = remoteBranchName.Find('/');
536 remoteName = remoteBranchName.Left(slashPlace);
537 remoteBranchName = remoteBranchName.Mid(slashPlace + 1); //Strip remote name (for example 'origin/')
539 //Select remote
540 int remoteSel = m_Remote.FindStringExact(0,remoteName);
541 if(remoteSel >= 0)
542 m_Remote.SetCurSel(remoteSel);
544 //Select branch
545 m_BranchRemote.AddString(remoteBranchName, 0);
548 BOOL CPushDlg::PreTranslateMessage(MSG* pMsg)
550 m_tooltips.RelayEvent(pMsg);
552 if (pMsg->message == WM_KEYDOWN)
554 switch (pMsg->wParam)
556 case VK_F5:
558 Refresh();
560 break;
564 return CHorizontalResizableStandAloneDialog::PreTranslateMessage(pMsg);
567 void CPushDlg::OnBnClickedPushall()
569 this->UpdateData();
570 this->GetDlgItem(IDC_BRANCH_REMOTE)->EnableWindow(!m_bPushAllBranches);
571 this->GetDlgItem(IDC_BRANCH_SOURCE)->EnableWindow(!m_bPushAllBranches);
572 this->GetDlgItem(IDC_BUTTON_BROWSE_SOURCE_BRANCH)->EnableWindow(!m_bPushAllBranches);
573 this->GetDlgItem(IDC_BUTTON_BROWSE_DEST_BRANCH)->EnableWindow(!m_bPushAllBranches);
574 EnDisablePushRemoteArchiveBranch();
577 void CPushDlg::OnBnClickedProcPushSetUpstream()
579 UpdateData();
580 this->GetDlgItem(IDC_PROC_PUSH_SET_PUSHREMOTE)->EnableWindow(!m_bSetUpstream);
581 this->GetDlgItem(IDC_PROC_PUSH_SET_PUSHBRANCH)->EnableWindow(!m_bSetUpstream);
582 m_bSetPushBranch = FALSE;
583 m_bSetPushRemote = FALSE;
584 UpdateData(FALSE);
587 void CPushDlg::OnBnClickedProcPushSetPushremote()
589 UpdateData();
590 this->GetDlgItem(IDC_PROC_PUSH_SET_UPSTREAM)->EnableWindow(!(m_bSetPushBranch || m_bSetPushRemote));
591 m_bSetUpstream = FALSE;
592 UpdateData(FALSE);