X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=blobdiff_plain;f=src%2FGit%2FGitFolderStatus.cpp;h=16bde65699dad3ee3b206d2c591fbe2bddca9bc1;hp=df2d45f89b1d681b35c356435a1ab6d40743a09a;hb=9be52fb6cac4a5460b6db9fb63f84d1e5c54952f;hpb=01ed9d0cab6b52fb9922679acd9969e7fffeeb8f;ds=sidebyside diff --git a/src/Git/GitFolderStatus.cpp b/src/Git/GitFolderStatus.cpp index df2d45f..16bde65 100644 --- a/src/Git/GitFolderStatus.cpp +++ b/src/Git/GitFolderStatus.cpp @@ -21,10 +21,13 @@ #include "GitFolderStatus.h" #include "UnicodeUtils.h" #include "..\TGitCache\CacheInterface.h" +#include "Git.h" //#include "GitGlobal.h" +#include "gitindex.h" extern ShellCache g_ShellCache; +extern CGitIndexFileMap g_IndexFileMap; // get / auto-alloc a string "copy" @@ -113,7 +116,7 @@ const FileStatusCacheEntry * GitFolderStatus::BuildCache(const CTGitPath& filepa // apr_hash_t * statushash; // apr_pool_t * pool; //git_error_t * err = NULL; // If svn_client_status comes out through catch(...), err would else be unassigned - BOOL err = FALSE; + git_error_t err = 0; //dont' build the cache if an instance of TortoiseProc is running //since this could interfere with svn commands running (concurrent @@ -228,34 +231,53 @@ const FileStatusCacheEntry * GitFolderStatus::BuildCache(const CTGitPath& filepa // rev.kind = git_opt_revision_unspecified; try { - // extract the sub-path (relative to project root) -//MessageBox(NULL, filepath.GetDirectory().GetWinPathString(), sProjectRoot, MB_OK); - LPCSTR lpszSubPath = NULL; - CStringA sSubPath; - CString s = filepath.GetDirectory().GetWinPathString(); - if (s.GetLength() > sProjectRoot.GetLength()) + if (g_ShellCache.GetCacheType() == ShellCache::dll) { - sSubPath = CStringA(s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/)); - lpszSubPath = sSubPath; + // gitindex.h based status + + // extract the sub-path (relative to project root) + CString sSubPath; + CString s = filepath.GetWinPathString(); + if (s.GetLength() > sProjectRoot.GetLength()) + { + sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/); + } + + git_wc_status_kind status; + + err = g_IndexFileMap.GetFileStatus((CString&)sProjectRoot,sSubPath,&status,true,true,fillstatusmap_idx,this); } + else + { + // extract the sub-path (relative to project root) +//MessageBox(NULL, filepath.GetDirectory().GetWinPathString(), sProjectRoot, MB_OK); + LPCSTR lpszSubPath = NULL; + CStringA sSubPath; + CString s = filepath.GetDirectory().GetWinPathString(); + if (s.GetLength() > sProjectRoot.GetLength()) + { + sSubPath = CStringA(s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/)); + lpszSubPath = sSubPath; + } //if (lpszSubPath) MessageBoxA(NULL, lpszSubPath, "BuildCache", MB_OK); //MessageBoxA(NULL, CStringA(sProjectRoot), sSubPath, MB_OK); - err = !wgEnumFiles(CStringA(sProjectRoot), lpszSubPath, WGEFF_NoRecurse|WGEFF_FullPath|WGEFF_DirStatusAll, &fillstatusmap, this); - - /*err = svn_client_status4 (&youngest, - filepath.GetDirectory().GetSVNApiPath(pool), - &rev, - fillstatusmap, - this, - svn_depth_immediates, //depth - TRUE, //getall - FALSE, //update - TRUE, //noignore - FALSE, //ignore externals - NULL, - localctx, - pool);*/ + err = !wgEnumFiles(CStringA(sProjectRoot), lpszSubPath, WGEFF_NoRecurse|WGEFF_FullPath|WGEFF_DirStatusAll, &fillstatusmap, this); + + /*err = svn_client_status4 (&youngest, + filepath.GetDirectory().GetSVNApiPath(pool), + &rev, + fillstatusmap, + this, + svn_depth_immediates, //depth + TRUE, //getall + FALSE, //update + TRUE, //noignore + FALSE, //ignore externals + NULL, + localctx, + pool);*/ + } } catch ( ... ) { @@ -407,7 +429,8 @@ BOOL GitFolderStatus::fillstatusmap(const struct wgFile_s *pFile, void *pUserDat s.author = Stat->authors.GetString(NULL); s.url = Stat->urls.GetString(NULL); -// s.rev = -1; + if (pFile->sha1) + s.rev = ConvertHashToRevnum(pFile->sha1); s.owner = Stat->owners.GetString(NULL); s.status = git_wc_status_none; @@ -425,7 +448,7 @@ BOOL GitFolderStatus::fillstatusmap(const struct wgFile_s *pFile, void *pUserDat stdstring str; if (pFile->sFileName) { - str = CUnicodeUtils::StdGetUnicode(pFile->sFileName); + str = pFile->sFileName;//CUnicodeUtils::StdGetUnicode(pFile->sFileName); std::replace(str.begin(), str.end(), '/', '\\'); //MessageBox(NULL, str.c_str(), _T(""), MB_OK); } @@ -436,6 +459,52 @@ BOOL GitFolderStatus::fillstatusmap(const struct wgFile_s *pFile, void *pUserDat return FALSE; } +void GitFolderStatus::fillstatusmap_idx(CString &path,git_wc_status_kind status,void *pUserData) +{ + GitFolderStatus *Stat = (GitFolderStatus*)pUserData; + + FileStatusMap &cache = Stat->m_cache; + FileStatusCacheEntry s; + s.needslock = false; + s.tree_conflict = false; + + s.author = Stat->authors.GetString(NULL); + s.url = Stat->urls.GetString(NULL); +// s.rev = -1; + s.owner = Stat->owners.GetString(NULL); + + s.status = status; + + //s.status = GitStatus::GetMoreImportant(s.status, status->text_status); + //s.status = GitStatus::GetMoreImportant(s.status, status->prop_status); + //s.status = GitStatusFromWingit(pFile->nStatus); + + // TODO ?: s.blaha = pFile->nStage + + //s.lock = status->repos_lock; + //s.tree_conflict = (status->tree_conflict != NULL); + + s.askedcounter = GITFOLDERSTATUS_CACHETIMES; + //stdstring str; + //if (pFile->sFileName) + //{ + // str = CUnicodeUtils::StdGetUnicode(pFile->sFileName); + // std::replace(str.begin(), str.end(), '/', '\\'); +//MessageBox(NULL, str.c_str(), _T(""), MB_OK); + //} + //else + // str = _T(" "); + if( path.Right(1) == _T("\\")) + { + path=path.Left(path.GetLength()-1); + } + stdstring str; + str=path; + cache[str] = s; + + return; +} + #if 0 git_error_t* GitFolderStatus::fillstatusmap(void * baton, const char * path, git_wc_status2_t * status, apr_pool_t * /*pool*/) {