1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2014 - 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 */
90 * @param name [IN] Reference name, such as HEAD, master, ...
91 * @param sha1 [OUT] char[20] hash value. Caller prepare char[20] buffer.
94 GITDLL_API
int git_get_sha1(const char *name
, GIT_HASH sha1
);
97 * @remark, this function must be call before other function.
100 GITDLL_API
int git_init();
102 GITDLL_API
int git_open_log(GIT_LOG
* handle
, char * arg
);
103 GITDLL_API
int git_get_log_firstcommit(GIT_LOG handle
);
104 GITDLL_API
int git_get_log_estimate_commit_count(GIT_LOG handle
);
108 * @param handle [IN]handle Get handle from git_open_log
109 * @param commit [OUT]commit Caller need prepare buffer for this call
110 * @param follow [IN]follow Follow history beyond renames (see --follow)
112 * @remark Caller need call git_free_commit to free internal buffer after use it;
114 GITDLL_API
int git_get_log_nextcommit(GIT_LOG handle
, GIT_COMMIT
*commit
, int follow
);
116 GITDLL_API
int git_close_log(GIT_LOG handle
);
119 * Get Commit information from commit hash
120 * @param commit [OUT] output commit information
121 * @param hash [in] hash
124 GITDLL_API
int git_get_commit_from_hash(GIT_COMMIT
*commit
, GIT_HASH hash
);
125 GITDLL_API
int git_parse_commit(GIT_COMMIT
*commit
);
127 GITDLL_API
int git_get_commit_first_parent(GIT_COMMIT
*commit
,GIT_COMMIT_LIST
*list
);
128 GITDLL_API
int git_get_commit_next_parent(GIT_COMMIT_LIST
*list
, GIT_HASH hash
);
130 GITDLL_API
int git_free_commit(GIT_COMMIT
*commit
);
132 GITDLL_API
int git_open_diff(GIT_DIFF
*diff
, char * arg
);
133 GITDLL_API
int git_do_diff(GIT_DIFF diff
, GIT_HASH hash1
,GIT_HASH hash2
, GIT_FILE
* file
, int *count
, int isstat
);
134 GITDLL_API
int git_root_diff(GIT_DIFF diff
, GIT_HASH hash
,GIT_FILE
*file
, int *count
,int isstat
);
135 GITDLL_API
int git_diff_flush(GIT_DIFF diff
);
136 GITDLL_API
int git_close_diff(GIT_DIFF diff
);
139 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
);
141 #define READ_TREE_RECURSIVE 1
142 typedef int (*read_tree_fn_t
)(const unsigned char *, const char *, int, const char *, unsigned int, int, void *);
144 GITDLL_API
int git_read_tree(GIT_HASH hash
,read_tree_fn_t fn
, void *context
);
147 typedef void * EXCLUDE_LIST
;
149 GITDLL_API
int git_create_exclude_list(EXCLUDE_LIST
*which
);
151 GITDLL_API
int git_add_exclude(const char *string
, const char *base
,
152 int baselen
, EXCLUDE_LIST which
, int lineno
);
154 GITDLL_API
int git_check_excluded_1(const char *pathname
,
155 int pathlen
, const char *basename
, int *dtype
,
163 GITDLL_API
int git_free_exclude_list(EXCLUDE_LIST which
);
165 //caller need free p_note
166 GITDLL_API
int git_get_notes(GIT_HASH hash
, char **p_note
);
168 GITDLL_API
int git_run_cmd(char *cmd
, char *arg
);
170 #define REF_ISSYMREF 01
171 #define REF_ISPACKED 02
173 typedef int each_ref_fn(const char *refname
, const unsigned char *sha1
, int flags
, void *cb_data
);
174 GITDLL_API
int git_head_ref(each_ref_fn
, void *);
175 GITDLL_API
int git_for_each_ref_in(const char *, each_ref_fn
, void *);
176 GITDLL_API
const char *git_resolve_ref(const char *path
, unsigned char *sha1
, int, int *);
178 typedef int each_reflog_ent_fn(unsigned char *osha1
, unsigned char *nsha1
, const char *, unsigned long, int, const char *, void *);
179 GITDLL_API
int git_for_each_reflog_ent(const char *ref
, each_reflog_ent_fn fn
, void *cb_data
);
180 GITDLL_API
int git_deref_tag(const unsigned char *tagsha1
,GIT_HASH refhash
);
182 GITDLL_API
int git_checkout_file(const char *ref
, const char *path
, const char *outputpath
);
184 GITDLL_API
int git_get_config(const char *key
, char *buffer
, int size
);
195 GITDLL_API
int get_set_config(const char *key
, const char *value
, CONFIG_TYPE type
);
197 const char *get_windows_home_directory(void);
199 GITDLL_API
const wchar_t *wget_windows_home_directory(void);
200 GITDLL_API
const wchar_t *wget_msysgit_etc(void);
202 typedef void *GIT_MAILMAP
;
204 GITDLL_API
int git_read_mailmap(GIT_MAILMAP
*mailmap
);
205 GITDLL_API
const char * git_get_mailmap_author(GIT_MAILMAP mailmap
, const char *email2
, void *payload
, const char *(*author2_cb
)(void *));
206 GITDLL_API
void git_free_mailmap(GIT_MAILMAP mailmap
);