rugged 1.0.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (349) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +1 -1
  4. data/ext/rugged/rugged.c +7 -4
  5. data/ext/rugged/rugged_commit.c +1 -1
  6. data/ext/rugged/rugged_object.c +1 -1
  7. data/ext/rugged/rugged_repo.c +3 -3
  8. data/lib/rugged/commit.rb +16 -2
  9. data/lib/rugged/repository.rb +2 -2
  10. data/lib/rugged/version.rb +1 -1
  11. data/vendor/libgit2/CMakeLists.txt +41 -74
  12. data/vendor/libgit2/COPYING +109 -1
  13. data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
  14. data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
  15. data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
  16. data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
  17. data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
  18. data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
  19. data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
  20. data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
  21. data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
  22. data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
  23. data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
  24. data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
  25. data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
  26. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  27. data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
  28. data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
  29. data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
  30. data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
  31. data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
  32. data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +29 -32
  33. data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +21 -28
  34. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  35. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
  36. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +24 -10
  37. data/vendor/libgit2/deps/ntlmclient/compat.h +0 -27
  38. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  39. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  40. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  41. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  42. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  43. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  44. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  45. data/vendor/libgit2/deps/ntlmclient/ntlm.c +164 -135
  46. data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
  47. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
  48. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  49. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  50. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  51. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  52. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  53. data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
  54. data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
  55. data/vendor/libgit2/deps/pcre/LICENCE +93 -0
  56. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  57. data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
  58. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
  59. data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
  60. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
  61. data/vendor/libgit2/deps/zlib/deflate.c +1 -0
  62. data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
  63. data/vendor/libgit2/include/git2/apply.h +2 -0
  64. data/vendor/libgit2/include/git2/attr.h +95 -0
  65. data/vendor/libgit2/include/git2/blame.h +95 -42
  66. data/vendor/libgit2/include/git2/blob.h +37 -3
  67. data/vendor/libgit2/include/git2/branch.h +25 -0
  68. data/vendor/libgit2/include/git2/cert.h +42 -5
  69. data/vendor/libgit2/include/git2/checkout.h +28 -12
  70. data/vendor/libgit2/include/git2/clone.h +1 -1
  71. data/vendor/libgit2/include/git2/commit.h +35 -19
  72. data/vendor/libgit2/include/git2/common.h +51 -6
  73. data/vendor/libgit2/include/git2/config.h +1 -1
  74. data/vendor/libgit2/include/git2/deprecated.h +368 -8
  75. data/vendor/libgit2/include/git2/diff.h +34 -113
  76. data/vendor/libgit2/include/git2/email.h +127 -0
  77. data/vendor/libgit2/include/git2/errors.h +8 -7
  78. data/vendor/libgit2/include/git2/filter.h +63 -17
  79. data/vendor/libgit2/include/git2/graph.h +20 -2
  80. data/vendor/libgit2/include/git2/index.h +4 -5
  81. data/vendor/libgit2/include/git2/indexer.h +2 -1
  82. data/vendor/libgit2/include/git2/notes.h +2 -2
  83. data/vendor/libgit2/include/git2/odb.h +44 -20
  84. data/vendor/libgit2/include/git2/oidarray.h +5 -8
  85. data/vendor/libgit2/include/git2/pack.h +1 -1
  86. data/vendor/libgit2/include/git2/patch.h +8 -0
  87. data/vendor/libgit2/include/git2/rebase.h +25 -1
  88. data/vendor/libgit2/include/git2/refs.h +9 -5
  89. data/vendor/libgit2/include/git2/remote.h +62 -9
  90. data/vendor/libgit2/include/git2/repository.h +107 -62
  91. data/vendor/libgit2/include/git2/revparse.h +5 -5
  92. data/vendor/libgit2/include/git2/stash.h +1 -1
  93. data/vendor/libgit2/include/git2/status.h +115 -59
  94. data/vendor/libgit2/include/git2/stdint.h +3 -3
  95. data/vendor/libgit2/include/git2/strarray.h +6 -10
  96. data/vendor/libgit2/include/git2/submodule.h +9 -0
  97. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  98. data/vendor/libgit2/include/git2/sys/email.h +45 -0
  99. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  100. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  101. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
  102. data/vendor/libgit2/include/git2/sys/transport.h +1 -0
  103. data/vendor/libgit2/include/git2/tag.h +12 -0
  104. data/vendor/libgit2/include/git2/transport.h +1 -1
  105. data/vendor/libgit2/include/git2/tree.h +2 -14
  106. data/vendor/libgit2/include/git2/types.h +9 -0
  107. data/vendor/libgit2/include/git2/version.h +4 -4
  108. data/vendor/libgit2/include/git2/worktree.h +1 -0
  109. data/vendor/libgit2/include/git2.h +1 -0
  110. data/vendor/libgit2/src/CMakeLists.txt +84 -44
  111. data/vendor/libgit2/src/alloc.c +21 -8
  112. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  113. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  114. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  115. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  116. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  117. data/vendor/libgit2/src/annotated_commit.c +21 -9
  118. data/vendor/libgit2/src/apply.c +21 -8
  119. data/vendor/libgit2/src/array.h +11 -11
  120. data/vendor/libgit2/src/assert_safe.h +58 -0
  121. data/vendor/libgit2/src/attr.c +192 -70
  122. data/vendor/libgit2/src/attr_file.c +99 -41
  123. data/vendor/libgit2/src/attr_file.h +32 -11
  124. data/vendor/libgit2/src/attrcache.c +44 -40
  125. data/vendor/libgit2/src/attrcache.h +4 -5
  126. data/vendor/libgit2/src/blame.c +32 -19
  127. data/vendor/libgit2/src/blame_git.c +7 -4
  128. data/vendor/libgit2/src/blob.c +60 -32
  129. data/vendor/libgit2/src/branch.c +87 -37
  130. data/vendor/libgit2/src/buffer.c +349 -29
  131. data/vendor/libgit2/src/buffer.h +154 -2
  132. data/vendor/libgit2/src/cache.c +3 -24
  133. data/vendor/libgit2/src/cache.h +7 -7
  134. data/vendor/libgit2/src/cc-compat.h +10 -8
  135. data/vendor/libgit2/src/checkout.c +103 -105
  136. data/vendor/libgit2/src/cherrypick.c +8 -2
  137. data/vendor/libgit2/src/clone.c +105 -30
  138. data/vendor/libgit2/src/commit.c +41 -28
  139. data/vendor/libgit2/src/commit_graph.c +1209 -0
  140. data/vendor/libgit2/src/commit_graph.h +162 -0
  141. data/vendor/libgit2/src/commit_list.c +46 -0
  142. data/vendor/libgit2/src/commit_list.h +2 -0
  143. data/vendor/libgit2/src/common.h +26 -2
  144. data/vendor/libgit2/src/config.c +41 -23
  145. data/vendor/libgit2/src/config_cache.c +9 -4
  146. data/vendor/libgit2/src/config_entries.c +35 -27
  147. data/vendor/libgit2/src/config_file.c +17 -9
  148. data/vendor/libgit2/src/config_parse.c +6 -8
  149. data/vendor/libgit2/src/config_snapshot.c +2 -1
  150. data/vendor/libgit2/src/crlf.c +16 -6
  151. data/vendor/libgit2/src/date.c +4 -3
  152. data/vendor/libgit2/src/delta.c +1 -1
  153. data/vendor/libgit2/src/describe.c +12 -5
  154. data/vendor/libgit2/src/diff.c +55 -183
  155. data/vendor/libgit2/src/diff_driver.c +21 -17
  156. data/vendor/libgit2/src/diff_file.c +5 -7
  157. data/vendor/libgit2/src/diff_generate.c +56 -28
  158. data/vendor/libgit2/src/diff_parse.c +2 -3
  159. data/vendor/libgit2/src/diff_print.c +81 -65
  160. data/vendor/libgit2/src/diff_stats.c +19 -16
  161. data/vendor/libgit2/src/diff_tform.c +13 -13
  162. data/vendor/libgit2/src/diff_xdiff.c +4 -2
  163. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  164. data/vendor/libgit2/src/email.c +299 -0
  165. data/vendor/libgit2/src/email.h +25 -0
  166. data/vendor/libgit2/src/errors.c +26 -19
  167. data/vendor/libgit2/src/features.h.in +5 -1
  168. data/vendor/libgit2/src/fetch.c +7 -2
  169. data/vendor/libgit2/src/fetchhead.c +8 -4
  170. data/vendor/libgit2/src/filebuf.c +9 -7
  171. data/vendor/libgit2/src/filter.c +215 -113
  172. data/vendor/libgit2/src/filter.h +24 -5
  173. data/vendor/libgit2/src/futils.c +8 -8
  174. data/vendor/libgit2/src/futils.h +4 -4
  175. data/vendor/libgit2/src/graph.c +64 -9
  176. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
  177. data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
  178. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  179. data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
  180. data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
  181. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +8 -10
  182. data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
  183. data/vendor/libgit2/src/hash.c +16 -13
  184. data/vendor/libgit2/src/hash.h +1 -1
  185. data/vendor/libgit2/src/hashsig.c +23 -10
  186. data/vendor/libgit2/src/ident.c +13 -3
  187. data/vendor/libgit2/src/idxmap.c +0 -22
  188. data/vendor/libgit2/src/ignore.c +33 -17
  189. data/vendor/libgit2/src/index.c +124 -82
  190. data/vendor/libgit2/src/index.h +1 -1
  191. data/vendor/libgit2/src/indexer.c +95 -37
  192. data/vendor/libgit2/src/integer.h +79 -2
  193. data/vendor/libgit2/src/iterator.c +40 -28
  194. data/vendor/libgit2/src/iterator.h +1 -1
  195. data/vendor/libgit2/src/khash.h +2 -11
  196. data/vendor/libgit2/src/{settings.c → libgit2.c} +148 -49
  197. data/vendor/libgit2/src/libgit2.h +15 -0
  198. data/vendor/libgit2/src/mailmap.c +23 -10
  199. data/vendor/libgit2/src/map.h +3 -3
  200. data/vendor/libgit2/src/merge.c +95 -43
  201. data/vendor/libgit2/src/merge.h +2 -1
  202. data/vendor/libgit2/src/merge_driver.c +19 -13
  203. data/vendor/libgit2/src/merge_file.c +15 -9
  204. data/vendor/libgit2/src/message.c +3 -1
  205. data/vendor/libgit2/src/midx.c +879 -0
  206. data/vendor/libgit2/src/midx.h +110 -0
  207. data/vendor/libgit2/src/mwindow.c +214 -95
  208. data/vendor/libgit2/src/mwindow.h +3 -3
  209. data/vendor/libgit2/src/net.c +133 -4
  210. data/vendor/libgit2/src/net.h +16 -2
  211. data/vendor/libgit2/src/netops.c +6 -4
  212. data/vendor/libgit2/src/netops.h +2 -2
  213. data/vendor/libgit2/src/notes.c +40 -40
  214. data/vendor/libgit2/src/object.c +24 -15
  215. data/vendor/libgit2/src/odb.c +298 -57
  216. data/vendor/libgit2/src/odb.h +16 -2
  217. data/vendor/libgit2/src/odb_loose.c +31 -21
  218. data/vendor/libgit2/src/odb_mempack.c +3 -1
  219. data/vendor/libgit2/src/odb_pack.c +391 -114
  220. data/vendor/libgit2/src/oid.c +7 -4
  221. data/vendor/libgit2/src/oidarray.c +10 -1
  222. data/vendor/libgit2/src/pack-objects.c +83 -69
  223. data/vendor/libgit2/src/pack.c +383 -150
  224. data/vendor/libgit2/src/pack.h +44 -9
  225. data/vendor/libgit2/src/patch.c +14 -7
  226. data/vendor/libgit2/src/patch_generate.c +3 -5
  227. data/vendor/libgit2/src/patch_parse.c +6 -3
  228. data/vendor/libgit2/src/path.c +103 -58
  229. data/vendor/libgit2/src/path.h +80 -7
  230. data/vendor/libgit2/src/pathspec.c +12 -11
  231. data/vendor/libgit2/src/pool.c +34 -22
  232. data/vendor/libgit2/src/pool.h +9 -1
  233. data/vendor/libgit2/src/posix.c +43 -12
  234. data/vendor/libgit2/src/posix.h +9 -0
  235. data/vendor/libgit2/src/proxy.c +2 -0
  236. data/vendor/libgit2/src/push.c +2 -0
  237. data/vendor/libgit2/src/reader.c +10 -6
  238. data/vendor/libgit2/src/rebase.c +95 -49
  239. data/vendor/libgit2/src/refdb.c +165 -13
  240. data/vendor/libgit2/src/refdb.h +69 -0
  241. data/vendor/libgit2/src/refdb_fs.c +145 -153
  242. data/vendor/libgit2/src/reflog.c +21 -20
  243. data/vendor/libgit2/src/refs.c +153 -233
  244. data/vendor/libgit2/src/refs.h +2 -20
  245. data/vendor/libgit2/src/refspec.c +81 -45
  246. data/vendor/libgit2/src/regexp.c +2 -2
  247. data/vendor/libgit2/src/remote.c +320 -122
  248. data/vendor/libgit2/src/remote.h +2 -1
  249. data/vendor/libgit2/src/repository.c +476 -203
  250. data/vendor/libgit2/src/repository.h +27 -29
  251. data/vendor/libgit2/src/reset.c +8 -7
  252. data/vendor/libgit2/src/revert.c +8 -2
  253. data/vendor/libgit2/src/revparse.c +23 -17
  254. data/vendor/libgit2/src/revwalk.c +35 -20
  255. data/vendor/libgit2/src/runtime.c +162 -0
  256. data/vendor/libgit2/src/runtime.h +62 -0
  257. data/vendor/libgit2/src/{refdb_fs.h → settings.h} +3 -11
  258. data/vendor/libgit2/src/signature.c +6 -5
  259. data/vendor/libgit2/src/sortedcache.c +2 -3
  260. data/vendor/libgit2/src/sortedcache.h +10 -8
  261. data/vendor/libgit2/src/stash.c +6 -2
  262. data/vendor/libgit2/src/status.c +9 -4
  263. data/vendor/libgit2/src/strarray.c +64 -0
  264. data/vendor/libgit2/src/streams/mbedtls.c +14 -17
  265. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  266. data/vendor/libgit2/src/streams/openssl.c +113 -207
  267. data/vendor/libgit2/src/streams/openssl.h +9 -1
  268. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  269. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  270. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  271. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  272. data/vendor/libgit2/src/streams/registry.c +10 -9
  273. data/vendor/libgit2/src/streams/socket.c +6 -2
  274. data/vendor/libgit2/src/streams/stransport.c +6 -3
  275. data/vendor/libgit2/src/streams/tls.c +5 -3
  276. data/vendor/libgit2/src/submodule.c +134 -66
  277. data/vendor/libgit2/src/submodule.h +9 -9
  278. data/vendor/libgit2/src/sysdir.c +8 -26
  279. data/vendor/libgit2/src/sysdir.h +0 -11
  280. data/vendor/libgit2/src/tag.c +49 -11
  281. data/vendor/libgit2/src/thread.c +140 -0
  282. data/vendor/libgit2/src/thread.h +479 -0
  283. data/vendor/libgit2/src/threadstate.c +84 -0
  284. data/vendor/libgit2/src/threadstate.h +24 -0
  285. data/vendor/libgit2/src/trace.c +2 -2
  286. data/vendor/libgit2/src/trace.h +17 -13
  287. data/vendor/libgit2/src/trailer.c +1 -1
  288. data/vendor/libgit2/src/transaction.c +21 -9
  289. data/vendor/libgit2/src/transport.c +3 -3
  290. data/vendor/libgit2/src/transports/auth.c +1 -1
  291. data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
  292. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
  293. data/vendor/libgit2/src/transports/credential.c +17 -7
  294. data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
  295. data/vendor/libgit2/src/transports/git.c +1 -3
  296. data/vendor/libgit2/src/transports/http.c +19 -17
  297. data/vendor/libgit2/src/transports/http.h +1 -0
  298. data/vendor/libgit2/src/transports/httpclient.c +68 -38
  299. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  300. data/vendor/libgit2/src/transports/local.c +5 -5
  301. data/vendor/libgit2/src/transports/smart.c +14 -9
  302. data/vendor/libgit2/src/transports/smart.h +1 -1
  303. data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
  304. data/vendor/libgit2/src/transports/ssh.c +55 -21
  305. data/vendor/libgit2/src/transports/winhttp.c +157 -89
  306. data/vendor/libgit2/src/tree.c +100 -77
  307. data/vendor/libgit2/src/tree.h +1 -0
  308. data/vendor/libgit2/src/tsort.c +0 -2
  309. data/vendor/libgit2/src/unix/map.c +3 -1
  310. data/vendor/libgit2/src/unix/posix.h +16 -1
  311. data/vendor/libgit2/src/unix/pthread.h +2 -1
  312. data/vendor/libgit2/src/utf8.c +150 -0
  313. data/vendor/libgit2/src/utf8.h +52 -0
  314. data/vendor/libgit2/src/util.c +75 -184
  315. data/vendor/libgit2/src/util.h +34 -40
  316. data/vendor/libgit2/src/vector.c +23 -19
  317. data/vendor/libgit2/src/vector.h +4 -2
  318. data/vendor/libgit2/src/win32/findfile.c +5 -3
  319. data/vendor/libgit2/src/win32/git2.rc +18 -3
  320. data/vendor/libgit2/src/win32/map.c +1 -1
  321. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  322. data/vendor/libgit2/src/win32/path_w32.c +23 -25
  323. data/vendor/libgit2/src/win32/path_w32.h +0 -1
  324. data/vendor/libgit2/src/win32/posix.h +6 -6
  325. data/vendor/libgit2/src/win32/posix_w32.c +86 -7
  326. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  327. data/vendor/libgit2/src/win32/reparse.h +4 -4
  328. data/vendor/libgit2/src/win32/thread.c +24 -15
  329. data/vendor/libgit2/src/win32/thread.h +1 -1
  330. data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
  331. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  332. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  333. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  334. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  335. data/vendor/libgit2/src/worktree.c +36 -14
  336. data/vendor/libgit2/src/zstream.c +1 -1
  337. metadata +65 -42
  338. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
  339. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
  340. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  341. data/vendor/libgit2/src/buf_text.c +0 -316
  342. data/vendor/libgit2/src/buf_text.h +0 -122
  343. data/vendor/libgit2/src/global.c +0 -361
  344. data/vendor/libgit2/src/global.h +0 -41
  345. data/vendor/libgit2/src/thread-utils.c +0 -58
  346. data/vendor/libgit2/src/thread-utils.h +0 -246
  347. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  348. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  349. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -27,9 +27,6 @@
27
27
 
28
28
  bool git_reference__enable_symbolic_ref_target_validation = true;
29
29
 
30
- #define DEFAULT_NESTING_LEVEL 5
31
- #define MAX_NESTING_LEVEL 10
32
-
33
30
  enum {
34
31
  GIT_PACKREF_HAS_PEEL = 1,
35
32
  GIT_PACKREF_WAS_LOOSE = 2
@@ -53,7 +50,8 @@ git_reference *git_reference__alloc_symbolic(
53
50
  {
54
51
  git_reference *ref;
55
52
 
56
- assert(name && target);
53
+ GIT_ASSERT_ARG_WITH_RETVAL(name, NULL);
54
+ GIT_ASSERT_ARG_WITH_RETVAL(target, NULL);
57
55
 
58
56
  ref = alloc_ref(name);
59
57
  if (!ref)
@@ -76,7 +74,8 @@ git_reference *git_reference__alloc(
76
74
  {
77
75
  git_reference *ref;
78
76
 
79
- assert(name && oid);
77
+ GIT_ASSERT_ARG_WITH_RETVAL(name, NULL);
78
+ GIT_ASSERT_ARG_WITH_RETVAL(oid, NULL);
80
79
 
81
80
  ref = alloc_ref(name);
82
81
  if (!ref)
@@ -97,7 +96,8 @@ git_reference *git_reference__realloc(
97
96
  size_t namelen, reflen;
98
97
  git_reference *rewrite = NULL;
99
98
 
100
- assert(ptr_to_ref && name);
99
+ GIT_ASSERT_ARG_WITH_RETVAL(ptr_to_ref, NULL);
100
+ GIT_ASSERT_ARG_WITH_RETVAL(name, NULL);
101
101
 
102
102
  namelen = strlen(name);
103
103
 
@@ -214,97 +214,42 @@ int git_reference_lookup_resolved(
214
214
  const char *name,
215
215
  int max_nesting)
216
216
  {
217
- git_refname_t scan_name;
218
- git_reference_t scan_type;
219
- int error = 0, nesting;
220
- git_reference *ref = NULL;
217
+ git_refname_t normalized;
221
218
  git_refdb *refdb;
219
+ int error = 0;
222
220
 
223
- assert(ref_out && repo && name);
224
-
225
- *ref_out = NULL;
226
-
227
- if (max_nesting > MAX_NESTING_LEVEL)
228
- max_nesting = MAX_NESTING_LEVEL;
229
- else if (max_nesting < 0)
230
- max_nesting = DEFAULT_NESTING_LEVEL;
231
-
232
- scan_type = GIT_REFERENCE_SYMBOLIC;
233
-
234
- if ((error = reference_normalize_for_repo(scan_name, repo, name, true)) < 0)
235
- return error;
221
+ GIT_ASSERT_ARG(ref_out);
222
+ GIT_ASSERT_ARG(repo);
223
+ GIT_ASSERT_ARG(name);
236
224
 
237
- if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
225
+ if ((error = reference_normalize_for_repo(normalized, repo, name, true)) < 0 ||
226
+ (error = git_repository_refdb__weakptr(&refdb, repo)) < 0 ||
227
+ (error = git_refdb_resolve(ref_out, refdb, normalized, max_nesting)) < 0)
238
228
  return error;
239
229
 
240
- for (nesting = max_nesting;
241
- nesting >= 0 && scan_type == GIT_REFERENCE_SYMBOLIC;
242
- nesting--)
243
- {
244
- if (nesting != max_nesting) {
245
- strncpy(scan_name, ref->target.symbolic, sizeof(scan_name));
246
- git_reference_free(ref);
247
- }
248
-
249
- if ((error = git_refdb_lookup(&ref, refdb, scan_name)) < 0)
250
- return error;
251
-
252
- scan_type = ref->type;
253
- }
254
-
255
- if (scan_type != GIT_REFERENCE_DIRECT && max_nesting != 0) {
256
- git_error_set(GIT_ERROR_REFERENCE,
257
- "cannot resolve reference (>%u levels deep)", max_nesting);
258
- git_reference_free(ref);
259
- return -1;
230
+ /*
231
+ * The resolved reference may be a symbolic reference in case its
232
+ * target doesn't exist. If the user asked us to resolve (e.g.
233
+ * `max_nesting != 0`), then we need to return an error in case we got
234
+ * a symbolic reference back.
235
+ */
236
+ if (max_nesting && git_reference_type(*ref_out) == GIT_REFERENCE_SYMBOLIC) {
237
+ git_reference_free(*ref_out);
238
+ *ref_out = NULL;
239
+ return GIT_ENOTFOUND;
260
240
  }
261
241
 
262
- *ref_out = ref;
263
242
  return 0;
264
243
  }
265
244
 
266
- int git_reference__read_head(
267
- git_reference **out,
268
- git_repository *repo,
269
- const char *path)
270
- {
271
- git_buf reference = GIT_BUF_INIT;
272
- char *name = NULL;
273
- int error;
274
-
275
- if ((error = git_futils_readbuffer(&reference, path)) < 0)
276
- goto out;
277
- git_buf_rtrim(&reference);
278
-
279
- if (git__strncmp(reference.ptr, GIT_SYMREF, strlen(GIT_SYMREF)) == 0) {
280
- git_buf_consume(&reference, reference.ptr + strlen(GIT_SYMREF));
281
-
282
- name = git_path_basename(path);
283
-
284
- if ((*out = git_reference__alloc_symbolic(name, reference.ptr)) == NULL) {
285
- error = -1;
286
- goto out;
287
- }
288
- } else {
289
- if ((error = git_reference_lookup(out, repo, reference.ptr)) < 0)
290
- goto out;
291
- }
292
-
293
- out:
294
- git__free(name);
295
- git_buf_dispose(&reference);
296
-
297
- return error;
298
- }
299
-
300
245
  int git_reference_dwim(git_reference **out, git_repository *repo, const char *refname)
301
246
  {
302
- int error = 0, i;
247
+ int error = 0, i, valid;
303
248
  bool fallbackmode = true, foundvalid = false;
304
249
  git_reference *ref;
305
250
  git_buf refnamebuf = GIT_BUF_INIT, name = GIT_BUF_INIT;
306
251
 
307
- static const char* formatters[] = {
252
+ static const char *formatters[] = {
308
253
  "%s",
309
254
  GIT_REFS_DIR "%s",
310
255
  GIT_REFS_TAGS_DIR "%s",
@@ -325,10 +270,11 @@ int git_reference_dwim(git_reference **out, git_repository *repo, const char *re
325
270
 
326
271
  git_buf_clear(&refnamebuf);
327
272
 
328
- if ((error = git_buf_printf(&refnamebuf, formatters[i], git_buf_cstr(&name))) < 0)
273
+ if ((error = git_buf_printf(&refnamebuf, formatters[i], git_buf_cstr(&name))) < 0 ||
274
+ (error = git_reference_name_is_valid(&valid, git_buf_cstr(&refnamebuf))) < 0)
329
275
  goto cleanup;
330
276
 
331
- if (!git_reference_is_valid_name(git_buf_cstr(&refnamebuf))) {
277
+ if (!valid) {
332
278
  error = GIT_EINVALIDSPEC;
333
279
  continue;
334
280
  }
@@ -366,25 +312,25 @@ cleanup:
366
312
  */
367
313
  git_reference_t git_reference_type(const git_reference *ref)
368
314
  {
369
- assert(ref);
315
+ GIT_ASSERT_ARG(ref);
370
316
  return ref->type;
371
317
  }
372
318
 
373
319
  const char *git_reference_name(const git_reference *ref)
374
320
  {
375
- assert(ref);
321
+ GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
376
322
  return ref->name;
377
323
  }
378
324
 
379
325
  git_repository *git_reference_owner(const git_reference *ref)
380
326
  {
381
- assert(ref);
327
+ GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
382
328
  return ref->db->repo;
383
329
  }
384
330
 
385
331
  const git_oid *git_reference_target(const git_reference *ref)
386
332
  {
387
- assert(ref);
333
+ GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
388
334
 
389
335
  if (ref->type != GIT_REFERENCE_DIRECT)
390
336
  return NULL;
@@ -394,7 +340,7 @@ const git_oid *git_reference_target(const git_reference *ref)
394
340
 
395
341
  const git_oid *git_reference_target_peel(const git_reference *ref)
396
342
  {
397
- assert(ref);
343
+ GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
398
344
 
399
345
  if (ref->type != GIT_REFERENCE_DIRECT || git_oid_is_zero(&ref->peel))
400
346
  return NULL;
@@ -404,7 +350,7 @@ const git_oid *git_reference_target_peel(const git_reference *ref)
404
350
 
405
351
  const char *git_reference_symbolic_target(const git_reference *ref)
406
352
  {
407
- assert(ref);
353
+ GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
408
354
 
409
355
  if (ref->type != GIT_REFERENCE_SYMBOLIC)
410
356
  return NULL;
@@ -429,8 +375,9 @@ static int reference__create(
429
375
  git_reference *ref = NULL;
430
376
  int error = 0;
431
377
 
432
- assert(repo && name);
433
- assert(symbolic || signature);
378
+ GIT_ASSERT_ARG(repo);
379
+ GIT_ASSERT_ARG(name);
380
+ GIT_ASSERT_ARG(symbolic || signature);
434
381
 
435
382
  if (ref_out)
436
383
  *ref_out = NULL;
@@ -444,7 +391,7 @@ static int reference__create(
444
391
  return error;
445
392
 
446
393
  if (oid != NULL) {
447
- assert(symbolic == NULL);
394
+ GIT_ASSERT(symbolic == NULL);
448
395
 
449
396
  if (!git_object__is_valid(repo, oid, GIT_OBJECT_ANY)) {
450
397
  git_error_set(GIT_ERROR_REFERENCE,
@@ -480,7 +427,7 @@ static int reference__create(
480
427
  return 0;
481
428
  }
482
429
 
483
- int configured_ident(git_signature **out, const git_repository *repo)
430
+ static int refs_configured_ident(git_signature **out, const git_repository *repo)
484
431
  {
485
432
  if (repo->ident_name && repo->ident_email)
486
433
  return git_signature_now(out, repo->ident_name, repo->ident_email);
@@ -494,7 +441,7 @@ int git_reference__log_signature(git_signature **out, git_repository *repo)
494
441
  int error;
495
442
  git_signature *who;
496
443
 
497
- if(((error = configured_ident(&who, repo)) < 0) &&
444
+ if(((error = refs_configured_ident(&who, repo)) < 0) &&
498
445
  ((error = git_signature_default(&who, repo)) < 0) &&
499
446
  ((error = git_signature_now(&who, "unknown", "unknown")) < 0))
500
447
  return error;
@@ -516,7 +463,7 @@ int git_reference_create_matching(
516
463
  int error;
517
464
  git_signature *who = NULL;
518
465
 
519
- assert(id);
466
+ GIT_ASSERT_ARG(id);
520
467
 
521
468
  if ((error = git_reference__log_signature(&who, repo)) < 0)
522
469
  return error;
@@ -551,7 +498,7 @@ int git_reference_symbolic_create_matching(
551
498
  int error;
552
499
  git_signature *who = NULL;
553
500
 
554
- assert(target);
501
+ GIT_ASSERT_ARG(target);
555
502
 
556
503
  if ((error = git_reference__log_signature(&who, repo)) < 0)
557
504
  return error;
@@ -592,7 +539,9 @@ int git_reference_set_target(
592
539
  int error;
593
540
  git_repository *repo;
594
541
 
595
- assert(out && ref && id);
542
+ GIT_ASSERT_ARG(out);
543
+ GIT_ASSERT_ARG(ref);
544
+ GIT_ASSERT_ARG(id);
596
545
 
597
546
  repo = ref->db->repo;
598
547
 
@@ -619,7 +568,9 @@ int git_reference_symbolic_set_target(
619
568
  {
620
569
  int error;
621
570
 
622
- assert(out && ref && target);
571
+ GIT_ASSERT_ARG(out);
572
+ GIT_ASSERT_ARG(ref);
573
+ GIT_ASSERT_ARG(target);
623
574
 
624
575
  if ((error = ensure_is_an_updatable_symbolic_reference(ref)) < 0)
625
576
  return error;
@@ -631,84 +582,33 @@ int git_reference_symbolic_set_target(
631
582
  typedef struct {
632
583
  const char *old_name;
633
584
  git_refname_t new_name;
634
- } rename_cb_data;
585
+ } refs_update_head_payload;
635
586
 
636
- static int update_wt_heads(git_repository *repo, const char *path, void *payload)
587
+ static int refs_update_head(git_repository *worktree, void *_payload)
637
588
  {
638
- rename_cb_data *data = (rename_cb_data *) payload;
639
- git_reference *head = NULL;
640
- char *gitdir = NULL;
589
+ refs_update_head_payload *payload = (refs_update_head_payload *)_payload;
590
+ git_reference *head = NULL, *updated = NULL;
641
591
  int error;
642
592
 
643
- if ((error = git_reference__read_head(&head, repo, path)) < 0) {
644
- git_error_set(GIT_ERROR_REFERENCE, "could not read HEAD when renaming references");
645
- goto out;
646
- }
647
-
648
- if ((gitdir = git_path_dirname(path)) == NULL) {
649
- error = -1;
593
+ if ((error = git_reference_lookup(&head, worktree, GIT_HEAD_FILE)) < 0)
650
594
  goto out;
651
- }
652
595
 
653
596
  if (git_reference_type(head) != GIT_REFERENCE_SYMBOLIC ||
654
- git__strcmp(head->target.symbolic, data->old_name) != 0) {
655
- error = 0;
597
+ git__strcmp(git_reference_symbolic_target(head), payload->old_name) != 0)
656
598
  goto out;
657
- }
658
599
 
659
- /* Update HEAD it was pointing to the reference being renamed */
660
- if ((error = git_repository_create_head(gitdir, data->new_name)) < 0) {
600
+ /* Update HEAD if it was pointing to the reference being renamed */
601
+ if ((error = git_reference_symbolic_set_target(&updated, head, payload->new_name, NULL)) < 0) {
661
602
  git_error_set(GIT_ERROR_REFERENCE, "failed to update HEAD after renaming reference");
662
603
  goto out;
663
604
  }
664
605
 
665
606
  out:
607
+ git_reference_free(updated);
666
608
  git_reference_free(head);
667
- git__free(gitdir);
668
-
669
609
  return error;
670
610
  }
671
611
 
672
- static int reference__rename(git_reference **out, git_reference *ref, const char *new_name, int force,
673
- const git_signature *signature, const char *message)
674
- {
675
- git_repository *repo;
676
- git_refname_t normalized;
677
- bool should_head_be_updated = false;
678
- int error = 0;
679
-
680
- assert(ref && new_name && signature);
681
-
682
- repo = git_reference_owner(ref);
683
-
684
- if ((error = reference_normalize_for_repo(
685
- normalized, repo, new_name, true)) < 0)
686
- return error;
687
-
688
- /* Check if we have to update HEAD. */
689
- if ((error = git_branch_is_head(ref)) < 0)
690
- return error;
691
-
692
- should_head_be_updated = (error > 0);
693
-
694
- if ((error = git_refdb_rename(out, ref->db, ref->name, normalized, force, signature, message)) < 0)
695
- return error;
696
-
697
- /* Update HEAD if it was pointing to the reference being renamed */
698
- if (should_head_be_updated) {
699
- error = git_repository_set_head(ref->db->repo, normalized);
700
- } else {
701
- rename_cb_data payload;
702
- payload.old_name = ref->name;
703
- memcpy(&payload.new_name, &normalized, sizeof(normalized));
704
-
705
- error = git_repository_foreach_head(repo, update_wt_heads, 0, &payload);
706
- }
707
-
708
- return error;
709
- }
710
-
711
-
712
612
  int git_reference_rename(
713
613
  git_reference **out,
714
614
  git_reference *ref,
@@ -716,17 +616,29 @@ int git_reference_rename(
716
616
  int force,
717
617
  const char *log_message)
718
618
  {
719
- git_signature *who;
619
+ refs_update_head_payload payload;
620
+ git_signature *signature = NULL;
621
+ git_repository *repo;
720
622
  int error;
721
623
 
722
- assert(out && ref);
624
+ GIT_ASSERT_ARG(out);
625
+ GIT_ASSERT_ARG(ref);
723
626
 
724
- if ((error = git_reference__log_signature(&who, ref->db->repo)) < 0)
725
- return error;
627
+ repo = git_reference_owner(ref);
726
628
 
727
- error = reference__rename(out, ref, new_name, force, who, log_message);
728
- git_signature_free(who);
629
+ if ((error = git_reference__log_signature(&signature, repo)) < 0 ||
630
+ (error = reference_normalize_for_repo(payload.new_name, repo, new_name, true)) < 0 ||
631
+ (error = git_refdb_rename(out, ref->db, ref->name, payload.new_name, force, signature, log_message)) < 0)
632
+ goto out;
729
633
 
634
+ payload.old_name = ref->name;
635
+
636
+ /* We may have to update any HEAD that was pointing to the renamed reference. */
637
+ if ((error = git_repository_foreach_worktree(repo, refs_update_head, &payload)) < 0)
638
+ goto out;
639
+
640
+ out:
641
+ git_signature_free(signature);
730
642
  return error;
731
643
  }
732
644
 
@@ -876,7 +788,8 @@ int git_reference_list(
876
788
  {
877
789
  git_vector ref_list;
878
790
 
879
- assert(array && repo);
791
+ GIT_ASSERT_ARG(array);
792
+ GIT_ASSERT_ARG(repo);
880
793
 
881
794
  array->strings = NULL;
882
795
  array->count = 0;
@@ -960,7 +873,8 @@ static bool is_all_caps_and_underscore(const char *name, size_t len)
960
873
  size_t i;
961
874
  char c;
962
875
 
963
- assert(name && len > 0);
876
+ GIT_ASSERT_ARG(name);
877
+ GIT_ASSERT_ARG(len > 0);
964
878
 
965
879
  for (i = 0; i < len; i++)
966
880
  {
@@ -991,7 +905,7 @@ int git_reference__normalize_name(
991
905
  git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
992
906
  #endif
993
907
 
994
- assert(name);
908
+ GIT_ASSERT_ARG(name);
995
909
 
996
910
  process_flags = flags;
997
911
  current = (char *)name;
@@ -1123,7 +1037,8 @@ int git_reference_normalize_name(
1123
1037
  goto cleanup;
1124
1038
  }
1125
1039
 
1126
- git_buf_copy_cstr(buffer_out, buffer_size, &buf);
1040
+ if ((error = git_buf_copy_cstr(buffer_out, buffer_size, &buf)) < 0)
1041
+ goto cleanup;
1127
1042
 
1128
1043
  error = 0;
1129
1044
 
@@ -1139,7 +1054,9 @@ int git_reference_cmp(
1139
1054
  const git_reference *ref2)
1140
1055
  {
1141
1056
  git_reference_t type1, type2;
1142
- assert(ref1 && ref2);
1057
+
1058
+ GIT_ASSERT_ARG(ref1);
1059
+ GIT_ASSERT_ARG(ref2);
1143
1060
 
1144
1061
  type1 = git_reference_type(ref1);
1145
1062
  type2 = git_reference_type(ref2);
@@ -1154,40 +1071,6 @@ int git_reference_cmp(
1154
1071
  return git_oid__cmp(&ref1->target.oid, &ref2->target.oid);
1155
1072
  }
1156
1073
 
1157
- /**
1158
- * Get the end of a chain of references. If the final one is not
1159
- * found, we return the reference just before that.
1160
- */
1161
- static int get_terminal(git_reference **out, git_repository *repo, const char *ref_name, int nesting)
1162
- {
1163
- git_reference *ref;
1164
- int error = 0;
1165
-
1166
- if (nesting > MAX_NESTING_LEVEL) {
1167
- git_error_set(GIT_ERROR_REFERENCE, "reference chain too deep (%d)", nesting);
1168
- return GIT_ENOTFOUND;
1169
- }
1170
-
1171
- /* set to NULL to let the caller know that they're at the end of the chain */
1172
- if ((error = git_reference_lookup(&ref, repo, ref_name)) < 0) {
1173
- *out = NULL;
1174
- return error;
1175
- }
1176
-
1177
- if (git_reference_type(ref) == GIT_REFERENCE_DIRECT) {
1178
- *out = ref;
1179
- error = 0;
1180
- } else {
1181
- error = get_terminal(out, repo, git_reference_symbolic_target(ref), nesting + 1);
1182
- if (error == GIT_ENOTFOUND && !*out)
1183
- *out = ref;
1184
- else
1185
- git_reference_free(ref);
1186
- }
1187
-
1188
- return error;
1189
- }
1190
-
1191
1074
  /*
1192
1075
  * Starting with the reference given by `ref_name`, follows symbolic
1193
1076
  * references until a direct reference is found and updated the OID
@@ -1202,31 +1085,37 @@ int git_reference__update_terminal(
1202
1085
  {
1203
1086
  git_reference *ref = NULL, *ref2 = NULL;
1204
1087
  git_signature *who = NULL;
1088
+ git_refdb *refdb = NULL;
1205
1089
  const git_signature *to_use;
1206
1090
  int error = 0;
1207
1091
 
1208
1092
  if (!sig && (error = git_reference__log_signature(&who, repo)) < 0)
1209
- return error;
1093
+ goto out;
1210
1094
 
1211
1095
  to_use = sig ? sig : who;
1212
- error = get_terminal(&ref, repo, ref_name, 0);
1213
1096
 
1214
- /* found a dangling symref */
1215
- if (error == GIT_ENOTFOUND && ref) {
1216
- assert(git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC);
1217
- git_error_clear();
1097
+ if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
1098
+ goto out;
1099
+
1100
+ if ((error = git_refdb_resolve(&ref, refdb, ref_name, -1)) < 0) {
1101
+ if (error == GIT_ENOTFOUND) {
1102
+ git_error_clear();
1103
+ error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use,
1104
+ log_message, NULL, NULL);
1105
+ }
1106
+ goto out;
1107
+ }
1108
+
1109
+ /* In case the resolved reference is symbolic, then it's a dangling symref. */
1110
+ if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
1218
1111
  error = reference__create(&ref2, repo, ref->target.symbolic, oid, NULL, 0, to_use,
1219
1112
  log_message, NULL, NULL);
1220
- } else if (error == GIT_ENOTFOUND) {
1221
- git_error_clear();
1222
- error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use,
1223
- log_message, NULL, NULL);
1224
- } else if (error == 0) {
1225
- assert(git_reference_type(ref) == GIT_REFERENCE_DIRECT);
1113
+ } else {
1226
1114
  error = reference__create(&ref2, repo, ref->name, oid, NULL, 1, to_use,
1227
1115
  log_message, &ref->target.oid, NULL);
1228
1116
  }
1229
1117
 
1118
+ out:
1230
1119
  git_reference_free(ref2);
1231
1120
  git_reference_free(ref);
1232
1121
  git_signature_free(who);
@@ -1290,7 +1179,8 @@ int git_reference_has_log(git_repository *repo, const char *refname)
1290
1179
  int error;
1291
1180
  git_refdb *refdb;
1292
1181
 
1293
- assert(repo && refname);
1182
+ GIT_ASSERT_ARG(repo);
1183
+ GIT_ASSERT_ARG(refname);
1294
1184
 
1295
1185
  if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
1296
1186
  return error;
@@ -1303,7 +1193,8 @@ int git_reference_ensure_log(git_repository *repo, const char *refname)
1303
1193
  int error;
1304
1194
  git_refdb *refdb;
1305
1195
 
1306
- assert(repo && refname);
1196
+ GIT_ASSERT_ARG(repo);
1197
+ GIT_ASSERT_ARG(refname);
1307
1198
 
1308
1199
  if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
1309
1200
  return error;
@@ -1318,7 +1209,7 @@ int git_reference__is_branch(const char *ref_name)
1318
1209
 
1319
1210
  int git_reference_is_branch(const git_reference *ref)
1320
1211
  {
1321
- assert(ref);
1212
+ GIT_ASSERT_ARG(ref);
1322
1213
  return git_reference__is_branch(ref->name);
1323
1214
  }
1324
1215
 
@@ -1329,7 +1220,7 @@ int git_reference__is_remote(const char *ref_name)
1329
1220
 
1330
1221
  int git_reference_is_remote(const git_reference *ref)
1331
1222
  {
1332
- assert(ref);
1223
+ GIT_ASSERT_ARG(ref);
1333
1224
  return git_reference__is_remote(ref->name);
1334
1225
  }
1335
1226
 
@@ -1340,7 +1231,7 @@ int git_reference__is_tag(const char *ref_name)
1340
1231
 
1341
1232
  int git_reference_is_tag(const git_reference *ref)
1342
1233
  {
1343
- assert(ref);
1234
+ GIT_ASSERT_ARG(ref);
1344
1235
  return git_reference__is_tag(ref->name);
1345
1236
  }
1346
1237
 
@@ -1351,11 +1242,11 @@ int git_reference__is_note(const char *ref_name)
1351
1242
 
1352
1243
  int git_reference_is_note(const git_reference *ref)
1353
1244
  {
1354
- assert(ref);
1245
+ GIT_ASSERT_ARG(ref);
1355
1246
  return git_reference__is_note(ref->name);
1356
1247
  }
1357
1248
 
1358
- static int peel_error(int error, const git_reference *ref, const char* msg)
1249
+ static int peel_error(int error, const git_reference *ref, const char *msg)
1359
1250
  {
1360
1251
  git_error_set(
1361
1252
  GIT_ERROR_INVALID,
@@ -1373,7 +1264,7 @@ int git_reference_peel(
1373
1264
  git_object *target = NULL;
1374
1265
  int error;
1375
1266
 
1376
- assert(ref);
1267
+ GIT_ASSERT_ARG(ref);
1377
1268
 
1378
1269
  if (ref->type == GIT_REFERENCE_DIRECT) {
1379
1270
  resolved = ref;
@@ -1415,19 +1306,30 @@ cleanup:
1415
1306
  return error;
1416
1307
  }
1417
1308
 
1418
- int git_reference__is_valid_name(const char *refname, unsigned int flags)
1309
+ int git_reference__name_is_valid(
1310
+ int *valid,
1311
+ const char *refname,
1312
+ unsigned int flags)
1419
1313
  {
1420
- if (git_reference__normalize_name(NULL, refname, flags) < 0) {
1421
- git_error_clear();
1422
- return false;
1423
- }
1314
+ int error;
1424
1315
 
1425
- return true;
1316
+ GIT_ASSERT(valid && refname);
1317
+
1318
+ *valid = 0;
1319
+
1320
+ error = git_reference__normalize_name(NULL, refname, flags);
1321
+
1322
+ if (!error)
1323
+ *valid = 1;
1324
+ else if (error == GIT_EINVALIDSPEC)
1325
+ error = 0;
1326
+
1327
+ return error;
1426
1328
  }
1427
1329
 
1428
- int git_reference_is_valid_name(const char *refname)
1330
+ int git_reference_name_is_valid(int *valid, const char *refname)
1429
1331
  {
1430
- return git_reference__is_valid_name(refname, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL);
1332
+ return git_reference__name_is_valid(valid, refname, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL);
1431
1333
  }
1432
1334
 
1433
1335
  const char *git_reference__shorthand(const char *name)
@@ -1441,7 +1343,7 @@ const char *git_reference__shorthand(const char *name)
1441
1343
  else if (!git__prefixcmp(name, GIT_REFS_DIR))
1442
1344
  return name + strlen(GIT_REFS_DIR);
1443
1345
 
1444
- /* No shorthands are avaiable, so just return the name */
1346
+ /* No shorthands are available, so just return the name. */
1445
1347
  return name;
1446
1348
  }
1447
1349
 
@@ -1454,7 +1356,10 @@ int git_reference__is_unborn_head(bool *unborn, const git_reference *ref, git_re
1454
1356
  {
1455
1357
  int error;
1456
1358
  git_reference *tmp_ref;
1457
- assert(unborn && ref && repo);
1359
+
1360
+ GIT_ASSERT_ARG(unborn);
1361
+ GIT_ASSERT_ARG(ref);
1362
+ GIT_ASSERT_ARG(repo);
1458
1363
 
1459
1364
  if (ref->type == GIT_REFERENCE_DIRECT) {
1460
1365
  *unborn = 0;
@@ -1473,3 +1378,18 @@ int git_reference__is_unborn_head(bool *unborn, const git_reference *ref, git_re
1473
1378
 
1474
1379
  return 0;
1475
1380
  }
1381
+
1382
+ /* Deprecated functions */
1383
+
1384
+ #ifndef GIT_DEPRECATE_HARD
1385
+
1386
+ int git_reference_is_valid_name(const char *refname)
1387
+ {
1388
+ int valid = 0;
1389
+
1390
+ git_reference__name_is_valid(&valid, refname, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL);
1391
+
1392
+ return valid;
1393
+ }
1394
+
1395
+ #endif