rugged 0.27.10.1 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (297) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/extconf.rb +23 -2
  3. data/ext/rugged/rugged.c +48 -2
  4. data/ext/rugged/rugged.h +5 -0
  5. data/ext/rugged/rugged_allocator.c +89 -0
  6. data/ext/rugged/rugged_blob.c +3 -3
  7. data/ext/rugged/rugged_branch.c +1 -1
  8. data/ext/rugged/rugged_commit.c +8 -8
  9. data/ext/rugged/rugged_config.c +1 -1
  10. data/ext/rugged/rugged_diff.c +24 -4
  11. data/ext/rugged/rugged_note.c +1 -1
  12. data/ext/rugged/rugged_repo.c +10 -10
  13. data/ext/rugged/rugged_settings.c +1 -1
  14. data/lib/rugged/version.rb +1 -1
  15. data/vendor/libgit2/CMakeLists.txt +69 -47
  16. data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
  17. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -8
  18. data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
  19. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
  20. data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
  21. data/vendor/libgit2/deps/regex/COPYING +502 -0
  22. data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
  23. data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
  24. data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
  25. data/vendor/libgit2/deps/zlib/COPYING +27 -0
  26. data/vendor/libgit2/include/git2.h +3 -0
  27. data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
  28. data/vendor/libgit2/include/git2/apply.h +129 -0
  29. data/vendor/libgit2/include/git2/attr.h +19 -8
  30. data/vendor/libgit2/include/git2/blame.h +41 -24
  31. data/vendor/libgit2/include/git2/blob.h +1 -1
  32. data/vendor/libgit2/include/git2/branch.h +1 -1
  33. data/vendor/libgit2/include/git2/buffer.h +2 -2
  34. data/vendor/libgit2/include/git2/checkout.h +20 -19
  35. data/vendor/libgit2/include/git2/cherrypick.h +6 -4
  36. data/vendor/libgit2/include/git2/clone.h +11 -9
  37. data/vendor/libgit2/include/git2/commit.h +30 -2
  38. data/vendor/libgit2/include/git2/common.h +54 -4
  39. data/vendor/libgit2/include/git2/config.h +18 -7
  40. data/vendor/libgit2/include/git2/deprecated.h +253 -0
  41. data/vendor/libgit2/include/git2/describe.h +30 -7
  42. data/vendor/libgit2/include/git2/diff.h +193 -143
  43. data/vendor/libgit2/include/git2/errors.h +54 -46
  44. data/vendor/libgit2/include/git2/ignore.h +2 -2
  45. data/vendor/libgit2/include/git2/index.h +72 -51
  46. data/vendor/libgit2/include/git2/indexer.h +30 -4
  47. data/vendor/libgit2/include/git2/mailmap.h +115 -0
  48. data/vendor/libgit2/include/git2/merge.h +29 -8
  49. data/vendor/libgit2/include/git2/net.h +1 -1
  50. data/vendor/libgit2/include/git2/notes.h +1 -1
  51. data/vendor/libgit2/include/git2/object.h +16 -16
  52. data/vendor/libgit2/include/git2/odb.h +10 -10
  53. data/vendor/libgit2/include/git2/odb_backend.h +7 -7
  54. data/vendor/libgit2/include/git2/oid.h +1 -1
  55. data/vendor/libgit2/include/git2/pack.h +2 -2
  56. data/vendor/libgit2/include/git2/proxy.h +9 -5
  57. data/vendor/libgit2/include/git2/rebase.h +7 -4
  58. data/vendor/libgit2/include/git2/refs.h +14 -15
  59. data/vendor/libgit2/include/git2/refspec.h +17 -0
  60. data/vendor/libgit2/include/git2/remote.h +92 -16
  61. data/vendor/libgit2/include/git2/repository.h +52 -37
  62. data/vendor/libgit2/include/git2/revert.h +5 -3
  63. data/vendor/libgit2/include/git2/revwalk.h +7 -7
  64. data/vendor/libgit2/include/git2/signature.h +2 -2
  65. data/vendor/libgit2/include/git2/stash.h +13 -10
  66. data/vendor/libgit2/include/git2/status.h +8 -4
  67. data/vendor/libgit2/include/git2/submodule.h +11 -10
  68. data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
  69. data/vendor/libgit2/include/git2/sys/commit.h +1 -1
  70. data/vendor/libgit2/include/git2/sys/config.h +13 -13
  71. data/vendor/libgit2/include/git2/sys/filter.h +6 -6
  72. data/vendor/libgit2/include/git2/sys/index.h +3 -0
  73. data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
  74. data/vendor/libgit2/include/git2/sys/merge.h +9 -4
  75. data/vendor/libgit2/include/git2/sys/odb_backend.h +19 -19
  76. data/vendor/libgit2/include/git2/sys/path.h +64 -0
  77. data/vendor/libgit2/include/git2/sys/refdb_backend.h +19 -19
  78. data/vendor/libgit2/include/git2/sys/stream.h +92 -12
  79. data/vendor/libgit2/include/git2/sys/transport.h +127 -81
  80. data/vendor/libgit2/include/git2/tag.h +2 -2
  81. data/vendor/libgit2/include/git2/trace.h +1 -1
  82. data/vendor/libgit2/include/git2/transaction.h +1 -0
  83. data/vendor/libgit2/include/git2/transport.h +47 -18
  84. data/vendor/libgit2/include/git2/tree.h +3 -3
  85. data/vendor/libgit2/include/git2/types.h +35 -28
  86. data/vendor/libgit2/include/git2/version.h +4 -4
  87. data/vendor/libgit2/include/git2/worktree.h +47 -12
  88. data/vendor/libgit2/src/CMakeLists.txt +87 -26
  89. data/vendor/libgit2/src/alloc.c +55 -0
  90. data/vendor/libgit2/src/alloc.h +40 -0
  91. data/vendor/libgit2/src/annotated_commit.c +15 -8
  92. data/vendor/libgit2/src/apply.c +490 -14
  93. data/vendor/libgit2/src/apply.h +3 -1
  94. data/vendor/libgit2/src/array.h +2 -2
  95. data/vendor/libgit2/src/attr.c +11 -11
  96. data/vendor/libgit2/src/attr_file.c +20 -15
  97. data/vendor/libgit2/src/attrcache.c +11 -11
  98. data/vendor/libgit2/src/blame.c +30 -15
  99. data/vendor/libgit2/src/blame.h +1 -0
  100. data/vendor/libgit2/src/blame_git.c +16 -13
  101. data/vendor/libgit2/src/blob.c +50 -28
  102. data/vendor/libgit2/src/blob.h +18 -1
  103. data/vendor/libgit2/src/branch.c +38 -38
  104. data/vendor/libgit2/src/buf_text.c +7 -6
  105. data/vendor/libgit2/src/buffer.c +55 -50
  106. data/vendor/libgit2/src/buffer.h +1 -1
  107. data/vendor/libgit2/src/cache.c +16 -16
  108. data/vendor/libgit2/src/cache.h +2 -2
  109. data/vendor/libgit2/src/cc-compat.h +15 -3
  110. data/vendor/libgit2/src/checkout.c +83 -74
  111. data/vendor/libgit2/src/cherrypick.c +6 -6
  112. data/vendor/libgit2/src/clone.c +20 -20
  113. data/vendor/libgit2/src/commit.c +53 -33
  114. data/vendor/libgit2/src/commit.h +1 -0
  115. data/vendor/libgit2/src/commit_list.c +6 -10
  116. data/vendor/libgit2/src/common.h +32 -30
  117. data/vendor/libgit2/src/config.c +167 -147
  118. data/vendor/libgit2/src/config.h +1 -14
  119. data/vendor/libgit2/src/config_backend.h +84 -0
  120. data/vendor/libgit2/src/config_cache.c +7 -1
  121. data/vendor/libgit2/src/config_entries.c +259 -0
  122. data/vendor/libgit2/src/config_entries.h +23 -0
  123. data/vendor/libgit2/src/config_file.c +167 -439
  124. data/vendor/libgit2/src/config_mem.c +224 -0
  125. data/vendor/libgit2/src/config_parse.c +69 -38
  126. data/vendor/libgit2/src/config_parse.h +4 -4
  127. data/vendor/libgit2/src/crlf.c +215 -186
  128. data/vendor/libgit2/src/delta.c +25 -18
  129. data/vendor/libgit2/src/describe.c +23 -23
  130. data/vendor/libgit2/src/diff.c +12 -12
  131. data/vendor/libgit2/src/diff_driver.c +14 -15
  132. data/vendor/libgit2/src/diff_file.c +10 -10
  133. data/vendor/libgit2/src/diff_generate.c +29 -23
  134. data/vendor/libgit2/src/diff_generate.h +1 -1
  135. data/vendor/libgit2/src/diff_parse.c +3 -3
  136. data/vendor/libgit2/src/diff_print.c +17 -17
  137. data/vendor/libgit2/src/diff_stats.c +22 -7
  138. data/vendor/libgit2/src/diff_tform.c +12 -12
  139. data/vendor/libgit2/src/diff_xdiff.c +15 -3
  140. data/vendor/libgit2/src/errors.c +42 -20
  141. data/vendor/libgit2/src/features.h.in +2 -1
  142. data/vendor/libgit2/src/fetch.c +3 -3
  143. data/vendor/libgit2/src/fetchhead.c +16 -16
  144. data/vendor/libgit2/src/filebuf.c +28 -28
  145. data/vendor/libgit2/src/fileops.c +54 -54
  146. data/vendor/libgit2/src/fileops.h +1 -1
  147. data/vendor/libgit2/src/filter.c +30 -30
  148. data/vendor/libgit2/src/filter.h +0 -10
  149. data/vendor/libgit2/src/global.c +36 -23
  150. data/vendor/libgit2/src/hash.h +4 -1
  151. data/vendor/libgit2/src/hash/hash_collisiondetect.h +6 -2
  152. data/vendor/libgit2/src/hash/hash_common_crypto.h +5 -1
  153. data/vendor/libgit2/src/hash/hash_generic.h +5 -1
  154. data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
  155. data/vendor/libgit2/src/hash/hash_mbedtls.h +24 -0
  156. data/vendor/libgit2/src/hash/hash_openssl.h +8 -4
  157. data/vendor/libgit2/src/hash/hash_win32.c +13 -13
  158. data/vendor/libgit2/src/hashsig.c +4 -4
  159. data/vendor/libgit2/src/idxmap.c +25 -5
  160. data/vendor/libgit2/src/idxmap.h +4 -18
  161. data/vendor/libgit2/src/ignore.c +9 -9
  162. data/vendor/libgit2/src/index.c +280 -198
  163. data/vendor/libgit2/src/index.h +16 -0
  164. data/vendor/libgit2/src/indexer.c +311 -139
  165. data/vendor/libgit2/src/integer.h +32 -22
  166. data/vendor/libgit2/src/iterator.c +116 -49
  167. data/vendor/libgit2/src/iterator.h +15 -0
  168. data/vendor/libgit2/src/khash.h +3 -1
  169. data/vendor/libgit2/src/mailmap.c +485 -0
  170. data/vendor/libgit2/src/mailmap.h +35 -0
  171. data/vendor/libgit2/src/merge.c +89 -59
  172. data/vendor/libgit2/src/merge_driver.c +7 -7
  173. data/vendor/libgit2/src/merge_file.c +1 -1
  174. data/vendor/libgit2/src/mwindow.c +8 -8
  175. data/vendor/libgit2/src/netops.c +22 -13
  176. data/vendor/libgit2/src/netops.h +2 -0
  177. data/vendor/libgit2/src/notes.c +15 -10
  178. data/vendor/libgit2/src/object.c +118 -67
  179. data/vendor/libgit2/src/object.h +20 -9
  180. data/vendor/libgit2/src/object_api.c +8 -8
  181. data/vendor/libgit2/src/odb.c +72 -72
  182. data/vendor/libgit2/src/odb.h +7 -7
  183. data/vendor/libgit2/src/odb_loose.c +46 -46
  184. data/vendor/libgit2/src/odb_mempack.c +14 -14
  185. data/vendor/libgit2/src/odb_pack.c +14 -10
  186. data/vendor/libgit2/src/offmap.c +30 -0
  187. data/vendor/libgit2/src/offmap.h +20 -11
  188. data/vendor/libgit2/src/oid.c +6 -6
  189. data/vendor/libgit2/src/oidmap.c +20 -0
  190. data/vendor/libgit2/src/oidmap.h +9 -12
  191. data/vendor/libgit2/src/pack-objects.c +71 -63
  192. data/vendor/libgit2/src/pack-objects.h +1 -7
  193. data/vendor/libgit2/src/pack.c +58 -58
  194. data/vendor/libgit2/src/pack.h +6 -6
  195. data/vendor/libgit2/src/parse.h +1 -1
  196. data/vendor/libgit2/src/patch.c +3 -3
  197. data/vendor/libgit2/src/patch_generate.c +18 -18
  198. data/vendor/libgit2/src/patch_parse.c +13 -13
  199. data/vendor/libgit2/src/path.c +93 -225
  200. data/vendor/libgit2/src/path.h +2 -84
  201. data/vendor/libgit2/src/pathspec.c +6 -6
  202. data/vendor/libgit2/src/posix.c +3 -3
  203. data/vendor/libgit2/src/proxy.c +1 -1
  204. data/vendor/libgit2/src/push.c +27 -26
  205. data/vendor/libgit2/src/push.h +2 -1
  206. data/vendor/libgit2/src/reader.c +265 -0
  207. data/vendor/libgit2/src/reader.h +107 -0
  208. data/vendor/libgit2/src/rebase.c +49 -52
  209. data/vendor/libgit2/src/refdb.c +3 -3
  210. data/vendor/libgit2/src/refdb_fs.c +181 -103
  211. data/vendor/libgit2/src/reflog.c +3 -3
  212. data/vendor/libgit2/src/refs.c +98 -74
  213. data/vendor/libgit2/src/refs.h +5 -3
  214. data/vendor/libgit2/src/refspec.c +47 -21
  215. data/vendor/libgit2/src/refspec.h +1 -1
  216. data/vendor/libgit2/src/remote.c +219 -166
  217. data/vendor/libgit2/src/remote.h +9 -0
  218. data/vendor/libgit2/src/repository.c +173 -133
  219. data/vendor/libgit2/src/repository.h +6 -3
  220. data/vendor/libgit2/src/reset.c +8 -8
  221. data/vendor/libgit2/src/revert.c +6 -6
  222. data/vendor/libgit2/src/revparse.c +30 -30
  223. data/vendor/libgit2/src/revwalk.c +60 -30
  224. data/vendor/libgit2/src/revwalk.h +2 -1
  225. data/vendor/libgit2/src/settings.c +42 -10
  226. data/vendor/libgit2/src/signature.c +11 -11
  227. data/vendor/libgit2/src/sortedcache.c +13 -13
  228. data/vendor/libgit2/src/stash.c +91 -45
  229. data/vendor/libgit2/src/status.c +13 -13
  230. data/vendor/libgit2/src/stdalloc.c +120 -0
  231. data/vendor/libgit2/src/{streams/curl.h → stdalloc.h} +6 -6
  232. data/vendor/libgit2/src/stream.h +17 -2
  233. data/vendor/libgit2/src/streams/mbedtls.c +483 -0
  234. data/vendor/libgit2/src/streams/mbedtls.h +23 -0
  235. data/vendor/libgit2/src/streams/openssl.c +204 -114
  236. data/vendor/libgit2/src/streams/openssl.h +4 -108
  237. data/vendor/libgit2/src/streams/registry.c +118 -0
  238. data/vendor/libgit2/src/streams/registry.h +19 -0
  239. data/vendor/libgit2/src/streams/socket.c +54 -29
  240. data/vendor/libgit2/src/streams/stransport.c +57 -32
  241. data/vendor/libgit2/src/streams/stransport.h +5 -0
  242. data/vendor/libgit2/src/streams/tls.c +50 -19
  243. data/vendor/libgit2/src/streams/tls.h +12 -4
  244. data/vendor/libgit2/src/strmap.c +22 -2
  245. data/vendor/libgit2/src/strmap.h +18 -15
  246. data/vendor/libgit2/src/submodule.c +179 -155
  247. data/vendor/libgit2/src/sysdir.c +18 -18
  248. data/vendor/libgit2/src/tag.c +31 -26
  249. data/vendor/libgit2/src/tag.h +2 -1
  250. data/vendor/libgit2/src/trace.c +1 -1
  251. data/vendor/libgit2/src/trace.h +1 -1
  252. data/vendor/libgit2/src/trailer.c +6 -6
  253. data/vendor/libgit2/src/transaction.c +23 -23
  254. data/vendor/libgit2/src/transport.c +5 -5
  255. data/vendor/libgit2/src/transports/auth.c +7 -4
  256. data/vendor/libgit2/src/transports/auth.h +1 -1
  257. data/vendor/libgit2/src/transports/auth_negotiate.c +12 -11
  258. data/vendor/libgit2/src/transports/cred.c +18 -18
  259. data/vendor/libgit2/src/transports/git.c +15 -15
  260. data/vendor/libgit2/src/transports/http.c +606 -216
  261. data/vendor/libgit2/src/transports/http.h +2 -0
  262. data/vendor/libgit2/src/transports/local.c +26 -26
  263. data/vendor/libgit2/src/transports/smart.c +54 -31
  264. data/vendor/libgit2/src/transports/smart.h +1 -2
  265. data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
  266. data/vendor/libgit2/src/transports/smart_protocol.c +61 -57
  267. data/vendor/libgit2/src/transports/ssh.c +34 -33
  268. data/vendor/libgit2/src/transports/winhttp.c +99 -119
  269. data/vendor/libgit2/src/tree-cache.c +5 -5
  270. data/vendor/libgit2/src/tree.c +96 -121
  271. data/vendor/libgit2/src/tree.h +1 -12
  272. data/vendor/libgit2/src/unix/map.c +2 -2
  273. data/vendor/libgit2/src/util.c +22 -6
  274. data/vendor/libgit2/src/util.h +12 -135
  275. data/vendor/libgit2/src/vector.c +4 -4
  276. data/vendor/libgit2/src/win32/dir.c +3 -3
  277. data/vendor/libgit2/src/win32/findfile.c +3 -3
  278. data/vendor/libgit2/src/win32/map.c +6 -6
  279. data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
  280. data/vendor/libgit2/src/win32/path_w32.c +101 -7
  281. data/vendor/libgit2/src/win32/path_w32.h +18 -0
  282. data/vendor/libgit2/src/win32/posix_w32.c +24 -43
  283. data/vendor/libgit2/src/win32/w32_buffer.c +2 -2
  284. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +96 -2
  285. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
  286. data/vendor/libgit2/src/win32/w32_stack.c +2 -2
  287. data/vendor/libgit2/src/win32/w32_util.c +1 -69
  288. data/vendor/libgit2/src/win32/w32_util.h +1 -19
  289. data/vendor/libgit2/src/worktree.c +75 -54
  290. data/vendor/libgit2/src/worktree.h +2 -0
  291. data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
  292. data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
  293. data/vendor/libgit2/src/xdiff/xmerge.c +15 -15
  294. data/vendor/libgit2/src/zstream.c +4 -4
  295. metadata +33 -7
  296. data/vendor/libgit2/src/config_file.h +0 -73
  297. data/vendor/libgit2/src/streams/curl.c +0 -385
@@ -123,7 +123,7 @@ static int read_tree_internal(git_tree_cache **out,
123
123
  unsigned int i;
124
124
 
125
125
  tree->children = git_pool_malloc(pool, tree->children_count * sizeof(git_tree_cache *));
126
- GITERR_CHECK_ALLOC(tree->children);
126
+ GIT_ERROR_CHECK_ALLOC(tree->children);
127
127
 
128
128
  memset(tree->children, 0x0, tree->children_count * sizeof(git_tree_cache *));
129
129
 
@@ -138,7 +138,7 @@ static int read_tree_internal(git_tree_cache **out,
138
138
  return 0;
139
139
 
140
140
  corrupted:
141
- giterr_set(GITERR_INDEX, "corrupted TREE extension in index");
141
+ git_error_set(GIT_ERROR_INDEX, "corrupted TREE extension in index");
142
142
  return -1;
143
143
  }
144
144
 
@@ -150,7 +150,7 @@ int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer
150
150
  return -1;
151
151
 
152
152
  if (buffer < buffer_end) {
153
- giterr_set(GITERR_INDEX, "corrupted TREE extension in index (unexpected trailing data)");
153
+ git_error_set(GIT_ERROR_INDEX, "corrupted TREE extension in index (unexpected trailing data)");
154
154
  return -1;
155
155
  }
156
156
 
@@ -184,7 +184,7 @@ static int read_tree_recursive(git_tree_cache *cache, const git_tree *tree, git_
184
184
 
185
185
  cache->children_count = ntrees;
186
186
  cache->children = git_pool_mallocz(pool, ntrees * sizeof(git_tree_cache *));
187
- GITERR_CHECK_ALLOC(cache->children);
187
+ GIT_ERROR_CHECK_ALLOC(cache->children);
188
188
 
189
189
  j = 0;
190
190
  for (i = 0; i < nentries; i++) {
@@ -237,7 +237,7 @@ int git_tree_cache_new(git_tree_cache **out, const char *name, git_pool *pool)
237
237
 
238
238
  name_len = strlen(name);
239
239
  tree = git_pool_malloc(pool, sizeof(git_tree_cache) + name_len + 1);
240
- GITERR_CHECK_ALLOC(tree);
240
+ GIT_ERROR_CHECK_ALLOC(tree);
241
241
 
242
242
  memset(tree, 0x0, sizeof(git_tree_cache));
243
243
  /* NUL-terminated tree name */
@@ -18,7 +18,7 @@
18
18
  #define MAX_FILEMODE_BYTES 6
19
19
 
20
20
  #define TREE_ENTRY_CHECK_NAMELEN(n) \
21
- if (n > UINT16_MAX) { giterr_set(GITERR_INVALID, "tree entry path too long"); }
21
+ if (n > UINT16_MAX) { git_error_set(GIT_ERROR_INVALID, "tree entry path too long"); }
22
22
 
23
23
  static bool valid_filemode(const int filemode)
24
24
  {
@@ -74,14 +74,6 @@ int git_tree_entry_cmp(const git_tree_entry *e1, const git_tree_entry *e2)
74
74
  return entry_sort_cmp(e1, e2);
75
75
  }
76
76
 
77
- int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2)
78
- {
79
- return git_path_cmp(
80
- e1->filename, e1->filename_len, git_tree_entry__is_tree(e1),
81
- e2->filename, e2->filename_len, git_tree_entry__is_tree(e2),
82
- git__strncasecmp);
83
- }
84
-
85
77
  /**
86
78
  * Allocate a new self-contained entry, with enough space after it to
87
79
  * store the filename and the id.
@@ -279,16 +271,16 @@ const git_oid *git_tree_entry_id(const git_tree_entry *entry)
279
271
  return entry->oid;
280
272
  }
281
273
 
282
- git_otype git_tree_entry_type(const git_tree_entry *entry)
274
+ git_object_t git_tree_entry_type(const git_tree_entry *entry)
283
275
  {
284
276
  assert(entry);
285
277
 
286
278
  if (S_ISGITLINK(entry->attr))
287
- return GIT_OBJ_COMMIT;
279
+ return GIT_OBJECT_COMMIT;
288
280
  else if (S_ISDIR(entry->attr))
289
- return GIT_OBJ_TREE;
281
+ return GIT_OBJECT_TREE;
290
282
  else
291
- return GIT_OBJ_BLOB;
283
+ return GIT_OBJECT_BLOB;
292
284
  }
293
285
 
294
286
  int git_tree_entry_to_object(
@@ -297,7 +289,7 @@ int git_tree_entry_to_object(
297
289
  const git_tree_entry *entry)
298
290
  {
299
291
  assert(entry && object_out);
300
- return git_object_lookup(object_out, repo, entry->oid, GIT_OBJ_ANY);
292
+ return git_object_lookup(object_out, repo, entry->oid, GIT_OBJECT_ANY);
301
293
  }
302
294
 
303
295
  static const git_tree_entry *entry_fromname(
@@ -342,41 +334,6 @@ const git_tree_entry *git_tree_entry_byid(
342
334
  return NULL;
343
335
  }
344
336
 
345
- int git_tree__prefix_position(const git_tree *tree, const char *path)
346
- {
347
- struct tree_key_search ksearch;
348
- size_t at_pos, path_len;
349
-
350
- if (!path)
351
- return 0;
352
-
353
- path_len = strlen(path);
354
- TREE_ENTRY_CHECK_NAMELEN(path_len);
355
-
356
- ksearch.filename = path;
357
- ksearch.filename_len = (uint16_t)path_len;
358
-
359
- /* Find tree entry with appropriate prefix */
360
- git_array_search(
361
- &at_pos, tree->entries, &homing_search_cmp, &ksearch);
362
-
363
- for (; at_pos < tree->entries.size; ++at_pos) {
364
- const git_tree_entry *entry = git_array_get(tree->entries, at_pos);
365
- if (homing_search_cmp(&ksearch, entry) < 0)
366
- break;
367
- }
368
-
369
- for (; at_pos > 0; --at_pos) {
370
- const git_tree_entry *entry =
371
- git_array_get(tree->entries, at_pos - 1);
372
-
373
- if (homing_search_cmp(&ksearch, entry) > 0)
374
- break;
375
- }
376
-
377
- return (int)at_pos;
378
- }
379
-
380
337
  size_t git_tree_entrycount(const git_tree *tree)
381
338
  {
382
339
  assert(tree);
@@ -393,9 +350,9 @@ unsigned int git_treebuilder_entrycount(git_treebuilder *bld)
393
350
  static int tree_error(const char *str, const char *path)
394
351
  {
395
352
  if (path)
396
- giterr_set(GITERR_TREE, "%s - %s", str, path);
353
+ git_error_set(GIT_ERROR_TREE, "%s - %s", str, path);
397
354
  else
398
- giterr_set(GITERR_TREE, "%s", str);
355
+ git_error_set(GIT_ERROR_TREE, "%s", str);
399
356
  return -1;
400
357
  }
401
358
 
@@ -418,20 +375,18 @@ static int parse_mode(uint16_t *mode_out, const char *buffer, size_t buffer_len,
418
375
  return 0;
419
376
  }
420
377
 
421
- int git_tree__parse(void *_tree, git_odb_object *odb_obj)
378
+ int git_tree__parse_raw(void *_tree, const char *data, size_t size)
422
379
  {
423
380
  git_tree *tree = _tree;
424
381
  const char *buffer;
425
382
  const char *buffer_end;
426
383
 
427
- if (git_odb_object_dup(&tree->odb_obj, odb_obj) < 0)
428
- return -1;
429
-
430
- buffer = git_odb_object_data(tree->odb_obj);
431
- buffer_end = buffer + git_odb_object_size(tree->odb_obj);
384
+ buffer = data;
385
+ buffer_end = buffer + size;
432
386
 
387
+ tree->odb_obj = NULL;
433
388
  git_array_init_to_size(tree->entries, DEFAULT_TREE_SIZE);
434
- GITERR_CHECK_ARRAY(tree->entries);
389
+ GIT_ERROR_CHECK_ARRAY(tree->entries);
435
390
 
436
391
  while (buffer < buffer_end) {
437
392
  git_tree_entry *entry;
@@ -448,7 +403,7 @@ int git_tree__parse(void *_tree, git_odb_object *odb_obj)
448
403
  if ((nul = memchr(buffer, 0, buffer_end - buffer)) == NULL)
449
404
  return tree_error("failed to parse tree: object is corrupted", NULL);
450
405
 
451
- if ((filename_len = nul - buffer) == 0)
406
+ if ((filename_len = nul - buffer) == 0 || filename_len > UINT16_MAX)
452
407
  return tree_error("failed to parse tree: can't parse filename", NULL);
453
408
 
454
409
  if ((buffer_end - (nul + 1)) < GIT_OID_RAWSZ)
@@ -457,10 +412,10 @@ int git_tree__parse(void *_tree, git_odb_object *odb_obj)
457
412
  /* Allocate the entry */
458
413
  {
459
414
  entry = git_array_alloc(tree->entries);
460
- GITERR_CHECK_ALLOC(entry);
415
+ GIT_ERROR_CHECK_ALLOC(entry);
461
416
 
462
417
  entry->attr = attr;
463
- entry->filename_len = filename_len;
418
+ entry->filename_len = (uint16_t)filename_len;
464
419
  entry->filename = buffer;
465
420
  entry->oid = (git_oid *) ((char *) buffer + filename_len + 1);
466
421
  }
@@ -472,6 +427,21 @@ int git_tree__parse(void *_tree, git_odb_object *odb_obj)
472
427
  return 0;
473
428
  }
474
429
 
430
+ int git_tree__parse(void *_tree, git_odb_object *odb_obj)
431
+ {
432
+ git_tree *tree = _tree;
433
+
434
+ if ((git_tree__parse_raw(tree,
435
+ git_odb_object_data(odb_obj),
436
+ git_odb_object_size(odb_obj))) < 0)
437
+ return -1;
438
+
439
+ if (git_odb_object_dup(&tree->odb_obj, odb_obj) < 0)
440
+ return -1;
441
+
442
+ return 0;
443
+ }
444
+
475
445
  static size_t find_next_dir(const char *dirname, git_index *index, size_t start)
476
446
  {
477
447
  size_t dirlen, i, entries = git_index_entrycount(index);
@@ -489,6 +459,36 @@ static size_t find_next_dir(const char *dirname, git_index *index, size_t start)
489
459
  return i;
490
460
  }
491
461
 
462
+ static git_object_t otype_from_mode(git_filemode_t filemode)
463
+ {
464
+ switch (filemode) {
465
+ case GIT_FILEMODE_TREE:
466
+ return GIT_OBJECT_TREE;
467
+ case GIT_FILEMODE_COMMIT:
468
+ return GIT_OBJECT_COMMIT;
469
+ default:
470
+ return GIT_OBJECT_BLOB;
471
+ }
472
+ }
473
+
474
+ static int check_entry(git_repository *repo, const char *filename, const git_oid *id, git_filemode_t filemode)
475
+ {
476
+ if (!valid_filemode(filemode))
477
+ return tree_error("failed to insert entry: invalid filemode for file", filename);
478
+
479
+ if (!valid_entry_name(repo, filename))
480
+ return tree_error("failed to insert entry: invalid name for a tree entry", filename);
481
+
482
+ if (git_oid_iszero(id))
483
+ return tree_error("failed to insert entry: invalid null OID", filename);
484
+
485
+ if (filemode != GIT_FILEMODE_COMMIT &&
486
+ !git_object__is_valid(repo, id, otype_from_mode(filemode)))
487
+ return tree_error("failed to insert entry: invalid object specified", filename);
488
+
489
+ return 0;
490
+ }
491
+
492
492
  static int append_entry(
493
493
  git_treebuilder *bld,
494
494
  const char *filename,
@@ -499,21 +499,18 @@ static int append_entry(
499
499
  git_tree_entry *entry;
500
500
  int error = 0;
501
501
 
502
- if (validate && !valid_entry_name(bld->repo, filename))
503
- return tree_error("failed to insert entry: invalid name for a tree entry", filename);
504
-
505
- if (validate && git_oid_iszero(id))
506
- return tree_error("failed to insert entry: invalid null OID for a tree entry", filename);
502
+ if (validate && ((error = check_entry(bld->repo, filename, id, filemode)) < 0))
503
+ return error;
507
504
 
508
505
  entry = alloc_entry(filename, strlen(filename), id);
509
- GITERR_CHECK_ALLOC(entry);
506
+ GIT_ERROR_CHECK_ALLOC(entry);
510
507
 
511
508
  entry->attr = (uint16_t)filemode;
512
509
 
513
510
  git_strmap_insert(bld->map, entry->filename, entry, &error);
514
511
  if (error < 0) {
515
512
  git_tree_entry_free(entry);
516
- giterr_set(GITERR_TREE, "failed to append entry %s to the tree builder", filename);
513
+ git_error_set(GIT_ERROR_TREE, "failed to append entry %s to the tree builder", filename);
517
514
  return -1;
518
515
  }
519
516
 
@@ -576,7 +573,7 @@ static int write_tree(
576
573
  char *subdir, *last_comp;
577
574
 
578
575
  subdir = git__strndup(entry->path, next_slash - entry->path);
579
- GITERR_CHECK_ALLOC(subdir);
576
+ GIT_ERROR_CHECK_ALLOC(subdir);
580
577
 
581
578
  /* Write out the subtree */
582
579
  written = write_tree(&sub_oid, repo, index, subdir, i, shared_buf);
@@ -633,7 +630,7 @@ int git_tree__write_index(
633
630
  assert(oid && index && repo);
634
631
 
635
632
  if (git_index_has_conflicts(index)) {
636
- giterr_set(GITERR_INDEX,
633
+ git_error_set(GIT_ERROR_INDEX,
637
634
  "cannot create a tree from a not fully merged index.");
638
635
  return GIT_EUNMERGED;
639
636
  }
@@ -654,7 +651,7 @@ int git_tree__write_index(
654
651
  }
655
652
 
656
653
  ret = write_tree(oid, repo, index, "", 0, &shared_buf);
657
- git_buf_free(&shared_buf);
654
+ git_buf_dispose(&shared_buf);
658
655
 
659
656
  if (old_ignore_case)
660
657
  git_index__set_ignore_case(index, true);
@@ -687,7 +684,7 @@ int git_treebuilder_new(
687
684
  assert(builder_p && repo);
688
685
 
689
686
  bld = git__calloc(1, sizeof(git_treebuilder));
690
- GITERR_CHECK_ALLOC(bld);
687
+ GIT_ERROR_CHECK_ALLOC(bld);
691
688
 
692
689
  bld->repo = repo;
693
690
 
@@ -717,18 +714,6 @@ on_error:
717
714
  return -1;
718
715
  }
719
716
 
720
- static git_otype otype_from_mode(git_filemode_t filemode)
721
- {
722
- switch (filemode) {
723
- case GIT_FILEMODE_TREE:
724
- return GIT_OBJ_TREE;
725
- case GIT_FILEMODE_COMMIT:
726
- return GIT_OBJ_COMMIT;
727
- default:
728
- return GIT_OBJ_BLOB;
729
- }
730
- }
731
-
732
717
  int git_treebuilder_insert(
733
718
  const git_tree_entry **entry_out,
734
719
  git_treebuilder *bld,
@@ -738,22 +723,12 @@ int git_treebuilder_insert(
738
723
  {
739
724
  git_tree_entry *entry;
740
725
  int error;
741
- git_strmap_iter pos;
726
+ size_t pos;
742
727
 
743
728
  assert(bld && id && filename);
744
729
 
745
- if (!valid_filemode(filemode))
746
- return tree_error("failed to insert entry: invalid filemode for file", filename);
747
-
748
- if (!valid_entry_name(bld->repo, filename))
749
- return tree_error("failed to insert entry: invalid name for a tree entry", filename);
750
-
751
- if (git_oid_iszero(id))
752
- return tree_error("failed to insert entry: invalid null OID", filename);
753
-
754
- if (filemode != GIT_FILEMODE_COMMIT &&
755
- !git_object__is_valid(bld->repo, id, otype_from_mode(filemode)))
756
- return tree_error("failed to insert entry: invalid object specified", filename);
730
+ if ((error = check_entry(bld->repo, filename, id, filemode)) < 0)
731
+ return error;
757
732
 
758
733
  pos = git_strmap_lookup_index(bld->map, filename);
759
734
  if (git_strmap_valid_index(bld->map, pos)) {
@@ -761,13 +736,13 @@ int git_treebuilder_insert(
761
736
  git_oid_cpy((git_oid *) entry->oid, id);
762
737
  } else {
763
738
  entry = alloc_entry(filename, strlen(filename), id);
764
- GITERR_CHECK_ALLOC(entry);
739
+ GIT_ERROR_CHECK_ALLOC(entry);
765
740
 
766
741
  git_strmap_insert(bld->map, entry->filename, entry, &error);
767
742
 
768
743
  if (error < 0) {
769
744
  git_tree_entry_free(entry);
770
- giterr_set(GITERR_TREE, "failed to insert %s", filename);
745
+ git_error_set(GIT_ERROR_TREE, "failed to insert %s", filename);
771
746
  return -1;
772
747
  }
773
748
  }
@@ -783,7 +758,7 @@ int git_treebuilder_insert(
783
758
  static git_tree_entry *treebuilder_get(git_treebuilder *bld, const char *filename)
784
759
  {
785
760
  git_tree_entry *entry = NULL;
786
- git_strmap_iter pos;
761
+ size_t pos;
787
762
 
788
763
  assert(bld && filename);
789
764
 
@@ -819,7 +794,7 @@ int git_treebuilder_write(git_oid *oid, git_treebuilder *bld)
819
794
 
820
795
  error = git_treebuilder_write_with_buffer(oid, bld, &buffer);
821
796
 
822
- git_buf_free(&buffer);
797
+ git_buf_dispose(&buffer);
823
798
  return error;
824
799
  }
825
800
 
@@ -865,7 +840,7 @@ int git_treebuilder_write_with_buffer(git_oid *oid, git_treebuilder *bld, git_bu
865
840
  }
866
841
 
867
842
  if ((error = git_repository_odb__weakptr(&odb, bld->repo)) == 0)
868
- error = git_odb_write(oid, odb, tree->ptr, tree->size, GIT_OBJ_TREE);
843
+ error = git_odb_write(oid, odb, tree->ptr, tree->size, GIT_OBJECT_TREE);
869
844
 
870
845
  out:
871
846
  git_vector_free(&entries);
@@ -935,14 +910,14 @@ int git_tree_entry_bypath(
935
910
  filename_len = subpath_len(path);
936
911
 
937
912
  if (filename_len == 0) {
938
- giterr_set(GITERR_TREE, "invalid tree path given");
913
+ git_error_set(GIT_ERROR_TREE, "invalid tree path given");
939
914
  return GIT_ENOTFOUND;
940
915
  }
941
916
 
942
917
  entry = entry_fromname(root, path, filename_len);
943
918
 
944
919
  if (entry == NULL) {
945
- giterr_set(GITERR_TREE,
920
+ git_error_set(GIT_ERROR_TREE,
946
921
  "the path '%.*s' does not exist in the given tree", (int) filename_len, path);
947
922
  return GIT_ENOTFOUND;
948
923
  }
@@ -952,7 +927,7 @@ int git_tree_entry_bypath(
952
927
  /* If there are more components in the path...
953
928
  * then this entry *must* be a tree */
954
929
  if (!git_tree_entry__is_tree(entry)) {
955
- giterr_set(GITERR_TREE,
930
+ git_error_set(GIT_ERROR_TREE,
956
931
  "the path '%.*s' exists but is not a tree", (int) filename_len, path);
957
932
  return GIT_ENOTFOUND;
958
933
  }
@@ -997,7 +972,7 @@ static int tree_walk(
997
972
  if (preorder) {
998
973
  error = callback(path->ptr, entry, payload);
999
974
  if (error < 0) { /* negative value stops iteration */
1000
- giterr_set_after_callback_function(error, "git_tree_walk");
975
+ git_error_set_after_callback_function(error, "git_tree_walk");
1001
976
  break;
1002
977
  }
1003
978
  if (error > 0) { /* positive value skips this entry */
@@ -1033,7 +1008,7 @@ static int tree_walk(
1033
1008
  if (!preorder) {
1034
1009
  error = callback(path->ptr, entry, payload);
1035
1010
  if (error < 0) { /* negative value stops iteration */
1036
- giterr_set_after_callback_function(error, "git_tree_walk");
1011
+ git_error_set_after_callback_function(error, "git_tree_walk");
1037
1012
  break;
1038
1013
  }
1039
1014
  error = 0;
@@ -1053,14 +1028,14 @@ int git_tree_walk(
1053
1028
  git_buf root_path = GIT_BUF_INIT;
1054
1029
 
1055
1030
  if (mode != GIT_TREEWALK_POST && mode != GIT_TREEWALK_PRE) {
1056
- giterr_set(GITERR_INVALID, "invalid walking mode for tree walk");
1031
+ git_error_set(GIT_ERROR_INVALID, "invalid walking mode for tree walk");
1057
1032
  return -1;
1058
1033
  }
1059
1034
 
1060
1035
  error = tree_walk(
1061
1036
  tree, callback, &root_path, payload, (mode == GIT_TREEWALK_PRE));
1062
1037
 
1063
- git_buf_free(&root_path);
1038
+ git_buf_dispose(&root_path);
1064
1039
 
1065
1040
  return error;
1066
1041
  }
@@ -1077,7 +1052,7 @@ static int on_dup_entry(void **old, void *new)
1077
1052
  {
1078
1053
  GIT_UNUSED(old); GIT_UNUSED(new);
1079
1054
 
1080
- giterr_set(GITERR_TREE, "duplicate entries given for update");
1055
+ git_error_set(GIT_ERROR_TREE, "duplicate entries given for update");
1081
1056
  return -1;
1082
1057
  }
1083
1058
 
@@ -1146,14 +1121,14 @@ static int create_popped_tree(tree_stack_entry *current, tree_stack_entry *poppe
1146
1121
  git_buf_puts(component, popped->name);
1147
1122
  git__free(popped->name);
1148
1123
 
1149
- GITERR_CHECK_ALLOC(component->ptr);
1124
+ GIT_ERROR_CHECK_ALLOC(component->ptr);
1150
1125
 
1151
1126
  /* Error out if this would create a D/F conflict in this update */
1152
1127
  if (current->tree) {
1153
1128
  const git_tree_entry *to_replace;
1154
1129
  to_replace = git_tree_entry_byname(current->tree, component->ptr);
1155
- if (to_replace && git_tree_entry_type(to_replace) != GIT_OBJ_TREE) {
1156
- giterr_set(GITERR_TREE, "D/F conflict when updating tree");
1130
+ if (to_replace && git_tree_entry_type(to_replace) != GIT_OBJECT_TREE) {
1131
+ git_error_set(GIT_ERROR_TREE, "D/F conflict when updating tree");
1157
1132
  return -1;
1158
1133
  }
1159
1134
  }
@@ -1180,7 +1155,7 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
1180
1155
  }
1181
1156
 
1182
1157
  root_elem = git_array_alloc(stack);
1183
- GITERR_CHECK_ALLOC(root_elem);
1158
+ GIT_ERROR_CHECK_ALLOC(root_elem);
1184
1159
  memset(root_elem, 0, sizeof(*root_elem));
1185
1160
 
1186
1161
  if (baseline && (error = git_tree_dup(&root_elem->tree, baseline)) < 0)
@@ -1229,14 +1204,14 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
1229
1204
  if (!entry)
1230
1205
  entry = treebuilder_get(last->bld, component.ptr);
1231
1206
 
1232
- if (entry && git_tree_entry_type(entry) != GIT_OBJ_TREE) {
1233
- giterr_set(GITERR_TREE, "D/F conflict when updating tree");
1207
+ if (entry && git_tree_entry_type(entry) != GIT_OBJECT_TREE) {
1208
+ git_error_set(GIT_ERROR_TREE, "D/F conflict when updating tree");
1234
1209
  error = -1;
1235
1210
  goto cleanup;
1236
1211
  }
1237
1212
 
1238
1213
  new_entry = git_array_alloc(stack);
1239
- GITERR_CHECK_ALLOC(new_entry);
1214
+ GIT_ERROR_CHECK_ALLOC(new_entry);
1240
1215
  memset(new_entry, 0, sizeof(*new_entry));
1241
1216
 
1242
1217
  new_entry->tree = NULL;
@@ -1247,7 +1222,7 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
1247
1222
  goto cleanup;
1248
1223
 
1249
1224
  new_entry->name = git__strdup(component.ptr);
1250
- GITERR_CHECK_ALLOC(new_entry->name);
1225
+ GIT_ERROR_CHECK_ALLOC(new_entry->name);
1251
1226
 
1252
1227
  /* Get to the start of the next component */
1253
1228
  path += component.size + 1;
@@ -1263,7 +1238,7 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
1263
1238
  const git_tree_entry *e = git_treebuilder_get(last->bld, basename);
1264
1239
  if (e && git_tree_entry_type(e) != git_object__type_from_filemode(update->filemode)) {
1265
1240
  git__free(basename);
1266
- giterr_set(GITERR_TREE, "cannot replace '%s' with '%s' at '%s'",
1241
+ git_error_set(GIT_ERROR_TREE, "cannot replace '%s' with '%s' at '%s'",
1267
1242
  git_object_type2string(git_tree_entry_type(e)),
1268
1243
  git_object_type2string(git_object__type_from_filemode(update->filemode)),
1269
1244
  update->path);
@@ -1283,7 +1258,7 @@ int git_tree_create_updated(git_oid *out, git_repository *repo, git_tree *baseli
1283
1258
  break;
1284
1259
  }
1285
1260
  default:
1286
- giterr_set(GITERR_TREE, "unknown action for update");
1261
+ git_error_set(GIT_ERROR_TREE, "unknown action for update");
1287
1262
  error = -1;
1288
1263
  goto cleanup;
1289
1264
  }
@@ -1325,7 +1300,7 @@ cleanup:
1325
1300
  }
1326
1301
  }
1327
1302
 
1328
- git_buf_free(&component);
1303
+ git_buf_dispose(&component);
1329
1304
  git_array_clear(stack);
1330
1305
  git_vector_free(&entries);
1331
1306
  return error;