OSDN Git Service

Added extra helper methods to BYTE_VECTOR
[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(CString cmd):m_Cmd(cmd){}\r
11 \r
12         CString                 GetCmd()const{return m_Cmd;}\r
13 \r
14         //When this function returns 'true' the git command should be aborted.\r
15         //This behavior is not implemented yet.\r
16         virtual bool    OnOutputData(const BYTE* data, size_t size)=0;\r
17 \r
18 private:\r
19         CString m_Cmd;\r
20 \r
21 };\r
22 \r
23 class CGit\r
24 {\r
25 private:\r
26         GitAdminDir m_GitDir;\r
27 public:\r
28         static BOOL CheckMsysGitDir();\r
29         static CString ms_LastMsysGitDir;       // the last msysgitdir added to the path, blank if none\r
30 \r
31 //      static CString m_MsysGitPath;\r
32         CGit(void);\r
33         ~CGit(void);\r
34         \r
35         int Run(CString cmd, CString* output,int code);\r
36         int Run(CString cmd, BYTE_VECTOR *byte_array);\r
37         int Run(CGitCall* pcall);\r
38 \r
39         int RunAsync(CString cmd,PROCESS_INFORMATION *pi, HANDLE* hRead, CString *StdioFile=NULL);\r
40         int RunLogFile(CString cmd, CString &filename);\r
41         CString GetUserName(void);\r
42         CString GetUserEmail(void);\r
43         CString GetCurrentBranch(void);\r
44 \r
45         bool SetCurrentDir(CString path)\r
46         {\r
47                 return m_GitDir.HasAdminDir(path,&m_CurrentDir);\r
48         }\r
49         CString m_CurrentDir;\r
50 \r
51         typedef enum\r
52         {\r
53                 BRANCH_LOCAL=0x1,\r
54                 BRANCH_REMOTE=0x2,\r
55                 BRANCH_ALL=BRANCH_LOCAL|BRANCH_REMOTE,\r
56         }BRANCH_TYPE;\r
57 \r
58         typedef enum\r
59         {\r
60                 LOG_INFO_STAT=0x1,\r
61                 LOG_INFO_FILESTATE=0x2,\r
62                 LOG_INFO_PATCH=0x4,\r
63                 LOG_INFO_FULLHISTORY=0x8,\r
64                 LOG_INFO_BOUNDARY=0x10,\r
65         LOG_INFO_ALL_BRANCH=0x20,\r
66                 LOG_INFO_ONLY_HASH=0x40,\r
67                 LOG_INFO_DETECT_RENAME=0x80,\r
68                 LOG_INFO_DETECT_COPYRENAME=0x100,\r
69                 LOG_INFO_FIRST_PARENT = 0x200,\r
70                 LOG_INFO_NO_MERGE = 0x400,\r
71                 LOG_INFO_FOLLOW = 0x800\r
72         }LOG_INFO_MASK;\r
73 \r
74         int GetRemoteList(STRING_VECTOR &list);\r
75         int GetBranchList(STRING_VECTOR &list, int *Current,BRANCH_TYPE type=BRANCH_LOCAL);\r
76         int GetTagList(STRING_VECTOR &list);\r
77         int GetMapHashToFriendName(MAP_HASH_NAME &map);\r
78         \r
79         //hash is empty means all. -1 means all\r
80         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
81 \r
82         git_revnum_t GetHash(CString &friendname);\r
83 \r
84         int BuildOutputFormat(CString &format,bool IsFull=TRUE);\r
85         //int GetShortLog(CString &log,CTGitPath * path=NULL, int count =-1);\r
86         static void StringAppend(CString *str,BYTE *p,int code=CP_UTF8,int length=-1);\r
87 \r
88         BOOL IsInitRepos();\r
89         static BOOL IsVista();\r
90         \r
91 };\r
92 extern void GetTempPath(CString &path);\r
93 extern CString GetTempFile();\r
94 \r
95 \r
96 extern CGit g_Git;\r
97 \r
98 extern LPBYTE wgGetRevisionID_safe(const char *pszProjectPath, const char *pszName);\r
99 extern BOOL wgEnumFiles_safe(const char *pszProjectPath, const char *pszSubPath, unsigned int nFlags, WGENUMFILECB *pEnumCb, void *pUserData);\r