Can display author/commit date after year 2038
[TortoiseGit.git] / ext / gitdll / gitdll.h
blobfdefbf3504861c1bad3d351d4410b304cae2f26c
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.
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 #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
59 const char* Name;
60 int NameSize;
61 const char* Email;
62 int EmailSize;
63 long long Date;
64 int TimeZone;
67 typedef struct GIT_COMMIT_DATA
69 GIT_HASH m_hash;
70 struct GIT_COMMIT_AUTHOR m_Author;
71 struct GIT_COMMIT_AUTHOR m_Committer;
72 const char* m_Subject;
73 int m_SubjectSize;
74 const char* m_Body;
75 int m_BodySize;
76 void * m_pGitCommit; /** internal used */
77 const char* m_Encode;
78 int m_EncodeSize;
79 int m_ignore;
80 const void* buffer;
81 } GIT_COMMIT;
83 /**
84 * Get hash value.
85 * @param name [IN] Reference name, such as HEAD, master, ...
86 * @param sha1 [OUT] char[20] hash value. Caller prepare char[20] buffer.
87 * @return 0 success.
89 GITDLL_API int git_get_sha1(const char *name, GIT_HASH sha1);
90 /**
91 * Init git dll
92 * @remark, this function must be call before other function.
93 * @return 0 success
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);
102 * Get Next Commit
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)
106 * @return 0 success
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
117 * @return 0 success
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);
148 #define DT_UNKNOWN 0
149 #define DT_DIR 1
150 #define DT_REG 2
151 #define DT_LNK 3
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);
174 typedef enum
176 CONFIG_LOCAL,
177 CONFIG_GLOBAL,
178 CONFIG_XDGGLOBAL,
179 CONFIG_SYSTEM,
181 }CONFIG_TYPE;
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);
199 #endif