1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2020 - 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)
42 #define LIBGIT_GIT_HASH_SIZE 32
44 typedef unsigned char GIT_HASH
[LIBGIT_GIT_HASH_SIZE
];
46 struct GIT_OBJECT_OID
{
47 unsigned char hash
[LIBGIT_GIT_HASH_SIZE
];
50 typedef void * GIT_HANDLE
;
51 typedef void * GIT_LOG
;
53 typedef void * GIT_DIFF
;
54 typedef void * GIT_FILE
;
55 typedef void * GIT_COMMIT_LIST
;
57 struct GIT_COMMIT_AUTHOR
67 typedef struct GIT_COMMIT_DATA
70 struct GIT_COMMIT_AUTHOR m_Author
;
71 struct GIT_COMMIT_AUTHOR m_Committer
;
72 const char* m_Subject
;
76 void * m_pGitCommit
; /** internal used */
85 * @param name [IN] Reference name, such as HEAD, master, ...
86 * @param sha1 [OUT] char[20] hash value. Caller prepare char[20] buffer.
89 GITDLL_API
int git_get_sha1(const char *name
, GIT_HASH sha1
);
92 * @remark, this function must be call before other function.
95 GITDLL_API
int git_init(void);
97 GITDLL_API
int git_open_log(GIT_LOG
* handle
, const char* arg
);
98 GITDLL_API
int git_get_log_firstcommit(GIT_LOG handle
);
99 GITDLL_API
int git_get_log_estimate_commit_count(GIT_LOG handle
);
103 * @param handle [IN]handle Get handle from git_open_log
104 * @param commit [OUT]commit Caller need prepare buffer for this call
105 * @param follow [IN]follow Follow history beyond renames (see --follow)
107 * @remark Caller need call git_free_commit to free internal buffer after use it;
109 GITDLL_API
int git_get_log_nextcommit(GIT_LOG handle
, GIT_COMMIT
*commit
, int follow
);
111 GITDLL_API
int git_close_log(GIT_LOG handle
);
114 * Get Commit information from commit hash
115 * @param commit [OUT] output commit information
116 * @param hash [in] hash
119 GITDLL_API
int git_get_commit_from_hash(GIT_COMMIT
* commit
, const GIT_HASH hash
);
120 GITDLL_API
int git_parse_commit(GIT_COMMIT
*commit
);
121 GITDLL_API
int git_commit_is_root(const GIT_COMMIT
* commit
);
122 GITDLL_API
int git_get_commit_first_parent(GIT_COMMIT
*commit
,GIT_COMMIT_LIST
*list
);
123 GITDLL_API
int git_get_commit_next_parent(GIT_COMMIT_LIST
*list
, GIT_HASH hash
);
125 GITDLL_API
int git_free_commit(GIT_COMMIT
*commit
);
127 GITDLL_API
int git_open_diff(GIT_DIFF
* diff
, const char* arg
);
128 GITDLL_API
int git_do_diff(GIT_DIFF diff
, const GIT_HASH hash1
, const GIT_HASH hash2
, GIT_FILE
* file
, int* count
, int isstat
);
129 GITDLL_API
int git_root_diff(GIT_DIFF diff
, const GIT_HASH hash
, GIT_FILE
* file
, int* count
, int isstat
);
130 GITDLL_API
int git_diff_flush(GIT_DIFF diff
);
131 GITDLL_API
int git_close_diff(GIT_DIFF diff
);
134 GITDLL_API
int git_get_diff_file(GIT_DIFF diff
, GIT_FILE file
, int i
, char** newname
, char** oldname
, int* IsDir
, int* status
, int* IsBin
, int* inc
, int* dec
);
137 typedef void * EXCLUDE_LIST
;
139 GITDLL_API
int git_create_exclude_list(EXCLUDE_LIST
*which
);
141 GITDLL_API
int git_add_exclude(const char *string
, const char *base
,
142 int baselen
, EXCLUDE_LIST which
, int lineno
);
144 GITDLL_API
int git_check_excluded_1(const char *pathname
,
145 int pathlen
, const char *basename
, int *dtype
,
146 EXCLUDE_LIST el
, int ignorecase
);
153 GITDLL_API
int git_free_exclude_list(EXCLUDE_LIST which
);
155 //caller need free p_note
156 GITDLL_API
int git_get_notes(const GIT_HASH hash
, char** p_note
);
158 GITDLL_API
int git_update_index(void);
160 GITDLL_API
void git_exit_cleanup(void);
162 #define REF_ISSYMREF 01
163 #define REF_ISPACKED 02
165 typedef int each_ref_fn(const char* refname
, const struct GIT_OBJECT_OID
* oid
, int flags
, void* cb_data
);
167 typedef int each_reflog_ent_fn(struct GIT_OBJECT_OID
* old_oid
, struct GIT_OBJECT_OID
* new_oid
, const char* committer
, unsigned long long timestamp
, int tz
, const char* msg
, void* cb_data
);
168 GITDLL_API
int git_for_each_reflog_ent(const char *ref
, each_reflog_ent_fn fn
, void *cb_data
);
170 GITDLL_API
int git_checkout_file(const char* ref
, const char* path
, char* outputpath
);
172 GITDLL_API
int git_get_config(const char *key
, char *buffer
, int size
);
183 GITDLL_API
int get_set_config(const char *key
, const char *value
, CONFIG_TYPE type
);
185 const char *get_windows_home_directory(void);
187 GITDLL_API
const wchar_t *wget_windows_home_directory(void);
188 GITDLL_API
const wchar_t *wget_msysgit_etc(void);
189 GITDLL_API
const wchar_t *wget_program_data_config(void);
191 typedef void *GIT_MAILMAP
;
193 GITDLL_API
int git_read_mailmap(GIT_MAILMAP
*mailmap
);
194 GITDLL_API
int git_lookup_mailmap(GIT_MAILMAP mailmap
, const char** email1
, const char** name1
, const char* email2
, void* payload
, const char* (*author2_cb
)(void*));
195 GITDLL_API
void git_free_mailmap(GIT_MAILMAP mailmap
);
197 GITDLL_API
int git_mkdir(const char* path
);