rugged 0.24.0 → 0.24.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +20 -9
  4. data/vendor/libgit2/deps/http-parser/http_parser.c +5 -2
  5. data/vendor/libgit2/include/git2/checkout.h +7 -0
  6. data/vendor/libgit2/include/git2/common.h +16 -1
  7. data/vendor/libgit2/include/git2/version.h +2 -2
  8. data/vendor/libgit2/src/array.h +40 -0
  9. data/vendor/libgit2/src/blame.c +8 -3
  10. data/vendor/libgit2/src/blame_git.c +20 -9
  11. data/vendor/libgit2/src/checkout.c +13 -5
  12. data/vendor/libgit2/src/commit.c +5 -4
  13. data/vendor/libgit2/src/common.h +1 -1
  14. data/vendor/libgit2/src/config_cache.c +2 -1
  15. data/vendor/libgit2/src/config_file.c +14 -20
  16. data/vendor/libgit2/src/delta-apply.c +36 -5
  17. data/vendor/libgit2/src/delta-apply.h +12 -0
  18. data/vendor/libgit2/src/describe.c +2 -1
  19. data/vendor/libgit2/src/diff_tform.c +5 -3
  20. data/vendor/libgit2/src/filebuf.c +6 -1
  21. data/vendor/libgit2/src/global.c +28 -8
  22. data/vendor/libgit2/src/global.h +1 -0
  23. data/vendor/libgit2/src/ignore.c +56 -19
  24. data/vendor/libgit2/src/index.c +27 -8
  25. data/vendor/libgit2/src/indexer.c +11 -7
  26. data/vendor/libgit2/src/iterator.c +2 -2
  27. data/vendor/libgit2/src/merge.c +1 -0
  28. data/vendor/libgit2/src/mwindow.c +20 -21
  29. data/vendor/libgit2/src/mwindow.h +1 -2
  30. data/vendor/libgit2/src/object.c +3 -6
  31. data/vendor/libgit2/src/odb.c +11 -15
  32. data/vendor/libgit2/src/odb.h +2 -1
  33. data/vendor/libgit2/src/odb_loose.c +13 -9
  34. data/vendor/libgit2/src/odb_pack.c +5 -6
  35. data/vendor/libgit2/src/oid.h +9 -0
  36. data/vendor/libgit2/src/openssl_stream.c +60 -27
  37. data/vendor/libgit2/src/openssl_stream.h +106 -0
  38. data/vendor/libgit2/src/pack-objects.c +4 -2
  39. data/vendor/libgit2/src/pack.c +10 -14
  40. data/vendor/libgit2/src/posix.c +7 -0
  41. data/vendor/libgit2/src/posix.h +1 -0
  42. data/vendor/libgit2/src/push.c +6 -6
  43. data/vendor/libgit2/src/refdb_fs.c +1 -0
  44. data/vendor/libgit2/src/refs.c +3 -0
  45. data/vendor/libgit2/src/refspec.c +4 -2
  46. data/vendor/libgit2/src/remote.c +15 -5
  47. data/vendor/libgit2/src/repository.c +29 -21
  48. data/vendor/libgit2/src/settings.c +23 -1
  49. data/vendor/libgit2/src/stransport_stream.c +15 -9
  50. data/vendor/libgit2/src/submodule.c +3 -2
  51. data/vendor/libgit2/src/sysdir.c +41 -47
  52. data/vendor/libgit2/src/sysdir.h +0 -5
  53. data/vendor/libgit2/src/tag.c +8 -2
  54. data/vendor/libgit2/src/thread-utils.h +5 -51
  55. data/vendor/libgit2/src/transport.c +2 -0
  56. data/vendor/libgit2/src/transports/http.c +2 -1
  57. data/vendor/libgit2/src/transports/smart_pkt.c +1 -0
  58. data/vendor/libgit2/src/transports/smart_protocol.c +72 -17
  59. data/vendor/libgit2/src/transports/ssh.c +32 -17
  60. data/vendor/libgit2/src/tree.c +83 -100
  61. data/vendor/libgit2/src/tree.h +4 -5
  62. data/vendor/libgit2/src/unix/map.c +5 -0
  63. data/vendor/libgit2/src/unix/pthread.h +54 -0
  64. data/vendor/libgit2/src/util.c +3 -3
  65. data/vendor/libgit2/src/win32/map.c +24 -5
  66. data/vendor/libgit2/src/win32/precompiled.h +1 -1
  67. data/vendor/libgit2/src/win32/{pthread.c → thread.c} +50 -80
  68. data/vendor/libgit2/src/win32/thread.h +62 -0
  69. data/vendor/libgit2/src/xdiff/xprepare.c +2 -1
  70. metadata +384 -394
  71. 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 prefix_ssh[] = "ssh://";
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
- if (!git__prefixcmp(url, prefix_ssh)) {
68
- url = url + strlen(prefix_ssh);
69
- repo = strchr(url, '/');
70
- if (repo && repo[1] == '~')
71
- ++repo;
72
- } else {
73
- repo = strchr(url, ':');
74
- if (repo) repo++;
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
- if (!git__prefixcmp(url, prefix_ssh)) {
519
- if ((error = gitno_extract_url_parts(&host, &port, &path, &user, &pass, url, default_port)) < 0)
520
- goto done;
521
- } else {
522
- if ((error = git_ssh_extract_url_parts(&host, &user, url)) < 0)
523
- goto done;
524
- port = git__strdup(default_port);
525
- GITERR_CHECK_ALLOC(port);
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;
@@ -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 commit */
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 either from the pool or from the system allocator
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 *alloc_entry_base(git_pool *pool, const char *filename, size_t filename_len)
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 = pool ? git_pool_malloc(pool, tree_len) :
102
- git__malloc(tree_len);
103
+ entry = git__calloc(1, tree_len);
103
104
  if (!entry)
104
105
  return NULL;
105
106
 
106
- memset(entry, 0x0, sizeof(git_tree_entry));
107
- memcpy(entry->filename, filename, filename_len);
108
- entry->filename[filename_len] = 0;
109
- entry->filename_len = (uint16_t)filename_len;
107
+ {
108
+ char *filename_ptr;
109
+ void *id_ptr;
110
110
 
111
- return entry;
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
- if (!(entry = alloc_entry_base(pool, filename, filename_len)))
124
- return NULL;
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->pooled = true;
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, git_vector *entries, const char *filename, size_t filename_len)
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
- if (git_vector_bsearch2(&homing, entries, &homing_search_cmp, &ksearch) < 0)
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->length; ++i) {
196
- entry = entries->contents[i];
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->contents[i];
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 || entry->pooled)
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
- size_t total_size;
246
- git_tree_entry *copy;
239
+ git_tree_entry *cpy;
247
240
 
248
241
  assert(source);
249
242
 
250
- GITERR_CHECK_ALLOC_ADD(&total_size, sizeof(git_tree_entry), source->filename_len);
251
- GITERR_CHECK_ALLOC_ADD(&total_size, total_size, 1);
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
- copy->pooled = 0;
247
+ cpy->attr = source->attr;
259
248
 
260
- *dest = copy;
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
- git_vector_free(&tree->entries);
274
- git_pool_clear(&tree->pool);
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 &entry->oid;
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, &entry->oid, GIT_OBJ_ANY);
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
- /* be safe when we cast away constness - i.e. don't trigger a sort */
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 git_vector_get(&tree->entries, idx);
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 git_vector_get(&tree->entries, idx);
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
- git_vector_foreach(&tree->entries, i, e) {
359
- if (memcmp(&e->oid.id, &id->id, sizeof(id->id)) == 0)
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
- git_vector_bsearch2(
386
- &at_pos, (git_vector *)entries, &homing_search_cmp, &ksearch);
362
+ git_array_search(
363
+ &at_pos, tree->entries, &homing_search_cmp, &ksearch);
387
364
 
388
- for (; at_pos < entries->length; ++at_pos) {
389
- const git_tree_entry *entry = entries->contents[at_pos];
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 = entries->contents[at_pos - 1];
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.length;
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 = git_odb_object_data(odb_obj);
448
- const char *buffer_end = buffer + git_odb_object_size(odb_obj);
426
+ const char *buffer;
427
+ const char *buffer_end;
449
428
 
450
- git_pool_init(&tree->pool, 1);
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
- /** Allocate the entry and store it in the entries vector */
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 = alloc_entry_pooled(&tree->pool, buffer, filename_len);
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
- git_vector_foreach(&source->entries, i, entry_src) {
694
+ git_array_foreach(source->entries, i, entry_src) {
713
695
  if (append_entry(
714
696
  bld, entry_src->filename,
715
- &entry_src->oid,
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.id, GIT_OID_RAWSZ);
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, &entry->oid) < 0)
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
- git_vector_foreach(&tree->entries, i, entry) {
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, &entry->oid);
987
+ error = git_tree_lookup(&subtree, tree->object.repo, entry->oid);
1005
988
  if (error < 0)
1006
989
  break;
1007
990