当前位置: 首页>>代码示例>>C++>>正文


C++ CGit::IsFastForward方法代码示例

本文整理汇总了C++中CGit::IsFastForward方法的典型用法代码示例。如果您正苦于以下问题:C++ CGit::IsFastForward方法的具体用法?C++ CGit::IsFastForward怎么用?C++ CGit::IsFastForward使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGit的用法示例。


在下文中一共展示了CGit::IsFastForward方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SubmoduleDiff


//.........这里部分代码省略.........
		if(g_Git.Run(cmd, &bytes, &errBytes))
		{
			CString err;
			g_Git.StringAppend(&err, &errBytes[0], CP_UTF8);
			CMessageBox::Show(NULL,err,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
			return -1;
		}

		g_Git.StringAppend(&oldhash, &bytes[15], CP_UTF8, 40);
		g_Git.StringAppend(&newhash, &bytes[15+41], CP_UTF8, 40);

	}

	CString oldsub;
	CString newsub;
	bool oldOK = false, newOK = false;

	CGit subgit;
	subgit.m_CurrentDir=g_Git.m_CurrentDir+_T("\\")+pPath->GetWinPathString();
	CSubmoduleDiffDlg::ChangeType changeType = CSubmoduleDiffDlg::Unknown;

	if(pPath->HasAdminDir())
	{
		int encode=CAppUtils::GetLogOutputEncode(&subgit);
		int oldTime = 0, newTime = 0;

		if(oldhash != GIT_REV_ZERO)
		{
			CString cmdout, cmderr;
			cmd.Format(_T("git.exe log -n1 --pretty=format:\"%%ct %%s\" %s --"), oldhash);
			oldOK = !subgit.Run(cmd, &cmdout, &cmderr, encode);
			if (oldOK)
			{
				int pos = cmdout.Find(_T(" "));
				oldTime = _ttoi(cmdout.Left(pos));
				oldsub = cmdout.Mid(pos + 1);
			}
			else
				oldsub = cmderr;
		}
		if (newhash != GIT_REV_ZERO)
		{
			CString cmdout, cmderr;
			cmd.Format(_T("git.exe log -n1 --pretty=format:\"%%ct %%s\" %s --"), newhash);
			newOK = !subgit.Run(cmd, &cmdout, &cmderr, encode);
			if (newOK)
			{
				int pos = cmdout.Find(_T(" "));
				newTime = _ttoi(cmdout.Left(pos));
				newsub = cmdout.Mid(pos + 1);
			}
			else
				newsub = cmderr;
		}

		if (oldhash == GIT_REV_ZERO)
		{
			oldOK = true;
			changeType = CSubmoduleDiffDlg::NewSubmodule;
		}
		else if (newhash == GIT_REV_ZERO)
		{
			newOK = true;
			changeType = CSubmoduleDiffDlg::DeleteSubmodule;
		}
		else if (oldhash != newhash)
		{
			bool ffNewer = false, ffOlder = false;
			ffNewer = subgit.IsFastForward(oldhash, newhash);
			if (!ffNewer)
			{
				ffOlder = subgit.IsFastForward(newhash, oldhash);
				if (!ffOlder)
				{
					if (newTime > oldTime)
						changeType = CSubmoduleDiffDlg::NewerTime;
					else if (newTime < oldTime)
						changeType = CSubmoduleDiffDlg::OlderTime;
					else
						changeType = CSubmoduleDiffDlg::SameTime;
				}
				else
					changeType = CSubmoduleDiffDlg::Rewind;
			}
			else
				changeType = CSubmoduleDiffDlg::FastForward;
		}
	}

	if (!oldOK || !newOK)
		changeType = CSubmoduleDiffDlg::Unknown;

	CSubmoduleDiffDlg submoduleDiffDlg;
	submoduleDiffDlg.SetDiff(pPath->GetWinPath(), isWorkingCopy, oldhash, oldsub, oldOK, newhash, newsub, newOK, dirty, changeType);
	submoduleDiffDlg.DoModal();
	if (submoduleDiffDlg.IsRefresh())
		return 1;

	return 0;
}
开发者ID:DinaraRigon,项目名称:TortoiseGit,代码行数:101,代码来源:GitDiff.cpp

示例2: GetSubmoduleChangeType

void CGitDiff::GetSubmoduleChangeType(CGit& subgit, const CString& oldhash, const CString& newhash, bool& oldOK, bool& newOK, ChangeType& changeType, CString& oldsub, CString& newsub)
{
	CString cmd;
	int encode = CAppUtils::GetLogOutputEncode(&subgit);
	int oldTime = 0, newTime = 0;

	if (oldhash != GIT_REV_ZERO)
	{
		CString cmdout, cmderr;
		cmd.Format(_T("git.exe log -n1 --pretty=format:\"%%ct %%s\" %s --"), (LPCTSTR)oldhash);
		oldOK = !subgit.Run(cmd, &cmdout, &cmderr, encode);
		if (oldOK)
		{
			int pos = cmdout.Find(_T(" "));
			oldTime = _ttoi(cmdout.Left(pos));
			oldsub = cmdout.Mid(pos + 1);
		}
		else
			oldsub = cmderr;
	}
	if (newhash != GIT_REV_ZERO)
	{
		CString cmdout, cmderr;
		cmd.Format(_T("git.exe log -n1 --pretty=format:\"%%ct %%s\" %s --"), (LPCTSTR)newhash);
		newOK = !subgit.Run(cmd, &cmdout, &cmderr, encode);
		if (newOK)
		{
			int pos = cmdout.Find(_T(" "));
			newTime = _ttoi(cmdout.Left(pos));
			newsub = cmdout.Mid(pos + 1);
		}
		else
			newsub = cmderr;
	}

	if (oldhash == GIT_REV_ZERO)
	{
		oldOK = true;
		changeType = NewSubmodule;
	}
	else if (newhash == GIT_REV_ZERO)
	{
		newOK = true;
		changeType = DeleteSubmodule;
	}
	else if (oldhash != newhash)
	{
		bool ffNewer = false, ffOlder = false;
		ffNewer = subgit.IsFastForward(oldhash, newhash);
		if (!ffNewer)
		{
			ffOlder = subgit.IsFastForward(newhash, oldhash);
			if (!ffOlder)
			{
				if (newTime > oldTime)
					changeType = NewerTime;
				else if (newTime < oldTime)
					changeType = OlderTime;
				else
					changeType = SameTime;
			}
			else
				changeType = Rewind;
		}
		else
			changeType = FastForward;
	}
	else if (oldhash == newhash)
		changeType = Identical;

	if (!oldOK || !newOK)
		changeType = Unknown;
}
开发者ID:tribis,项目名称:TortoiseGit,代码行数:73,代码来源:GitDiff.cpp


注:本文中的CGit::IsFastForward方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。