예제 #1
0
void CPullFetchDlg::Refresh()
{
	//Select pull-remote from current branch
	CString currentBranch;
	if (g_Git.GetCurrentBranchFromFile(g_Git.m_CurrentDir, currentBranch))
		currentBranch.Empty();

	CString pullRemote, pullBranch;
	g_Git.GetRemoteTrackedBranch(currentBranch, pullRemote, pullBranch);
	m_configPullRemote = pullRemote;
	m_configPullBranch  = pullBranch;

	if (pullBranch.IsEmpty())
		m_RemoteBranch.AddString(currentBranch);
	else
		m_RemoteBranch.AddString(pullBranch);

	if(pullRemote.IsEmpty())
		pullRemote = m_RemoteReg;

	if (!m_PreSelectRemote.IsEmpty())
		pullRemote = m_PreSelectRemote;

	STRING_VECTOR list;
	m_Remote.Reset();
	int sel=0;
	if(!g_Git.GetRemoteList(list))
	{
		if (!m_IsPull && list.size() > 1)
			m_Remote.AddString(CString(MAKEINTRESOURCE(IDS_PROC_PUSHFETCH_ALLREMOTES)));

		for (unsigned int i = 0; i < list.size(); ++i)
		{
			m_Remote.AddString(list[i]);
			if (!m_bAllRemotes && list[i] == pullRemote)
				sel = i + (!m_IsPull && list.size() > 1 ? 1 : 0);
		}
	}
	m_Remote.SetCurSel(sel);
	OnCbnSelchangeRemote();
}
예제 #2
0
void CPullFetchDlg::Refresh()
{
	//Select pull-remote from current branch
	CString currentBranch = g_Git.GetSymbolicRef();
	CString configName;
	configName.Format(L"branch.%s.remote", currentBranch);
	CString pullRemote = this->m_configPullRemote = g_Git.GetConfigValue(configName);

	//Select pull-branch from current branch
	configName.Format(L"branch.%s.merge", currentBranch);
	CString pullBranch = m_configPullBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));
	if (pullBranch.IsEmpty())
		m_RemoteBranch.AddString(currentBranch);
	else
		m_RemoteBranch.AddString(pullBranch);

	if(pullRemote.IsEmpty())
		pullRemote = m_RemoteReg;

	if (!m_PreSelectRemote.IsEmpty())
		pullRemote = m_PreSelectRemote;

	STRING_VECTOR list;
	int sel=0;
	if (!m_IsPull)
		list.push_back(_T("- all -"));
	if(!g_Git.GetRemoteList(list))
	{
		if (!m_IsPull && list.size() <= 2)
			list.erase(list.begin());

		for (unsigned int i = 0; i < list.size(); ++i)
		{
			m_Remote.AddString(list[i]);
			if (!m_bAllRemotes && list[i] == pullRemote)
				sel = i;
		}
	}
	m_Remote.SetCurSel(sel);
	OnCbnSelchangeRemote();
}