rugged 1.3.2.3 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (329) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/extconf.rb +1 -1
  3. data/ext/rugged/rugged_config.c +7 -2
  4. data/ext/rugged/rugged_remote.c +17 -0
  5. data/lib/rugged/version.rb +1 -1
  6. data/vendor/libgit2/CMakeLists.txt +103 -276
  7. data/vendor/libgit2/COPYING +36 -19
  8. data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
  9. data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
  10. data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
  11. data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
  12. data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
  13. data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
  14. data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
  15. data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
  16. data/vendor/libgit2/cmake/FindLibSSH2.cmake +5 -5
  17. data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
  18. data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
  19. data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
  20. data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
  21. data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
  22. data/vendor/libgit2/cmake/Findfutimens.cmake +8 -8
  23. data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
  24. data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
  25. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
  26. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
  27. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
  28. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
  29. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -100
  30. data/vendor/libgit2/cmake/SelectHashes.cmake +39 -49
  31. data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
  32. data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
  33. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
  34. data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
  35. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
  36. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +31 -31
  37. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +1 -1
  38. data/vendor/libgit2/deps/ntlmclient/ntlm.c +4 -4
  39. data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
  40. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
  41. data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
  42. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
  43. data/vendor/libgit2/deps/zlib/adler32.c +0 -7
  44. data/vendor/libgit2/deps/zlib/crc32.c +288 -975
  45. data/vendor/libgit2/deps/zlib/crc32.h +436 -9441
  46. data/vendor/libgit2/deps/zlib/deflate.c +31 -83
  47. data/vendor/libgit2/deps/zlib/deflate.h +15 -12
  48. data/vendor/libgit2/deps/zlib/gzguts.h +2 -3
  49. data/vendor/libgit2/deps/zlib/infback.c +1 -2
  50. data/vendor/libgit2/deps/zlib/inffast.c +14 -14
  51. data/vendor/libgit2/deps/zlib/inflate.c +8 -39
  52. data/vendor/libgit2/deps/zlib/inflate.h +2 -3
  53. data/vendor/libgit2/deps/zlib/inftrees.c +3 -3
  54. data/vendor/libgit2/deps/zlib/trees.c +48 -27
  55. data/vendor/libgit2/deps/zlib/zlib.h +100 -126
  56. data/vendor/libgit2/deps/zlib/zutil.c +2 -2
  57. data/vendor/libgit2/deps/zlib/zutil.h +9 -12
  58. data/vendor/libgit2/include/git2/apply.h +16 -2
  59. data/vendor/libgit2/include/git2/attr.h +11 -2
  60. data/vendor/libgit2/include/git2/blame.h +4 -1
  61. data/vendor/libgit2/include/git2/blob.h +14 -1
  62. data/vendor/libgit2/include/git2/branch.h +2 -0
  63. data/vendor/libgit2/include/git2/buffer.h +18 -78
  64. data/vendor/libgit2/include/git2/cert.h +2 -2
  65. data/vendor/libgit2/include/git2/checkout.h +5 -2
  66. data/vendor/libgit2/include/git2/clone.h +3 -3
  67. data/vendor/libgit2/include/git2/commit.h +2 -0
  68. data/vendor/libgit2/include/git2/common.h +5 -12
  69. data/vendor/libgit2/include/git2/config.h +19 -3
  70. data/vendor/libgit2/include/git2/credential.h +2 -1
  71. data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
  72. data/vendor/libgit2/include/git2/deprecated.h +1 -1
  73. data/vendor/libgit2/include/git2/describe.h +7 -2
  74. data/vendor/libgit2/include/git2/diff.h +17 -9
  75. data/vendor/libgit2/include/git2/email.h +1 -1
  76. data/vendor/libgit2/include/git2/errors.h +1 -2
  77. data/vendor/libgit2/include/git2/filter.h +7 -2
  78. data/vendor/libgit2/include/git2/graph.h +1 -0
  79. data/vendor/libgit2/include/git2/ignore.h +1 -1
  80. data/vendor/libgit2/include/git2/index.h +11 -5
  81. data/vendor/libgit2/include/git2/indexer.h +19 -0
  82. data/vendor/libgit2/include/git2/merge.h +23 -3
  83. data/vendor/libgit2/include/git2/message.h +2 -0
  84. data/vendor/libgit2/include/git2/object.h +23 -0
  85. data/vendor/libgit2/include/git2/odb.h +37 -7
  86. data/vendor/libgit2/include/git2/odb_backend.h +1 -1
  87. data/vendor/libgit2/include/git2/pack.h +24 -8
  88. data/vendor/libgit2/include/git2/patch.h +8 -0
  89. data/vendor/libgit2/include/git2/pathspec.h +1 -1
  90. data/vendor/libgit2/include/git2/proxy.h +1 -1
  91. data/vendor/libgit2/include/git2/rebase.h +9 -1
  92. data/vendor/libgit2/include/git2/refdb.h +3 -0
  93. data/vendor/libgit2/include/git2/reflog.h +1 -1
  94. data/vendor/libgit2/include/git2/refs.h +2 -2
  95. data/vendor/libgit2/include/git2/remote.h +184 -37
  96. data/vendor/libgit2/include/git2/repository.h +14 -9
  97. data/vendor/libgit2/include/git2/reset.h +2 -2
  98. data/vendor/libgit2/include/git2/revparse.h +1 -1
  99. data/vendor/libgit2/include/git2/revwalk.h +4 -1
  100. data/vendor/libgit2/include/git2/signature.h +1 -1
  101. data/vendor/libgit2/include/git2/stash.h +3 -3
  102. data/vendor/libgit2/include/git2/status.h +9 -3
  103. data/vendor/libgit2/include/git2/submodule.h +7 -2
  104. data/vendor/libgit2/include/git2/sys/commit_graph.h +1 -1
  105. data/vendor/libgit2/include/git2/sys/odb_backend.h +2 -5
  106. data/vendor/libgit2/include/git2/sys/remote.h +31 -0
  107. data/vendor/libgit2/include/git2/sys/stream.h +1 -1
  108. data/vendor/libgit2/include/git2/sys/transport.h +25 -34
  109. data/vendor/libgit2/include/git2/tag.h +1 -0
  110. data/vendor/libgit2/include/git2/tree.h +4 -3
  111. data/vendor/libgit2/include/git2/types.h +7 -7
  112. data/vendor/libgit2/include/git2/version.h +3 -3
  113. data/vendor/libgit2/include/git2/worktree.h +12 -2
  114. data/vendor/libgit2/src/CMakeLists.txt +189 -315
  115. data/vendor/libgit2/src/annotated_commit.h +1 -1
  116. data/vendor/libgit2/src/apply.c +18 -18
  117. data/vendor/libgit2/src/apply.h +2 -2
  118. data/vendor/libgit2/src/attr.c +18 -18
  119. data/vendor/libgit2/src/attr_file.c +17 -17
  120. data/vendor/libgit2/src/attr_file.h +4 -4
  121. data/vendor/libgit2/src/attrcache.c +17 -12
  122. data/vendor/libgit2/src/blame_git.c +1 -1
  123. data/vendor/libgit2/src/blob.c +33 -26
  124. data/vendor/libgit2/src/blob.h +1 -1
  125. data/vendor/libgit2/src/branch.c +150 -109
  126. data/vendor/libgit2/src/branch.h +15 -3
  127. data/vendor/libgit2/src/buf.c +126 -0
  128. data/vendor/libgit2/src/buf.h +50 -0
  129. data/vendor/libgit2/src/cc-compat.h +1 -1
  130. data/vendor/libgit2/src/checkout.c +74 -68
  131. data/vendor/libgit2/src/cherrypick.c +10 -10
  132. data/vendor/libgit2/src/clone.c +66 -66
  133. data/vendor/libgit2/src/commit.c +128 -58
  134. data/vendor/libgit2/src/commit.h +24 -1
  135. data/vendor/libgit2/src/commit_graph.c +68 -53
  136. data/vendor/libgit2/src/commit_graph.h +10 -3
  137. data/vendor/libgit2/src/commit_list.c +2 -3
  138. data/vendor/libgit2/src/common.h +10 -3
  139. data/vendor/libgit2/src/config.c +99 -77
  140. data/vendor/libgit2/src/config.h +15 -2
  141. data/vendor/libgit2/src/config_file.c +103 -91
  142. data/vendor/libgit2/src/config_mem.c +9 -9
  143. data/vendor/libgit2/src/config_parse.c +27 -23
  144. data/vendor/libgit2/src/crlf.c +24 -21
  145. data/vendor/libgit2/src/date.c +10 -17
  146. data/vendor/libgit2/src/date.h +33 -0
  147. data/vendor/libgit2/src/describe.c +27 -19
  148. data/vendor/libgit2/src/diff.c +25 -8
  149. data/vendor/libgit2/src/diff.h +2 -4
  150. data/vendor/libgit2/src/diff_driver.c +34 -36
  151. data/vendor/libgit2/src/diff_driver.h +3 -3
  152. data/vendor/libgit2/src/diff_file.c +29 -20
  153. data/vendor/libgit2/src/diff_generate.c +30 -6
  154. data/vendor/libgit2/src/diff_generate.h +5 -3
  155. data/vendor/libgit2/src/diff_print.c +102 -95
  156. data/vendor/libgit2/src/diff_stats.c +40 -29
  157. data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
  158. data/vendor/libgit2/src/diff_tform.c +9 -8
  159. data/vendor/libgit2/src/diff_xdiff.c +3 -8
  160. data/vendor/libgit2/src/email.c +54 -38
  161. data/vendor/libgit2/src/email.h +1 -1
  162. data/vendor/libgit2/src/errors.c +18 -18
  163. data/vendor/libgit2/src/features.h.in +6 -1
  164. data/vendor/libgit2/src/fetch.c +69 -24
  165. data/vendor/libgit2/src/fetch.h +1 -1
  166. data/vendor/libgit2/src/fetchhead.c +19 -19
  167. data/vendor/libgit2/src/filebuf.c +28 -28
  168. data/vendor/libgit2/src/filebuf.h +1 -1
  169. data/vendor/libgit2/src/filter.c +96 -52
  170. data/vendor/libgit2/src/filter.h +26 -5
  171. data/vendor/libgit2/src/fs_path.c +1912 -0
  172. data/vendor/libgit2/src/fs_path.h +752 -0
  173. data/vendor/libgit2/src/futils.c +91 -85
  174. data/vendor/libgit2/src/futils.h +26 -14
  175. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +2 -2
  176. data/vendor/libgit2/src/hash/sha1/common_crypto.c +2 -2
  177. data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
  178. data/vendor/libgit2/src/hash/sha1/mbedtls.c +2 -2
  179. data/vendor/libgit2/src/hash/sha1/openssl.c +2 -2
  180. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +1 -1
  181. data/vendor/libgit2/src/hash/sha1/win32.c +6 -6
  182. data/vendor/libgit2/src/hash/sha1.h +3 -1
  183. data/vendor/libgit2/src/hash.c +67 -35
  184. data/vendor/libgit2/src/hash.h +12 -12
  185. data/vendor/libgit2/src/ident.c +18 -18
  186. data/vendor/libgit2/src/ignore.c +35 -34
  187. data/vendor/libgit2/src/ignore.h +2 -2
  188. data/vendor/libgit2/src/index.c +79 -80
  189. data/vendor/libgit2/src/index.h +6 -3
  190. data/vendor/libgit2/src/indexer.c +75 -57
  191. data/vendor/libgit2/src/iterator.c +64 -56
  192. data/vendor/libgit2/src/iterator.h +5 -5
  193. data/vendor/libgit2/src/khash.h +1 -1
  194. data/vendor/libgit2/src/libgit2.c +22 -19
  195. data/vendor/libgit2/src/mailmap.c +38 -36
  196. data/vendor/libgit2/src/merge.c +27 -27
  197. data/vendor/libgit2/src/merge.h +1 -14
  198. data/vendor/libgit2/src/merge_driver.c +2 -2
  199. data/vendor/libgit2/src/merge_file.c +13 -3
  200. data/vendor/libgit2/src/message.c +21 -10
  201. data/vendor/libgit2/src/midx.c +83 -66
  202. data/vendor/libgit2/src/midx.h +3 -3
  203. data/vendor/libgit2/src/mwindow.c +1 -1
  204. data/vendor/libgit2/src/net.c +278 -68
  205. data/vendor/libgit2/src/net.h +10 -3
  206. data/vendor/libgit2/src/netops.c +1 -1
  207. data/vendor/libgit2/src/netops.h +1 -1
  208. data/vendor/libgit2/src/notes.c +20 -29
  209. data/vendor/libgit2/src/object.c +49 -9
  210. data/vendor/libgit2/src/object.h +1 -1
  211. data/vendor/libgit2/src/odb.c +35 -32
  212. data/vendor/libgit2/src/odb.h +1 -1
  213. data/vendor/libgit2/src/odb_loose.c +68 -68
  214. data/vendor/libgit2/src/odb_mempack.c +18 -5
  215. data/vendor/libgit2/src/odb_pack.c +43 -43
  216. data/vendor/libgit2/src/oid.c +11 -4
  217. data/vendor/libgit2/src/oid.h +15 -0
  218. data/vendor/libgit2/src/pack-objects.c +41 -26
  219. data/vendor/libgit2/src/pack-objects.h +11 -6
  220. data/vendor/libgit2/src/pack.c +10 -10
  221. data/vendor/libgit2/src/patch.c +3 -3
  222. data/vendor/libgit2/src/patch.h +1 -0
  223. data/vendor/libgit2/src/patch_generate.c +27 -11
  224. data/vendor/libgit2/src/patch_generate.h +5 -5
  225. data/vendor/libgit2/src/patch_parse.c +24 -24
  226. data/vendor/libgit2/src/path.c +76 -1951
  227. data/vendor/libgit2/src/path.h +34 -741
  228. data/vendor/libgit2/src/pathspec.c +6 -6
  229. data/vendor/libgit2/src/pathspec.h +2 -2
  230. data/vendor/libgit2/src/posix.c +3 -3
  231. data/vendor/libgit2/src/posix.h +1 -0
  232. data/vendor/libgit2/src/pqueue.h +1 -1
  233. data/vendor/libgit2/src/proxy.c +4 -1
  234. data/vendor/libgit2/src/proxy.h +1 -1
  235. data/vendor/libgit2/src/push.c +30 -35
  236. data/vendor/libgit2/src/push.h +4 -16
  237. data/vendor/libgit2/src/rand.c +226 -0
  238. data/vendor/libgit2/src/rand.h +37 -0
  239. data/vendor/libgit2/src/reader.c +8 -8
  240. data/vendor/libgit2/src/reader.h +2 -2
  241. data/vendor/libgit2/src/rebase.c +89 -88
  242. data/vendor/libgit2/src/refdb_fs.c +447 -173
  243. data/vendor/libgit2/src/refs.c +32 -32
  244. data/vendor/libgit2/src/refs.h +2 -2
  245. data/vendor/libgit2/src/refspec.c +32 -37
  246. data/vendor/libgit2/src/refspec.h +5 -2
  247. data/vendor/libgit2/src/regexp.c +1 -1
  248. data/vendor/libgit2/src/remote.c +713 -419
  249. data/vendor/libgit2/src/remote.h +15 -10
  250. data/vendor/libgit2/src/repository.c +350 -467
  251. data/vendor/libgit2/src/repository.h +11 -10
  252. data/vendor/libgit2/src/reset.c +8 -5
  253. data/vendor/libgit2/src/revert.c +10 -10
  254. data/vendor/libgit2/src/revparse.c +48 -35
  255. data/vendor/libgit2/src/revwalk.c +7 -7
  256. data/vendor/libgit2/src/signature.c +12 -6
  257. data/vendor/libgit2/src/signature.h +1 -1
  258. data/vendor/libgit2/src/sortedcache.c +1 -1
  259. data/vendor/libgit2/src/sortedcache.h +1 -1
  260. data/vendor/libgit2/src/stash.c +36 -37
  261. data/vendor/libgit2/src/status.c +4 -1
  262. data/vendor/libgit2/src/{buffer.c → str.c} +157 -151
  263. data/vendor/libgit2/src/str.h +357 -0
  264. data/vendor/libgit2/src/streams/mbedtls.c +8 -6
  265. data/vendor/libgit2/src/streams/openssl_dynamic.h +3 -3
  266. data/vendor/libgit2/src/submodule.c +171 -159
  267. data/vendor/libgit2/src/submodule.h +1 -1
  268. data/vendor/libgit2/src/sysdir.c +68 -52
  269. data/vendor/libgit2/src/sysdir.h +15 -10
  270. data/vendor/libgit2/src/tag.c +29 -27
  271. data/vendor/libgit2/src/thread.h +3 -3
  272. data/vendor/libgit2/src/threadstate.c +3 -3
  273. data/vendor/libgit2/src/threadstate.h +1 -1
  274. data/vendor/libgit2/src/trace.c +1 -14
  275. data/vendor/libgit2/src/trace.h +5 -22
  276. data/vendor/libgit2/src/trailer.c +1 -1
  277. data/vendor/libgit2/src/transaction.c +1 -1
  278. data/vendor/libgit2/src/transport.c +10 -10
  279. data/vendor/libgit2/src/transports/auth.c +7 -9
  280. data/vendor/libgit2/src/transports/auth.h +2 -3
  281. data/vendor/libgit2/src/transports/auth_negotiate.c +12 -13
  282. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -10
  283. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
  284. data/vendor/libgit2/src/transports/git.c +9 -11
  285. data/vendor/libgit2/src/transports/http.c +37 -17
  286. data/vendor/libgit2/src/transports/http.h +2 -3
  287. data/vendor/libgit2/src/transports/httpclient.c +65 -65
  288. data/vendor/libgit2/src/transports/local.c +124 -116
  289. data/vendor/libgit2/src/transports/smart.c +51 -139
  290. data/vendor/libgit2/src/transports/smart.h +25 -31
  291. data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
  292. data/vendor/libgit2/src/transports/smart_protocol.c +57 -39
  293. data/vendor/libgit2/src/transports/ssh.c +47 -112
  294. data/vendor/libgit2/src/transports/winhttp.c +50 -56
  295. data/vendor/libgit2/src/tree-cache.c +5 -5
  296. data/vendor/libgit2/src/tree-cache.h +2 -2
  297. data/vendor/libgit2/src/tree.c +59 -48
  298. data/vendor/libgit2/src/tree.h +1 -1
  299. data/vendor/libgit2/src/unix/map.c +0 -2
  300. data/vendor/libgit2/src/unix/posix.h +1 -4
  301. data/vendor/libgit2/src/unix/realpath.c +0 -2
  302. data/vendor/libgit2/src/util.c +14 -14
  303. data/vendor/libgit2/src/util.h +2 -28
  304. data/vendor/libgit2/src/vector.h +1 -1
  305. data/vendor/libgit2/src/win32/findfile.c +172 -116
  306. data/vendor/libgit2/src/win32/findfile.h +7 -4
  307. data/vendor/libgit2/src/win32/path_w32.c +140 -9
  308. data/vendor/libgit2/src/win32/path_w32.h +2 -0
  309. data/vendor/libgit2/src/win32/posix.h +0 -1
  310. data/vendor/libgit2/src/win32/posix_w32.c +11 -27
  311. data/vendor/libgit2/src/win32/w32_buffer.c +2 -3
  312. data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
  313. data/vendor/libgit2/src/win32/w32_leakcheck.c +1 -1
  314. data/vendor/libgit2/src/worktree.c +116 -94
  315. data/vendor/libgit2/src/worktree.h +1 -1
  316. data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
  317. data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
  318. data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
  319. data/vendor/libgit2/src/xdiff/xemit.c +23 -7
  320. data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
  321. data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
  322. data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
  323. data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
  324. data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
  325. data/vendor/libgit2/src/xdiff/xutils.c +18 -7
  326. data/vendor/libgit2/src/zstream.c +5 -5
  327. data/vendor/libgit2/src/zstream.h +4 -4
  328. metadata +25 -10
  329. data/vendor/libgit2/src/buffer.h +0 -374
@@ -7,7 +7,7 @@
7
7
 
8
8
  #include "notes.h"
9
9
 
10
- #include "git2.h"
10
+ #include "buf.h"
11
11
  #include "refs.h"
12
12
  #include "config.h"
13
13
  #include "iterator.h"
@@ -407,7 +407,7 @@ cleanup:
407
407
  return error;
408
408
  }
409
409
 
410
- static int note_get_default_ref(git_buf *out, git_repository *repo)
410
+ static int note_get_default_ref(git_str *out, git_repository *repo)
411
411
  {
412
412
  git_config *cfg;
413
413
  int error;
@@ -415,25 +415,25 @@ static int note_get_default_ref(git_buf *out, git_repository *repo)
415
415
  if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
416
416
  return error;
417
417
 
418
- error = git_config_get_string_buf(out, cfg, "core.notesref");
418
+ error = git_config__get_string_buf(out, cfg, "core.notesref");
419
419
 
420
420
  if (error == GIT_ENOTFOUND)
421
- error = git_buf_puts(out, GIT_NOTES_DEFAULT_REF);
421
+ error = git_str_puts(out, GIT_NOTES_DEFAULT_REF);
422
422
 
423
423
  return error;
424
424
  }
425
425
 
426
- static int normalize_namespace(git_buf *out, git_repository *repo, const char *notes_ref)
426
+ static int normalize_namespace(git_str *out, git_repository *repo, const char *notes_ref)
427
427
  {
428
428
  if (notes_ref)
429
- return git_buf_puts(out, notes_ref);
429
+ return git_str_puts(out, notes_ref);
430
430
 
431
431
  return note_get_default_ref(out, repo);
432
432
  }
433
433
 
434
434
  static int retrieve_note_commit(
435
435
  git_commit **commit_out,
436
- git_buf *notes_ref_out,
436
+ git_str *notes_ref_out,
437
437
  git_repository *repo,
438
438
  const char *notes_ref)
439
439
  {
@@ -478,7 +478,7 @@ int git_note_read(git_note **out, git_repository *repo,
478
478
  const char *notes_ref_in, const git_oid *oid)
479
479
  {
480
480
  int error;
481
- git_buf notes_ref = GIT_BUF_INIT;
481
+ git_str notes_ref = GIT_STR_INIT;
482
482
  git_commit *commit = NULL;
483
483
 
484
484
  error = retrieve_note_commit(&commit, &notes_ref, repo, notes_ref_in);
@@ -489,7 +489,7 @@ int git_note_read(git_note **out, git_repository *repo,
489
489
  error = git_note_commit_read(out, repo, commit, oid);
490
490
 
491
491
  cleanup:
492
- git_buf_dispose(&notes_ref);
492
+ git_str_dispose(&notes_ref);
493
493
  git_commit_free(commit);
494
494
  return error;
495
495
  }
@@ -536,7 +536,7 @@ int git_note_create(
536
536
  int allow_note_overwrite)
537
537
  {
538
538
  int error;
539
- git_buf notes_ref = GIT_BUF_INIT;
539
+ git_str notes_ref = GIT_STR_INIT;
540
540
  git_commit *existing_notes_commit = NULL;
541
541
  git_reference *ref = NULL;
542
542
  git_oid notes_blob_oid, notes_commit_oid;
@@ -562,7 +562,7 @@ int git_note_create(
562
562
  git_oid_cpy(out, &notes_blob_oid);
563
563
 
564
564
  cleanup:
565
- git_buf_dispose(&notes_ref);
565
+ git_str_dispose(&notes_ref);
566
566
  git_commit_free(existing_notes_commit);
567
567
  git_reference_free(ref);
568
568
  return error;
@@ -598,7 +598,7 @@ int git_note_remove(git_repository *repo, const char *notes_ref_in,
598
598
  const git_oid *oid)
599
599
  {
600
600
  int error;
601
- git_buf notes_ref_target = GIT_BUF_INIT;
601
+ git_str notes_ref_target = GIT_STR_INIT;
602
602
  git_commit *existing_notes_commit = NULL;
603
603
  git_oid new_notes_commit;
604
604
  git_reference *notes_ref = NULL;
@@ -618,7 +618,7 @@ int git_note_remove(git_repository *repo, const char *notes_ref_in,
618
618
  &new_notes_commit, 1, NULL);
619
619
 
620
620
  cleanup:
621
- git_buf_dispose(&notes_ref_target);
621
+ git_str_dispose(&notes_ref_target);
622
622
  git_reference_free(notes_ref);
623
623
  git_commit_free(existing_notes_commit);
624
624
  return error;
@@ -626,16 +626,7 @@ cleanup:
626
626
 
627
627
  int git_note_default_ref(git_buf *out, git_repository *repo)
628
628
  {
629
- int error;
630
-
631
- GIT_ASSERT_ARG(out);
632
- GIT_ASSERT_ARG(repo);
633
-
634
- if ((error = git_buf_sanitize(out)) < 0 ||
635
- (error = note_get_default_ref(out, repo)) < 0)
636
- git_buf_dispose(out);
637
-
638
- return error;
629
+ GIT_BUF_WRAP_PRIVATE(out, note_get_default_ref, repo);
639
630
  }
640
631
 
641
632
  const git_signature *git_note_committer(const git_note *note)
@@ -679,12 +670,12 @@ static int process_entry_path(
679
670
  {
680
671
  int error = 0;
681
672
  size_t i = 0, j = 0, len;
682
- git_buf buf = GIT_BUF_INIT;
673
+ git_str buf = GIT_STR_INIT;
683
674
 
684
- if ((error = git_buf_puts(&buf, entry_path)) < 0)
675
+ if ((error = git_str_puts(&buf, entry_path)) < 0)
685
676
  goto cleanup;
686
677
 
687
- len = git_buf_len(&buf);
678
+ len = git_str_len(&buf);
688
679
 
689
680
  while (i < len) {
690
681
  if (buf.ptr[i] == '/') {
@@ -715,7 +706,7 @@ static int process_entry_path(
715
706
  error = git_oid_fromstr(annotated_object_id, buf.ptr);
716
707
 
717
708
  cleanup:
718
- git_buf_dispose(&buf);
709
+ git_str_dispose(&buf);
719
710
  return error;
720
711
  }
721
712
 
@@ -780,7 +771,7 @@ int git_note_iterator_new(
780
771
  {
781
772
  int error;
782
773
  git_commit *commit = NULL;
783
- git_buf notes_ref = GIT_BUF_INIT;
774
+ git_str notes_ref = GIT_STR_INIT;
784
775
 
785
776
  error = retrieve_note_commit(&commit, &notes_ref, repo, notes_ref_in);
786
777
  if (error < 0)
@@ -789,7 +780,7 @@ int git_note_iterator_new(
789
780
  error = git_note_commit_iterator_new(it, commit);
790
781
 
791
782
  cleanup:
792
- git_buf_dispose(&notes_ref);
783
+ git_str_dispose(&notes_ref);
793
784
  git_commit_free(commit);
794
785
 
795
786
  return error;
@@ -11,6 +11,7 @@
11
11
 
12
12
  #include "repository.h"
13
13
 
14
+ #include "buf.h"
14
15
  #include "commit.h"
15
16
  #include "hash.h"
16
17
  #include "tree.h"
@@ -143,12 +144,17 @@ int git_object__from_odb_object(
143
144
  def = &git_objects_table[odb_obj->cached.type];
144
145
  GIT_ASSERT(def->free && def->parse);
145
146
 
146
- if ((error = def->parse(object, odb_obj)) < 0)
147
+ if ((error = def->parse(object, odb_obj)) < 0) {
148
+ /*
149
+ * parse returns EINVALID on invalid data; downgrade
150
+ * that to a normal -1 error code.
151
+ */
147
152
  def->free(object);
148
- else
149
- *object_out = git_cache_store_parsed(&repo->objects, object);
153
+ return -1;
154
+ }
150
155
 
151
- return error;
156
+ *object_out = git_cache_store_parsed(&repo->objects, object);
157
+ return 0;
152
158
  }
153
159
 
154
160
  void git_object__free(void *obj)
@@ -491,7 +497,7 @@ cleanup:
491
497
  return error;
492
498
  }
493
499
 
494
- int git_object_short_id(git_buf *out, const git_object *obj)
500
+ static int git_object__short_id(git_str *out, const git_object *obj)
495
501
  {
496
502
  git_repository *repo;
497
503
  int len = GIT_ABBREV_DEFAULT, error;
@@ -501,9 +507,6 @@ int git_object_short_id(git_buf *out, const git_object *obj)
501
507
  GIT_ASSERT_ARG(out);
502
508
  GIT_ASSERT_ARG(obj);
503
509
 
504
- if ((error = git_buf_sanitize(out)) < 0)
505
- return error;
506
-
507
510
  repo = git_object_owner(obj);
508
511
 
509
512
  if ((error = git_repository__configmap_lookup(&len, repo, GIT_CONFIGMAP_ABBREV)) < 0)
@@ -526,7 +529,7 @@ int git_object_short_id(git_buf *out, const git_object *obj)
526
529
  len++;
527
530
  }
528
531
 
529
- if (!error && !(error = git_buf_grow(out, len + 1))) {
532
+ if (!error && !(error = git_str_grow(out, len + 1))) {
530
533
  git_oid_tostr(out->ptr, len + 1, &id);
531
534
  out->size = len;
532
535
  }
@@ -536,6 +539,11 @@ int git_object_short_id(git_buf *out, const git_object *obj)
536
539
  return error;
537
540
  }
538
541
 
542
+ int git_object_short_id(git_buf *out, const git_object *obj)
543
+ {
544
+ GIT_BUF_WRAP_PRIVATE(out, git_object__short_id, obj);
545
+ }
546
+
539
547
  bool git_object__is_valid(
540
548
  git_repository *repo, const git_oid *id, git_object_t expected_type)
541
549
  {
@@ -559,3 +567,35 @@ bool git_object__is_valid(
559
567
 
560
568
  return true;
561
569
  }
570
+
571
+ int git_object_rawcontent_is_valid(
572
+ int *valid,
573
+ const char *buf,
574
+ size_t len,
575
+ git_object_t type)
576
+ {
577
+ git_object *obj = NULL;
578
+ int error;
579
+
580
+ GIT_ASSERT_ARG(valid);
581
+ GIT_ASSERT_ARG(buf);
582
+
583
+ /* Blobs are always valid; don't bother parsing. */
584
+ if (type == GIT_OBJECT_BLOB) {
585
+ *valid = 1;
586
+ return 0;
587
+ }
588
+
589
+ error = git_object__from_raw(&obj, buf, len, type);
590
+ git_object_free(obj);
591
+
592
+ if (error == 0) {
593
+ *valid = 1;
594
+ return 0;
595
+ } else if (error == GIT_EINVALID) {
596
+ *valid = 0;
597
+ return 0;
598
+ }
599
+
600
+ return error;
601
+ }
@@ -47,7 +47,7 @@ git_object_t git_object_stringn2type(const char *str, size_t len);
47
47
 
48
48
  int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end, const char *header);
49
49
 
50
- void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid);
50
+ void git_oid__writebuf(git_str *buf, const char *header, const git_oid *oid);
51
51
 
52
52
  bool git_object__is_valid(
53
53
  git_repository *repo, const git_oid *id, git_object_t expected_type);
@@ -16,6 +16,7 @@
16
16
  #include "filter.h"
17
17
  #include "repository.h"
18
18
  #include "blob.h"
19
+ #include "oid.h"
19
20
 
20
21
  #include "git2/odb_backend.h"
21
22
  #include "git2/oid.h"
@@ -58,10 +59,7 @@ static int error_null_oid(int error, const char *message);
58
59
 
59
60
  static git_object_t odb_hardcoded_type(const git_oid *id)
60
61
  {
61
- static git_oid empty_tree = {{ 0x4b, 0x82, 0x5d, 0xc6, 0x42, 0xcb, 0x6e, 0xb9, 0xa0, 0x60,
62
- 0xe5, 0x4b, 0xf8, 0xd6, 0x92, 0x88, 0xfb, 0xee, 0x49, 0x04 }};
63
-
64
- if (!git_oid_cmp(id, &empty_tree))
62
+ if (!git_oid_cmp(id, &git_oid__empty_tree_sha1))
65
63
  return GIT_OBJECT_TREE;
66
64
 
67
65
  return GIT_OBJECT_INVALID;
@@ -109,7 +107,7 @@ int git_odb__format_object_header(
109
107
 
110
108
  int git_odb__hashobj(git_oid *id, git_rawobj *obj)
111
109
  {
112
- git_buf_vec vec[2];
110
+ git_str_vec vec[2];
113
111
  char header[64];
114
112
  size_t hdrlen;
115
113
  int error;
@@ -136,7 +134,7 @@ int git_odb__hashobj(git_oid *id, git_rawobj *obj)
136
134
  vec[1].data = obj->data;
137
135
  vec[1].len = obj->len;
138
136
 
139
- return git_hash_vec(id, vec, 2);
137
+ return git_hash_vec(id->id, vec, 2, GIT_HASH_ALGORITHM_SHA1);
140
138
  }
141
139
 
142
140
 
@@ -210,7 +208,7 @@ int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_object_t type)
210
208
  return -1;
211
209
  }
212
210
 
213
- if ((error = git_hash_ctx_init(&ctx)) < 0)
211
+ if ((error = git_hash_ctx_init(&ctx, GIT_HASH_ALGORITHM_SHA1)) < 0)
214
212
  return error;
215
213
 
216
214
  if ((error = git_odb__format_object_header(&hdr_len, hdr,
@@ -237,7 +235,7 @@ int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_object_t type)
237
235
  goto done;
238
236
  }
239
237
 
240
- error = git_hash_final(out, &ctx);
238
+ error = git_hash_final(out->id, &ctx);
241
239
 
242
240
  done:
243
241
  git_hash_ctx_cleanup(&ctx);
@@ -248,7 +246,7 @@ int git_odb__hashfd_filtered(
248
246
  git_oid *out, git_file fd, size_t size, git_object_t type, git_filter_list *fl)
249
247
  {
250
248
  int error;
251
- git_buf raw = GIT_BUF_INIT;
249
+ git_str raw = GIT_STR_INIT;
252
250
 
253
251
  if (!fl)
254
252
  return git_odb__hashfd(out, fd, size, type);
@@ -258,14 +256,14 @@ int git_odb__hashfd_filtered(
258
256
  */
259
257
 
260
258
  if (!(error = git_futils_readbuffer_fd(&raw, fd, size))) {
261
- git_buf post = GIT_BUF_INIT;
259
+ git_str post = GIT_STR_INIT;
262
260
 
263
261
  error = git_filter_list__convert_buf(&post, fl, &raw);
264
262
 
265
263
  if (!error)
266
264
  error = git_odb_hash(out, post.ptr, post.size, type);
267
265
 
268
- git_buf_dispose(&post);
266
+ git_str_dispose(&post);
269
267
  }
270
268
 
271
269
  return error;
@@ -277,7 +275,7 @@ int git_odb__hashlink(git_oid *out, const char *path)
277
275
  int size;
278
276
  int result;
279
277
 
280
- if (git_path_lstat(path, &st) < 0)
278
+ if (git_fs_path_lstat(path, &st) < 0)
281
279
  return -1;
282
280
 
283
281
  if (!git__is_int(st.st_size) || (int)st.st_size < 0) {
@@ -636,8 +634,8 @@ int git_odb__add_default_backends(
636
634
 
637
635
  static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_depth)
638
636
  {
639
- git_buf alternates_path = GIT_BUF_INIT;
640
- git_buf alternates_buf = GIT_BUF_INIT;
637
+ git_str alternates_path = GIT_STR_INIT;
638
+ git_str alternates_buf = GIT_STR_INIT;
641
639
  char *buffer;
642
640
  const char *alternate;
643
641
  int result = 0;
@@ -646,16 +644,16 @@ static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_
646
644
  if (alternate_depth > GIT_ALTERNATES_MAX_DEPTH)
647
645
  return 0;
648
646
 
649
- if (git_buf_joinpath(&alternates_path, objects_dir, GIT_ALTERNATES_FILE) < 0)
647
+ if (git_str_joinpath(&alternates_path, objects_dir, GIT_ALTERNATES_FILE) < 0)
650
648
  return -1;
651
649
 
652
- if (git_path_exists(alternates_path.ptr) == false) {
653
- git_buf_dispose(&alternates_path);
650
+ if (git_fs_path_exists(alternates_path.ptr) == false) {
651
+ git_str_dispose(&alternates_path);
654
652
  return 0;
655
653
  }
656
654
 
657
655
  if (git_futils_readbuffer(&alternates_buf, alternates_path.ptr) < 0) {
658
- git_buf_dispose(&alternates_path);
656
+ git_str_dispose(&alternates_path);
659
657
  return -1;
660
658
  }
661
659
 
@@ -672,17 +670,17 @@ static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_
672
670
  * the current repository.
673
671
  */
674
672
  if (*alternate == '.' && !alternate_depth) {
675
- if ((result = git_buf_joinpath(&alternates_path, objects_dir, alternate)) < 0)
673
+ if ((result = git_str_joinpath(&alternates_path, objects_dir, alternate)) < 0)
676
674
  break;
677
- alternate = git_buf_cstr(&alternates_path);
675
+ alternate = git_str_cstr(&alternates_path);
678
676
  }
679
677
 
680
678
  if ((result = git_odb__add_default_backends(odb, alternate, true, alternate_depth + 1)) < 0)
681
679
  break;
682
680
  }
683
681
 
684
- git_buf_dispose(&alternates_path);
685
- git_buf_dispose(&alternates_buf);
682
+ git_str_dispose(&alternates_path);
683
+ git_str_dispose(&alternates_buf);
686
684
 
687
685
  return result;
688
686
  }
@@ -882,6 +880,11 @@ int git_odb__freshen(git_odb *db, const git_oid *id)
882
880
  }
883
881
 
884
882
  int git_odb_exists(git_odb *db, const git_oid *id)
883
+ {
884
+ return git_odb_exists_ext(db, id, 0);
885
+ }
886
+
887
+ int git_odb_exists_ext(git_odb *db, const git_oid *id, unsigned int flags)
885
888
  {
886
889
  git_odb_object *object;
887
890
 
@@ -899,7 +902,7 @@ int git_odb_exists(git_odb *db, const git_oid *id)
899
902
  if (odb_exists_1(db, id, false))
900
903
  return 1;
901
904
 
902
- if (!git_odb_refresh(db))
905
+ if (!(flags & GIT_ODB_LOOKUP_NO_REFRESH) && !git_odb_refresh(db))
903
906
  return odb_exists_1(db, id, true);
904
907
 
905
908
  /* Failed to refresh, hence not found */
@@ -1337,15 +1340,15 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
1337
1340
  data = raw.data;
1338
1341
 
1339
1342
  if (found && git_oid__cmp(&full_oid, &found_full_oid)) {
1340
- git_buf buf = GIT_BUF_INIT;
1343
+ git_str buf = GIT_STR_INIT;
1341
1344
 
1342
- git_buf_printf(&buf, "multiple matches for prefix: %s",
1345
+ git_str_printf(&buf, "multiple matches for prefix: %s",
1343
1346
  git_oid_tostr_s(&full_oid));
1344
- git_buf_printf(&buf, " %s",
1347
+ git_str_printf(&buf, " %s",
1345
1348
  git_oid_tostr_s(&found_full_oid));
1346
1349
 
1347
1350
  error = git_odb__error_ambiguous(buf.ptr);
1348
- git_buf_dispose(&buf);
1351
+ git_str_dispose(&buf);
1349
1352
  git_mutex_unlock(&db->lock);
1350
1353
  goto out;
1351
1354
  }
@@ -1496,10 +1499,10 @@ int git_odb_write(
1496
1499
  if ((error = git_odb_open_wstream(&stream, db, len, type)) != 0)
1497
1500
  return error;
1498
1501
 
1499
- stream->write(stream, data, len);
1500
- error = stream->finalize_write(stream, oid);
1501
- git_odb_stream_free(stream);
1502
+ if ((error = stream->write(stream, data, len)) == 0)
1503
+ error = stream->finalize_write(stream, oid);
1502
1504
 
1505
+ git_odb_stream_free(stream);
1503
1506
  return error;
1504
1507
  }
1505
1508
 
@@ -1561,7 +1564,7 @@ int git_odb_open_wstream(
1561
1564
  ctx = git__malloc(sizeof(git_hash_ctx));
1562
1565
  GIT_ERROR_CHECK_ALLOC(ctx);
1563
1566
 
1564
- if ((error = git_hash_ctx_init(ctx)) < 0 ||
1567
+ if ((error = git_hash_ctx_init(ctx, GIT_HASH_ALGORITHM_SHA1)) < 0 ||
1565
1568
  (error = hash_header(ctx, size, type)) < 0)
1566
1569
  goto done;
1567
1570
 
@@ -1607,7 +1610,7 @@ int git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stream)
1607
1610
  return git_odb_stream__invalid_length(stream,
1608
1611
  "stream_finalize_write()");
1609
1612
 
1610
- git_hash_final(out, stream->hash_ctx);
1613
+ git_hash_final(out->id, stream->hash_ctx);
1611
1614
 
1612
1615
  if (git_odb__freshen(stream->backend->odb, out))
1613
1616
  return 0;
@@ -53,7 +53,7 @@ struct git_odb {
53
53
  };
54
54
 
55
55
  typedef enum {
56
- GIT_ODB_CAP_FROM_OWNER = -1,
56
+ GIT_ODB_CAP_FROM_OWNER = -1
57
57
  } git_odb_cap_t;
58
58
 
59
59
  /*