3 // Windows GIT wrapper (under msysgit)
5 // This is NOT a full git API, it only exposes a few helper functions that
6 // third party windows apps might find useful, to avoid having to parse
7 // console output from the command-line tools.
9 // Make sure wingit.dll is placed in the bin directory of the msysgit installation.
11 // Created by Georg Fischer
16 #define WG_VERSION "0.1.7"
19 #define DLLIMPORT __declspec(dllimport) __stdcall
20 #define DLLEXPORT __declspec(dllexport) __stdcall
23 #define WINGIT_API DLLEXPORT
25 #define WINGIT_API DLLIMPORT
26 #endif // GAME_EXPORTS
33 // Flags for wgEnumFiles
36 WGEFF_NoRecurse
= (1<<0), // only enumerate files directly in the specified path
37 WGEFF_FullPath
= (1<<1), // enumerated filenames are specified with full path (instead of relative to proj root)
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)
39 WGEFF_DirStatusAll
= (1<<3), // include directories, in enumeration, with recursive status
40 WGEFF_EmptyAsNormal
= (1<<4), // report sub-directories, with no versioned files, as WGFS_Normal instead of WGFS_Empty
41 WGEFF_SingleFile
= (1<<5) // indicates that the status of a single file or dir, specified by pszSubPath, is wanted
44 // NOTE: Special behavior for directories when specifying WGEFF_SingleFile:
46 // * when combined with WGEFF_SingleFile the returned status will only reflect the immediate files in the dir,
47 // NOT the recusrive status of immediate sub-dirs
48 // * unlike a normal enumeration where the project root dir always is returned as WGFS_Normal regardless
49 // of WGEFF_EmptyAsNormal, the project root will return WGFS_Empty if no immediate versioned files
50 // unless WGEFF_EmptyAsNormal is specified
51 // * WGEFF_DirStatusDelta and WGEFF_DirStatusAll are ignored and can be omitted even for dirs
72 WGFF_Directory
= (1<<0) // enumerated file is a directory
78 const char *sFileName
; // filename or directory relative to project root (using forward slashes)
79 int nStatus
; // the WGFILESTATUS of the file
80 int nFlags
; // a combination of WGFILEFLAGS
82 const BYTE
* sha1
; // points to the BYTE[20] sha1 (NULL for directories, WGFF_Directory)
86 // Application-defined callback function for wgEnumFiles, returns TRUE to abort enumeration
87 // 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
88 typedef BOOL (__cdecl WGENUMFILECB
)(const struct wgFile_s
*pFile
, void *pUserData
);
92 BOOL WINGIT_API
wgInit(void);
94 // Get the lib version
95 LPCSTR WINGIT_API
wgGetVersion(void);
97 // Get the git version that is used in this lib
98 LPCSTR WINGIT_API
wgGetGitVersion(void);
100 // Enumerate files in a git project
101 // Ex: wgEnumFiles("C:\\Projects\\MyProject", "src/core", WGEFF_NoRecurse, MyEnumFunc, NULL)
102 BOOL WINGIT_API
wgEnumFiles(const char *pszProjectPath
, const char *pszSubPath
, unsigned int nFlags
, WGENUMFILECB
*pEnumCb
, void *pUserData
);
104 // Get the SHA1 of pszName (NULL is same as "HEAD", "HEAD^" etc. expression allowed), returns NULL on failure
105 // NOTE: do not store returned pointer for later used, data must be used/copied right away before further wg calls
106 LPBYTE WINGIT_API
wgGetRevisionID(const char *pszProjectPath
, const char *pszName
);