Started implementing EnumFiles() with git.exe call
[TortoiseGit.git] / src / Git / Git.h
blob632ddb34b7fd52e6a3c88e59a051c0596af6c578
1 #pragma once
2 #include "GitType.h"
3 #include "GitRev.h"
4 #include "GitStatus.h"
5 #include "GitAdminDir.h"
7 class CGitCall
9 public:
10 CGitCall(){}
11 CGitCall(CString cmd):m_Cmd(cmd){}
13 CString GetCmd()const{return m_Cmd;}
14 void SetCmd(CString cmd){m_Cmd=cmd;}
16 //This function is called when command output data is available.
17 //When this function returns 'true' the git command should be aborted.
18 //This behavior is not implemented yet.
19 virtual bool OnOutputData(const BYTE* data, size_t size)=0;
20 virtual void OnEnd(){}
22 private:
23 CString m_Cmd;
27 class CTGitPath;
29 class CGit
31 private:
32 GitAdminDir m_GitDir;
33 public:
34 static BOOL CheckMsysGitDir();
35 static CString ms_LastMsysGitDir; // the last msysgitdir added to the path, blank if none
37 // static CString m_MsysGitPath;
38 CGit(void);
39 ~CGit(void);
41 int Run(CString cmd, CString* output,int code);
42 int Run(CString cmd, BYTE_VECTOR *byte_array);
43 int Run(CGitCall* pcall);
45 int RunAsync(CString cmd,PROCESS_INFORMATION *pi, HANDLE* hRead, CString *StdioFile=NULL);
46 int RunLogFile(CString cmd, CString &filename);
47 CString GetUserName(void);
48 CString GetUserEmail(void);
49 CString GetCurrentBranch(void);
51 bool SetCurrentDir(CString path)
53 return m_GitDir.HasAdminDir(path,&m_CurrentDir);
55 CString m_CurrentDir;
57 typedef enum
59 BRANCH_LOCAL=0x1,
60 BRANCH_REMOTE=0x2,
61 BRANCH_ALL=BRANCH_LOCAL|BRANCH_REMOTE,
62 }BRANCH_TYPE;
64 typedef enum
66 LOG_INFO_STAT=0x1,
67 LOG_INFO_FILESTATE=0x2,
68 LOG_INFO_PATCH=0x4,
69 LOG_INFO_FULLHISTORY=0x8,
70 LOG_INFO_BOUNDARY=0x10,
71 LOG_INFO_ALL_BRANCH=0x20,
72 LOG_INFO_ONLY_HASH=0x40,
73 LOG_INFO_DETECT_RENAME=0x80,
74 LOG_INFO_DETECT_COPYRENAME=0x100,
75 LOG_INFO_FIRST_PARENT = 0x200,
76 LOG_INFO_NO_MERGE = 0x400,
77 LOG_INFO_FOLLOW = 0x800
78 }LOG_INFO_MASK;
80 int GetRemoteList(STRING_VECTOR &list);
81 int GetBranchList(STRING_VECTOR &list, int *Current,BRANCH_TYPE type=BRANCH_LOCAL);
82 int GetTagList(STRING_VECTOR &list);
83 int GetMapHashToFriendName(MAP_HASH_NAME &map);
85 //hash is empty means all. -1 means all
87 int GetLog(CGitCall* pgitCall, CString &hash, CTGitPath *path = NULL,int count=-1,int InfoMask=LOG_INFO_STAT|LOG_INFO_FILESTATE|LOG_INFO_BOUNDARY|LOG_INFO_DETECT_COPYRENAME);
88 int GetLog(BYTE_VECTOR& logOut,CString &hash, CTGitPath *path = NULL,int count=-1,int InfoMask=LOG_INFO_STAT|LOG_INFO_FILESTATE|LOG_INFO_BOUNDARY|LOG_INFO_DETECT_COPYRENAME);
90 BOOL EnumFiles(const char *pszProjectPath, const char *pszSubPath, unsigned int nFlags, WGENUMFILECB *pEnumCb, void *pUserData);
92 git_revnum_t GetHash(CString &friendname);
94 int BuildOutputFormat(CString &format,bool IsFull=TRUE);
95 //int GetShortLog(CString &log,CTGitPath * path=NULL, int count =-1);
96 static void StringAppend(CString *str,BYTE *p,int code=CP_UTF8,int length=-1);
98 BOOL IsInitRepos();
99 static BOOL IsVista();
102 extern void GetTempPath(CString &path);
103 extern CString GetTempFile();
106 extern CGit g_Git;
108 extern LPBYTE wgGetRevisionID_safe(const char *pszProjectPath, const char *pszName);
109 extern BOOL wgEnumFiles_safe(const char *pszProjectPath, const char *pszSubPath, unsigned int nFlags, WGENUMFILECB *pEnumCb, void *pUserData);