//\r
\r
#include "stdafx.h"\r
+#ifdef _TORTOISESHELL\r
+#include "ShellExt.h"\r
+#else\r
+#include "registry.h"\r
+#endif\r
//#include "resource.h"\r
#include "..\TortoiseShell\resource.h"\r
//#include "git_config.h"\r
\r
const BOOL bIsRecursive = (depth == git_depth_infinity || depth == git_depth_unknown); // taken from SVN source\r
\r
- //LPCSTR lpszSubPath = NULL;\r
- CString sSubPath;\r
- CString s = path.GetWinPathString();\r
- if (s.GetLength() > sProjectRoot.GetLength())\r
+#ifdef _TORTOISESHELL\r
+ if (g_ShellCache.GetCacheType() == ShellCache::dll)\r
+#else\r
+ if ((DWORD)CRegStdWORD(_T("Software\\TortoiseGit\\CacheType"), GetSystemMetrics(SM_REMOTESESSION) ? 2 : 1) == 2)\r
+#endif\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
+ CString sSubPath;\r
+ CString s = path.GetWinPathString();\r
+ if (s.GetLength() > sProjectRoot.GetLength())\r
+ {\r
+ sSubPath = CStringA(s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/));\r
+ }\r
+\r
+ err = g_IndexFileMap.GetFileStatus(sProjectRoot,sSubPath,&statuskind);\r
}\r
+ else\r
+ {\r
+ LPCTSTR lpszSubPath = NULL;\r
+ CString sSubPath;\r
+ CString s = path.GetWinPathString();\r
+ if (s.GetLength() > sProjectRoot.GetLength())\r
+ {\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);\r
+ lpszSubPath = sSubPath;\r
+ }\r
\r
#if 1\r
- // when recursion enabled, let wingit determine the recursive status for folders instead of enumerating all files here\r
- //UINT nFlags = WGEFF_SingleFile;\r
- //if (!bIsRecursive)\r
- // nFlags |= WGEFF_NoRecurse;\r
- //if (!lpszSubPath)\r
- // report root dir as normal (otherwise it could be considered git_wc_status_unversioned, which would be wrong?)\r
- // nFlags |= WGEFF_EmptyAsNormal;\r
+ // when recursion enabled, let wingit determine the recursive status for folders instead of enumerating all files here\r
+ UINT nFlags = WGEFF_SingleFile;\r
+ if (!bIsRecursive)\r
+ nFlags |= WGEFF_NoRecurse;\r
+ if (!lpszSubPath)\r
+ // report root dir as normal (otherwise it could be considered git_wc_status_unversioned, which would be wrong?)\r
+ nFlags |= WGEFF_EmptyAsNormal;\r
#else\r
- // enumerate all files, recursively if requested\r
- UINT nFlags = 0;\r
- if (!bIsRecursive)\r
- nFlags |= WGEFF_NoRecurse;\r
+ // enumerate all files, recursively if requested\r
+ UINT nFlags = 0;\r
+ if (!bIsRecursive)\r
+ nFlags |= WGEFF_NoRecurse;\r
#endif\r
\r
- //err = !wgEnumFiles_safe(CStringA(sProjectRoot), lpszSubPath, nFlags, &getallstatus, &statuskind);\r
- \r
- err = g_IndexFileMap.GetFileStatus(sProjectRoot,sSubPath,&statuskind);\r
+ err = !wgEnumFiles(sProjectRoot, lpszSubPath, nFlags, &getallstatus, &statuskind);\r
\r
- /*err = git_client_status4 (&youngest,\r
+ /*err = git_client_status4 (&youngest,\r
path.GetSVNApiPath(pool),\r
&rev,\r
getallstatus,\r
NULL,\r
ctx,\r
pool);*/\r
+ }\r
\r
// Error present\r
if (err != NULL)\r
// hashbaton.exthash = exthash;\r
hashbaton.pThis = this;\r
\r
- //LPCSTR lpszSubPath = NULL;\r
- CString sSubPath;\r
- CString s = path.GetWinPathString();\r
- if (s.GetLength() > sProjectRoot.GetLength())\r
+#ifdef _TORTOISESHELL\r
+ if (g_ShellCache.GetCacheType() == ShellCache::dll)\r
+#else\r
+ if ((DWORD)CRegStdWORD(_T("Software\\TortoiseGit\\CacheType"), GetSystemMetrics(SM_REMOTESESSION) ? 2 : 1) == 2)\r
+#endif\r
{\r
- sSubPath = CString(s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/));\r
- // lpszSubPath = sSubPath;\r
+ // gitindex.h based status\r
+\r
+ CString sSubPath;\r
+ CString s = path.GetWinPathString();\r
+ if (s.GetLength() > sProjectRoot.GetLength())\r
+ {\r
+ sSubPath = CString(s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/));\r
+ }\r
+\r
+ m_status.prop_status = m_status.text_status = git_wc_status_none;\r
+\r
+ m_err = g_IndexFileMap.GetFileStatus(sProjectRoot,sSubPath,&m_status.text_status);\r
}\r
+ else\r
+ {\r
+ LPCTSTR lpszSubPath = NULL;\r
+ CString sSubPath;\r
+ CString s = path.GetWinPathString();\r
+ if (s.GetLength() > sProjectRoot.GetLength())\r
+ {\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);\r
+ lpszSubPath = sSubPath;\r
+ }\r
\r
- \r
- // when recursion enabled, let wingit determine the recursive status for folders instead of enumerating all files here\r
- //UINT nFlags = WGEFF_SingleFile | WGEFF_NoRecurse;\r
- //if (!lpszSubPath)\r
- // // report root dir as normal (otherwise it could be considered git_wc_status_unversioned, which would be wrong?)\r
- // nFlags |= WGEFF_EmptyAsNormal;\r
+ // when recursion enabled, let wingit determine the recursive status for folders instead of enumerating all files here\r
+ UINT nFlags = WGEFF_SingleFile | WGEFF_NoRecurse;\r
+ if (!lpszSubPath)\r
+ // report root dir as normal (otherwise it could be considered git_wc_status_unversioned, which would be wrong?)\r
+ nFlags |= WGEFF_EmptyAsNormal;\r
\r
- m_status.prop_status = m_status.text_status = git_wc_status_none;\r
+ m_status.prop_status = m_status.text_status = git_wc_status_none;\r
\r
- // NOTE: currently wgEnumFiles_safe_safe_safe will not enumerate file if it isn't versioned (so status will be git_wc_status_none)\r
- //m_err = !wgEnumFiles_safe(CStringA(sProjectRoot), lpszSubPath, nFlags, &getstatus, &m_status);\r
+ // NOTE: currently wgEnumFiles will not enumerate file if it isn't versioned (so status will be git_wc_status_none)\r
+ m_err = !wgEnumFiles(sProjectRoot, lpszSubPath, nFlags, &getstatus, &m_status);\r
\r
- m_err = g_IndexFileMap.GetFileStatus(sProjectRoot,sSubPath,&m_status.text_status);\r
- \r
- /*m_err = git_client_status4 (&youngest,\r
+ /*m_err = git_client_status4 (&youngest,\r
path.GetGitApiPath(m_pool),\r
&rev,\r
getstatushash,\r
NULL,\r
ctx,\r
m_pool);*/\r
-\r
+ }\r
\r
// Error present if function is not under version control\r
if (m_err) /*|| (apr_hash_count(statushash) == 0)*/\r
\r
if (update)\r
{\r
- //const BYTE *sha1 = wgGetRevisionID_safe(CStringA(sProjectRoot), NULL);\r
- //if (sha1)\r
- // youngest = ConvertHashToRevnum(sha1);\r
+ // done to match TSVN functionality of this function (not sure if any code uses the reutrn val)\r
+ // if TGit does not need this, then change the return type of function\r
+ youngest = g_Git.GetHash(CString(_T("HEAD")));\r
}\r
\r
return youngest;\r