Performance optimization: Do not search whole vector if we know we need all
[TortoiseGit.git] / src / Git / GitStatus.cpp
blob55dbac3ddd4a07051787f84c2a4befa9bd261639
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2015 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "registry.h"
22 #include "..\TortoiseShell\resource.h"
23 #include "GitStatus.h"
24 #include "UnicodeUtils.h"
25 #include "Git.h"
26 #include "gitindex.h"
27 #include "ShellCache.h"
28 #include "SysInfo.h"
30 extern CGitAdminDirMap g_AdminDirMap;
31 extern CGitIndexFileMap g_IndexFileMap;
32 CGitHeadFileMap g_HeadFileMap;
33 CGitIgnoreList g_IgnoreList;
35 GitStatus::GitStatus()
36 : status(NULL)
38 m_status.assumeValid = m_status.skipWorktree = false;
39 m_status.prop_status = m_status.text_status = git_wc_status_none;
42 GitStatus::~GitStatus(void)
46 // static method
47 #ifndef TGITCACHE
48 git_wc_status_kind GitStatus::GetAllStatus(const CTGitPath& path, git_depth_t depth, bool * assumeValid, bool * skipWorktree)
50 git_wc_status_kind statuskind;
51 BOOL err;
52 BOOL isDir;
53 CString sProjectRoot;
55 isDir = path.IsDirectory();
56 if (!path.HasAdminDir(&sProjectRoot))
57 return git_wc_status_none;
59 // rev.kind = git_opt_revision_unspecified;
60 statuskind = git_wc_status_none;
62 const BOOL bIsRecursive = (depth == git_depth_infinity || depth == git_depth_unknown); // taken from SVN source
64 CString sSubPath;
65 CString s = path.GetWinPathString();
66 if (s.GetLength() > sProjectRoot.GetLength())
68 if (sProjectRoot.GetLength() == 3 && sProjectRoot[1] == _T(':'))
69 sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());
70 else
71 sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);
74 bool isfull = ((DWORD)CRegStdDWORD(_T("Software\\TortoiseGit\\CacheType"),
75 GetSystemMetrics(SM_REMOTESESSION) ? ShellCache::dll : ShellCache::exe) == ShellCache::dllFull);
77 if(isDir)
79 err = GetDirStatus(sProjectRoot, sSubPath, &statuskind, isfull, bIsRecursive, isfull);
80 // folders must not be displayed as added or deleted only as modified (this is for Shell Overlay-Modes)
81 if (statuskind == git_wc_status_unversioned && sSubPath.IsEmpty())
82 statuskind = git_wc_status_normal;
83 else if (statuskind == git_wc_status_deleted || statuskind == git_wc_status_added)
84 statuskind = git_wc_status_modified;
86 else
88 err = GetFileStatus(sProjectRoot, sSubPath, &statuskind, isfull, false, isfull, NULL, NULL, assumeValid, skipWorktree);
91 return statuskind;
93 #endif
95 // static method
96 git_wc_status_kind GitStatus::GetMoreImportant(git_wc_status_kind status1, git_wc_status_kind status2)
98 if (GetStatusRanking(status1) >= GetStatusRanking(status2))
99 return status1;
100 return status2;
102 // static private method
103 int GitStatus::GetStatusRanking(git_wc_status_kind status)
105 switch (status)
107 case git_wc_status_none:
108 return 0;
109 case git_wc_status_unversioned:
110 return 1;
111 case git_wc_status_ignored:
112 return 2;
113 case git_wc_status_incomplete:
114 return 4;
115 case git_wc_status_normal:
116 case git_wc_status_external:
117 return 5;
118 case git_wc_status_added:
119 return 6;
120 case git_wc_status_missing:
121 return 7;
122 case git_wc_status_deleted:
123 return 8;
124 case git_wc_status_replaced:
125 return 9;
126 case git_wc_status_modified:
127 return 10;
128 case git_wc_status_merged:
129 return 11;
130 case git_wc_status_conflicted:
131 return 12;
132 case git_wc_status_obstructed:
133 return 13;
135 return 0;
138 #ifndef TGITCACHE
139 void GitStatus::GetStatus(const CTGitPath& path, bool /*update*/ /* = false */, bool noignore /* = false */, bool /*noexternals*/ /* = false */)
141 // NOTE: unlike the SVN version this one does not cache the enumerated files, because in practice no code in all of
142 // Tortoise uses this, all places that call GetStatus create a temp GitStatus object which gets destroyed right
143 // after the call again
145 CString sProjectRoot;
146 if ( !path.HasAdminDir(&sProjectRoot) )
147 return;
149 bool isfull = ((DWORD)CRegStdDWORD(_T("Software\\TortoiseGit\\CacheType"),
150 GetSystemMetrics(SM_REMOTESESSION) ? ShellCache::dll : ShellCache::exe) == ShellCache::dllFull);
152 int err = 0;
154 LPCTSTR lpszSubPath = NULL;
155 CString sSubPath;
156 CString s = path.GetWinPathString();
157 if (s.GetLength() > sProjectRoot.GetLength())
159 sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());
160 lpszSubPath = sSubPath;
161 // skip initial slash if necessary
162 if (*lpszSubPath == _T('\\'))
163 ++lpszSubPath;
166 m_status.prop_status = m_status.text_status = git_wc_status_none;
167 m_status.assumeValid = false;
168 m_status.skipWorktree = false;
170 if (path.IsDirectory())
172 err = GetDirStatus(sProjectRoot, lpszSubPath, &m_status.text_status, isfull, false, !noignore);
173 if (m_status.text_status == git_wc_status_added || m_status.text_status == git_wc_status_deleted) // fix for issue #1769; a folder is either modified, conflicted or normal
174 m_status.text_status = git_wc_status_modified;
176 else
177 err = GetFileStatus(sProjectRoot, lpszSubPath, &m_status.text_status, isfull, false, !noignore, nullptr, nullptr, &m_status.assumeValid, &m_status.skipWorktree);
179 // Error present if function is not under version control
180 if (err)
182 status = NULL;
183 return;
186 status = &m_status;
188 #endif
190 typedef CComCritSecLock<CComCriticalSection> CAutoLocker;
192 int GitStatus::GetFileStatus(const CString& gitdir, CString path, git_wc_status_kind* status, BOOL IsFull, BOOL /*IsRecursive*/, BOOL IsIgnore, FILL_STATUS_CALLBACK callback, void* pData, bool* assumeValid, bool* skipWorktree)
194 if (!status)
195 return 0;
197 path.Replace(_T('\\'), _T('/'));
199 CString lowcasepath = path;
200 lowcasepath.MakeLower();
202 git_wc_status_kind st = git_wc_status_none;
203 CGitHash hash;
205 g_IndexFileMap.GetFileStatus(gitdir, path, &st, IsFull, false, callback, pData, &hash, true, assumeValid, skipWorktree);
207 if (st == git_wc_status_conflicted)
209 *status = st;
210 if (callback && assumeValid && skipWorktree)
211 callback(CombinePath(gitdir, path), st, false, pData, *assumeValid, *skipWorktree);
212 return 0;
215 if (st == git_wc_status_unversioned)
217 if (!IsIgnore)
219 *status = git_wc_status_unversioned;
220 if (callback && assumeValid && skipWorktree)
221 callback(CombinePath(gitdir, path), *status, false, pData, *assumeValid, *skipWorktree);
222 return 0;
225 if (g_IgnoreList.CheckIgnoreChanged(gitdir, path, false))
226 g_IgnoreList.LoadAllIgnoreFile(gitdir, path, false);
227 if (g_IgnoreList.IsIgnore(path, gitdir, false))
228 st = git_wc_status_ignored;
230 *status = st;
231 if (callback && assumeValid && skipWorktree)
232 callback(CombinePath(gitdir, path), st, false, pData, *assumeValid, *skipWorktree);
234 return 0;
237 if ((st == git_wc_status_normal || st == git_wc_status_modified) && IsFull)
239 g_HeadFileMap.CheckHeadAndUpdate(gitdir);
241 // Check Head Tree Hash
242 SHARED_TREE_PTR treeptr = g_HeadFileMap.SafeGet(gitdir);
244 //add item
245 int start = SearchInSortVector(*treeptr, lowcasepath, -1);
246 if (start < 0)
248 *status = st = git_wc_status_added;
249 CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": File miss in head tree %s"), (LPCTSTR)path);
250 if (callback && assumeValid && skipWorktree)
251 callback(CombinePath(gitdir, path), st, false, pData, *assumeValid, *skipWorktree);
252 return 0;
255 // staged and not commit
256 if (treeptr->at(start).m_Hash != hash)
258 *status = st = git_wc_status_modified;
259 if (callback && assumeValid && skipWorktree)
260 callback(CombinePath(gitdir, path), st, false, pData, *assumeValid, *skipWorktree);
261 return 0;
264 *status = st;
265 if (callback && assumeValid && skipWorktree)
266 callback(CombinePath(gitdir, path), st, false, pData, *assumeValid, *skipWorktree);
267 return 0;
270 #ifdef TGITCACHE
271 bool GitStatus::HasIgnoreFilesChanged(const CString &gitdir, const CString &subpaths, bool isDir)
273 return g_IgnoreList.CheckIgnoreChanged(gitdir, subpaths, isDir);
276 int GitStatus::LoadIgnoreFile(const CString &gitdir, const CString &subpaths, bool isDir)
278 return g_IgnoreList.LoadAllIgnoreFile(gitdir, subpaths, isDir);
280 int GitStatus::IsUnderVersionControl(const CString &gitdir, const CString &path, bool isDir,bool *isVersion)
282 if (g_IndexFileMap.IsUnderVersionControl(gitdir, path, isDir, isVersion))
283 return 1;
284 if (!*isVersion)
285 return g_HeadFileMap.IsUnderVersionControl(gitdir, path, isDir, isVersion);
286 return 0;
289 int GitStatus::IsIgnore(const CString &gitdir, const CString &path, bool *isIgnore, bool isDir)
291 if (g_IgnoreList.CheckIgnoreChanged(gitdir, path, isDir))
292 g_IgnoreList.LoadAllIgnoreFile(gitdir, path, isDir);
294 *isIgnore = g_IgnoreList.IsIgnore(path, gitdir, isDir);
296 return 0;
299 int GitStatus::GetFileList(CString path, std::vector<CGitFileName> &list)
301 path += _T("\\*.*");
302 WIN32_FIND_DATA data;
303 HANDLE handle = ::FindFirstFileEx(path, SysInfo::Instance().IsWin7OrLater() ? FindExInfoBasic : FindExInfoStandard, &data, FindExSearchNameMatch, nullptr, SysInfo::Instance().IsWin7OrLater() ? FIND_FIRST_EX_LARGE_FETCH : 0);
306 if(_tcscmp(data.cFileName, _T(".git")) == 0)
307 continue;
309 if(_tcscmp(data.cFileName, _T(".")) == 0)
310 continue;
312 if(_tcscmp(data.cFileName, _T("..")) == 0)
313 continue;
315 CGitFileName filename;
317 filename.m_CaseFileName = filename.m_FileName = data.cFileName;
318 filename.m_FileName.MakeLower();
320 if(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
322 filename.m_FileName += _T('/');
325 list.push_back(filename);
327 }while(::FindNextFile(handle, &data));
329 FindClose(handle);
331 std::sort(list.begin(), list.end(), SortCGitFileName);
332 return 0;
335 int GitStatus::EnumDirStatus(const CString &gitdir, const CString &subpath, git_wc_status_kind * status,BOOL IsFul, BOOL IsRecursive, BOOL IsIgnore, FILL_STATUS_CALLBACK callback, void *pData)
337 if (!status)
338 return 0;
340 CString path = subpath;
342 path.Replace(_T('\\'), _T('/'));
343 if (!path.IsEmpty() && path[path.GetLength() - 1] != _T('/'))
344 path += _T('/'); // Add trail / to show it is directory, not file name.
346 std::vector<CGitFileName> filelist;
347 GetFileList(CombinePath(gitdir, subpath), filelist);
349 g_IndexFileMap.CheckAndUpdate(gitdir,true);
351 g_HeadFileMap.CheckHeadAndUpdate(gitdir);
353 SHARED_INDEX_PTR indexptr = g_IndexFileMap.SafeGet(gitdir);
354 SHARED_TREE_PTR treeptr = g_HeadFileMap.SafeGet(gitdir);
356 // new git working tree has no index file
357 if (!indexptr.get())
359 for (auto it = filelist.cbegin(); it != filelist.cend(); ++it)
361 CString casepath = path;
362 casepath += it->m_CaseFileName;
364 bool bIsDir = false;
365 if (it->m_FileName.GetLength() > 0 && it->m_FileName[it->m_FileName.GetLength() - 1] == _T('/'))
366 bIsDir = true;
368 if (IsIgnore)
370 if (g_IgnoreList.CheckIgnoreChanged(gitdir, casepath, bIsDir))
371 g_IgnoreList.LoadAllIgnoreFile(gitdir, casepath, bIsDir);
373 if (g_IgnoreList.IsIgnore(casepath, gitdir, bIsDir))
374 *status = git_wc_status_ignored;
375 else if (bIsDir)
376 continue;
377 else
378 *status = git_wc_status_unversioned;
380 else if (bIsDir)
381 continue;
382 else
383 *status = git_wc_status_unversioned;
385 if (callback)
386 callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false);
388 return 0;
391 CString lowcasepath = path;
392 lowcasepath.MakeLower();
394 CString onepath;
395 CString casepath;
396 for (auto it = filelist.cbegin(), itend = filelist.cend(); it != itend; ++it)
398 casepath = onepath = lowcasepath;
399 onepath += it->m_FileName;
400 casepath += it->m_CaseFileName;
402 bool bIsDir = false;
403 if (!onepath.IsEmpty() && onepath[onepath.GetLength() - 1] == _T('/'))
404 bIsDir = true;
406 int matchLength = -1;
407 if (bIsDir)
408 matchLength = onepath.GetLength();
409 int pos = SearchInSortVector(*indexptr, onepath, matchLength);
410 int posintree = SearchInSortVector(*treeptr, onepath, matchLength);
412 if (pos < 0 && posintree < 0)
414 if (onepath.IsEmpty())
415 continue;
417 if (!IsIgnore)
419 *status = git_wc_status_unversioned;
420 if (callback)
421 callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false);
422 continue;
425 if (g_IgnoreList.CheckIgnoreChanged(gitdir, casepath, bIsDir))
426 g_IgnoreList.LoadAllIgnoreFile(gitdir, casepath, bIsDir);
428 if (g_IgnoreList.IsIgnore(casepath, gitdir, bIsDir))
429 *status = git_wc_status_ignored;
430 else
431 *status = git_wc_status_unversioned;
433 if (callback)
434 callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false);
436 else if (pos < 0 && posintree >= 0) /* check if file delete in index */
438 *status = git_wc_status_deleted;
439 if (callback)
440 callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false);
442 else if (pos >= 0 && posintree < 0) /* Check if file added */
444 *status = git_wc_status_added;
445 if (indexptr->at(pos).m_Flags & GIT_IDXENTRY_STAGEMASK)
446 *status = git_wc_status_conflicted;
447 if (callback)
448 callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false);
450 else
452 if (onepath.IsEmpty())
453 continue;
455 if (bIsDir)
457 *status = git_wc_status_normal;
458 if (callback)
459 callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false);
461 else
463 bool assumeValid = false;
464 bool skipWorktree = false;
465 git_wc_status_kind filestatus;
466 GetFileStatus(gitdir, casepath, &filestatus, IsFul, IsRecursive, IsIgnore, callback, pData, &assumeValid, &skipWorktree);
469 }/*End of For*/
471 /* Check deleted file in system */
472 int start = 0, end = 0;
473 int pos = SearchInSortVector(*indexptr, lowcasepath, lowcasepath.GetLength()); // match path prefix, (sub)folders end with slash
474 std::map<CString, bool> skipWorktreeMap;
476 if (GetRangeInSortVector(*indexptr, lowcasepath, lowcasepath.GetLength(), &start, &end, pos) == 0)
478 CString oldstring;
479 for (auto it = indexptr->cbegin() + start, itlast = indexptr->cbegin() + end; it <= itlast; ++it)
481 int commonPrefixLength = lowcasepath.GetLength();
482 int index = (*it).m_FileName.Find(_T('/'), commonPrefixLength);
483 if (index < 0)
484 index = (*it).m_FileName.GetLength();
485 else
486 ++index; // include slash at the end for subfolders, so that we do not match files by mistake
488 CString filename = (*it).m_FileName.Mid(commonPrefixLength, index - commonPrefixLength);
489 if (oldstring != filename)
491 oldstring = filename;
492 if (SearchInSortVector(filelist, filename, filename.GetLength()) < 0)
494 bool skipWorktree = false;
495 *status = git_wc_status_deleted;
496 if (((*it).m_Flags & GIT_IDXENTRY_SKIP_WORKTREE) != 0)
498 skipWorktreeMap[filename] = true;
499 skipWorktree = true;
500 *status = git_wc_status_normal;
502 if (callback)
503 callback(CombinePath(gitdir, (*it).m_FileName), *status, false, pData, false, skipWorktree);
509 start = end = 0;
510 pos = SearchInSortVector(*treeptr, lowcasepath, lowcasepath.GetLength()); // match path prefix, (sub)folders end with slash
511 if (GetRangeInSortVector(*treeptr, lowcasepath, lowcasepath.GetLength(), &start, &end, pos) == 0)
513 CString oldstring;
514 for (auto it = treeptr->cbegin() + start, itlast = treeptr->cbegin() + end; it <= itlast; ++it)
516 int commonPrefixLength = lowcasepath.GetLength();
517 int index = (*it).m_FileName.Find(_T('/'), commonPrefixLength);
518 if (index < 0)
519 index = (*it).m_FileName.GetLength();
520 else
521 ++index; // include slash at the end for subfolders, so that we do not match files by mistake
523 CString filename = (*it).m_FileName.Mid(commonPrefixLength, index - commonPrefixLength);
524 if (oldstring != filename && skipWorktreeMap[filename] != true)
526 oldstring = filename;
527 if (SearchInSortVector(filelist, filename, filename.GetLength()) < 0)
529 *status = git_wc_status_deleted;
530 if (callback)
531 callback(CombinePath(gitdir, (*it).m_FileName), *status, false, pData, false, false);
536 return 0;
538 #endif
540 #ifndef TGITCACHE
541 int GitStatus::GetDirStatus(const CString& gitdir, const CString& subpath, git_wc_status_kind* status, BOOL IsFul, BOOL IsRecursive, BOOL IsIgnore)
543 if (!status)
544 return 0;
546 CString path = subpath;
548 path.Replace(_T('\\'), _T('/'));
549 if (!path.IsEmpty() && path[path.GetLength() - 1] != _T('/'))
550 path += _T('/'); //Add trail / to show it is directory, not file name.
552 g_IndexFileMap.CheckAndUpdate(gitdir, true);
554 SHARED_INDEX_PTR indexptr = g_IndexFileMap.SafeGet(gitdir);
556 if (!indexptr)
558 *status = git_wc_status_unversioned;
559 return 0;
562 CString lowcasepath = path;
563 lowcasepath.MakeLower();
565 int pos = SearchInSortVector(*indexptr, lowcasepath, lowcasepath.GetLength());
567 // Not In Version Contorl
568 if (pos < 0)
570 if (!IsIgnore)
572 *status = git_wc_status_unversioned;
573 return 0;
576 // Check ignore always.
577 if (g_IgnoreList.CheckIgnoreChanged(gitdir, path, true))
578 g_IgnoreList.LoadAllIgnoreFile(gitdir, path, true);
580 if (g_IgnoreList.IsIgnore(path, gitdir, true))
581 *status = git_wc_status_ignored;
582 else
583 *status = git_wc_status_unversioned;
585 g_HeadFileMap.CheckHeadAndUpdate(gitdir);
587 SHARED_TREE_PTR treeptr = g_HeadFileMap.SafeGet(gitdir);
588 // Check init repository
589 if (treeptr->HeadIsEmpty() && path.IsEmpty())
590 *status = git_wc_status_normal;
591 // check if only one file in repository is deleted in index
592 else if (path.IsEmpty() && !treeptr->empty())
593 *status = git_wc_status_deleted;
595 return 0;
598 // In version control
599 *status = git_wc_status_normal;
601 int start = 0;
602 int end = 0;
604 GetRangeInSortVector(*indexptr, lowcasepath, lowcasepath.GetLength(), &start, &end, pos);
606 // Check Conflict;
607 for (auto it = indexptr->cbegin() + start, itlast = indexptr->cbegin() + end; it <= itlast; ++it)
609 if (((*it).m_Flags & GIT_IDXENTRY_STAGEMASK) != 0)
611 *status = git_wc_status_conflicted;
612 break;
616 if (IsFul && (*status != git_wc_status_conflicted))
618 *status = git_wc_status_normal;
620 g_HeadFileMap.CheckHeadAndUpdate(gitdir);
622 // Check Add
624 // Check if new init repository
625 SHARED_TREE_PTR treeptr = g_HeadFileMap.SafeGet(gitdir);
627 if (!treeptr->empty() || treeptr->HeadIsEmpty())
629 for (auto it = indexptr->cbegin() + start, itlast = indexptr->cbegin() + end; it <= itlast; ++it)
631 pos = SearchInSortVector(*treeptr, (*it).m_FileName, -1);
633 if (pos < 0)
635 *status = max(git_wc_status_added, *status); // added file found
636 break;
639 if (pos >= 0 && treeptr->at(pos).m_Hash != (*it).m_IndexHash)
641 *status = max(git_wc_status_modified, *status); // modified file found
642 break;
646 // Check Delete
647 if (*status == git_wc_status_normal)
649 pos = SearchInSortVector(*treeptr, lowcasepath, lowcasepath.GetLength());
650 if (pos < 0)
651 *status = max(git_wc_status_added, *status); // added file found
652 else
654 int hstart, hend;
655 GetRangeInSortVector(*treeptr, lowcasepath, lowcasepath.GetLength(), &hstart, &hend, pos);
656 for (auto hit = treeptr->cbegin() + hstart, lastElement = treeptr->cbegin() + hend; hit <= lastElement; ++hit)
658 if (SearchInSortVector(*indexptr, (*hit).m_FileName, -1) < 0)
660 *status = max(git_wc_status_deleted, *status); // deleted file found
661 break;
667 } /* End lock*/
670 // When status == git_wc_status_conflicted, needn't check each file status
671 // because git_wc_status_conflicted is highest.s
672 if (*status == git_wc_status_conflicted)
673 return 0;
675 for (auto it = indexptr->cbegin() + start, itlast = indexptr->cbegin() + end; it <= itlast; ++it)
677 //skip child directory
678 if (!IsRecursive && (*it).m_FileName.Find(_T('/'), path.GetLength()) > 0)
679 continue;
681 git_wc_status_kind filestatus = git_wc_status_none;
682 bool assumeValid = false;
683 bool skipWorktree = false;
684 GetFileStatus(gitdir, (*it).m_FileName, &filestatus, IsFul, IsRecursive, IsIgnore, nullptr, nullptr, &assumeValid, &skipWorktree);
685 switch (filestatus)
687 case git_wc_status_added:
688 case git_wc_status_modified:
689 case git_wc_status_deleted:
690 case git_wc_status_conflicted:
691 *status = GetMoreImportant(filestatus, *status);
695 return 0;
697 #endif
699 #ifdef TGITCACHE
700 bool GitStatus::IsExistIndexLockFile(CString sDirName)
702 if (!PathIsDirectory(sDirName))
704 int x = sDirName.ReverseFind(_T('\\'));
705 if (x < 2)
706 return false;
708 sDirName = sDirName.Left(x);
711 for (;;)
713 if (PathFileExists(CombinePath(sDirName, _T(".git"))))
715 if (PathFileExists(g_AdminDirMap.GetAdminDirConcat(sDirName, _T("index.lock"))))
716 return true;
718 return false;
721 int x = sDirName.ReverseFind(_T('\\'));
722 if (x < 2)
723 return false;
725 sDirName = sDirName.Left(x);
728 #endif
730 bool GitStatus::ReleasePath(const CString &gitdir)
732 g_IndexFileMap.SafeClear(gitdir);
733 g_HeadFileMap.SafeClear(gitdir);
734 return true;
737 bool GitStatus::ReleasePathsRecursively(const CString &rootpath)
739 g_IndexFileMap.SafeClearRecursively(rootpath);
740 g_HeadFileMap.SafeClearRecursively(rootpath);
741 return true;