Fixed issue #2449: wrong column info in tag reference dialog
[TortoiseGit.git] / src / TortoiseProc / PushDlg.cpp
blobdfbf68da6d0c1ae2ee7e37f1f83042678ee3a6de
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2015 - 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_bForceWithLease(FALSE)
44 , m_bPack(FALSE)
45 , m_bTags(FALSE)
46 , m_bAutoLoad(FALSE)
47 , m_bPushAllRemotes(FALSE)
48 , m_bSetPushBranch(FALSE)
49 , m_bSetPushRemote(FALSE)
50 , m_bSetUpstream(FALSE)
51 , m_RecurseSubmodules(0)
53 m_bAutoLoad = CAppUtils::IsSSHPutty();
56 CPushDlg::~CPushDlg()
60 void CPushDlg::DoDataExchange(CDataExchange* pDX)
62 CHorizontalResizableStandAloneDialog::DoDataExchange(pDX);
63 DDX_Control(pDX, IDC_BRANCH_REMOTE, this->m_BranchRemote);
64 DDX_Control(pDX, IDC_BRANCH_SOURCE, this->m_BranchSource);
65 DDX_Control(pDX, IDC_REMOTE, this->m_Remote);
66 DDX_Control(pDX, IDC_URL, this->m_RemoteURL);
67 DDX_Control(pDX, IDC_BUTTON_BROWSE_SOURCE_BRANCH, m_BrowseLocalRef);
68 DDX_Control(pDX, IDC_COMBOBOX_RECURSE_SUBMODULES, m_RecurseSubmodulesCombo);
69 DDX_Check(pDX,IDC_FORCE,this->m_bForce);
70 DDX_Check(pDX, IDC_FORCE_WITH_LEASE, m_bForceWithLease);
71 DDX_Check(pDX,IDC_PUSHALL,this->m_bPushAllBranches);
72 DDX_Check(pDX,IDC_PACK,this->m_bPack);
73 DDX_Check(pDX,IDC_TAGS,this->m_bTags);
74 DDX_Check(pDX,IDC_PUTTYKEY_AUTOLOAD,this->m_bAutoLoad);
75 DDX_Check(pDX, IDC_PROC_PUSH_SET_PUSHREMOTE, m_bSetPushRemote);
76 DDX_Check(pDX, IDC_PROC_PUSH_SET_PUSHBRANCH, m_bSetPushBranch);
77 DDX_Check(pDX, IDC_PROC_PUSH_SET_UPSTREAM, m_bSetUpstream);
80 BEGIN_MESSAGE_MAP(CPushDlg, CHorizontalResizableStandAloneDialog)
81 ON_BN_CLICKED(IDC_RD_REMOTE, &CPushDlg::OnBnClickedRd)
82 ON_BN_CLICKED(IDC_RD_URL, &CPushDlg::OnBnClickedRd)
83 ON_CBN_SELCHANGE(IDC_BRANCH_SOURCE, &CPushDlg::OnCbnSelchangeBranchSource)
84 ON_CBN_SELCHANGE(IDC_REMOTE, &CPushDlg::EnDisablePushRemoteArchiveBranch)
85 ON_BN_CLICKED(IDOK, &CPushDlg::OnBnClickedOk)
86 ON_BN_CLICKED(IDC_REMOTE_MANAGE, &CPushDlg::OnBnClickedRemoteManage)
87 ON_BN_CLICKED(IDC_BUTTON_BROWSE_SOURCE_BRANCH, &CPushDlg::OnBnClickedButtonBrowseSourceBranch)
88 ON_BN_CLICKED(IDC_BUTTON_BROWSE_DEST_BRANCH, &CPushDlg::OnBnClickedButtonBrowseDestBranch)
89 ON_BN_CLICKED(IDC_PUSHALL, &CPushDlg::OnBnClickedPushall)
90 ON_BN_CLICKED(IDC_FORCE, &CPushDlg::OnBnClickedForce)
91 ON_BN_CLICKED(IDC_FORCE_WITH_LEASE, &CPushDlg::OnBnClickedForceWithLease)
92 ON_BN_CLICKED(IDC_PROC_PUSH_SET_UPSTREAM, &CPushDlg::OnBnClickedProcPushSetUpstream)
93 ON_BN_CLICKED(IDC_PROC_PUSH_SET_PUSHREMOTE, &CPushDlg::OnBnClickedProcPushSetPushremote)
94 ON_BN_CLICKED(IDC_PROC_PUSH_SET_PUSHBRANCH, &CPushDlg::OnBnClickedProcPushSetPushremote)
95 END_MESSAGE_MAP()
97 BOOL CPushDlg::OnInitDialog()
99 CHorizontalResizableStandAloneDialog::OnInitDialog();
100 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
102 AddAnchor(IDOK,BOTTOM_RIGHT);
103 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
104 AddAnchor(IDC_BRANCH_GROUP, TOP_LEFT,TOP_RIGHT);
105 AddAnchor(IDC_STATIC_REMOTE, TOP_LEFT);
106 AddAnchor(IDC_STATIC_SOURCE, TOP_LEFT);
108 AddAnchor(IDC_PUSHALL, TOP_LEFT);
109 AddAnchor(IDC_BRANCH_REMOTE, TOP_LEFT, TOP_RIGHT);
110 AddAnchor(IDC_BUTTON_BROWSE_DEST_BRANCH, TOP_RIGHT);
111 AddAnchor(IDC_BRANCH_SOURCE, TOP_LEFT, TOP_RIGHT);
112 AddAnchor(IDC_BUTTON_BROWSE_SOURCE_BRANCH, TOP_RIGHT);
114 AddAnchor(IDC_URL_GROUP, TOP_LEFT,TOP_RIGHT);
115 AddAnchor(IDC_RD_REMOTE, TOP_LEFT);
116 AddAnchor(IDC_RD_URL, TOP_LEFT);
118 AddAnchor(IDC_REMOTE, TOP_LEFT, TOP_RIGHT);
120 AddAnchor(IDC_URL, TOP_LEFT,TOP_RIGHT);
122 AddAnchor(IDC_OPTION_GROUP, TOP_LEFT,TOP_RIGHT);
124 AddAnchor(IDC_FORCE, TOP_LEFT);
125 AddAnchor(IDC_FORCE_WITH_LEASE, TOP_LEFT);
126 AddAnchor(IDC_PACK, TOP_LEFT);
127 AddAnchor(IDC_TAGS, TOP_LEFT);
128 AddAnchor(IDC_PUTTYKEY_AUTOLOAD,TOP_LEFT);
129 AddAnchor(IDC_PROC_PUSH_SET_PUSHBRANCH, TOP_LEFT);
130 AddAnchor(IDC_PROC_PUSH_SET_PUSHREMOTE, TOP_LEFT);
131 AddAnchor(IDC_PROC_PUSH_SET_UPSTREAM, TOP_LEFT);
132 AddAnchor(IDC_STATIC_RECURSE_SUBMODULES, TOP_LEFT);
133 AddAnchor(IDC_COMBOBOX_RECURSE_SUBMODULES, TOP_LEFT);
135 AddAnchor(IDC_REMOTE_MANAGE,TOP_RIGHT);
136 AddAnchor(IDHELP, BOTTOM_RIGHT);
138 AddOthersToAnchor();
140 AdjustControlSize(IDC_RD_REMOTE);
141 AdjustControlSize(IDC_RD_URL);
142 AdjustControlSize(IDC_PUSHALL);
143 AdjustControlSize(IDC_FORCE);
144 AdjustControlSize(IDC_FORCE_WITH_LEASE);
145 AdjustControlSize(IDC_PACK);
146 AdjustControlSize(IDC_TAGS);
147 AdjustControlSize(IDC_PUTTYKEY_AUTOLOAD);
148 AdjustControlSize(IDC_PROC_PUSH_SET_PUSHBRANCH);
149 AdjustControlSize(IDC_PROC_PUSH_SET_PUSHREMOTE);
150 AdjustControlSize(IDC_PROC_PUSH_SET_UPSTREAM);
151 AdjustControlSize(IDC_STATIC_RECURSE_SUBMODULES);
153 CString sWindowTitle;
154 GetWindowText(sWindowTitle);
155 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
157 this->GetDlgItem(IDC_PUTTYKEY_AUTOLOAD)->EnableWindow(CAppUtils::IsSSHPutty());
159 EnableSaveRestore(_T("PushDlg"));
161 m_RemoteURL.SetCaseSensitive(TRUE);
162 m_RemoteURL.SetURLHistory(TRUE);
164 CString WorkingDir=g_Git.m_CurrentDir;
165 WorkingDir.Replace(_T(':'),_T('_'));
166 m_regPushAllRemotes = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Push\\") + WorkingDir + _T("\\AllRemotes"), FALSE);
167 m_bPushAllRemotes = m_regPushAllRemotes;
168 m_regPushAllBranches = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Push\\") + WorkingDir + _T("\\AllBranches"), FALSE);
169 m_bPushAllBranches = m_regPushAllBranches;
170 m_RemoteURL.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\PushURLS\\"))+WorkingDir, _T("url"));
171 m_RemoteURL.EnableWindow(FALSE);
172 CheckRadioButton(IDC_RD_REMOTE,IDC_RD_URL,IDC_RD_REMOTE);
175 m_regThinPack = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\Push\\") + WorkingDir + _T("\\ThinPack"), FALSE);
176 m_bPack = m_regThinPack;
177 this->m_regAutoLoad = CRegDWORD(CString(_T("Software\\TortoiseGit\\History\\PushDlgAutoLoad\\"))+WorkingDir,
178 m_bAutoLoad);
179 m_bAutoLoad = this->m_regAutoLoad;
180 if(!CAppUtils::IsSSHPutty())
181 m_bAutoLoad = false;
183 m_BrowseLocalRef.m_bRightArrow = TRUE;
184 m_BrowseLocalRef.m_bDefaultClick = FALSE;
185 m_BrowseLocalRef.m_bMarkDefault = FALSE;
186 m_BrowseLocalRef.AddEntry(CString(MAKEINTRESOURCE(IDS_REFBROWSE)));
187 m_BrowseLocalRef.AddEntry(CString(MAKEINTRESOURCE(IDS_LOG)));
188 m_BrowseLocalRef.AddEntry(CString(MAKEINTRESOURCE(IDS_REFLOG)));
190 m_tooltips.AddTool(IDC_PROC_PUSH_SET_PUSHBRANCH, IDS_PUSHDLG_PUSHBRANCH_TT);
191 m_tooltips.AddTool(IDC_PROC_PUSH_SET_PUSHREMOTE, IDS_PUSHDLG_PUSHREMOTE_TT);
192 m_tooltips.AddTool(IDC_FORCE, IDS_FORCE_TT);
193 m_tooltips.AddTool(IDC_FORCE_WITH_LEASE, IDS_FORCE_WITH_LEASE_TT);
195 m_regRecurseSubmodules = CRegDWORD(
196 CString(_T("Software\\TortoiseGit\\History\\PushRecurseSubmodules\\")) + WorkingDir, m_RecurseSubmodules);
197 m_RecurseSubmodules = m_regRecurseSubmodules;
198 m_RecurseSubmodulesCombo.AddString(CString(MAKEINTRESOURCE(IDS_NONE)));
199 m_RecurseSubmodulesCombo.AddString(CString(MAKEINTRESOURCE(IDS_RECURSE_SUBMODULES_CHECK)));
200 m_RecurseSubmodulesCombo.AddString(CString(MAKEINTRESOURCE(IDS_RECURSE_SUBMODULES_ONDEMAND)));
201 m_RecurseSubmodulesCombo.SetCurSel(m_RecurseSubmodules);
203 if (CAppUtils::GetMsysgitVersion() < 0x01080500)
204 GetDlgItem(IDC_FORCE_WITH_LEASE)->EnableWindow(FALSE);
206 Refresh();
208 this->UpdateData(false);
210 OnBnClickedPushall();
211 return TRUE;
214 void CPushDlg::Refresh()
216 CString WorkingDir=g_Git.m_CurrentDir;
217 WorkingDir.Replace(_T(':'),_T('_'));
219 CRegString remote(CString(_T("Software\\TortoiseGit\\History\\PushRemote\\")+WorkingDir));
220 m_RemoteReg = remote;
221 int sel = -1;
223 STRING_VECTOR list;
224 m_Remote.Reset();
226 if(!g_Git.GetRemoteList(list))
228 if (list.size() > 1)
229 m_Remote.AddString(CString(MAKEINTRESOURCE(IDS_PROC_PUSHFETCH_ALLREMOTES)));
230 for (unsigned int i = 0; i < list.size(); ++i)
232 m_Remote.AddString(list[i]);
233 if(list[i] == remote)
234 sel = i + (list.size() > 1 ? 1 : 0);
237 else
238 MessageBox(g_Git.GetGitLastErr(_T("Could not get list of remotes.")), _T("TortoiseGit"), MB_ICONERROR);
239 // if the last selected remote was "- All -" and "- All -" is still in the list -> select it
240 if (list.size() > 1 && remote == CString(MAKEINTRESOURCE(IDS_PROC_PUSHFETCH_ALLREMOTES)))
241 sel = 0;
242 m_Remote.SetCurSel(sel);
244 int current = -1;
245 list.clear();
246 m_BranchSource.Reset();
247 m_BranchSource.SetMaxHistoryItems(0x7FFFFFFF);
248 if(!g_Git.GetBranchList(list,&current))
249 m_BranchSource.SetList(list);
250 else
251 MessageBox(g_Git.GetGitLastErr(_T("Could not get list of local branches.")), _T("TortoiseGit"), MB_ICONERROR);
252 if (wcsncmp(m_BranchSourceName, _T("refs/"), 5) == 0)
253 m_BranchSourceName = m_BranchSourceName.Mid(5);
254 if (wcsncmp(m_BranchSourceName, _T("heads/"), 6) == 0)
256 m_BranchSourceName = m_BranchSourceName.Mid(6);
257 m_BranchSource.SetCurSel(m_BranchSource.FindStringExact(-1, m_BranchSourceName));
259 else if (wcsncmp(m_BranchSourceName, _T("remotes/"), 8) == 0)
260 m_BranchSource.SetCurSel(m_BranchSource.FindStringExact(-1, m_BranchSourceName));
261 else if (m_BranchSourceName.IsEmpty())
262 m_BranchSource.SetCurSel(current);
263 else
264 m_BranchSource.SetWindowText(m_BranchSourceName);
266 GetRemoteBranch(m_BranchSource.GetString());
268 this->GetDlgItem(IDOK)->EnableWindow(m_BranchSource.GetCount() != 0);
270 if (list.size() > 1 && m_bPushAllRemotes)
271 m_Remote.SetCurSel(0);
272 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
275 void CPushDlg::GetRemoteBranch(CString currentBranch)
277 CString WorkingDir=g_Git.m_CurrentDir;
278 WorkingDir.Replace(_T(':'), _T('_'));
280 if (currentBranch.IsEmpty())
282 EnDisablePushRemoteArchiveBranch();
283 return;
286 CString configName;
288 configName.Format(L"branch.%s.pushremote", currentBranch);
289 CString pushRemote = g_Git.GetConfigValue(configName);
290 if( pushRemote.IsEmpty() )
292 pushRemote = g_Git.GetConfigValue(L"remote.pushdefault");
293 if (pushRemote.IsEmpty())
295 configName.Format(L"branch.%s.remote", currentBranch);
296 pushRemote = g_Git.GetConfigValue(configName);
300 CRegString remote(CString(_T("Software\\TortoiseGit\\History\\PushRemote\\")+WorkingDir));
302 if (!pushRemote.IsEmpty())
304 remote = pushRemote;
305 // if a pushRemote exists, select it
306 for (int i = 0; i < m_Remote.GetCount(); ++i)
308 CString str;
309 int n = m_Remote.GetLBTextLen(i);
310 m_Remote.GetLBText(i, str.GetBuffer(n));
311 str.ReleaseBuffer();
312 if (str == pushRemote)
314 m_Remote.SetCurSel(i);
315 break;
319 // select the only remote if only one exists
320 else if (m_Remote.GetCount() == 1)
321 m_Remote.SetCurSel(0);
322 // select no remote if no push-remote is specified AND push to all remotes is not selected
323 else if (!(m_Remote.GetCount() > 1 && m_Remote.GetCurSel() == 0))
325 m_Remote.SetCurSel(-1);
328 //Select pull-branch from current branch
329 configName.Format(L"branch.%s.pushbranch", currentBranch);
330 CString pushBranch = g_Git.GetConfigValue(configName); // do not strip branch name (for gerrit), see issue #1609)
331 if( pushBranch.IsEmpty() )
333 configName.Format(L"branch.%s.merge", currentBranch);
334 pushBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));
337 m_BranchRemote.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\RemoteBranch\\"))+WorkingDir, _T("branch"));
338 if( !pushBranch.IsEmpty() )
339 m_BranchRemote.AddString(pushBranch);
341 EnDisablePushRemoteArchiveBranch();
344 void CPushDlg::EnDisablePushRemoteArchiveBranch()
346 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())
348 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHBRANCH, FALSE);
349 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHREMOTE, FALSE);
350 bool enableUpstream = (GetCheckedRadioButton(IDC_RD_REMOTE, IDC_RD_URL) != IDC_RD_URL && (!m_BranchSource.GetString().Trim().IsEmpty() || m_bPushAllBranches));
351 DialogEnableWindow(IDC_PROC_PUSH_SET_UPSTREAM, enableUpstream);
352 if (m_bSetUpstream && !enableUpstream)
353 m_bSetUpstream = FALSE;
354 m_bSetPushRemote = FALSE;
355 m_bSetPushBranch = FALSE;
356 UpdateData(FALSE);
358 else
360 DialogEnableWindow(IDC_PROC_PUSH_SET_UPSTREAM, TRUE);
361 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHBRANCH, !m_bSetUpstream);
362 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHREMOTE, !m_bSetUpstream);
366 // CPushDlg message handlers
368 void CPushDlg::OnBnClickedRd()
370 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_REMOTE)
372 m_Remote.EnableWindow(TRUE);
373 GetDlgItem(IDC_REMOTE_MANAGE)->EnableWindow(TRUE);
374 m_RemoteURL.EnableWindow(FALSE);
376 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_URL)
378 CString clippath = CAppUtils::GetClipboardLink();
379 if (clippath.IsEmpty())
380 m_RemoteURL.SetCurSel(0);
381 else
382 m_RemoteURL.SetWindowText(clippath);
383 m_Remote.EnableWindow(FALSE);
384 GetDlgItem(IDC_REMOTE_MANAGE)->EnableWindow(FALSE);
385 m_RemoteURL.EnableWindow(TRUE);
387 EnDisablePushRemoteArchiveBranch();
391 void CPushDlg::OnCbnSelchangeBranchSource()
393 GetRemoteBranch(m_BranchSource.GetString());
396 void CPushDlg::OnBnClickedOk()
398 CHorizontalResizableStandAloneDialog::UpdateData(TRUE);
400 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_REMOTE)
402 m_URL=m_Remote.GetString();
403 if (m_URL.IsEmpty())
405 CMessageBox::Show(NULL, IDS_PROC_GITCONFIG_REMOTEEMPTY, IDS_APPNAME, MB_OK);
406 return;
408 m_bPushAllRemotes = (m_Remote.GetCurSel() == 0 && m_Remote.GetCount() > 1);
410 if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_URL)
412 m_URL=m_RemoteURL.GetString();
415 if (!m_bPushAllBranches)
417 this->m_BranchRemoteName=m_BranchRemote.GetString().Trim();
418 this->m_BranchSourceName=m_BranchSource.GetString().Trim();
420 if (m_BranchSourceName.IsEmpty() && m_BranchRemoteName.IsEmpty())
422 if (CMessageBox::Show(NULL, IDS_B_T_BOTHEMPTY, IDS_APPNAME, MB_ICONQUESTION | MB_YESNO) != IDYES)
423 return;
425 if (m_BranchSourceName.IsEmpty() && !m_BranchRemoteName.IsEmpty())
427 if (CMessageBox::Show(NULL, IDS_B_T_LOCALEMPTY, IDS_APPNAME, MB_ICONEXCLAMATION | MB_YESNO) != IDYES)
428 return;
430 else if (!m_BranchRemoteName.IsEmpty() && !g_Git.IsBranchNameValid(this->m_BranchRemoteName))
432 CMessageBox::Show(NULL, IDS_B_T_INVALID, IDS_APPNAME, MB_OK);
433 return;
435 else if (!m_BranchSourceName.IsEmpty() && !g_Git.IsBranchTagNameUnique(m_BranchSourceName))
437 CMessageBox::Show(NULL, IDS_B_T_NOT_UNIQUE, IDS_APPNAME, MB_OK | MB_ICONEXCLAMATION);
438 return;
440 else
442 // do not store branch names on removal
443 if (m_RemoteURL.IsWindowEnabled())
444 m_RemoteURL.SaveHistory(); // do not store Remote URLs if not used
445 this->m_BranchRemote.SaveHistory();
446 m_RemoteReg = m_Remote.GetString();
448 if (!m_BranchSourceName.IsEmpty())
450 CString configName;
451 if (m_bSetPushBranch)
453 configName.Format(L"branch.%s.pushbranch", m_BranchSourceName);
454 if (!m_BranchRemoteName.IsEmpty())
455 g_Git.SetConfigValue(configName, m_BranchRemoteName);
456 else
457 g_Git.UnsetConfigValue(configName);
459 if (m_bSetPushRemote)
461 configName.Format(L"branch.%s.pushremote", m_BranchSourceName);
462 if (!m_URL.IsEmpty())
463 g_Git.SetConfigValue(configName, m_URL);
464 else
465 g_Git.UnsetConfigValue(configName);
471 m_regPushAllBranches = m_bPushAllBranches;
472 m_regPushAllRemotes = m_bPushAllRemotes;
473 m_regThinPack = m_bPack;
474 this->m_regAutoLoad = m_bAutoLoad ;
475 m_RecurseSubmodules = m_RecurseSubmodulesCombo.GetCurSel();
476 if (m_RecurseSubmodules == 2 && CAppUtils::GetMsysgitVersion() < 0x01070b00)
478 CString gitver;
479 gitver.Format(IDS_GITVER_REQUIRED, _T("--recurse-submodules=on-demand"), _T("1.7.11"));
480 CMessageBox::Show(m_hWnd, gitver, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
481 return;
483 m_regRecurseSubmodules = m_RecurseSubmodules;
485 CHorizontalResizableStandAloneDialog::OnOK();
488 void CPushDlg::OnBnClickedRemoteManage()
490 CAppUtils::LaunchRemoteSetting();
491 Refresh();
494 void CPushDlg::OnBnClickedButtonBrowseSourceBranch()
496 switch (m_BrowseLocalRef.GetCurrentEntry())
498 case 0: /* Browse Refence*/
500 if(CBrowseRefsDlg::PickRefForCombo(&m_BranchSource, gPickRef_Head))
501 OnCbnSelchangeBranchSource();
503 break;
505 case 1: /* Log */
507 CLogDlg dlg;
508 CString revision;
509 m_BranchSource.GetWindowText(revision);
510 dlg.SetParams(CTGitPath(), CTGitPath(), revision, revision, 0);
511 dlg.SetSelect(true);
512 if(dlg.DoModal() == IDOK)
514 if (dlg.GetSelectedHash().IsEmpty())
515 return;
517 m_BranchSource.SetWindowText(dlg.GetSelectedHash());
518 OnCbnSelchangeBranchSource();
521 break;
523 case 2: /*RefLog*/
525 CRefLogDlg dlg;
526 if(dlg.DoModal() == IDOK)
528 m_BranchSource.SetWindowText(dlg.m_SelectedHash);
529 OnCbnSelchangeBranchSource();
532 break;
536 void CPushDlg::OnBnClickedButtonBrowseDestBranch()
538 CString remoteBranchName;
539 CString remoteName;
540 m_BranchRemote.GetWindowText(remoteBranchName);
541 remoteName = m_Remote.GetString();
542 remoteBranchName = remoteName + '/' + remoteBranchName;
543 remoteBranchName = CBrowseRefsDlg::PickRef(false, remoteBranchName, gPickRef_Remote);
544 if(remoteBranchName.IsEmpty())
545 return; //Canceled
546 remoteBranchName = remoteBranchName.Mid(13);//Strip 'refs/remotes/'
547 int slashPlace = remoteBranchName.Find('/');
548 remoteName = remoteBranchName.Left(slashPlace);
549 remoteBranchName = remoteBranchName.Mid(slashPlace + 1); //Strip remote name (for example 'origin/')
551 //Select remote
552 int remoteSel = m_Remote.FindStringExact(0,remoteName);
553 if(remoteSel >= 0)
554 m_Remote.SetCurSel(remoteSel);
556 //Select branch
557 m_BranchRemote.AddString(remoteBranchName, 0);
560 BOOL CPushDlg::PreTranslateMessage(MSG* pMsg)
562 if (pMsg->message == WM_KEYDOWN)
564 switch (pMsg->wParam)
566 case VK_F5:
568 Refresh();
570 break;
574 return CHorizontalResizableStandAloneDialog::PreTranslateMessage(pMsg);
577 void CPushDlg::OnBnClickedPushall()
579 this->UpdateData();
580 this->GetDlgItem(IDC_BRANCH_REMOTE)->EnableWindow(!m_bPushAllBranches);
581 this->GetDlgItem(IDC_BRANCH_SOURCE)->EnableWindow(!m_bPushAllBranches);
582 this->GetDlgItem(IDC_BUTTON_BROWSE_SOURCE_BRANCH)->EnableWindow(!m_bPushAllBranches);
583 this->GetDlgItem(IDC_BUTTON_BROWSE_DEST_BRANCH)->EnableWindow(!m_bPushAllBranches);
584 EnDisablePushRemoteArchiveBranch();
587 void CPushDlg::OnBnClickedForce()
589 UpdateData();
590 if (CAppUtils::GetMsysgitVersion() >= 0x01080500)
591 GetDlgItem(IDC_FORCE_WITH_LEASE)->EnableWindow(m_bForce ? FALSE : TRUE);
594 void CPushDlg::OnBnClickedForceWithLease()
596 UpdateData();
597 GetDlgItem(IDC_FORCE)->EnableWindow(m_bForceWithLease ? FALSE : TRUE);
600 void CPushDlg::OnBnClickedProcPushSetUpstream()
602 UpdateData();
603 this->GetDlgItem(IDC_PROC_PUSH_SET_PUSHREMOTE)->EnableWindow(!m_bSetUpstream);
604 this->GetDlgItem(IDC_PROC_PUSH_SET_PUSHBRANCH)->EnableWindow(!m_bSetUpstream);
605 m_bSetPushBranch = FALSE;
606 m_bSetPushRemote = FALSE;
607 UpdateData(FALSE);
610 void CPushDlg::OnBnClickedProcPushSetPushremote()
612 UpdateData();
613 this->GetDlgItem(IDC_PROC_PUSH_SET_UPSTREAM)->EnableWindow(!(m_bSetPushBranch || m_bSetPushRemote));
614 m_bSetUpstream = FALSE;
615 UpdateData(FALSE);