rugged 0.24.0b13 → 0.24.0b14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/rugged/rugged_commit.c +6 -6
- data/ext/rugged/rugged_revwalk.c +7 -3
- data/ext/rugged/rugged_settings.c +5 -0
- data/lib/rugged/tag.rb +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +21 -8
- data/vendor/libgit2/include/git2/commit.h +6 -0
- data/vendor/libgit2/include/git2/common.h +15 -0
- data/vendor/libgit2/include/git2/errors.h +0 -5
- data/vendor/libgit2/include/git2/rebase.h +1 -1
- data/vendor/libgit2/include/git2/sys/filter.h +34 -25
- data/vendor/libgit2/include/git2/sys/index.h +1 -1
- data/vendor/libgit2/src/checkout.c +1 -1
- data/vendor/libgit2/src/commit.c +44 -12
- data/vendor/libgit2/src/common.h +11 -0
- data/vendor/libgit2/src/crlf.c +1 -1
- data/vendor/libgit2/src/diff_print.c +5 -1
- data/vendor/libgit2/src/diff_tform.c +16 -11
- data/vendor/libgit2/src/fileops.c +8 -15
- data/vendor/libgit2/src/filter.c +155 -124
- data/vendor/libgit2/src/filter.h +2 -0
- data/vendor/libgit2/src/global.c +56 -162
- data/vendor/libgit2/src/index.c +68 -30
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/iterator.c +9 -3
- data/vendor/libgit2/src/netops.c +4 -0
- data/vendor/libgit2/src/object.c +26 -0
- data/vendor/libgit2/src/object.h +23 -0
- data/vendor/libgit2/src/openssl_stream.c +135 -3
- data/vendor/libgit2/src/openssl_stream.h +2 -0
- data/vendor/libgit2/src/pack-objects.c +6 -6
- data/vendor/libgit2/src/pack.c +18 -1
- data/vendor/libgit2/src/path.c +7 -3
- data/vendor/libgit2/src/path.h +14 -4
- data/vendor/libgit2/src/pool.c +78 -30
- data/vendor/libgit2/src/pool.h +28 -0
- data/vendor/libgit2/src/posix.c +5 -2
- data/vendor/libgit2/src/rebase.c +12 -10
- data/vendor/libgit2/src/refdb_fs.c +3 -4
- data/vendor/libgit2/src/refs.c +1 -7
- data/vendor/libgit2/src/refspec.c +4 -4
- data/vendor/libgit2/src/remote.c +2 -2
- data/vendor/libgit2/src/revwalk.c +1 -2
- data/vendor/libgit2/src/settings.c +9 -0
- data/vendor/libgit2/src/signature.c +2 -3
- data/vendor/libgit2/src/submodule.c +2 -2
- data/vendor/libgit2/src/thread-utils.h +1 -1
- data/vendor/libgit2/src/transports/smart_pkt.c +15 -9
- data/vendor/libgit2/src/transports/smart_protocol.c +2 -0
- data/vendor/libgit2/src/transports/winhttp.c +1 -1
- data/vendor/libgit2/src/tree.c +31 -10
- data/vendor/libgit2/src/unix/map.c +1 -1
- data/vendor/libgit2/src/unix/posix.h +15 -1
- data/vendor/libgit2/src/win32/posix.h +6 -4
- data/vendor/libgit2/src/win32/posix_w32.c +18 -2
- data/vendor/libgit2/src/win32/utf-conv.c +3 -18
- data/vendor/libgit2/src/win32/w32_util.h +44 -11
- data/vendor/libgit2/src/win32/win32-compat.h +10 -0
- data/vendor/libgit2/src/xdiff/xmerge.c +2 -0
- metadata +416 -405
- checksums.yaml +0 -7
data/vendor/libgit2/src/common.h
CHANGED
@@ -62,6 +62,12 @@
|
|
62
62
|
# endif
|
63
63
|
#define GIT_STDLIB_CALL
|
64
64
|
|
65
|
+
#ifdef GIT_USE_STAT_ATIMESPEC
|
66
|
+
# define st_atim st_atimespec
|
67
|
+
# define st_ctim st_ctimespec
|
68
|
+
# define st_mtim st_mtimespec
|
69
|
+
#endif
|
70
|
+
|
65
71
|
# include <arpa/inet.h>
|
66
72
|
|
67
73
|
#endif
|
@@ -83,6 +89,11 @@
|
|
83
89
|
*/
|
84
90
|
#define GITERR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; }
|
85
91
|
|
92
|
+
/**
|
93
|
+
* Check a buffer allocation result, returning -1 if it failed.
|
94
|
+
*/
|
95
|
+
#define GITERR_CHECK_ALLOC_BUF(buf) if ((void *)(buf) == NULL || git_buf_oom(buf)) { return -1; }
|
96
|
+
|
86
97
|
/**
|
87
98
|
* Check a return value and propagate result if non-zero.
|
88
99
|
*/
|
data/vendor/libgit2/src/crlf.c
CHANGED
@@ -92,7 +92,11 @@ static int diff_print_info_init_frompatch(
|
|
92
92
|
git_diff_line_cb cb,
|
93
93
|
void *payload)
|
94
94
|
{
|
95
|
-
git_repository *repo
|
95
|
+
git_repository *repo;
|
96
|
+
|
97
|
+
assert(patch);
|
98
|
+
|
99
|
+
repo = patch->diff ? patch->diff->repo : NULL;
|
96
100
|
|
97
101
|
memset(pi, 0, sizeof(diff_print_info));
|
98
102
|
|
@@ -261,18 +261,23 @@ static int normalize_find_opts(
|
|
261
261
|
if (!given ||
|
262
262
|
(given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG)
|
263
263
|
{
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
264
|
+
if (diff->repo) {
|
265
|
+
char *rule =
|
266
|
+
git_config__get_string_force(cfg, "diff.renames", "true");
|
267
|
+
int boolval;
|
268
|
+
|
269
|
+
if (!git__parse_bool(&boolval, rule) && !boolval)
|
270
|
+
/* don't set FIND_RENAMES if bool value is false */;
|
271
|
+
else if (!strcasecmp(rule, "copies") || !strcasecmp(rule, "copy"))
|
272
|
+
opts->flags |= GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES;
|
273
|
+
else
|
274
|
+
opts->flags |= GIT_DIFF_FIND_RENAMES;
|
274
275
|
|
275
|
-
|
276
|
+
git__free(rule);
|
277
|
+
} else {
|
278
|
+
/* set default flag */
|
279
|
+
opts->flags |= GIT_DIFF_FIND_RENAMES;
|
280
|
+
}
|
276
281
|
}
|
277
282
|
|
278
283
|
/* some flags imply others */
|
@@ -13,12 +13,6 @@
|
|
13
13
|
#include "win32/findfile.h"
|
14
14
|
#endif
|
15
15
|
|
16
|
-
#ifdef GIT_USE_STAT_ATIMESPEC
|
17
|
-
#define st_atim st_atimespec
|
18
|
-
#define st_ctim st_ctimespec
|
19
|
-
#define st_mtim st_mtimespec
|
20
|
-
#endif
|
21
|
-
|
22
16
|
GIT__USE_STRMAP
|
23
17
|
|
24
18
|
int git_futils_mkpath2file(const char *file_path, const mode_t mode)
|
@@ -1040,7 +1034,6 @@ int git_futils_filestamp_check(
|
|
1040
1034
|
git_futils_filestamp *stamp, const char *path)
|
1041
1035
|
{
|
1042
1036
|
struct stat st;
|
1043
|
-
const struct timespec *statmtime = &st.st_mtim;
|
1044
1037
|
|
1045
1038
|
/* if the stamp is NULL, then always reload */
|
1046
1039
|
if (stamp == NULL)
|
@@ -1049,17 +1042,17 @@ int git_futils_filestamp_check(
|
|
1049
1042
|
if (p_stat(path, &st) < 0)
|
1050
1043
|
return GIT_ENOTFOUND;
|
1051
1044
|
|
1052
|
-
if (stamp->mtime.tv_sec ==
|
1045
|
+
if (stamp->mtime.tv_sec == st.st_mtime &&
|
1053
1046
|
#if defined(GIT_USE_NSEC)
|
1054
|
-
stamp->mtime.tv_nsec ==
|
1047
|
+
stamp->mtime.tv_nsec == st.st_mtime_nsec &&
|
1055
1048
|
#endif
|
1056
1049
|
stamp->size == (git_off_t)st.st_size &&
|
1057
1050
|
stamp->ino == (unsigned int)st.st_ino)
|
1058
1051
|
return 0;
|
1059
1052
|
|
1060
|
-
stamp->mtime.tv_sec =
|
1053
|
+
stamp->mtime.tv_sec = st.st_mtime;
|
1061
1054
|
#if defined(GIT_USE_NSEC)
|
1062
|
-
stamp->mtime.tv_nsec =
|
1055
|
+
stamp->mtime.tv_nsec = st.st_mtime_nsec;
|
1063
1056
|
#endif
|
1064
1057
|
stamp->size = (git_off_t)st.st_size;
|
1065
1058
|
stamp->ino = (unsigned int)st.st_ino;
|
@@ -1082,11 +1075,11 @@ void git_futils_filestamp_set(
|
|
1082
1075
|
void git_futils_filestamp_set_from_stat(
|
1083
1076
|
git_futils_filestamp *stamp, struct stat *st)
|
1084
1077
|
{
|
1085
|
-
const struct timespec *statmtime = &st->st_mtim;
|
1086
|
-
|
1087
1078
|
if (st) {
|
1088
|
-
stamp->mtime =
|
1089
|
-
#if
|
1079
|
+
stamp->mtime.tv_sec = st->st_mtime;
|
1080
|
+
#if defined(GIT_USE_NSEC)
|
1081
|
+
stamp->mtime.tv_nsec = st->st_mtime_nsec;
|
1082
|
+
#else
|
1090
1083
|
stamp->mtime.tv_nsec = 0;
|
1091
1084
|
#endif
|
1092
1085
|
stamp->size = (git_off_t)st->st_size;
|
data/vendor/libgit2/src/filter.c
CHANGED
@@ -56,80 +56,15 @@ static int filter_def_priority_cmp(const void *a, const void *b)
|
|
56
56
|
return (pa < pb) ? -1 : (pa > pb) ? 1 : 0;
|
57
57
|
}
|
58
58
|
|
59
|
-
struct
|
59
|
+
struct git_filter_registry {
|
60
|
+
git_rwlock lock;
|
60
61
|
git_vector filters;
|
61
62
|
};
|
62
63
|
|
63
|
-
static struct filter_registry
|
64
|
+
static struct git_filter_registry filter_registry;
|
64
65
|
|
65
|
-
static void
|
66
|
-
{
|
67
|
-
struct filter_registry *reg = NULL;
|
68
|
-
size_t pos;
|
69
|
-
git_filter_def *fdef;
|
70
|
-
|
71
|
-
if ((reg = git__swap(git__filter_registry, NULL)) == NULL)
|
72
|
-
return;
|
73
|
-
|
74
|
-
git_vector_foreach(®->filters, pos, fdef) {
|
75
|
-
if (fdef->filter && fdef->filter->shutdown) {
|
76
|
-
fdef->filter->shutdown(fdef->filter);
|
77
|
-
fdef->initialized = false;
|
78
|
-
}
|
79
|
-
|
80
|
-
git__free(fdef->filter_name);
|
81
|
-
git__free(fdef->attrdata);
|
82
|
-
git__free(fdef);
|
83
|
-
}
|
84
|
-
|
85
|
-
git_vector_free(®->filters);
|
86
|
-
git__free(reg);
|
87
|
-
}
|
88
|
-
|
89
|
-
static int filter_registry_initialize(void)
|
90
|
-
{
|
91
|
-
int error = 0;
|
92
|
-
struct filter_registry *reg;
|
93
|
-
|
94
|
-
if (git__filter_registry)
|
95
|
-
return 0;
|
96
|
-
|
97
|
-
reg = git__calloc(1, sizeof(struct filter_registry));
|
98
|
-
GITERR_CHECK_ALLOC(reg);
|
99
|
-
|
100
|
-
if ((error = git_vector_init(
|
101
|
-
®->filters, 2, filter_def_priority_cmp)) < 0)
|
102
|
-
goto cleanup;
|
66
|
+
static void git_filter_global_shutdown(void);
|
103
67
|
|
104
|
-
reg = git__compare_and_swap(&git__filter_registry, NULL, reg);
|
105
|
-
if (reg != NULL)
|
106
|
-
goto cleanup;
|
107
|
-
|
108
|
-
git__on_shutdown(filter_registry_shutdown);
|
109
|
-
|
110
|
-
/* try to register both default filters */
|
111
|
-
{
|
112
|
-
git_filter *crlf = git_crlf_filter_new();
|
113
|
-
git_filter *ident = git_ident_filter_new();
|
114
|
-
|
115
|
-
if (crlf && git_filter_register(
|
116
|
-
GIT_FILTER_CRLF, crlf, GIT_FILTER_CRLF_PRIORITY) < 0)
|
117
|
-
crlf = NULL;
|
118
|
-
if (ident && git_filter_register(
|
119
|
-
GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0)
|
120
|
-
ident = NULL;
|
121
|
-
|
122
|
-
if (!crlf || !ident)
|
123
|
-
return -1;
|
124
|
-
}
|
125
|
-
|
126
|
-
return 0;
|
127
|
-
|
128
|
-
cleanup:
|
129
|
-
git_vector_free(®->filters);
|
130
|
-
git__free(reg);
|
131
|
-
return error;
|
132
|
-
}
|
133
68
|
|
134
69
|
static int filter_def_scan_attrs(
|
135
70
|
git_buf *attrs, size_t *nattr, size_t *nmatch, const char *attr_str)
|
@@ -210,40 +145,14 @@ static int filter_def_filter_key_check(const void *key, const void *fdef)
|
|
210
145
|
return (key == filter) ? 0 : -1;
|
211
146
|
}
|
212
147
|
|
213
|
-
|
214
|
-
|
215
|
-
return git_vector_search2(
|
216
|
-
pos, &git__filter_registry->filters, filter_def_name_key_check, name);
|
217
|
-
}
|
218
|
-
|
219
|
-
static git_filter_def *filter_registry_lookup(size_t *pos, const char *name)
|
220
|
-
{
|
221
|
-
git_filter_def *fdef = NULL;
|
222
|
-
|
223
|
-
if (!filter_registry_find(pos, name))
|
224
|
-
fdef = git_vector_get(&git__filter_registry->filters, *pos);
|
225
|
-
|
226
|
-
return fdef;
|
227
|
-
}
|
228
|
-
|
229
|
-
int git_filter_register(
|
148
|
+
/* Note: callers must lock the registry before calling this function */
|
149
|
+
static int filter_registry_insert(
|
230
150
|
const char *name, git_filter *filter, int priority)
|
231
151
|
{
|
232
152
|
git_filter_def *fdef;
|
233
153
|
size_t nattr = 0, nmatch = 0, alloc_len;
|
234
154
|
git_buf attrs = GIT_BUF_INIT;
|
235
155
|
|
236
|
-
assert(name && filter);
|
237
|
-
|
238
|
-
if (filter_registry_initialize() < 0)
|
239
|
-
return -1;
|
240
|
-
|
241
|
-
if (!filter_registry_find(NULL, name)) {
|
242
|
-
giterr_set(
|
243
|
-
GITERR_FILTER, "Attempt to reregister existing filter '%s'", name);
|
244
|
-
return GIT_EEXISTS;
|
245
|
-
}
|
246
|
-
|
247
156
|
if (filter_def_scan_attrs(&attrs, &nattr, &nmatch, filter->attributes) < 0)
|
248
157
|
return -1;
|
249
158
|
|
@@ -265,21 +174,123 @@ int git_filter_register(
|
|
265
174
|
|
266
175
|
filter_def_set_attrs(fdef);
|
267
176
|
|
268
|
-
if (git_vector_insert(&
|
177
|
+
if (git_vector_insert(&filter_registry.filters, fdef) < 0) {
|
269
178
|
git__free(fdef->filter_name);
|
270
179
|
git__free(fdef->attrdata);
|
271
180
|
git__free(fdef);
|
272
181
|
return -1;
|
273
182
|
}
|
274
183
|
|
275
|
-
git_vector_sort(&
|
184
|
+
git_vector_sort(&filter_registry.filters);
|
276
185
|
return 0;
|
277
186
|
}
|
278
187
|
|
188
|
+
int git_filter_global_init(void)
|
189
|
+
{
|
190
|
+
git_filter *crlf = NULL, *ident = NULL;
|
191
|
+
int error = 0;
|
192
|
+
|
193
|
+
if (git_rwlock_init(&filter_registry.lock) < 0)
|
194
|
+
return -1;
|
195
|
+
|
196
|
+
if ((error = git_vector_init(&filter_registry.filters, 2,
|
197
|
+
filter_def_priority_cmp)) < 0)
|
198
|
+
goto done;
|
199
|
+
|
200
|
+
if ((crlf = git_crlf_filter_new()) == NULL ||
|
201
|
+
filter_registry_insert(
|
202
|
+
GIT_FILTER_CRLF, crlf, GIT_FILTER_CRLF_PRIORITY) < 0 ||
|
203
|
+
(ident = git_ident_filter_new()) == NULL ||
|
204
|
+
filter_registry_insert(
|
205
|
+
GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0)
|
206
|
+
error = -1;
|
207
|
+
|
208
|
+
git__on_shutdown(git_filter_global_shutdown);
|
209
|
+
|
210
|
+
done:
|
211
|
+
if (error) {
|
212
|
+
git_filter_free(crlf);
|
213
|
+
git_filter_free(ident);
|
214
|
+
}
|
215
|
+
|
216
|
+
return error;
|
217
|
+
}
|
218
|
+
|
219
|
+
static void git_filter_global_shutdown(void)
|
220
|
+
{
|
221
|
+
size_t pos;
|
222
|
+
git_filter_def *fdef;
|
223
|
+
|
224
|
+
if (git_rwlock_wrlock(&filter_registry.lock) < 0)
|
225
|
+
return;
|
226
|
+
|
227
|
+
git_vector_foreach(&filter_registry.filters, pos, fdef) {
|
228
|
+
if (fdef->filter && fdef->filter->shutdown) {
|
229
|
+
fdef->filter->shutdown(fdef->filter);
|
230
|
+
fdef->initialized = false;
|
231
|
+
}
|
232
|
+
|
233
|
+
git__free(fdef->filter_name);
|
234
|
+
git__free(fdef->attrdata);
|
235
|
+
git__free(fdef);
|
236
|
+
}
|
237
|
+
|
238
|
+
git_vector_free(&filter_registry.filters);
|
239
|
+
|
240
|
+
git_rwlock_wrunlock(&filter_registry.lock);
|
241
|
+
git_rwlock_free(&filter_registry.lock);
|
242
|
+
}
|
243
|
+
|
244
|
+
/* Note: callers must lock the registry before calling this function */
|
245
|
+
static int filter_registry_find(size_t *pos, const char *name)
|
246
|
+
{
|
247
|
+
return git_vector_search2(
|
248
|
+
pos, &filter_registry.filters, filter_def_name_key_check, name);
|
249
|
+
}
|
250
|
+
|
251
|
+
/* Note: callers must lock the registry before calling this function */
|
252
|
+
static git_filter_def *filter_registry_lookup(size_t *pos, const char *name)
|
253
|
+
{
|
254
|
+
git_filter_def *fdef = NULL;
|
255
|
+
|
256
|
+
if (!filter_registry_find(pos, name))
|
257
|
+
fdef = git_vector_get(&filter_registry.filters, *pos);
|
258
|
+
|
259
|
+
return fdef;
|
260
|
+
}
|
261
|
+
|
262
|
+
|
263
|
+
int git_filter_register(
|
264
|
+
const char *name, git_filter *filter, int priority)
|
265
|
+
{
|
266
|
+
int error;
|
267
|
+
|
268
|
+
assert(name && filter);
|
269
|
+
|
270
|
+
if (git_rwlock_wrlock(&filter_registry.lock) < 0) {
|
271
|
+
giterr_set(GITERR_OS, "failed to lock filter registry");
|
272
|
+
return -1;
|
273
|
+
}
|
274
|
+
|
275
|
+
if (!filter_registry_find(NULL, name)) {
|
276
|
+
giterr_set(
|
277
|
+
GITERR_FILTER, "attempt to reregister existing filter '%s'", name);
|
278
|
+
error = GIT_EEXISTS;
|
279
|
+
goto done;
|
280
|
+
}
|
281
|
+
|
282
|
+
error = filter_registry_insert(name, filter, priority);
|
283
|
+
|
284
|
+
done:
|
285
|
+
git_rwlock_wrunlock(&filter_registry.lock);
|
286
|
+
return error;
|
287
|
+
}
|
288
|
+
|
279
289
|
int git_filter_unregister(const char *name)
|
280
290
|
{
|
281
291
|
size_t pos;
|
282
292
|
git_filter_def *fdef;
|
293
|
+
int error = 0;
|
283
294
|
|
284
295
|
assert(name);
|
285
296
|
|
@@ -289,12 +300,18 @@ int git_filter_unregister(const char *name)
|
|
289
300
|
return -1;
|
290
301
|
}
|
291
302
|
|
303
|
+
if (git_rwlock_wrlock(&filter_registry.lock) < 0) {
|
304
|
+
giterr_set(GITERR_OS, "failed to lock filter registry");
|
305
|
+
return -1;
|
306
|
+
}
|
307
|
+
|
292
308
|
if ((fdef = filter_registry_lookup(&pos, name)) == NULL) {
|
293
309
|
giterr_set(GITERR_FILTER, "Cannot find filter '%s' to unregister", name);
|
294
|
-
|
310
|
+
error = GIT_ENOTFOUND;
|
311
|
+
goto done;
|
295
312
|
}
|
296
313
|
|
297
|
-
|
314
|
+
git_vector_remove(&filter_registry.filters, pos);
|
298
315
|
|
299
316
|
if (fdef->initialized && fdef->filter && fdef->filter->shutdown) {
|
300
317
|
fdef->filter->shutdown(fdef->filter);
|
@@ -305,21 +322,18 @@ int git_filter_unregister(const char *name)
|
|
305
322
|
git__free(fdef->attrdata);
|
306
323
|
git__free(fdef);
|
307
324
|
|
308
|
-
|
325
|
+
done:
|
326
|
+
git_rwlock_wrunlock(&filter_registry.lock);
|
327
|
+
return error;
|
309
328
|
}
|
310
329
|
|
311
330
|
static int filter_initialize(git_filter_def *fdef)
|
312
331
|
{
|
313
332
|
int error = 0;
|
314
333
|
|
315
|
-
if (!fdef->initialized &&
|
316
|
-
fdef->filter
|
317
|
-
|
318
|
-
(error = fdef->filter->initialize(fdef->filter)) < 0)
|
319
|
-
{
|
320
|
-
/* auto-unregister if initialize fails */
|
321
|
-
git_filter_unregister(fdef->filter_name);
|
322
|
-
return error;
|
334
|
+
if (!fdef->initialized && fdef->filter && fdef->filter->initialize) {
|
335
|
+
if ((error = fdef->filter->initialize(fdef->filter)) < 0)
|
336
|
+
return error;
|
323
337
|
}
|
324
338
|
|
325
339
|
fdef->initialized = true;
|
@@ -330,17 +344,22 @@ git_filter *git_filter_lookup(const char *name)
|
|
330
344
|
{
|
331
345
|
size_t pos;
|
332
346
|
git_filter_def *fdef;
|
347
|
+
git_filter *filter = NULL;
|
333
348
|
|
334
|
-
if (
|
349
|
+
if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
|
350
|
+
giterr_set(GITERR_OS, "failed to lock filter registry");
|
335
351
|
return NULL;
|
352
|
+
}
|
336
353
|
|
337
|
-
if ((fdef = filter_registry_lookup(&pos, name)) == NULL
|
338
|
-
|
354
|
+
if ((fdef = filter_registry_lookup(&pos, name)) == NULL ||
|
355
|
+
(!fdef->initialized && filter_initialize(fdef) < 0))
|
356
|
+
goto done;
|
339
357
|
|
340
|
-
|
341
|
-
return NULL;
|
358
|
+
filter = fdef->filter;
|
342
359
|
|
343
|
-
|
360
|
+
done:
|
361
|
+
git_rwlock_rdunlock(&filter_registry.lock);
|
362
|
+
return filter;
|
344
363
|
}
|
345
364
|
|
346
365
|
void git_filter_free(git_filter *filter)
|
@@ -478,8 +497,10 @@ int git_filter_list__load_ext(
|
|
478
497
|
size_t idx;
|
479
498
|
git_filter_def *fdef;
|
480
499
|
|
481
|
-
if (
|
500
|
+
if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
|
501
|
+
giterr_set(GITERR_OS, "failed to lock filter registry");
|
482
502
|
return -1;
|
503
|
+
}
|
483
504
|
|
484
505
|
src.repo = repo;
|
485
506
|
src.path = path;
|
@@ -489,7 +510,7 @@ int git_filter_list__load_ext(
|
|
489
510
|
if (blob)
|
490
511
|
git_oid_cpy(&src.oid, git_blob_id(blob));
|
491
512
|
|
492
|
-
git_vector_foreach(&
|
513
|
+
git_vector_foreach(&filter_registry.filters, idx, fdef) {
|
493
514
|
const char **values = NULL;
|
494
515
|
void *payload = NULL;
|
495
516
|
|
@@ -523,7 +544,7 @@ int git_filter_list__load_ext(
|
|
523
544
|
else {
|
524
545
|
if (!fl) {
|
525
546
|
if ((error = filter_list_new(&fl, &src)) < 0)
|
526
|
-
|
547
|
+
break;
|
527
548
|
|
528
549
|
fl->temp_buf = filter_opts->temp_buf;
|
529
550
|
}
|
@@ -537,6 +558,8 @@ int git_filter_list__load_ext(
|
|
537
558
|
}
|
538
559
|
}
|
539
560
|
|
561
|
+
git_rwlock_rdunlock(&filter_registry.lock);
|
562
|
+
|
540
563
|
if (error && fl != NULL) {
|
541
564
|
git_array_clear(fl->filters);
|
542
565
|
git__free(fl);
|
@@ -604,20 +627,28 @@ int git_filter_list_push(
|
|
604
627
|
{
|
605
628
|
int error = 0;
|
606
629
|
size_t pos;
|
607
|
-
git_filter_def *fdef;
|
630
|
+
git_filter_def *fdef = NULL;
|
608
631
|
git_filter_entry *fe;
|
609
632
|
|
610
633
|
assert(fl && filter);
|
611
634
|
|
635
|
+
if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
|
636
|
+
giterr_set(GITERR_OS, "failed to lock filter registry");
|
637
|
+
return -1;
|
638
|
+
}
|
639
|
+
|
612
640
|
if (git_vector_search2(
|
613
|
-
&pos, &
|
614
|
-
filter_def_filter_key_check, filter)
|
641
|
+
&pos, &filter_registry.filters,
|
642
|
+
filter_def_filter_key_check, filter) == 0)
|
643
|
+
fdef = git_vector_get(&filter_registry.filters, pos);
|
644
|
+
|
645
|
+
git_rwlock_rdunlock(&filter_registry.lock);
|
646
|
+
|
647
|
+
if (fdef == NULL) {
|
615
648
|
giterr_set(GITERR_FILTER, "Cannot use an unregistered filter");
|
616
649
|
return -1;
|
617
650
|
}
|
618
651
|
|
619
|
-
fdef = git_vector_get(&git__filter_registry->filters, pos);
|
620
|
-
|
621
652
|
if (!fdef->initialized && (error = filter_initialize(fdef)) < 0)
|
622
653
|
return error;
|
623
654
|
|