OSDN Git Service

updated wingit.dll with some fixes
[tortoisegit/TortoiseGitJp.git] / ext / wingit / wingit.h
1 // wingit.h\r
2 //\r
3 // Windows GIT wrapper (under msysgit)\r
4 //\r
5 // This is NOT a full git API, it only exposes a few helper functions that\r
6 // third party windows apps might find useful, to avoid having to parse\r
7 // console output from the command-line tools.\r
8 //\r
9 // Make sure wingit.dll is placed in the bin directory of the msysgit installation.\r
10 //\r
11 // Created by Georg Fischer\r
12 \r
13 #ifndef _WINGIT_H_\r
14 #define _WINGIT_H_\r
15 \r
16 #define WG_VERSION "0.1.6"\r
17 \r
18 \r
19 #define DLLIMPORT __declspec(dllimport) __stdcall\r
20 #define DLLEXPORT __declspec(dllexport) __stdcall\r
21 \r
22 #ifdef WINGIT_EXPORTS\r
23 #define WINGIT_API DLLEXPORT\r
24 #else // GAME_EXPORTS\r
25 #define WINGIT_API DLLIMPORT\r
26 #endif // GAME_EXPORTS\r
27 \r
28 #ifdef __cplusplus\r
29 extern "C" {\r
30 #endif\r
31 \r
32 \r
33 // Flags for wgEnumFiles\r
34 enum WGENUMFILEFLAGS\r
35 {\r
36         WGEFF_NoRecurse         = (1<<0),       // only enumerate files directly in the specified path\r
37         WGEFF_FullPath          = (1<<1),       // enumerated filenames are specified with full path (instead of relative to proj root)\r
38         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
39         WGEFF_DirStatusAll      = (1<<3),       // include directories, in enumeration, with recursive status\r
40         WGEFF_EmptyAsNormal     = (1<<4),       // report sub-directories, with no versioned files, as WGFS_Normal instead of WGFS_Empty\r
41         WGEFF_SingleFile        = (1<<5)        // indicates that the status of a single file or dir, specified by pszSubPath, is wanted\r
42 };\r
43 \r
44 // NOTE: Special behavior for directories when specifying WGEFF_SingleFile:\r
45 //\r
46 //       * when combined with WGEFF_SingleFile the returned status will only reflect the immediate files in the dir,\r
47 //         NOT the recusrive status of immediate sub-dirs\r
48 //       * unlike a normal enumeration where the project root dir always is returned as WGFS_Normal regardless\r
49 //         of WGEFF_EmptyAsNormal, the project root will return WGFS_Empty if no immediate versioned files\r
50 //         unless WGEFF_EmptyAsNormal is specified\r
51 //       * WGEFF_DirStatusDelta and WGEFF_DirStatusAll are ignored and can be omitted even for dirs\r
52 \r
53 \r
54 // File status\r
55 enum WGFILESTATUS\r
56 {\r
57         WGFS_Normal,\r
58         WGFS_Modified,\r
59         WGFS_Deleted,\r
60 \r
61         WGFS_Unknown = -1,\r
62         WGFS_Empty = -2\r
63 };\r
64 \r
65 \r
66 // File flags\r
67 enum WGFILEFLAGS\r
68 {\r
69         WGFF_Directory          = (1<<0)        // enumerated file is a directory\r
70 };\r
71 \r
72 \r
73 struct wgFile_s\r
74 {\r
75         const char *sFileName;                  // filename or directory relative to project root (using forward slashes)\r
76         int nStatus;                                    // the WGFILESTATUS of the file\r
77         int nStage;                                             // the stage number of the file (0 if unstaged)\r
78         int nFlags;                                             // a combination of WGFILEFLAGS\r
79 \r
80         const BYTE* sha1;                               // points to the BYTE[20] sha1 (NULL for directories, WGFF_Directory)\r
81 };\r
82 \r
83 \r
84 // Application-defined callback function for wgEnumFiles, returns TRUE to abort enumeration\r
85 // 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
86 typedef BOOL (__cdecl WGENUMFILECB)(const struct wgFile_s *pFile, void *pUserData);\r
87 \r
88 \r
89 // Init git framework\r
90 BOOL WINGIT_API wgInit(void);\r
91 \r
92 // Get the lib version\r
93 LPCSTR WINGIT_API wgGetVersion(void);\r
94 \r
95 // Get the git version that is used in this lib\r
96 LPCSTR WINGIT_API wgGetGitVersion(void);\r
97 \r
98 // Enumerate files in a git project\r
99 // Ex: wgEnumFiles("C:\\Projects\\MyProject", "src/core", WGEFF_NoRecurse, MyEnumFunc, NULL)\r
100 BOOL WINGIT_API wgEnumFiles(const char *pszProjectPath, const char *pszSubPath, unsigned int nFlags, WGENUMFILECB *pEnumCb, void *pUserData);\r
101 \r
102 // Get the SHA1 of pszName (NULL is same as "HEAD", "HEAD^" etc. expression allowed), returns NULL on failure\r
103 // NOTE: do not store returned pointer for later used, data must be used/copied right away before further wg calls\r
104 LPBYTE WINGIT_API wgGetRevisionID(const char *pszProjectPath, const char *pszName);\r
105 \r
106 \r
107 #ifdef __cplusplus\r
108 }\r
109 #endif\r
110 #endif\r