int CGitIgnoreItem::IsPathIgnored(const CStringA& patha, const char* base, int& type)
{
	if (!m_pExcludeList)
		return -1; // error or undecided

	return git_check_excluded_1(patha, patha.GetLength(), base, &type, m_pExcludeList);
}
Example #2
0
int CGitIgnoreList::CheckFileAgainstIgnoreList(const CString &ignorefile, const CStringA &patha, const char * base, int &type)
{
    if (m_Map.find(ignorefile) != m_Map.end())
    {
        int ret = -1;
        if(m_Map[ignorefile].m_pExcludeList)
            ret = git_check_excluded_1(patha, patha.GetLength(), base, &type, m_Map[ignorefile].m_pExcludeList);
        if (ret == 0 || ret == 1)
            return ret;
    }
    return -1;
}
Example #3
0
int CGitIgnoreList::CheckIgnore(const CString &path,const CString &projectroot)
{
	__int64 time = 0;
	bool dir = 0;
	CString temp = projectroot + _T("\\") + path;
	temp.Replace(_T('/'), _T('\\'));

	CStringA patha;

	patha = CUnicodeUtils::GetMulti(path, CP_ACP) ;
	patha.Replace('\\', '/');

	if(g_Git.GetFileModifyTime(temp, &time, &dir))
		return -1;

	int type = 0;
	if (dir)
		type = DT_DIR;
	else
		type = DT_REG;

	while (!temp.IsEmpty())
	{
		int x;
		x = temp.ReverseFind(_T('\\'));
		if(x < 0)
			x=0;
		temp=temp.Left(x);

		temp += _T("\\.gitignore");

		char *base;

		patha.Replace('\\', '/');
		int pos = patha.ReverseFind('/');
		base = pos >= 0 ? patha.GetBuffer() + pos + 1 : patha.GetBuffer();

		CAutoReadLock lock(&this->m_SharedMutex);

		if(this->m_Map.find(temp) != m_Map.end())
		{
			int ret=-1;

			if(m_Map[temp].m_pExcludeList)
				ret = git_check_excluded_1( patha, patha.GetLength(), base, &type, m_Map[temp].m_pExcludeList);

			if(ret == 1)
				return 1;
			if(ret == 0)
				return 0;
		}

		temp = temp.Left(temp.GetLength()-11);
		temp +=_T("\\.git\\info\\exclude");

		if(this->m_Map.find(temp) != m_Map.end())
		{
			int ret = -1;

			if(m_Map[temp].m_pExcludeList)
				ret = git_check_excluded_1(patha, patha.GetLength(), base, &type, m_Map[temp].m_pExcludeList);

			if(ret == 1)
				return 1;
			if(ret == 0)
				return 0;

			return -1;
		}
		temp = temp.Left(temp.GetLength() - 18);
	}

	return -1;
}