4 //# include "SVNPrompt.h"
\r
6 #include "TGitPath.h"
\r
8 #pragma warning (push,1)
\r
9 typedef std::basic_string<wchar_t> wide_string;
\r
11 # define stdstring wide_string
\r
13 # define stdstring std::string
\r
15 #pragma warning (pop)
\r
17 #include "TGitPath.h"
\r
19 typedef enum type_git_wc_status_kind
\r
22 git_wc_status_unversioned,
\r
23 git_wc_status_ignored,
\r
24 git_wc_status_normal,
\r
25 git_wc_status_external,
\r
26 git_wc_status_incomplete,
\r
27 git_wc_status_missing,
\r
28 git_wc_status_deleted,
\r
29 git_wc_status_replaced,
\r
30 git_wc_status_modified,
\r
31 git_wc_status_merged,
\r
32 git_wc_status_added,
\r
33 git_wc_status_conflicted,
\r
34 git_wc_status_obstructed,
\r
36 }git_wc_status_kind;
\r
44 git_depth_immediates,
\r
48 #define GIT_REV_ZERO _T("0000000000000000000000000000000000000000")
\r
49 #define GIT_INVALID_REVNUM _T("")
\r
50 typedef CString git_revnum_t;
\r
51 typedef int git_error_t;
\r
53 typedef struct git_wc_status2_t
\r
55 /** The status of the entries text. */
\r
56 git_wc_status_kind text_status;
\r
58 /** The status of the entries properties. */
\r
59 git_wc_status_kind prop_status;
\r
62 #define MAX_STATUS_STRING_LENGTH 256
\r
65 /////////////////////////////////////////////////////////////////////
\r
66 // WINGIT API (replaced by commandline tool, but defs and data types kept so old code still works)
\r
68 // Flags for wgEnumFiles
\r
69 enum WGENUMFILEFLAGS
\r
71 WGEFF_NoRecurse = (1<<0), // only enumerate files directly in the specified path
\r
72 WGEFF_FullPath = (1<<1), // enumerated filenames are specified with full path (instead of relative to proj root)
\r
73 WGEFF_DirStatusDelta= (1<<2), // include directories, in enumeration, that have a recursive status != WGFS_Normal (may have a slightly better performance than WGEFF_DirStatusAll)
\r
74 WGEFF_DirStatusAll = (1<<3), // include directories, in enumeration, with recursive status
\r
75 WGEFF_EmptyAsNormal = (1<<4), // report sub-directories, with no versioned files, as WGFS_Normal instead of WGFS_Empty
\r
76 WGEFF_SingleFile = (1<<5) // indicates that the status of a single file or dir, specified by pszSubPath, is wanted
\r
90 WGFS_Unversioned = -2,
\r
98 WGFF_Directory = (1<<0) // enumerated file is a directory
\r
103 const char *sFileName; // filename or directory relative to project root (using forward slashes)
\r
104 int nStatus; // the WGFILESTATUS of the file
\r
105 int nFlags; // a combination of WGFILEFLAGS
\r
107 const BYTE* sha1; // points to the BYTE[20] sha1 (NULL for directories, WGFF_Directory)
\r
110 // Application-defined callback function for wgEnumFiles, returns TRUE to abort enumeration
\r
111 // NOTE: do NOT store the pFile pointer or any pointers in wgFile_s for later use, the data is only valid for a single callback call
\r
112 typedef BOOL (__cdecl WGENUMFILECB)(const struct wgFile_s *pFile, void *pUserData);
\r
115 /////////////////////////////////////////////////////////////////////
\r
118 // convert wingit.dll status to git_wc_status_kind
\r
119 inline static git_wc_status_kind GitStatusFromWingit(int nStatus)
\r
123 case WGFS_Normal: return git_wc_status_normal;
\r
124 case WGFS_Modified: return git_wc_status_modified;
\r
125 case WGFS_Staged: return git_wc_status_modified;
\r
126 case WGFS_Added: return git_wc_status_added;
\r
127 case WGFS_Conflicted: return git_wc_status_conflicted;
\r
128 case WGFS_Deleted: return git_wc_status_deleted;
\r
130 case WGFS_Ignored: return git_wc_status_ignored;
\r
131 case WGFS_Unversioned: return git_wc_status_unversioned;
\r
132 case WGFS_Empty: return git_wc_status_unversioned;
\r
135 return git_wc_status_none;
\r
138 // convert 20 byte sha1 hash to the git_revnum_t type
\r
139 inline static git_revnum_t ConvertHashToRevnum(const BYTE *sha1)
\r
142 return GIT_INVALID_REVNUM;
\r
146 for (int i=0; i<20; i++)
\r
148 #pragma warning(push)
\r
149 #pragma warning(disable: 4996)
\r
150 sprintf(p, "%02x", (UINT)*sha1);
\r
151 #pragma warning(pop)
\r
162 * Handles Subversion status of working copies.
\r
167 GitStatus(bool * pbCanceled = NULL);
\r
172 * Reads the Subversion status of the working copy entry. No
\r
173 * recurse is done, even if the entry is a directory.
\r
174 * If the status of the text and property part are different
\r
175 * then the more important status is returned.
\r
177 static git_wc_status_kind GetAllStatus(const CTGitPath& path, git_depth_t depth = git_depth_empty);
\r
180 * Reads the Subversion status of the working copy entry and all its
\r
181 * subitems. The resulting status is determined by using priorities for
\r
182 * each status. The status with the highest priority is then returned.
\r
183 * If the status of the text and property part are different then
\r
184 * the more important status is returned.
\r
186 static git_wc_status_kind GetAllStatusRecursive(const CTGitPath& path);
\r
189 * Returns the status which is more "important" of the two statuses specified.
\r
190 * This is used for the "recursive" status functions on folders - i.e. which status
\r
191 * should be returned for a folder which has several files with different statuses
\r
194 static git_wc_status_kind GetMoreImportant(git_wc_status_kind status1, git_wc_status_kind status2);
\r
197 * Checks if a status is "important", i.e. if the status indicates that the user should know about it.
\r
198 * E.g. a "normal" status is not important, but "modified" is.
\r
199 * \param status the status to check
\r
201 static BOOL IsImportant(git_wc_status_kind status) {return (GetMoreImportant(git_wc_status_added, status)==status);}
\r
204 * Reads the Subversion text status of the working copy entry. No
\r
205 * recurse is done, even if the entry is a directory.
\r
206 * The result is stored in the public member variable status.
\r
207 * Use this method if you need detailed information about a file/folder, not just the raw status (like "normal", "modified").
\r
209 * \param path the pathname of the entry
\r
210 * \param update true if the status should be updated with the repository. Default is false.
\r
211 * \return If update is set to true the HEAD revision of the repository is returned. If update is false then -1 is returned.
\r
212 * \remark If the return value is -2 then the status could not be obtained.
\r
214 git_revnum_t GetStatus(const CTGitPath& path, bool update = false, bool noignore = false, bool noexternals = false);
\r
217 * Returns a string representation of a Subversion status.
\r
218 * \param status the status enum
\r
219 * \param string a string representation
\r
221 static void GetStatusString(git_wc_status_kind status, size_t buflen, TCHAR * string);
\r
222 static void GetStatusString(HINSTANCE hInst, git_wc_status_kind status, TCHAR * string, int size, WORD lang);
\r
225 * Returns the string representation of a depth.
\r
228 static CString GetDepthString(git_depth_t depth);
\r
230 static void GetDepthString(HINSTANCE hInst, git_depth_t depth, TCHAR * string, int size, WORD lang);
\r
233 * Returns the status of the first file of the given path. Use GetNextFileStatus() to obtain
\r
234 * the status of the next file in the list.
\r
235 * \param path the path of the folder from where the status list should be obtained
\r
236 * \param retPath the path of the file for which the status was returned
\r
237 * \param update set this to true if you want the status to be updated with the repository (needs network access)
\r
238 * \param recurse true to fetch the status recursively
\r
239 * \param bNoIgnore true to not fetch the ignored files
\r
240 * \param bNoExternals true to not fetch the status of included Git:externals
\r
241 * \return the status
\r
243 git_wc_status2_t * GetFirstFileStatus(const CTGitPath& path, CTGitPath& retPath, bool update = false, git_depth_t depth = git_depth_infinity, bool bNoIgnore = true, bool bNoExternals = false);
\r
244 unsigned int GetFileCount() const {return /*apr_hash_count(m_statushash);*/0;}
\r
245 unsigned int GetVersionedCount() const;
\r
247 * Returns the status of the next file in the file list. If no more files are in the list then NULL is returned.
\r
248 * See GetFirstFileStatus() for details.
\r
250 git_wc_status2_t * GetNextFileStatus(CTGitPath& retPath);
\r
252 * Checks if a path is an external folder.
\r
253 * This is necessary since Subversion returns two entries for external folders: one with the status Git_wc_status_external
\r
254 * and one with the 'real' status of that folder. GetFirstFileStatus() and GetNextFileStatus() only return the 'real'
\r
255 * status, so with this method it's possible to check if the status also is Git_wc_status_external.
\r
257 bool IsExternal(const CTGitPath& path) const;
\r
259 * Checks if a path is in an external folder.
\r
261 bool IsInExternal(const CTGitPath& path) const;
\r
264 * Clears the memory pool.
\r
269 * This member variable hold the status of the last call to GetStatus().
\r
271 git_wc_status2_t * status; ///< the status result of GetStatus()
\r
273 git_revnum_t headrev; ///< the head revision fetched with GetFirstStatus()
\r
275 bool * m_pbCanceled;
\r
277 friend class Git; // So that Git can get to our m_err
\r
279 * Returns the last error message as a CString object.
\r
281 CString GetLastErrorMsg() const;
\r
284 * Set a list of paths which will be considered when calling GetFirstFileStatus.
\r
285 * If a filter is set, then GetFirstFileStatus/GetNextFileStatus will only return items which are in the filter list
\r
287 void SetFilter(const CTGitPathList& fileList);
\r
288 void ClearFilter();
\r
292 * Returns the last error message as a CString object.
\r
294 stdstring GetLastErrorMsg() const;
\r
299 // apr_pool_t * m_pool; ///< the memory pool
\r
301 typedef struct sort_item
\r
304 // apr_ssize_t klen;
\r
308 typedef struct hashbaton_t
\r
311 // apr_hash_t * hash;
\r
312 // apr_hash_t * exthash;
\r
315 // git_client_ctx_t * ctx;
\r
316 git_wc_status_kind m_allstatus; ///< used by GetAllStatus and GetAllStatusRecursive
\r
317 // git_error_t * m_err; ///< Subversion error baton
\r
320 git_wc_status2_t m_status; // used for GetStatus
\r
323 // GitPrompt m_prompt;
\r
327 * Returns a numeric value indicating the importance of a status.
\r
328 * A higher number indicates a more important status.
\r
330 static int GetStatusRanking(git_wc_status_kind status);
\r
333 * Callback function which collects the raw status from a Git_client_status() function call
\r
335 //static git_error_t * getallstatus (void *baton, const char *path, git_wc_status2_t *status, apr_pool_t *pool);
\r
336 static BOOL getallstatus(const struct wgFile_s *pFile, void *pUserData);
\r
337 static BOOL getstatus(const struct wgFile_s *pFile, void *pUserData);
\r
340 * Callback function which stores the raw status from a Git_client_status() function call
\r
343 // static git_error_t * getstatushash (void *baton, const char *path, git_wc_status2_t *status, apr_pool_t *pool);
\r
346 * helper function to sort a hash to an array
\r
348 // static apr_array_header_t * sort_hash (apr_hash_t *ht, int (*comparison_func) (const sort_item *,
\r
349 // const sort_item *), apr_pool_t *pool);
\r
352 * Callback function used by qsort() which does the comparison of two elements
\r
354 static int __cdecl sort_compare_items_as_paths (const sort_item *a, const sort_item *b);
\r
356 //for GetFirstFileStatus and GetNextFileStatus
\r
357 // apr_hash_t * m_statushash;
\r
358 // apr_array_header_t * m_statusarray;
\r
359 unsigned int m_statushashindex;
\r
360 // apr_hash_t * m_externalhash;
\r
362 #pragma warning(push)
\r
363 #pragma warning(disable: 4200)
\r
364 struct STRINGRESOURCEIMAGE
\r
369 #pragma warning(pop) // C4200
\r
371 static int LoadStringEx(HINSTANCE hInstance, UINT uID, LPTSTR lpBuffer, int nBufferMax, WORD wLanguage);
\r
372 static git_error_t* cancel(void *baton);
\r
374 // A sorted list of filenames (in Git format, in lowercase)
\r
375 // when this list is set, we only pick-up files during a GetStatus which are found in this list
\r
376 typedef std::vector<std::string> StdStrAVector;
\r
377 StdStrAVector m_filterFileList;
\r