| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* |
|
2
|
|
|
|
|
|
|
* Copyright (C) the libgit2 contributors. All rights reserved. |
|
3
|
|
|
|
|
|
|
* |
|
4
|
|
|
|
|
|
|
* This file is part of libgit2, distributed under the GNU GPL v2 with |
|
5
|
|
|
|
|
|
|
* a Linking Exception. For full terms see the included COPYING file. |
|
6
|
|
|
|
|
|
|
*/ |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#include "libgit2.h" |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include |
|
11
|
|
|
|
|
|
|
#include "alloc.h" |
|
12
|
|
|
|
|
|
|
#include "buf.h" |
|
13
|
|
|
|
|
|
|
#include "cache.h" |
|
14
|
|
|
|
|
|
|
#include "common.h" |
|
15
|
|
|
|
|
|
|
#include "filter.h" |
|
16
|
|
|
|
|
|
|
#include "hash.h" |
|
17
|
|
|
|
|
|
|
#include "index.h" |
|
18
|
|
|
|
|
|
|
#include "merge_driver.h" |
|
19
|
|
|
|
|
|
|
#include "pool.h" |
|
20
|
|
|
|
|
|
|
#include "mwindow.h" |
|
21
|
|
|
|
|
|
|
#include "object.h" |
|
22
|
|
|
|
|
|
|
#include "odb.h" |
|
23
|
|
|
|
|
|
|
#include "rand.h" |
|
24
|
|
|
|
|
|
|
#include "refs.h" |
|
25
|
|
|
|
|
|
|
#include "runtime.h" |
|
26
|
|
|
|
|
|
|
#include "sysdir.h" |
|
27
|
|
|
|
|
|
|
#include "thread.h" |
|
28
|
|
|
|
|
|
|
#include "threadstate.h" |
|
29
|
|
|
|
|
|
|
#include "git2/global.h" |
|
30
|
|
|
|
|
|
|
#include "streams/registry.h" |
|
31
|
|
|
|
|
|
|
#include "streams/mbedtls.h" |
|
32
|
|
|
|
|
|
|
#include "streams/openssl.h" |
|
33
|
|
|
|
|
|
|
#include "transports/smart.h" |
|
34
|
|
|
|
|
|
|
#include "transports/http.h" |
|
35
|
|
|
|
|
|
|
#include "transports/ssh.h" |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#ifdef GIT_WIN32 |
|
38
|
|
|
|
|
|
|
# include "win32/w32_leakcheck.h" |
|
39
|
|
|
|
|
|
|
#endif |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
/* Declarations for tuneable settings */ |
|
42
|
|
|
|
|
|
|
extern size_t git_mwindow__window_size; |
|
43
|
|
|
|
|
|
|
extern size_t git_mwindow__mapped_limit; |
|
44
|
|
|
|
|
|
|
extern size_t git_mwindow__file_limit; |
|
45
|
|
|
|
|
|
|
extern size_t git_indexer__max_objects; |
|
46
|
|
|
|
|
|
|
extern bool git_disable_pack_keep_file_checks; |
|
47
|
|
|
|
|
|
|
extern int git_odb__packed_priority; |
|
48
|
|
|
|
|
|
|
extern int git_odb__loose_priority; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
char *git__user_agent; |
|
51
|
|
|
|
|
|
|
char *git__ssl_ciphers; |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
static void libgit2_settings_global_shutdown(void) |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
0
|
|
|
|
|
|
git__free(git__user_agent); |
|
56
|
0
|
|
|
|
|
|
git__free(git__ssl_ciphers); |
|
57
|
0
|
|
|
|
|
|
git_repository__free_extensions(); |
|
58
|
0
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
87
|
|
|
|
|
|
static int git_libgit2_settings_global_init(void) |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
87
|
|
|
|
|
|
return git_runtime_shutdown_register(libgit2_settings_global_shutdown); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
87
|
|
|
|
|
|
int git_libgit2_init(void) |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
|
|
|
|
|
|
static git_runtime_init_fn init_fns[] = { |
|
68
|
|
|
|
|
|
|
#ifdef GIT_WIN32 |
|
69
|
|
|
|
|
|
|
git_win32_leakcheck_global_init, |
|
70
|
|
|
|
|
|
|
#endif |
|
71
|
|
|
|
|
|
|
git_allocator_global_init, |
|
72
|
|
|
|
|
|
|
git_threadstate_global_init, |
|
73
|
|
|
|
|
|
|
git_threads_global_init, |
|
74
|
|
|
|
|
|
|
git_rand_global_init, |
|
75
|
|
|
|
|
|
|
git_hash_global_init, |
|
76
|
|
|
|
|
|
|
git_sysdir_global_init, |
|
77
|
|
|
|
|
|
|
git_filter_global_init, |
|
78
|
|
|
|
|
|
|
git_merge_driver_global_init, |
|
79
|
|
|
|
|
|
|
git_transport_ssh_global_init, |
|
80
|
|
|
|
|
|
|
git_stream_registry_global_init, |
|
81
|
|
|
|
|
|
|
git_openssl_stream_global_init, |
|
82
|
|
|
|
|
|
|
git_mbedtls_stream_global_init, |
|
83
|
|
|
|
|
|
|
git_mwindow_global_init, |
|
84
|
|
|
|
|
|
|
git_pool_global_init, |
|
85
|
|
|
|
|
|
|
git_libgit2_settings_global_init |
|
86
|
|
|
|
|
|
|
}; |
|
87
|
|
|
|
|
|
|
|
|
88
|
87
|
|
|
|
|
|
return git_runtime_init(init_fns, ARRAY_SIZE(init_fns)); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
67
|
|
|
|
|
|
int git_libgit2_init_count(void) |
|
92
|
|
|
|
|
|
|
{ |
|
93
|
67
|
|
|
|
|
|
return git_runtime_init_count(); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
int git_libgit2_shutdown(void) |
|
97
|
|
|
|
|
|
|
{ |
|
98
|
0
|
|
|
|
|
|
return git_runtime_shutdown(); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
int git_libgit2_version(int *major, int *minor, int *rev) |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
0
|
|
|
|
|
|
*major = LIBGIT2_VER_MAJOR; |
|
104
|
0
|
|
|
|
|
|
*minor = LIBGIT2_VER_MINOR; |
|
105
|
0
|
|
|
|
|
|
*rev = LIBGIT2_VER_REVISION; |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
return 0; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
const char *git_libgit2_prerelease(void) |
|
111
|
|
|
|
|
|
|
{ |
|
112
|
0
|
|
|
|
|
|
return LIBGIT2_VER_PRERELEASE; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
1
|
|
|
|
|
|
int git_libgit2_features(void) |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
1
|
|
|
|
|
|
return 0 |
|
118
|
|
|
|
|
|
|
#ifdef GIT_THREADS |
|
119
|
|
|
|
|
|
|
| GIT_FEATURE_THREADS |
|
120
|
|
|
|
|
|
|
#endif |
|
121
|
|
|
|
|
|
|
#ifdef GIT_HTTPS |
|
122
|
|
|
|
|
|
|
| GIT_FEATURE_HTTPS |
|
123
|
|
|
|
|
|
|
#endif |
|
124
|
|
|
|
|
|
|
#if defined(GIT_SSH) |
|
125
|
|
|
|
|
|
|
| GIT_FEATURE_SSH |
|
126
|
|
|
|
|
|
|
#endif |
|
127
|
|
|
|
|
|
|
#if defined(GIT_USE_NSEC) |
|
128
|
|
|
|
|
|
|
| GIT_FEATURE_NSEC |
|
129
|
|
|
|
|
|
|
#endif |
|
130
|
|
|
|
|
|
|
; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
static int config_level_to_sysdir(int *out, int config_level) |
|
134
|
|
|
|
|
|
|
{ |
|
135
|
0
|
|
|
|
|
|
switch (config_level) { |
|
136
|
|
|
|
|
|
|
case GIT_CONFIG_LEVEL_SYSTEM: |
|
137
|
0
|
|
|
|
|
|
*out = GIT_SYSDIR_SYSTEM; |
|
138
|
0
|
|
|
|
|
|
return 0; |
|
139
|
|
|
|
|
|
|
case GIT_CONFIG_LEVEL_XDG: |
|
140
|
0
|
|
|
|
|
|
*out = GIT_SYSDIR_XDG; |
|
141
|
0
|
|
|
|
|
|
return 0; |
|
142
|
|
|
|
|
|
|
case GIT_CONFIG_LEVEL_GLOBAL: |
|
143
|
0
|
|
|
|
|
|
*out = GIT_SYSDIR_GLOBAL; |
|
144
|
0
|
|
|
|
|
|
return 0; |
|
145
|
|
|
|
|
|
|
case GIT_CONFIG_LEVEL_PROGRAMDATA: |
|
146
|
0
|
|
|
|
|
|
*out = GIT_SYSDIR_PROGRAMDATA; |
|
147
|
0
|
|
|
|
|
|
return 0; |
|
148
|
|
|
|
|
|
|
default: |
|
149
|
0
|
|
|
|
|
|
break; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
git_error_set( |
|
153
|
|
|
|
|
|
|
GIT_ERROR_INVALID, "invalid config path selector %d", config_level); |
|
154
|
0
|
|
|
|
|
|
return -1; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
const char *git_libgit2__user_agent(void) |
|
158
|
|
|
|
|
|
|
{ |
|
159
|
0
|
|
|
|
|
|
return git__user_agent; |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
const char *git_libgit2__ssl_ciphers(void) |
|
163
|
|
|
|
|
|
|
{ |
|
164
|
0
|
|
|
|
|
|
return git__ssl_ciphers; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
int git_libgit2_opts(int key, ...) |
|
168
|
|
|
|
|
|
|
{ |
|
169
|
0
|
|
|
|
|
|
int error = 0; |
|
170
|
|
|
|
|
|
|
va_list ap; |
|
171
|
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
va_start(ap, key); |
|
173
|
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
switch (key) { |
|
175
|
|
|
|
|
|
|
case GIT_OPT_SET_MWINDOW_SIZE: |
|
176
|
0
|
0
|
|
|
|
|
git_mwindow__window_size = va_arg(ap, size_t); |
|
177
|
0
|
|
|
|
|
|
break; |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
case GIT_OPT_GET_MWINDOW_SIZE: |
|
180
|
0
|
0
|
|
|
|
|
*(va_arg(ap, size_t *)) = git_mwindow__window_size; |
|
181
|
0
|
|
|
|
|
|
break; |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
case GIT_OPT_SET_MWINDOW_MAPPED_LIMIT: |
|
184
|
0
|
0
|
|
|
|
|
git_mwindow__mapped_limit = va_arg(ap, size_t); |
|
185
|
0
|
|
|
|
|
|
break; |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
case GIT_OPT_GET_MWINDOW_MAPPED_LIMIT: |
|
188
|
0
|
0
|
|
|
|
|
*(va_arg(ap, size_t *)) = git_mwindow__mapped_limit; |
|
189
|
0
|
|
|
|
|
|
break; |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
case GIT_OPT_SET_MWINDOW_FILE_LIMIT: |
|
192
|
0
|
0
|
|
|
|
|
git_mwindow__file_limit = va_arg(ap, size_t); |
|
193
|
0
|
|
|
|
|
|
break; |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
case GIT_OPT_GET_MWINDOW_FILE_LIMIT: |
|
196
|
0
|
0
|
|
|
|
|
*(va_arg(ap, size_t *)) = git_mwindow__file_limit; |
|
197
|
0
|
|
|
|
|
|
break; |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
case GIT_OPT_GET_SEARCH_PATH: |
|
200
|
|
|
|
|
|
|
{ |
|
201
|
0
|
0
|
|
|
|
|
int sysdir = va_arg(ap, int); |
|
202
|
0
|
0
|
|
|
|
|
git_buf *out = va_arg(ap, git_buf *); |
|
203
|
0
|
|
|
|
|
|
git_str str = GIT_STR_INIT; |
|
204
|
|
|
|
|
|
|
const git_str *tmp; |
|
205
|
|
|
|
|
|
|
int level; |
|
206
|
|
|
|
|
|
|
|
|
207
|
0
|
0
|
|
|
|
|
if ((error = git_buf_tostr(&str, out)) < 0 || |
|
|
|
0
|
|
|
|
|
|
|
208
|
0
|
0
|
|
|
|
|
(error = config_level_to_sysdir(&level, sysdir)) < 0 || |
|
209
|
0
|
0
|
|
|
|
|
(error = git_sysdir_get(&tmp, level)) < 0 || |
|
210
|
0
|
|
|
|
|
|
(error = git_str_put(&str, tmp->ptr, tmp->size)) < 0) |
|
211
|
|
|
|
|
|
|
break; |
|
212
|
|
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
error = git_buf_fromstr(out, &str); |
|
214
|
|
|
|
|
|
|
} |
|
215
|
0
|
|
|
|
|
|
break; |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
case GIT_OPT_SET_SEARCH_PATH: |
|
218
|
|
|
|
|
|
|
{ |
|
219
|
|
|
|
|
|
|
int level; |
|
220
|
|
|
|
|
|
|
|
|
221
|
0
|
0
|
|
|
|
|
if ((error = config_level_to_sysdir(&level, va_arg(ap, int))) >= 0) |
|
|
|
0
|
|
|
|
|
|
|
222
|
0
|
0
|
|
|
|
|
error = git_sysdir_set(level, va_arg(ap, const char *)); |
|
223
|
|
|
|
|
|
|
} |
|
224
|
0
|
|
|
|
|
|
break; |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
case GIT_OPT_SET_CACHE_OBJECT_LIMIT: |
|
227
|
|
|
|
|
|
|
{ |
|
228
|
0
|
0
|
|
|
|
|
git_object_t type = (git_object_t)va_arg(ap, int); |
|
229
|
0
|
0
|
|
|
|
|
size_t size = va_arg(ap, size_t); |
|
230
|
0
|
|
|
|
|
|
error = git_cache_set_max_object_size(type, size); |
|
231
|
0
|
|
|
|
|
|
break; |
|
232
|
|
|
|
|
|
|
} |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
case GIT_OPT_SET_CACHE_MAX_SIZE: |
|
235
|
0
|
0
|
|
|
|
|
git_cache__max_storage = va_arg(ap, ssize_t); |
|
236
|
0
|
|
|
|
|
|
break; |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
case GIT_OPT_ENABLE_CACHING: |
|
239
|
0
|
0
|
|
|
|
|
git_cache__enabled = (va_arg(ap, int) != 0); |
|
240
|
0
|
|
|
|
|
|
break; |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
case GIT_OPT_GET_CACHED_MEMORY: |
|
243
|
0
|
0
|
|
|
|
|
*(va_arg(ap, ssize_t *)) = git_cache__current_storage.val; |
|
244
|
0
|
0
|
|
|
|
|
*(va_arg(ap, ssize_t *)) = git_cache__max_storage; |
|
245
|
0
|
|
|
|
|
|
break; |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
case GIT_OPT_GET_TEMPLATE_PATH: |
|
248
|
|
|
|
|
|
|
{ |
|
249
|
0
|
0
|
|
|
|
|
git_buf *out = va_arg(ap, git_buf *); |
|
250
|
0
|
|
|
|
|
|
git_str str = GIT_STR_INIT; |
|
251
|
|
|
|
|
|
|
const git_str *tmp; |
|
252
|
|
|
|
|
|
|
|
|
253
|
0
|
0
|
|
|
|
|
if ((error = git_buf_tostr(&str, out)) < 0 || |
|
|
|
0
|
|
|
|
|
|
|
254
|
0
|
0
|
|
|
|
|
(error = git_sysdir_get(&tmp, GIT_SYSDIR_TEMPLATE)) < 0 || |
|
255
|
0
|
|
|
|
|
|
(error = git_str_put(&str, tmp->ptr, tmp->size)) < 0) |
|
256
|
|
|
|
|
|
|
break; |
|
257
|
|
|
|
|
|
|
|
|
258
|
0
|
|
|
|
|
|
error = git_buf_fromstr(out, &str); |
|
259
|
|
|
|
|
|
|
} |
|
260
|
0
|
|
|
|
|
|
break; |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
case GIT_OPT_SET_TEMPLATE_PATH: |
|
263
|
0
|
0
|
|
|
|
|
error = git_sysdir_set(GIT_SYSDIR_TEMPLATE, va_arg(ap, const char *)); |
|
264
|
0
|
|
|
|
|
|
break; |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
case GIT_OPT_SET_SSL_CERT_LOCATIONS: |
|
267
|
|
|
|
|
|
|
#ifdef GIT_OPENSSL |
|
268
|
|
|
|
|
|
|
{ |
|
269
|
0
|
0
|
|
|
|
|
const char *file = va_arg(ap, const char *); |
|
270
|
0
|
0
|
|
|
|
|
const char *path = va_arg(ap, const char *); |
|
271
|
0
|
|
|
|
|
|
error = git_openssl__set_cert_location(file, path); |
|
272
|
|
|
|
|
|
|
} |
|
273
|
|
|
|
|
|
|
#elif defined(GIT_MBEDTLS) |
|
274
|
|
|
|
|
|
|
{ |
|
275
|
|
|
|
|
|
|
const char *file = va_arg(ap, const char *); |
|
276
|
|
|
|
|
|
|
const char *path = va_arg(ap, const char *); |
|
277
|
|
|
|
|
|
|
error = git_mbedtls__set_cert_location(file, path); |
|
278
|
|
|
|
|
|
|
} |
|
279
|
|
|
|
|
|
|
#else |
|
280
|
|
|
|
|
|
|
git_error_set(GIT_ERROR_SSL, "TLS backend doesn't support certificate locations"); |
|
281
|
|
|
|
|
|
|
error = -1; |
|
282
|
|
|
|
|
|
|
#endif |
|
283
|
0
|
|
|
|
|
|
break; |
|
284
|
|
|
|
|
|
|
case GIT_OPT_SET_USER_AGENT: |
|
285
|
0
|
|
|
|
|
|
git__free(git__user_agent); |
|
286
|
0
|
0
|
|
|
|
|
git__user_agent = git__strdup(va_arg(ap, const char *)); |
|
287
|
0
|
0
|
|
|
|
|
if (!git__user_agent) { |
|
288
|
0
|
|
|
|
|
|
git_error_set_oom(); |
|
289
|
0
|
|
|
|
|
|
error = -1; |
|
290
|
|
|
|
|
|
|
} |
|
291
|
|
|
|
|
|
|
|
|
292
|
0
|
|
|
|
|
|
break; |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
case GIT_OPT_ENABLE_STRICT_OBJECT_CREATION: |
|
295
|
0
|
0
|
|
|
|
|
git_object__strict_input_validation = (va_arg(ap, int) != 0); |
|
296
|
0
|
|
|
|
|
|
break; |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
case GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION: |
|
299
|
0
|
0
|
|
|
|
|
git_reference__enable_symbolic_ref_target_validation = (va_arg(ap, int) != 0); |
|
300
|
0
|
|
|
|
|
|
break; |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
case GIT_OPT_SET_SSL_CIPHERS: |
|
303
|
|
|
|
|
|
|
#if (GIT_OPENSSL || GIT_MBEDTLS) |
|
304
|
|
|
|
|
|
|
{ |
|
305
|
0
|
|
|
|
|
|
git__free(git__ssl_ciphers); |
|
306
|
0
|
0
|
|
|
|
|
git__ssl_ciphers = git__strdup(va_arg(ap, const char *)); |
|
307
|
0
|
0
|
|
|
|
|
if (!git__ssl_ciphers) { |
|
308
|
0
|
|
|
|
|
|
git_error_set_oom(); |
|
309
|
0
|
|
|
|
|
|
error = -1; |
|
310
|
|
|
|
|
|
|
} |
|
311
|
|
|
|
|
|
|
} |
|
312
|
|
|
|
|
|
|
#else |
|
313
|
|
|
|
|
|
|
git_error_set(GIT_ERROR_SSL, "TLS backend doesn't support custom ciphers"); |
|
314
|
|
|
|
|
|
|
error = -1; |
|
315
|
|
|
|
|
|
|
#endif |
|
316
|
0
|
|
|
|
|
|
break; |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
case GIT_OPT_GET_USER_AGENT: |
|
319
|
|
|
|
|
|
|
{ |
|
320
|
0
|
0
|
|
|
|
|
git_buf *out = va_arg(ap, git_buf *); |
|
321
|
0
|
|
|
|
|
|
git_str str = GIT_STR_INIT; |
|
322
|
|
|
|
|
|
|
|
|
323
|
0
|
0
|
|
|
|
|
if ((error = git_buf_tostr(&str, out)) < 0 || |
|
|
|
0
|
|
|
|
|
|
|
324
|
0
|
|
|
|
|
|
(error = git_str_puts(&str, git__user_agent)) < 0) |
|
325
|
|
|
|
|
|
|
break; |
|
326
|
|
|
|
|
|
|
|
|
327
|
0
|
|
|
|
|
|
error = git_buf_fromstr(out, &str); |
|
328
|
|
|
|
|
|
|
} |
|
329
|
0
|
|
|
|
|
|
break; |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
case GIT_OPT_ENABLE_OFS_DELTA: |
|
332
|
0
|
0
|
|
|
|
|
git_smart__ofs_delta_enabled = (va_arg(ap, int) != 0); |
|
333
|
0
|
|
|
|
|
|
break; |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
case GIT_OPT_ENABLE_FSYNC_GITDIR: |
|
336
|
0
|
0
|
|
|
|
|
git_repository__fsync_gitdir = (va_arg(ap, int) != 0); |
|
337
|
0
|
|
|
|
|
|
break; |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
case GIT_OPT_GET_WINDOWS_SHAREMODE: |
|
340
|
|
|
|
|
|
|
#ifdef GIT_WIN32 |
|
341
|
|
|
|
|
|
|
*(va_arg(ap, unsigned long *)) = git_win32__createfile_sharemode; |
|
342
|
|
|
|
|
|
|
#endif |
|
343
|
0
|
|
|
|
|
|
break; |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
case GIT_OPT_SET_WINDOWS_SHAREMODE: |
|
346
|
|
|
|
|
|
|
#ifdef GIT_WIN32 |
|
347
|
|
|
|
|
|
|
git_win32__createfile_sharemode = va_arg(ap, unsigned long); |
|
348
|
|
|
|
|
|
|
#endif |
|
349
|
0
|
|
|
|
|
|
break; |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
case GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION: |
|
352
|
0
|
0
|
|
|
|
|
git_odb__strict_hash_verification = (va_arg(ap, int) != 0); |
|
353
|
0
|
|
|
|
|
|
break; |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
case GIT_OPT_SET_ALLOCATOR: |
|
356
|
0
|
0
|
|
|
|
|
error = git_allocator_setup(va_arg(ap, git_allocator *)); |
|
357
|
0
|
|
|
|
|
|
break; |
|
358
|
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
case GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY: |
|
360
|
0
|
0
|
|
|
|
|
git_index__enforce_unsaved_safety = (va_arg(ap, int) != 0); |
|
361
|
0
|
|
|
|
|
|
break; |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
case GIT_OPT_SET_PACK_MAX_OBJECTS: |
|
364
|
0
|
0
|
|
|
|
|
git_indexer__max_objects = va_arg(ap, size_t); |
|
365
|
0
|
|
|
|
|
|
break; |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
case GIT_OPT_GET_PACK_MAX_OBJECTS: |
|
368
|
0
|
0
|
|
|
|
|
*(va_arg(ap, size_t *)) = git_indexer__max_objects; |
|
369
|
0
|
|
|
|
|
|
break; |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
case GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS: |
|
372
|
0
|
0
|
|
|
|
|
git_disable_pack_keep_file_checks = (va_arg(ap, int) != 0); |
|
373
|
0
|
|
|
|
|
|
break; |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
case GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE: |
|
376
|
0
|
0
|
|
|
|
|
git_http__expect_continue = (va_arg(ap, int) != 0); |
|
377
|
0
|
|
|
|
|
|
break; |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
case GIT_OPT_SET_ODB_PACKED_PRIORITY: |
|
380
|
0
|
0
|
|
|
|
|
git_odb__packed_priority = va_arg(ap, int); |
|
381
|
0
|
|
|
|
|
|
break; |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
case GIT_OPT_SET_ODB_LOOSE_PRIORITY: |
|
384
|
0
|
0
|
|
|
|
|
git_odb__loose_priority = va_arg(ap, int); |
|
385
|
0
|
|
|
|
|
|
break; |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
case GIT_OPT_SET_EXTENSIONS: |
|
388
|
|
|
|
|
|
|
{ |
|
389
|
0
|
0
|
|
|
|
|
const char **extensions = va_arg(ap, const char **); |
|
390
|
0
|
0
|
|
|
|
|
size_t len = va_arg(ap, size_t); |
|
391
|
0
|
|
|
|
|
|
error = git_repository__set_extensions(extensions, len); |
|
392
|
|
|
|
|
|
|
} |
|
393
|
0
|
|
|
|
|
|
break; |
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
case GIT_OPT_GET_EXTENSIONS: |
|
396
|
|
|
|
|
|
|
{ |
|
397
|
0
|
0
|
|
|
|
|
git_strarray *out = va_arg(ap, git_strarray *); |
|
398
|
|
|
|
|
|
|
char **extensions; |
|
399
|
|
|
|
|
|
|
size_t len; |
|
400
|
|
|
|
|
|
|
|
|
401
|
0
|
0
|
|
|
|
|
if ((error = git_repository__extensions(&extensions, &len)) < 0) |
|
402
|
0
|
|
|
|
|
|
break; |
|
403
|
|
|
|
|
|
|
|
|
404
|
0
|
|
|
|
|
|
out->strings = extensions; |
|
405
|
0
|
|
|
|
|
|
out->count = len; |
|
406
|
|
|
|
|
|
|
} |
|
407
|
0
|
|
|
|
|
|
break; |
|
408
|
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
case GIT_OPT_GET_OWNER_VALIDATION: |
|
410
|
0
|
0
|
|
|
|
|
*(va_arg(ap, int *)) = git_repository__validate_ownership; |
|
411
|
0
|
|
|
|
|
|
break; |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
case GIT_OPT_SET_OWNER_VALIDATION: |
|
414
|
0
|
0
|
|
|
|
|
git_repository__validate_ownership = (va_arg(ap, int) != 0); |
|
415
|
0
|
|
|
|
|
|
break; |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
default: |
|
418
|
0
|
|
|
|
|
|
git_error_set(GIT_ERROR_INVALID, "invalid option key"); |
|
419
|
0
|
|
|
|
|
|
error = -1; |
|
420
|
|
|
|
|
|
|
} |
|
421
|
|
|
|
|
|
|
|
|
422
|
0
|
|
|
|
|
|
va_end(ap); |
|
423
|
|
|
|
|
|
|
|
|
424
|
0
|
|
|
|
|
|
return error; |
|
425
|
|
|
|
|
|
|
} |