+BOOL CCachedDirectory::GetStatusCallback(const struct wgFile_s *pFile, void *pUserData)\r
+{\r
+ CCachedDirectory* pThis = (CCachedDirectory*)pUserData;\r
+\r
+ const char *path = pFile->sFileName;\r
+\r
+ if (path == NULL)\r
+ return FALSE;\r
+\r
+ git_wc_status2_t _status;\r
+ git_wc_status2_t *status = &_status;\r
+\r
+ if ((pFile->nFlags & WGFF_Directory) && pFile->nStatus == WGFS_Unknown)\r
+ status->prop_status = status->text_status = git_wc_status_incomplete;\r
+ else\r
+ status->prop_status = status->text_status = GitStatusFromWingit(pFile->nStatus);\r
+//if (pFile->nStatus > WGFS_Normal) {CStringA s; s.Format("==>%s %d\r\n",pFile->sFileName,pFile->nStatus); OutputDebugStringA(s);}\r
+ CTGitPath svnPath;\r
+\r
+// if(status->entry)\r
+ {\r
+ //if ((status->text_status != git_wc_status_none)&&(status->text_status != git_wc_status_missing))\r
+ svnPath.SetFromGit(path, pFile->nFlags & WGFF_Directory);\r
+ /*else\r
+ svnPath.SetFromGit(path);*/\r
+\r
+ if (pFile->nFlags & WGFF_Directory)\r
+ {\r
+ if ( !svnPath.IsEquivalentToWithoutCase(pThis->m_directoryPath) )\r
+ {\r
+ if (pThis->m_bRecursive)\r
+ {\r
+ // Add any versioned directory, which is not our 'self' entry, to the list for having its status updated\r
+//OutputDebugStringA("AddFolderCrawl: ");OutputDebugStringW(svnPath.GetWinPathString());OutputDebugStringA("\r\n");\r
+ CGitStatusCache::Instance().AddFolderForCrawling(svnPath);\r
+ }\r
+\r
+ // Make sure we know about this child directory\r
+ // This initial status value is likely to be overwritten from below at some point\r
+ git_wc_status_kind s = GitStatus::GetMoreImportant(status->text_status, status->prop_status);\r
+ CCachedDirectory * cdir = CGitStatusCache::Instance().GetDirectoryCacheEntryNoCreate(svnPath);\r
+ if (cdir)\r
+ {\r
+ // This child directory is already in our cache!\r
+ // So ask this dir about its recursive status\r
+ git_wc_status_kind st = GitStatus::GetMoreImportant(s, cdir->GetCurrentFullStatus());\r
+ AutoLocker lock(pThis->m_critSec);\r
+ pThis->m_childDirectories[svnPath] = st;\r
+ }\r
+ else\r
+ {\r
+ // the child directory is not in the cache. Create a new entry for it in the cache which is\r
+ // initially 'unversioned'. But we added that directory to the crawling list above, which\r
+ // means the cache will be updated soon.\r
+ CGitStatusCache::Instance().GetDirectoryCacheEntry(svnPath);\r
+ AutoLocker lock(pThis->m_critSec);\r
+ pThis->m_childDirectories[svnPath] = s;\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ // Keep track of the most important status of all the files in this directory\r
+ // Don't include subdirectories in this figure, because they need to provide their \r
+ // own 'most important' value\r
+ pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, status->text_status);\r
+ pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, status->prop_status);\r
+ if (((status->text_status == git_wc_status_unversioned)||(status->text_status == git_wc_status_none))\r
+ &&(CGitStatusCache::Instance().IsUnversionedAsModified()))\r
+ {\r
+ // treat unversioned files as modified\r
+ if (pThis->m_mostImportantFileStatus != git_wc_status_added)\r
+ pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, git_wc_status_modified);\r
+ }\r
+ }\r
+ }\r
+#if 0\r
+ else\r
+ {\r
+ svnPath.SetFromGit(path);\r
+ // Subversion returns no 'entry' field for versioned folders if they're\r
+ // part of another working copy (nested layouts).\r
+ // So we have to make sure that such an 'unversioned' folder really\r
+ // is unversioned.\r
+ if (((status->text_status == git_wc_status_unversioned)||(status->text_status == git_wc_status_missing))&&(!svnPath.IsEquivalentToWithoutCase(pThis->m_directoryPath))&&(svnPath.IsDirectory()))\r
+ {\r
+ if (svnPath.HasAdminDir())\r
+ {\r
+ CGitStatusCache::Instance().AddFolderForCrawling(svnPath);\r
+ // Mark the directory as 'versioned' (status 'normal' for now).\r
+ // This initial value will be overwritten from below some time later\r
+ {\r
+ AutoLocker lock(pThis->m_critSec);\r
+ pThis->m_childDirectories[svnPath] = git_wc_status_normal;\r
+ }\r
+ // Make sure the entry is also in the cache\r
+ CGitStatusCache::Instance().GetDirectoryCacheEntry(svnPath);\r
+ // also mark the status in the status object as normal\r
+ status->text_status = git_wc_status_normal;\r
+ }\r
+ }\r
+ else if (status->text_status == git_wc_status_external)\r
+ {\r
+ CGitStatusCache::Instance().AddFolderForCrawling(svnPath);\r
+ // Mark the directory as 'versioned' (status 'normal' for now).\r
+ // This initial value will be overwritten from below some time later\r
+ {\r
+ AutoLocker lock(pThis->m_critSec);\r
+ pThis->m_childDirectories[svnPath] = git_wc_status_normal;\r
+ }\r
+ // we have added a directory to the child-directory list of this\r
+ // directory. We now must make sure that this directory also has\r
+ // an entry in the cache.\r
+ CGitStatusCache::Instance().GetDirectoryCacheEntry(svnPath);\r
+ // also mark the status in the status object as normal\r
+ status->text_status = git_wc_status_normal;\r
+ }\r
+ else\r
+ {\r
+ if (svnPath.IsDirectory())\r
+ {\r
+ AutoLocker lock(pThis->m_critSec);\r
+ pThis->m_childDirectories[svnPath] = GitStatus::GetMoreImportant(status->text_status, status->prop_status);\r
+ }\r
+ else if ((CGitStatusCache::Instance().IsUnversionedAsModified())&&(status->text_status != git_wc_status_missing))\r
+ {\r
+ // make this unversioned item change the most important status of this\r
+ // folder to modified if it doesn't already have another status\r
+ if (pThis->m_mostImportantFileStatus != git_wc_status_added)\r
+ pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, git_wc_status_modified);\r
+ }\r
+ }\r
+ }\r
+#endif\r
+\r
+ pThis->AddEntry(svnPath, status);\r
+\r
+ return FALSE;\r
+}\r
+\r
+#if 0\r