本文整理汇总了C++中CGitHeadFileMap类的典型用法代码示例。如果您正苦于以下问题:C++ CGitHeadFileMap类的具体用法?C++ CGitHeadFileMap怎么用?C++ CGitHeadFileMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CGitHeadFileMap类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsUnderVersionControl
int GitStatus::IsUnderVersionControl(const CString &gitdir, const CString &path, bool isDir,bool *isVersion)
{
if (g_IndexFileMap.IsUnderVersionControl(gitdir, path, isDir, isVersion))
return 1;
if (!*isVersion)
return g_HeadFileMap.IsUnderVersionControl(gitdir, path, isDir, isVersion);
return 0;
}
示例2: GetDirStatus
int GitStatus::GetDirStatus(const CString &gitdir, const CString &subpath, git_wc_status_kind * status, BOOL IsFul, BOOL IsRecursive, BOOL IsIgnore, FILL_STATUS_CALLBACK callback, void *pData)
{
try
{
CString path =subpath;
path.Replace(_T('\\'),_T('/'));
if(!path.IsEmpty())
if(path[path.GetLength()-1] != _T('/'))
path += _T('/'); //Add trail / to show it is directory, not file name.
CString lowcasepath = path;
lowcasepath.MakeLower();
if(status)
{
g_IndexFileMap.CheckAndUpdate(gitdir, true);
SHARED_INDEX_PTR indexptr = g_IndexFileMap.SafeGet(gitdir);
if (indexptr == NULL)
{
*status = git_wc_status_unversioned;
return 0;
}
int pos = SearchInSortVector(*indexptr, lowcasepath, lowcasepath.GetLength());
//Not In Version Contorl
if(pos<0)
{
if(!IsIgnore)
{
*status = git_wc_status_unversioned;
if(callback)
callback(gitdir + _T("/") + path, *status, false, pData, false, false);
return 0;
}
//Check ignore always.
{
if (g_IgnoreList.CheckIgnoreChanged(gitdir, path, true))
g_IgnoreList.LoadAllIgnoreFile(gitdir, path, true);
if (g_IgnoreList.IsIgnore(path, gitdir, true))
*status = git_wc_status_ignored;
else
*status = git_wc_status_unversioned;
g_HeadFileMap.CheckHeadAndUpdate(gitdir, false);
SHARED_TREE_PTR treeptr = g_HeadFileMap.SafeGet(gitdir);
//Check init repository
if (treeptr->HeadIsEmpty() && path.IsEmpty())
*status = git_wc_status_normal;
}
}
else // In version control
{
*status = git_wc_status_normal;
int start=0;
int end=0;
if(path.IsEmpty())
{
start=0;
end = (int)indexptr->size() - 1;
}
GetRangeInSortVector(*indexptr, lowcasepath, lowcasepath.GetLength(), &start, &end, pos);
CGitIndexList::iterator it;
it = indexptr->begin()+start;
// Check Conflict;
for (int i = start; i <= end; ++i)
{
if (((*it).m_Flags & GIT_IDXENTRY_STAGEMASK) !=0)
{
*status = git_wc_status_conflicted;
if(callback)
{
int dirpos = (*it).m_FileName.Find(_T('/'), path.GetLength());
if(dirpos<0 || IsRecursive)
callback(gitdir + _T("\\") + it->m_FileName, git_wc_status_conflicted, false, pData, false, false);
}
else
break;
}
++it;
}
if( IsFul && (*status != git_wc_status_conflicted))
{
*status = git_wc_status_normal;
g_HeadFileMap.CheckHeadAndUpdate(gitdir);
//Check Add
it = indexptr->begin()+start;
//.........这里部分代码省略.........
示例3: EnumDirStatus
int GitStatus::EnumDirStatus(const CString &gitdir, const CString &subpath, git_wc_status_kind * status,BOOL IsFul, BOOL IsRecursive, BOOL IsIgnore, FILL_STATUS_CALLBACK callback, void *pData)
{
try
{
CString path =subpath;
path.Replace(_T('\\'),_T('/'));
if(!path.IsEmpty())
if(path[path.GetLength()-1] != _T('/'))
path += _T('/'); //Add trail / to show it is directory, not file name.
CString lowcasepath = path;
lowcasepath.MakeLower();
std::vector<CGitFileName> filelist;
GetFileList(gitdir, subpath, filelist);
if(status)
{
g_IndexFileMap.CheckAndUpdate(gitdir,true);
g_HeadFileMap.CheckHeadAndUpdate(gitdir);
SHARED_INDEX_PTR indexptr = g_IndexFileMap.SafeGet(gitdir);
SHARED_TREE_PTR treeptr = g_HeadFileMap.SafeGet(gitdir);
std::vector<CGitFileName>::iterator it;
// new git working tree has no index file
if (indexptr.get() == NULL)
{
for (it = filelist.begin(); it < filelist.end(); ++it)
{
CString casepath = path + it->m_CaseFileName;
bool bIsDir = false;
if (it->m_FileName.GetLength() > 0 && it->m_FileName[it->m_FileName.GetLength() - 1] == _T('/'))
bIsDir = true;
if (IsIgnore)
{
if (g_IgnoreList.CheckIgnoreChanged(gitdir, casepath, bIsDir))
g_IgnoreList.LoadAllIgnoreFile(gitdir, casepath, bIsDir);
if (g_IgnoreList.IsIgnore(casepath, gitdir, bIsDir))
*status = git_wc_status_ignored;
else if (bIsDir)
continue;
else
*status = git_wc_status_unversioned;
}
else if (bIsDir)
continue;
else
*status = git_wc_status_unversioned;
if(callback)
callback(gitdir + _T("/") + casepath, *status, bIsDir, pData, false, false);
}
return 0;
}
CString onepath;
CString casepath;
for (it = filelist.begin(); it < filelist.end(); ++it)
{
casepath=onepath = path;
onepath.MakeLower();
onepath += it->m_FileName;
casepath += it->m_CaseFileName;
bool bIsDir = false;
if (!onepath.IsEmpty() && onepath[onepath.GetLength() - 1] == _T('/'))
bIsDir = true;
int matchLength = -1;
if (bIsDir)
matchLength = onepath.GetLength();
int pos = SearchInSortVector(*indexptr, onepath, matchLength);
int posintree = SearchInSortVector(*treeptr, onepath, matchLength);
if(pos <0 && posintree<0)
{
if (onepath.IsEmpty())
continue;
if(!IsIgnore)
{
*status = git_wc_status_unversioned;
if(callback)
callback(gitdir + _T("/") + casepath, *status, bIsDir, pData, false, false);
continue;
}
if (g_IgnoreList.CheckIgnoreChanged(gitdir, casepath, bIsDir))
g_IgnoreList.LoadAllIgnoreFile(gitdir, casepath, bIsDir);
if (g_IgnoreList.IsIgnore(casepath, gitdir, bIsDir))
*status = git_wc_status_ignored;
else
//.........这里部分代码省略.........
示例4: GetFileStatus
int GitStatus::GetFileStatus(const CString &gitdir, const CString &pathParam, git_wc_status_kind * status,BOOL IsFull, BOOL /*IsRecursive*/,BOOL IsIgnore, FILL_STATUS_CALLBACK callback, void *pData, bool * assumeValid, bool * skipWorktree)
{
try
{
CString path = pathParam;
path.Replace(_T('\\'),_T('/'));
CString lowcasepath =path;
lowcasepath.MakeLower();
if(status)
{
git_wc_status_kind st = git_wc_status_none;
CGitHash hash;
g_IndexFileMap.GetFileStatus(gitdir, path, &st, IsFull, false, callback, pData, &hash, true, assumeValid, skipWorktree);
if( st == git_wc_status_conflicted )
{
*status =st;
if (callback && assumeValid && skipWorktree)
callback(gitdir + _T("/") + path, st, false, pData, *assumeValid, *skipWorktree);
return 0;
}
if( st == git_wc_status_unversioned )
{
if(!IsIgnore)
{
*status = git_wc_status_unversioned;
if (callback && assumeValid && skipWorktree)
callback(gitdir + _T("/") + path, *status, false, pData, *assumeValid, *skipWorktree);
return 0;
}
if (g_IgnoreList.CheckIgnoreChanged(gitdir, path, false))
{
g_IgnoreList.LoadAllIgnoreFile(gitdir, path, false);
}
if (g_IgnoreList.IsIgnore(path, gitdir, false))
{
st = git_wc_status_ignored;
}
*status = st;
if (callback && assumeValid && skipWorktree)
callback(gitdir + _T("/") + path, st, false, pData, *assumeValid, *skipWorktree);
return 0;
}
if ((st == git_wc_status_normal || st == git_wc_status_modified) && IsFull)
{
{
g_HeadFileMap.CheckHeadAndUpdate(gitdir);
SHARED_TREE_PTR treeptr = g_HeadFileMap.SafeGet(gitdir);
// Check Head Tree Hash;
{
//add item
int start = SearchInSortVector(*treeptr, lowcasepath, -1);
if(start<0)
{
*status =st=git_wc_status_added;
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": File miss in head tree %s"), path);
if (callback && assumeValid && skipWorktree)
callback(gitdir + _T("/") + path, st, false, pData, *assumeValid, *skipWorktree);
return 0;
}
//staged and not commit
if( treeptr->at(start).m_Hash != hash )
{
*status =st=git_wc_status_modified;
if (callback && assumeValid && skipWorktree)
callback(gitdir + _T("/") + path, st, false, pData, *assumeValid, *skipWorktree);
return 0;
}
}
}
}
*status =st;
if (callback && assumeValid && skipWorktree)
callback(gitdir + _T("/") + path, st, false, pData, *assumeValid, *skipWorktree);
return 0;
}
}
catch(...)
{
if(status)
*status = git_wc_status_none;
return -1;
}
return 0;
}
示例5: ReleasePathsRecursively
bool GitStatus::ReleasePathsRecursively(const CString &rootpath)
{
g_IndexFileMap.SafeClearRecursively(rootpath);
g_HeadFileMap.SafeClearRecursively(rootpath);
return true;
}
示例6: ReleasePath
bool GitStatus::ReleasePath(const CString &gitdir)
{
g_IndexFileMap.SafeClear(gitdir);
g_HeadFileMap.SafeClear(gitdir);
return true;
}
示例7: GetDirStatus
int GitStatus::GetDirStatus(const CString& gitdir, const CString& subpath, git_wc_status_kind* status, BOOL IsFul, BOOL IsRecursive, BOOL IsIgnore)
{
if (!status)
return 0;
CString path = subpath;
path.Replace(_T('\\'), _T('/'));
if (!path.IsEmpty() && path[path.GetLength() - 1] != _T('/'))
path += _T('/'); //Add trail / to show it is directory, not file name.
g_IndexFileMap.CheckAndUpdate(gitdir, true);
SHARED_INDEX_PTR indexptr = g_IndexFileMap.SafeGet(gitdir);
if (!indexptr)
{
*status = git_wc_status_unversioned;
return 0;
}
CString lowcasepath = path;
lowcasepath.MakeLower();
int pos = SearchInSortVector(*indexptr, lowcasepath, lowcasepath.GetLength());
// Not In Version Contorl
if (pos < 0)
{
if (!IsIgnore)
{
*status = git_wc_status_unversioned;
return 0;
}
// Check ignore always.
if (g_IgnoreList.CheckIgnoreChanged(gitdir, path, true))
g_IgnoreList.LoadAllIgnoreFile(gitdir, path, true);
if (g_IgnoreList.IsIgnore(path, gitdir, true))
*status = git_wc_status_ignored;
else
*status = git_wc_status_unversioned;
g_HeadFileMap.CheckHeadAndUpdate(gitdir);
SHARED_TREE_PTR treeptr = g_HeadFileMap.SafeGet(gitdir);
// Check init repository
if (treeptr->HeadIsEmpty() && path.IsEmpty())
*status = git_wc_status_normal;
// check if only one file in repository is deleted in index
else if (path.IsEmpty() && !treeptr->empty())
*status = git_wc_status_deleted;
return 0;
}
// In version control
*status = git_wc_status_normal;
int start = 0;
int end = 0;
GetRangeInSortVector(*indexptr, lowcasepath, lowcasepath.GetLength(), &start, &end, pos);
// Check Conflict;
for (auto it = indexptr->cbegin() + start, itlast = indexptr->cbegin() + end; indexptr->m_bHasConflicts && it <= itlast; ++it)
{
if (((*it).m_Flags & GIT_IDXENTRY_STAGEMASK) != 0)
{
*status = git_wc_status_conflicted;
break;
}
}
if (IsFul && (*status != git_wc_status_conflicted))
{
*status = git_wc_status_normal;
g_HeadFileMap.CheckHeadAndUpdate(gitdir);
// Check Add
{
// Check if new init repository
SHARED_TREE_PTR treeptr = g_HeadFileMap.SafeGet(gitdir);
if (!treeptr->empty() || treeptr->HeadIsEmpty())
{
for (auto it = indexptr->cbegin() + start, itlast = indexptr->cbegin() + end; it <= itlast; ++it)
{
pos = SearchInSortVector(*treeptr, (*it).m_FileName, -1);
if (pos < 0)
{
*status = max(git_wc_status_added, *status); // added file found
break;
}
if (pos >= 0 && treeptr->at(pos).m_Hash != (*it).m_IndexHash)
{
//.........这里部分代码省略.........