bool PrevDiffCommand::Execute()
{
	if (!GitAdminDir::HasAdminDir(g_Git.m_CurrentDir))
	{
		CMessageBox::Show(GetExplorerHWND(), IDS_NOWORKINGCOPY, IDS_APPNAME, MB_ICONERROR);
		return false;
	}

	bool bAlternativeTool = !!parser.HasKey(L"alternative");
	bool bUnified = !!parser.HasKey(L"unified");
	if (this->orgCmdLinePath.IsDirectory())
	{
		CFileDiffDlg dlg;
		theApp.m_pMainWnd = &dlg;
		dlg.m_strRev1 = L"HEAD~1";
		dlg.m_strRev2 = GIT_REV_ZERO;
		dlg.m_sFilter = this->cmdLinePath.GetGitPathString();

		dlg.DoModal();
		return true;
	}

	CLogDataVector revs;
	CLogCache cache;
	revs.m_pLogCache = &cache;
	revs.ParserFromLog(&cmdLinePath, 2, CGit::LOG_INFO_ONLY_HASH);

	if (revs.size() != 2)
	{
		CMessageBox::Show(GetExplorerHWND(), IDS_ERR_NOPREVREVISION, IDS_APPNAME, MB_ICONERROR);
		return false;
	}

	return !!CGitDiff::Diff(GetExplorerHWND(), &cmdLinePath, &cmdLinePath, GIT_REV_ZERO, revs.GetGitRevAt(1).m_CommitHash.ToString(), false, bUnified, 0, bAlternativeTool);
}
Example #2
0
void CRefLogDlg::OnCbnSelchangeRef()
{
	CString ref=m_ChooseRef.GetString();
	if(m_RefList.m_RefMap.find(ref) == m_RefList.m_RefMap.end())
	{
		m_RefList.m_RefMap[ref].m_pLogCache = &m_RefList.m_LogCache;
		m_RefList.m_RefMap[ref].ParserFromRefLog(ref);
	}
	m_RefList.ClearText();

	//this->m_logEntries.ParserFromLog();
	m_RefList.SetRedraw(false);

	CLogDataVector *plog;
	plog = &m_RefList.m_RefMap[ref];

	m_RefList.SetItemCountEx(plog->size());

	this->m_RefList.m_arShownList.RemoveAll();

	for(unsigned int i=0;i<m_RefList.m_RefMap[ref].size();i++)
	{
		plog->GetGitRevAt(i).m_IsFull=TRUE;
		this->m_RefList.m_arShownList.Add(&(plog->GetGitRevAt(i)));

	}

	m_RefList.SetRedraw(true);

	m_RefList.Invalidate();

}
Example #3
0
bool PrevDiffCommand::Execute()
{
	bool bRet = false;
	//bool bAlternativeTool = !!parser.HasKey(_T("alternative"));
	if (this->orgCmdLinePath.IsDirectory())
	{
		CFileDiffDlg dlg;

		dlg.m_strRev1 = GIT_REV_ZERO;
		dlg.m_strRev2 = _T("HEAD~1");
		dlg.m_sFilter = this->cmdLinePath.GetGitPathString();

		//dlg.m_pathList = CTGitPathList(cmdLinePath);
		dlg.DoModal();
		bRet = true;
	}
	else
	{
		GitStatus st;
		st.GetStatus(cmdLinePath);

		if (1)
		{
			CString hash;
			CString logout;

			CLogDataVector revs;
			CLogCache cache;
			revs.m_pLogCache=&cache;

			revs.ParserFromLog(&cmdLinePath,2,CGit::LOG_INFO_ONLY_HASH);

			if( revs.size() != 2)
			{
				CMessageBox::Show(hWndExplorer, IDS_ERR_NOPREVREVISION, IDS_APPNAME, MB_ICONERROR);
				bRet = false;
			}
			else
			{
				CGitDiff diff;
				bRet = !!diff.Diff(&cmdLinePath,&cmdLinePath, GIT_REV_ZERO, revs.GetGitRevAt(1).m_CommitHash.ToString());
			}
		}
		else
		{
			//if (st.GetLastErrorMsg().IsEmpty())
			{
				CMessageBox::Show(hWndExplorer, IDS_ERR_NOPREVREVISION, IDS_APPNAME, MB_ICONERROR);
			}
			//else
			//{
			//	CMessageBox::Show(hWndExplorer, IDS_ERR_NOSTATUS, IDS_APPNAME, MB_ICONERROR);
			//s}
		}
	}
	return bRet;
}
Example #4
0
int AddTolist(unsigned char * /*osha1*/, unsigned char *nsha1, const char * /*name*/, unsigned long /*time*/, int /*sz*/, const char *msg, void *data)
{
	CLogDataVector *vector = (CLogDataVector*)data;
	GitRevLoglist rev;
	rev.m_CommitHash = (char*)nsha1;

	CString one = CUnicodeUtils::GetUnicode(msg);

	int message = one.Find(_T(":"), 0);
	if (message > 0)
	{
		rev.m_RefAction = one.Left(message);
		rev.GetSubject() = one.Mid(message + 1);
	}

	vector->m_pLogCache->m_HashMap[rev.m_CommitHash] = rev;
	vector->insert(vector->begin(),rev.m_CommitHash);

	return 0;
}
Example #5
0
void CPropertiesWnd::UpdateProperties(GitRev *rev)
{
	if(rev)
	{
		m_CommitHash->SetValue(rev->m_CommitHash);
		m_AuthorName->SetValue(rev->m_AuthorName);
		m_AuthorDate->SetValue(rev->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")));
		m_AuthorEmail->SetValue(rev->m_AuthorEmail);	

		m_CommitterName->SetValue(rev->m_CommitterName);
		m_CommitterEmail->SetValue(rev->m_CommitterEmail);
		m_CommitterDate->SetValue(rev->m_CommitterDate.Format(_T("%Y-%m-%d %H:%M")));

		m_Subject->SetValue(rev->m_Subject);
		m_Body->SetValue(rev->m_Body);

		RemoveParent();

		m_ParentGroup;
	
		CLogDataVector		*pLogEntry = &((CMainFrame*)AfxGetApp()->GetMainWnd())->m_wndOutput.m_LogList.m_logEntries;

		for(unsigned int i=0;i<rev->m_ParentHash.size();i++)
		{
			CString str;
			CString parentsubject;
			int index;

			if( pLogEntry->m_HashMap.find(rev->m_ParentHash[i]) == pLogEntry->m_HashMap.end() )
			{ 
				index = -1;
			}
			else
			{
				index=pLogEntry->m_HashMap[rev->m_ParentHash[i]];
			}
			if(index>=0)
				parentsubject=pLogEntry->at(index).m_Subject;

			str.Format(_T("%d - %s \n %s"),i,rev->m_ParentHash[i],parentsubject);
			
			CMFCPropertyGridProperty*p=new CMFCPropertyGridProperty(
											rev->m_ParentHash[i].Left(8), 
												parentsubject,
												str
											);
			m_ParentGroup->AddSubItem(p);
			m_ParentGroup->Expand();
		}
		for(int i=0;i<m_BaseInfoGroup->GetSubItemsCount();i++)
			m_BaseInfoGroup->GetSubItem(i)->SetDescription(m_BaseInfoGroup->GetSubItem(i)->GetValue());

	}else
	{
		m_CommitHash->SetValue(_T(""));
		m_AuthorName->SetValue(_T(""));
		m_AuthorDate->SetValue(_T(""));
		m_AuthorEmail->SetValue(_T(""));

		m_CommitterName->SetValue(_T(""));
		m_CommitterEmail->SetValue(_T(""));
		m_CommitterDate->SetValue(_T(""));

		m_Subject->SetValue(_T(""));
		m_Body->SetValue(_T(""));

		RemoveParent();
		//m_ParentGroup;

		//m_ParentHash->SetValue(_T(""));
		//m_ParentSubject->SetValue(_T(""));		
		for(int i=0;i<m_BaseInfoGroup->GetSubItemsCount();i++)
			m_BaseInfoGroup->GetSubItem(i)->SetDescription(_T(""));
	}
	this->Invalidate();
	m_wndPropList.Invalidate();
}