OSDN Git Service

changed EnumFiles path/file params to unicode strings
[tortoisegit/TortoiseGitJp.git] / src / Git / Git.h
1 #pragma once\r
2 #include "GitType.h"\r
3 #include "GitRev.h"\r
4 #include "GitStatus.h"\r
5 #include "GitAdminDir.h"\r
6 \r
7 class CGitCall\r
8 {\r
9 public:\r
10         CGitCall(){}\r
11         CGitCall(CString cmd):m_Cmd(cmd){}\r
12 \r
13         CString                 GetCmd()const{return m_Cmd;}\r
14         void                    SetCmd(CString cmd){m_Cmd=cmd;}\r
15 \r
16         //This function is called when command output data is available.\r
17         //When this function returns 'true' the git command should be aborted.\r
18         //This behavior is not implemented yet.\r
19         virtual bool    OnOutputData(const BYTE* data, size_t size)=0;\r
20         virtual void    OnEnd(){}\r
21 \r
22 private:\r
23         CString m_Cmd;\r
24 \r
25 };\r
26 \r
27 class CTGitPath;\r
28 \r
29 class CGit\r
30 {\r
31 private:\r
32         GitAdminDir m_GitDir;\r
33 public:\r
34         static BOOL CheckMsysGitDir();\r
35         static CString ms_LastMsysGitDir;       // the last msysgitdir added to the path, blank if none\r
36 \r
37 //      static CString m_MsysGitPath;\r
38         CGit(void);\r
39         ~CGit(void);\r
40         \r
41         int Run(CString cmd, CString* output,int code);\r
42         int Run(CString cmd, BYTE_VECTOR *byte_array);\r
43         int Run(CGitCall* pcall);\r
44 \r
45         int RunAsync(CString cmd,PROCESS_INFORMATION *pi, HANDLE* hRead, CString *StdioFile=NULL);\r
46         int RunLogFile(CString cmd, CString &filename);\r
47         CString GetUserName(void);\r
48         CString GetUserEmail(void);\r
49         CString GetCurrentBranch(void);\r
50         // read current branch name from HEAD file, returns 0 on success, -1 on failure, 1 detached (branch name "HEAD" returned)\r
51         int GetCurrentBranchFromFile(const CString &sProjectRoot, CString &sBranchOut);\r
52         BOOL CheckCleanWorkTree();\r
53         int Revert(CTGitPath &path,bool keep=true);\r
54         int Revert(CTGitPathList &list,bool keep=true);\r
55 \r
56         bool SetCurrentDir(CString path)\r
57         {\r
58                 return m_GitDir.HasAdminDir(path,&m_CurrentDir);\r
59         }\r
60         CString m_CurrentDir;\r
61 \r
62         typedef enum\r
63         {\r
64                 BRANCH_LOCAL=0x1,\r
65                 BRANCH_REMOTE=0x2,\r
66                 BRANCH_ALL=BRANCH_LOCAL|BRANCH_REMOTE,\r
67         }BRANCH_TYPE;\r
68 \r
69         typedef enum\r
70         {\r
71                 LOG_INFO_STAT=0x1,\r
72                 LOG_INFO_FILESTATE=0x2,\r
73                 LOG_INFO_PATCH=0x4,\r
74                 LOG_INFO_FULLHISTORY=0x8,\r
75                 LOG_INFO_BOUNDARY=0x10,\r
76         LOG_INFO_ALL_BRANCH=0x20,\r
77                 LOG_INFO_ONLY_HASH=0x40,\r
78                 LOG_INFO_DETECT_RENAME=0x80,\r
79                 LOG_INFO_DETECT_COPYRENAME=0x100,\r
80                 LOG_INFO_FIRST_PARENT = 0x200,\r
81                 LOG_INFO_NO_MERGE = 0x400,\r
82                 LOG_INFO_FOLLOW = 0x800\r
83         }LOG_INFO_MASK;\r
84 \r
85         int GetRemoteList(STRING_VECTOR &list);\r
86         int GetBranchList(STRING_VECTOR &list, int *Current,BRANCH_TYPE type=BRANCH_LOCAL);\r
87         int GetTagList(STRING_VECTOR &list);\r
88         int GetMapHashToFriendName(MAP_HASH_NAME &map);\r
89         \r
90         //hash is empty means all. -1 means all\r
91 \r
92         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,\r
93                                                                 CString *from=NULL,CString *to=NULL);\r
94         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,\r
95                                                                 CString *from=NULL,CString *to=NULL);\r
96 \r
97         BOOL EnumFiles(const TCHAR *pszProjectPath, const TCHAR *pszSubPath, unsigned int nFlags, WGENUMFILECB *pEnumCb, void *pUserData);\r
98 \r
99         git_revnum_t GetHash(CString &friendname);\r
100 \r
101         int BuildOutputFormat(CString &format,bool IsFull=TRUE);\r
102         //int GetShortLog(CString &log,CTGitPath * path=NULL, int count =-1);\r
103         static void StringAppend(CString *str,BYTE *p,int code=CP_UTF8,int length=-1);\r
104 \r
105         BOOL IsInitRepos();\r
106         int ListConflictFile(CTGitPathList &list,CTGitPath *path=NULL);\r
107         \r
108 };\r
109 extern void GetTempPath(CString &path);\r
110 extern CString GetTempFile();\r
111 \r
112 \r
113 extern CGit g_Git;\r
114 \r
115 inline static BOOL wgEnumFiles(const TCHAR *pszProjectPath, const TCHAR *pszSubPath, unsigned int nFlags, WGENUMFILECB *pEnumCb, void *pUserData) { return g_Git.EnumFiles(pszProjectPath, pszSubPath, nFlags, pEnumCb, pUserData); }\r