void CSyncDlg::OnOK() { UpdateCombox(); this->UpdateData(); m_ctrlURL.SaveHistory(); SaveHistory(); m_regAutoLoadPutty = this->m_bAutoLoadPuttyKey; __super::OnOK(); }
void CSyncDlg::OnBnClickedButtonStash() { UpdateData(); UpdateCombox(); m_ctrlCmdOut.SetWindowTextW(_T("")); m_LogText = ""; SwitchToRun(); m_bAbort = false; m_GitCmdList.clear(); ShowTab(IDC_CMD_LOG); m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST - 1, false); m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST -1, false); m_ctrlTabCtrl.ShowTab(IDC_IN_CONFLICT -1, false); CString cmd; switch (m_ctrlStash.GetCurrentEntry()) { case 0: cmd = _T("git.exe stash save"); break; case 1: cmd = _T("git.exe stash pop"); break; case 2: cmd = _T("git.exe stash apply"); break; } m_GitCmdList.push_back(cmd); m_CurrentCmd = GIT_COMMAND_STASH; m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); if (!m_pThread) { //ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED))); } else { m_pThread->m_bAutoDelete = TRUE; m_pThread->ResumeThread(); } }
void CSyncDlg::OnBnClickedButtonSubmodule() { this->UpdateData(); UpdateCombox(); m_ctrlCmdOut.SetWindowTextW(_T("")); m_LogText = ""; this->m_regSubmoduleButton = (DWORD)this->m_ctrlSubmodule.GetCurrentEntry(); this->SwitchToRun(); this->m_bAbort=false; this->m_GitCmdList.clear(); ShowTab(IDC_CMD_LOG); CString cmd; switch (m_ctrlSubmodule.GetCurrentEntry()) { case 0: cmd=_T("git.exe submodule update --init"); break; case 1: cmd=_T("git.exe submodule init"); break; case 2: cmd=_T("git.exe submodule sync"); break; } m_GitCmdList.push_back(cmd); m_CurrentCmd = GIT_COMMAND_SUBMODULE; m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED); if (m_pThread==NULL) { // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED))); } else { m_pThread->m_bAutoDelete = TRUE; m_pThread->ResumeThread(); } }
void CSyncDlg::OnBnClickedButtonPush() { this->UpdateData(); UpdateCombox(); m_ctrlCmdOut.SetWindowTextW(_T("")); m_LogText = ""; if(this->m_strURL.IsEmpty()) { CMessageBox::Show(NULL, IDS_PROC_GITCONFIG_URLEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR); return; } this->m_regPushButton=(DWORD)this->m_ctrlPush.GetCurrentEntry(); this->SwitchToRun(); this->m_bAbort=false; this->m_GitCmdList.clear(); ShowTab(IDC_CMD_LOG); CString cmd; CString arg; CString error; DWORD exitcode; CTGitPathList list; list.AddPath(CTGitPath(g_Git.m_CurrentDir)); if (CHooks::Instance().PrePush(list,exitcode, error)) { if (exitcode) { CString temp; temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error); //ReportError(temp); CMessageBox::Show(NULL,temp,_T("TortoiseGit"),MB_OK|MB_ICONERROR); return ; } } CString refName = g_Git.FixBranchName(m_strLocalBranch); switch (m_ctrlPush.GetCurrentEntry()) { case 1: arg += _T(" --tags "); break; case 2: refName = _T("refs/notes/commits"); //default ref for notes break; } if(this->m_bForce) arg += _T(" --force "); if(m_Gitverion >= 0x01070203) //above 1.7.0.2 arg += _T("--progress "); cmd.Format(_T("git.exe push -v %s \"%s\" %s"), arg, m_strURL, refName); if (!m_strRemoteBranch.IsEmpty() && m_ctrlPush.GetCurrentEntry() != 2) { cmd += _T(":") + m_strRemoteBranch; } m_GitCmdList.push_back(cmd); m_CurrentCmd = GIT_COMMAND_PUSH; if(this->m_bAutoLoadPuttyKey) { CAppUtils::LaunchPAgent(NULL,&this->m_strURL); } m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED); if (m_pThread==NULL) { // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED))); } else { m_pThread->m_bAutoDelete = TRUE; m_pThread->ResumeThread(); } }
void CSyncDlg::OnBnClickedButtonPull() { int CurrentEntry; CurrentEntry = (int)this->m_ctrlPull.GetCurrentEntry(); this->m_regPullButton = CurrentEntry; this->m_bAbort=false; this->m_GitCmdList.clear(); m_ctrlCmdOut.SetWindowTextW(_T("")); m_LogText = ""; this->UpdateData(); UpdateCombox(); if (g_Git.GetHash(m_oldHash, _T("HEAD"))) { MessageBox(g_Git.GetGitLastErr(_T("Could not get HEAD hash.")), _T("TortoiseGit"), MB_ICONERROR); return; } m_refList.Clear(); m_newHashMap.clear(); m_oldHashMap.clear(); if( CurrentEntry == 0) { CGitHash localBranchHash; if (g_Git.GetHash(localBranchHash, m_strLocalBranch)) { MessageBox(g_Git.GetGitLastErr(_T("Could not get hash of \"") + m_strLocalBranch + _T("\".")), _T("TortoiseGit"), MB_ICONERROR); return; } if (localBranchHash != m_oldHash) { CMessageBox::Show(NULL, IDS_PROC_SYNC_PULLWRONGBRANCH, IDS_APPNAME, MB_OK | MB_ICONERROR); return; } } if(this->m_strURL.IsEmpty()) { CMessageBox::Show(NULL, IDS_PROC_GITCONFIG_URLEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR); return; } if (m_bAutoLoadPuttyKey && CurrentEntry != 3) // CurrentEntry (Remote Update) handles this on its own) { CAppUtils::LaunchPAgent(NULL,&this->m_strURL); } this->SwitchToRun(); CString force; if(this->m_bForce) force = _T(" --force "); CString cmd; ShowTab(IDC_CMD_LOG); this->m_ctrlTabCtrl.ShowTab(IDC_REFLIST-1,true); this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,false); this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false); this->m_ctrlTabCtrl.ShowTab(IDC_IN_CONFLICT-1,false); ///Pull if(CurrentEntry == 0) //Pull { CString remotebranch; remotebranch = m_strRemoteBranch; if(!IsURL()) { CString configName; configName.Format(L"branch.%s.merge", this->m_strLocalBranch); CString pullBranch = CGit::StripRefName(g_Git.GetConfigValue(configName)); configName.Format(L"branch.%s.remote", m_strLocalBranch); CString pullRemote = g_Git.GetConfigValue(configName); if(pullBranch == remotebranch && pullRemote == this->m_strURL) remotebranch.Empty(); } if(m_Gitverion >= 0x01070203) //above 1.7.0.2 force += _T("--progress "); cmd.Format(_T("git.exe pull -v %s \"%s\" %s"), force, m_strURL, remotebranch); m_CurrentCmd = GIT_COMMAND_PULL; m_GitCmdList.push_back(cmd); m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED); if (m_pThread==NULL) { // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED))); } else { m_pThread->m_bAutoDelete = TRUE; m_pThread->ResumeThread(); } } ///Fetch if(CurrentEntry == 1 || CurrentEntry ==2 ) //Fetch { CString remotebranch; if(this->IsURL() || m_strRemoteBranch.IsEmpty()) { remotebranch=this->m_strRemoteBranch; } else { remotebranch.Format(_T("remotes/%s/%s"), m_strURL,m_strRemoteBranch); CGitHash remoteBranchHash; g_Git.GetHash(remoteBranchHash, remotebranch); if (remoteBranchHash.IsEmpty()) remotebranch=m_strRemoteBranch; else remotebranch=m_strRemoteBranch+_T(":")+remotebranch; } if(CurrentEntry == 1) m_CurrentCmd = GIT_COMMAND_FETCH; else m_CurrentCmd = GIT_COMMAND_FETCHANDREBASE; if (g_Git.UsingLibGit2(CGit::GIT_CMD_FETCH)) { CString refspec; // current libgit2 only supports well formated refspec refspec.Format(_T("refs/heads/%s:refs/remotes/%s/%s"), m_strRemoteBranch, m_strURL, m_strRemoteBranch); m_GitProgressList.SetUrl(m_strURL); m_GitProgressList.SetRefSpec(refspec); m_GitProgressList.SetCommand(CGitProgressList::GitProgress_Fetch); m_GitProgressList.Init(); ShowTab(IDC_CMD_GIT_PROG); } else { if(m_Gitverion >= 0x01070203) //above 1.7.0.2 force += _T("--progress "); cmd.Format(_T("git.exe fetch -v %s \"%s\" %s"), force, m_strURL, remotebranch); m_GitCmdList.push_back(cmd); m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED); if (m_pThread==NULL) { // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED))); } else { m_pThread->m_bAutoDelete = TRUE; m_pThread->ResumeThread(); } } } ///Remote Update if(CurrentEntry == 3) { if (m_bAutoLoadPuttyKey) { STRING_VECTOR list; if (!g_Git.GetRemoteList(list)) { for (size_t i = 0; i < list.size(); ++i) CAppUtils::LaunchPAgent(NULL, &list[i]); } } m_CurrentCmd = GIT_COMMAND_REMOTE; cmd=_T("git.exe remote update"); m_GitCmdList.push_back(cmd); InterlockedExchange(&m_bBlock, TRUE); m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED); if (m_pThread==NULL) { // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED))); InterlockedExchange(&m_bBlock, FALSE); } else { m_pThread->m_bAutoDelete = TRUE; m_pThread->ResumeThread(); } } ///Cleanup stale remote banches if(CurrentEntry == 4) { m_CurrentCmd = GIT_COMMAND_REMOTE; cmd.Format(_T("git.exe remote prune \"%s\""), m_strURL); m_GitCmdList.push_back(cmd); InterlockedExchange(&m_bBlock, TRUE); m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED); if (m_pThread==NULL) { // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED))); InterlockedExchange(&m_bBlock, FALSE); } else { m_pThread->m_bAutoDelete = TRUE; m_pThread->ResumeThread(); } } }
void CSyncDlg::OnBnClickedButtonPull() { int CurrentEntry; CurrentEntry = this->m_ctrlPull.GetCurrentEntry(); this->m_regPullButton = CurrentEntry; this->m_bAbort=false; this->m_GitCmdList.clear(); this->UpdateData(); UpdateCombox(); m_oldHash = g_Git.GetHash(_T("HEAD")); if( CurrentEntry == 0) { if( g_Git.GetHash(this->m_strLocalBranch) != m_oldHash) { CMessageBox::Show(NULL,_T("Pull require local branch must be current branch"),_T("TortoiseGit"),MB_OK|MB_ICONERROR); return; } } if(this->m_strURL.IsEmpty()) { CMessageBox::Show(NULL,_T("URL can't Empty"),_T("TortoiseGit"),MB_OK|MB_ICONERROR); return; } if(this->m_bAutoLoadPuttyKey) { CAppUtils::LaunchPAgent(NULL,&this->m_strURL); } this->SwitchToRun(); CString force; if(this->m_bForce) force = _T(" --force "); CString cmd; ShowTab(IDC_CMD_LOG); this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,false); this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false); this->m_ctrlTabCtrl.ShowTab(IDC_IN_CONFLICT-1,false); this->GetDlgItem(IDC_BUTTON_COMMIT)->ShowWindow(SW_HIDE); ///Pull if(CurrentEntry == 0) //Pull { CString remotebranch; remotebranch = m_strRemoteBranch; if(!IsURL()) { CString configName; configName.Format(L"branch.%s.merge", this->m_strLocalBranch); CString pullBranch = CGit::StripRefName(g_Git.GetConfigValue(configName)); configName.Format(L"branch.%s.remote", m_strLocalBranch); CString pullRemote = g_Git.GetConfigValue(configName); if(pullBranch == remotebranch && pullRemote == this->m_strURL) remotebranch.Empty(); } if(m_Gitverion >= 0x01070203) //above 1.7.0.2 force += _T("--progress "); cmd.Format(_T("git.exe pull -v %s \"%s\" %s"), force, m_strURL, remotebranch); m_CurrentCmd = GIT_COMMAND_PULL; m_GitCmdList.push_back(cmd); m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED); if (m_pThread==NULL) { // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED))); } else { m_pThread->m_bAutoDelete = TRUE; m_pThread->ResumeThread(); } } ///Fetch if(CurrentEntry == 1 || CurrentEntry ==2 ) //Fetch { CString remotebranch; if(this->IsURL() || m_strRemoteBranch.IsEmpty()) { remotebranch=this->m_strRemoteBranch; } else { remotebranch.Format(_T("remotes/%s/%s"), m_strURL,m_strRemoteBranch); if(g_Git.GetHash(remotebranch).IsEmpty()) remotebranch=m_strRemoteBranch; else remotebranch=m_strRemoteBranch+_T(":")+remotebranch; } if(m_Gitverion >= 0x01070203) //above 1.7.0.2 force += _T("--progress "); cmd.Format(_T("git.exe fetch -v %s \"%s\" %s"), force, m_strURL, remotebranch); if(CurrentEntry == 1) m_CurrentCmd = GIT_COMMAND_FETCH; else m_CurrentCmd = GIT_COMMAND_FETCHANDREBASE; m_GitCmdList.push_back(cmd); m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED); if (m_pThread==NULL) { // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED))); } else { m_pThread->m_bAutoDelete = TRUE; m_pThread->ResumeThread(); } } ///Remote Update if(CurrentEntry == 3) { m_CurrentCmd = GIT_COMMAND_REMOTE; cmd=_T("git.exe remote update"); m_GitCmdList.push_back(cmd); InterlockedExchange(&m_bBlock, TRUE); m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED); if (m_pThread==NULL) { // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED))); InterlockedExchange(&m_bBlock, FALSE); } else { m_pThread->m_bAutoDelete = TRUE; m_pThread->ResumeThread(); } } }