Make TortoiseGit work with unicode HomeDirectories
[TortoiseGit.git] / ext / gitdll / gitdll.h
blobbdaa0914834236daa73f4ee3096b13c47266bb81
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // The following ifdef block is the standard way of creating macros which make exporting
21 // from a DLL simpler. All files within this DLL are compiled with the GITDLL_EXPORTS
22 // symbol defined on the command line. this symbol should not be defined on any project
23 // that uses this DLL. This way any other project whose source files include this file see
24 // GITDLL_API functions as being imported from a DLL, whereas this DLL sees symbols
25 // defined with this macro as being exported.
27 #ifndef __GITDLL__
28 #define __GITDLL__
30 #ifdef __cplusplus
31 #define EXTERN extern "C"
32 #else
33 #define EXTERN
34 #endif
36 #ifdef GITDLL_EXPORTS
37 #define GITDLL_API EXTERN __declspec(dllexport)
38 #else
39 #define GITDLL_API EXTERN __declspec(dllimport)
40 #endif
42 #if 0
43 // This class is exported from the gitdll.dll
44 class GITDLL_API Cgitdll {
45 public:
46 Cgitdll(void);
47 // TODO: add your methods here.
49 #endif
51 #define GIT_HASH_SIZE 20
53 typedef unsigned char GIT_HASH[GIT_HASH_SIZE];
55 typedef void * GIT_HANDLE;
56 typedef void * GIT_LOG;
58 typedef void * GIT_DIFF;
59 typedef void * GIT_FILE;
60 typedef void * GIT_COMMIT_LIST;
62 struct GIT_COMMIT_AUTHOR
64 char *Name;
65 int NameSize;
66 char *Email;
67 int EmailSize;
68 int Date;
69 int TimeZone;
72 typedef struct GIT_COMMIT_DATA
74 GIT_HASH m_hash;
75 struct GIT_COMMIT_AUTHOR m_Author;
76 struct GIT_COMMIT_AUTHOR m_Committer;
77 char * m_Subject;
78 int m_SubjectSize;
79 char * m_Body;
80 int m_BodySize;
81 void * m_pGitCommit; /** internal used */
82 char * m_Encode;
83 int m_EncodeSize;
84 int m_ignore;
86 } GIT_COMMIT;
89 GITDLL_API int ngitdll;
91 GITDLL_API int fngitdll(void);
92 /**
93 * Get Git Last Error string.
95 GITDLL_API char * get_git_last_error();
96 /**
97 * Get hash value.
98 * @param name [IN] Reference name, such as HEAD, master, ...
99 * @param sha1 [OUT] char[20] hash value. Caller prepare char[20] buffer.
100 * @return 0 success.
102 GITDLL_API int git_get_sha1(const char *name, GIT_HASH sha1);
104 * Init git dll
105 * @remark, this function must be call before other function.
106 * @return 0 success
108 GITDLL_API int git_init();
110 GITDLL_API int git_open_log(GIT_LOG * handle, char * arg);
111 GITDLL_API int git_get_log_firstcommit(GIT_LOG handle);
112 GITDLL_API int git_get_log_estimate_commit_count(GIT_LOG handle);
115 * Get Next Commit
116 * @param handle [IN]handle Get handle from git_open_log
117 * @param commit [OUT]commit Caller need prepare buffer for this call
118 * @return 0 success
119 * @remark Caller need call git_free_commit to free internal buffer after use it;
121 GITDLL_API int git_get_log_nextcommit(GIT_LOG handle, GIT_COMMIT *commit, int follow);
123 GITDLL_API int git_close_log(GIT_LOG handle);
126 * Get Commit information from commit hash
127 * @param commit [OUT] output commit information
128 * @param hash [in] hash
129 * @return 0 success
131 GITDLL_API int git_get_commit_from_hash(GIT_COMMIT *commit, GIT_HASH hash);
132 GITDLL_API int git_parse_commit(GIT_COMMIT *commit);
134 GITDLL_API int git_get_commit_first_parent(GIT_COMMIT *commit,GIT_COMMIT_LIST *list);
135 GITDLL_API int git_get_commit_next_parent(GIT_COMMIT_LIST *list, GIT_HASH hash);
137 GITDLL_API int git_free_commit(GIT_COMMIT *commit);
139 GITDLL_API int git_open_diff(GIT_DIFF *diff, char * arg);
140 GITDLL_API int git_diff(GIT_DIFF diff, GIT_HASH hash1,GIT_HASH hash2, GIT_FILE * file, int *count, int isstat);
141 GITDLL_API int git_root_diff(GIT_DIFF diff, GIT_HASH hash,GIT_FILE *file, int *count,int isstat);
142 GITDLL_API int git_diff_flush(GIT_DIFF diff);
143 GITDLL_API int git_close_diff(GIT_DIFF diff);
146 GITDLL_API int git_get_diff_file(GIT_DIFF diff,GIT_FILE file, int i,char **newname, char **oldname, int *mode, int *IsBin, int *inc, int *dec);
148 #define READ_TREE_RECURSIVE 1
149 typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const char *, unsigned int, int, void *);
151 GITDLL_API int git_read_tree(GIT_HASH hash,read_tree_fn_t fn, void *context);
154 typedef void * EXCLUDE_LIST;
156 GITDLL_API int git_create_exclude_list(EXCLUDE_LIST *which);
158 GITDLL_API int git_add_exclude(const char *string, const char *base,
159 int baselen, EXCLUDE_LIST which);
161 GITDLL_API int git_check_excluded_1(const char *pathname,
162 int pathlen, const char *basename, int *dtype,
163 EXCLUDE_LIST el);
165 #define DT_UNKNOWN 0
166 #define DT_DIR 1
167 #define DT_REG 2
168 #define DT_LNK 3
170 GITDLL_API int git_free_exclude_list(EXCLUDE_LIST which);
172 //caller need free p_note
173 GITDLL_API int git_get_notes(GIT_HASH hash, char **p_note);
175 GITDLL_API int git_run_cmd(char *cmd, char *arg);
177 #define REF_ISSYMREF 01
178 #define REF_ISPACKED 02
180 typedef int each_ref_fn(const char *refname, const unsigned char *sha1, int flags, void *cb_data);
181 GITDLL_API int git_head_ref(each_ref_fn, void *);
182 GITDLL_API int git_for_each_ref_in(const char *, each_ref_fn, void *);
183 GITDLL_API const char *git_resolve_ref(const char *path, unsigned char *sha1, int, int *);
185 typedef int each_reflog_ent_fn(unsigned char *osha1, unsigned char *nsha1, const char *, unsigned long, int, const char *, void *);
186 GITDLL_API int git_for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data);
187 GITDLL_API int git_deref_tag(const unsigned char *tagsha1,GIT_HASH refhash);
189 GITDLL_API int git_checkout_file(const char *ref, const char *path, const char *outputpath);
191 GITDLL_API int git_get_config(const char *key, char *buffer, int size, char* git_path);
193 typedef enum
195 CONFIG_LOCAL,
196 CONFIG_GLOBAL,
197 CONFIG_SYSTEM,
199 }CONFIG_TYPE;
201 GITDLL_API int get_set_config(const char *key, char *value, CONFIG_TYPE type, char *git_path);
203 const char *get_windows_home_directory(void);
205 GITDLL_API const wchar_t *wget_windows_home_directory(void);
207 GITDLL_API const char *get_msysgit_etc(void);
209 #endif