Fixed issue #2495: "Show Reflog" dialog shows empty action for "push" entries
[TortoiseGit.git] / src / Git / GitFolderStatus.h
blobc100c68d4411fb9df2208e96accbde6e71fb8b32
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2003-2006,2008,2011 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
22 #include "GitStatus.h"
23 #include "TGitPath.h"
24 #include "SmartHandle.h"
26 typedef struct FileStatusCacheEntry
28 git_wc_status_kind status;
29 int askedcounter;
30 bool assumeValid;
31 bool skipWorktree;
32 } FileStatusCacheEntry;
34 #define GITFOLDERSTATUS_CACHETIMES 10
35 #define GITFOLDERSTATUS_CACHETIMEOUT 2000
36 #define GITFOLDERSTATUS_RECURSIVECACHETIMEOUT 4000
37 #define GITFOLDERSTATUS_FOLDER 500
38 /**
39 * \ingroup TortoiseShell
40 * This class represents a caching mechanism for the
41 * git statuses. Once a status for a versioned
42 * file is requested (GetFileStatus()) first its checked
43 * if that status is already in the cache. If it is not
44 * then the git statuses for ALL files in the same
45 * directory is fetched and cached. This is because git
46 * needs almost the same time to get one or all status (in
47 * the same directory).
48 * To prevent a cache flush for the explorer folder view
49 * the cache is only fetched for versioned files and
50 * not for folders.
52 class GitFolderStatus
54 public:
55 GitFolderStatus(void);
56 ~GitFolderStatus(void);
57 const FileStatusCacheEntry * GetFullStatus(const CTGitPath& filepath, BOOL bIsFolder);
58 const FileStatusCacheEntry * GetCachedItem(const CTGitPath& filepath);
60 FileStatusCacheEntry invalidstatus;
62 GitStatus m_GitStatus;
64 private:
65 const FileStatusCacheEntry * BuildCache(const CTGitPath& filepath, const CString& sProjectRoot, BOOL bIsFolder, BOOL bDirectFolder = FALSE);
66 DWORD GetTimeoutValue();
68 void ClearCache();
70 int m_nCounter;
71 typedef std::map<stdstring, FileStatusCacheEntry> FileStatusMap;
72 FileStatusMap m_cache;
73 DWORD m_TimeStamp;
74 FileStatusCacheEntry dirstat;
75 git_wc_status2_t * dirstatus;
77 stdstring sCacheKey;
79 CAutoGeneralHandle m_hInvalidationEvent;
81 // The item we most recently supplied status for
82 CTGitPath m_mostRecentPath;
83 const FileStatusCacheEntry* m_mostRecentStatus;