rugged 0.24.0 → 0.24.5
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.
- checksums.yaml +7 -0
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +20 -9
- data/vendor/libgit2/deps/http-parser/http_parser.c +5 -2
- data/vendor/libgit2/include/git2/checkout.h +7 -0
- data/vendor/libgit2/include/git2/common.h +16 -1
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/array.h +40 -0
- data/vendor/libgit2/src/blame.c +8 -3
- data/vendor/libgit2/src/blame_git.c +20 -9
- data/vendor/libgit2/src/checkout.c +13 -5
- data/vendor/libgit2/src/commit.c +5 -4
- data/vendor/libgit2/src/common.h +1 -1
- data/vendor/libgit2/src/config_cache.c +2 -1
- data/vendor/libgit2/src/config_file.c +14 -20
- data/vendor/libgit2/src/delta-apply.c +36 -5
- data/vendor/libgit2/src/delta-apply.h +12 -0
- data/vendor/libgit2/src/describe.c +2 -1
- data/vendor/libgit2/src/diff_tform.c +5 -3
- data/vendor/libgit2/src/filebuf.c +6 -1
- data/vendor/libgit2/src/global.c +28 -8
- data/vendor/libgit2/src/global.h +1 -0
- data/vendor/libgit2/src/ignore.c +56 -19
- data/vendor/libgit2/src/index.c +27 -8
- data/vendor/libgit2/src/indexer.c +11 -7
- data/vendor/libgit2/src/iterator.c +2 -2
- data/vendor/libgit2/src/merge.c +1 -0
- data/vendor/libgit2/src/mwindow.c +20 -21
- data/vendor/libgit2/src/mwindow.h +1 -2
- data/vendor/libgit2/src/object.c +3 -6
- data/vendor/libgit2/src/odb.c +11 -15
- data/vendor/libgit2/src/odb.h +2 -1
- data/vendor/libgit2/src/odb_loose.c +13 -9
- data/vendor/libgit2/src/odb_pack.c +5 -6
- data/vendor/libgit2/src/oid.h +9 -0
- data/vendor/libgit2/src/openssl_stream.c +60 -27
- data/vendor/libgit2/src/openssl_stream.h +106 -0
- data/vendor/libgit2/src/pack-objects.c +4 -2
- data/vendor/libgit2/src/pack.c +10 -14
- data/vendor/libgit2/src/posix.c +7 -0
- data/vendor/libgit2/src/posix.h +1 -0
- data/vendor/libgit2/src/push.c +6 -6
- data/vendor/libgit2/src/refdb_fs.c +1 -0
- data/vendor/libgit2/src/refs.c +3 -0
- data/vendor/libgit2/src/refspec.c +4 -2
- data/vendor/libgit2/src/remote.c +15 -5
- data/vendor/libgit2/src/repository.c +29 -21
- data/vendor/libgit2/src/settings.c +23 -1
- data/vendor/libgit2/src/stransport_stream.c +15 -9
- data/vendor/libgit2/src/submodule.c +3 -2
- data/vendor/libgit2/src/sysdir.c +41 -47
- data/vendor/libgit2/src/sysdir.h +0 -5
- data/vendor/libgit2/src/tag.c +8 -2
- data/vendor/libgit2/src/thread-utils.h +5 -51
- data/vendor/libgit2/src/transport.c +2 -0
- data/vendor/libgit2/src/transports/http.c +2 -1
- data/vendor/libgit2/src/transports/smart_pkt.c +1 -0
- data/vendor/libgit2/src/transports/smart_protocol.c +72 -17
- data/vendor/libgit2/src/transports/ssh.c +32 -17
- data/vendor/libgit2/src/tree.c +83 -100
- data/vendor/libgit2/src/tree.h +4 -5
- data/vendor/libgit2/src/unix/map.c +5 -0
- data/vendor/libgit2/src/unix/pthread.h +54 -0
- data/vendor/libgit2/src/util.c +3 -3
- data/vendor/libgit2/src/win32/map.c +24 -5
- data/vendor/libgit2/src/win32/precompiled.h +1 -1
- data/vendor/libgit2/src/win32/{pthread.c → thread.c} +50 -80
- data/vendor/libgit2/src/win32/thread.h +62 -0
- data/vendor/libgit2/src/xdiff/xprepare.c +2 -1
- metadata +384 -394
- data/vendor/libgit2/src/win32/pthread.h +0 -92
@@ -21,7 +21,8 @@
|
|
21
21
|
|
22
22
|
#define OWNING_SUBTRANSPORT(s) ((ssh_subtransport *)(s)->parent.subtransport)
|
23
23
|
|
24
|
-
static const char
|
24
|
+
static const char *ssh_prefixes[] = { "ssh://", "ssh+git://", "git+ssh://" };
|
25
|
+
|
25
26
|
static const char cmd_uploadpack[] = "git-upload-pack";
|
26
27
|
static const char cmd_receivepack[] = "git-receive-pack";
|
27
28
|
|
@@ -63,17 +64,24 @@ static int gen_proto(git_buf *request, const char *cmd, const char *url)
|
|
63
64
|
{
|
64
65
|
char *repo;
|
65
66
|
int len;
|
67
|
+
size_t i;
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
if (
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
for (i = 0; i < ARRAY_SIZE(ssh_prefixes); ++i) {
|
70
|
+
const char *p = ssh_prefixes[i];
|
71
|
+
|
72
|
+
if (!git__prefixcmp(url, p)) {
|
73
|
+
url = url + strlen(p);
|
74
|
+
repo = strchr(url, '/');
|
75
|
+
if (repo && repo[1] == '~')
|
76
|
+
++repo;
|
77
|
+
|
78
|
+
goto done;
|
79
|
+
}
|
75
80
|
}
|
81
|
+
repo = strchr(url, ':');
|
82
|
+
if (repo) repo++;
|
76
83
|
|
84
|
+
done:
|
77
85
|
if (!repo) {
|
78
86
|
giterr_set(GITERR_NET, "Malformed git protocol URL");
|
79
87
|
return -1;
|
@@ -500,6 +508,7 @@ static int _git_ssh_setup_conn(
|
|
500
508
|
char *host=NULL, *port=NULL, *path=NULL, *user=NULL, *pass=NULL;
|
501
509
|
const char *default_port="22";
|
502
510
|
int auth_methods, error = 0;
|
511
|
+
size_t i;
|
503
512
|
ssh_stream *s;
|
504
513
|
git_cred *cred = NULL;
|
505
514
|
LIBSSH2_SESSION* session=NULL;
|
@@ -515,16 +524,22 @@ static int _git_ssh_setup_conn(
|
|
515
524
|
s->session = NULL;
|
516
525
|
s->channel = NULL;
|
517
526
|
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
527
|
+
for (i = 0; i < ARRAY_SIZE(ssh_prefixes); ++i) {
|
528
|
+
const char *p = ssh_prefixes[i];
|
529
|
+
|
530
|
+
if (!git__prefixcmp(url, p)) {
|
531
|
+
if ((error = gitno_extract_url_parts(&host, &port, &path, &user, &pass, url, default_port)) < 0)
|
532
|
+
goto done;
|
533
|
+
|
534
|
+
goto post_extract;
|
535
|
+
}
|
526
536
|
}
|
537
|
+
if ((error = git_ssh_extract_url_parts(&host, &user, url)) < 0)
|
538
|
+
goto done;
|
539
|
+
port = git__strdup(default_port);
|
540
|
+
GITERR_CHECK_ALLOC(port);
|
527
541
|
|
542
|
+
post_extract:
|
528
543
|
if ((error = git_socket_stream_new(&s->io, host, port)) < 0 ||
|
529
544
|
(error = git_stream_connect(s->io)) < 0)
|
530
545
|
goto done;
|
data/vendor/libgit2/src/tree.c
CHANGED
@@ -45,7 +45,7 @@ GIT_INLINE(git_filemode_t) normalize_filemode(git_filemode_t filemode)
|
|
45
45
|
if (GIT_MODE_TYPE(filemode) == GIT_FILEMODE_COMMIT)
|
46
46
|
return GIT_FILEMODE_COMMIT;
|
47
47
|
|
48
|
-
/* 12XXXX means
|
48
|
+
/* 12XXXX means symlink */
|
49
49
|
if (GIT_MODE_TYPE(filemode) == GIT_FILEMODE_LINK)
|
50
50
|
return GIT_FILEMODE_LINK;
|
51
51
|
|
@@ -85,9 +85,10 @@ int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2)
|
|
85
85
|
}
|
86
86
|
|
87
87
|
/**
|
88
|
-
* Allocate
|
88
|
+
* Allocate a new self-contained entry, with enough space after it to
|
89
|
+
* store the filename and the id.
|
89
90
|
*/
|
90
|
-
static git_tree_entry *
|
91
|
+
static git_tree_entry *alloc_entry(const char *filename, size_t filename_len, const git_oid *id)
|
91
92
|
{
|
92
93
|
git_tree_entry *entry = NULL;
|
93
94
|
size_t tree_len;
|
@@ -95,44 +96,32 @@ static git_tree_entry *alloc_entry_base(git_pool *pool, const char *filename, si
|
|
95
96
|
TREE_ENTRY_CHECK_NAMELEN(filename_len);
|
96
97
|
|
97
98
|
if (GIT_ADD_SIZET_OVERFLOW(&tree_len, sizeof(git_tree_entry), filename_len) ||
|
98
|
-
GIT_ADD_SIZET_OVERFLOW(&tree_len, tree_len, 1)
|
99
|
+
GIT_ADD_SIZET_OVERFLOW(&tree_len, tree_len, 1) ||
|
100
|
+
GIT_ADD_SIZET_OVERFLOW(&tree_len, tree_len, GIT_OID_RAWSZ))
|
99
101
|
return NULL;
|
100
102
|
|
101
|
-
entry =
|
102
|
-
git__malloc(tree_len);
|
103
|
+
entry = git__calloc(1, tree_len);
|
103
104
|
if (!entry)
|
104
105
|
return NULL;
|
105
106
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
entry->filename_len = (uint16_t)filename_len;
|
107
|
+
{
|
108
|
+
char *filename_ptr;
|
109
|
+
void *id_ptr;
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
/**
|
115
|
-
* Allocate a tree entry, using the poolin the tree which owns
|
116
|
-
* it. This is useful when reading trees, so we don't allocate a ton
|
117
|
-
* of small strings but can use the pool.
|
118
|
-
*/
|
119
|
-
static git_tree_entry *alloc_entry_pooled(git_pool *pool, const char *filename, size_t filename_len)
|
120
|
-
{
|
121
|
-
git_tree_entry *entry = NULL;
|
111
|
+
filename_ptr = ((char *) entry) + sizeof(git_tree_entry);
|
112
|
+
memcpy(filename_ptr, filename, filename_len);
|
113
|
+
entry->filename = filename_ptr;
|
122
114
|
|
123
|
-
|
124
|
-
|
115
|
+
id_ptr = filename_ptr + filename_len + 1;
|
116
|
+
git_oid_cpy(id_ptr, id);
|
117
|
+
entry->oid = id_ptr;
|
118
|
+
}
|
125
119
|
|
126
|
-
entry->
|
120
|
+
entry->filename_len = (uint16_t)filename_len;
|
127
121
|
|
128
122
|
return entry;
|
129
123
|
}
|
130
124
|
|
131
|
-
static git_tree_entry *alloc_entry(const char *filename)
|
132
|
-
{
|
133
|
-
return alloc_entry_base(NULL, filename, strlen(filename));
|
134
|
-
}
|
135
|
-
|
136
125
|
struct tree_key_search {
|
137
126
|
const char *filename;
|
138
127
|
uint16_t filename_len;
|
@@ -174,7 +163,10 @@ static int homing_search_cmp(const void *key, const void *array_member)
|
|
174
163
|
* around the area for our target file.
|
175
164
|
*/
|
176
165
|
static int tree_key_search(
|
177
|
-
size_t *at_pos,
|
166
|
+
size_t *at_pos,
|
167
|
+
const git_tree *tree,
|
168
|
+
const char *filename,
|
169
|
+
size_t filename_len)
|
178
170
|
{
|
179
171
|
struct tree_key_search ksearch;
|
180
172
|
const git_tree_entry *entry;
|
@@ -187,13 +179,15 @@ static int tree_key_search(
|
|
187
179
|
|
188
180
|
/* Initial homing search; find an entry on the tree with
|
189
181
|
* the same prefix as the filename we're looking for */
|
190
|
-
|
182
|
+
|
183
|
+
if (git_array_search(&homing,
|
184
|
+
tree->entries, &homing_search_cmp, &ksearch) < 0)
|
191
185
|
return GIT_ENOTFOUND; /* just a signal error; not passed back to user */
|
192
186
|
|
193
187
|
/* We found a common prefix. Look forward as long as
|
194
188
|
* there are entries that share the common prefix */
|
195
|
-
for (i = homing; i < entries
|
196
|
-
entry = entries
|
189
|
+
for (i = homing; i < tree->entries.size; ++i) {
|
190
|
+
entry = git_array_get(tree->entries, i);
|
197
191
|
|
198
192
|
if (homing_search_cmp(&ksearch, entry) < 0)
|
199
193
|
break;
|
@@ -213,7 +207,7 @@ static int tree_key_search(
|
|
213
207
|
i = homing - 1;
|
214
208
|
|
215
209
|
do {
|
216
|
-
entry = entries
|
210
|
+
entry = git_array_get(tree->entries, i);
|
217
211
|
|
218
212
|
if (homing_search_cmp(&ksearch, entry) > 0)
|
219
213
|
break;
|
@@ -234,7 +228,7 @@ static int tree_key_search(
|
|
234
228
|
|
235
229
|
void git_tree_entry_free(git_tree_entry *entry)
|
236
230
|
{
|
237
|
-
if (entry == NULL
|
231
|
+
if (entry == NULL)
|
238
232
|
return;
|
239
233
|
|
240
234
|
git__free(entry);
|
@@ -242,36 +236,26 @@ void git_tree_entry_free(git_tree_entry *entry)
|
|
242
236
|
|
243
237
|
int git_tree_entry_dup(git_tree_entry **dest, const git_tree_entry *source)
|
244
238
|
{
|
245
|
-
|
246
|
-
git_tree_entry *copy;
|
239
|
+
git_tree_entry *cpy;
|
247
240
|
|
248
241
|
assert(source);
|
249
242
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
copy = git__malloc(total_size);
|
254
|
-
GITERR_CHECK_ALLOC(copy);
|
255
|
-
|
256
|
-
memcpy(copy, source, total_size);
|
243
|
+
cpy = alloc_entry(source->filename, source->filename_len, source->oid);
|
244
|
+
if (cpy == NULL)
|
245
|
+
return -1;
|
257
246
|
|
258
|
-
|
247
|
+
cpy->attr = source->attr;
|
259
248
|
|
260
|
-
*dest =
|
249
|
+
*dest = cpy;
|
261
250
|
return 0;
|
262
251
|
}
|
263
252
|
|
264
253
|
void git_tree__free(void *_tree)
|
265
254
|
{
|
266
255
|
git_tree *tree = _tree;
|
267
|
-
size_t i;
|
268
|
-
git_tree_entry *e;
|
269
|
-
|
270
|
-
git_vector_foreach(&tree->entries, i, e)
|
271
|
-
git_tree_entry_free(e);
|
272
256
|
|
273
|
-
|
274
|
-
|
257
|
+
git_odb_object_free(tree->odb_obj);
|
258
|
+
git_array_clear(tree->entries);
|
275
259
|
git__free(tree);
|
276
260
|
}
|
277
261
|
|
@@ -294,7 +278,7 @@ const char *git_tree_entry_name(const git_tree_entry *entry)
|
|
294
278
|
const git_oid *git_tree_entry_id(const git_tree_entry *entry)
|
295
279
|
{
|
296
280
|
assert(entry);
|
297
|
-
return
|
281
|
+
return entry->oid;
|
298
282
|
}
|
299
283
|
|
300
284
|
git_otype git_tree_entry_type(const git_tree_entry *entry)
|
@@ -315,7 +299,7 @@ int git_tree_entry_to_object(
|
|
315
299
|
const git_tree_entry *entry)
|
316
300
|
{
|
317
301
|
assert(entry && object_out);
|
318
|
-
return git_object_lookup(object_out, repo,
|
302
|
+
return git_object_lookup(object_out, repo, entry->oid, GIT_OBJ_ANY);
|
319
303
|
}
|
320
304
|
|
321
305
|
static const git_tree_entry *entry_fromname(
|
@@ -323,13 +307,10 @@ static const git_tree_entry *entry_fromname(
|
|
323
307
|
{
|
324
308
|
size_t idx;
|
325
309
|
|
326
|
-
|
327
|
-
assert(git_vector_is_sorted(&tree->entries));
|
328
|
-
|
329
|
-
if (tree_key_search(&idx, (git_vector *)&tree->entries, name, name_len) < 0)
|
310
|
+
if (tree_key_search(&idx, tree, name, name_len) < 0)
|
330
311
|
return NULL;
|
331
312
|
|
332
|
-
return
|
313
|
+
return git_array_get(tree->entries, idx);
|
333
314
|
}
|
334
315
|
|
335
316
|
const git_tree_entry *git_tree_entry_byname(
|
@@ -344,7 +325,7 @@ const git_tree_entry *git_tree_entry_byindex(
|
|
344
325
|
const git_tree *tree, size_t idx)
|
345
326
|
{
|
346
327
|
assert(tree);
|
347
|
-
return
|
328
|
+
return git_array_get(tree->entries, idx);
|
348
329
|
}
|
349
330
|
|
350
331
|
const git_tree_entry *git_tree_entry_byid(
|
@@ -355,8 +336,8 @@ const git_tree_entry *git_tree_entry_byid(
|
|
355
336
|
|
356
337
|
assert(tree);
|
357
338
|
|
358
|
-
|
359
|
-
if (memcmp(&e->oid
|
339
|
+
git_array_foreach(tree->entries, i, e) {
|
340
|
+
if (memcmp(&e->oid->id, &id->id, sizeof(id->id)) == 0)
|
360
341
|
return e;
|
361
342
|
}
|
362
343
|
|
@@ -365,7 +346,6 @@ const git_tree_entry *git_tree_entry_byid(
|
|
365
346
|
|
366
347
|
int git_tree__prefix_position(const git_tree *tree, const char *path)
|
367
348
|
{
|
368
|
-
const git_vector *entries = &tree->entries;
|
369
349
|
struct tree_key_search ksearch;
|
370
350
|
size_t at_pos, path_len;
|
371
351
|
|
@@ -378,21 +358,20 @@ int git_tree__prefix_position(const git_tree *tree, const char *path)
|
|
378
358
|
ksearch.filename = path;
|
379
359
|
ksearch.filename_len = (uint16_t)path_len;
|
380
360
|
|
381
|
-
/* be safe when we cast away constness - i.e. don't trigger a sort */
|
382
|
-
assert(git_vector_is_sorted(&tree->entries));
|
383
|
-
|
384
361
|
/* Find tree entry with appropriate prefix */
|
385
|
-
|
386
|
-
&at_pos,
|
362
|
+
git_array_search(
|
363
|
+
&at_pos, tree->entries, &homing_search_cmp, &ksearch);
|
387
364
|
|
388
|
-
for (; at_pos < entries
|
389
|
-
const git_tree_entry *entry = entries
|
365
|
+
for (; at_pos < tree->entries.size; ++at_pos) {
|
366
|
+
const git_tree_entry *entry = git_array_get(tree->entries, at_pos);
|
390
367
|
if (homing_search_cmp(&ksearch, entry) < 0)
|
391
368
|
break;
|
392
369
|
}
|
393
370
|
|
394
371
|
for (; at_pos > 0; --at_pos) {
|
395
|
-
const git_tree_entry *entry =
|
372
|
+
const git_tree_entry *entry =
|
373
|
+
git_array_get(tree->entries, at_pos - 1);
|
374
|
+
|
396
375
|
if (homing_search_cmp(&ksearch, entry) > 0)
|
397
376
|
break;
|
398
377
|
}
|
@@ -403,7 +382,7 @@ int git_tree__prefix_position(const git_tree *tree, const char *path)
|
|
403
382
|
size_t git_tree_entrycount(const git_tree *tree)
|
404
383
|
{
|
405
384
|
assert(tree);
|
406
|
-
return tree->entries.
|
385
|
+
return tree->entries.size;
|
407
386
|
}
|
408
387
|
|
409
388
|
unsigned int git_treebuilder_entrycount(git_treebuilder *bld)
|
@@ -444,13 +423,18 @@ static int parse_mode(unsigned int *modep, const char *buffer, const char **buff
|
|
444
423
|
int git_tree__parse(void *_tree, git_odb_object *odb_obj)
|
445
424
|
{
|
446
425
|
git_tree *tree = _tree;
|
447
|
-
const char *buffer
|
448
|
-
const char *buffer_end
|
426
|
+
const char *buffer;
|
427
|
+
const char *buffer_end;
|
449
428
|
|
450
|
-
|
451
|
-
if (git_vector_init(&tree->entries, DEFAULT_TREE_SIZE, entry_sort_cmp) < 0)
|
429
|
+
if (git_odb_object_dup(&tree->odb_obj, odb_obj) < 0)
|
452
430
|
return -1;
|
453
431
|
|
432
|
+
buffer = git_odb_object_data(tree->odb_obj);
|
433
|
+
buffer_end = buffer + git_odb_object_size(tree->odb_obj);
|
434
|
+
|
435
|
+
git_array_init_to_size(tree->entries, DEFAULT_TREE_SIZE);
|
436
|
+
GITERR_CHECK_ARRAY(tree->entries);
|
437
|
+
|
454
438
|
while (buffer < buffer_end) {
|
455
439
|
git_tree_entry *entry;
|
456
440
|
size_t filename_len;
|
@@ -463,28 +447,27 @@ int git_tree__parse(void *_tree, git_odb_object *odb_obj)
|
|
463
447
|
if ((nul = memchr(buffer, 0, buffer_end - buffer)) == NULL)
|
464
448
|
return tree_error("Failed to parse tree. Object is corrupted", NULL);
|
465
449
|
|
466
|
-
filename_len = nul - buffer
|
467
|
-
|
450
|
+
if ((filename_len = nul - buffer) == 0)
|
451
|
+
return tree_error("Failed to parse tree. Can't parse filename", NULL);
|
452
|
+
|
453
|
+
if ((buffer_end - (nul + 1)) < GIT_OID_RAWSZ)
|
454
|
+
return tree_error("Failed to parse tree. Can't parse OID", NULL);
|
455
|
+
|
456
|
+
/* Allocate the entry */
|
468
457
|
{
|
469
|
-
entry =
|
458
|
+
entry = git_array_alloc(tree->entries);
|
470
459
|
GITERR_CHECK_ALLOC(entry);
|
471
460
|
|
472
|
-
if (git_vector_insert(&tree->entries, entry) < 0)
|
473
|
-
return -1;
|
474
|
-
|
475
461
|
entry->attr = attr;
|
462
|
+
entry->filename_len = filename_len;
|
463
|
+
entry->filename = buffer;
|
464
|
+
entry->oid = (git_oid *) ((char *) buffer + filename_len + 1);
|
476
465
|
}
|
477
466
|
|
478
|
-
/* Advance to the ID just after the path */
|
479
467
|
buffer += filename_len + 1;
|
480
|
-
|
481
|
-
git_oid_fromraw(&entry->oid, (const unsigned char *)buffer);
|
482
468
|
buffer += GIT_OID_RAWSZ;
|
483
469
|
}
|
484
470
|
|
485
|
-
/* The tree is sorted by definition. Bad inputs give bad outputs */
|
486
|
-
tree->entries.flags |= GIT_VECTOR_SORTED;
|
487
|
-
|
488
471
|
return 0;
|
489
472
|
}
|
490
473
|
|
@@ -517,10 +500,9 @@ static int append_entry(
|
|
517
500
|
if (!valid_entry_name(bld->repo, filename))
|
518
501
|
return tree_error("Failed to insert entry. Invalid name for a tree entry", filename);
|
519
502
|
|
520
|
-
entry = alloc_entry(filename);
|
503
|
+
entry = alloc_entry(filename, strlen(filename), id);
|
521
504
|
GITERR_CHECK_ALLOC(entry);
|
522
505
|
|
523
|
-
git_oid_cpy(&entry->oid, id);
|
524
506
|
entry->attr = (uint16_t)filemode;
|
525
507
|
|
526
508
|
git_strmap_insert(bld->map, entry->filename, entry, error);
|
@@ -709,10 +691,10 @@ int git_treebuilder_new(
|
|
709
691
|
if (source != NULL) {
|
710
692
|
git_tree_entry *entry_src;
|
711
693
|
|
712
|
-
|
694
|
+
git_array_foreach(source->entries, i, entry_src) {
|
713
695
|
if (append_entry(
|
714
696
|
bld, entry_src->filename,
|
715
|
-
|
697
|
+
entry_src->oid,
|
716
698
|
entry_src->attr) < 0)
|
717
699
|
goto on_error;
|
718
700
|
}
|
@@ -764,8 +746,9 @@ int git_treebuilder_insert(
|
|
764
746
|
pos = git_strmap_lookup_index(bld->map, filename);
|
765
747
|
if (git_strmap_valid_index(bld->map, pos)) {
|
766
748
|
entry = git_strmap_value_at(bld->map, pos);
|
749
|
+
git_oid_cpy((git_oid *) entry->oid, id);
|
767
750
|
} else {
|
768
|
-
entry = alloc_entry(filename);
|
751
|
+
entry = alloc_entry(filename, strlen(filename), id);
|
769
752
|
GITERR_CHECK_ALLOC(entry);
|
770
753
|
|
771
754
|
git_strmap_insert(bld->map, entry->filename, entry, error);
|
@@ -777,7 +760,6 @@ int git_treebuilder_insert(
|
|
777
760
|
}
|
778
761
|
}
|
779
762
|
|
780
|
-
git_oid_cpy(&entry->oid, id);
|
781
763
|
entry->attr = filemode;
|
782
764
|
|
783
765
|
if (entry_out)
|
@@ -848,19 +830,20 @@ int git_treebuilder_write(git_oid *oid, git_treebuilder *bld)
|
|
848
830
|
|
849
831
|
git_buf_printf(&tree, "%o ", entry->attr);
|
850
832
|
git_buf_put(&tree, entry->filename, entry->filename_len + 1);
|
851
|
-
git_buf_put(&tree, (char *)entry->oid
|
833
|
+
git_buf_put(&tree, (char *)entry->oid->id, GIT_OID_RAWSZ);
|
852
834
|
|
853
835
|
if (git_buf_oom(&tree))
|
854
836
|
error = -1;
|
855
837
|
}
|
856
838
|
|
857
|
-
git_vector_free(&entries);
|
858
839
|
|
859
840
|
if (!error &&
|
860
841
|
!(error = git_repository_odb__weakptr(&odb, bld->repo)))
|
861
842
|
error = git_odb_write(oid, odb, tree.ptr, tree.size, GIT_OBJ_TREE);
|
862
843
|
|
863
844
|
git_buf_free(&tree);
|
845
|
+
git_vector_free(&entries);
|
846
|
+
|
864
847
|
return error;
|
865
848
|
}
|
866
849
|
|
@@ -960,7 +943,7 @@ int git_tree_entry_bypath(
|
|
960
943
|
return git_tree_entry_dup(entry_out, entry);
|
961
944
|
}
|
962
945
|
|
963
|
-
if (git_tree_lookup(&subtree, root->object.repo,
|
946
|
+
if (git_tree_lookup(&subtree, root->object.repo, entry->oid) < 0)
|
964
947
|
return -1;
|
965
948
|
|
966
949
|
error = git_tree_entry_bypath(
|
@@ -984,7 +967,7 @@ static int tree_walk(
|
|
984
967
|
size_t i;
|
985
968
|
const git_tree_entry *entry;
|
986
969
|
|
987
|
-
|
970
|
+
git_array_foreach(tree->entries, i, entry) {
|
988
971
|
if (preorder) {
|
989
972
|
error = callback(path->ptr, entry, payload);
|
990
973
|
if (error < 0) { /* negative value stops iteration */
|
@@ -1001,7 +984,7 @@ static int tree_walk(
|
|
1001
984
|
git_tree *subtree;
|
1002
985
|
size_t path_len = git_buf_len(path);
|
1003
986
|
|
1004
|
-
error = git_tree_lookup(&subtree, tree->object.repo,
|
987
|
+
error = git_tree_lookup(&subtree, tree->object.repo, entry->oid);
|
1005
988
|
if (error < 0)
|
1006
989
|
break;
|
1007
990
|
|