OSDN Git Service

6460789f9dcd3b0d848c0a64623a414663e434c2
[tortoisegit/TortoiseGitJp.git] / src / TGitCache / CachedDirectory.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // External Cache Copyright (C) 2005-2008 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #include "StdAfx.h"\r
20 #include ".\cacheddirectory.h"\r
21 //#include "SVNHelpers.h"\r
22 #include "GitStatusCache.h"\r
23 #include "GitStatus.h"\r
24 #include <set>\r
25 \r
26 CCachedDirectory::CCachedDirectory(void)\r
27 {\r
28         m_indexFileTime = 0;\r
29 //      m_propsFileTime = 0;\r
30         m_currentStatusFetchingPathTicks = 0;\r
31         m_bCurrentFullStatusValid = false;\r
32         m_currentFullStatus = m_mostImportantFileStatus = git_wc_status_none;\r
33         m_bRecursive = true;\r
34 }\r
35 \r
36 CCachedDirectory::~CCachedDirectory(void)\r
37 {\r
38 }\r
39 \r
40 CCachedDirectory::CCachedDirectory(const CTGitPath& directoryPath)\r
41 {\r
42         ATLASSERT(directoryPath.IsDirectory() || !PathFileExists(directoryPath.GetWinPath()));\r
43 \r
44         m_directoryPath = directoryPath;\r
45         m_indexFileTime = 0;\r
46 //      m_propsFileTime = 0;\r
47         m_currentStatusFetchingPathTicks = 0;\r
48         m_bCurrentFullStatusValid = false;\r
49         m_currentFullStatus = m_mostImportantFileStatus = git_wc_status_none;\r
50         m_bRecursive = true;\r
51 }\r
52 \r
53 BOOL CCachedDirectory::SaveToDisk(FILE * pFile)\r
54 {\r
55         AutoLocker lock(m_critSec);\r
56 #define WRITEVALUETOFILE(x) if (fwrite(&x, sizeof(x), 1, pFile)!=1) return false;\r
57 \r
58         unsigned int value = 1;\r
59         WRITEVALUETOFILE(value);        // 'version' of this save-format\r
60         value = (int)m_entryCache.size();\r
61         WRITEVALUETOFILE(value);        // size of the cache map\r
62         // now iterate through the maps and save every entry.\r
63         for (CacheEntryMap::iterator I = m_entryCache.begin(); I != m_entryCache.end(); ++I)\r
64         {\r
65                 const CString& key = I->first;\r
66                 value = key.GetLength();\r
67                 WRITEVALUETOFILE(value);\r
68                 if (value)\r
69                 {\r
70                         if (fwrite((LPCTSTR)key, sizeof(TCHAR), value, pFile)!=value)\r
71                                 return false;\r
72                         if (!I->second.SaveToDisk(pFile))\r
73                                 return false;\r
74                 }\r
75         }\r
76         value = (int)m_childDirectories.size();\r
77         WRITEVALUETOFILE(value);\r
78         for (ChildDirStatus::iterator I = m_childDirectories.begin(); I != m_childDirectories.end(); ++I)\r
79         {\r
80                 const CString& path = I->first.GetWinPathString();\r
81                 value = path.GetLength();\r
82                 WRITEVALUETOFILE(value);\r
83                 if (value)\r
84                 {\r
85                         if (fwrite((LPCTSTR)path, sizeof(TCHAR), value, pFile)!=value)\r
86                                 return false;\r
87                         git_wc_status_kind status = I->second;\r
88                         WRITEVALUETOFILE(status);\r
89                 }\r
90         }\r
91         WRITEVALUETOFILE(m_indexFileTime);\r
92 //      WRITEVALUETOFILE(m_propsFileTime);\r
93         value = m_directoryPath.GetWinPathString().GetLength();\r
94         WRITEVALUETOFILE(value);\r
95         if (value)\r
96         {\r
97                 if (fwrite(m_directoryPath.GetWinPath(), sizeof(TCHAR), value, pFile)!=value)\r
98                         return false;\r
99         }\r
100         if (!m_ownStatus.SaveToDisk(pFile))\r
101                 return false;\r
102         WRITEVALUETOFILE(m_currentFullStatus);\r
103         WRITEVALUETOFILE(m_mostImportantFileStatus);\r
104         return true;\r
105 }\r
106 \r
107 BOOL CCachedDirectory::LoadFromDisk(FILE * pFile)\r
108 {\r
109         AutoLocker lock(m_critSec);\r
110 #define LOADVALUEFROMFILE(x) if (fread(&x, sizeof(x), 1, pFile)!=1) return false;\r
111         try\r
112         {\r
113                 unsigned int value = 0;\r
114                 LOADVALUEFROMFILE(value);\r
115                 if (value != 1)\r
116                         return false;           // not the correct version\r
117                 int mapsize = 0;\r
118                 LOADVALUEFROMFILE(mapsize);\r
119                 for (int i=0; i<mapsize; ++i)\r
120                 {\r
121                         LOADVALUEFROMFILE(value);\r
122                         if (value > MAX_PATH)\r
123                                 return false;\r
124                         if (value)\r
125                         {\r
126                                 CString sKey;\r
127                                 if (fread(sKey.GetBuffer(value+1), sizeof(TCHAR), value, pFile)!=value)\r
128                                 {\r
129                                         sKey.ReleaseBuffer(0);\r
130                                         return false;\r
131                                 }\r
132                                 sKey.ReleaseBuffer(value);\r
133                                 CStatusCacheEntry entry;\r
134                                 if (!entry.LoadFromDisk(pFile))\r
135                                         return false;\r
136                                 m_entryCache[sKey] = entry;\r
137                         }\r
138                 }\r
139                 LOADVALUEFROMFILE(mapsize);\r
140                 for (int i=0; i<mapsize; ++i)\r
141                 {\r
142                         LOADVALUEFROMFILE(value);\r
143                         if (value > MAX_PATH)\r
144                                 return false;\r
145                         if (value)\r
146                         {\r
147                                 CString sPath;\r
148                                 if (fread(sPath.GetBuffer(value), sizeof(TCHAR), value, pFile)!=value)\r
149                                 {\r
150                                         sPath.ReleaseBuffer(0);\r
151                                         return false;\r
152                                 }\r
153                                 sPath.ReleaseBuffer(value);\r
154                                 git_wc_status_kind status;\r
155                                 LOADVALUEFROMFILE(status);\r
156                                 m_childDirectories[CTGitPath(sPath)] = status;\r
157                         }\r
158                 }\r
159                 LOADVALUEFROMFILE(m_indexFileTime);\r
160 //              LOADVALUEFROMFILE(m_propsFileTime);\r
161                 LOADVALUEFROMFILE(value);\r
162                 if (value > MAX_PATH)\r
163                         return false;\r
164                 if (value)\r
165                 {\r
166                         CString sPath;\r
167                         if (fread(sPath.GetBuffer(value+1), sizeof(TCHAR), value, pFile)!=value)\r
168                         {\r
169                                 sPath.ReleaseBuffer(0);\r
170                                 return false;\r
171                         }\r
172                         sPath.ReleaseBuffer(value);\r
173                         m_directoryPath.SetFromWin(sPath);\r
174                 }\r
175                 if (!m_ownStatus.LoadFromDisk(pFile))\r
176                         return false;\r
177 \r
178                 LOADVALUEFROMFILE(m_currentFullStatus);\r
179                 LOADVALUEFROMFILE(m_mostImportantFileStatus);\r
180         }\r
181         catch ( CAtlException )\r
182         {\r
183                 return false;\r
184         }\r
185         return true;\r
186 \r
187 }\r
188 \r
189 CStatusCacheEntry CCachedDirectory::GetStatusForMember(const CTGitPath& path, bool bRecursive,  bool bFetch /* = true */)\r
190 {\r
191         CString strCacheKey;\r
192         bool bThisDirectoryIsUnversioned = false;\r
193         bool bRequestForSelf = false;\r
194         if(path.IsEquivalentToWithoutCase(m_directoryPath))\r
195         {\r
196                 bRequestForSelf = true;\r
197         }\r
198 //OutputDebugStringA("GetStatusForMember: ");OutputDebugStringW(path.GetWinPathString());OutputDebugStringA("\r\n");\r
199         // In all most circumstances, we ask for the status of a member of this directory.\r
200         ATLASSERT(m_directoryPath.IsEquivalentToWithoutCase(path.GetContainingDirectory()) || bRequestForSelf);\r
201 \r
202         CString sProjectRoot;\r
203         const BOOL bIsVersionedPath = m_directoryPath.HasAdminDir(&sProjectRoot);\r
204 \r
205         // Check if the index file has been changed\r
206         CTGitPath indexFilePath(bIsVersionedPath ? sProjectRoot : m_directoryPath);\r
207 //      CTGitPath propsDirPath(m_directoryPath);\r
208         if (g_GitAdminDir.IsVSNETHackActive())\r
209         {\r
210                 indexFilePath.AppendPathString(g_GitAdminDir.GetVSNETAdminDirName() + _T("\\index"));\r
211 //              propsDirPath.AppendPathString(g_GitAdminDir.GetVSNETAdminDirName() + _T("\\dir-props"));\r
212         }\r
213         else\r
214         {\r
215                 indexFilePath.AppendPathString(g_GitAdminDir.GetAdminDirName() + _T("\\index"));\r
216 //              propsDirPath.AppendPathString(g_GitAdminDir.GetAdminDirName() + _T("\\dir-props"));\r
217         }\r
218         if ( (m_indexFileTime == indexFilePath.GetLastWriteTime()) /*&& ((indexFilePath.GetLastWriteTime() == 0) || (m_propsFileTime == propsDirPath.GetLastWriteTime()))*/ )\r
219         {\r
220 //              m_indexFileTime = indexFilePath.GetLastWriteTime();\r
221 //              if (m_indexFileTime)\r
222 //                      m_propsFileTime = propsDirPath.GetLastWriteTime();\r
223 \r
224                 //if(m_indexFileTime == 0)\r
225                 // a newly created project (without commits) has no index file but we still want it to count as versioned\r
226                 if(m_indexFileTime == 0 && !bIsVersionedPath)\r
227                 {\r
228                         // We are a folder which is not in a working copy\r
229                         bThisDirectoryIsUnversioned = true;\r
230                         m_ownStatus.SetStatus(NULL);\r
231 \r
232                         // If a user removes the .git directory, we get here with m_entryCache\r
233                         // not being empty, but still us being unversioned\r
234                         if (!m_entryCache.empty())\r
235                         {\r
236                                 m_entryCache.clear();\r
237                         }\r
238                         ATLASSERT(m_entryCache.empty());\r
239 \r
240                         // However, a member *DIRECTORY* might be the top of WC\r
241                         // so we need to ask them to get their own status\r
242                         if(!path.IsDirectory())\r
243                         {\r
244                                 if ((PathFileExists(path.GetWinPath()))||(bRequestForSelf))\r
245                                         return CStatusCacheEntry();\r
246                                 // the entry doesn't exist anymore! \r
247                                 // but we can't remove it from the cache here:\r
248                                 // the GetStatusForMember() method is called only with a read\r
249                                 // lock and not a write lock!\r
250                                 // So mark it for crawling, and let the crawler remove it\r
251                                 // later\r
252                                 CGitStatusCache::Instance().AddFolderForCrawling(path.GetContainingDirectory());\r
253 \r
254                                 return CStatusCacheEntry();\r
255                         }\r
256                         else\r
257                         {\r
258                                 // If we're in the special case of a directory being asked for its own status\r
259                                 // and this directory is unversioned, then we should just return that here\r
260                                 if(bRequestForSelf)\r
261                                         return CStatusCacheEntry();\r
262                         }\r
263                 }\r
264 \r
265                 if(path.IsDirectory())\r
266                 {\r
267                         // We don't have directory status in our cache\r
268                         // Ask the directory if it knows its own status\r
269                         CCachedDirectory * dirEntry = CGitStatusCache::Instance().GetDirectoryCacheEntry(path);\r
270                         if ((dirEntry)&&(dirEntry->IsOwnStatusValid()))\r
271                         {\r
272                                 // To keep recursive status up to date, we'll request that children are all crawled again\r
273                                 // This will be very quick if nothings changed, because it will all be cache hits\r
274                                 if (bRecursive)\r
275                                 {\r
276                                         AutoLocker lock(dirEntry->m_critSec);\r
277                                         ChildDirStatus::const_iterator it;\r
278                                         for(it = dirEntry->m_childDirectories.begin(); it != dirEntry->m_childDirectories.end(); ++it)\r
279                                         {\r
280                                                 CGitStatusCache::Instance().AddFolderForCrawling(it->first);\r
281                                         }\r
282                                 }\r
283                                 return dirEntry->GetOwnStatus(bRecursive);\r
284                         }\r
285                 }\r
286                 else\r
287                 {\r
288                         {\r
289                                 // if we currently are fetching the status of the directory\r
290                                 // we want the status for, we just return an empty entry here\r
291                                 // and don't wait for that fetching to finish.\r
292                                 // That's because fetching the status can take a *really* long\r
293                                 // time (e.g. if a commit is also in progress on that same\r
294                                 // directory), and we don't want to make the explorer appear\r
295                                 // to hang.\r
296                                 AutoLocker pathlock(m_critSecPath);\r
297                                 if ((!bFetch)&&(!m_currentStatusFetchingPath.IsEmpty()))\r
298                                 {\r
299                                         if ((m_currentStatusFetchingPath.IsAncestorOf(path))&&((m_currentStatusFetchingPathTicks + 1000)<GetTickCount()))\r
300                                         {\r
301                                                 ATLTRACE(_T("returning empty status (status fetch in progress) for %s\n"), path.GetWinPath());\r
302                                                 m_currentFullStatus = m_mostImportantFileStatus = git_wc_status_none;\r
303                                                 return CStatusCacheEntry();\r
304                                         }\r
305                                 }\r
306                         }\r
307                         // Look up a file in our own cache\r
308                         AutoLocker lock(m_critSec);\r
309                         strCacheKey = GetCacheKey(path);\r
310                         CacheEntryMap::iterator itMap = m_entryCache.find(strCacheKey);\r
311                         if(itMap != m_entryCache.end())\r
312                         {\r
313                                 // We've hit the cache - check for timeout\r
314                                 if(!itMap->second.HasExpired((long)GetTickCount()))\r
315                                 {\r
316                                         if(itMap->second.DoesFileTimeMatch(path.GetLastWriteTime()))\r
317                                         {\r
318                                                 if ((itMap->second.GetEffectiveStatus()!=git_wc_status_missing)||(!PathFileExists(path.GetWinPath())))\r
319                                                 {\r
320                                                         // Note: the filetime matches after a modified has been committed too.\r
321                                                         // So in that case, we would return a wrong status (e.g. 'modified' instead\r
322                                                         // of 'normal') here.\r
323                                                         return itMap->second;\r
324                                                 }\r
325                                         }\r
326                                 }\r
327                         }\r
328                 }\r
329         }\r
330         else\r
331         {\r
332                 AutoLocker pathlock(m_critSecPath);\r
333                 if ((!bFetch)&&(!m_currentStatusFetchingPath.IsEmpty()))\r
334                 {\r
335                         if ((m_currentStatusFetchingPath.IsAncestorOf(path))&&((m_currentStatusFetchingPathTicks + 1000)<GetTickCount()))\r
336                         {\r
337                                 ATLTRACE(_T("returning empty status (status fetch in progress) for %s\n"), path.GetWinPath());\r
338                                 m_currentFullStatus = m_mostImportantFileStatus = git_wc_status_none;\r
339                                 return CStatusCacheEntry();\r
340                         }\r
341                 }\r
342                 // if we're fetching the status for the explorer,\r
343                 // we don't refresh the status but use the one\r
344                 // we already have (to save time and make the explorer\r
345                 // more responsive in stress conditions).\r
346                 // We leave the refreshing to the crawler.\r
347                 if ((!bFetch)&&(m_indexFileTime))\r
348                 {\r
349                         CGitStatusCache::Instance().AddFolderForCrawling(path.GetDirectory());\r
350                         return CStatusCacheEntry();\r
351                 }\r
352                 AutoLocker lock(m_critSec);\r
353                 m_indexFileTime = indexFilePath.GetLastWriteTime();\r
354 //              m_propsFileTime = propsDirPath.GetLastWriteTime();\r
355                 m_entryCache.clear();\r
356                 strCacheKey = GetCacheKey(path);\r
357         }\r
358 \r
359 //      svn_opt_revision_t revision;\r
360 //      revision.kind = svn_opt_revision_unspecified;\r
361 \r
362         // We've not got this item in the cache - let's add it\r
363         // We never bother asking SVN for the status of just one file, always for its containing directory\r
364 \r
365         if (g_GitAdminDir.IsAdminDirPath(path.GetWinPathString()))\r
366         {\r
367                 // We're being asked for the status of an .git directory\r
368                 // It's not worth asking for this\r
369                 return CStatusCacheEntry();\r
370         }\r
371 \r
372         {\r
373                 {\r
374                         AutoLocker pathlock(m_critSecPath);\r
375                         if ((!bFetch)&&(!m_currentStatusFetchingPath.IsEmpty()))\r
376                         {\r
377                                 if ((m_currentStatusFetchingPath.IsAncestorOf(path))&&((m_currentStatusFetchingPathTicks + 1000)<GetTickCount()))\r
378                                 {\r
379                                         ATLTRACE(_T("returning empty status (status fetch in progress) for %s\n"), path.GetWinPath());\r
380                                         m_currentFullStatus = m_mostImportantFileStatus = git_wc_status_none;\r
381                                         return CStatusCacheEntry();\r
382                                 }\r
383                         }\r
384                 }\r
385 //              SVNPool subPool(CGitStatusCache::Instance().m_svnHelp.Pool());\r
386                 {\r
387                         AutoLocker lock(m_critSec);\r
388                         m_mostImportantFileStatus = git_wc_status_none;\r
389                         m_childDirectories.clear();\r
390                         m_entryCache.clear();\r
391                         m_ownStatus.SetStatus(NULL);\r
392                         m_bRecursive = bRecursive;\r
393                 }\r
394                 if(!bThisDirectoryIsUnversioned)\r
395                 {\r
396                         {\r
397                                 AutoLocker pathlock(m_critSecPath);\r
398                                 m_currentStatusFetchingPath = m_directoryPath;\r
399                                 m_currentStatusFetchingPathTicks = GetTickCount();\r
400                         }\r
401                         ATLTRACE(_T("git_enum_files for '%s' (req %s)\n"), m_directoryPath.GetWinPath(), path.GetWinPath());\r
402 \r
403                         CString sProjectRoot;\r
404                         m_directoryPath.HasAdminDir(&sProjectRoot);\r
405                         ATLASSERT( !m_directoryPath.IsEmpty() );\r
406 \r
407                         LPCTSTR lpszSubPath = NULL;\r
408                         CString sSubPath;\r
409                         CString s = m_directoryPath.GetDirectory().GetWinPathString();\r
410                         if (s.GetLength() > sProjectRoot.GetLength())\r
411                         {\r
412                                 sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);\r
413                                 lpszSubPath = sSubPath;\r
414                         }\r
415 //MessageBoxA(NULL, CStringA(sProjectRoot), sSubPath, MB_OK);\r
416 //OutputDebugStringA("###");OutputDebugStringW(sProjectRoot);OutputDebugStringA(" - ");OutputDebugStringA(sSubPath);OutputDebugStringA("\r\n");\r
417                         BOOL pErr = !wgEnumFiles(sProjectRoot, lpszSubPath, WGEFF_NoRecurse|WGEFF_FullPath, &GetStatusCallback, this);\r
418 \r
419                         /*git_error_t* pErr = svn_client_status4 (\r
420                                 NULL,\r
421                                 m_directoryPath.GetSVNApiPath(subPool),\r
422                                 &revision,\r
423                                 GetStatusCallback,\r
424                                 this,\r
425                                 svn_depth_immediates,\r
426                                 TRUE,                                                                   //getall\r
427                                 FALSE,\r
428                                 TRUE,                                                                   //noignore\r
429                                 FALSE,                                                                  //ignore externals\r
430                                 NULL,                                                                   //changelists\r
431                                 CGitStatusCache::Instance().m_svnHelp.ClientContext(),\r
432                                 subPool\r
433                                 );*/\r
434                         {\r
435                                 AutoLocker pathlock(m_critSecPath);\r
436                                 m_currentStatusFetchingPath.Reset();\r
437                         }\r
438                         ATLTRACE(_T("git_enum_files finished for '%s'\n"), m_directoryPath.GetWinPath(), path.GetWinPath());\r
439                         if(pErr)\r
440                         {\r
441                                 // Handle an error\r
442                                 // The most likely error on a folder is that it's not part of a WC\r
443                                 // In most circumstances, this will have been caught earlier,\r
444                                 // but in some situations, we'll get this error.\r
445                                 // If we allow ourselves to fall on through, then folders will be asked\r
446                                 // for their own status, and will set themselves as unversioned, for the \r
447                                 // benefit of future requests\r
448 //                              ATLTRACE("git_enum_files err: '%s'\n", pErr->message);\r
449 //                              svn_error_clear(pErr);\r
450                                 // No assert here! Since we _can_ get here, an assertion is not an option!\r
451                                 // Reasons to get here: \r
452                                 // - renaming a folder with many sub folders --> results in "not a working copy" if the revert\r
453                                 //   happens between our checks and the svn_client_status() call.\r
454                                 // - reverting a move/copy --> results in "not a working copy" (as above)\r
455                                 if (!m_directoryPath.HasAdminDir())\r
456                                 {\r
457                                         m_currentFullStatus = m_mostImportantFileStatus = git_wc_status_none;\r
458                                         return CStatusCacheEntry();\r
459                                 }\r
460                                 else\r
461                                 {\r
462                                         ATLTRACE("git_enum_files error, assume none status\n");\r
463                                         // Since we only assume a none status here due to svn_client_status()\r
464                                         // returning an error, make sure that this status times out soon.\r
465                                         CGitStatusCache::Instance().m_folderCrawler.BlockPath(m_directoryPath, 2000);\r
466                                         CGitStatusCache::Instance().AddFolderForCrawling(m_directoryPath);\r
467                                         return CStatusCacheEntry();\r
468                                 }\r
469                         }\r
470                 }\r
471                 else\r
472                 {\r
473                         ATLTRACE("Skipped git status for unversioned folder\n");\r
474                 }\r
475         }\r
476         // Now that we've refreshed our SVN status, we can see if it's \r
477         // changed the 'most important' status value for this directory.\r
478         // If it has, then we should tell our parent\r
479         UpdateCurrentStatus();\r
480 \r
481         if (path.IsDirectory())\r
482         {\r
483                 CCachedDirectory * dirEntry = CGitStatusCache::Instance().GetDirectoryCacheEntry(path);\r
484                 if ((dirEntry)&&(dirEntry->IsOwnStatusValid()))\r
485                 {\r
486                         CGitStatusCache::Instance().AddFolderForCrawling(path);\r
487                         return dirEntry->GetOwnStatus(bRecursive);\r
488                 }\r
489 \r
490                 // If the status *still* isn't valid here, it means that \r
491                 // the current directory is unversioned, and we shall need to ask its children for info about themselves\r
492                 if (dirEntry)\r
493                         return dirEntry->GetStatusForMember(path,bRecursive);\r
494                 CGitStatusCache::Instance().AddFolderForCrawling(path);\r
495                 return CStatusCacheEntry();\r
496         }\r
497         else\r
498         {\r
499                 CacheEntryMap::iterator itMap = m_entryCache.find(strCacheKey);\r
500                 if(itMap != m_entryCache.end())\r
501                 {\r
502                         return itMap->second;\r
503                 }\r
504         }\r
505 \r
506         AddEntry(path, NULL);\r
507         return CStatusCacheEntry();\r
508 }\r
509 \r
510 void \r
511 CCachedDirectory::AddEntry(const CTGitPath& path, const git_wc_status2_t* pGitStatus, DWORD validuntil /* = 0*/)\r
512 {\r
513         AutoLocker lock(m_critSec);\r
514         if(path.IsDirectory())\r
515         {\r
516                 CCachedDirectory * childDir = CGitStatusCache::Instance().GetDirectoryCacheEntry(path);\r
517                 if (childDir)\r
518                 {\r
519                         if ((childDir->GetCurrentFullStatus() != git_wc_status_missing)||(pGitStatus==NULL)||(pGitStatus->text_status != git_wc_status_unversioned))\r
520                                 childDir->m_ownStatus.SetStatus(pGitStatus);\r
521                         childDir->m_ownStatus.SetKind(git_node_dir);\r
522                 }\r
523         }\r
524         else\r
525         {\r
526                 CString cachekey = GetCacheKey(path);\r
527                 CacheEntryMap::iterator entry_it = m_entryCache.lower_bound(cachekey);\r
528                 if (entry_it != m_entryCache.end() && entry_it->first == cachekey)\r
529                 {\r
530                         if (pGitStatus)\r
531                         {\r
532                                 if (entry_it->second.GetEffectiveStatus() > git_wc_status_none &&\r
533                                         entry_it->second.GetEffectiveStatus() != GitStatus::GetMoreImportant(pGitStatus->prop_status, pGitStatus->text_status))\r
534                                 {\r
535                                         CGitStatusCache::Instance().UpdateShell(path);\r
536                                         ATLTRACE(_T("shell update for %s\n"), path.GetWinPath());\r
537                                 }\r
538                         }\r
539                 }\r
540                 else\r
541                 {\r
542                         entry_it = m_entryCache.insert(entry_it, std::make_pair(cachekey, CStatusCacheEntry()));\r
543                 }\r
544                 entry_it->second = CStatusCacheEntry(pGitStatus, path.GetLastWriteTime(), path.IsReadOnly(), validuntil);\r
545                 // TEMP(?): git status doesn't not have "entry" that contains node type, so manually set as file\r
546                 entry_it->second.SetKind(git_node_file);\r
547         }\r
548 }\r
549 \r
550 \r
551 CString \r
552 CCachedDirectory::GetCacheKey(const CTGitPath& path)\r
553 {\r
554         // All we put into the cache as a key is just the end portion of the pathname\r
555         // There's no point storing the path of the containing directory for every item\r
556         return path.GetWinPathString().Mid(m_directoryPath.GetWinPathString().GetLength());\r
557 }\r
558 \r
559 CString \r
560 CCachedDirectory::GetFullPathString(const CString& cacheKey)\r
561 {\r
562         return m_directoryPath.GetWinPathString() + _T("\\") + cacheKey;\r
563 }\r
564 \r
565 BOOL CCachedDirectory::GetStatusCallback(const struct wgFile_s *pFile, void *pUserData)\r
566 {\r
567         CCachedDirectory* pThis = (CCachedDirectory*)pUserData;\r
568 \r
569         const TCHAR *path = pFile->sFileName;\r
570 \r
571         if (path == NULL)\r
572                 return FALSE;\r
573 \r
574         git_wc_status2_t _status;\r
575         git_wc_status2_t *status = &_status;\r
576 \r
577         if ((pFile->nFlags & WGFF_Directory) && pFile->nStatus == WGFS_Unknown)\r
578                 status->prop_status = status->text_status = git_wc_status_incomplete;\r
579         else\r
580                 status->prop_status = status->text_status = GitStatusFromWingit(pFile->nStatus);\r
581 //if (pFile->nStatus > WGFS_Normal) {CStringA s; s.Format("==>%s %d\r\n",pFile->sFileName,pFile->nStatus); OutputDebugStringA(s);}\r
582         CTGitPath svnPath;\r
583 \r
584 //      if(status->entry)\r
585         {\r
586                 //if ((status->text_status != git_wc_status_none)&&(status->text_status != git_wc_status_missing))\r
587                         svnPath.SetFromGit(path, pFile->nFlags & WGFF_Directory);\r
588                 /*else\r
589                         svnPath.SetFromGit(path);*/\r
590 \r
591                 if (pFile->nFlags & WGFF_Directory)\r
592                 {\r
593                         if ( !svnPath.IsEquivalentToWithoutCase(pThis->m_directoryPath) )\r
594                         {\r
595                                 if (pThis->m_bRecursive)\r
596                                 {\r
597                                         // Add any versioned directory, which is not our 'self' entry, to the list for having its status updated\r
598 //OutputDebugStringA("AddFolderCrawl: ");OutputDebugStringW(svnPath.GetWinPathString());OutputDebugStringA("\r\n");\r
599                                         CGitStatusCache::Instance().AddFolderForCrawling(svnPath);\r
600                                 }\r
601 \r
602                                 // Make sure we know about this child directory\r
603                                 // This initial status value is likely to be overwritten from below at some point\r
604                                 git_wc_status_kind s = GitStatus::GetMoreImportant(status->text_status, status->prop_status);\r
605                                 CCachedDirectory * cdir = CGitStatusCache::Instance().GetDirectoryCacheEntryNoCreate(svnPath);\r
606                                 if (cdir)\r
607                                 {\r
608                                         // This child directory is already in our cache!\r
609                                         // So ask this dir about its recursive status\r
610                                         git_wc_status_kind st = GitStatus::GetMoreImportant(s, cdir->GetCurrentFullStatus());\r
611                                         AutoLocker lock(pThis->m_critSec);\r
612                                         pThis->m_childDirectories[svnPath] = st;\r
613                                 }\r
614                                 else\r
615                                 {\r
616                                         // the child directory is not in the cache. Create a new entry for it in the cache which is\r
617                                         // initially 'unversioned'. But we added that directory to the crawling list above, which\r
618                                         // means the cache will be updated soon.\r
619                                         CGitStatusCache::Instance().GetDirectoryCacheEntry(svnPath);\r
620                                         AutoLocker lock(pThis->m_critSec);\r
621                                         pThis->m_childDirectories[svnPath] = s;\r
622                                 }\r
623                         }\r
624                 }\r
625                 else\r
626                 {\r
627                         // Keep track of the most important status of all the files in this directory\r
628                         // Don't include subdirectories in this figure, because they need to provide their \r
629                         // own 'most important' value\r
630                         pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, status->text_status);\r
631                         pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, status->prop_status);\r
632                         if (((status->text_status == git_wc_status_unversioned)||(status->text_status == git_wc_status_none))\r
633                                 &&(CGitStatusCache::Instance().IsUnversionedAsModified()))\r
634                         {\r
635                                 // treat unversioned files as modified\r
636                                 if (pThis->m_mostImportantFileStatus != git_wc_status_added)\r
637                                         pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, git_wc_status_modified);\r
638                         }\r
639                 }\r
640         }\r
641 #if 0\r
642         else\r
643         {\r
644                 svnPath.SetFromGit(path);\r
645                 // Subversion returns no 'entry' field for versioned folders if they're\r
646                 // part of another working copy (nested layouts).\r
647                 // So we have to make sure that such an 'unversioned' folder really\r
648                 // is unversioned.\r
649                 if (((status->text_status == git_wc_status_unversioned)||(status->text_status == git_wc_status_missing))&&(!svnPath.IsEquivalentToWithoutCase(pThis->m_directoryPath))&&(svnPath.IsDirectory()))\r
650                 {\r
651                         if (svnPath.HasAdminDir())\r
652                         {\r
653                                 CGitStatusCache::Instance().AddFolderForCrawling(svnPath);\r
654                                 // Mark the directory as 'versioned' (status 'normal' for now).\r
655                                 // This initial value will be overwritten from below some time later\r
656                                 {\r
657                                         AutoLocker lock(pThis->m_critSec);\r
658                                         pThis->m_childDirectories[svnPath] = git_wc_status_normal;\r
659                                 }\r
660                                 // Make sure the entry is also in the cache\r
661                                 CGitStatusCache::Instance().GetDirectoryCacheEntry(svnPath);\r
662                                 // also mark the status in the status object as normal\r
663                                 status->text_status = git_wc_status_normal;\r
664                         }\r
665                 }\r
666                 else if (status->text_status == git_wc_status_external)\r
667                 {\r
668                         CGitStatusCache::Instance().AddFolderForCrawling(svnPath);\r
669                         // Mark the directory as 'versioned' (status 'normal' for now).\r
670                         // This initial value will be overwritten from below some time later\r
671                         {\r
672                                 AutoLocker lock(pThis->m_critSec);\r
673                                 pThis->m_childDirectories[svnPath] = git_wc_status_normal;\r
674                         }\r
675                         // we have added a directory to the child-directory list of this\r
676                         // directory. We now must make sure that this directory also has\r
677                         // an entry in the cache.\r
678                         CGitStatusCache::Instance().GetDirectoryCacheEntry(svnPath);\r
679                         // also mark the status in the status object as normal\r
680                         status->text_status = git_wc_status_normal;\r
681                 }\r
682                 else\r
683                 {\r
684                         if (svnPath.IsDirectory())\r
685                         {\r
686                                 AutoLocker lock(pThis->m_critSec);\r
687                                 pThis->m_childDirectories[svnPath] = GitStatus::GetMoreImportant(status->text_status, status->prop_status);\r
688                         }\r
689                         else if ((CGitStatusCache::Instance().IsUnversionedAsModified())&&(status->text_status != git_wc_status_missing))\r
690                         {\r
691                                 // make this unversioned item change the most important status of this\r
692                                 // folder to modified if it doesn't already have another status\r
693                                 if (pThis->m_mostImportantFileStatus != git_wc_status_added)\r
694                                         pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, git_wc_status_modified);\r
695                         }\r
696                 }\r
697         }\r
698 #endif\r
699 \r
700         pThis->AddEntry(svnPath, status);\r
701 \r
702         return FALSE;\r
703 }\r
704 \r
705 #if 0\r
706 git_error_t * CCachedDirectory::GetStatusCallback(void *baton, const char *path, git_wc_status2_t *status)\r
707 {\r
708         CCachedDirectory* pThis = (CCachedDirectory*)baton;\r
709 \r
710         if (path == NULL)\r
711                 return 0;\r
712                 \r
713         CTGitPath svnPath;\r
714 \r
715         if(status->entry)\r
716         {\r
717                 if ((status->text_status != git_wc_status_none)&&(status->text_status != git_wc_status_missing))\r
718                         svnPath.SetFromSVN(path, (status->entry->kind == svn_node_dir));\r
719                 else\r
720                         svnPath.SetFromSVN(path);\r
721 \r
722                 if(svnPath.IsDirectory())\r
723                 {\r
724                         if(!svnPath.IsEquivalentToWithoutCase(pThis->m_directoryPath))\r
725                         {\r
726                                 if (pThis->m_bRecursive)\r
727                                 {\r
728                                         // Add any versioned directory, which is not our 'self' entry, to the list for having its status updated\r
729                                         CGitStatusCache::Instance().AddFolderForCrawling(svnPath);\r
730                                 }\r
731 \r
732                                 // Make sure we know about this child directory\r
733                                 // This initial status value is likely to be overwritten from below at some point\r
734                                 git_wc_status_kind s = GitStatus::GetMoreImportant(status->text_status, status->prop_status);\r
735                                 CCachedDirectory * cdir = CGitStatusCache::Instance().GetDirectoryCacheEntryNoCreate(svnPath);\r
736                                 if (cdir)\r
737                                 {\r
738                                         // This child directory is already in our cache!\r
739                                         // So ask this dir about its recursive status\r
740                                         git_wc_status_kind st = GitStatus::GetMoreImportant(s, cdir->GetCurrentFullStatus());\r
741                                         AutoLocker lock(pThis->m_critSec);\r
742                                         pThis->m_childDirectories[svnPath] = st;\r
743                                 }\r
744                                 else\r
745                                 {\r
746                                         // the child directory is not in the cache. Create a new entry for it in the cache which is\r
747                                         // initially 'unversioned'. But we added that directory to the crawling list above, which\r
748                                         // means the cache will be updated soon.\r
749                                         CGitStatusCache::Instance().GetDirectoryCacheEntry(svnPath);\r
750                                         AutoLocker lock(pThis->m_critSec);\r
751                                         pThis->m_childDirectories[svnPath] = s;\r
752                                 }\r
753                         }\r
754                 }\r
755                 else\r
756                 {\r
757                         // Keep track of the most important status of all the files in this directory\r
758                         // Don't include subdirectories in this figure, because they need to provide their \r
759                         // own 'most important' value\r
760                         pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, status->text_status);\r
761                         pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, status->prop_status);\r
762                         if (((status->text_status == git_wc_status_unversioned)||(status->text_status == git_wc_status_none))\r
763                                 &&(CGitStatusCache::Instance().IsUnversionedAsModified()))\r
764                         {\r
765                                 // treat unversioned files as modified\r
766                                 if (pThis->m_mostImportantFileStatus != git_wc_status_added)\r
767                                         pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, git_wc_status_modified);\r
768                         }\r
769                 }\r
770         }\r
771         else\r
772         {\r
773                 svnPath.SetFromSVN(path);\r
774                 // Subversion returns no 'entry' field for versioned folders if they're\r
775                 // part of another working copy (nested layouts).\r
776                 // So we have to make sure that such an 'unversioned' folder really\r
777                 // is unversioned.\r
778                 if (((status->text_status == git_wc_status_unversioned)||(status->text_status == git_wc_status_missing))&&(!svnPath.IsEquivalentToWithoutCase(pThis->m_directoryPath))&&(svnPath.IsDirectory()))\r
779                 {\r
780                         if (svnPath.HasAdminDir())\r
781                         {\r
782                                 CGitStatusCache::Instance().AddFolderForCrawling(svnPath);\r
783                                 // Mark the directory as 'versioned' (status 'normal' for now).\r
784                                 // This initial value will be overwritten from below some time later\r
785                                 {\r
786                                         AutoLocker lock(pThis->m_critSec);\r
787                                         pThis->m_childDirectories[svnPath] = git_wc_status_normal;\r
788                                 }\r
789                                 // Make sure the entry is also in the cache\r
790                                 CGitStatusCache::Instance().GetDirectoryCacheEntry(svnPath);\r
791                                 // also mark the status in the status object as normal\r
792                                 status->text_status = git_wc_status_normal;\r
793                         }\r
794                 }\r
795                 else if (status->text_status == git_wc_status_external)\r
796                 {\r
797                         CGitStatusCache::Instance().AddFolderForCrawling(svnPath);\r
798                         // Mark the directory as 'versioned' (status 'normal' for now).\r
799                         // This initial value will be overwritten from below some time later\r
800                         {\r
801                                 AutoLocker lock(pThis->m_critSec);\r
802                                 pThis->m_childDirectories[svnPath] = git_wc_status_normal;\r
803                         }\r
804                         // we have added a directory to the child-directory list of this\r
805                         // directory. We now must make sure that this directory also has\r
806                         // an entry in the cache.\r
807                         CGitStatusCache::Instance().GetDirectoryCacheEntry(svnPath);\r
808                         // also mark the status in the status object as normal\r
809                         status->text_status = git_wc_status_normal;\r
810                 }\r
811                 else\r
812                 {\r
813                         if (svnPath.IsDirectory())\r
814                         {\r
815                                 AutoLocker lock(pThis->m_critSec);\r
816                                 pThis->m_childDirectories[svnPath] = GitStatus::GetMoreImportant(status->text_status, status->prop_status);\r
817                         }\r
818                         else if ((CGitStatusCache::Instance().IsUnversionedAsModified())&&(status->text_status != git_wc_status_missing))\r
819                         {\r
820                                 // make this unversioned item change the most important status of this\r
821                                 // folder to modified if it doesn't already have another status\r
822                                 if (pThis->m_mostImportantFileStatus != git_wc_status_added)\r
823                                         pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, git_wc_status_modified);\r
824                         }\r
825                 }\r
826         }\r
827 \r
828         pThis->AddEntry(svnPath, status);\r
829 \r
830         return 0;\r
831 }\r
832 #endif\r
833 \r
834 bool \r
835 CCachedDirectory::IsOwnStatusValid() const\r
836 {\r
837         return m_ownStatus.HasBeenSet() && \r
838                    !m_ownStatus.HasExpired(GetTickCount()) &&\r
839                    // 'external' isn't a valid status. That just\r
840                    // means the folder is not part of the current working\r
841                    // copy but it still has its own 'real' status\r
842                    m_ownStatus.GetEffectiveStatus()!=git_wc_status_external &&\r
843                    m_ownStatus.IsKindKnown();\r
844 }\r
845 \r
846 void CCachedDirectory::Invalidate()\r
847 {\r
848         m_ownStatus.Invalidate();\r
849 }\r
850 \r
851 git_wc_status_kind CCachedDirectory::CalculateRecursiveStatus()\r
852 {\r
853         // Combine our OWN folder status with the most important of our *FILES'* status.\r
854         git_wc_status_kind retVal = GitStatus::GetMoreImportant(m_mostImportantFileStatus, m_ownStatus.GetEffectiveStatus());\r
855 \r
856         // NOTE: TSVN marks dir as modified if it contains added/deleted/missing files, but we prefer the most important\r
857         //       status to propagate upward in its original state\r
858         /*if ((retVal != git_wc_status_modified)&&(retVal != m_ownStatus.GetEffectiveStatus()))\r
859         {\r
860                 if ((retVal == git_wc_status_added)||(retVal == git_wc_status_deleted)||(retVal == git_wc_status_missing))\r
861                         retVal = git_wc_status_modified;\r
862         }*/\r
863 \r
864         // Now combine all our child-directorie's status\r
865         \r
866         AutoLocker lock(m_critSec);\r
867         ChildDirStatus::const_iterator it;\r
868         for(it = m_childDirectories.begin(); it != m_childDirectories.end(); ++it)\r
869         {\r
870                 retVal = GitStatus::GetMoreImportant(retVal, it->second);\r
871                 /*if ((retVal != git_wc_status_modified)&&(retVal != m_ownStatus.GetEffectiveStatus()))\r
872                 {\r
873                         if ((retVal == git_wc_status_added)||(retVal == git_wc_status_deleted)||(retVal == git_wc_status_missing))\r
874                                 retVal = git_wc_status_modified;\r
875                 }*/\r
876         }\r
877         \r
878         return retVal;\r
879 }\r
880 \r
881 // Update our composite status and deal with things if it's changed\r
882 void CCachedDirectory::UpdateCurrentStatus()\r
883 {\r
884         git_wc_status_kind newStatus = CalculateRecursiveStatus();\r
885 \r
886         if ((newStatus != m_currentFullStatus)&&(m_ownStatus.IsVersioned()))\r
887         {\r
888                 if ((m_currentFullStatus != git_wc_status_none)&&(m_ownStatus.GetEffectiveStatus() != git_wc_status_missing))\r
889                 {\r
890                         // Our status has changed - tell the shell\r
891                         ATLTRACE(_T("Dir %s, status change from %d to %d, send shell notification\n"), m_directoryPath.GetWinPath(), m_currentFullStatus, newStatus);           \r
892                         CGitStatusCache::Instance().UpdateShell(m_directoryPath);\r
893                 }\r
894                 if (m_ownStatus.GetEffectiveStatus() != git_wc_status_missing)\r
895                         m_currentFullStatus = newStatus;\r
896                 else\r
897                         m_currentFullStatus = git_wc_status_missing;\r
898         }\r
899         // And tell our parent, if we've got one...\r
900         // we tell our parent *always* about our status, even if it hasn't\r
901         // changed. This is to make sure that the parent has really our current\r
902         // status - the parent can decide itself if our status has changed\r
903         // or not.\r
904         CTGitPath parentPath = m_directoryPath.GetContainingDirectory();\r
905         if(!parentPath.IsEmpty())\r
906         {\r
907                 // We have a parent\r
908                 CCachedDirectory * cachedDir = CGitStatusCache::Instance().GetDirectoryCacheEntry(parentPath);\r
909                 if (cachedDir)\r
910                         cachedDir->UpdateChildDirectoryStatus(m_directoryPath, m_currentFullStatus);\r
911         }\r
912 }\r
913 \r
914 \r
915 // Receive a notification from a child that its status has changed\r
916 void CCachedDirectory::UpdateChildDirectoryStatus(const CTGitPath& childDir, git_wc_status_kind childStatus)\r
917 {\r
918         git_wc_status_kind currentStatus = git_wc_status_none;\r
919         {\r
920                 AutoLocker lock(m_critSec);\r
921                 currentStatus = m_childDirectories[childDir];\r
922         }\r
923         if ((currentStatus != childStatus)||(!IsOwnStatusValid()))\r
924         {\r
925                 {\r
926                         AutoLocker lock(m_critSec);\r
927                         m_childDirectories[childDir] = childStatus;\r
928                 }\r
929                 UpdateCurrentStatus();\r
930         }\r
931 }\r
932 \r
933 CStatusCacheEntry CCachedDirectory::GetOwnStatus(bool bRecursive)\r
934 {\r
935         // Don't return recursive status if we're unversioned ourselves.\r
936         if(bRecursive && m_ownStatus.GetEffectiveStatus() > git_wc_status_unversioned)\r
937         {\r
938                 CStatusCacheEntry recursiveStatus(m_ownStatus);\r
939                 UpdateCurrentStatus();\r
940                 recursiveStatus.ForceStatus(m_currentFullStatus);\r
941                 return recursiveStatus;                         \r
942         }\r
943         else\r
944         {\r
945                 return m_ownStatus;\r
946         }\r
947 }\r
948 \r
949 void CCachedDirectory::RefreshStatus(bool bRecursive)\r
950 {\r
951         // Make sure that our own status is up-to-date\r
952         GetStatusForMember(m_directoryPath,bRecursive);\r
953 \r
954         AutoLocker lock(m_critSec);\r
955         // We also need to check if all our file members have the right date on them\r
956         CacheEntryMap::iterator itMembers;\r
957         std::set<CTGitPath> refreshedpaths;\r
958         DWORD now = GetTickCount();\r
959         if (m_entryCache.size() == 0)\r
960                 return;\r
961         for (itMembers = m_entryCache.begin(); itMembers != m_entryCache.end(); ++itMembers)\r
962         {\r
963                 if (itMembers->first)\r
964                 {\r
965                         CTGitPath filePath(m_directoryPath);\r
966                         filePath.AppendPathString(itMembers->first);\r
967                         std::set<CTGitPath>::iterator refr_it;\r
968                         if ((!filePath.IsEquivalentToWithoutCase(m_directoryPath))&&\r
969                                 (((refr_it = refreshedpaths.lower_bound(filePath)) == refreshedpaths.end()) || !filePath.IsEquivalentToWithoutCase(*refr_it)))\r
970                         {\r
971                                 if ((itMembers->second.HasExpired(now))||(!itMembers->second.DoesFileTimeMatch(filePath.GetLastWriteTime())))\r
972                                 {\r
973                                         lock.Unlock();\r
974                                         // We need to request this item as well\r
975                                         GetStatusForMember(filePath,bRecursive);\r
976                                         // GetStatusForMember now has recreated the m_entryCache map.\r
977                                         // So start the loop again, but add this path to the refreshed paths set\r
978                                         // to make sure we don't refresh this path again. This is to make sure\r
979                                         // that we don't end up in an endless loop.\r
980                                         lock.Lock();\r
981                                         refreshedpaths.insert(refr_it, filePath);\r
982                                         itMembers = m_entryCache.begin();\r
983                                         if (m_entryCache.size()==0)\r
984                                                 return;\r
985                                         continue;\r
986                                 }\r
987                                 else if ((bRecursive)&&(itMembers->second.IsDirectory()))\r
988                                 {\r
989                                         // crawl all sub folders too! Otherwise a change deep inside the\r
990                                         // tree which has changed won't get propagated up the tree.\r
991                                         CGitStatusCache::Instance().AddFolderForCrawling(filePath);\r
992                                 }\r
993                         }\r
994                 }\r
995         }\r
996 }\r
997 \r
998 void CCachedDirectory::RefreshMostImportant()\r
999 {\r
1000         CacheEntryMap::iterator itMembers;\r
1001         git_wc_status_kind newStatus = m_ownStatus.GetEffectiveStatus();\r
1002         for (itMembers = m_entryCache.begin(); itMembers != m_entryCache.end(); ++itMembers)\r
1003         {\r
1004                 newStatus = GitStatus::GetMoreImportant(newStatus, itMembers->second.GetEffectiveStatus());\r
1005                 if (((itMembers->second.GetEffectiveStatus() == git_wc_status_unversioned)||(itMembers->second.GetEffectiveStatus() == git_wc_status_none))\r
1006                         &&(CGitStatusCache::Instance().IsUnversionedAsModified()))\r
1007                 {\r
1008                         // treat unversioned files as modified\r
1009                         if (newStatus != git_wc_status_added)\r
1010                                 newStatus = GitStatus::GetMoreImportant(newStatus, git_wc_status_modified);\r
1011                 }\r
1012         }\r
1013         if (newStatus != m_mostImportantFileStatus)\r
1014         {\r
1015                 ATLTRACE(_T("status change of path %s\n"), m_directoryPath.GetWinPath());\r
1016                 CGitStatusCache::Instance().UpdateShell(m_directoryPath);\r
1017         }\r
1018         m_mostImportantFileStatus = newStatus;\r
1019 }\r