1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013 - 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.
31 #define EXTERN extern "C"
37 #define GITDLL_API EXTERN __declspec(dllexport)
39 #define GITDLL_API EXTERN __declspec(dllimport)
43 // This class is exported from the gitdll.dll
44 class GITDLL_API Cgitdll
{
47 // TODO: add your methods here.
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
72 typedef struct GIT_COMMIT_DATA
75 struct GIT_COMMIT_AUTHOR m_Author
;
76 struct GIT_COMMIT_AUTHOR m_Committer
;
81 void * m_pGitCommit
; /** internal used */
89 GITDLL_API
int ngitdll
;
91 GITDLL_API
int fngitdll(void);
93 * Get Git Last Error string.
95 GITDLL_API
char * get_git_last_error();
98 * @param name [IN] Reference name, such as HEAD, master, ...
99 * @param sha1 [OUT] char[20] hash value. Caller prepare char[20] buffer.
102 GITDLL_API
int git_get_sha1(const char *name
, GIT_HASH sha1
);
105 * @remark, this function must be call before other function.
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
);
116 * @param handle [IN]handle Get handle from git_open_log
117 * @param commit [OUT]commit Caller need prepare buffer for this call
118 * @param follow [IN]follow Follow history beyond renames (see --follow)
120 * @remark Caller need call git_free_commit to free internal buffer after use it;
122 GITDLL_API
int git_get_log_nextcommit(GIT_LOG handle
, GIT_COMMIT
*commit
, int follow
);
124 GITDLL_API
int git_close_log(GIT_LOG handle
);
127 * Get Commit information from commit hash
128 * @param commit [OUT] output commit information
129 * @param hash [in] hash
132 GITDLL_API
int git_get_commit_from_hash(GIT_COMMIT
*commit
, GIT_HASH hash
);
133 GITDLL_API
int git_parse_commit(GIT_COMMIT
*commit
);
135 GITDLL_API
int git_get_commit_first_parent(GIT_COMMIT
*commit
,GIT_COMMIT_LIST
*list
);
136 GITDLL_API
int git_get_commit_next_parent(GIT_COMMIT_LIST
*list
, GIT_HASH hash
);
138 GITDLL_API
int git_free_commit(GIT_COMMIT
*commit
);
140 GITDLL_API
int git_open_diff(GIT_DIFF
*diff
, char * arg
);
141 GITDLL_API
int git_diff(GIT_DIFF diff
, GIT_HASH hash1
,GIT_HASH hash2
, GIT_FILE
* file
, int *count
, int isstat
);
142 GITDLL_API
int git_root_diff(GIT_DIFF diff
, GIT_HASH hash
,GIT_FILE
*file
, int *count
,int isstat
);
143 GITDLL_API
int git_diff_flush(GIT_DIFF diff
);
144 GITDLL_API
int git_close_diff(GIT_DIFF diff
);
147 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
);
149 #define READ_TREE_RECURSIVE 1
150 typedef int (*read_tree_fn_t
)(const unsigned char *, const char *, int, const char *, unsigned int, int, void *);
152 GITDLL_API
int git_read_tree(GIT_HASH hash
,read_tree_fn_t fn
, void *context
);
155 typedef void * EXCLUDE_LIST
;
157 GITDLL_API
int git_create_exclude_list(EXCLUDE_LIST
*which
);
159 GITDLL_API
int git_add_exclude(const char *string
, const char *base
,
160 int baselen
, EXCLUDE_LIST which
);
162 GITDLL_API
int git_check_excluded_1(const char *pathname
,
163 int pathlen
, const char *basename
, int *dtype
,
171 GITDLL_API
int git_free_exclude_list(EXCLUDE_LIST which
);
173 //caller need free p_note
174 GITDLL_API
int git_get_notes(GIT_HASH hash
, char **p_note
);
176 GITDLL_API
int git_run_cmd(char *cmd
, char *arg
);
178 #define REF_ISSYMREF 01
179 #define REF_ISPACKED 02
181 typedef int each_ref_fn(const char *refname
, const unsigned char *sha1
, int flags
, void *cb_data
);
182 GITDLL_API
int git_head_ref(each_ref_fn
, void *);
183 GITDLL_API
int git_for_each_ref_in(const char *, each_ref_fn
, void *);
184 GITDLL_API
const char *git_resolve_ref(const char *path
, unsigned char *sha1
, int, int *);
186 typedef int each_reflog_ent_fn(unsigned char *osha1
, unsigned char *nsha1
, const char *, unsigned long, int, const char *, void *);
187 GITDLL_API
int git_for_each_reflog_ent(const char *ref
, each_reflog_ent_fn fn
, void *cb_data
);
188 GITDLL_API
int git_deref_tag(const unsigned char *tagsha1
,GIT_HASH refhash
);
190 GITDLL_API
int git_checkout_file(const char *ref
, const char *path
, const char *outputpath
);
192 GITDLL_API
int git_get_config(const char *key
, char *buffer
, int size
, char* git_path
);
203 GITDLL_API
int get_set_config(const char *key
, char *value
, CONFIG_TYPE type
, char *git_path
);
205 const char *get_windows_home_directory(void);
207 GITDLL_API
const wchar_t *wget_windows_home_directory(void);
208 GITDLL_API
const wchar_t *wget_msysgit_etc(void);