#include "GitFolderStatus.h"\r
#include "UnicodeUtils.h"\r
#include "..\TGitCache\CacheInterface.h"\r
+#include "Git.h"\r
//#include "GitGlobal.h"\r
+#include "gitindex.h"\r
\r
extern ShellCache g_ShellCache;\r
\r
+extern CGitIndexFileMap g_IndexFileMap;\r
\r
// get / auto-alloc a string "copy"\r
\r
// apr_hash_t * statushash;\r
// apr_pool_t * pool;\r
//git_error_t * err = NULL; // If svn_client_status comes out through catch(...), err would else be unassigned\r
- BOOL err = FALSE;\r
+ git_error_t err = 0;\r
\r
//dont' build the cache if an instance of TortoiseProc is running\r
//since this could interfere with svn commands running (concurrent\r
// rev.kind = git_opt_revision_unspecified;\r
try\r
{\r
- // extract the sub-path (relative to project root)\r
-//MessageBox(NULL, filepath.GetDirectory().GetWinPathString(), sProjectRoot, MB_OK);\r
- LPCSTR lpszSubPath = NULL;\r
- CStringA sSubPath;\r
- CString s = filepath.GetDirectory().GetWinPathString();\r
- if (s.GetLength() > sProjectRoot.GetLength())\r
+ if (g_ShellCache.GetCacheType() == ShellCache::dll)\r
{\r
- sSubPath = CStringA(s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/));\r
- lpszSubPath = sSubPath;\r
+ // gitindex.h based status\r
+\r
+ // extract the sub-path (relative to project root)\r
+ CString sSubPath;\r
+ CString s = filepath.GetWinPathString();\r
+ if (s.GetLength() > sProjectRoot.GetLength())\r
+ {\r
+ if (sProjectRoot.GetLength() == 3 && sProjectRoot[1] == _T(':'))\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());\r
+ else\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);\r
+ }\r
+\r
+ git_wc_status_kind status;\r
+\r
+ err = g_IndexFileMap.GetFileStatus((CString&)sProjectRoot,sSubPath,&status,true,true,fillstatusmap_idx,this);\r
}\r
+ else\r
+ {\r
+ // extract the sub-path (relative to project root)\r
+//MessageBox(NULL, filepath.GetDirectory().GetWinPathString(), sProjectRoot, MB_OK);\r
+ LPCTSTR lpszSubPath = NULL;\r
+ CString sSubPath;\r
+ CString s = filepath.GetDirectory().GetWinPathString();\r
+ if (s.GetLength() > sProjectRoot.GetLength())\r
+ {\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());\r
+ lpszSubPath = sSubPath;\r
+ // skip initial slash if necessary\r
+ if (*lpszSubPath == _T('\\'))\r
+ lpszSubPath++;\r
+ }\r
\r
//if (lpszSubPath) MessageBoxA(NULL, lpszSubPath, "BuildCache", MB_OK);\r
//MessageBoxA(NULL, CStringA(sProjectRoot), sSubPath, MB_OK);\r
- err = !wgEnumFiles(CStringA(sProjectRoot), lpszSubPath, WGEFF_NoRecurse|WGEFF_FullPath|WGEFF_DirStatusAll, &fillstatusmap, this);\r
-\r
- /*err = svn_client_status4 (&youngest,\r
- filepath.GetDirectory().GetSVNApiPath(pool),\r
- &rev,\r
- fillstatusmap,\r
- this,\r
- svn_depth_immediates, //depth\r
- TRUE, //getall\r
- FALSE, //update\r
- TRUE, //noignore\r
- FALSE, //ignore externals\r
- NULL,\r
- localctx,\r
- pool);*/\r
+//OutputDebugStringA("---");OutputDebugStringW(sProjectRoot);OutputDebugStringA(" = ");OutputDebugStringW(filepath.GetWinPathString());OutputDebugStringA(" - ");OutputDebugStringW(sSubPath);OutputDebugStringA("\r\n");\r
+ err = !wgEnumFiles(sProjectRoot, lpszSubPath, WGEFF_NoRecurse|WGEFF_FullPath|WGEFF_DirStatusAll, &fillstatusmap, this);\r
+\r
+ /*err = svn_client_status4 (&youngest,\r
+ filepath.GetDirectory().GetSVNApiPath(pool),\r
+ &rev,\r
+ fillstatusmap,\r
+ this,\r
+ svn_depth_immediates, //depth\r
+ TRUE, //getall\r
+ FALSE, //update\r
+ TRUE, //noignore\r
+ FALSE, //ignore externals\r
+ NULL,\r
+ localctx,\r
+ pool);*/\r
+ }\r
}\r
catch ( ... )\r
{\r
\r
s.author = Stat->authors.GetString(NULL);\r
s.url = Stat->urls.GetString(NULL);\r
-// s.rev = -1;\r
+ if (pFile->sha1)\r
+ s.rev = ConvertHashToRevnum(pFile->sha1);\r
s.owner = Stat->owners.GetString(NULL);\r
\r
s.status = git_wc_status_none;\r
stdstring str;\r
if (pFile->sFileName)\r
{\r
- str = CUnicodeUtils::StdGetUnicode(pFile->sFileName);\r
+ str = pFile->sFileName;//CUnicodeUtils::StdGetUnicode(pFile->sFileName);\r
std::replace(str.begin(), str.end(), '/', '\\');\r
//MessageBox(NULL, str.c_str(), _T(""), MB_OK);\r
}\r
return FALSE;\r
}\r
\r
+void GitFolderStatus::fillstatusmap_idx(CString &path,git_wc_status_kind status,void *pUserData)\r
+{\r
+ GitFolderStatus *Stat = (GitFolderStatus*)pUserData;\r
+\r
+ FileStatusMap &cache = Stat->m_cache;\r
+ FileStatusCacheEntry s;\r
+ s.needslock = false;\r
+ s.tree_conflict = false;\r
+\r
+ s.author = Stat->authors.GetString(NULL);\r
+ s.url = Stat->urls.GetString(NULL);\r
+// s.rev = -1;\r
+ s.owner = Stat->owners.GetString(NULL);\r
+\r
+ s.status = status;\r
+\r
+ //s.status = GitStatus::GetMoreImportant(s.status, status->text_status);\r
+ //s.status = GitStatus::GetMoreImportant(s.status, status->prop_status);\r
+ //s.status = GitStatusFromWingit(pFile->nStatus);\r
+\r
+ // TODO ?: s.blaha = pFile->nStage\r
+\r
+ //s.lock = status->repos_lock;\r
+ //s.tree_conflict = (status->tree_conflict != NULL);\r
+\r
+ s.askedcounter = GITFOLDERSTATUS_CACHETIMES;\r
+ //stdstring str;\r
+ //if (pFile->sFileName)\r
+ //{\r
+ // str = CUnicodeUtils::StdGetUnicode(pFile->sFileName);\r
+ // std::replace(str.begin(), str.end(), '/', '\\');\r
+//MessageBox(NULL, str.c_str(), _T(""), MB_OK);\r
+ //}\r
+ //else\r
+ // str = _T(" ");\r
+ if( path.Right(1) == _T("\\"))\r
+ {\r
+ path=path.Left(path.GetLength()-1);\r
+ }\r
+ stdstring str;\r
+ str=path;\r
+ cache[str] = s;\r
+\r
+ return;\r
+}\r
+\r
#if 0\r
git_error_t* GitFolderStatus::fillstatusmap(void * baton, const char * path, git_wc_status2_t * status, apr_pool_t * /*pool*/)\r
{\r