1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2016 - 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
24 #include "TortoiseProc.h"
26 #include "StringUtils.h"
31 #include "BrowseRefsDlg.h"
32 #include "RefLogDlg.h"
33 #include "MessageBox.h"
37 IMPLEMENT_DYNAMIC(CPushDlg
, CHorizontalResizableStandAloneDialog
)
39 CPushDlg::CPushDlg(CWnd
* pParent
/*=nullptr*/)
40 : CHorizontalResizableStandAloneDialog(CPushDlg::IDD
, pParent
)
41 , m_bPushAllBranches(FALSE
)
43 , m_bForceWithLease(FALSE
)
46 , m_bPushAllRemotes(FALSE
)
47 , m_bSetPushBranch(FALSE
)
48 , m_bSetPushRemote(FALSE
)
49 , m_bSetUpstream(FALSE
)
50 , m_RecurseSubmodules(0)
51 , m_bAutoLoad(CAppUtils::IsSSHPutty())
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_FORCE_WITH_LEASE
, m_bForceWithLease
);
70 DDX_Check(pDX
,IDC_PUSHALL
,this->m_bPushAllBranches
);
71 DDX_Check(pDX
,IDC_PACK
,this->m_bPack
);
72 DDX_Check(pDX
,IDC_TAGS
,this->m_bTags
);
73 DDX_Check(pDX
,IDC_PUTTYKEY_AUTOLOAD
,this->m_bAutoLoad
);
74 DDX_Check(pDX
, IDC_PROC_PUSH_SET_PUSHREMOTE
, m_bSetPushRemote
);
75 DDX_Check(pDX
, IDC_PROC_PUSH_SET_PUSHBRANCH
, m_bSetPushBranch
);
76 DDX_Check(pDX
, IDC_PROC_PUSH_SET_UPSTREAM
, m_bSetUpstream
);
79 BEGIN_MESSAGE_MAP(CPushDlg
, CHorizontalResizableStandAloneDialog
)
80 ON_BN_CLICKED(IDC_RD_REMOTE
, &CPushDlg::OnBnClickedRd
)
81 ON_BN_CLICKED(IDC_RD_URL
, &CPushDlg::OnBnClickedRd
)
82 ON_CBN_SELCHANGE(IDC_BRANCH_SOURCE
, &CPushDlg::OnCbnSelchangeBranchSource
)
83 ON_CBN_SELCHANGE(IDC_REMOTE
, &CPushDlg::EnDisablePushRemoteArchiveBranch
)
84 ON_BN_CLICKED(IDOK
, &CPushDlg::OnBnClickedOk
)
85 ON_BN_CLICKED(IDC_REMOTE_MANAGE
, &CPushDlg::OnBnClickedRemoteManage
)
86 ON_BN_CLICKED(IDC_BUTTON_BROWSE_SOURCE_BRANCH
, &CPushDlg::OnBnClickedButtonBrowseSourceBranch
)
87 ON_BN_CLICKED(IDC_BUTTON_BROWSE_DEST_BRANCH
, &CPushDlg::OnBnClickedButtonBrowseDestBranch
)
88 ON_BN_CLICKED(IDC_PUSHALL
, &CPushDlg::OnBnClickedPushall
)
89 ON_BN_CLICKED(IDC_FORCE
, &CPushDlg::OnBnClickedForce
)
90 ON_BN_CLICKED(IDC_FORCE_WITH_LEASE
, &CPushDlg::OnBnClickedForceWithLease
)
91 ON_BN_CLICKED(IDC_TAGS
, &CPushDlg::OnBnClickedTags
)
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
)
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
);
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(L
"PushDlg");
161 m_Remote
.SetMaxHistoryItems(0x7FFFFFFF);
162 m_RemoteURL
.SetCaseSensitive(TRUE
);
163 m_RemoteURL
.SetURLHistory(TRUE
);
165 CString WorkingDir
=g_Git
.m_CurrentDir
;
166 WorkingDir
.Replace(L
':', L
'_');
167 m_regPushAllRemotes
= CRegDWORD(L
"Software\\TortoiseGit\\TortoiseProc\\Push\\" + WorkingDir
+ L
"\\AllRemotes", FALSE
);
168 m_bPushAllRemotes
= m_regPushAllRemotes
;
169 m_regPushAllBranches
= CRegDWORD(L
"Software\\TortoiseGit\\TortoiseProc\\Push\\" + WorkingDir
+ L
"\\AllBranches", FALSE
);
170 m_bPushAllBranches
= m_regPushAllBranches
;
171 m_RemoteURL
.LoadHistory(L
"Software\\TortoiseGit\\History\\PushURLS\\" + WorkingDir
, L
"url");
172 m_RemoteURL
.EnableWindow(FALSE
);
173 CheckRadioButton(IDC_RD_REMOTE
,IDC_RD_URL
,IDC_RD_REMOTE
);
176 m_regThinPack
= CRegDWORD(L
"Software\\TortoiseGit\\TortoiseProc\\Push\\" + WorkingDir
+ L
"\\ThinPack", FALSE
);
177 m_bPack
= m_regThinPack
;
178 this->m_regAutoLoad
= CRegDWORD(L
"Software\\TortoiseGit\\History\\PushDlgAutoLoad\\" + WorkingDir
,
180 m_bAutoLoad
= this->m_regAutoLoad
;
181 if(!CAppUtils::IsSSHPutty())
184 m_BrowseLocalRef
.m_bRightArrow
= TRUE
;
185 m_BrowseLocalRef
.m_bDefaultClick
= FALSE
;
186 m_BrowseLocalRef
.m_bMarkDefault
= FALSE
;
187 m_BrowseLocalRef
.m_bShowCurrentItem
= FALSE
;
188 m_BrowseLocalRef
.AddEntry(CString(MAKEINTRESOURCE(IDS_REFBROWSE
)));
189 m_BrowseLocalRef
.AddEntry(CString(MAKEINTRESOURCE(IDS_LOG
)));
190 m_BrowseLocalRef
.AddEntry(CString(MAKEINTRESOURCE(IDS_REFLOG
)));
192 m_tooltips
.AddTool(IDC_PROC_PUSH_SET_PUSHBRANCH
, IDS_PUSHDLG_PUSHBRANCH_TT
);
193 m_tooltips
.AddTool(IDC_PROC_PUSH_SET_PUSHREMOTE
, IDS_PUSHDLG_PUSHREMOTE_TT
);
194 m_tooltips
.AddTool(IDC_FORCE
, IDS_FORCE_TT
);
195 m_tooltips
.AddTool(IDC_FORCE_WITH_LEASE
, IDS_FORCE_WITH_LEASE_TT
);
197 CString recurseSubmodules
= g_Git
.GetConfigValue(L
"push.recurseSubmodules");
198 if (recurseSubmodules
== L
"check")
199 m_RecurseSubmodules
= 1;
200 else if (recurseSubmodules
== L
"on-demand")
201 m_RecurseSubmodules
= 2;
203 m_RecurseSubmodules
= 0;
204 m_regRecurseSubmodules
= CRegDWORD(L
"Software\\TortoiseGit\\History\\PushRecurseSubmodules\\" + WorkingDir
, m_RecurseSubmodules
);
205 m_RecurseSubmodules
= m_regRecurseSubmodules
;
206 m_RecurseSubmodulesCombo
.AddString(CString(MAKEINTRESOURCE(IDS_NONE
)));
207 m_RecurseSubmodulesCombo
.AddString(CString(MAKEINTRESOURCE(IDS_RECURSE_SUBMODULES_CHECK
)));
208 m_RecurseSubmodulesCombo
.AddString(CString(MAKEINTRESOURCE(IDS_RECURSE_SUBMODULES_ONDEMAND
)));
209 m_RecurseSubmodulesCombo
.SetCurSel(m_RecurseSubmodules
);
213 this->UpdateData(false);
215 OnBnClickedPushall();
219 void CPushDlg::Refresh()
221 CString WorkingDir
=g_Git
.m_CurrentDir
;
222 WorkingDir
.Replace(L
':', L
'_');
224 CRegString
remote(L
"Software\\TortoiseGit\\History\\PushRemote\\" + WorkingDir
);
225 m_RemoteReg
= remote
;
231 if(!g_Git
.GetRemoteList(list
))
234 m_Remote
.AddString(CString(MAKEINTRESOURCE(IDS_PROC_PUSHFETCH_ALLREMOTES
)));
235 for (unsigned int i
= 0; i
< list
.size(); ++i
)
237 m_Remote
.AddString(list
[i
]);
238 if(list
[i
] == remote
)
239 sel
= i
+ (list
.size() > 1 ? 1 : 0);
243 MessageBox(g_Git
.GetGitLastErr(L
"Could not get list of remotes."), L
"TortoiseGit", MB_ICONERROR
);
244 // if the last selected remote was "- All -" and "- All -" is still in the list -> select it
245 if (list
.size() > 1 && remote
== CString(MAKEINTRESOURCE(IDS_PROC_PUSHFETCH_ALLREMOTES
)))
247 m_Remote
.SetCurSel(sel
);
251 m_BranchSource
.Reset();
252 m_BranchSource
.SetMaxHistoryItems(0x7FFFFFFF);
253 if(!g_Git
.GetBranchList(list
,¤t
))
254 m_BranchSource
.SetList(list
);
256 MessageBox(g_Git
.GetGitLastErr(L
"Could not get list of local branches."), L
"TortoiseGit", MB_ICONERROR
);
257 if (CStringUtils::StartsWith(m_BranchSourceName
, L
"refs/"))
258 m_BranchSourceName
= m_BranchSourceName
.Mid(5);
259 if (CStringUtils::StartsWith(m_BranchSourceName
, L
"heads/"))
261 m_BranchSourceName
= m_BranchSourceName
.Mid(6);
262 m_BranchSource
.SetCurSel(m_BranchSource
.FindStringExact(-1, m_BranchSourceName
));
264 else if (CStringUtils::StartsWith(m_BranchSourceName
, L
"remotes/"))
265 m_BranchSource
.SetCurSel(m_BranchSource
.FindStringExact(-1, m_BranchSourceName
));
266 else if (m_BranchSourceName
.IsEmpty())
267 m_BranchSource
.SetCurSel(current
);
269 m_BranchSource
.SetWindowText(m_BranchSourceName
);
271 GetRemoteBranch(m_BranchSource
.GetString());
273 this->GetDlgItem(IDOK
)->EnableWindow(m_BranchSource
.GetCount() != 0);
275 if (list
.size() > 1 && m_bPushAllRemotes
)
276 m_Remote
.SetCurSel(0);
277 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
280 void CPushDlg::GetRemoteBranch(CString currentBranch
)
282 CString WorkingDir
=g_Git
.m_CurrentDir
;
283 WorkingDir
.Replace(L
':', L
'_');
285 if (currentBranch
.IsEmpty())
287 EnDisablePushRemoteArchiveBranch();
293 g_Git
.GetRemotePushBranch(currentBranch
, pushRemote
, pushBranch
);
295 CRegString
remote(L
"Software\\TortoiseGit\\History\\PushRemote\\" + WorkingDir
);
297 if (!pushRemote
.IsEmpty())
300 // if a pushRemote exists, select it
301 for (int i
= 0; i
< m_Remote
.GetCount(); ++i
)
304 int n
= m_Remote
.GetLBTextLen(i
);
305 m_Remote
.GetLBText(i
, CStrBuf(str
, n
));
306 if (str
== pushRemote
)
308 m_Remote
.SetCurSel(i
);
313 // select the only remote if only one exists
314 else if (m_Remote
.GetCount() == 1)
315 m_Remote
.SetCurSel(0);
316 // select no remote if no push-remote is specified AND push to all remotes is not selected
317 else if (!(m_Remote
.GetCount() > 1 && m_Remote
.GetCurSel() == 0))
318 m_Remote
.SetCurSel(-1);
320 m_BranchRemote
.LoadHistory(L
"Software\\TortoiseGit\\History\\RemoteBranch\\" + WorkingDir
, L
"branch");
321 if( !pushBranch
.IsEmpty() )
322 m_BranchRemote
.AddString(pushBranch
);
324 EnDisablePushRemoteArchiveBranch();
327 void CPushDlg::EnDisablePushRemoteArchiveBranch()
329 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())
331 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHBRANCH
, FALSE
);
332 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHREMOTE
, FALSE
);
333 bool enableUpstream
= (GetCheckedRadioButton(IDC_RD_REMOTE
, IDC_RD_URL
) != IDC_RD_URL
&& (!m_BranchSource
.GetString().Trim().IsEmpty() || m_bPushAllBranches
));
334 DialogEnableWindow(IDC_PROC_PUSH_SET_UPSTREAM
, enableUpstream
);
335 if (m_bSetUpstream
&& !enableUpstream
)
336 m_bSetUpstream
= FALSE
;
337 m_bSetPushRemote
= FALSE
;
338 m_bSetPushBranch
= FALSE
;
343 DialogEnableWindow(IDC_PROC_PUSH_SET_UPSTREAM
, TRUE
);
344 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHBRANCH
, !m_bSetUpstream
);
345 DialogEnableWindow(IDC_PROC_PUSH_SET_PUSHREMOTE
, !m_bSetUpstream
);
349 // CPushDlg message handlers
351 void CPushDlg::OnBnClickedRd()
353 if( GetCheckedRadioButton(IDC_RD_REMOTE
,IDC_RD_URL
) == IDC_RD_REMOTE
)
355 m_Remote
.EnableWindow(TRUE
);
356 GetDlgItem(IDC_REMOTE_MANAGE
)->EnableWindow(TRUE
);
357 m_RemoteURL
.EnableWindow(FALSE
);
359 if( GetCheckedRadioButton(IDC_RD_REMOTE
,IDC_RD_URL
) == IDC_RD_URL
)
361 CString clippath
= CAppUtils::GetClipboardLink();
362 if (clippath
.IsEmpty())
363 m_RemoteURL
.SetCurSel(0);
365 m_RemoteURL
.SetWindowText(clippath
);
366 m_Remote
.EnableWindow(FALSE
);
367 GetDlgItem(IDC_REMOTE_MANAGE
)->EnableWindow(FALSE
);
368 m_RemoteURL
.EnableWindow(TRUE
);
370 EnDisablePushRemoteArchiveBranch();
374 void CPushDlg::OnCbnSelchangeBranchSource()
376 GetRemoteBranch(m_BranchSource
.GetString());
379 void CPushDlg::OnBnClickedOk()
381 CHorizontalResizableStandAloneDialog::UpdateData(TRUE
);
383 if( GetCheckedRadioButton(IDC_RD_REMOTE
,IDC_RD_URL
) == IDC_RD_REMOTE
)
385 m_URL
=m_Remote
.GetString();
388 CMessageBox::Show(GetSafeHwnd(), IDS_PROC_GITCONFIG_REMOTEEMPTY
, IDS_APPNAME
, MB_OK
| MB_ICONEXCLAMATION
);
391 m_bPushAllRemotes
= (m_Remote
.GetCurSel() == 0 && m_Remote
.GetCount() > 1);
393 if( GetCheckedRadioButton(IDC_RD_REMOTE
,IDC_RD_URL
) == IDC_RD_URL
)
394 m_URL
=m_RemoteURL
.GetString();
396 if (!m_bPushAllBranches
)
398 this->m_BranchRemoteName
=m_BranchRemote
.GetString().Trim();
399 this->m_BranchSourceName
=m_BranchSource
.GetString().Trim();
401 if (m_BranchSourceName
.IsEmpty() && m_BranchRemoteName
.IsEmpty())
403 if (CMessageBox::Show(GetSafeHwnd(), IDS_B_T_BOTHEMPTY
, IDS_APPNAME
, MB_ICONQUESTION
| MB_YESNO
) != IDYES
)
406 if (m_BranchSourceName
.IsEmpty() && !m_BranchRemoteName
.IsEmpty())
408 if (CMessageBox::Show(GetSafeHwnd(), IDS_B_T_LOCALEMPTY
, IDS_APPNAME
, MB_ICONEXCLAMATION
| MB_YESNO
) != IDYES
)
411 else if (!m_BranchRemoteName
.IsEmpty() && !g_Git
.IsBranchNameValid(this->m_BranchRemoteName
))
413 CMessageBox::Show(GetSafeHwnd(), IDS_B_T_INVALID
, IDS_APPNAME
, MB_OK
| MB_ICONEXCLAMATION
);
416 else if (!m_BranchSourceName
.IsEmpty() && !g_Git
.IsBranchTagNameUnique(m_BranchSourceName
))
418 CMessageBox::Show(GetSafeHwnd(), IDS_B_T_NOT_UNIQUE
, IDS_APPNAME
, MB_OK
| MB_ICONEXCLAMATION
);
423 // do not store branch names on removal
424 if (m_RemoteURL
.IsWindowEnabled())
425 m_RemoteURL
.SaveHistory(); // do not store Remote URLs if not used
426 this->m_BranchRemote
.SaveHistory();
427 m_RemoteReg
= m_Remote
.GetString();
429 if (!m_BranchSourceName
.IsEmpty())
432 if (m_bSetPushBranch
)
434 configName
.Format(L
"branch.%s.pushbranch", (LPCTSTR
)m_BranchSourceName
);
435 if (!m_BranchRemoteName
.IsEmpty())
436 g_Git
.SetConfigValue(configName
, m_BranchRemoteName
);
438 g_Git
.UnsetConfigValue(configName
);
440 if (m_bSetPushRemote
)
442 configName
.Format(L
"branch.%s.pushremote", (LPCTSTR
)m_BranchSourceName
);
443 if (!m_URL
.IsEmpty())
444 g_Git
.SetConfigValue(configName
, m_URL
);
446 g_Git
.UnsetConfigValue(configName
);
452 m_regPushAllBranches
= m_bPushAllBranches
;
453 m_regPushAllRemotes
= m_bPushAllRemotes
;
454 m_regThinPack
= m_bPack
;
455 this->m_regAutoLoad
= m_bAutoLoad
;
456 m_RecurseSubmodules
= m_RecurseSubmodulesCombo
.GetCurSel();
457 m_regRecurseSubmodules
= m_RecurseSubmodules
;
459 CHorizontalResizableStandAloneDialog::OnOK();
462 void CPushDlg::OnBnClickedRemoteManage()
464 CAppUtils::LaunchRemoteSetting();
468 void CPushDlg::OnBnClickedButtonBrowseSourceBranch()
470 switch (m_BrowseLocalRef
.GetCurrentEntry())
472 case 0: /* Browse Refence*/
474 if(CBrowseRefsDlg::PickRefForCombo(&m_BranchSource
, gPickRef_Head
))
475 OnCbnSelchangeBranchSource();
483 m_BranchSource
.GetWindowText(revision
);
484 dlg
.SetParams(CTGitPath(), CTGitPath(), revision
, revision
, 0);
486 dlg
.ShowWorkingTreeChanges(false);
487 if(dlg
.DoModal() == IDOK
)
489 m_BranchSource
.SetWindowText(dlg
.GetSelectedHash().at(0).ToString());
490 OnCbnSelchangeBranchSource();
498 if(dlg
.DoModal() == IDOK
)
500 m_BranchSource
.SetWindowText(dlg
.m_SelectedHash
);
501 OnCbnSelchangeBranchSource();
508 void CPushDlg::OnBnClickedButtonBrowseDestBranch()
510 CString remoteBranchName
;
512 m_BranchRemote
.GetWindowText(remoteBranchName
);
513 remoteName
= m_Remote
.GetString();
514 remoteBranchName
= remoteName
+ '/' + remoteBranchName
;
515 remoteBranchName
= CBrowseRefsDlg::PickRef(false, remoteBranchName
, gPickRef_Remote
);
516 if(remoteBranchName
.IsEmpty())
518 remoteBranchName
= remoteBranchName
.Mid(13);//Strip 'refs/remotes/'
519 int slashPlace
= remoteBranchName
.Find('/');
520 remoteName
= remoteBranchName
.Left(slashPlace
);
521 remoteBranchName
= remoteBranchName
.Mid(slashPlace
+ 1); //Strip remote name (for example 'origin/')
524 int remoteSel
= m_Remote
.FindStringExact(0,remoteName
);
526 m_Remote
.SetCurSel(remoteSel
);
529 m_BranchRemote
.AddString(remoteBranchName
, 0);
532 BOOL
CPushDlg::PreTranslateMessage(MSG
* pMsg
)
534 if (pMsg
->message
== WM_KEYDOWN
)
536 switch (pMsg
->wParam
)
546 return CHorizontalResizableStandAloneDialog::PreTranslateMessage(pMsg
);
549 void CPushDlg::OnBnClickedPushall()
552 this->GetDlgItem(IDC_BRANCH_REMOTE
)->EnableWindow(!m_bPushAllBranches
);
553 this->GetDlgItem(IDC_BRANCH_SOURCE
)->EnableWindow(!m_bPushAllBranches
);
554 this->GetDlgItem(IDC_BUTTON_BROWSE_SOURCE_BRANCH
)->EnableWindow(!m_bPushAllBranches
);
555 this->GetDlgItem(IDC_BUTTON_BROWSE_DEST_BRANCH
)->EnableWindow(!m_bPushAllBranches
);
556 EnDisablePushRemoteArchiveBranch();
559 void CPushDlg::OnBnClickedForce()
562 GetDlgItem(IDC_FORCE_WITH_LEASE
)->EnableWindow(m_bTags
|| m_bForce
? FALSE
: TRUE
);
565 void CPushDlg::OnBnClickedForceWithLease()
568 GetDlgItem(IDC_FORCE
)->EnableWindow(m_bForceWithLease
? FALSE
: TRUE
);
569 GetDlgItem(IDC_TAGS
)->EnableWindow(m_bForceWithLease
? FALSE
: TRUE
);
572 void CPushDlg::OnBnClickedTags()
575 GetDlgItem(IDC_FORCE_WITH_LEASE
)->EnableWindow(m_bTags
|| m_bForce
? FALSE
: TRUE
);
578 void CPushDlg::OnBnClickedProcPushSetUpstream()
581 this->GetDlgItem(IDC_PROC_PUSH_SET_PUSHREMOTE
)->EnableWindow(!m_bSetUpstream
);
582 this->GetDlgItem(IDC_PROC_PUSH_SET_PUSHBRANCH
)->EnableWindow(!m_bSetUpstream
);
583 m_bSetPushBranch
= FALSE
;
584 m_bSetPushRemote
= FALSE
;
588 void CPushDlg::OnBnClickedProcPushSetPushremote()
591 this->GetDlgItem(IDC_PROC_PUSH_SET_UPSTREAM
)->EnableWindow(!(m_bSetPushBranch
|| m_bSetPushRemote
));
592 m_bSetUpstream
= FALSE
;