OSDN Git Service

made wingit.dll delay load so that PATH can be inited with git/bin dir before dll...
[tortoisegit/TortoiseGitJp.git] / src / Git / GitStatus.h
index 1ba4e16..ea566e2 100644 (file)
@@ -15,6 +15,7 @@ typedef std::basic_string<wchar_t> wide_string;
 #pragma warning (pop)\r
 \r
 #include "TGitPath.h"\r
+#include "../../ext/wingit/wingit.h"\r
 \r
 typedef enum type_git_wc_status_kind\r
 {\r
@@ -46,6 +47,7 @@ typedef enum
 \r
 \r
 #define GIT_REV_ZERO _T("0000000000000000000000000000000000000000")\r
+#define GIT_INVALID_REVNUM _T("")\r
 typedef CString git_revnum_t;\r
 typedef int git_error_t;\r
 \r
@@ -60,6 +62,44 @@ typedef struct git_wc_status2_t
 \r
 #define MAX_STATUS_STRING_LENGTH               256\r
 \r
+\r
+// convert wingit.dll status to git_wc_status_kind\r
+inline static git_wc_status_kind GitStatusFromWingit(int nStatus)\r
+{\r
+       switch (nStatus)\r
+       {\r
+       case WGFS_Normal: return git_wc_status_normal;\r
+       case WGFS_Modified: return git_wc_status_modified;\r
+       case WGFS_Deleted: return git_wc_status_deleted;\r
+\r
+       case WGFS_Empty: return git_wc_status_unversioned;\r
+       }\r
+\r
+       return git_wc_status_none;\r
+}\r
+\r
+// convert 20 byte sha1 hash to the git_revnum_t type\r
+inline static git_revnum_t ConvertHashToRevnum(const BYTE *sha1)\r
+{\r
+       if (!sha1)\r
+               return GIT_INVALID_REVNUM;\r
+\r
+       char s[41];\r
+       char *p = s;\r
+       for (int i=0; i<20; i++)\r
+       {\r
+#pragma warning(push)\r
+#pragma warning(disable: 4996)\r
+               sprintf(p, "%02x", (UINT)*sha1);\r
+#pragma warning(pop)\r
+               p += 2;\r
+               sha1++;\r
+       }\r
+\r
+       return CString(s);\r
+}\r
+\r
+\r
 /**\r
  * \ingroup Git\r
  * Handles Subversion status of working copies.\r
@@ -217,7 +257,10 @@ private:
 \r
 //     git_client_ctx_t *                      ctx;\r
        git_wc_status_kind                      m_allstatus;    ///< used by GetAllStatus and GetAllStatusRecursive\r
-       git_error_t *                           m_err;                  ///< Subversion error baton\r
+//     git_error_t *                           m_err;                  ///< Subversion error baton\r
+       BOOL                                            m_err;\r
+\r
+       git_wc_status2_t                        m_status;               // used for GetStatus\r
 \r
 #ifdef _MFC_VER\r
 //     GitPrompt                                       m_prompt;\r
@@ -232,7 +275,9 @@ private:
        /**\r
         * Callback function which collects the raw status from a Git_client_status() function call\r
         */\r
-//     static git_error_t * getallstatus (void *baton, const char *path, git_wc_status2_t *status, apr_pool_t *pool);\r
+       //static git_error_t * getallstatus (void *baton, const char *path, git_wc_status2_t *status, apr_pool_t *pool);\r
+       static BOOL getallstatus(const struct wgFile_s *pFile, void *pUserData);\r
+       static BOOL getstatus(const struct wgFile_s *pFile, void *pUserData);\r
 \r
        /**\r
         * Callback function which stores the raw status from a Git_client_status() function call\r