rugged 0.26.0b3 → 0.26.0b4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/ext/rugged/extconf.rb +10 -7
  4. data/ext/rugged/rugged.c +4 -6
  5. data/ext/rugged/rugged_repo.c +1 -1
  6. data/ext/rugged/rugged_revwalk.c +4 -4
  7. data/ext/rugged/rugged_tree.c +2 -2
  8. data/lib/rugged/version.rb +1 -1
  9. data/vendor/libgit2/CMakeLists.txt +13 -6
  10. data/vendor/libgit2/COPYING +33 -0
  11. data/vendor/libgit2/include/git2/branch.h +12 -0
  12. data/vendor/libgit2/include/git2/commit.h +6 -3
  13. data/vendor/libgit2/include/git2/common.h +11 -0
  14. data/vendor/libgit2/include/git2/errors.h +2 -0
  15. data/vendor/libgit2/include/git2/index.h +7 -6
  16. data/vendor/libgit2/include/git2/repository.h +91 -0
  17. data/vendor/libgit2/include/git2/stash.h +2 -2
  18. data/vendor/libgit2/include/git2/types.h +3 -0
  19. data/vendor/libgit2/include/git2/worktree.h +161 -0
  20. data/vendor/libgit2/src/attr.c +24 -16
  21. data/vendor/libgit2/src/attr_file.h +1 -1
  22. data/vendor/libgit2/src/attrcache.c +11 -10
  23. data/vendor/libgit2/src/attrcache.h +1 -4
  24. data/vendor/libgit2/src/blob.c +2 -2
  25. data/vendor/libgit2/src/branch.c +63 -0
  26. data/vendor/libgit2/src/buffer.h +2 -1
  27. data/vendor/libgit2/src/cache.c +21 -25
  28. data/vendor/libgit2/src/cache.h +1 -1
  29. data/vendor/libgit2/src/checkout.c +0 -2
  30. data/vendor/libgit2/src/cherrypick.c +2 -2
  31. data/vendor/libgit2/src/clone.c +2 -3
  32. data/vendor/libgit2/src/commit.c +8 -4
  33. data/vendor/libgit2/src/config_file.c +1 -3
  34. data/vendor/libgit2/src/describe.c +1 -3
  35. data/vendor/libgit2/src/diff_driver.c +2 -4
  36. data/vendor/libgit2/src/fetchhead.c +2 -2
  37. data/vendor/libgit2/src/fileops.c +1 -3
  38. data/vendor/libgit2/src/hash.h +5 -3
  39. data/vendor/libgit2/src/hash/hash_collisiondetect.h +57 -0
  40. data/vendor/libgit2/src/hash/sha1dc/sha1.c +1149 -0
  41. data/vendor/libgit2/src/hash/sha1dc/sha1.h +94 -0
  42. data/vendor/libgit2/src/hash/sha1dc/ubc_check.c +361 -0
  43. data/vendor/libgit2/src/hash/sha1dc/ubc_check.h +35 -0
  44. data/vendor/libgit2/src/idxmap.c +133 -0
  45. data/vendor/libgit2/src/idxmap.h +22 -60
  46. data/vendor/libgit2/src/ignore.c +7 -1
  47. data/vendor/libgit2/src/ignore.h +1 -1
  48. data/vendor/libgit2/src/index.c +11 -14
  49. data/vendor/libgit2/src/indexer.c +8 -11
  50. data/vendor/libgit2/src/merge.c +5 -5
  51. data/vendor/libgit2/src/mwindow.c +1 -3
  52. data/vendor/libgit2/src/odb.c +3 -3
  53. data/vendor/libgit2/src/odb.h +3 -0
  54. data/vendor/libgit2/src/odb_mempack.c +11 -18
  55. data/vendor/libgit2/src/offmap.c +83 -0
  56. data/vendor/libgit2/src/offmap.h +14 -34
  57. data/vendor/libgit2/src/oidmap.c +105 -0
  58. data/vendor/libgit2/src/oidmap.h +19 -22
  59. data/vendor/libgit2/src/pack-objects.c +10 -13
  60. data/vendor/libgit2/src/pack.c +17 -26
  61. data/vendor/libgit2/src/path.c +45 -24
  62. data/vendor/libgit2/src/rebase.c +3 -3
  63. data/vendor/libgit2/src/refdb_fs.c +81 -46
  64. data/vendor/libgit2/src/refs.c +13 -3
  65. data/vendor/libgit2/src/remote.c +6 -2
  66. data/vendor/libgit2/src/repository.c +318 -46
  67. data/vendor/libgit2/src/repository.h +5 -2
  68. data/vendor/libgit2/src/revert.c +2 -2
  69. data/vendor/libgit2/src/revwalk.c +6 -8
  70. data/vendor/libgit2/src/settings.c +5 -0
  71. data/vendor/libgit2/src/sortedcache.c +3 -5
  72. data/vendor/libgit2/src/strmap.c +95 -0
  73. data/vendor/libgit2/src/strmap.h +17 -37
  74. data/vendor/libgit2/src/submodule.c +12 -8
  75. data/vendor/libgit2/src/thread-utils.h +6 -0
  76. data/vendor/libgit2/src/transaction.c +5 -17
  77. data/vendor/libgit2/src/transports/local.c +2 -1
  78. data/vendor/libgit2/src/transports/smart.h +2 -0
  79. data/vendor/libgit2/src/transports/smart_protocol.c +3 -1
  80. data/vendor/libgit2/src/tree.c +2 -4
  81. data/vendor/libgit2/src/unix/posix.h +1 -1
  82. data/vendor/libgit2/src/worktree.c +432 -0
  83. data/vendor/libgit2/src/worktree.h +35 -0
  84. metadata +13 -2
@@ -14,8 +14,6 @@
14
14
  #include "strmap.h"
15
15
  #include "pack.h"
16
16
 
17
- GIT__USE_STRMAP
18
-
19
17
  #define DEFAULT_WINDOW_SIZE \
20
18
  (sizeof(void*) >= 8 \
21
19
  ? 1 * 1024 * 1024 * 1024 \
@@ -84,7 +82,7 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
84
82
 
85
83
  git_atomic_inc(&pack->refcount);
86
84
 
87
- git_strmap_insert(git__pack_cache, pack->pack_name, pack, error);
85
+ git_strmap_insert(git__pack_cache, pack->pack_name, pack, &error);
88
86
  git_mutex_unlock(&git__mwindow_mutex);
89
87
 
90
88
  if (error < 0) {
@@ -695,7 +695,7 @@ static int odb_freshen_1(
695
695
  return (int)found;
696
696
  }
697
697
 
698
- static int odb_freshen(git_odb *db, const git_oid *id)
698
+ int git_odb__freshen(git_odb *db, const git_oid *id)
699
699
  {
700
700
  assert(db && id);
701
701
 
@@ -1167,7 +1167,7 @@ int git_odb_write(
1167
1167
  assert(oid && db);
1168
1168
 
1169
1169
  git_odb_hash(oid, data, len, type);
1170
- if (odb_freshen(db, oid))
1170
+ if (git_odb__freshen(db, oid))
1171
1171
  return 0;
1172
1172
 
1173
1173
  for (i = 0; i < db->backends.length && error < 0; ++i) {
@@ -1293,7 +1293,7 @@ int git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream)
1293
1293
 
1294
1294
  git_hash_final(out, stream->hash_ctx);
1295
1295
 
1296
- if (odb_freshen(stream->backend->odb, out))
1296
+ if (git_odb__freshen(stream->backend->odb, out))
1297
1297
  return 0;
1298
1298
 
1299
1299
  return stream->finalize_write(stream, out);
@@ -98,6 +98,9 @@ int git_odb__read_header_or_object(
98
98
  git_odb_object **out, size_t *len_p, git_otype *type_p,
99
99
  git_odb *db, const git_oid *id);
100
100
 
101
+ /* freshen an entry in the object database */
102
+ int git_odb__freshen(git_odb *db, const git_oid *id);
103
+
101
104
  /* fully free the object; internal method, DO NOT EXPORT */
102
105
  void git_odb_object__free(void *object);
103
106
 
@@ -18,8 +18,6 @@
18
18
  #include "git2/types.h"
19
19
  #include "git2/pack.h"
20
20
 
21
- GIT__USE_OIDMAP
22
-
23
21
  struct memobject {
24
22
  git_oid oid;
25
23
  size_t len;
@@ -41,7 +39,7 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void
41
39
  size_t alloc_len;
42
40
  int rval;
43
41
 
44
- pos = kh_put(oid, db->objects, oid, &rval);
42
+ pos = git_oidmap_put(db->objects, oid, &rval);
45
43
  if (rval < 0)
46
44
  return -1;
47
45
 
@@ -57,8 +55,8 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void
57
55
  obj->len = len;
58
56
  obj->type = type;
59
57
 
60
- kh_key(db->objects, pos) = &obj->oid;
61
- kh_val(db->objects, pos) = obj;
58
+ git_oidmap_set_key_at(db->objects, pos, &obj->oid);
59
+ git_oidmap_set_value_at(db->objects, pos, obj);
62
60
 
63
61
  if (type == GIT_OBJ_COMMIT) {
64
62
  struct memobject **store = git_array_alloc(db->commits);
@@ -72,13 +70,8 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void
72
70
  static int impl__exists(git_odb_backend *backend, const git_oid *oid)
73
71
  {
74
72
  struct memory_packer_db *db = (struct memory_packer_db *)backend;
75
- khiter_t pos;
76
73
 
77
- pos = kh_get(oid, db->objects, oid);
78
- if (pos != kh_end(db->objects))
79
- return 1;
80
-
81
- return 0;
74
+ return git_oidmap_exists(db->objects, oid);
82
75
  }
83
76
 
84
77
  static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
@@ -87,11 +80,11 @@ static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb
87
80
  struct memobject *obj = NULL;
88
81
  khiter_t pos;
89
82
 
90
- pos = kh_get(oid, db->objects, oid);
91
- if (pos == kh_end(db->objects))
83
+ pos = git_oidmap_lookup_index(db->objects, oid);
84
+ if (!git_oidmap_valid_index(db->objects, pos))
92
85
  return GIT_ENOTFOUND;
93
86
 
94
- obj = kh_val(db->objects, pos);
87
+ obj = git_oidmap_value_at(db->objects, pos);
95
88
 
96
89
  *len_p = obj->len;
97
90
  *type_p = obj->type;
@@ -108,11 +101,11 @@ static int impl__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *
108
101
  struct memobject *obj = NULL;
109
102
  khiter_t pos;
110
103
 
111
- pos = kh_get(oid, db->objects, oid);
112
- if (pos == kh_end(db->objects))
104
+ pos = git_oidmap_lookup_index(db->objects, oid);
105
+ if (!git_oidmap_valid_index(db->objects, pos))
113
106
  return GIT_ENOTFOUND;
114
107
 
115
- obj = kh_val(db->objects, pos);
108
+ obj = git_oidmap_value_at(db->objects, pos);
116
109
 
117
110
  *len_p = obj->len;
118
111
  *type_p = obj->type;
@@ -149,7 +142,7 @@ void git_mempack_reset(git_odb_backend *_backend)
149
142
  struct memory_packer_db *db = (struct memory_packer_db *)_backend;
150
143
  struct memobject *object = NULL;
151
144
 
152
- kh_foreach_value(db->objects, object, {
145
+ git_oidmap_foreach_value(db->objects, object, {
153
146
  git__free(object);
154
147
  });
155
148
 
@@ -0,0 +1,83 @@
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 "offmap.h"
9
+
10
+ __KHASH_IMPL(off, static kh_inline, git_off_t, void *, 1, kh_int64_hash_func, kh_int64_hash_equal)
11
+
12
+ git_offmap *git_offmap_alloc(void)
13
+ {
14
+ return kh_init(off);
15
+ }
16
+
17
+ void git_offmap__free(git_offmap *map)
18
+ {
19
+ kh_destroy(off, map);
20
+ }
21
+
22
+ void git_offmap_clear(git_offmap *map)
23
+ {
24
+ kh_clear(off, map);
25
+ }
26
+
27
+ size_t git_offmap_num_entries(git_offmap *map)
28
+ {
29
+ return kh_size(map);
30
+ }
31
+
32
+ size_t git_offmap_lookup_index(git_offmap *map, const git_off_t key)
33
+ {
34
+ return kh_get(off, map, key);
35
+ }
36
+
37
+ int git_offmap_valid_index(git_offmap *map, size_t idx)
38
+ {
39
+ return idx != kh_end(map);
40
+ }
41
+
42
+ int git_offmap_exists(git_offmap *map, const git_off_t key)
43
+ {
44
+ return kh_get(off, map, key) != kh_end(map);
45
+ }
46
+
47
+ void *git_offmap_value_at(git_offmap *map, size_t idx)
48
+ {
49
+ return kh_val(map, idx);
50
+ }
51
+
52
+ void git_offmap_set_value_at(git_offmap *map, size_t idx, void *value)
53
+ {
54
+ kh_val(map, idx) = value;
55
+ }
56
+
57
+ void git_offmap_delete_at(git_offmap *map, size_t idx)
58
+ {
59
+ kh_del(off, map, idx);
60
+ }
61
+
62
+ int git_offmap_put(git_offmap *map, const git_off_t key, int *err)
63
+ {
64
+ return kh_put(off, map, key, err);
65
+ }
66
+
67
+ void git_offmap_insert(git_offmap *map, const git_off_t key, void *value, int *rval)
68
+ {
69
+ khiter_t idx = kh_put(off, map, key, rval);
70
+
71
+ if ((*rval) >= 0) {
72
+ if ((*rval) == 0)
73
+ kh_key(map, idx) = key;
74
+ kh_val(map, idx) = value;
75
+ }
76
+ }
77
+
78
+ void git_offmap_delete(git_offmap *map, const git_off_t key)
79
+ {
80
+ khiter_t idx = git_offmap_lookup_index(map, key);
81
+ if (git_offmap_valid_index(map, idx))
82
+ git_offmap_delete_at(map, idx);
83
+ }
@@ -20,45 +20,25 @@
20
20
  __KHASH_TYPE(off, git_off_t, void *)
21
21
  typedef khash_t(off) git_offmap;
22
22
 
23
- #define GIT__USE_OFFMAP \
24
- __KHASH_IMPL(off, static kh_inline, git_off_t, void *, 1, kh_int64_hash_func, kh_int64_hash_equal)
23
+ git_offmap *git_offmap_alloc(void);
24
+ #define git_offmap_free(h) git_offmap__free(h); (h) = NULL
25
+ void git_offmap__free(git_offmap *map);
26
+ void git_offmap_clear(git_offmap *map);
25
27
 
26
- #define git_offmap_alloc() kh_init(off)
27
- #define git_offmap_free(h) kh_destroy(off, h), h = NULL
28
- #define git_offmap_clear(h) kh_clear(off, h)
28
+ size_t git_offmap_num_entries(git_offmap *map);
29
29
 
30
- #define git_offmap_num_entries(h) kh_size(h)
30
+ size_t git_offmap_lookup_index(git_offmap *map, const git_off_t key);
31
+ int git_offmap_valid_index(git_offmap *map, size_t idx);
31
32
 
32
- #define git_offmap_lookup_index(h, k) kh_get(off, h, k)
33
- #define git_offmap_valid_index(h, idx) (idx != kh_end(h))
33
+ int git_offmap_exists(git_offmap *map, const git_off_t key);
34
34
 
35
- #define git_offmap_exists(h, k) (kh_get(off, h, k) != kh_end(h))
35
+ void *git_offmap_value_at(git_offmap *map, size_t idx);
36
+ void git_offmap_set_value_at(git_offmap *map, size_t idx, void *value);
37
+ void git_offmap_delete_at(git_offmap *map, size_t idx);
36
38
 
37
- #define git_offmap_value_at(h, idx) kh_val(h, idx)
38
- #define git_offmap_set_value_at(h, idx, v) kh_val(h, idx) = v
39
- #define git_offmap_delete_at(h, idx) kh_del(off, h, idx)
40
-
41
- #define git_offmap_insert(h, key, val, rval) do { \
42
- khiter_t __pos = kh_put(off, h, key, &rval); \
43
- if (rval >= 0) { \
44
- if (rval == 0) kh_key(h, __pos) = key; \
45
- kh_val(h, __pos) = val; \
46
- } } while (0)
47
-
48
- #define git_offmap_insert2(h, key, val, oldv, rval) do { \
49
- khiter_t __pos = kh_put(off, h, key, &rval); \
50
- if (rval >= 0) { \
51
- if (rval == 0) { \
52
- oldv = kh_val(h, __pos); \
53
- kh_key(h, __pos) = key; \
54
- } else { oldv = NULL; } \
55
- kh_val(h, __pos) = val; \
56
- } } while (0)
57
-
58
- #define git_offmap_delete(h, key) do { \
59
- khiter_t __pos = git_offmap_lookup_index(h, key); \
60
- if (git_offmap_valid_index(h, __pos)) \
61
- git_offmap_delete_at(h, __pos); } while (0)
39
+ int git_offmap_put(git_offmap *map, const git_off_t key, int *err);
40
+ void git_offmap_insert(git_offmap *map, const git_off_t key, void *value, int *rval);
41
+ void git_offmap_delete(git_offmap *map, const git_off_t key);
62
42
 
63
43
  #define git_offmap_foreach kh_foreach
64
44
  #define git_offmap_foreach_value kh_foreach_value
@@ -0,0 +1,105 @@
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 "oidmap.h"
9
+
10
+ GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
11
+ {
12
+ khint_t h;
13
+ memcpy(&h, oid, sizeof(khint_t));
14
+ return h;
15
+ }
16
+
17
+ __KHASH_IMPL(oid, static kh_inline, const git_oid *, void *, 1, git_oidmap_hash, git_oid_equal)
18
+
19
+ git_oidmap *git_oidmap_alloc()
20
+ {
21
+ return kh_init(oid);
22
+ }
23
+
24
+ void git_oidmap__free(git_oidmap *map)
25
+ {
26
+ kh_destroy(oid, map);
27
+ }
28
+
29
+ void git_oidmap_clear(git_oidmap *map)
30
+ {
31
+ kh_clear(oid, map);
32
+ }
33
+
34
+ size_t git_oidmap_size(git_oidmap *map)
35
+ {
36
+ return kh_size(map);
37
+ }
38
+
39
+ size_t git_oidmap_lookup_index(git_oidmap *map, const git_oid *key)
40
+ {
41
+ return kh_get(oid, map, key);
42
+ }
43
+
44
+ int git_oidmap_valid_index(git_oidmap *map, size_t idx)
45
+ {
46
+ return idx != kh_end(map);
47
+ }
48
+
49
+ int git_oidmap_exists(git_oidmap *map, const git_oid *key)
50
+ {
51
+ return kh_get(oid, map, key) != kh_end(map);
52
+ }
53
+
54
+ int git_oidmap_has_data(git_oidmap *map, size_t idx)
55
+ {
56
+ return kh_exist(map, idx);
57
+ }
58
+
59
+ const git_oid *git_oidmap_key(git_oidmap *map, size_t idx)
60
+ {
61
+ return kh_key(map, idx);
62
+ }
63
+
64
+ void git_oidmap_set_key_at(git_oidmap *map, size_t idx, git_oid *key)
65
+ {
66
+ kh_key(map, idx) = key;
67
+ }
68
+
69
+ void *git_oidmap_value_at(git_oidmap *map, size_t idx)
70
+ {
71
+ return kh_val(map, idx);
72
+ }
73
+
74
+ void git_oidmap_set_value_at(git_oidmap *map, size_t idx, void *value)
75
+ {
76
+ kh_val(map, idx) = value;
77
+ }
78
+
79
+ void git_oidmap_delete_at(git_oidmap *map, size_t idx)
80
+ {
81
+ kh_del(oid, map, idx);
82
+ }
83
+
84
+ int git_oidmap_put(git_oidmap *map, const git_oid *key, int *err)
85
+ {
86
+ return kh_put(oid, map, key, err);
87
+ }
88
+
89
+ void git_oidmap_insert(git_oidmap *map, const git_oid *key, void *value, int *rval)
90
+ {
91
+ khiter_t idx = kh_put(oid, map, key, rval);
92
+
93
+ if ((*rval) >= 0) {
94
+ if ((*rval) == 0)
95
+ kh_key(map, idx) = key;
96
+ kh_val(map, idx) = value;
97
+ }
98
+ }
99
+
100
+ void git_oidmap_delete(git_oidmap *map, const git_oid *key)
101
+ {
102
+ khiter_t idx = git_oidmap_lookup_index(map, key);
103
+ if (git_oidmap_valid_index(map, idx))
104
+ git_oidmap_delete_at(map, idx);
105
+ }
@@ -20,35 +20,32 @@
20
20
  __KHASH_TYPE(oid, const git_oid *, void *)
21
21
  typedef khash_t(oid) git_oidmap;
22
22
 
23
- GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
24
- {
25
- khint_t h;
26
- memcpy(&h, oid, sizeof(khint_t));
27
- return h;
28
- }
23
+ git_oidmap *git_oidmap_alloc(void);
24
+ #define git_oidmap_free(h) git_oidmap__free(h); (h) = NULL
25
+ void git_oidmap__free(git_oidmap *map);
26
+ void git_oidmap_clear(git_oidmap *map);
29
27
 
30
- #define GIT__USE_OIDMAP \
31
- __KHASH_IMPL(oid, static kh_inline, const git_oid *, void *, 1, git_oidmap_hash, git_oid_equal)
28
+ size_t git_oidmap_size(git_oidmap *map);
32
29
 
33
- #define git_oidmap_alloc() kh_init(oid)
34
- #define git_oidmap_free(h) kh_destroy(oid,h), h = NULL
30
+ size_t git_oidmap_lookup_index(git_oidmap *map, const git_oid *key);
31
+ int git_oidmap_valid_index(git_oidmap *map, size_t idx);
35
32
 
36
- #define git_oidmap_lookup_index(h, k) kh_get(oid, h, k)
37
- #define git_oidmap_valid_index(h, idx) (idx != kh_end(h))
33
+ int git_oidmap_exists(git_oidmap *map, const git_oid *key);
34
+ int git_oidmap_has_data(git_oidmap *map, size_t idx);
38
35
 
39
- #define git_oidmap_value_at(h, idx) kh_val(h, idx)
36
+ const git_oid *git_oidmap_key(git_oidmap *map, size_t idx);
37
+ void git_oidmap_set_key_at(git_oidmap *map, size_t idx, git_oid *key);
38
+ void *git_oidmap_value_at(git_oidmap *map, size_t idx);
39
+ void git_oidmap_set_value_at(git_oidmap *map, size_t idx, void *value);
40
+ void git_oidmap_delete_at(git_oidmap *map, size_t idx);
40
41
 
41
- #define git_oidmap_insert(h, key, val, rval) do { \
42
- khiter_t __pos = kh_put(oid, h, key, &rval); \
43
- if (rval >= 0) { \
44
- if (rval == 0) kh_key(h, __pos) = key; \
45
- kh_val(h, __pos) = val; \
46
- } } while (0)
42
+ int git_oidmap_put(git_oidmap *map, const git_oid *key, int *err);
43
+ void git_oidmap_insert(git_oidmap *map, const git_oid *key, void *value, int *rval);
44
+ void git_oidmap_delete(git_oidmap *map, const git_oid *key);
47
45
 
48
46
  #define git_oidmap_foreach_value kh_foreach_value
49
47
 
50
- #define git_oidmap_size(h) kh_size(h)
51
-
52
- #define git_oidmap_clear(h) kh_clear(oid, h)
48
+ #define git_oidmap_begin kh_begin
49
+ #define git_oidmap_end kh_end
53
50
 
54
51
  #endif
@@ -41,8 +41,6 @@ struct pack_write_context {
41
41
  git_transfer_progress *stats;
42
42
  };
43
43
 
44
- GIT__USE_OIDMAP
45
-
46
44
  #ifdef GIT_THREADS
47
45
 
48
46
  #define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) do { \
@@ -197,10 +195,10 @@ static void rehash(git_packbuilder *pb)
197
195
  size_t i;
198
196
  int ret;
199
197
 
200
- kh_clear(oid, pb->object_ix);
198
+ git_oidmap_clear(pb->object_ix);
201
199
  for (i = 0, po = pb->object_list; i < pb->nr_objects; i++, po++) {
202
- pos = kh_put(oid, pb->object_ix, &po->id, &ret);
203
- kh_value(pb->object_ix, pos) = po;
200
+ pos = git_oidmap_put(pb->object_ix, &po->id, &ret);
201
+ git_oidmap_set_value_at(pb->object_ix, pos, po);
204
202
  }
205
203
  }
206
204
 
@@ -216,8 +214,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
216
214
 
217
215
  /* If the object already exists in the hash table, then we don't
218
216
  * have any work to do */
219
- pos = kh_get(oid, pb->object_ix, oid);
220
- if (pos != kh_end(pb->object_ix))
217
+ if (git_oidmap_exists(pb->object_ix, oid))
221
218
  return 0;
222
219
 
223
220
  if (pb->nr_objects >= pb->nr_alloc) {
@@ -247,13 +244,13 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
247
244
  git_oid_cpy(&po->id, oid);
248
245
  po->hash = name_hash(name);
249
246
 
250
- pos = kh_put(oid, pb->object_ix, &po->id, &ret);
247
+ pos = git_oidmap_put(pb->object_ix, &po->id, &ret);
251
248
  if (ret < 0) {
252
249
  giterr_set_oom();
253
250
  return ret;
254
251
  }
255
252
  assert(ret != 0);
256
- kh_value(pb->object_ix, pos) = po;
253
+ git_oidmap_set_value_at(pb->object_ix, pos, po);
257
254
 
258
255
  pb->done = false;
259
256
 
@@ -517,11 +514,11 @@ static int cb_tag_foreach(const char *name, git_oid *oid, void *data)
517
514
 
518
515
  GIT_UNUSED(name);
519
516
 
520
- pos = kh_get(oid, pb->object_ix, oid);
521
- if (pos == kh_end(pb->object_ix))
517
+ pos = git_oidmap_lookup_index(pb->object_ix, oid);
518
+ if (!git_oidmap_valid_index(pb->object_ix, pos))
522
519
  return 0;
523
520
 
524
- po = kh_value(pb->object_ix, pos);
521
+ po = git_oidmap_value_at(pb->object_ix, pos);
525
522
  po->tagged = 1;
526
523
 
527
524
  /* TODO: peel objects */
@@ -1541,7 +1538,7 @@ static int retrieve_object(git_walk_object **out, git_packbuilder *pb, const git
1541
1538
  if ((error = lookup_walk_object(&obj, pb, id)) < 0)
1542
1539
  return error;
1543
1540
 
1544
- git_oidmap_insert(pb->walk_objects, &obj->id, obj, error);
1541
+ git_oidmap_insert(pb->walk_objects, &obj->id, obj, &error);
1545
1542
  }
1546
1543
 
1547
1544
  *out = obj;