OSDN Git Service

Add external diff merge and udiff Setting at setting Page
[tortoisegit/TortoiseGitJp.git] / src / Git / GitStatus.h
index d04d80a..751e980 100644 (file)
@@ -15,7 +15,6 @@ typedef std::basic_string<wchar_t> wide_string;
 #pragma warning (pop)\r
 \r
 #include "TGitPath.h"\r
-#include "wingit.h"\r
 \r
 typedef enum type_git_wc_status_kind\r
 {\r
@@ -47,9 +46,19 @@ 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
+typedef struct git_wc_entry_t\r
+{\r
+       // url in repository\r
+       const char *url;\r
+\r
+       TCHAR cmt_rev[41];\r
+} git_wc_entry_t;\r
+\r
+\r
 typedef struct git_wc_status2_t\r
 { \r
   /** The status of the entries text. */\r
@@ -57,11 +66,66 @@ typedef struct git_wc_status2_t
 \r
   /** The status of the entries properties. */\r
   git_wc_status_kind prop_status;\r
+\r
+  //git_wc_entry_t *entry;\r
 }git_wc_status2;\r
 \r
 #define MAX_STATUS_STRING_LENGTH               256\r
 \r
 \r
+/////////////////////////////////////////////////////////////////////\r
+// WINGIT API (replaced by commandline tool, but defs and data types kept so old code still works)\r
+\r
+// Flags for wgEnumFiles\r
+enum WGENUMFILEFLAGS\r
+{\r
+       WGEFF_NoRecurse         = (1<<0),       // only enumerate files directly in the specified path\r
+       WGEFF_FullPath          = (1<<1),       // enumerated filenames are specified with full path (instead of relative to proj root)\r
+       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
+       WGEFF_DirStatusAll      = (1<<3),       // include directories, in enumeration, with recursive status\r
+       WGEFF_EmptyAsNormal     = (1<<4),       // report sub-directories, with no versioned files, as WGFS_Normal instead of WGFS_Empty\r
+       WGEFF_SingleFile        = (1<<5)        // indicates that the status of a single file or dir, specified by pszSubPath, is wanted\r
+};\r
+\r
+// File status\r
+enum WGFILESTATUS\r
+{\r
+       WGFS_Normal,\r
+       WGFS_Modified,\r
+       WGFS_Staged,\r
+       WGFS_Added,\r
+       WGFS_Conflicted,\r
+       WGFS_Deleted,\r
+\r
+       WGFS_Ignored = -1,\r
+       WGFS_Unversioned = -2,\r
+       WGFS_Empty = -3,\r
+       WGFS_Unknown = -4\r
+};\r
+\r
+// File flags\r
+enum WGFILEFLAGS\r
+{\r
+       WGFF_Directory          = (1<<0)        // enumerated file is a directory\r
+};\r
+\r
+struct wgFile_s\r
+{\r
+       LPCTSTR sFileName;                              // filename or directory relative to project root (using forward slashes)\r
+       int nStatus;                                    // the WGFILESTATUS of the file\r
+       int nFlags;                                             // a combination of WGFILEFLAGS\r
+\r
+       const BYTE* sha1;                               // points to the BYTE[20] sha1 (NULL for directories, WGFF_Directory)\r
+};\r
+\r
+// Application-defined callback function for wgEnumFiles, returns TRUE to abort enumeration\r
+// 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
+typedef BOOL (__cdecl WGENUMFILECB)(const struct wgFile_s *pFile, void *pUserData);\r
+\r
+//\r
+/////////////////////////////////////////////////////////////////////\r
+\r
+\r
 // convert wingit.dll status to git_wc_status_kind\r
 inline static git_wc_status_kind GitStatusFromWingit(int nStatus)\r
 {\r
@@ -69,12 +133,40 @@ inline static git_wc_status_kind GitStatusFromWingit(int nStatus)
        {\r
        case WGFS_Normal: return git_wc_status_normal;\r
        case WGFS_Modified: return git_wc_status_modified;\r
+       case WGFS_Staged: return git_wc_status_merged;\r
+       case WGFS_Added: return git_wc_status_added;\r
+       case WGFS_Conflicted: return git_wc_status_conflicted;\r
        case WGFS_Deleted: return git_wc_status_deleted;\r
+\r
+       case WGFS_Ignored: return git_wc_status_ignored;\r
+       case WGFS_Unversioned: return git_wc_status_unversioned;\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
@@ -233,7 +325,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
+       git_error_t                                                     m_err;\r
+\r
+       git_wc_status2_t                        m_status;               // used for GetStatus\r
 \r
 #ifdef _MFC_VER\r
 //     GitPrompt                                       m_prompt;\r
@@ -250,6 +345,7 @@ private:
         */\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
@@ -293,4 +389,3 @@ private:
 };\r
 \r
 \r
-       
\ No newline at end of file