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
@@ -181,7 +181,7 @@ static int merge_driver_registry_insert(
181
181
  git_merge_driver_entry *entry;
182
182
 
183
183
  entry = git__calloc(1, sizeof(git_merge_driver_entry) + strlen(name) + 1);
184
- GITERR_CHECK_ALLOC(entry);
184
+ GIT_ERROR_CHECK_ALLOC(entry);
185
185
 
186
186
  strcpy(entry->name, name);
187
187
  entry->driver = driver;
@@ -265,12 +265,12 @@ int git_merge_driver_register(const char *name, git_merge_driver *driver)
265
265
  assert(name && driver);
266
266
 
267
267
  if (git_rwlock_wrlock(&merge_driver_registry.lock) < 0) {
268
- giterr_set(GITERR_OS, "failed to lock merge driver registry");
268
+ git_error_set(GIT_ERROR_OS, "failed to lock merge driver registry");
269
269
  return -1;
270
270
  }
271
271
 
272
272
  if (!merge_driver_registry_find(NULL, name)) {
273
- giterr_set(GITERR_MERGE, "attempt to reregister existing driver '%s'",
273
+ git_error_set(GIT_ERROR_MERGE, "attempt to reregister existing driver '%s'",
274
274
  name);
275
275
  error = GIT_EEXISTS;
276
276
  goto done;
@@ -290,12 +290,12 @@ int git_merge_driver_unregister(const char *name)
290
290
  int error = 0;
291
291
 
292
292
  if (git_rwlock_wrlock(&merge_driver_registry.lock) < 0) {
293
- giterr_set(GITERR_OS, "failed to lock merge driver registry");
293
+ git_error_set(GIT_ERROR_OS, "failed to lock merge driver registry");
294
294
  return -1;
295
295
  }
296
296
 
297
297
  if ((entry = merge_driver_registry_lookup(&pos, name)) == NULL) {
298
- giterr_set(GITERR_MERGE, "cannot find merge driver '%s' to unregister",
298
+ git_error_set(GIT_ERROR_MERGE, "cannot find merge driver '%s' to unregister",
299
299
  name);
300
300
  error = GIT_ENOTFOUND;
301
301
  goto done;
@@ -332,7 +332,7 @@ git_merge_driver *git_merge_driver_lookup(const char *name)
332
332
  return &git_merge_driver__binary;
333
333
 
334
334
  if (git_rwlock_rdlock(&merge_driver_registry.lock) < 0) {
335
- giterr_set(GITERR_OS, "failed to lock merge driver registry");
335
+ git_error_set(GIT_ERROR_OS, "failed to lock merge driver registry");
336
336
  return NULL;
337
337
  }
338
338
 
@@ -341,7 +341,7 @@ git_merge_driver *git_merge_driver_lookup(const char *name)
341
341
  git_rwlock_rdunlock(&merge_driver_registry.lock);
342
342
 
343
343
  if (entry == NULL) {
344
- giterr_set(GITERR_MERGE, "cannot use an unregistered filter");
344
+ git_error_set(GIT_ERROR_MERGE, "cannot use an unregistered filter");
345
345
  return NULL;
346
346
  }
347
347
 
@@ -130,7 +130,7 @@ static int merge_file__xdiff(
130
130
 
131
131
  if ((xdl_result = xdl_merge(&ancestor_mmfile, &our_mmfile,
132
132
  &their_mmfile, &xmparam, &mmbuffer)) < 0) {
133
- giterr_set(GITERR_MERGE, "failed to merge files");
133
+ git_error_set(GIT_ERROR_MERGE, "failed to merge files");
134
134
  error = -1;
135
135
  goto done;
136
136
  }
@@ -51,14 +51,14 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
51
51
  {
52
52
  int error;
53
53
  char *packname;
54
- git_strmap_iter pos;
54
+ size_t pos;
55
55
  struct git_pack_file *pack;
56
56
 
57
57
  if ((error = git_packfile__name(&packname, path)) < 0)
58
58
  return error;
59
59
 
60
60
  if (git_mutex_lock(&git__mwindow_mutex) < 0) {
61
- giterr_set(GITERR_OS, "failed to lock mwindow mutex");
61
+ git_error_set(GIT_ERROR_OS, "failed to lock mwindow mutex");
62
62
  return -1;
63
63
  }
64
64
 
@@ -97,7 +97,7 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
97
97
  void git_mwindow_put_pack(struct git_pack_file *pack)
98
98
  {
99
99
  int count;
100
- git_strmap_iter pos;
100
+ size_t pos;
101
101
 
102
102
  if (git_mutex_lock(&git__mwindow_mutex) < 0)
103
103
  return;
@@ -122,7 +122,7 @@ void git_mwindow_put_pack(struct git_pack_file *pack)
122
122
  void git_mwindow_free_all(git_mwindow_file *mwf)
123
123
  {
124
124
  if (git_mutex_lock(&git__mwindow_mutex)) {
125
- giterr_set(GITERR_THREAD, "unable to lock mwindow mutex");
125
+ git_error_set(GIT_ERROR_THREAD, "unable to lock mwindow mutex");
126
126
  return;
127
127
  }
128
128
 
@@ -229,7 +229,7 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
229
229
  }
230
230
 
231
231
  if (!lru_w) {
232
- giterr_set(GITERR_OS, "failed to close memory window; couldn't find LRU");
232
+ git_error_set(GIT_ERROR_OS, "failed to close memory window; couldn't find LRU");
233
233
  return -1;
234
234
  }
235
235
 
@@ -324,7 +324,7 @@ unsigned char *git_mwindow_open(
324
324
  git_mwindow *w = *cursor;
325
325
 
326
326
  if (git_mutex_lock(&git__mwindow_mutex)) {
327
- giterr_set(GITERR_THREAD, "unable to lock mwindow mutex");
327
+ git_error_set(GIT_ERROR_THREAD, "unable to lock mwindow mutex");
328
328
  return NULL;
329
329
  }
330
330
 
@@ -376,7 +376,7 @@ int git_mwindow_file_register(git_mwindow_file *mwf)
376
376
  int ret;
377
377
 
378
378
  if (git_mutex_lock(&git__mwindow_mutex)) {
379
- giterr_set(GITERR_THREAD, "unable to lock mwindow mutex");
379
+ git_error_set(GIT_ERROR_THREAD, "unable to lock mwindow mutex");
380
380
  return -1;
381
381
  }
382
382
 
@@ -416,7 +416,7 @@ void git_mwindow_close(git_mwindow **window)
416
416
  git_mwindow *w = *window;
417
417
  if (w) {
418
418
  if (git_mutex_lock(&git__mwindow_mutex)) {
419
- giterr_set(GITERR_THREAD, "unable to lock mwindow mutex");
419
+ git_error_set(GIT_ERROR_THREAD, "unable to lock mwindow mutex");
420
420
  return;
421
421
  }
422
422
 
@@ -119,6 +119,15 @@ int gitno__match_host(const char *pattern, const char *host)
119
119
  return -1;
120
120
  }
121
121
 
122
+ static const char *default_port_http = "80";
123
+ static const char *default_port_https = "443";
124
+
125
+ const char *gitno__default_port(
126
+ gitno_connection_data *data)
127
+ {
128
+ return data->use_ssl ? default_port_https : default_port_http;
129
+ }
130
+
122
131
  static const char *prefix_http = "http://";
123
132
  static const char *prefix_https = "https://";
124
133
 
@@ -141,21 +150,21 @@ int gitno_connection_data_from_url(
141
150
 
142
151
  if (!git__prefixcmp(url, prefix_http)) {
143
152
  path_search_start = url + strlen(prefix_http);
144
- default_port = "80";
153
+ default_port = default_port_http;
145
154
 
146
155
  if (data->use_ssl) {
147
- giterr_set(GITERR_NET, "redirect from HTTPS to HTTP is not allowed");
156
+ git_error_set(GIT_ERROR_NET, "redirect from HTTPS to HTTP is not allowed");
148
157
  goto cleanup;
149
158
  }
150
159
  } else if (!git__prefixcmp(url, prefix_https)) {
151
160
  path_search_start = url + strlen(prefix_https);
152
- default_port = "443";
161
+ default_port = default_port_https;
153
162
  data->use_ssl = true;
154
163
  } else if (url[0] == '/')
155
- default_port = data->use_ssl ? "443" : "80";
164
+ default_port = gitno__default_port(data);
156
165
 
157
166
  if (!default_port) {
158
- giterr_set(GITERR_NET, "unrecognized URL prefix");
167
+ git_error_set(GIT_ERROR_NET, "unrecognized URL prefix");
159
168
  goto cleanup;
160
169
  }
161
170
 
@@ -187,7 +196,7 @@ int gitno_connection_data_from_url(
187
196
 
188
197
  /* Check for errors in the resulting data */
189
198
  if (original_host && url[0] != '/' && strcmp(original_host, data->host)) {
190
- giterr_set(GITERR_NET, "cross host redirect not allowed");
199
+ git_error_set(GIT_ERROR_NET, "cross host redirect not allowed");
191
200
  error = -1;
192
201
  }
193
202
  }
@@ -225,7 +234,7 @@ int gitno_extract_url_parts(
225
234
  int error = 0;
226
235
 
227
236
  if (http_parser_parse_url(url, strlen(url), false, &u)) {
228
- giterr_set(GITERR_NET, "malformed URL '%s'", url);
237
+ git_error_set(GIT_ERROR_NET, "malformed URL '%s'", url);
229
238
  error = GIT_EINVALIDSPEC;
230
239
  goto done;
231
240
  }
@@ -254,7 +263,7 @@ int gitno_extract_url_parts(
254
263
  size_t url_path_len = u.field_data[UF_PATH].len;
255
264
  git_buf_decode_percent(&path, url_path, url_path_len);
256
265
  } else if (path_out) {
257
- giterr_set(GITERR_NET, "invalid url, missing path");
266
+ git_error_set(GIT_ERROR_NET, "invalid url, missing path");
258
267
  error = GIT_EINVALIDSPEC;
259
268
  goto done;
260
269
  }
@@ -292,10 +301,10 @@ int gitno_extract_url_parts(
292
301
  *password_out = git_buf_detach(&password);
293
302
 
294
303
  done:
295
- git_buf_free(&host);
296
- git_buf_free(&port);
297
- git_buf_free(&path);
298
- git_buf_free(&username);
299
- git_buf_free(&password);
304
+ git_buf_dispose(&host);
305
+ git_buf_dispose(&port);
306
+ git_buf_dispose(&path);
307
+ git_buf_dispose(&username);
308
+ git_buf_dispose(&password);
300
309
  return error;
301
310
  }
@@ -96,4 +96,6 @@ int gitno_extract_url_parts(
96
96
  const char *url,
97
97
  const char *default_port);
98
98
 
99
+ const char *gitno__default_port(gitno_connection_data *data);
100
+
99
101
  #endif
@@ -12,10 +12,11 @@
12
12
  #include "config.h"
13
13
  #include "iterator.h"
14
14
  #include "signature.h"
15
+ #include "blob.h"
15
16
 
16
17
  static int note_error_notfound(void)
17
18
  {
18
- giterr_set(GITERR_INVALID, "note could not be found");
19
+ git_error_set(GIT_ERROR_INVALID, "note could not be found");
19
20
  return GIT_ENOTFOUND;
20
21
  }
21
22
 
@@ -226,7 +227,7 @@ static int remove_note_in_tree_enotfound_cb(
226
227
  GIT_UNUSED(note_oid);
227
228
  GIT_UNUSED(fanout);
228
229
 
229
- giterr_set(GITERR_REPOSITORY, "object '%s' has no note", annotated_object_sha);
230
+ git_error_set(GIT_ERROR_REPOSITORY, "object '%s' has no note", annotated_object_sha);
230
231
  return current_error;
231
232
  }
232
233
 
@@ -244,7 +245,7 @@ static int insert_note_in_tree_eexists_cb(git_tree **out,
244
245
  GIT_UNUSED(note_oid);
245
246
  GIT_UNUSED(fanout);
246
247
 
247
- giterr_set(GITERR_REPOSITORY, "note for '%s' exists already", annotated_object_sha);
248
+ git_error_set(GIT_ERROR_REPOSITORY, "note for '%s' exists already", annotated_object_sha);
248
249
  return current_error;
249
250
  }
250
251
 
@@ -285,7 +286,7 @@ static int note_write(
285
286
  git_oid oid;
286
287
  git_tree *tree = NULL;
287
288
 
288
- // TODO: should we apply filters?
289
+ /* TODO: should we apply filters? */
289
290
  /* create note object */
290
291
  if ((error = git_blob_create_frombuffer(&oid, repo, note, strlen(note))) < 0)
291
292
  goto cleanup;
@@ -319,9 +320,10 @@ static int note_new(
319
320
  git_blob *blob)
320
321
  {
321
322
  git_note *note = NULL;
323
+ git_off_t blobsize;
322
324
 
323
325
  note = git__malloc(sizeof(git_note));
324
- GITERR_CHECK_ALLOC(note);
326
+ GIT_ERROR_CHECK_ALLOC(note);
325
327
 
326
328
  git_oid_cpy(&note->id, note_oid);
327
329
 
@@ -329,8 +331,11 @@ static int note_new(
329
331
  git_signature_dup(&note->committer, git_commit_committer(commit)) < 0)
330
332
  return -1;
331
333
 
332
- note->message = git__strndup(git_blob_rawcontent(blob), git_blob_rawsize(blob));
333
- GITERR_CHECK_ALLOC(note->message);
334
+ blobsize = git_blob_rawsize(blob);
335
+ GIT_ERROR_CHECK_BLOBSIZE(blobsize);
336
+
337
+ note->message = git__strndup(git_blob_rawcontent(blob), (size_t)blobsize);
338
+ GIT_ERROR_CHECK_ALLOC(note->message);
334
339
 
335
340
  *out = note;
336
341
  return 0;
@@ -417,7 +422,7 @@ static int normalize_namespace(char **out, git_repository *repo, const char *not
417
422
  {
418
423
  if (notes_ref) {
419
424
  *out = git__strdup(notes_ref);
420
- GITERR_CHECK_ALLOC(*out);
425
+ GIT_ERROR_CHECK_ALLOC(*out);
421
426
  return 0;
422
427
  }
423
428
 
@@ -710,7 +715,7 @@ static int process_entry_path(
710
715
  error = git_oid_fromstr(annotated_object_id, buf.ptr);
711
716
 
712
717
  cleanup:
713
- git_buf_free(&buf);
718
+ git_buf_dispose(&buf);
714
719
  return error;
715
720
  }
716
721
 
@@ -729,7 +734,7 @@ int git_note_foreach(
729
734
 
730
735
  while (!(error = git_note_next(&note_id, &annotated_id, iter))) {
731
736
  if ((error = note_cb(&note_id, &annotated_id, payload)) != 0) {
732
- giterr_set_after_callback(error);
737
+ git_error_set_after_callback(error);
733
738
  break;
734
739
  }
735
740
  }
@@ -12,6 +12,7 @@
12
12
  #include "repository.h"
13
13
 
14
14
  #include "commit.h"
15
+ #include "hash.h"
15
16
  #include "tree.h"
16
17
  #include "blob.h"
17
18
  #include "oid.h"
@@ -19,43 +20,93 @@
19
20
 
20
21
  bool git_object__strict_input_validation = true;
21
22
 
23
+ extern int git_odb_hash(git_oid *out, const void *data, size_t len, git_object_t type);
24
+
22
25
  typedef struct {
23
26
  const char *str; /* type name string */
24
27
  size_t size; /* size in bytes of the object structure */
25
28
 
26
29
  int (*parse)(void *self, git_odb_object *obj);
30
+ int (*parse_raw)(void *self, const char *data, size_t size);
27
31
  void (*free)(void *self);
28
32
  } git_object_def;
29
33
 
30
34
  static git_object_def git_objects_table[] = {
31
- /* 0 = GIT_OBJ__EXT1 */
32
- { "", 0, NULL, NULL },
35
+ /* 0 = GIT_OBJECT__EXT1 */
36
+ { "", 0, NULL, NULL, NULL },
33
37
 
34
- /* 1 = GIT_OBJ_COMMIT */
35
- { "commit", sizeof(git_commit), git_commit__parse, git_commit__free },
38
+ /* 1 = GIT_OBJECT_COMMIT */
39
+ { "commit", sizeof(git_commit), git_commit__parse, git_commit__parse_raw, git_commit__free },
36
40
 
37
- /* 2 = GIT_OBJ_TREE */
38
- { "tree", sizeof(git_tree), git_tree__parse, git_tree__free },
41
+ /* 2 = GIT_OBJECT_TREE */
42
+ { "tree", sizeof(git_tree), git_tree__parse, git_tree__parse_raw, git_tree__free },
39
43
 
40
- /* 3 = GIT_OBJ_BLOB */
41
- { "blob", sizeof(git_blob), git_blob__parse, git_blob__free },
44
+ /* 3 = GIT_OBJECT_BLOB */
45
+ { "blob", sizeof(git_blob), git_blob__parse, git_blob__parse_raw, git_blob__free },
42
46
 
43
- /* 4 = GIT_OBJ_TAG */
44
- { "tag", sizeof(git_tag), git_tag__parse, git_tag__free },
47
+ /* 4 = GIT_OBJECT_TAG */
48
+ { "tag", sizeof(git_tag), git_tag__parse, git_tag__parse_raw, git_tag__free },
45
49
 
46
- /* 5 = GIT_OBJ__EXT2 */
47
- { "", 0, NULL, NULL },
48
- /* 6 = GIT_OBJ_OFS_DELTA */
49
- { "OFS_DELTA", 0, NULL, NULL },
50
- /* 7 = GIT_OBJ_REF_DELTA */
51
- { "REF_DELTA", 0, NULL, NULL },
50
+ /* 5 = GIT_OBJECT__EXT2 */
51
+ { "", 0, NULL, NULL, NULL },
52
+ /* 6 = GIT_OBJECT_OFS_DELTA */
53
+ { "OFS_DELTA", 0, NULL, NULL, NULL },
54
+ /* 7 = GIT_OBJECT_REF_DELTA */
55
+ { "REF_DELTA", 0, NULL, NULL, NULL },
52
56
  };
53
57
 
58
+ int git_object__from_raw(
59
+ git_object **object_out,
60
+ const char *data,
61
+ size_t size,
62
+ git_object_t type)
63
+ {
64
+ git_object_def *def;
65
+ git_object *object;
66
+ size_t object_size;
67
+ int error;
68
+
69
+ assert(object_out);
70
+ *object_out = NULL;
71
+
72
+ /* Validate type match */
73
+ if (type != GIT_OBJECT_BLOB && type != GIT_OBJECT_TREE && type != GIT_OBJECT_COMMIT && type != GIT_OBJECT_TAG) {
74
+ git_error_set(GIT_ERROR_INVALID, "the requested type is invalid");
75
+ return GIT_ENOTFOUND;
76
+ }
77
+
78
+ if ((object_size = git_object__size(type)) == 0) {
79
+ git_error_set(GIT_ERROR_INVALID, "the requested type is invalid");
80
+ return GIT_ENOTFOUND;
81
+ }
82
+
83
+ /* Allocate and initialize base object */
84
+ object = git__calloc(1, object_size);
85
+ GIT_ERROR_CHECK_ALLOC(object);
86
+ object->cached.flags = GIT_CACHE_STORE_PARSED;
87
+ object->cached.type = type;
88
+ git_odb_hash(&object->cached.oid, data, size, type);
89
+
90
+ /* Parse raw object data */
91
+ def = &git_objects_table[type];
92
+ assert(def->free && def->parse_raw);
93
+
94
+ if ((error = def->parse_raw(object, data, size)) < 0) {
95
+ def->free(object);
96
+ return error;
97
+ }
98
+
99
+ git_cached_obj_incref(object);
100
+ *object_out = object;
101
+
102
+ return 0;
103
+ }
104
+
54
105
  int git_object__from_odb_object(
55
106
  git_object **object_out,
56
107
  git_repository *repo,
57
108
  git_odb_object *odb_obj,
58
- git_otype type)
109
+ git_object_t type)
59
110
  {
60
111
  int error;
61
112
  size_t object_size;
@@ -66,20 +117,20 @@ int git_object__from_odb_object(
66
117
  *object_out = NULL;
67
118
 
68
119
  /* Validate type match */
69
- if (type != GIT_OBJ_ANY && type != odb_obj->cached.type) {
70
- giterr_set(GITERR_INVALID,
120
+ if (type != GIT_OBJECT_ANY && type != odb_obj->cached.type) {
121
+ git_error_set(GIT_ERROR_INVALID,
71
122
  "the requested type does not match the type in the ODB");
72
123
  return GIT_ENOTFOUND;
73
124
  }
74
125
 
75
126
  if ((object_size = git_object__size(odb_obj->cached.type)) == 0) {
76
- giterr_set(GITERR_INVALID, "the requested type is invalid");
127
+ git_error_set(GIT_ERROR_INVALID, "the requested type is invalid");
77
128
  return GIT_ENOTFOUND;
78
129
  }
79
130
 
80
131
  /* Allocate and initialize base object */
81
132
  object = git__calloc(1, object_size);
82
- GITERR_CHECK_ALLOC(object);
133
+ GIT_ERROR_CHECK_ALLOC(object);
83
134
 
84
135
  git_oid_cpy(&object->cached.oid, &odb_obj->cached.oid);
85
136
  object->cached.type = odb_obj->cached.type;
@@ -100,7 +151,7 @@ int git_object__from_odb_object(
100
151
 
101
152
  void git_object__free(void *obj)
102
153
  {
103
- git_otype type = ((git_object *)obj)->cached.type;
154
+ git_object_t type = ((git_object *)obj)->cached.type;
104
155
 
105
156
  if (type < 0 || ((size_t)type) >= ARRAY_SIZE(git_objects_table) ||
106
157
  !git_objects_table[type].free)
@@ -114,7 +165,7 @@ int git_object_lookup_prefix(
114
165
  git_repository *repo,
115
166
  const git_oid *id,
116
167
  size_t len,
117
- git_otype type)
168
+ git_object_t type)
118
169
  {
119
170
  git_object *object = NULL;
120
171
  git_odb *odb = NULL;
@@ -124,7 +175,7 @@ int git_object_lookup_prefix(
124
175
  assert(repo && object_out && id);
125
176
 
126
177
  if (len < GIT_OID_MINPREFIXLEN) {
127
- giterr_set(GITERR_OBJECT, "ambiguous lookup - OID prefix is too short");
178
+ git_error_set(GIT_ERROR_OBJECT, "ambiguous lookup - OID prefix is too short");
128
179
  return GIT_EAMBIGUOUS;
129
180
  }
130
181
 
@@ -146,9 +197,9 @@ int git_object_lookup_prefix(
146
197
  if (cached->flags == GIT_CACHE_STORE_PARSED) {
147
198
  object = (git_object *)cached;
148
199
 
149
- if (type != GIT_OBJ_ANY && type != object->cached.type) {
200
+ if (type != GIT_OBJECT_ANY && type != object->cached.type) {
150
201
  git_object_free(object);
151
- giterr_set(GITERR_INVALID,
202
+ git_error_set(GIT_ERROR_INVALID,
152
203
  "the requested type does not match the type in ODB");
153
204
  return GIT_ENOTFOUND;
154
205
  }
@@ -196,7 +247,7 @@ int git_object_lookup_prefix(
196
247
  return error;
197
248
  }
198
249
 
199
- int git_object_lookup(git_object **object_out, git_repository *repo, const git_oid *id, git_otype type) {
250
+ int git_object_lookup(git_object **object_out, git_repository *repo, const git_oid *id, git_object_t type) {
200
251
  return git_object_lookup_prefix(object_out, repo, id, GIT_OID_HEXSZ, type);
201
252
  }
202
253
 
@@ -214,7 +265,7 @@ const git_oid *git_object_id(const git_object *obj)
214
265
  return &obj->cached.oid;
215
266
  }
216
267
 
217
- git_otype git_object_type(const git_object *obj)
268
+ git_object_t git_object_type(const git_object *obj)
218
269
  {
219
270
  assert(obj);
220
271
  return obj->cached.type;
@@ -226,7 +277,7 @@ git_repository *git_object_owner(const git_object *obj)
226
277
  return obj->repo;
227
278
  }
228
279
 
229
- const char *git_object_type2string(git_otype type)
280
+ const char *git_object_type2string(git_object_t type)
230
281
  {
231
282
  if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table))
232
283
  return "";
@@ -234,30 +285,30 @@ const char *git_object_type2string(git_otype type)
234
285
  return git_objects_table[type].str;
235
286
  }
236
287
 
237
- git_otype git_object_string2type(const char *str)
288
+ git_object_t git_object_string2type(const char *str)
238
289
  {
239
290
  if (!str)
240
- return GIT_OBJ_BAD;
291
+ return GIT_OBJECT_INVALID;
241
292
 
242
293
  return git_object_stringn2type(str, strlen(str));
243
294
  }
244
295
 
245
- git_otype git_object_stringn2type(const char *str, size_t len)
296
+ git_object_t git_object_stringn2type(const char *str, size_t len)
246
297
  {
247
298
  size_t i;
248
299
 
249
300
  if (!str || !len || !*str)
250
- return GIT_OBJ_BAD;
301
+ return GIT_OBJECT_INVALID;
251
302
 
252
303
  for (i = 0; i < ARRAY_SIZE(git_objects_table); i++)
253
304
  if (*git_objects_table[i].str &&
254
305
  !git__prefixncmp(str, len, git_objects_table[i].str))
255
- return (git_otype)i;
306
+ return (git_object_t)i;
256
307
 
257
- return GIT_OBJ_BAD;
308
+ return GIT_OBJECT_INVALID;
258
309
  }
259
310
 
260
- int git_object_typeisloose(git_otype type)
311
+ int git_object_typeisloose(git_object_t type)
261
312
  {
262
313
  if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table))
263
314
  return 0;
@@ -265,7 +316,7 @@ int git_object_typeisloose(git_otype type)
265
316
  return (git_objects_table[type].size > 0) ? 1 : 0;
266
317
  }
267
318
 
268
- size_t git_object__size(git_otype type)
319
+ size_t git_object__size(git_object_t type)
269
320
  {
270
321
  if (type < 0 || ((size_t) type) >= ARRAY_SIZE(git_objects_table))
271
322
  return 0;
@@ -275,17 +326,17 @@ size_t git_object__size(git_otype type)
275
326
 
276
327
  static int dereference_object(git_object **dereferenced, git_object *obj)
277
328
  {
278
- git_otype type = git_object_type(obj);
329
+ git_object_t type = git_object_type(obj);
279
330
 
280
331
  switch (type) {
281
- case GIT_OBJ_COMMIT:
332
+ case GIT_OBJECT_COMMIT:
282
333
  return git_commit_tree((git_tree **)dereferenced, (git_commit*)obj);
283
334
 
284
- case GIT_OBJ_TAG:
335
+ case GIT_OBJECT_TAG:
285
336
  return git_tag_target(dereferenced, (git_tag*)obj);
286
337
 
287
- case GIT_OBJ_BLOB:
288
- case GIT_OBJ_TREE:
338
+ case GIT_OBJECT_BLOB:
339
+ case GIT_OBJECT_TREE:
289
340
  return GIT_EPEEL;
290
341
 
291
342
  default:
@@ -293,7 +344,7 @@ static int dereference_object(git_object **dereferenced, git_object *obj)
293
344
  }
294
345
  }
295
346
 
296
- static int peel_error(int error, const git_oid *oid, git_otype type)
347
+ static int peel_error(int error, const git_oid *oid, git_object_t type)
297
348
  {
298
349
  const char *type_name;
299
350
  char hex_oid[GIT_OID_HEXSZ + 1];
@@ -303,29 +354,29 @@ static int peel_error(int error, const git_oid *oid, git_otype type)
303
354
  git_oid_fmt(hex_oid, oid);
304
355
  hex_oid[GIT_OID_HEXSZ] = '\0';
305
356
 
306
- giterr_set(GITERR_OBJECT, "the git_object of id '%s' can not be "
307
- "successfully peeled into a %s (git_otype=%i).", hex_oid, type_name, type);
357
+ git_error_set(GIT_ERROR_OBJECT, "the git_object of id '%s' can not be "
358
+ "successfully peeled into a %s (git_object_t=%i).", hex_oid, type_name, type);
308
359
 
309
360
  return error;
310
361
  }
311
362
 
312
- static int check_type_combination(git_otype type, git_otype target)
363
+ static int check_type_combination(git_object_t type, git_object_t target)
313
364
  {
314
365
  if (type == target)
315
366
  return 0;
316
367
 
317
368
  switch (type) {
318
- case GIT_OBJ_BLOB:
319
- case GIT_OBJ_TREE:
369
+ case GIT_OBJECT_BLOB:
370
+ case GIT_OBJECT_TREE:
320
371
  /* a blob or tree can never be peeled to anything but themselves */
321
372
  return GIT_EINVALIDSPEC;
322
373
  break;
323
- case GIT_OBJ_COMMIT:
374
+ case GIT_OBJECT_COMMIT:
324
375
  /* a commit can only be peeled to a tree */
325
- if (target != GIT_OBJ_TREE && target != GIT_OBJ_ANY)
376
+ if (target != GIT_OBJECT_TREE && target != GIT_OBJECT_ANY)
326
377
  return GIT_EINVALIDSPEC;
327
378
  break;
328
- case GIT_OBJ_TAG:
379
+ case GIT_OBJECT_TAG:
329
380
  /* a tag may point to anything, so we let anything through */
330
381
  break;
331
382
  default:
@@ -338,18 +389,18 @@ static int check_type_combination(git_otype type, git_otype target)
338
389
  int git_object_peel(
339
390
  git_object **peeled,
340
391
  const git_object *object,
341
- git_otype target_type)
392
+ git_object_t target_type)
342
393
  {
343
394
  git_object *source, *deref = NULL;
344
395
  int error;
345
396
 
346
397
  assert(object && peeled);
347
398
 
348
- assert(target_type == GIT_OBJ_TAG ||
349
- target_type == GIT_OBJ_COMMIT ||
350
- target_type == GIT_OBJ_TREE ||
351
- target_type == GIT_OBJ_BLOB ||
352
- target_type == GIT_OBJ_ANY);
399
+ assert(target_type == GIT_OBJECT_TAG ||
400
+ target_type == GIT_OBJECT_COMMIT ||
401
+ target_type == GIT_OBJECT_TREE ||
402
+ target_type == GIT_OBJECT_BLOB ||
403
+ target_type == GIT_OBJECT_ANY);
353
404
 
354
405
  if ((error = check_type_combination(git_object_type(object), target_type)) < 0)
355
406
  return peel_error(error, git_object_id(object), target_type);
@@ -369,7 +420,7 @@ int git_object_peel(
369
420
  return 0;
370
421
  }
371
422
 
372
- if (target_type == GIT_OBJ_ANY &&
423
+ if (target_type == GIT_OBJECT_ANY &&
373
424
  git_object_type(deref) != git_object_type(object))
374
425
  {
375
426
  *peeled = deref;
@@ -402,7 +453,7 @@ int git_object_lookup_bypath(
402
453
  git_object **out,
403
454
  const git_object *treeish,
404
455
  const char *path,
405
- git_otype type)
456
+ git_object_t type)
406
457
  {
407
458
  int error = -1;
408
459
  git_tree *tree = NULL;
@@ -410,15 +461,15 @@ int git_object_lookup_bypath(
410
461
 
411
462
  assert(out && treeish && path);
412
463
 
413
- if ((error = git_object_peel((git_object**)&tree, treeish, GIT_OBJ_TREE)) < 0 ||
464
+ if ((error = git_object_peel((git_object**)&tree, treeish, GIT_OBJECT_TREE)) < 0 ||
414
465
  (error = git_tree_entry_bypath(&entry, tree, path)) < 0)
415
466
  {
416
467
  goto cleanup;
417
468
  }
418
469
 
419
- if (type != GIT_OBJ_ANY && git_tree_entry_type(entry) != type)
470
+ if (type != GIT_OBJECT_ANY && git_tree_entry_type(entry) != type)
420
471
  {
421
- giterr_set(GITERR_OBJECT,
472
+ git_error_set(GIT_ERROR_OBJECT,
422
473
  "object at path '%s' is not of the asked-for type %d",
423
474
  path, type);
424
475
  error = GIT_EINVALIDSPEC;
@@ -461,7 +512,7 @@ int git_object_short_id(git_buf *out, const git_object *obj)
461
512
  if (error != GIT_EAMBIGUOUS)
462
513
  break;
463
514
 
464
- giterr_clear();
515
+ git_error_clear();
465
516
  len++;
466
517
  }
467
518
 
@@ -476,10 +527,10 @@ int git_object_short_id(git_buf *out, const git_object *obj)
476
527
  }
477
528
 
478
529
  bool git_object__is_valid(
479
- git_repository *repo, const git_oid *id, git_otype expected_type)
530
+ git_repository *repo, const git_oid *id, git_object_t expected_type)
480
531
  {
481
532
  git_odb *odb;
482
- git_otype actual_type;
533
+ git_object_t actual_type;
483
534
  size_t len;
484
535
  int error;
485
536
 
@@ -490,8 +541,8 @@ bool git_object__is_valid(
490
541
  (error = git_odb_read_header(&len, &actual_type, odb, id)) < 0)
491
542
  return false;
492
543
 
493
- if (expected_type != GIT_OBJ_ANY && expected_type != actual_type) {
494
- giterr_set(GITERR_INVALID,
544
+ if (expected_type != GIT_OBJECT_ANY && expected_type != actual_type) {
545
+ git_error_set(GIT_ERROR_INVALID,
495
546
  "the requested type does not match the type in the ODB");
496
547
  return false;
497
548
  }