Exemplo n.º 1
0
void CPushDlg::Refresh()
{
	CString WorkingDir=g_Git.m_CurrentDir;
	WorkingDir.Replace(_T(':'),_T('_'));

	CRegString remote(CString(_T("Software\\TortoiseGit\\History\\PushRemote\\")+WorkingDir));
	m_RemoteReg = remote;
	int sel = -1;

	STRING_VECTOR list;
	m_Remote.Reset();

	list.push_back(CString(MAKEINTRESOURCE(IDS_PROC_PUSHFETCH_ALLREMOTES)));
	if(!g_Git.GetRemoteList(list))
	{
		if (list.size() <= 2)
			list.erase(list.begin());

		for (unsigned int i = 0; i < list.size(); ++i)
		{
			m_Remote.AddString(list[i]);
			if(list[i] == remote)
				sel = i;
		}
	}
	// if the last selected remote was "- All -" and "- All -" is still in the list -> select it
	if (list.size() > 1 && remote == CString(MAKEINTRESOURCE(IDS_PROC_PUSHFETCH_ALLREMOTES)))
		sel = 0;
	m_Remote.SetCurSel(sel);

	int current=0;
	list.clear();
	m_BranchSource.Reset();
	m_BranchSource.AddString(_T(" ")); // empty string does not work, for removal of remote branches/tags
	m_BranchSource.SetMaxHistoryItems(0x7FFFFFFF);
	if(!g_Git.GetBranchList(list,&current))
	{
		for (unsigned int i = 0; i < list.size(); ++i)
			m_BranchSource.AddString(list[i]);
		++current; // shift for " "
	}
	if (wcsncmp(m_BranchSourceName, _T("refs/"), 5) == 0)
		m_BranchSourceName = m_BranchSourceName.Mid(5);
	if (wcsncmp(m_BranchSourceName, _T("heads/"), 6) == 0)
	{
		m_BranchSourceName = m_BranchSourceName.Mid(6);
		m_BranchSource.SetCurSel(m_BranchSource.FindStringExact(-1, m_BranchSourceName));
	}
	else if (wcsncmp(m_BranchSourceName, _T("remotes/"), 8) == 0)
		m_BranchSource.SetCurSel(m_BranchSource.FindStringExact(-1, m_BranchSourceName));
	else
		m_BranchSource.SetCurSel(current);

	GetRemoteBranch(m_BranchSource.GetString());

	this->GetDlgItem(IDOK)->EnableWindow(m_BranchSource.GetCount() != 0);
}
Exemplo n.º 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();
}