1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2014 - 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.
22 #include "..\TortoiseShell\resource.h"
23 #include "GitStatus.h"
24 #include "UnicodeUtils.h"
27 #include "ShellCache.h"
29 extern CGitAdminDirMap g_AdminDirMap
;
30 extern CGitIndexFileMap g_IndexFileMap
;
31 CGitHeadFileMap g_HeadFileMap
;
32 CGitIgnoreList g_IgnoreList
;
34 GitStatus::GitStatus()
36 , m_allstatus(git_wc_status_none
)
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)
47 git_wc_status_kind
GitStatus::GetAllStatus(const CTGitPath
& path
, git_depth_t depth
, bool * assumeValid
, bool * skipWorktree
)
49 git_wc_status_kind statuskind
;
54 isDir
= path
.IsDirectory();
55 if (!path
.HasAdminDir(&sProjectRoot
))
56 return git_wc_status_none
;
58 // rev.kind = git_opt_revision_unspecified;
59 statuskind
= git_wc_status_none
;
61 const BOOL bIsRecursive
= (depth
== git_depth_infinity
|| depth
== git_depth_unknown
); // taken from SVN source
64 CString s
= path
.GetWinPathString();
65 if (s
.GetLength() > sProjectRoot
.GetLength())
67 if (sProjectRoot
.GetLength() == 3 && sProjectRoot
[1] == _T(':'))
68 sSubPath
= s
.Right(s
.GetLength() - sProjectRoot
.GetLength());
70 sSubPath
= s
.Right(s
.GetLength() - sProjectRoot
.GetLength() - 1/*otherwise it gets initial slash*/);
73 bool isfull
= ((DWORD
)CRegStdDWORD(_T("Software\\TortoiseGit\\CacheType"),
74 GetSystemMetrics(SM_REMOTESESSION
) ? ShellCache::dll
: ShellCache::exe
) == ShellCache::dllFull
);
78 err
= GetDirStatus(sProjectRoot
,sSubPath
,&statuskind
, isfull
,bIsRecursive
,isfull
,NULL
, NULL
);
79 // folders must not be displayed as added or deleted only as modified (this is for Shell Overlay-Modes)
80 if (statuskind
== git_wc_status_unversioned
&& sSubPath
.IsEmpty())
81 statuskind
= git_wc_status_normal
;
82 else if (statuskind
== git_wc_status_deleted
|| statuskind
== git_wc_status_added
)
83 statuskind
= git_wc_status_modified
;
87 err
= GetFileStatus(sProjectRoot
, sSubPath
, &statuskind
, isfull
, false, isfull
, NULL
, NULL
, assumeValid
, skipWorktree
);
94 git_wc_status_kind
GitStatus::GetAllStatusRecursive(const CTGitPath
& path
)
96 return GetAllStatus(path
, git_depth_infinity
);
100 git_wc_status_kind
GitStatus::GetMoreImportant(git_wc_status_kind status1
, git_wc_status_kind status2
)
102 if (GetStatusRanking(status1
) >= GetStatusRanking(status2
))
106 // static private method
107 int GitStatus::GetStatusRanking(git_wc_status_kind status
)
111 case git_wc_status_none
:
113 case git_wc_status_unversioned
:
115 case git_wc_status_ignored
:
117 case git_wc_status_incomplete
:
119 case git_wc_status_normal
:
120 case git_wc_status_external
:
122 case git_wc_status_added
:
124 case git_wc_status_missing
:
126 case git_wc_status_deleted
:
128 case git_wc_status_replaced
:
130 case git_wc_status_modified
:
132 case git_wc_status_merged
:
134 case git_wc_status_conflicted
:
136 case git_wc_status_obstructed
:
142 void GitStatus::GetStatus(const CTGitPath
& path
, bool /*update*/ /* = false */, bool noignore
/* = false */, bool /*noexternals*/ /* = false */)
144 // NOTE: unlike the SVN version this one does not cache the enumerated files, because in practice no code in all of
145 // Tortoise uses this, all places that call GetStatus create a temp GitStatus object which gets destroyed right
146 // after the call again
148 CString sProjectRoot
;
149 if ( !path
.HasAdminDir(&sProjectRoot
) )
152 bool isfull
= ((DWORD
)CRegStdDWORD(_T("Software\\TortoiseGit\\CacheType"),
153 GetSystemMetrics(SM_REMOTESESSION
) ? ShellCache::dll
: ShellCache::exe
) == ShellCache::dllFull
);
158 LPCTSTR lpszSubPath
= NULL
;
160 CString s
= path
.GetWinPathString();
161 if (s
.GetLength() > sProjectRoot
.GetLength())
163 sSubPath
= s
.Right(s
.GetLength() - sProjectRoot
.GetLength());
164 lpszSubPath
= sSubPath
;
165 // skip initial slash if necessary
166 if (*lpszSubPath
== _T('\\'))
170 m_status
.prop_status
= m_status
.text_status
= git_wc_status_none
;
171 m_status
.assumeValid
= false;
172 m_status
.skipWorktree
= false;
174 if(path
.IsDirectory())
176 err
= GetDirStatus(sProjectRoot
,lpszSubPath
,&m_status
.text_status
, isfull
, false,!noignore
, NULL
, NULL
);
177 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
178 m_status
.text_status
= git_wc_status_modified
;
182 err
= GetFileStatus(sProjectRoot
, lpszSubPath
, &m_status
.text_status
,isfull
, false,!noignore
, NULL
,NULL
, &m_status
.assumeValid
, &m_status
.skipWorktree
);
186 // Error present if function is not under version control
196 typedef CComCritSecLock
<CComCriticalSection
> CAutoLocker
;
198 int GitStatus::GetFileStatus(const CString
&gitdir
, const CString
&pathParam
, git_wc_status_kind
* status
,BOOL IsFull
, BOOL
/*IsRecursive*/,BOOL IsIgnore
, FILL_STATUS_CALLBACK callback
, void *pData
, bool * assumeValid
, bool * skipWorktree
)
202 CString path
= pathParam
;
204 path
.Replace(_T('\\'),_T('/'));
206 CString lowcasepath
=path
;
207 lowcasepath
.MakeLower();
211 git_wc_status_kind st
= git_wc_status_none
;
214 g_IndexFileMap
.GetFileStatus(gitdir
, path
, &st
, IsFull
, false, callback
, pData
, &hash
, true, assumeValid
, skipWorktree
);
216 if( st
== git_wc_status_conflicted
)
219 if (callback
&& assumeValid
&& skipWorktree
)
220 callback(gitdir
+ _T("/") + path
, st
, false, pData
, *assumeValid
, *skipWorktree
);
224 if( st
== git_wc_status_unversioned
)
228 *status
= git_wc_status_unversioned
;
229 if (callback
&& assumeValid
&& skipWorktree
)
230 callback(gitdir
+ _T("/") + path
, *status
, false, pData
, *assumeValid
, *skipWorktree
);
234 if (g_IgnoreList
.CheckIgnoreChanged(gitdir
, path
, false))
236 g_IgnoreList
.LoadAllIgnoreFile(gitdir
, path
, false);
238 if (g_IgnoreList
.IsIgnore(path
, gitdir
, false))
240 st
= git_wc_status_ignored
;
243 if (callback
&& assumeValid
&& skipWorktree
)
244 callback(gitdir
+ _T("/") + path
, st
, false, pData
, *assumeValid
, *skipWorktree
);
249 if ((st
== git_wc_status_normal
|| st
== git_wc_status_modified
) && IsFull
)
252 g_HeadFileMap
.CheckHeadAndUpdate(gitdir
);
254 SHARED_TREE_PTR treeptr
= g_HeadFileMap
.SafeGet(gitdir
);
256 // Check Head Tree Hash;
260 int start
= SearchInSortVector(*treeptr
, lowcasepath
, -1);
264 *status
=st
=git_wc_status_added
;
265 CTraceToOutputDebugString::Instance()(_T(__FUNCTION__
) _T(": File miss in head tree %s"), path
);
266 if (callback
&& assumeValid
&& skipWorktree
)
267 callback(gitdir
+ _T("/") + path
, st
, false, pData
, *assumeValid
, *skipWorktree
);
271 //staged and not commit
272 if( treeptr
->at(start
).m_Hash
!= hash
)
274 *status
=st
=git_wc_status_modified
;
275 if (callback
&& assumeValid
&& skipWorktree
)
276 callback(gitdir
+ _T("/") + path
, st
, false, pData
, *assumeValid
, *skipWorktree
);
283 if (callback
&& assumeValid
&& skipWorktree
)
284 callback(gitdir
+ _T("/") + path
, st
, false, pData
, *assumeValid
, *skipWorktree
);
291 *status
= git_wc_status_none
;
299 bool GitStatus::HasIgnoreFilesChanged(const CString
&gitdir
, const CString
&subpaths
, bool isDir
)
301 return g_IgnoreList
.CheckIgnoreChanged(gitdir
, subpaths
, isDir
);
304 int GitStatus::LoadIgnoreFile(const CString
&gitdir
, const CString
&subpaths
, bool isDir
)
306 return g_IgnoreList
.LoadAllIgnoreFile(gitdir
, subpaths
, isDir
);
308 int GitStatus::IsUnderVersionControl(const CString
&gitdir
, const CString
&path
, bool isDir
,bool *isVersion
)
310 if (g_IndexFileMap
.IsUnderVersionControl(gitdir
, path
, isDir
, isVersion
))
313 return g_HeadFileMap
.IsUnderVersionControl(gitdir
, path
, isDir
, isVersion
);
317 __int64
GitStatus::GetIndexFileTime(const CString
&gitdir
)
319 SHARED_INDEX_PTR ptr
=g_IndexFileMap
.SafeGet(gitdir
);
320 if(ptr
.get() == NULL
)
323 return ptr
->m_LastModifyTime
;
326 int GitStatus::IsIgnore(const CString
&gitdir
, const CString
&path
, bool *isIgnore
, bool isDir
)
328 if (g_IgnoreList
.CheckIgnoreChanged(gitdir
, path
, isDir
))
329 g_IgnoreList
.LoadAllIgnoreFile(gitdir
, path
, isDir
);
331 *isIgnore
= g_IgnoreList
.IsIgnore(path
, gitdir
, isDir
);
336 static bool SortFileName(CGitFileName
&Item1
, CGitFileName
&Item2
)
338 return Item1
.m_FileName
.Compare(Item2
.m_FileName
)<0;
341 int GitStatus::GetFileList(const CString
&gitdir
, const CString
&subpath
, std::vector
<CGitFileName
> &list
)
343 WIN32_FIND_DATA data
;
344 HANDLE handle
=::FindFirstFile(gitdir
+_T("\\")+subpath
+_T("\\*.*"), &data
);
347 if(_tcscmp(data
.cFileName
, _T(".git")) == 0)
350 if(_tcscmp(data
.cFileName
, _T(".")) == 0)
353 if(_tcscmp(data
.cFileName
, _T("..")) == 0)
356 CGitFileName filename
;
358 filename
.m_CaseFileName
= filename
.m_FileName
= data
.cFileName
;
359 filename
.m_FileName
.MakeLower();
361 if(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
363 filename
.m_FileName
+= _T('/');
366 list
.push_back(filename
);
368 }while(::FindNextFile(handle
, &data
));
372 std::sort(list
.begin(), list
.end(), SortFileName
);
376 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
)
380 CString path
=subpath
;
382 path
.Replace(_T('\\'),_T('/'));
384 if(path
[path
.GetLength()-1] != _T('/'))
385 path
+= _T('/'); //Add trail / to show it is directory, not file name.
387 CString lowcasepath
= path
;
388 lowcasepath
.MakeLower();
390 std::vector
<CGitFileName
> filelist
;
391 GetFileList(gitdir
, subpath
, filelist
);
395 g_IndexFileMap
.CheckAndUpdate(gitdir
,true);
397 g_HeadFileMap
.CheckHeadAndUpdate(gitdir
);
399 SHARED_INDEX_PTR indexptr
= g_IndexFileMap
.SafeGet(gitdir
);
400 SHARED_TREE_PTR treeptr
= g_HeadFileMap
.SafeGet(gitdir
);
402 std::vector
<CGitFileName
>::iterator it
;
404 // new git working tree has no index file
405 if (indexptr
.get() == NULL
)
407 for (it
= filelist
.begin(); it
< filelist
.end(); ++it
)
409 CString casepath
= path
+ it
->m_CaseFileName
;
412 if (it
->m_FileName
.GetLength() > 0 && it
->m_FileName
[it
->m_FileName
.GetLength() - 1] == _T('/'))
417 if (g_IgnoreList
.CheckIgnoreChanged(gitdir
, casepath
, bIsDir
))
418 g_IgnoreList
.LoadAllIgnoreFile(gitdir
, casepath
, bIsDir
);
420 if (g_IgnoreList
.IsIgnore(casepath
, gitdir
, bIsDir
))
421 *status
= git_wc_status_ignored
;
425 *status
= git_wc_status_unversioned
;
430 *status
= git_wc_status_unversioned
;
433 callback(gitdir
+ _T("/") + casepath
, *status
, bIsDir
, pData
, false, false);
440 for (it
= filelist
.begin(); it
< filelist
.end(); ++it
)
442 casepath
=onepath
= path
;
444 onepath
+= it
->m_FileName
;
445 casepath
+= it
->m_CaseFileName
;
448 if (!onepath
.IsEmpty() && onepath
[onepath
.GetLength() - 1] == _T('/'))
451 int matchLength
= -1;
453 matchLength
= onepath
.GetLength();
454 int pos
= SearchInSortVector(*indexptr
, onepath
, matchLength
);
455 int posintree
= SearchInSortVector(*treeptr
, onepath
, matchLength
);
457 if(pos
<0 && posintree
<0)
459 if (onepath
.IsEmpty())
464 *status
= git_wc_status_unversioned
;
466 callback(gitdir
+ _T("/") + casepath
, *status
, bIsDir
, pData
, false, false);
470 if (g_IgnoreList
.CheckIgnoreChanged(gitdir
, casepath
, bIsDir
))
471 g_IgnoreList
.LoadAllIgnoreFile(gitdir
, casepath
, bIsDir
);
473 if (g_IgnoreList
.IsIgnore(casepath
, gitdir
, bIsDir
))
474 *status
= git_wc_status_ignored
;
476 *status
= git_wc_status_unversioned
;
479 callback(gitdir
+ _T("/") + casepath
, *status
, bIsDir
, pData
, false, false);
482 else if(pos
<0 && posintree
>=0) /* check if file delete in index */
484 *status
= git_wc_status_deleted
;
486 callback(gitdir
+ _T("/") + casepath
, *status
, bIsDir
, pData
, false, false);
489 else if(pos
>=0 && posintree
<0) /* Check if file added */
491 *status
= git_wc_status_added
;
493 callback(gitdir
+ _T("/") + casepath
, *status
, bIsDir
, pData
, false, false);
497 if (onepath
.IsEmpty())
502 *status
= git_wc_status_normal
;
504 callback(gitdir
+ _T("/") + casepath
, *status
, bIsDir
, pData
, false, false);
508 bool assumeValid
= false;
509 bool skipWorktree
= false;
510 git_wc_status_kind filestatus
;
511 GetFileStatus(gitdir
, casepath
, &filestatus
, IsFul
, IsRecursive
, IsIgnore
, callback
, pData
, &assumeValid
, &skipWorktree
);
517 /* Check deleted file in system */
519 int pos
= SearchInSortVector(*indexptr
, lowcasepath
, lowcasepath
.GetLength()); // match path prefix, (sub)folders end with slash
520 std::map
<CString
, bool> skipWorktreeMap
;
522 if (GetRangeInSortVector(*indexptr
, lowcasepath
, lowcasepath
.GetLength(), &start
, &end
, pos
) == 0)
524 CGitIndexList::iterator it
;
527 for (it
= indexptr
->begin() + start
; it
<= indexptr
->begin() + end
; ++it
)
529 int commonPrefixLength
= lowcasepath
.GetLength();
530 int index
= (*it
).m_FileName
.Find(_T('/'), commonPrefixLength
);
532 index
= (*it
).m_FileName
.GetLength();
534 ++index
; // include slash at the end for subfolders, so that we do not match files by mistake
536 CString filename
= (*it
).m_FileName
.Mid(commonPrefixLength
, index
- commonPrefixLength
);
537 if(oldstring
!= filename
)
539 oldstring
= filename
;
540 if (SearchInSortVector(filelist
, filename
, filename
.GetLength()) < 0)
542 bool skipWorktree
= false;
543 *status
= git_wc_status_deleted
;
544 if (((*it
).m_Flags
& GIT_IDXENTRY_SKIP_WORKTREE
) != 0)
546 skipWorktreeMap
[filename
] = true;
548 *status
= git_wc_status_normal
;
551 callback(gitdir
+ _T("/") + (*it
).m_FileName
, *status
, false, pData
, false, skipWorktree
);
558 pos
= SearchInSortVector(*treeptr
, lowcasepath
, lowcasepath
.GetLength()); // match path prefix, (sub)folders end with slash
559 if (GetRangeInSortVector(*treeptr
, lowcasepath
, lowcasepath
.GetLength(), &start
, &end
, pos
) == 0)
561 CGitHeadFileList::iterator it
;
564 for (it
= treeptr
->begin() + start
; it
<= treeptr
->begin() + end
; ++it
)
566 int commonPrefixLength
= lowcasepath
.GetLength();
567 int index
= (*it
).m_FileName
.Find(_T('/'), commonPrefixLength
);
569 index
= (*it
).m_FileName
.GetLength();
571 ++index
; // include slash at the end for subfolders, so that we do not match files by mistake
573 CString filename
= (*it
).m_FileName
.Mid(commonPrefixLength
, index
- commonPrefixLength
);
574 if (oldstring
!= filename
&& skipWorktreeMap
[filename
] != true)
576 oldstring
= filename
;
577 if (SearchInSortVector(filelist
, filename
, filename
.GetLength()) < 0)
579 *status
= git_wc_status_deleted
;
581 callback(gitdir
+ _T("/") + (*it
).m_FileName
, *status
, false, pData
, false, false);
587 }/*End of if status*/
595 int GitStatus::GetDirStatus(const CString
&gitdir
, const CString
&subpath
, git_wc_status_kind
* status
, BOOL IsFul
, BOOL IsRecursive
, BOOL IsIgnore
, FILL_STATUS_CALLBACK callback
, void *pData
)
599 CString path
=subpath
;
601 path
.Replace(_T('\\'),_T('/'));
603 if(path
[path
.GetLength()-1] != _T('/'))
604 path
+= _T('/'); //Add trail / to show it is directory, not file name.
606 CString lowcasepath
= path
;
607 lowcasepath
.MakeLower();
611 g_IndexFileMap
.CheckAndUpdate(gitdir
, true);
613 SHARED_INDEX_PTR indexptr
= g_IndexFileMap
.SafeGet(gitdir
);
615 if (indexptr
== NULL
)
617 *status
= git_wc_status_unversioned
;
621 int pos
= SearchInSortVector(*indexptr
, lowcasepath
, lowcasepath
.GetLength());
623 //Not In Version Contorl
628 *status
= git_wc_status_unversioned
;
630 callback(gitdir
+ _T("/") + path
, *status
, false, pData
, false, false);
633 //Check ignore always.
635 if (g_IgnoreList
.CheckIgnoreChanged(gitdir
, path
, true))
636 g_IgnoreList
.LoadAllIgnoreFile(gitdir
, path
, true);
638 if (g_IgnoreList
.IsIgnore(path
, gitdir
, true))
639 *status
= git_wc_status_ignored
;
641 *status
= git_wc_status_unversioned
;
643 g_HeadFileMap
.CheckHeadAndUpdate(gitdir
, false);
645 SHARED_TREE_PTR treeptr
= g_HeadFileMap
.SafeGet(gitdir
);
646 //Check init repository
647 if (treeptr
->HeadIsEmpty() && path
.IsEmpty())
648 *status
= git_wc_status_normal
;
652 else // In version control
654 *status
= git_wc_status_normal
;
661 end
= (int)indexptr
->size() - 1;
663 GetRangeInSortVector(*indexptr
, lowcasepath
, lowcasepath
.GetLength(), &start
, &end
, pos
);
664 CGitIndexList::iterator it
;
666 it
= indexptr
->begin()+start
;
669 for (int i
= start
; i
<= end
; ++i
)
671 if (((*it
).m_Flags
& GIT_IDXENTRY_STAGEMASK
) !=0)
673 *status
= git_wc_status_conflicted
;
676 int dirpos
= (*it
).m_FileName
.Find(_T('/'), path
.GetLength());
677 if(dirpos
<0 || IsRecursive
)
678 callback(gitdir
+ _T("\\") + it
->m_FileName
, git_wc_status_conflicted
, false, pData
, false, false);
686 if( IsFul
&& (*status
!= git_wc_status_conflicted
))
688 *status
= git_wc_status_normal
;
690 g_HeadFileMap
.CheckHeadAndUpdate(gitdir
);
693 it
= indexptr
->begin()+start
;
697 //Check if new init repository
698 SHARED_TREE_PTR treeptr
= g_HeadFileMap
.SafeGet(gitdir
);
700 if (!treeptr
->empty() || treeptr
->HeadIsEmpty())
702 for (int i
= start
; i
<= end
; ++i
)
704 pos
= SearchInSortVector(*treeptr
, (*it
).m_FileName
, -1);
708 *status
= max(git_wc_status_added
, *status
); // added file found
711 int dirpos
= (*it
).m_FileName
.Find(_T('/'), path
.GetLength());
712 if(dirpos
<0 || IsRecursive
)
713 callback(gitdir
+ _T("\\") + it
->m_FileName
, git_wc_status_added
, false, pData
, false, false);
720 if( pos
>=0 && treeptr
->at(pos
).m_Hash
!= (*it
).m_IndexHash
)
722 *status
= max(git_wc_status_modified
, *status
); // modified file found
725 int dirpos
= (*it
).m_FileName
.Find(_T('/'), path
.GetLength());
726 if(dirpos
<0 || IsRecursive
)
727 callback(gitdir
+ _T("\\") + it
->m_FileName
, git_wc_status_modified
, false, pData
, ((*it
).m_Flags
& GIT_IDXENTRY_VALID
) && !((*it
).m_Flags
& GIT_IDXENTRY_SKIP_WORKTREE
), ((*it
).m_Flags
& GIT_IDXENTRY_SKIP_WORKTREE
) != 0);
738 if( *status
== git_wc_status_normal
)
740 pos
= SearchInSortVector(*treeptr
, lowcasepath
, lowcasepath
.GetLength());
743 *status
= max(git_wc_status_added
, *status
); // added file found
749 GetRangeInSortVector(*treeptr
, lowcasepath
, lowcasepath
.GetLength(), &hstart
, &hend
, pos
);
750 CGitHeadFileList::iterator hit
;
751 hit
= treeptr
->begin() + hstart
;
752 CGitHeadFileList::iterator lastElement
= treeptr
->end();
753 for (int i
= hstart
; i
<= hend
&& hit
!= lastElement
; ++i
)
755 if (SearchInSortVector(*indexptr
, (*hit
).m_FileName
, -1) < 0)
757 *status
= max(git_wc_status_deleted
, *status
); // deleted file found
767 // If define callback, it need update each file status.
768 // If not define callback, status == git_wc_status_conflicted, needn't check each file status
769 // because git_wc_status_conflicted is highest.s
770 if(callback
|| (*status
!= git_wc_status_conflicted
))
775 CString sub
, currentPath
;
776 it
= indexptr
->begin()+start
;
777 for (int i
= start
; i
<= end
; ++i
, ++it
)
781 //skip child directory
782 int pos
= (*it
).m_FileName
.Find(_T('/'), path
.GetLength());
786 currentPath
= (*it
).m_FileName
.Left(pos
);
787 if( callback
&& (sub
!= currentPath
) )
790 CTraceToOutputDebugString::Instance()(_T(__FUNCTION__
) _T(": index subdir %s\n"),sub
);
791 if(callback
) callback(gitdir
+ _T("\\") + sub
,
792 git_wc_status_normal
, true, pData
, false, false);
798 git_wc_status_kind filestatus
= git_wc_status_none
;
799 bool assumeValid
= false;
800 bool skipWorktree
= false;
801 GetFileStatus(gitdir
, (*it
).m_FileName
, &filestatus
, IsFul
, IsRecursive
, IsIgnore
, callback
, pData
, &assumeValid
, &skipWorktree
);
807 if(callback
) callback(gitdir
+ _T("/") + subpath
, *status
, true, pData
, false, false);
813 *status
= git_wc_status_none
;
820 bool GitStatus::IsExistIndexLockFile(const CString
&gitdir
)
822 CString sDirName
= gitdir
;
824 if (!PathIsDirectory(sDirName
))
826 int x
= sDirName
.ReverseFind(_T('\\'));
830 sDirName
= sDirName
.Left(x
);
835 if(PathFileExists(sDirName
+ _T("\\.git")))
837 if(PathFileExists(g_AdminDirMap
.GetAdminDir(sDirName
) + _T("index.lock")))
843 int x
= sDirName
.ReverseFind(_T('\\'));
847 sDirName
= sDirName
.Left(x
);
851 bool GitStatus::ReleasePath(const CString
&gitdir
)
853 g_IndexFileMap
.SafeClear(gitdir
);
857 bool GitStatus::ReleasePathsRecursively(const CString
&rootpath
)
859 g_IndexFileMap
.SafeClearRecursively(rootpath
);