void CFilePatchesDlg::PatchAll() { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_ALL))); progDlg.ShowModeless(m_hWnd); for (int i=0; i<m_arFileStates.GetCount() && !progDlg.HasUserCancelled(); i++) { if (m_arFileStates.GetAt(i) == FPDLG_FILESTATE_ERROR) MessageBox(m_pPatch->GetPatchRejects(i), NULL, MB_ICONERROR); else if (m_arFileStates.GetAt(i) != FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, GetFullPath(i), true); m_pCallBack->PatchFile(m_pPatch->GetStrippedPath(i), m_pPatch->GetContentMods(i), m_pPatch->GetPropMods(i), _T(""), TRUE); m_ShownIndex = i; m_cFileList.Invalidate(); } progDlg.SetProgress64(i, m_arFileStates.GetCount()); } progDlg.Stop(); } }
void CDeleteRemoteTagDlg::Refresh() { m_ctrlTags.DeleteAllItems(); m_SelectAll.SetCheck(BST_UNCHECKED); m_taglist.clear(); CSysProgressDlg sysProgressDlg; sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_LOADING))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.ShowModal(this, true); if (g_Git.GetRemoteTags(m_sRemote, m_taglist)) { sysProgressDlg.Stop(); MessageBox(g_Git.GetGitLastErr(L"Could not retrieve remote tags.", CGit::GIT_CMD_FETCH), L"TortoiseGit", MB_ICONERROR); } sysProgressDlg.Stop(); BringWindowToTop(); for (int i = 0; i < (int)m_taglist.size(); ++i) m_ctrlTags.InsertItem(i, m_taglist[i]); DialogEnableWindow(IDOK, FALSE); }
void CFilePatchesDlg::PatchSelected() { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_SELECTED))); progDlg.ShowModeless(m_hWnd); // The list cannot be sorted by user, so the order of the // items in the list is identical to the order in the array // m_arFileStates. int selCount = m_cFileList.GetSelectedCount(); int count = 1; POSITION pos = m_cFileList.GetFirstSelectedItemPosition(); int index; BOOL ret = TRUE; while (((index = m_cFileList.GetNextSelectedItem(pos)) >= 0) && (!progDlg.HasUserCancelled()) && ret == TRUE) { if (m_arFileStates.GetAt(index)!= FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, m_pPatch->GetFullPath(m_sPath, index), true); ret = m_pCallBack->PatchFile(index, true, false); } progDlg.SetProgress64(count++, selCount); } progDlg.Stop(); } }
void CDeleteRemoteTagDlg::OnBnClickedOk() { if (m_ctrlTags.GetSelectedCount() > 1) { CString msg; msg.Format(IDS_PROC_DELETENREFS, m_ctrlTags.GetSelectedCount()); if (CMessageBox::Show(m_hWnd, msg, _T("TortoiseGit"), 2, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_DELETEBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 2) return; } else // GetSelectedCount() is 1, otherwise the button is disabled { POSITION pos = m_ctrlTags.GetFirstSelectedItemPosition(); CString msg; msg.Format(IDS_PROC_DELETEBRANCHTAG, (LPCTSTR)m_taglist[(m_ctrlTags.GetNextSelectedItem(pos))]); if (CMessageBox::Show(m_hWnd, msg, _T("TortoiseGit"), 2, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_DELETEBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 2) return; } STRING_VECTOR list; POSITION pos = m_ctrlTags.GetFirstSelectedItemPosition(); int index; while ((index = m_ctrlTags.GetNextSelectedItem(pos)) >= 0) list.push_back(_T("refs/tags/") + m_taglist[index]); CSysProgressDlg sysProgressDlg; sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_DELETING_REMOTE_REFS))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.ShowModal(this, true); if (g_Git.DeleteRemoteRefs(m_sRemote, list)) CMessageBox::Show(m_hWnd, g_Git.GetGitLastErr(_T("Could not delete remote ref."), CGit::GIT_CMD_PUSH), _T("TortoiseGit"), MB_OK | MB_ICONERROR); sysProgressDlg.Stop(); BringWindowToTop(); Refresh(); }
void CFilePatchesDlg::PatchSelected() { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_SELECTED))); progDlg.ShowModeless(m_hWnd); // The list cannot be sorted by user, so the order of the // items in the list is identical to the order in the array // m_arFileStates. int selCount = m_cFileList.GetSelectedCount(); int count = 1; POSITION pos = m_cFileList.GetFirstSelectedItemPosition(); int index; while (((index = m_cFileList.GetNextSelectedItem(pos)) >= 0) && (!progDlg.HasUserCancelled())) { if (m_arFileStates.GetAt(index) == FPDLG_FILESTATE_ERROR) MessageBox(m_pPatch->GetPatchRejects(index), NULL, MB_ICONERROR); else if (m_arFileStates.GetAt(index) != FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, GetFullPath(index), true); m_pCallBack->PatchFile(m_pPatch->GetStrippedPath(index), m_pPatch->GetContentMods(index), m_pPatch->GetPropMods(index), _T(""), TRUE); m_ShownIndex = index; m_cFileList.Invalidate(); } progDlg.SetProgress64(count++, selCount); } progDlg.Stop(); } }
CString GitPatch::CheckPatchPath(const CString& path) { // first check if the path already matches if (CountMatches(path) > (GetNumberOfFiles() / 3)) return path; CSysProgressDlg progress; CString tmp; progress.SetTitle(IDS_PATCH_SEARCHPATHTITLE); progress.SetShowProgressBar(false); tmp.LoadString(IDS_PATCH_SEARCHPATHLINE1); progress.SetLine(1, tmp); progress.ShowModeless(AfxGetMainWnd()); // now go up the tree and try again CString upperpath = path; while (upperpath.ReverseFind('\\')>0) { upperpath = upperpath.Left(upperpath.ReverseFind('\\')); progress.SetLine(2, upperpath, true); if (progress.HasUserCancelled()) return path; if (CountMatches(upperpath) > (GetNumberOfFiles()/3)) return upperpath; } // still no match found. So try sub folders bool isDir = false; CString subpath; CDirFileEnum filefinder(path); while (filefinder.NextFile(subpath, &isDir)) { if (progress.HasUserCancelled()) return path; if (!isDir) continue; if (GitAdminDir::IsAdminDirPath(subpath)) continue; progress.SetLine(2, subpath, true); if (CountMatches(subpath) > (GetNumberOfFiles()/3)) return subpath; } // if a patch file only contains newly added files // we can't really find the correct path. // But: we can compare paths strings without the filenames // and check if at least those match upperpath = path; while (upperpath.ReverseFind('\\')>0) { upperpath = upperpath.Left(upperpath.ReverseFind('\\')); progress.SetLine(2, upperpath, true); if (progress.HasUserCancelled()) return path; if (CountDirMatches(upperpath) > (GetNumberOfFiles()/3)) return upperpath; } return path; }
bool RebaseCommand::Execute() { bool bRet =false; if(!g_Git.CheckCleanWorkTree()) { if (CMessageBox::Show(NULL, IDS_ERROR_NOCLEAN_STASH, IDS_APPNAME, 1, IDI_QUESTION, IDS_STASHBUTTON, IDS_ABORTBUTTON) == 1) { CSysProgressDlg sysProgressDlg; sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROC_STASHRUNNING))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.SetCancelMsg(IDS_PROGRS_INFOFAILED); sysProgressDlg.ShowModeless((HWND)NULL, true); CString cmd,out; cmd=_T("git.exe stash"); if (g_Git.Run(cmd, &out, CP_UTF8)) { sysProgressDlg.Stop(); CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK); return false; } sysProgressDlg.Stop(); } else { return false; } } while(1) { CRebaseDlg dlg; dlg.m_PostButtonTexts.Add(CString(MAKEINTRESOURCE(IDS_MENULOG))); dlg.m_PostButtonTexts.Add(CString(MAKEINTRESOURCE(IDS_PROC_RESTARTREBASE))); INT_PTR ret = dlg.DoModal(); if( ret == IDOK) { bRet=true; return bRet; } if( ret == IDCANCEL) { bRet=false; return bRet; } if (ret == IDC_REBASE_POST_BUTTON) { CString cmd = _T("/command:log"); cmd += _T(" /path:\"") + g_Git.m_CurrentDir + _T("\""); CAppUtils::RunTortoiseProc(cmd); return true; } } return bRet; }
bool CBrowseRefsDlg::DoDeleteRef(CString completeRefName) { bool bIsRemoteBranch = false; bool bIsBranch = false; if (wcsncmp(completeRefName, L"refs/remotes/",13) == 0) {bIsBranch = true; bIsRemoteBranch = true;} else if (wcsncmp(completeRefName, L"refs/heads/",11) == 0) {bIsBranch = true;} if (bIsRemoteBranch) { CString branchToDelete = completeRefName.Mid(13); CString remoteName, remoteBranchToDelete; if (SplitRemoteBranchName(branchToDelete, remoteName, remoteBranchToDelete)) return false; if (CAppUtils::IsSSHPutty()) CAppUtils::LaunchPAgent(NULL, &remoteName); CSysProgressDlg sysProgressDlg; sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_DELETING_REMOTE_REFS))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.ShowModal(this, true); STRING_VECTOR list; list.push_back(_T("refs/heads/") + remoteBranchToDelete); if (g_Git.DeleteRemoteRefs(remoteName, list)) { CMessageBox::Show(m_hWnd, g_Git.GetGitLastErr(_T("Could not delete remote ref."), CGit::GIT_CMD_PUSH), _T("TortoiseGit"), MB_OK | MB_ICONERROR); sysProgressDlg.Stop(); BringWindowToTop(); return false; } sysProgressDlg.Stop(); BringWindowToTop(); } else if (bIsBranch) { if (g_Git.DeleteRef(completeRefName)) { CMessageBox::Show(m_hWnd, g_Git.GetGitLastErr(L"Could not delete reference.", CGit::GIT_CMD_DELETETAGBRANCH), _T("TortoiseGit"), MB_OK | MB_ICONERROR); return false; } } else if (wcsncmp(completeRefName, L"refs/tags/", 10) == 0) { if (g_Git.DeleteRef(completeRefName)) { CMessageBox::Show(m_hWnd, g_Git.GetGitLastErr(L"Could not delete reference.", CGit::GIT_CMD_DELETETAGBRANCH), _T("TortoiseGit"), MB_OK | MB_ICONERROR); return false; } } return true; }
void SVNRebaseCommand::askIfUserWantsToStashPop() { if(CMessageBox::Show(NULL, IDS_DCOMMIT_STASH_POP, IDS_APPNAME, MB_YESNO|MB_ICONINFORMATION) == IDYES) { CSysProgressDlg sysProgressDlg; sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROC_STASHRUNNING))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.SetCancelMsg(IDS_PROGRS_INFOFAILED); sysProgressDlg.ShowModeless((HWND)NULL, true); CString cmd,out; cmd=_T("git.exe stash pop"); if (g_Git.Run(cmd, &out, CP_UTF8)) { sysProgressDlg.Stop(); CMessageBox::Show(NULL,out,_T("TortoiseGit"), MB_OK); } sysProgressDlg.Stop(); } }
void CDeleteRemoteTagDlg::Refresh() { m_ctrlTags.DeleteAllItems(); m_SelectAll.SetCheck(BST_UNCHECKED); m_taglist.clear(); CSysProgressDlg sysProgressDlg; sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_LOADING))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.ShowModal(this, true); g_Git.GetRemoteTags(m_sRemote, m_taglist); sysProgressDlg.Stop(); for (int i = 0; i < (int)m_taglist.size(); ++i) { m_ctrlTags.InsertItem(i, m_taglist[i]); } DialogEnableWindow(IDOK, FALSE); }
void CDeleteRemoteTagDlg::OnBnClickedOk() { if (m_ctrlTags.GetSelectedCount() > 1) { CString msg; msg.Format(IDS_PROC_DELETENREFS, m_ctrlTags.GetSelectedCount()); if (CMessageBox::Show(m_hWnd, msg, _T("TortoiseGit"), 2, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_DELETEBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 2) return; } else // GetSelectedCount() is 1, otherwise the button is disabled { POSITION pos = m_ctrlTags.GetFirstSelectedItemPosition(); CString msg; msg.Format(IDS_PROC_DELETEBRANCHTAG, m_taglist[(m_ctrlTags.GetNextSelectedItem(pos))]); if (CMessageBox::Show(m_hWnd, msg, _T("TortoiseGit"), 2, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_DELETEBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 2) return; } CMassiveGitTask mgtPush(_T("push ") + m_sRemote, FALSE); POSITION pos = m_ctrlTags.GetFirstSelectedItemPosition(); int index; while ((index = m_ctrlTags.GetNextSelectedItem(pos)) >= 0) { mgtPush.AddFile(_T(":refs/tags/") + m_taglist[index]); } CSysProgressDlg sysProgressDlg; sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_DELETING_REMOTE_REFS))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.ShowModal(this, true); BOOL cancel = FALSE; mgtPush.Execute(cancel); sysProgressDlg.Stop(); Refresh(); }
void CFilePatchesDlg::PatchAll() { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_ALL))); progDlg.ShowModeless(m_hWnd); BOOL ret = TRUE; for (int i=0; i<m_arFileStates.GetCount() && !progDlg.HasUserCancelled() && ret == TRUE; i++) { if (m_arFileStates.GetAt(i)!= FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, m_pPatch->GetFullPath(m_sPath, i), true); ret = m_pCallBack->PatchFile(i, true, false); } progDlg.SetProgress64(i, m_arFileStates.GetCount()); } progDlg.Stop(); } }
bool SVNRebaseCommand::Execute() { if (!GitAdminDir::HasAdminDir(g_Git.m_CurrentDir)) { CMessageBox::Show(GetExplorerHWND(), IDS_NOWORKINGCOPY, IDS_APPNAME, MB_ICONERROR); return false; } bool isStash = false; if(!g_Git.CheckCleanWorkTree()) { if (CMessageBox::Show(GetExplorerHWND(), g_Git.m_CurrentDir + L"\r\n" + CString(MAKEINTRESOURCE(IDS_ERROR_NOCLEAN_STASH)), L"TortoiseGit", 1, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_STASHBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 1) { CSysProgressDlg sysProgressDlg; sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROC_STASHRUNNING))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.SetCancelMsg(IDS_PROGRS_INFOFAILED); sysProgressDlg.ShowModeless(static_cast<HWND>(nullptr), true); CString out; if (g_Git.Run(L"git.exe stash", &out, CP_UTF8)) { sysProgressDlg.Stop(); MessageBox(GetExplorerHWND(), out, L"TortoiseGit", MB_OK | MB_ICONERROR); return false; } sysProgressDlg.Stop(); isStash = true; } else { return false; } } CRebaseDlg dlg; // dlg.m_PreCmd=L"git.exe svn fetch"; CString out, err; if (!g_Git.Run(L"git.exe config svn-remote.svn.fetch", &out, &err, CP_UTF8)) { int start = out.Find(L':'); if( start >=0 ) out=out.Mid(start); if (CStringUtils::StartsWith(out, L":refs")) out = out.Mid(static_cast<int>(wcslen(L":refs")) + 1); start = 0; out = out.Tokenize(L"\n", start); } else { MessageBox(GetExplorerHWND(), L"Could not get \"svn-remote.svn.fetch\" config value.\n" + out + L'\n' + err, L"TortoiseGit", MB_OK | MB_ICONERROR); return false; } dlg.m_Upstream=out; CGitHash UpStreamOldHash,HeadHash,UpStreamNewHash; if (g_Git.GetHash(UpStreamOldHash, out)) { MessageBox(GetExplorerHWND(), g_Git.GetGitLastErr(L"Could not get hash of SVN branch."), L"TortoiseGit", MB_ICONERROR); return false; } if (g_Git.GetHash(HeadHash, L"HEAD")) { MessageBox(GetExplorerHWND(), g_Git.GetGitLastErr(L"Could not get HEAD hash."), L"TortoiseGit", MB_ICONERROR); return false; } CProgressDlg progress; progress.m_GitCmd = L"git.exe svn fetch"; progress.m_AutoClose = AUTOCLOSE_IF_NO_ERRORS; if(progress.DoModal()!=IDOK) return false; if(progress.m_GitStatus) return false; if (g_Git.GetHash(UpStreamNewHash, out)) { MessageBox(GetExplorerHWND(), g_Git.GetGitLastErr(L"Could not get upstream hash after fetching."), L"TortoiseGit", MB_ICONERROR); return false; } //everything updated if(UpStreamNewHash==HeadHash) { MessageBox(GetExplorerHWND(), g_Git.m_CurrentDir + L"\r\n" + CString(MAKEINTRESOURCE(IDS_PROC_EVERYTHINGUPDATED)), L"TortoiseGit", MB_OK | MB_ICONQUESTION); if(isStash) askIfUserWantsToStashPop(); return true; } //fast forward; if (g_Git.IsFastForward(L"HEAD", out)) { CProgressDlg progressReset; CString cmd; cmd.Format(L"git.exe reset --hard %s --", static_cast<LPCTSTR>(out)); progressReset.m_GitCmd = cmd; progressReset.m_AutoClose = AUTOCLOSE_IF_NO_ERRORS; if (progressReset.DoModal() != IDOK) return false; else { MessageBox(GetExplorerHWND(), g_Git.m_CurrentDir + L"\r\n" + CString(MAKEINTRESOURCE(IDS_PROC_FASTFORWARD)) + L":\n" + progressReset.m_LogText, L"TortoiseGit", MB_OK | MB_ICONQUESTION); if(isStash) askIfUserWantsToStashPop(); return true; } } dlg.m_PostButtonTexts.Add(CString(MAKEINTRESOURCE(IDS_MENULOG))); //need rebase INT_PTR response = dlg.DoModal(); if (response == IDOK || response == IDC_REBASE_POST_BUTTON) { if(isStash) askIfUserWantsToStashPop(); if (response == IDC_REBASE_POST_BUTTON) { CString cmd = L"/command:log"; cmd += L" /path:\"" + g_Git.m_CurrentDir + L'"'; CAppUtils::RunTortoiseGitProc(cmd); } return true; } return false; }
bool CleanupCommand::Execute() { bool bRet = false; CCleanTypeDlg dlg; if( dlg.DoModal() == IDOK) { bool quotepath = g_Git.GetConfigValueBool(_T("core.quotepath")); CString cmd; cmd.Format(_T("git clean")); if (dlg.m_bDryRun || !dlg.m_bNoRecycleBin) cmd += _T(" -n "); if(dlg.m_bDir) cmd += _T(" -d "); switch(dlg.m_CleanType) { case 0: cmd += _T(" -fx"); break; case 1: cmd += _T(" -f"); break; case 2: cmd += _T(" -fX"); break; } if (dlg.m_bDryRun || dlg.m_bNoRecycleBin) { CProgressDlg progress; for (int i = 0; i < this->pathList.GetCount(); ++i) { CString path; if (this->pathList[i].IsDirectory()) path = pathList[i].GetGitPathString(); else path = pathList[i].GetContainingDirectory().GetGitPathString(); progress.m_GitCmdList.push_back(cmd + _T(" \"") + path + _T("\"")); } if (progress.DoModal()==IDOK) return TRUE; } else { CSysProgressDlg sysProgressDlg; sysProgressDlg.SetAnimation(IDR_CLEANUPANI); sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROC_CLEANUP_INFO1))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.ShowModeless((HWND)NULL, true); CString cmdout, cmdouterr; if (g_Git.Run(cmd, &cmdout, &cmdouterr, CP_UTF8)) { MessageBox(NULL, cmdouterr, _T("TortoiseGit"), MB_ICONERROR); return FALSE; } if (sysProgressDlg.HasUserCancelled()) { CMessageBox::Show(NULL, IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_OK); return FALSE; } int pos = 0; CString token = cmdout.Tokenize(_T("\n"), pos); CTGitPathList delList; while (!token.IsEmpty()) { if (token.Mid(0, 13) == _T("Would remove ")) { CString tempPath = token.Mid(13).TrimRight(); if (quotepath) { tempPath = UnescapeQuotePath(tempPath.Trim(_T('"'))); } delList.AddPath(CTGitPath(tempPath)); } token = cmdout.Tokenize(_T("\n"), pos); } if (sysProgressDlg.HasUserCancelled()) { CMessageBox::Show(NULL, IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_OK); return FALSE; } delList.DeleteAllFiles(true, false); sysProgressDlg.Stop(); } } #if 0 CProgressDlg progress; progress.SetTitle(IDS_PROC_CLEANUP); progress.SetAnimation(IDR_CLEANUPANI); progress.SetShowProgressBar(false); progress.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROC_CLEANUP_INFO1))); progress.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROC_CLEANUP_INFO2))); progress.ShowModeless(hwndExplorer); CString strSuccessfullPaths, strFailedPaths; for (int i=0; i<pathList.GetCount(); ++i) { SVN svn; if (!svn.CleanUp(pathList[i])) { strFailedPaths += _T("- ") + pathList[i].GetWinPathString() + _T("\n"); strFailedPaths += svn.GetLastErrorMessage() + _T("\n\n"); } else { strSuccessfullPaths += _T("- ") + pathList[i].GetWinPathString() + _T("\n"); // after the cleanup has finished, crawl the path downwards and send a change // notification for every directory to the shell. This will update the // overlays in the left tree view of the explorer. CDirFileEnum crawler(pathList[i].GetWinPathString()); CString sPath; bool bDir = false; CTSVNPathList updateList; while (crawler.NextFile(sPath, &bDir)) { if ((bDir) && (!g_SVNAdminDir.IsAdminDirPath(sPath))) { updateList.AddPath(CTSVNPath(sPath)); } } updateList.AddPath(pathList[i]); CShellUpdater::Instance().AddPathsForUpdate(updateList); CShellUpdater::Instance().Flush(); updateList.SortByPathname(true); for (INT_PTR i=0; i<updateList.GetCount(); ++i) { SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, updateList[i].GetWinPath(), NULL); ATLTRACE(_T("notify change for path %s\n"), updateList[i].GetWinPath()); } } } progress.Stop(); CString strMessage; if ( !strSuccessfullPaths.IsEmpty() ) { CString tmp; tmp.Format(IDS_PROC_CLEANUPFINISHED, (LPCTSTR)strSuccessfullPaths); strMessage += tmp; bRet = true; } if ( !strFailedPaths.IsEmpty() ) { if (!strMessage.IsEmpty()) strMessage += _T("\n"); CString tmp; tmp.Format(IDS_PROC_CLEANUPFINISHED_FAILED, (LPCTSTR)strFailedPaths); strMessage += tmp; bRet = false; } CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseGit"), MB_OK | (strFailedPaths.IsEmpty()?MB_ICONINFORMATION:MB_ICONERROR)); #endif CShellUpdater::Instance().Flush(); return bRet; }
void CFilePatchesDlg::OnNMRclickFilelist(NMHDR * /*pNMHDR*/, LRESULT *pResult) { *pResult = 0; if (m_sPath.IsEmpty()) return; CString temp; CMenu popup; POINT point; DWORD ptW = GetMessagePos(); point.x = GET_X_LPARAM(ptW); point.y = GET_Y_LPARAM(ptW); if (popup.CreatePopupMenu()) { UINT nFlags; nFlags = MF_STRING | (m_cFileList.GetSelectedCount()==1 ? MF_ENABLED : MF_DISABLED | MF_GRAYED); temp.LoadString(IDS_PATCH_REVIEW); popup.AppendMenu(nFlags, ID_PATCH_REVIEW, temp); popup.SetDefaultItem(ID_PATCH_REVIEW, FALSE); temp.LoadString(IDS_PATCH_PREVIEW); popup.AppendMenu(nFlags, ID_PATCHPREVIEW, temp); temp.LoadString(IDS_PATCH_ALL); popup.AppendMenu(MF_STRING | MF_ENABLED, ID_PATCHALL, temp); nFlags = MF_STRING | (m_cFileList.GetSelectedCount()>0 ? MF_ENABLED : MF_DISABLED | MF_GRAYED); temp.LoadString(IDS_PATCH_SELECTED); popup.AppendMenu(nFlags, ID_PATCHSELECTED, temp); // if the context menu is invoked through the keyboard, we have to use // a calculated position on where to anchor the menu on if ((point.x == -1) && (point.y == -1)) { CRect rect; GetWindowRect(&rect); point = rect.CenterPoint(); } bool bReview=false; int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0); switch (cmd) { case ID_PATCH_REVIEW: bReview = true; //go through case case ID_PATCHPREVIEW: { if (m_pCallBack) { int nIndex = m_cFileList.GetSelectionMark(); if ( m_arFileStates.GetAt(nIndex)!=FPDLG_FILESTATE_PATCHED) { m_pCallBack->PatchFile(GetFullPath(nIndex), m_pPatch->GetRevision(nIndex),false,bReview); } } } break; case ID_PATCHALL: { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_ALL))); progDlg.ShowModeless(m_hWnd); for (int i=0; i<m_arFileStates.GetCount() && !progDlg.HasUserCancelled(); i++) { if (m_arFileStates.GetAt(i)!= FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, GetFullPath(i), true); m_pCallBack->PatchFile(GetFullPath(i), m_pPatch->GetRevision(i), TRUE); } progDlg.SetProgress64(i, m_arFileStates.GetCount()); } progDlg.Stop(); } } break; case ID_PATCHSELECTED: { if (m_pCallBack) { CSysProgressDlg progDlg; progDlg.SetTitle(IDR_MAINFRAME); progDlg.SetShowProgressBar(true); progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PATCH_SELECTED))); progDlg.ShowModeless(m_hWnd); // The list cannot be sorted by user, so the order of the // items in the list is identical to the order in the array // m_arFileStates. int selCount = m_cFileList.GetSelectedCount(); int count = 1; POSITION pos = m_cFileList.GetFirstSelectedItemPosition(); int index; while (((index = m_cFileList.GetNextSelectedItem(pos)) >= 0) && (!progDlg.HasUserCancelled())) { if (m_arFileStates.GetAt(index)!= FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, GetFullPath(index), true); m_pCallBack->PatchFile(GetFullPath(index), m_pPatch->GetRevision(index), TRUE); } progDlg.SetProgress64(count++, selCount); } progDlg.Stop(); } } break; default: break; } } }
bool CBrowseRefsDlg::DoDeleteRef(CString completeRefName, bool bForce) { bool bIsRemoteBranch = false; bool bIsBranch = false; if (wcsncmp(completeRefName, L"refs/remotes/",13) == 0) {bIsBranch = true; bIsRemoteBranch = true;} else if (wcsncmp(completeRefName, L"refs/heads/",11) == 0) {bIsBranch = true;} if(bIsBranch) { CString branchToDelete = completeRefName.Mid(bIsRemoteBranch ? 13 : 11); CString cmd; if(bIsRemoteBranch) { CString remoteName, remoteBranchToDelete; if (SplitRemoteBranchName(branchToDelete, remoteName, remoteBranchToDelete)) return false; if(CAppUtils::IsSSHPutty()) { CAppUtils::LaunchPAgent(NULL, &remoteName); } cmd.Format(L"git.exe push \"%s\" :refs/heads/%s", remoteName, remoteBranchToDelete); } else cmd.Format(L"git.exe branch -%c -- %s",bForce?L'D':L'd',branchToDelete); CSysProgressDlg sysProgressDlg; if (bIsRemoteBranch) { sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_DELETING_REMOTE_REFS))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.ShowModal(this, true); } CString errorMsg; if(g_Git.Run(cmd,&errorMsg,CP_UTF8)!=0) { CMessageBox::Show(m_hWnd, errorMsg, _T("TortoiseGit"), MB_OK | MB_ICONERROR); if (bIsRemoteBranch) sysProgressDlg.Stop(); BringWindowToTop(); return false; } if (bIsRemoteBranch) sysProgressDlg.Stop(); BringWindowToTop(); } else if (wcsncmp(completeRefName, L"refs/tags/", 10) == 0) { CString tagToDelete = completeRefName.Mid(10); CString cmd; cmd.Format(L"git.exe tag -d -- %s",tagToDelete); CString errorMsg; if(g_Git.Run(cmd,&errorMsg,CP_UTF8)!=0) { CMessageBox::Show(m_hWnd, errorMsg, _T("TortoiseGit"), MB_OK | MB_ICONERROR); return false; } } return true; }
static bool DoCleanUp(const CTGitPathList& pathList, int cleanType, bool bDir, bool bSubmodules, bool bDryRun, bool bNoRecycleBin) { CString cmd; cmd.Format(_T("git.exe clean")); if (bDryRun || !bNoRecycleBin) cmd += _T(" -n "); if (bDir) cmd += _T(" -d "); switch (cleanType) { case 0: cmd += _T(" -fx"); break; case 1: cmd += _T(" -f"); break; case 2: cmd += _T(" -fX"); break; } STRING_VECTOR submoduleList; if (bSubmodules) { SubmodulePayload payload(submoduleList); payload.basePath = CTGitPath(g_Git.m_CurrentDir).GetGitPathString(); if (pathList.GetCount() != 1 || pathList.GetCount() == 1 && !pathList[0].IsEmpty()) { for (int i = 0; i < pathList.GetCount(); ++i) { CString path; if (pathList[i].IsDirectory()) payload.prefixList.push_back(pathList[i].GetGitPathString()); else payload.prefixList.push_back(pathList[i].GetContainingDirectory().GetGitPathString()); } } if (!GetSubmodulePathList(payload)) return false; std::sort(submoduleList.begin(), submoduleList.end()); } if (bDryRun || bNoRecycleBin) { CProgressDlg progress; for (int i = 0; i < pathList.GetCount(); ++i) { CString path; if (pathList[i].IsDirectory()) path = pathList[i].GetGitPathString(); else path = pathList[i].GetContainingDirectory().GetGitPathString(); progress.m_GitDirList.push_back(g_Git.m_CurrentDir); progress.m_GitCmdList.push_back(cmd + _T(" -- \"") + path + _T("\"")); } for (CString dir : submoduleList) { progress.m_GitDirList.push_back(CTGitPath(dir).GetWinPathString()); progress.m_GitCmdList.push_back(cmd); } progress.m_PostCmdCallback = [&](DWORD status, PostCmdList& postCmdList) { if (status) postCmdList.push_back(PostCmd(IDS_MSGBOX_RETRY, [&] { DoCleanUp(pathList, cleanType, bDir, bSubmodules, bDryRun, bNoRecycleBin); })); if (status || !bDryRun) return; if (bNoRecycleBin) { postCmdList.push_back(PostCmd(IDS_CLEAN_NO_RECYCLEBIN, [&] { DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, TRUE); })); postCmdList.push_back(PostCmd(IDS_CLEAN_TO_RECYCLEBIN, [&] { DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, FALSE); })); } else { postCmdList.push_back(PostCmd(IDS_CLEAN_TO_RECYCLEBIN, [&] { DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, FALSE); })); postCmdList.push_back(PostCmd(IDS_CLEAN_NO_RECYCLEBIN, [&] { DoCleanUp(pathList, cleanType, bDir, bSubmodules, FALSE, TRUE); })); } }; INT_PTR result = progress.DoModal(); return result == IDOK; } else { CSysProgressDlg sysProgressDlg; sysProgressDlg.SetAnimation(IDR_CLEANUPANI); sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROC_CLEANUP_INFO1))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.ShowModeless((HWND)NULL, true); bool quotepath = g_Git.GetConfigValueBool(_T("core.quotepath")); CTGitPathList delList; for (int i = 0; i < pathList.GetCount(); ++i) { CString path; if (pathList[i].IsDirectory()) path = pathList[i].GetGitPathString(); else path = pathList[i].GetContainingDirectory().GetGitPathString(); if (!GetFilesToCleanUp(delList, cmd, &g_Git, path, quotepath, sysProgressDlg)) return false; } for (CString dir : submoduleList) { CGit git; git.m_CurrentDir = dir; if (!GetFilesToCleanUp(delList, cmd, &git, _T(""), quotepath, sysProgressDlg)) return false; } delList.DeleteAllFiles(true, false, true); sysProgressDlg.Stop(); } return true; }
int CGitLogList::DeleteRef(const CString& ref) { CString shortname; if (CGit::GetShortName(ref, shortname, _T("refs/remotes/"))) { CString msg; msg.Format(IDS_PROC_DELETEREMOTEBRANCH, (LPCTSTR)ref); int result = CMessageBox::Show(nullptr, msg, _T("TortoiseGit"), 3, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_PROC_DELETEREMOTEBRANCH_LOCALREMOTE)), CString(MAKEINTRESOURCE(IDS_PROC_DELETEREMOTEBRANCH_LOCAL)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))); if (result == 1) { CString remoteName = shortname.Left(shortname.Find(L'/')); shortname = shortname.Mid(shortname.Find(L'/') + 1); if (CAppUtils::IsSSHPutty()) CAppUtils::LaunchPAgent(nullptr, &remoteName); CSysProgressDlg sysProgressDlg; sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_DELETING_REMOTE_REFS))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.ShowModal(this, true); STRING_VECTOR list; list.push_back(_T("refs/heads/") + shortname); if (g_Git.DeleteRemoteRefs(remoteName, list)) CMessageBox::Show(nullptr, g_Git.GetGitLastErr(_T("Could not delete remote ref."), CGit::GIT_CMD_PUSH), _T("TortoiseGit"), MB_OK | MB_ICONERROR); sysProgressDlg.Stop(); return TRUE; } else if (result == 2) { if (g_Git.DeleteRef(ref)) { CMessageBox::Show(nullptr, g_Git.GetGitLastErr(L"Could not delete reference.", CGit::GIT_CMD_DELETETAGBRANCH), _T("TortoiseGit"), MB_OK | MB_ICONERROR); return FALSE; } return TRUE; } return FALSE; } else if (CGit::GetShortName(ref, shortname, _T("refs/stash"))) { CString err; std::vector<GitRevLoglist> stashList; size_t count = !GitRevLoglist::GetRefLog(ref, stashList, err) ? stashList.size() : 0; CString msg; msg.Format(IDS_PROC_DELETEALLSTASH, count); if (CMessageBox::Show(nullptr, msg, _T("TortoiseGit"), 2, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_DELETEBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 1) { CString sCmd; sCmd.Format(_T("git.exe stash clear")); CString out; if (g_Git.Run(sCmd, &out, CP_UTF8)) CMessageBox::Show(nullptr, out, _T("TortoiseGit"), MB_OK | MB_ICONERROR); return TRUE; } return FALSE; } CString msg; msg.Format(IDS_PROC_DELETEBRANCHTAG, (LPCTSTR)ref); if (CMessageBox::Show(nullptr, msg, _T("TortoiseGit"), 2, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_DELETEBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 1) { if (g_Git.DeleteRef(ref)) { CMessageBox::Show(nullptr, g_Git.GetGitLastErr(L"Could not delete reference.", CGit::GIT_CMD_DELETETAGBRANCH), _T("TortoiseGit"), MB_OK | MB_ICONERROR); return FALSE; } return TRUE; } return FALSE; }
bool CleanupCommand::Execute() { bool bRet = false; CCleanTypeDlg dlg; if( dlg.DoModal() == IDOK) { bool quotepath = g_Git.GetConfigValueBool(_T("core.quotepath")); CString cmd; cmd.Format(_T("git.exe clean")); if (dlg.m_bDryRun || !dlg.m_bNoRecycleBin) cmd += _T(" -n "); if(dlg.m_bDir) cmd += _T(" -d "); switch(dlg.m_CleanType) { case 0: cmd += _T(" -fx"); break; case 1: cmd += _T(" -f"); break; case 2: cmd += _T(" -fX"); break; } STRING_VECTOR submoduleList; SubmodulePayload payload(submoduleList); if (dlg.m_bSubmodules) { payload.basePath = CTGitPath(g_Git.m_CurrentDir).GetGitPathString(); if (pathList.GetCount() != 1 || pathList.GetCount() == 1 && !pathList[0].IsEmpty()) { for (int i = 0; i < pathList.GetCount(); ++i) { CString path; if (pathList[i].IsDirectory()) payload.prefixList.push_back(pathList[i].GetGitPathString()); else payload.prefixList.push_back(pathList[i].GetContainingDirectory().GetGitPathString()); } } if (!GetSubmodulePathList(payload)) return FALSE; std::sort(submoduleList.begin(), submoduleList.end()); } if (dlg.m_bDryRun || dlg.m_bNoRecycleBin) { while (true) { CProgressDlg progress; for (int i = 0; i < this->pathList.GetCount(); ++i) { CString path; if (this->pathList[i].IsDirectory()) path = pathList[i].GetGitPathString(); else path = pathList[i].GetContainingDirectory().GetGitPathString(); progress.m_GitDirList.push_back(g_Git.m_CurrentDir); progress.m_GitCmdList.push_back(cmd + _T(" \"") + path + _T("\"")); } if (dlg.m_bSubmodules) { for (CString dir : submoduleList) { progress.m_GitDirList.push_back(CTGitPath(dir).GetWinPathString()); progress.m_GitCmdList.push_back(cmd); } } INT_PTR idRetry = -1; if (!dlg.m_bDryRun) idRetry = progress.m_PostFailCmdList.Add(CString(MAKEINTRESOURCE(IDS_MSGBOX_RETRY))); INT_PTR result = progress.DoModal(); if (result == IDOK) return TRUE; if (progress.m_GitStatus && result == IDC_PROGRESS_BUTTON1 + idRetry) continue; break; } } else { CSysProgressDlg sysProgressDlg; sysProgressDlg.SetAnimation(IDR_CLEANUPANI); sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROC_CLEANUP_INFO1))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.ShowModeless((HWND)NULL, true); CTGitPathList delList; for (size_t i = 0; i <= submoduleList.size(); ++i) { CGit git; CGit *pGit; if (i == 0) pGit = &g_Git; else { git.m_CurrentDir = submoduleList[i - 1]; pGit = &git; } CString cmdout, cmdouterr; if (pGit->Run(cmd, &cmdout, &cmdouterr, CP_UTF8)) { MessageBox(nullptr, cmdouterr, _T("TortoiseGit"), MB_ICONERROR); return FALSE; } if (sysProgressDlg.HasUserCancelled()) { CMessageBox::Show(nullptr, IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_OK); return FALSE; } int pos = 0; CString token = cmdout.Tokenize(_T("\n"), pos); while (!token.IsEmpty()) { if (token.Mid(0, 13) == _T("Would remove ")) { CString tempPath = token.Mid(13).TrimRight(); if (quotepath) { tempPath = UnescapeQuotePath(tempPath.Trim(_T('"'))); } if (i == 0) delList.AddPath(CTGitPath(tempPath)); else delList.AddPath(CTGitPath(submoduleList[i - 1] + "/" + tempPath)); } token = cmdout.Tokenize(_T("\n"), pos); } if (sysProgressDlg.HasUserCancelled()) { CMessageBox::Show(nullptr, IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_OK); return FALSE; } } delList.DeleteAllFiles(true, false); sysProgressDlg.Stop(); } } #if 0 CProgressDlg progress; progress.SetTitle(IDS_PROC_CLEANUP); progress.SetAnimation(IDR_CLEANUPANI); progress.SetShowProgressBar(false); progress.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROC_CLEANUP_INFO1))); progress.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROC_CLEANUP_INFO2))); progress.ShowModeless(hwndExplorer); CString strSuccessfullPaths, strFailedPaths; for (int i=0; i<pathList.GetCount(); ++i) { SVN svn; if (!svn.CleanUp(pathList[i])) { strFailedPaths += _T("- ") + pathList[i].GetWinPathString() + _T("\n"); strFailedPaths += svn.GetLastErrorMessage() + _T("\n\n"); } else { strSuccessfullPaths += _T("- ") + pathList[i].GetWinPathString() + _T("\n"); // after the cleanup has finished, crawl the path downwards and send a change // notification for every directory to the shell. This will update the // overlays in the left tree view of the explorer. CDirFileEnum crawler(pathList[i].GetWinPathString()); CString sPath; bool bDir = false; CTSVNPathList updateList; while (crawler.NextFile(sPath, &bDir)) { if ((bDir) && (!g_SVNAdminDir.IsAdminDirPath(sPath))) { updateList.AddPath(CTSVNPath(sPath)); } } updateList.AddPath(pathList[i]); CShellUpdater::Instance().AddPathsForUpdate(updateList); CShellUpdater::Instance().Flush(); updateList.SortByPathname(true); for (INT_PTR i=0; i<updateList.GetCount(); ++i) { SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, updateList[i].GetWinPath(), NULL); CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": notify change for path %s\n"), updateList[i].GetWinPath()); } } } progress.Stop(); CString strMessage; if ( !strSuccessfullPaths.IsEmpty() ) { CString tmp; tmp.Format(IDS_PROC_CLEANUPFINISHED, (LPCTSTR)strSuccessfullPaths); strMessage += tmp; bRet = true; } if ( !strFailedPaths.IsEmpty() ) { if (!strMessage.IsEmpty()) strMessage += _T("\n"); CString tmp; tmp.Format(IDS_PROC_CLEANUPFINISHED_FAILED, (LPCTSTR)strFailedPaths); strMessage += tmp; bRet = false; } CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseGit"), MB_OK | (strFailedPaths.IsEmpty()?MB_ICONINFORMATION:MB_ICONERROR)); #endif CShellUpdater::Instance().Flush(); return bRet; }
bool SVNRebaseCommand::Execute() { bool isStash = false; if(!g_Git.CheckCleanWorkTree()) { if (CMessageBox::Show(hwndExplorer, g_Git.m_CurrentDir + L"\r\n" + CString(MAKEINTRESOURCE(IDS_ERROR_NOCLEAN_STASH)), L"TortoiseGit", 1, IDI_QUESTION, CString(MAKEINTRESOURCE(IDS_STASHBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 1) { CSysProgressDlg sysProgressDlg; sysProgressDlg.SetTitle(CString(MAKEINTRESOURCE(IDS_APPNAME))); sysProgressDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROC_STASHRUNNING))); sysProgressDlg.SetLine(2, CString(MAKEINTRESOURCE(IDS_PROGRESSWAIT))); sysProgressDlg.SetShowProgressBar(false); sysProgressDlg.SetCancelMsg(IDS_PROGRS_INFOFAILED); sysProgressDlg.ShowModeless((HWND)NULL, true); CString cmd,out; cmd=_T("git.exe stash"); if (g_Git.Run(cmd, &out, CP_UTF8)) { sysProgressDlg.Stop(); MessageBox(hwndExplorer, out, _T("TortoiseGit"), MB_OK | MB_ICONERROR); return false; } sysProgressDlg.Stop(); isStash = true; } else { return false; } } CRebaseDlg dlg; // dlg.m_PreCmd=_T("git.exe svn fetch"); CString cmd, out, err; cmd = _T("git.exe config svn-remote.svn.fetch"); if (!g_Git.Run(cmd, &out, &err, CP_UTF8)) { int start = out.Find(_T(':')); if( start >=0 ) out=out.Mid(start); if(out.Left(5) == _T(":refs")) out=out.Mid(6); start = 0; out=out.Tokenize(_T("\n"),start); } else { MessageBox(hwndExplorer, out + L"\n" + err, L"TortoiseGit", MB_OK | MB_ICONERROR); return false; } dlg.m_Upstream=out; CGitHash UpStreamOldHash,HeadHash,UpStreamNewHash; if (g_Git.GetHash(UpStreamOldHash, out)) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get hash of SVN branch.")), _T("TortoiseGit"), MB_ICONERROR); return false; } if (g_Git.GetHash(HeadHash, _T("HEAD"))) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get HEAD hash.")), _T("TortoiseGit"), MB_ICONERROR); return false; } CProgressDlg progress; progress.m_GitCmd=_T("git.exe svn fetch"); progress.m_AutoClose = AUTOCLOSE_IF_NO_ERRORS; if(progress.DoModal()!=IDOK) return false; if(progress.m_GitStatus) return false; if (g_Git.GetHash(UpStreamNewHash, out)) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get upstream hash after fetching.")), _T("TortoiseGit"), MB_ICONERROR); return false; } //everything updated if(UpStreamNewHash==HeadHash) { MessageBox(hwndExplorer, g_Git.m_CurrentDir + _T("\r\n") + CString(MAKEINTRESOURCE(IDS_PROC_EVERYTHINGUPDATED)), _T("TortoiseGit"), MB_OK | MB_ICONQUESTION); if(isStash) askIfUserWantsToStashPop(); return true; } //fast forward; if(g_Git.IsFastForward(CString(_T("HEAD")),out)) { CProgressDlg progressReset; cmd.Format(_T("git.exe reset --hard %s --"), (LPCTSTR)out); progressReset.m_GitCmd = cmd; progressReset.m_AutoClose = AUTOCLOSE_IF_NO_ERRORS; if (progressReset.DoModal() != IDOK) return false; else { MessageBox(hwndExplorer, g_Git.m_CurrentDir + _T("\r\n") + CString(MAKEINTRESOURCE(IDS_PROC_FASTFORWARD)) + _T(":\n") + progressReset.m_LogText, _T("TortoiseGit"), MB_OK | MB_ICONQUESTION); if(isStash) askIfUserWantsToStashPop(); return true; } } dlg.m_PostButtonTexts.Add(CString(MAKEINTRESOURCE(IDS_MENULOG))); //need rebase INT_PTR response = dlg.DoModal(); if (response == IDOK || response == IDC_REBASE_POST_BUTTON) { if(isStash) askIfUserWantsToStashPop(); if (response == IDC_REBASE_POST_BUTTON) { cmd = _T("/command:log"); cmd += _T(" /path:\"") + g_Git.m_CurrentDir + _T("\""); CAppUtils::RunTortoiseGitProc(cmd); } return true; } return false; }