void CRepositoryBrowser::OnBnClickedButtonRevision() { // use the git log to allow selection of a version CLogDlg dlg; dlg.SetParams(CTGitPath(), CTGitPath(), m_sRevision, m_sRevision, 0); // tell the dialog to use mode for selecting revisions dlg.SetSelect(true); // only one revision must be selected however dlg.SingleSelection(true); if (dlg.DoModal() == IDOK) { // get selected hash if any m_sRevision = dlg.GetSelectedHash(); Refresh(); } }
void CFormatPatchDlg::OnBnClickedButtonTo() { CLogDlg dlg; CString revision; m_cTo.GetWindowText(revision); dlg.SetParams(CTGitPath(), CTGitPath(), revision, revision, 0); // tell the dialog to use mode for selecting revisions dlg.SetSelect(true); // only one revision must be selected however dlg.SingleSelection(true); if ( dlg.DoModal() == IDOK ) { m_cTo.AddString(dlg.GetSelectedHash().at(0).ToString()); CheckRadioButton(IDC_RADIO_SINCE, IDC_RADIO_RANGE, IDC_RADIO_RANGE); OnBnClickedRadio(); } }
void CRequestPullDlg::OnBnClickedButtonLocalBranch() { // use the git log to allow selection of a version CLogDlg dlg; CString revision; m_cStartRevision.GetWindowText(revision); dlg.SetParams(CTGitPath(), CTGitPath(), revision, revision, 0); // tell the dialog to use mode for selecting revisions dlg.SetSelect(true); // only one revision must be selected however dlg.SingleSelection(true); if ( dlg.DoModal() == IDOK ) { // get selected hash if any CString selectedHash = dlg.GetSelectedHash(); // load into window, do this even if empty so that it is clear that nothing has been selected m_cStartRevision.SetWindowText( selectedHash ); } }
void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs) { CIconMenu popupMenu; popupMenu.CreatePopupMenu(); bool bAddSeparator = false; CString remoteName; if(selectedLeafs.size()==1) { bAddSeparator = true; bool bShowReflogOption = false; bool bShowFetchOption = false; bool bShowRenameOption = false; bool bShowCreateBranchOption = false; bool bShowEditBranchDescriptionOption = false; CString fetchFromCmd; if(selectedLeafs[0]->IsFrom(L"refs/heads/")) { bShowReflogOption = true; bShowRenameOption = true; bShowEditBranchDescriptionOption = true; } else if(selectedLeafs[0]->IsFrom(L"refs/remotes/")) { bShowReflogOption = true; bShowFetchOption = true; bShowCreateBranchOption = true; CString remoteBranch; if (SplitRemoteBranchName(selectedLeafs[0]->GetRefName(), remoteName, remoteBranch)) bShowFetchOption = false; else fetchFromCmd.Format(IDS_PROC_BROWSEREFS_FETCHFROM, (LPCTSTR)remoteName); } else if(selectedLeafs[0]->IsFrom(L"refs/tags/")) { } CString temp; temp.LoadString(IDS_MENULOG); popupMenu.AppendMenuIcon(eCmd_ViewLog, temp, IDI_LOG); popupMenu.AppendMenuIcon(eCmd_RepoBrowser, IDS_LOG_BROWSEREPO, IDI_REPOBROWSE); if(bShowReflogOption) { temp.LoadString(IDS_MENUREFLOG); popupMenu.AppendMenuIcon(eCmd_ShowReflog, temp, IDI_LOG); } popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; if(bShowFetchOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Fetch, fetchFromCmd, IDI_PULL); } if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; if (m_bHasWC) { CString str; if (selectedLeafs[0]->GetRefName() != _T("refs/heads/") + g_Git.GetCurrentBranch()) { str.Format(IDS_LOG_POPUP_MERGEREV, (LPCTSTR)g_Git.GetCurrentBranch()); popupMenu.AppendMenuIcon(eCmd_Merge, str, IDI_MERGE); } popupMenu.AppendMenuIcon(eCmd_Switch, CString(MAKEINTRESOURCE(IDS_SWITCH_TO_THIS)), IDI_SWITCH); popupMenu.AppendMenu(MF_SEPARATOR); } if(bShowCreateBranchOption) { bAddSeparator = true; temp.LoadString(IDS_MENUBRANCH); popupMenu.AppendMenuIcon(eCmd_CreateBranch, temp, IDI_COPY); } if (bShowEditBranchDescriptionOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_EditBranchDescription, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_EDITDESCRIPTION)), IDI_RENAME); } if(bShowRenameOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Rename, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_RENAME)), IDI_RENAME); } if (m_bHasWC && selectedLeafs[0]->IsFrom(L"refs/heads/")) { if (bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = true; if (!selectedLeafs[0]->m_csUpstream.IsEmpty()) popupMenu.AppendMenuIcon(eCmd_UpstreamDrop, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_DROPTRACKEDBRANCH))); popupMenu.AppendMenuIcon(eCmd_UpstreamSet, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_SETTRACKEDBRANCH))); } } else if(selectedLeafs.size() == 2) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Diff, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_COMPAREREFS)), IDI_DIFF); popupMenu.AppendMenuIcon(eCmd_UnifiedDiff, CString(MAKEINTRESOURCE(IDS_LOG_POPUP_GNUDIFF)), IDI_DIFF); CString menu; menu.Format(IDS_SHOWLOG_OF, (LPCTSTR)GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T(".."))); popupMenu.AppendMenuIcon(eCmd_ViewLogRange, menu, IDI_LOG); menu.Format(IDS_SHOWLOG_OF, (LPCTSTR)GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T("..."))); popupMenu.AppendMenuIcon(eCmd_ViewLogRangeReachableFromOnlyOne, menu, IDI_LOG); } if(!selectedLeafs.empty()) { if(AreAllFrom(selectedLeafs, L"refs/remotes/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETEREMOTEBRANCH); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETEREMOTEBRANCHES, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteRemoteBranch, menuItemName, IDI_DELETE); bAddSeparator = true; } else if(AreAllFrom(selectedLeafs, L"refs/heads/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETEBRANCH); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETEBRANCHES, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteBranch, menuItemName, IDI_DELETE); bAddSeparator = true; } else if(AreAllFrom(selectedLeafs, L"refs/tags/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETETAG); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETETAGS, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteTag, menuItemName, IDI_DELETE); bAddSeparator = true; } } if(hTreePos!=NULL && selectedLeafs.empty()) { CShadowTree* pTree=(CShadowTree*)m_RefTreeCtrl.GetItemData(hTreePos); if(pTree->IsFrom(L"refs/remotes")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); popupMenu.AppendMenuIcon(eCmd_ManageRemotes, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_MANAGEREMOTES)), IDI_SETTINGS); bAddSeparator = true; if(selectedLeafs.empty()) { CString remoteBranch; if (SplitRemoteBranchName(pTree->GetRefName(), remoteName, remoteBranch)) remoteName = _T(""); int pos = findVectorPosition(remotes, remoteName); if (pos >= 0) { CString temp; temp.Format(IDS_PROC_BROWSEREFS_FETCHFROM, (LPCTSTR)remoteName); popupMenu.AppendMenuIcon(eCmd_Fetch, temp, IDI_PULL); temp.LoadString(IDS_DELETEREMOTETAG); popupMenu.AppendMenuIcon(eCmd_DeleteRemoteTag | (pos << 16), temp, IDI_DELETE); } } } if(pTree->IsFrom(L"refs/heads")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString temp; temp.LoadString(IDS_MENUBRANCH); popupMenu.AppendMenuIcon(eCmd_CreateBranch, temp, IDI_COPY); } if(pTree->IsFrom(L"refs/tags")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString temp; temp.LoadString(IDS_MENUTAG); popupMenu.AppendMenuIcon(eCmd_CreateTag, temp, IDI_TAG); temp.LoadString(IDS_PROC_BROWSEREFS_DELETEALLTAGS); popupMenu.AppendMenuIcon(eCmd_DeleteAllTags, temp, IDI_DELETE); if (!remotes.empty()) { popupMenu.AppendMenu(MF_SEPARATOR); int i = 0; for (auto it = remotes.cbegin(); it != remotes.cend(); ++it, ++i) { temp.Format(IDS_DELETEREMOTETAGON, (LPCTSTR)*it); popupMenu.AppendMenuIcon(eCmd_DeleteRemoteTag | (i << 16), temp, IDI_DELETE); } } } } int selection = popupMenu.TrackPopupMenuEx(TPM_LEFTALIGN | TPM_RETURNCMD, point.x, point.y, this, 0); switch ((eCmd)(selection & 0xFFFF)) { case eCmd_ViewLog: { CLogDlg dlg; dlg.SetRange(g_Git.FixBranchName(selectedLeafs[0]->GetRefName())); dlg.DoModal(); } break; case eCmd_ViewLogRange: { CLogDlg dlg; dlg.SetRange(GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T(".."))); dlg.DoModal(); } break; case eCmd_ViewLogRangeReachableFromOnlyOne: { CLogDlg dlg; dlg.SetRange(GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T("..."))); dlg.DoModal(); } break; case eCmd_RepoBrowser: CAppUtils::RunTortoiseGitProc(_T("/command:repobrowser /path:\"") + g_Git.m_CurrentDir + _T("\" /rev:") + selectedLeafs[0]->GetRefName()); break; case eCmd_DeleteBranch: case eCmd_DeleteRemoteBranch: { if(ConfirmDeleteRef(selectedLeafs)) DoDeleteRefs(selectedLeafs); Refresh(); } break; case eCmd_DeleteTag: { if(ConfirmDeleteRef(selectedLeafs)) DoDeleteRefs(selectedLeafs); Refresh(); } break; case eCmd_ShowReflog: { CRefLogDlg refLogDlg(this); refLogDlg.m_CurrentBranch = selectedLeafs[0]->GetRefName(); refLogDlg.DoModal(); } break; case eCmd_Fetch: { CAppUtils::Fetch(remoteName); Refresh(); } break; case eCmd_DeleteRemoteTag: { CDeleteRemoteTagDlg deleteRemoteTagDlg; int remoteInx = selection >> 16; if (remoteInx < 0 || remoteInx >= remotes.size()) return; deleteRemoteTagDlg.m_sRemote = remotes[remoteInx]; deleteRemoteTagDlg.DoModal(); } break; case eCmd_Merge: { CString ref = selectedLeafs[0]->GetRefName(); CAppUtils::Merge(&ref); } break; case eCmd_Switch: { CAppUtils::Switch(selectedLeafs[0]->GetRefName()); } break; case eCmd_Rename: { POSITION pos = m_ListRefLeafs.GetFirstSelectedItemPosition(); if(pos != NULL) m_ListRefLeafs.EditLabel(m_ListRefLeafs.GetNextSelectedItem(pos)); } break; case eCmd_AddRemote: { CAddRemoteDlg(this).DoModal(); Refresh(); } break; case eCmd_ManageRemotes: { CSinglePropSheetDlg(CString(MAKEINTRESOURCE(IDS_PROCS_TITLE_GITREMOTESETTINGS)), new CSettingGitRemote(), this).DoModal(); // CSettingGitRemote W_Remotes(m_cmdPath); // W_Remotes.DoModal(); Refresh(); } break; case eCmd_CreateBranch: { CString *commitHash = NULL; if (selectedLeafs.size() == 1) commitHash = &(selectedLeafs[0]->m_csRefHash); CAppUtils::CreateBranchTag(false, commitHash); Refresh(); } break; case eCmd_CreateTag: { CAppUtils::CreateBranchTag(true); Refresh(); } break; case eCmd_DeleteAllTags: { for (int i = 0; i < m_ListRefLeafs.GetItemCount(); ++i) { m_ListRefLeafs.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED); selectedLeafs.push_back((CShadowTree*)m_ListRefLeafs.GetItemData(i)); } if (ConfirmDeleteRef(selectedLeafs)) DoDeleteRefs(selectedLeafs); Refresh(); } break; case eCmd_Diff: { CFileDiffDlg dlg; dlg.SetDiff( NULL, selectedLeafs[1]->GetRefName() + L"^{}", selectedLeafs[0]->GetRefName() + L"^{}"); dlg.DoModal(); } break; case eCmd_UnifiedDiff: { CAppUtils::StartShowUnifiedDiff(nullptr, CTGitPath(), selectedLeafs[0]->m_csRefHash, CTGitPath(), selectedLeafs[1]->m_csRefHash); } break; case eCmd_EditBranchDescription: { CInputDlg dlg; dlg.m_sHintText.LoadString(IDS_PROC_BROWSEREFS_EDITDESCRIPTION); dlg.m_sInputText = selectedLeafs[0]->m_csDescription; dlg.m_sTitle.LoadString(IDS_PROC_BROWSEREFS_EDITDESCRIPTION); dlg.m_bUseLogWidth = true; if(dlg.DoModal() == IDOK) { CString key; key.Format(_T("branch.%s.description"), (LPCTSTR)selectedLeafs[0]->GetRefsHeadsName()); dlg.m_sInputText.Replace(_T("\r"), _T("")); dlg.m_sInputText.Trim(); if (dlg.m_sInputText.IsEmpty()) g_Git.UnsetConfigValue(key); else g_Git.SetConfigValue(key, dlg.m_sInputText); Refresh(); } } break; case eCmd_UpstreamDrop: { CString key; key.Format(_T("branch.%s.remote"), (LPCTSTR)selectedLeafs[0]->GetRefsHeadsName()); g_Git.UnsetConfigValue(key); key.Format(_T("branch.%s.merge"), (LPCTSTR)selectedLeafs[0]->GetRefsHeadsName()); g_Git.UnsetConfigValue(key); } Refresh(); break; case eCmd_UpstreamSet: { CString newRef = CBrowseRefsDlg::PickRef(false, _T(""), gPickRef_Remote, false); if (newRef.IsEmpty() || newRef.Find(_T("refs/remotes/")) != 0) return; CString remote, branch; if (SplitRemoteBranchName(newRef, remote, branch)) return; CString key; key.Format(_T("branch.%s.remote"), (LPCTSTR)selectedLeafs[0]->GetRefsHeadsName()); g_Git.SetConfigValue(key, remote); key.Format(_T("branch.%s.merge"), (LPCTSTR)selectedLeafs[0]->GetRefsHeadsName()); g_Git.SetConfigValue(key, _T("refs/heads/") + branch); Refresh(); } break; } }
bool SVNFetchCommand::Execute() { 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, L"Found no SVN remote.", L"TortoiseGit", MB_OK | MB_ICONERROR); return false; } CGitHash upstreamOldHash; if (g_Git.GetHash(upstreamOldHash, out)) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get upstream hash.")), _T("TortoiseGit"), MB_ICONERROR); return false; } CProgressDlg progress; progress.m_GitCmd=_T("git.exe svn fetch"); CGitHash upstreamNewHash; // declare outside lambda, because it is captured by reference progress.m_PostCmdCallback = [&](DWORD status, PostCmdList& postCmdList) { if (status) return; if (g_Git.GetHash(upstreamNewHash, out)) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get upstream hash after fetching.")), _T("TortoiseGit"), MB_ICONERROR); return; } if (upstreamOldHash == upstreamNewHash) return; postCmdList.emplace_back(IDI_DIFF, _T("Fetched Diff"), [&] { CLogDlg dlg; dlg.SetParams(CTGitPath(_T("")), CTGitPath(_T("")), _T(""), upstreamOldHash.ToString() + _T("..") + upstreamNewHash.ToString(), 0); dlg.DoModal(); }); postCmdList.emplace_back(IDI_LOG, _T("Fetched Log"), [&] { CFileDiffDlg dlg; dlg.SetDiff(nullptr, upstreamNewHash.ToString(), upstreamOldHash.ToString()); dlg.DoModal(); }); }; return progress.DoModal() == IDOK; }
void CFileDiffDlg::OnBnClickedLog() { CLogDlg dlg; dlg.SetRange(m_rev2.m_CommitHash.ToString() + _T("..") + m_rev1.m_CommitHash.ToString()); dlg.DoModal(); }
void CFileDiffDlg::ClickRevButton(CMenuButton *button, GitRev *rev, CACEdit *edit) { INT_PTR entry=button->GetCurrentEntry(); if(entry == 0) /* Browse Refence*/ { { CString str = CBrowseRefsDlg::PickRef(); if(str.IsEmpty()) return; if(FillRevFromString(rev,str)) return; edit->SetWindowText(str); } } if(entry == 1) /*Log*/ { CLogDlg dlg; CString revision; edit->GetWindowText(revision); dlg.SetParams(CTGitPath(), CTGitPath(), revision, revision, 0); dlg.SetSelect(true); if(dlg.DoModal() == IDOK) { if (dlg.GetSelectedHash().empty()) return; if (FillRevFromString(rev, dlg.GetSelectedHash().at(0).ToString())) return; edit->SetWindowText(dlg.GetSelectedHash().at(0).ToString()); } else return; } if(entry == 2) /*RefLog*/ { CRefLogDlg dlg; if(dlg.DoModal() == IDOK) { if(FillRevFromString(rev,dlg.m_SelectedHash)) return; edit->SetWindowText(dlg.m_SelectedHash); } else return; } SetURLLabels(); InterlockedExchange(&m_bThreadRunning, TRUE); if (AfxBeginThread(DiffThreadEntry, this)==NULL) { InterlockedExchange(&m_bThreadRunning, FALSE); CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR); } KillTimer(IDT_INPUT); }
void CxpGbaDlg::OnOK() { CString logpath; GetRootDir(logpath); logpath += "\\gxplog.txt"; FILE *fp= fopen(logpath, "w"); if(fp) log_init(LOG_STATUS, fp); if(Validate() == FALSE) { if(fp) { log_exit(); fclose(fp); } return; } GritShared *grs= mgr->shared; // Read external tileset if required // PONDER: move inside grit_run? if(mgr->gfxIsShared) { // read file grs->dib= dib_load(grs->tilePath, NULL); if(grs->dib) { if( dib_get_bpp(grs->dib) != 8 ) { lprintf(LOG_WARNING, " External tileset must be 8bpp. Converting.\n"); dib_convert(grs->dib, 8, 0); } if( dib_get_width(grs->dib) != 8 ) { lprintf(LOG_WARNING, " External tileset not tiled yet. Doing so now.\n"); dib_redim(grs->dib, 8, 8, 0); } } else lprintf(LOG_WARNING, " Couldn't load external tileset from \n %s.\n", grs->tilePath); // PONDER: reduce here too? } int res= grit_run(mgr); // Save external tileset if required // PONDER: move inside grit_run? if(mgr->gfxIsShared) { if( !dib_save(grs->dib, grs->tilePath, NULL) ) lprintf(LOG_WARNING, " Couldn't save external tileset to \n %s.\n", grs->tilePath); } if(fp) { log_exit(); fclose(fp); } if(res == TRUE) { // PONDER: ask to see log? res= MessageBox("Export succeeded. Show log?", NULL, MB_ICONINFORMATION | MB_YESNO | MB_DEFBUTTON2); if(res == IDYES) { CLogDlg dlg; dlg.SetTextFromFile(logpath); dlg.DoModal(); } CDialog::OnOK(); } else { // PONDER: ask to see log? res= MessageBox("Export failed. Show Log?", NULL, MB_ICONEXCLAMATION | MB_YESNO); if(res == IDYES) { CLogDlg dlg; dlg.SetTextFromFile(logpath); dlg.DoModal(); } } }
bool PullCommand::Execute() { if (!GitAdminDir().HasAdminDir(g_Git.m_CurrentDir)) { CMessageBox::Show(hwndExplorer, IDS_NOWORKINGCOPY, IDS_APPNAME, MB_ICONERROR); return false; } CPullFetchDlg dlg; dlg.m_IsPull=TRUE; if(dlg.DoModal()==IDOK) { CString url; url=dlg.m_RemoteURL; if(dlg.m_bAutoLoad) { CAppUtils::LaunchPAgent(NULL,&dlg.m_RemoteURL); } CString cmd; CGitHash hashOld; if (g_Git.GetHash(hashOld, _T("HEAD"))) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get HEAD hash.")), _T("TortoiseGit"), MB_ICONERROR); return false; } CString cmdRebase; if(dlg.m_bRebase) cmdRebase = "--rebase "; CString noff; CString ffonly; CString squash; CString nocommit; CString notags; if (!dlg.m_bFetchTags) notags = _T("--no-tags"); if(dlg.m_bNoFF) noff=_T("--no-ff"); if (dlg.m_bFFonly) ffonly = _T("--ff-only"); if(dlg.m_bSquash) squash=_T("--squash"); if(dlg.m_bNoCommit) nocommit=_T("--no-commit"); int ver = CAppUtils::GetMsysgitVersion(); if(ver >= 0x01070203) //above 1.7.0.2 cmdRebase += _T("--progress "); cmd.Format(_T("git.exe pull -v %s %s %s %s %s %s \"%s\" %s"), cmdRebase, noff, ffonly, squash, nocommit, notags, url, dlg.m_RemoteBranchName); CProgressDlg progress; progress.m_GitCmd = cmd; progress.m_PostCmdList.Add(CString(MAKEINTRESOURCE(IDS_PROC_PULL_DIFFS))); progress.m_PostCmdList.Add(CString(MAKEINTRESOURCE(IDS_PROC_PULL_LOG))); CTGitPath gitPath = g_Git.m_CurrentDir; if (gitPath.HasSubmodules()) progress.m_PostCmdList.Add(CString(MAKEINTRESOURCE(IDS_PROC_SUBMODULESUPDATE))); //progress.m_PostCmdList.Add(_T("Show Conflict")); if (parser.HasVal(_T("closeonend"))) progress.m_bAutoCloseOnSuccess = !!parser.GetLongVal(_T("closeonend")); INT_PTR ret = progress.DoModal(); if (ret == IDOK && progress.m_GitStatus == 1 && progress.m_LogText.Find(_T("CONFLICT")) >= 0 && CMessageBox::Show(NULL, IDS_SEECHANGES, IDS_APPNAME, MB_YESNO | MB_ICONINFORMATION) == IDYES) { CChangedDlg dlg; dlg.m_pathList.AddPath(CTGitPath()); dlg.DoModal(); return FALSE; } CGitHash hashNew; if (g_Git.GetHash(hashNew, L"HEAD")) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get HEAD hash after pulling.")), _T("TortoiseGit"), MB_ICONERROR); return FALSE; } if( ret == IDC_PROGRESS_BUTTON1) { if(hashOld == hashNew) { if(progress.m_GitStatus == 0) CMessageBox::Show(NULL, IDS_UPTODATE, IDS_APPNAME, MB_OK | MB_ICONINFORMATION); return TRUE; } CFileDiffDlg dlg; dlg.SetDiff(NULL, hashNew.ToString(), hashOld.ToString()); dlg.DoModal(); return TRUE; } else if ( ret == IDC_PROGRESS_BUTTON1 +1 ) { if(hashOld == hashNew) { if(progress.m_GitStatus == 0) CMessageBox::Show(NULL, IDS_UPTODATE, IDS_APPNAME, MB_OK | MB_ICONINFORMATION); return TRUE; } CLogDlg dlg; //dlg.SetParams(cmdLinePath); dlg.SetParams(CTGitPath(_T("")), CTGitPath(_T("")), _T(""), hashOld.ToString() + _T("..") + hashNew.ToString(), 0); // dlg.SetIncludeMerge(!!parser.HasKey(_T("merge"))); // val = parser.GetVal(_T("propspath")); // if (!val.IsEmpty()) // dlg.SetProjectPropertiesPath(CTSVNPath(val)); dlg.DoModal(); } else if (ret == IDC_PROGRESS_BUTTON1 + 2 && gitPath.HasSubmodules()) { CString sCmd; sCmd.Format(_T("/command:subupdate /bkpath:\"%s\""), g_Git.m_CurrentDir); CAppUtils::RunTortoiseGitProc(sCmd); } } return FALSE; }
bool SVNFetchCommand::Execute() { bool autoClose = false; if (parser.HasVal(_T("closeonend"))) autoClose = !!parser.GetLongVal(_T("closeonend")); 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 { CMessageBox::Show(NULL, _T("Found no SVN remote."), _T("TortoiseGit"), MB_OK|MB_ICONERROR); return false; } CString upstreamOldHash, upstreamNewHash; upstreamOldHash = g_Git.GetHash(out); CProgressDlg progress; progress.m_GitCmd=_T("git.exe svn fetch"); progress.m_PostCmdList.Add(_T("Fetched Diff")); progress.m_PostCmdList.Add(_T("Fetched Log")); progress.m_bAutoCloseOnSuccess = autoClose; int userResponse = progress.DoModal(); upstreamNewHash = g_Git.GetHash(out); if (userResponse == IDC_PROGRESS_BUTTON1) { if (upstreamOldHash == upstreamNewHash) { if (progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"No new revisions fetched.", L"TortoiseGit Fetch", MB_OK | MB_ICONINFORMATION); return TRUE; } CLogDlg dlg; dlg.SetParams(CTGitPath(_T("")), CTGitPath(_T("")), _T(""), upstreamOldHash, upstreamNewHash, 0); dlg.DoModal(); return TRUE; } else if (userResponse == IDC_PROGRESS_BUTTON1 + 1) { if (upstreamOldHash == upstreamNewHash) { if (progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"No new revisions fetched.", L"TortoiseGit Fetch", MB_OK | MB_ICONINFORMATION); return TRUE; } CFileDiffDlg dlg; dlg.SetDiff(NULL, upstreamNewHash, upstreamOldHash); dlg.DoModal(); return TRUE; } else return false; return true; }
bool PullCommand::Execute() { CPullFetchDlg dlg; dlg.m_IsPull=TRUE; if(dlg.DoModal()==IDOK) { CString url; url=dlg.m_RemoteURL; if(dlg.m_bAutoLoad) { CAppUtils::LaunchPAgent(NULL,&dlg.m_RemoteURL); } CString cmd; CString hashOld = g_Git.GetHash(L"HEAD"); CString cmdRebase; if(dlg.m_bRebase) cmdRebase = "--rebase "; CString noff; CString ffonly; CString squash; CString nocommit; if(dlg.m_bNoFF) noff=_T("--no-ff"); if (dlg.m_bFFonly) ffonly = _T("--ff-only"); if(dlg.m_bSquash) squash=_T("--squash"); if(dlg.m_bNoCommit) nocommit=_T("--no-commit"); int ver = CAppUtils::GetMsysgitVersion(); if(ver >= 0x01070203) //above 1.7.0.2 cmdRebase += _T("--progress "); cmd.Format(_T("git.exe pull -v %s %s %s %s %s \"%s\" %s"), cmdRebase, noff, ffonly, squash, nocommit, url, dlg.m_RemoteBranchName); CProgressDlg progress; progress.m_GitCmd = cmd; progress.m_PostCmdList.Add(_T("Pulled Diff")); progress.m_PostCmdList.Add(_T("Pulled Log")); CTGitPath gitPath = g_Git.m_CurrentDir; if (gitPath.HasSubmodules()) progress.m_PostCmdList.Add(_T("Update submodules")); //progress.m_PostCmdList.Add(_T("Show Conflict")); if (parser.HasVal(_T("closeonend"))) progress.m_bAutoCloseOnSuccess = !!parser.GetLongVal(_T("closeonend")); int ret = progress.DoModal(); CString hashNew = g_Git.GetHash(L"HEAD"); if( ret == IDC_PROGRESS_BUTTON1) { if(hashOld == hashNew) { if(progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"Already up to date.", L"Pull", MB_OK | MB_ICONINFORMATION); return TRUE; } CFileDiffDlg dlg; dlg.SetDiff(NULL, hashNew, hashOld); dlg.DoModal(); return TRUE; } else if ( ret == IDC_PROGRESS_BUTTON1 +1 ) { if(hashOld == hashNew) { if(progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"Already up to date.", L"Pull", MB_OK | MB_ICONINFORMATION); return TRUE; } CLogDlg dlg; //dlg.SetParams(cmdLinePath); dlg.SetParams(CTGitPath(_T("")),CTGitPath(_T("")),_T(""), hashOld, hashNew, 0); // dlg.SetIncludeMerge(!!parser.HasKey(_T("merge"))); // val = parser.GetVal(_T("propspath")); // if (!val.IsEmpty()) // dlg.SetProjectPropertiesPath(CTSVNPath(val)); dlg.DoModal(); } else if (ret == IDC_PROGRESS_BUTTON1 + 2 && gitPath.HasSubmodules()) { CString sCmd; sCmd.Format(_T("/command:subupdate /bkpath:\"%s\""), g_Git.m_CurrentDir); CAppUtils::RunTortoiseProc(sCmd); } } #if 0 CCloneDlg dlg; dlg.m_Directory=this->orgCmdLinePath.GetWinPathString(); if(dlg.DoModal()==IDOK) { CString dir=dlg.m_Directory; CString url=dlg.m_URL; CString cmd; cmd.Format(_T("git.exe clone %s %s"), url, dir); CProgressDlg progress; progress.m_GitCmd=cmd; if(progress.DoModal()==IDOK) return TRUE; } #endif return FALSE; }
void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs) { CIconMenu popupMenu; popupMenu.CreatePopupMenu(); bool bAddSeparator = false; CString remoteName; if(selectedLeafs.size()==1) { bAddSeparator = true; bool bShowReflogOption = false; bool bShowFetchOption = false; bool bShowSwitchOption = false; bool bShowRenameOption = false; bool bShowCreateBranchOption = false; bool bShowEditBranchDescriptionOption = false; CString fetchFromCmd; if(selectedLeafs[0]->IsFrom(L"refs/heads")) { bShowReflogOption = true; bShowSwitchOption = true; bShowRenameOption = true; bShowEditBranchDescriptionOption = true; } else if(selectedLeafs[0]->IsFrom(L"refs/remotes")) { bShowReflogOption = true; bShowFetchOption = true; bShowCreateBranchOption = true; int dummy = 0;//Needed for tokenize remoteName = selectedLeafs[0]->GetRefName(); remoteName = remoteName.Mid(13); remoteName = remoteName.Tokenize(L"/", dummy); fetchFromCmd.Format(IDS_PROC_BROWSEREFS_FETCHFROM, remoteName); } else if(selectedLeafs[0]->IsFrom(L"refs/tags")) { } CString temp; temp.LoadString(IDS_MENULOG); popupMenu.AppendMenuIcon(eCmd_ViewLog, temp, IDI_LOG); popupMenu.AppendMenuIcon(eCmd_RepoBrowser, IDS_LOG_BROWSEREPO, IDI_REPOBROWSE); if(bShowReflogOption) { temp.LoadString(IDS_MENUREFLOG); popupMenu.AppendMenuIcon(eCmd_ShowReflog, temp, IDI_LOG); } popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; if(bShowFetchOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Fetch, fetchFromCmd, IDI_PULL); } if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; if (m_bHasWC) { popupMenu.AppendMenuIcon(eCmd_Switch, CString(MAKEINTRESOURCE(IDS_SWITCH_TO_THIS)), IDI_SWITCH); popupMenu.AppendMenu(MF_SEPARATOR); } if(bShowCreateBranchOption) { bAddSeparator = true; temp.LoadString(IDS_MENUBRANCH); popupMenu.AppendMenuIcon(eCmd_CreateBranch, temp, IDI_COPY); } if (bShowEditBranchDescriptionOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_EditBranchDescription, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_EDITDESCRIPTION)), IDI_RENAME); } if(bShowRenameOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Rename, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_RENAME)), IDI_RENAME); } } else if(selectedLeafs.size() == 2) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Diff, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_COMPAREREFS)), IDI_DIFF); } if(!selectedLeafs.empty()) { if(AreAllFrom(selectedLeafs, L"refs/remotes/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETEREMOTEBRANCH); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETEREMOTEBRANCHES, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteRemoteBranch, menuItemName, IDI_DELETE); bAddSeparator = true; } else if(AreAllFrom(selectedLeafs, L"refs/heads/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETEBRANCH); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETEBRANCHES, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteBranch, menuItemName, IDI_DELETE); bAddSeparator = true; } else if(AreAllFrom(selectedLeafs, L"refs/tags/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETETAG); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETETAGS, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteTag, menuItemName, IDI_DELETE); bAddSeparator = true; } } if(hTreePos!=NULL && selectedLeafs.empty()) { CShadowTree* pTree=(CShadowTree*)m_RefTreeCtrl.GetItemData(hTreePos); if(pTree->IsFrom(L"refs/remotes")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); popupMenu.AppendMenuIcon(eCmd_ManageRemotes, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_MANAGEREMOTES)), IDI_SETTINGS); bAddSeparator = true; if(selectedLeafs.empty()) { int dummy = 0;//Needed for tokenize remoteName = pTree->GetRefName(); remoteName = remoteName.Mid(13); remoteName = remoteName.Tokenize(L"/", dummy); if(!remoteName.IsEmpty()) { CString temp; temp.Format(IDS_PROC_BROWSEREFS_FETCHFROM, remoteName); popupMenu.AppendMenuIcon(eCmd_Fetch, temp, IDI_PULL); temp.LoadString(IDS_DELETEREMOTETAG); popupMenu.AppendMenuIcon(eCmd_DeleteRemoteTag, temp, IDI_DELETE); } } } if(pTree->IsFrom(L"refs/heads")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString temp; temp.LoadString(IDS_MENUBRANCH); popupMenu.AppendMenuIcon(eCmd_CreateBranch, temp, IDI_COPY); } if(pTree->IsFrom(L"refs/tags")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString temp; temp.LoadString(IDS_MENUTAG); popupMenu.AppendMenuIcon(eCmd_CreateTag, temp, IDI_TAG); } } eCmd cmd=(eCmd)popupMenu.TrackPopupMenuEx(TPM_LEFTALIGN|TPM_RETURNCMD, point.x, point.y, this, 0); switch(cmd) { case eCmd_ViewLog: { CLogDlg dlg; dlg.SetStartRef(selectedLeafs[0]->GetRefName()); dlg.DoModal(); } break; case eCmd_RepoBrowser: CAppUtils::RunTortoiseProc(_T("/command:repobrowser /path:\"") + g_Git.m_CurrentDir + _T("\" /rev:") + selectedLeafs[0]->GetRefName()); break; case eCmd_DeleteBranch: case eCmd_DeleteRemoteBranch: { if(ConfirmDeleteRef(selectedLeafs)) DoDeleteRefs(selectedLeafs, true); Refresh(); } break; case eCmd_DeleteTag: { if(ConfirmDeleteRef(selectedLeafs)) DoDeleteRefs(selectedLeafs, true); Refresh(); } break; case eCmd_ShowReflog: { CRefLogDlg refLogDlg(this); refLogDlg.m_CurrentBranch = selectedLeafs[0]->GetRefName(); refLogDlg.DoModal(); } break; case eCmd_Fetch: { CAppUtils::Fetch(remoteName); Refresh(); } break; case eCmd_DeleteRemoteTag: { CDeleteRemoteTagDlg deleteRemoteTagDlg; deleteRemoteTagDlg.m_sRemote = remoteName; deleteRemoteTagDlg.DoModal(); } break; case eCmd_Switch: { CAppUtils::Switch(selectedLeafs[0]->GetRefName()); } break; case eCmd_Rename: { POSITION pos = m_ListRefLeafs.GetFirstSelectedItemPosition(); if(pos != NULL) m_ListRefLeafs.EditLabel(m_ListRefLeafs.GetNextSelectedItem(pos)); } break; case eCmd_AddRemote: { CAddRemoteDlg(this).DoModal(); Refresh(); } break; case eCmd_ManageRemotes: { CSinglePropSheetDlg(CString(MAKEINTRESOURCE(IDS_PROCS_TITLE_GITREMOTESETTINGS)), new CSettingGitRemote(g_Git.m_CurrentDir), this).DoModal(); // CSettingGitRemote W_Remotes(m_cmdPath); // W_Remotes.DoModal(); Refresh(); } break; case eCmd_CreateBranch: { CString *commitHash = NULL; if (selectedLeafs.size() == 1) commitHash = &(selectedLeafs[0]->m_csRefHash); CAppUtils::CreateBranchTag(false, commitHash); Refresh(); } break; case eCmd_CreateTag: { CAppUtils::CreateBranchTag(true); Refresh(); } break; case eCmd_Diff: { CFileDiffDlg dlg; dlg.SetDiff( NULL, selectedLeafs[0]->m_csRefHash, selectedLeafs[1]->m_csRefHash); dlg.DoModal(); } break; case eCmd_EditBranchDescription: { CInputDlg dlg; dlg.m_sHintText = CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_EDITDESCRIPTION)); dlg.m_sInputText = selectedLeafs[0]->m_csDescription; dlg.m_sTitle = CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_EDITDESCRIPTION)); dlg.m_bUseLogWidth = true; if(dlg.DoModal() == IDOK) { CString key; key.Format(_T("branch.%s.description"), selectedLeafs[0]->m_csRefName); dlg.m_sInputText.Replace(_T("\r"), _T("")); dlg.m_sInputText.Trim(); if (dlg.m_sInputText.IsEmpty()) g_Git.UnsetConfigValue(key); else g_Git.SetConfigValue(key, dlg.m_sInputText); Refresh(); } } break; } }
bool SVNFetchCommand::Execute() { 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 { CMessageBox::Show(NULL, _T("Found no SVN remote."), _T("TortoiseGit"), MB_OK|MB_ICONERROR); return false; } CGitHash upstreamOldHash, upstreamNewHash; if (g_Git.GetHash(upstreamOldHash, out)) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get upstream hash.")), _T("TortoiseGit"), MB_ICONERROR); return false; } CProgressDlg progress; progress.m_GitCmd=_T("git.exe svn fetch"); progress.m_PostCmdList.Add(_T("Fetched Diff")); progress.m_PostCmdList.Add(_T("Fetched Log")); INT_PTR userResponse = progress.DoModal(); ::DeleteFile(g_Git.m_CurrentDir + _T("\\sys$command")); 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; } if (userResponse == IDC_PROGRESS_BUTTON1) { if (upstreamOldHash == upstreamNewHash) { if (progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"No new revisions fetched.", L"TortoiseGit Fetch", MB_OK | MB_ICONINFORMATION); return true; } CLogDlg dlg; dlg.SetParams(CTGitPath(_T("")), CTGitPath(_T("")), _T(""), upstreamOldHash.ToString() + _T("..") + upstreamNewHash.ToString(), 0); dlg.DoModal(); return true; } else if (userResponse == IDC_PROGRESS_BUTTON1 + 1) { if (upstreamOldHash == upstreamNewHash) { if (progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"No new revisions fetched.", L"TortoiseGit Fetch", MB_OK | MB_ICONINFORMATION); return true; } CFileDiffDlg dlg; dlg.SetDiff(NULL, upstreamNewHash.ToString(), upstreamOldHash.ToString()); dlg.DoModal(); return true; } else return false; }