Add support i18n.logOutputEncoding at log list
[TortoiseGit.git] / src / Git / Git.h
blobe0dde8dc26a66fb67fbda919717dd1d34ca3c3d6
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
36 static int m_LogEncode;
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);
50 // read current branch name from HEAD file, returns 0 on success, -1 on failure, 1 detached (branch name "HEAD" returned)
51 int GetCurrentBranchFromFile(const CString &sProjectRoot, CString &sBranchOut);
52 BOOL CheckCleanWorkTree();
53 int Revert(CTGitPath &path,bool keep=true);
54 int Revert(CTGitPathList &list,bool keep=true);
56 bool SetCurrentDir(CString path)
58 return m_GitDir.HasAdminDir(path,&m_CurrentDir);
60 CString m_CurrentDir;
62 typedef enum
64 BRANCH_LOCAL=0x1,
65 BRANCH_REMOTE=0x2,
66 BRANCH_ALL=BRANCH_LOCAL|BRANCH_REMOTE,
67 }BRANCH_TYPE;
69 typedef enum
71 LOG_INFO_STAT=0x1,
72 LOG_INFO_FILESTATE=0x2,
73 LOG_INFO_PATCH=0x4,
74 LOG_INFO_FULLHISTORY=0x8,
75 LOG_INFO_BOUNDARY=0x10,
76 LOG_INFO_ALL_BRANCH=0x20,
77 LOG_INFO_ONLY_HASH=0x40,
78 LOG_INFO_DETECT_RENAME=0x80,
79 LOG_INFO_DETECT_COPYRENAME=0x100,
80 LOG_INFO_FIRST_PARENT = 0x200,
81 LOG_INFO_NO_MERGE = 0x400,
82 LOG_INFO_FOLLOW = 0x800,
83 LOG_INFO_SHOW_MERGEDFILE=0x1000
84 }LOG_INFO_MASK;
86 int GetRemoteList(STRING_VECTOR &list);
87 int GetBranchList(STRING_VECTOR &list, int *Current,BRANCH_TYPE type=BRANCH_LOCAL);
88 int GetTagList(STRING_VECTOR &list);
89 int GetMapHashToFriendName(MAP_HASH_NAME &map);
91 //hash is empty means all. -1 means all
93 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|LOG_INFO_SHOW_MERGEDFILE,
94 CString *from=NULL,CString *to=NULL);
95 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|LOG_INFO_SHOW_MERGEDFILE,
96 CString *from=NULL,CString *to=NULL);
98 BOOL EnumFiles(const TCHAR *pszProjectPath, const TCHAR *pszSubPath, unsigned int nFlags, WGENUMFILECB *pEnumCb, void *pUserData);
100 git_revnum_t GetHash(CString &friendname);
102 int BuildOutputFormat(CString &format,bool IsFull=TRUE);
103 //int GetShortLog(CString &log,CTGitPath * path=NULL, int count =-1);
104 static void StringAppend(CString *str,BYTE *p,int code=CP_UTF8,int length=-1);
106 BOOL IsInitRepos();
107 int ListConflictFile(CTGitPathList &list,CTGitPath *path=NULL);
108 int GetRefList(STRING_VECTOR &list);
111 extern void GetTempPath(CString &path);
112 extern CString GetTempFile();
115 extern CGit g_Git;
117 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); }