Fix CMessageBox not modal
[TortoiseGit.git] / src / TortoiseProc / Settings / SettingGitRemote.cpp
blob94e3be533de6a1d1ab74ac4f49467cfa5b7fa4a5
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.
19 // SettingGitRemote.cpp : implementation file
22 #include "stdafx.h"
23 #include "TortoiseProc.h"
24 #include "SettingGitRemote.h"
25 #include "Settings.h"
26 #include "GitAdminDir.h"
27 #include "MessageBox.h"
28 #include "AppUtils.h"
29 #include "Git.h"
30 #include "HistoryCombo.h"
32 // CSettingGitRemote dialog
34 IMPLEMENT_DYNAMIC(CSettingGitRemote, ISettingsPropPage)
36 CSettingGitRemote::CSettingGitRemote()
37 : ISettingsPropPage(CSettingGitRemote::IDD)
38 , m_bNoFetch(false)
39 , m_bPrune(2)
40 , m_bPruneAll(FALSE)
41 , m_bPushDefault(FALSE)
43 m_ChangedMask = 0;
46 CSettingGitRemote::~CSettingGitRemote()
50 void CSettingGitRemote::DoDataExchange(CDataExchange* pDX)
52 CPropertyPage::DoDataExchange(pDX);
53 DDX_Control(pDX, IDC_LIST_REMOTE, m_ctrlRemoteList);
54 DDX_Text(pDX, IDC_EDIT_REMOTE, m_strRemote);
55 DDX_Text(pDX, IDC_EDIT_URL, m_strUrl);
56 DDX_Text(pDX, IDC_EDIT_PUSHURL, m_strPushUrl);
57 DDX_Text(pDX, IDC_EDIT_PUTTY_KEY, m_strPuttyKeyfile);
58 DDX_Control(pDX, IDC_COMBO_TAGOPT, m_ctrlTagOpt);
59 DDX_Check(pDX, IDC_CHECK_PRUNE, m_bPrune);
60 DDX_Check(pDX, IDC_CHECK_PRUNEALL, m_bPruneAll);
61 DDX_Check(pDX, IDC_CHECK_PUSHDEFAULT, m_bPushDefault);
64 BEGIN_MESSAGE_MAP(CSettingGitRemote, CPropertyPage)
65 ON_WM_TIMER()
66 ON_BN_CLICKED(IDC_BUTTON_BROWSE, &CSettingGitRemote::OnBnClickedButtonBrowse)
67 ON_BN_CLICKED(IDC_BUTTON_ADD, &CSettingGitRemote::OnBnClickedButtonAdd)
68 ON_LBN_SELCHANGE(IDC_LIST_REMOTE, &CSettingGitRemote::OnLbnSelchangeListRemote)
69 ON_EN_CHANGE(IDC_EDIT_REMOTE, &CSettingGitRemote::OnEnChangeEditRemote)
70 ON_EN_CHANGE(IDC_EDIT_URL, &CSettingGitRemote::OnEnChangeEditUrl)
71 ON_EN_CHANGE(IDC_EDIT_PUSHURL, &CSettingGitRemote::OnEnChangeEditPushUrl)
72 ON_EN_CHANGE(IDC_EDIT_PUTTY_KEY, &CSettingGitRemote::OnEnChangeEditPuttyKey)
73 ON_CBN_SELCHANGE(IDC_COMBO_TAGOPT, &CSettingGitRemote::OnCbnSelchangeComboTagOpt)
74 ON_BN_CLICKED(IDC_CHECK_PRUNE, &CSettingGitRemote::OnBnClickedCheckprune)
75 ON_BN_CLICKED(IDC_CHECK_PRUNEALL, &CSettingGitRemote::OnBnClickedCheckpruneall)
76 ON_BN_CLICKED(IDC_CHECK_PUSHDEFAULT, &CSettingGitRemote::OnBnClickedCheckpushdefault)
77 ON_BN_CLICKED(IDC_BUTTON_REMOVE, &CSettingGitRemote::OnBnClickedButtonRemove)
78 ON_BN_CLICKED(IDC_BUTTON_RENAME_REMOTE, &CSettingGitRemote::OnBnClickedButtonRenameRemote)
79 END_MESSAGE_MAP()
81 static void ShowEditBalloon(HWND hDlg, UINT nIdControl, UINT nIdText, UINT nIdTitle, int nIcon = TTI_WARNING)
83 CString text(MAKEINTRESOURCE(nIdText));
84 CString title(MAKEINTRESOURCE(nIdTitle));
85 EDITBALLOONTIP bt;
86 bt.cbStruct = sizeof(bt);
87 bt.pszText = text;
88 bt.pszTitle = title;
89 bt.ttiIcon = nIcon;
90 SendDlgItemMessage(hDlg, nIdControl, EM_SHOWBALLOONTIP, 0, (LPARAM)&bt);
93 #define TIMER_PREFILL 1
95 BOOL CSettingGitRemote::OnInitDialog()
97 ISettingsPropPage::OnInitDialog();
99 AdjustControlSize(IDC_CHECK_PRUNE);
100 AdjustControlSize(IDC_CHECK_PRUNEALL);
101 AdjustControlSize(IDC_CHECK_PUSHDEFAULT);
103 STRING_VECTOR remotes;
104 g_Git.GetRemoteList(remotes);
105 m_ctrlRemoteList.ResetContent();
106 for (size_t i = 0; i < remotes.size(); i++)
107 m_ctrlRemoteList.AddString(remotes[i]);
109 m_ctrlTagOpt.AddString(CString(MAKEINTRESOURCE(IDS_FETCH_REACHABLE)));
110 m_ctrlTagOpt.AddString(CString(MAKEINTRESOURCE(IDS_NONE)));
111 m_ctrlTagOpt.AddString(CString(MAKEINTRESOURCE(IDS_ALL)));
112 m_ctrlTagOpt.SetCurSel(0);
114 CString pruneAll = g_Git.GetConfigValue(_T("fetch.prune"));
115 m_bPruneAll = pruneAll == _T("true") ? TRUE : FALSE;
117 //this->GetDlgItem(IDC_EDIT_REMOTE)->EnableWindow(FALSE);
118 this->UpdateData(FALSE);
120 SetTimer(TIMER_PREFILL, 1000, nullptr);
121 return TRUE;
123 // CSettingGitRemote message handlers
125 void CSettingGitRemote::OnTimer(UINT_PTR nIDEvent)
127 if (nIDEvent == TIMER_PREFILL)
129 if (m_strRemote.IsEmpty() && m_ctrlRemoteList.GetCount() == 0)
131 ShowEditBalloon(m_hWnd, IDC_EDIT_URL, IDS_B_T_PREFILL_ORIGIN, IDS_HINT, TTI_INFO);
134 KillTimer(TIMER_PREFILL);
138 void CSettingGitRemote::OnBnClickedButtonBrowse()
140 CFileDialog dlg(TRUE, nullptr, nullptr, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, CString(MAKEINTRESOURCE(IDS_PUTTYKEYFILEFILTER)));
142 this->UpdateData();
143 INT_PTR ret = dlg.DoModal();
144 SetCurrentDirectory(g_Git.m_CurrentDir);
145 if (ret == IDOK)
147 this->m_strPuttyKeyfile = dlg.GetPathName();
148 this->UpdateData(FALSE);
149 OnEnChangeEditPuttyKey();
153 void CSettingGitRemote::OnBnClickedButtonAdd()
155 this->UpdateData();
157 if(m_strRemote.IsEmpty())
159 CMessageBox::Show(nullptr, IDS_PROC_GITCONFIG_REMOTEEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR);
160 return;
162 if(m_strUrl.IsEmpty())
164 CMessageBox::Show(nullptr, IDS_PROC_GITCONFIG_URLEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR);
165 return;
168 m_ChangedMask = REMOTE_NAME | REMOTE_URL | REMOTE_PUTTYKEY | REMOTE_TAGOPT | REMOTE_PRUNE | REMOTE_PRUNEALL | REMOTE_PUSHDEFAULT | REMOTE_PUSHURL;
169 if(IsRemoteExist(m_strRemote))
171 CString msg;
172 msg.Format(IDS_PROC_GITCONFIG_OVERWRITEREMOTE, (LPCTSTR)m_strRemote);
173 if (CMessageBox::Show(nullptr, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES)
174 m_ChangedMask &= ~REMOTE_NAME;
175 else
176 return;
179 this->OnApply();
182 BOOL CSettingGitRemote::IsRemoteExist(CString &remote)
184 CString str;
185 for(int i=0;i<m_ctrlRemoteList.GetCount();i++)
187 m_ctrlRemoteList.GetText(i,str);
188 if(str == remote)
189 return true;
191 return false;
194 struct CheckRefspecStruct
196 CStringA remote;
197 bool result;
200 static int CheckRemoteCollideWithRefspec(const git_config_entry *entry, void * payload)
202 auto crs = (CheckRefspecStruct *)payload;
203 crs->result = false;
204 if (entry->name == "remote." + crs->remote + ".fetch")
205 return 0;
206 CStringA value = CStringA(entry->value);
207 CStringA match = ":refs/remotes/" + crs->remote;
208 int pos = value.Find(match);
209 if (pos < 0)
210 return 0;
211 if ((pos + match.GetLength() == value.GetLength()) || (value[pos + match.GetLength()] == '/'))
213 crs->result = true;
214 return GIT_EUSER;
216 return 0;
219 bool CSettingGitRemote::IsRemoteCollideWithRefspec(CString remote)
221 CheckRefspecStruct crs = { CUnicodeUtils::GetUTF8(remote), false };
222 CAutoConfig config(true);
223 git_config_add_file_ondisk(config, CGit::GetGitPathStringA(g_Git.GetGitLocalConfig()), GIT_CONFIG_LEVEL_LOCAL, FALSE);
224 for (const auto pattern : { "remote\\..*\\.fetch", "svn-remote\\..*\\.fetch", "svn-remote\\..*\\.branches", "svn-remote\\..*\\.tags" })
226 git_config_foreach_match(config, pattern, CheckRemoteCollideWithRefspec, &crs);
227 if (crs.result)
228 return true;
230 return false;
233 void CSettingGitRemote::OnLbnSelchangeListRemote()
235 CWaitCursor wait;
237 if(m_ChangedMask)
239 if (CMessageBox::Show(GetSafeHwnd(), IDS_PROC_GITCONFIG_SAVEREMOTE, IDS_APPNAME, 1, IDI_QUESTION, IDS_SAVEBUTTON, IDS_DISCARDBUTTON) == 1)
240 OnApply();
242 SetModified(FALSE);
244 CString cmd,output;
245 int index;
246 index = this->m_ctrlRemoteList.GetCurSel();
247 if(index<0)
249 m_strUrl.Empty();
250 m_strPushUrl.Empty();
251 m_strRemote.Empty();
252 m_strPuttyKeyfile.Empty();
253 this->UpdateData(FALSE);
254 return;
256 CString remote;
257 m_ctrlRemoteList.GetText(index,remote);
258 this->m_strRemote=remote;
260 cmd.Format(_T("remote.%s.url"), (LPCTSTR)remote);
261 m_strUrl.Empty();
262 m_strUrl = g_Git.GetConfigValue(cmd);
264 cmd.Format(_T("remote.%s.pushurl"), (LPCTSTR)remote);
265 m_strPushUrl.Empty();
266 m_strPushUrl = g_Git.GetConfigValue(cmd);
268 cmd.Format(_T("remote.%s.puttykeyfile"), (LPCTSTR)remote);
270 this->m_strPuttyKeyfile = g_Git.GetConfigValue(cmd);
272 m_ChangedMask=0;
275 cmd.Format(_T("remote.%s.tagopt"), (LPCTSTR)remote);
276 CString tagopt = g_Git.GetConfigValue(cmd);
277 index = 0;
278 if (tagopt == "--no-tags")
279 index = 1;
280 else if (tagopt == "--tags")
281 index = 2;
282 m_ctrlTagOpt.SetCurSel(index);
284 CString pushDefault = g_Git.GetConfigValue(_T("remote.pushdefault"));
285 m_bPushDefault = pushDefault == remote ? TRUE : FALSE;
286 cmd.Format(_T("remote.%s.prune"), (LPCTSTR)remote);
287 CString prune = g_Git.GetConfigValue(cmd);
288 m_bPrune = prune == _T("true") ? TRUE : prune == _T("false") ? FALSE : 2;
289 CString pruneAll = g_Git.GetConfigValue(_T("fetch.prune"));
290 m_bPruneAll = pruneAll == _T("true") ? TRUE : FALSE;
292 GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(TRUE);
293 GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(TRUE);
294 GetDlgItem(IDC_BUTTON_RENAME_REMOTE)->EnableWindow(TRUE);
295 this->UpdateData(FALSE);
298 void CSettingGitRemote::OnEnChangeEditRemote()
300 m_ChangedMask|=REMOTE_NAME;
302 this->UpdateData();
304 if (IsRemoteCollideWithRefspec(m_strRemote))
305 ShowEditBalloon(m_hWnd, IDC_EDIT_REMOTE, IDS_B_T_REMOTE_NAME_COLLIDE, IDS_HINT, TTI_WARNING);
306 if( (!this->m_strRemote.IsEmpty())&&(!this->m_strUrl.IsEmpty()) )
307 this->SetModified();
310 void CSettingGitRemote::OnEnChangeEditUrl()
312 m_ChangedMask|=REMOTE_URL;
314 this->UpdateData();
316 if (m_strRemote.IsEmpty() && !m_strUrl.IsEmpty() && m_ctrlRemoteList.GetCount() == 0)
318 GetDlgItem(IDC_EDIT_REMOTE)->SetWindowText(_T("origin"));
319 OnEnChangeEditRemote();
322 if( (!this->m_strRemote.IsEmpty())&&(!this->m_strUrl.IsEmpty()) )
323 this->SetModified();
326 void CSettingGitRemote::OnEnChangeEditPushUrl()
328 m_ChangedMask |= REMOTE_PUSHURL;
330 this->UpdateData();
332 if (!this->m_strRemote.IsEmpty())
333 this->SetModified();
336 void CSettingGitRemote::OnEnChangeEditPuttyKey()
338 m_ChangedMask|=REMOTE_PUTTYKEY;
340 this->UpdateData();
341 if (!this->m_strUrl.IsEmpty())
342 this->SetModified();
345 void CSettingGitRemote::OnCbnSelchangeComboTagOpt()
347 m_ChangedMask |= REMOTE_TAGOPT;
349 this->UpdateData();
350 this->SetModified();
353 void CSettingGitRemote::OnBnClickedCheckprune()
355 m_ChangedMask |= REMOTE_PRUNE;
357 this->UpdateData();
358 this->SetModified();
361 void CSettingGitRemote::OnBnClickedCheckpruneall()
363 m_ChangedMask |= REMOTE_PRUNEALL;
364 UpdateData();
365 SetModified();
368 void CSettingGitRemote::OnBnClickedCheckpushdefault()
370 m_ChangedMask |= REMOTE_PUSHDEFAULT;
371 UpdateData();
372 SetModified();
375 BOOL CSettingGitRemote::Save(CString key,CString value)
377 CString cmd,out;
379 cmd.Format(_T("remote.%s.%s"), (LPCTSTR)m_strRemote, (LPCTSTR)key);
380 if (value.IsEmpty())
382 // don't check result code. it fails if the entry not exist
383 g_Git.UnsetConfigValue(cmd, CONFIG_LOCAL);
384 if (!g_Git.GetConfigValue(cmd).IsEmpty())
386 CString msg;
387 msg.Format(IDS_PROC_SAVECONFIGFAILED, (LPCTSTR)cmd, (LPCTSTR)value);
388 CMessageBox::Show(nullptr, msg, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
389 return FALSE;
391 return TRUE;
394 if (g_Git.SetConfigValue(cmd, value, CONFIG_LOCAL))
396 CString msg;
397 msg.Format(IDS_PROC_SAVECONFIGFAILED, (LPCTSTR)cmd, (LPCTSTR)value);
398 CMessageBox::Show(nullptr, msg, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
399 return FALSE;
401 return TRUE;
404 BOOL CSettingGitRemote::SaveGeneral(CString key, CString value)
406 if (value.IsEmpty())
408 // don't check result code. it fails if the entry not exist
409 g_Git.UnsetConfigValue(key, CONFIG_LOCAL);
410 if (!g_Git.GetConfigValue(key).IsEmpty())
412 CString msg;
413 msg.Format(IDS_PROC_SAVECONFIGFAILED, (LPCTSTR)key, (LPCTSTR)value);
414 CMessageBox::Show(nullptr, msg, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
415 return FALSE;
417 return TRUE;
420 if (g_Git.SetConfigValue(key, value, CONFIG_LOCAL))
422 CString msg;
423 msg.Format(IDS_PROC_SAVECONFIGFAILED, (LPCTSTR)key, (LPCTSTR)value);
424 CMessageBox::Show(nullptr, msg, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
425 return FALSE;
428 return TRUE;
431 BOOL CSettingGitRemote::OnApply()
433 CWaitCursor wait;
434 this->UpdateData();
436 if (m_ChangedMask & REMOTE_PUSHDEFAULT)
438 if (!m_strRemote.Trim().IsEmpty() && m_bPushDefault)
440 if (!SaveGeneral(_T("remote.pushdefault"), m_strRemote.Trim()))
441 return FALSE;
443 if (!m_bPushDefault)
445 if (!SaveGeneral(_T("remote.pushdefault"), _T("")))
446 return FALSE;
449 m_ChangedMask &= ~REMOTE_PUSHDEFAULT;
452 if (m_ChangedMask & REMOTE_PRUNEALL)
454 if (!SaveGeneral(_T("fetch.prune"), m_bPruneAll == TRUE ? _T("true") : _T("")))
455 return FALSE;
456 m_ChangedMask &= ~REMOTE_PRUNEALL;
459 if (m_ChangedMask && m_strRemote.Trim().IsEmpty())
461 CMessageBox::Show(nullptr, IDS_PROC_GITCONFIG_REMOTEEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR);
462 return FALSE;
465 if(m_ChangedMask & REMOTE_NAME)
467 //Add Remote
468 if(m_strRemote.IsEmpty())
470 CMessageBox::Show(nullptr, IDS_PROC_GITCONFIG_REMOTEEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR);
471 return FALSE;
473 if(m_strUrl.IsEmpty())
475 CMessageBox::Show(nullptr, IDS_PROC_GITCONFIG_URLEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR);
476 return FALSE;
479 if (m_ctrlRemoteList.GetCount() > 0)
481 // tagopt not --no-tags
482 if (m_ctrlTagOpt.GetCurSel() != 1)
484 if (CMessageBox::ShowCheck(GetSafeHwnd(), IDS_PROC_GITCONFIG_ASKTAGOPT, IDS_APPNAME, MB_YESNO | MB_ICONQUESTION, _T("TagOptNoTagsWarning"), IDS_MSGBOX_DONOTSHOWAGAIN) == IDYES)
486 m_ctrlTagOpt.SetCurSel(1);
487 m_ChangedMask |= REMOTE_TAGOPT;
492 m_strUrl.Replace(L'\\', L'/');
493 CString cmd,out;
494 cmd.Format(_T("git.exe remote add \"%s\" \"%s\""), (LPCTSTR)m_strRemote, (LPCTSTR)m_strUrl);
495 if (g_Git.Run(cmd, &out, CP_UTF8))
497 CMessageBox::Show(nullptr, out, _T("TorotiseGit"), MB_OK | MB_ICONERROR);
498 return FALSE;
500 m_ChangedMask &= ~REMOTE_URL;
502 m_ctrlRemoteList.SetCurSel(m_ctrlRemoteList.AddString(m_strRemote));
503 GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(TRUE);
504 GetDlgItem(IDC_BUTTON_RENAME_REMOTE)->EnableWindow(TRUE);
505 if (!m_bNoFetch && CMessageBox::Show(nullptr, IDS_SETTINGS_FETCH_ADDEDREMOTE, IDS_APPNAME, MB_ICONQUESTION | MB_YESNO) == IDYES)
506 CCommonAppUtils::RunTortoiseGitProc(_T("/command:fetch /path:\"") + g_Git.m_CurrentDir + _T("\" /remote:\"") + m_strRemote + _T("\""));
508 if(m_ChangedMask & REMOTE_URL)
510 m_strUrl.Replace(L'\\', L'/');
511 if (!Save(_T("url"),this->m_strUrl))
512 return FALSE;
515 if(m_ChangedMask & REMOTE_PUTTYKEY)
517 if (!Save(_T("puttykeyfile"),this->m_strPuttyKeyfile))
518 return FALSE;
521 if (m_ChangedMask & REMOTE_TAGOPT)
523 CString tagopt;
524 int index = m_ctrlTagOpt.GetCurSel();
525 if (index == 1)
526 tagopt = "--no-tags";
527 else if (index == 2)
528 tagopt = "--tags";
529 if (!Save(_T("tagopt"), tagopt))
530 return FALSE;
533 if (m_ChangedMask & REMOTE_PRUNE)
535 if (!Save(_T("prune"), m_bPrune == TRUE ? _T("true") : m_bPrune == FALSE ? _T("false") : _T("")))
536 return FALSE;
539 if (m_ChangedMask & REMOTE_PUSHURL)
541 m_strPushUrl.Replace(L'\\', L'/');
542 if (!Save(_T("pushurl"), m_strPushUrl))
543 return FALSE;
546 SetModified(FALSE);
548 m_ChangedMask = 0;
549 return ISettingsPropPage::OnApply();
552 void CleanupSyncRemotes(const CString& remote)
554 CString workingDir = g_Git.m_CurrentDir;
555 workingDir.Replace(_T(':'), _T('_'));
556 CHistoryCombo::RemoveEntryFromHistory(_T("Software\\TortoiseGit\\History\\SyncURL\\") + workingDir, _T("url"), remote);
559 void CSettingGitRemote::OnBnClickedButtonRemove()
561 int index;
562 index=m_ctrlRemoteList.GetCurSel();
563 if(index>=0)
565 CString str;
566 m_ctrlRemoteList.GetText(index,str);
567 CString msg;
568 msg.Format(IDS_WARN_REMOVE, (LPCTSTR)str);
569 if (CMessageBox::Show(nullptr, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES)
571 CString cmd,out;
572 cmd.Format(_T("git.exe remote rm %s"), (LPCTSTR)str);
573 if (g_Git.Run(cmd, &out, CP_UTF8))
575 CMessageBox::Show(nullptr, out,_T("TortoiseGit"), MB_OK | MB_ICONERROR);
576 return;
579 CleanupSyncRemotes(str);
580 m_ctrlRemoteList.DeleteString(index);
581 OnLbnSelchangeListRemote();
586 void CSettingGitRemote::OnBnClickedButtonRenameRemote()
588 int sel = m_ctrlRemoteList.GetCurSel();
589 if (sel >= 0)
591 CString oldRemote, newRemote;
592 m_ctrlRemoteList.GetText(sel, oldRemote);
593 GetDlgItem(IDC_EDIT_REMOTE)->GetWindowText(newRemote);
594 CString cmd, out;
595 cmd.Format(_T("git.exe remote rename %s %s"), (LPCTSTR)oldRemote, (LPCTSTR)newRemote);
596 if (g_Git.Run(cmd, &out, CP_UTF8))
598 CMessageBox::Show(nullptr, out, _T("TortoiseGit"), MB_OK | MB_ICONERROR);
599 return;
602 CleanupSyncRemotes(oldRemote);
603 m_ctrlRemoteList.DeleteString(sel);
604 m_ctrlRemoteList.SetCurSel(m_ctrlRemoteList.AddString(newRemote));
605 m_ChangedMask &= ~REMOTE_NAME;
606 if (!m_ChangedMask)
607 this->SetModified(FALSE);