void CSyncDlg::FetchOutList(bool force) { if(!m_bInited) return; m_OutChangeFileList.Clear(); this->m_OutLogList.Clear(); CString remote; this->m_ctrlURL.GetWindowText(remote); CString remotebranch; this->m_ctrlRemoteBranch.GetWindowText(remotebranch); remotebranch=remote+_T("/")+remotebranch; CGitHash remotebranchHash; g_Git.GetHash(remotebranchHash, remotebranch); if(IsURL()) { CString str; str.LoadString(IDS_PROC_SYNC_PUSH_UNKNOWN); m_OutLogList.ShowText(str); this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE); m_OutLocalBranch.Empty(); m_OutRemoteBranch.Empty(); this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE); return ; } else if(remotebranchHash.IsEmpty()) { CString str; str.Format(IDS_PROC_SYNC_PUSH_UNKNOWNBRANCH, remotebranch); m_OutLogList.ShowText(str); this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE); m_OutLocalBranch.Empty(); m_OutRemoteBranch.Empty(); this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE); return ; } else { CString localbranch; localbranch=this->m_ctrlLocalBranch.GetString(); if(localbranch != m_OutLocalBranch || m_OutRemoteBranch != remotebranch || force) { m_OutLogList.ClearText(); CGitHash base, localBranchHash; bool isFastForward = g_Git.IsFastForward(remotebranch, localbranch, &base); if (g_Git.GetHash(localBranchHash, localbranch)) { MessageBox(g_Git.GetGitLastErr(_T("Could not get hash of \"") + localbranch + _T("\".")), _T("TortoiseGit"), MB_ICONERROR); return; } if (remotebranchHash == localBranchHash) { CString str; str.Format(IDS_PROC_SYNC_COMMITSAHEAD, 0, remotebranch); m_OutLogList.ShowText(str); this->m_ctrlStatus.SetWindowText(str); this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE); this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE); } else if (isFastForward || m_bForce) { CString range; range.Format(_T("%s..%s"), g_Git.FixBranchName(remotebranch), g_Git.FixBranchName(localbranch)); //fast forward m_OutLogList.FillGitLog(nullptr, &range, CGit::LOG_INFO_STAT | CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE); CString str; str.Format(IDS_PROC_SYNC_COMMITSAHEAD, m_OutLogList.GetItemCount(), remotebranch); this->m_ctrlStatus.SetWindowText(str); if (isFastForward) AddDiffFileList(&m_OutChangeFileList, &m_arOutChangeList, localbranch, remotebranch); else { AddDiffFileList(&m_OutChangeFileList, &m_arOutChangeList, localbranch, base.ToString()); } this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,TRUE); this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(TRUE); } else { CString str; str.Format(IDS_PROC_SYNC_NOFASTFORWARD, localbranch, remotebranch); m_OutLogList.ShowText(str); this->m_ctrlStatus.SetWindowText(str); this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID() - 1, FALSE); this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE); } } this->m_OutLocalBranch=localbranch; this->m_OutRemoteBranch=remotebranch; } }
void CSyncDlg::FetchOutList(bool force) { if(!m_bInited) return; m_OutChangeFileList.Clear(); this->m_OutLogList.Clear(); CString remote; this->m_ctrlURL.GetWindowText(remote); CString remotebranch; this->m_ctrlRemoteBranch.GetWindowText(remotebranch); remotebranch=remote+_T("/")+remotebranch; if(IsURL()) { CString str; str=_T("Don't know what will push because you enter URL"); m_OutLogList.ShowText(str); this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE); m_OutLocalBranch.Empty(); m_OutRemoteBranch.Empty(); this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE); return ; } else if(g_Git.GetHash(remotebranch).IsEmpty()) { CString str; str.Format(_T("Don't know what will push because unknown \"%s\""),remotebranch); m_OutLogList.ShowText(str); this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE); m_OutLocalBranch.Empty(); m_OutRemoteBranch.Empty(); this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE); return ; } else { CString localbranch; localbranch=this->m_ctrlLocalBranch.GetString(); if(localbranch != m_OutLocalBranch || m_OutRemoteBranch != remotebranch || force) { m_OutLogList.ClearText(); m_OutLogList.FillGitLog(NULL,CGit:: LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE, &remotebranch,&localbranch); CString str; if(m_OutLogList.GetItemCount() == 0) { str.Format(_T("No commits ahead \"%s\""),remotebranch); m_OutLogList.ShowText(str); this->m_ctrlStatus.SetWindowText(str); this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE); this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE); } else { str.Format(_T("%d commits ahead \"%s\""),m_OutLogList.GetItemCount(),remotebranch); this->m_ctrlStatus.SetWindowText(str); AddDiffFileList(&m_OutChangeFileList,&m_arOutChangeList,localbranch,remotebranch); this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,TRUE); this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(TRUE); } } this->m_OutLocalBranch=localbranch; this->m_OutRemoteBranch=remotebranch; } }