rugged 0.27.7 → 0.27.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (409) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/AUTHORS +1 -0
  4. data/vendor/libgit2/CMakeLists.txt +99 -51
  5. data/vendor/libgit2/COPYING +28 -0
  6. data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
  7. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +29 -0
  8. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +96 -0
  9. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +9 -8
  10. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
  11. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
  12. data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +28 -0
  13. data/vendor/libgit2/cmake/Modules/FindIconv.cmake +11 -6
  14. data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +38 -0
  15. data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +37 -0
  16. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
  17. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +6 -0
  18. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +110 -0
  19. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +53 -0
  20. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +124 -0
  21. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +66 -0
  22. data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
  23. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +21 -0
  24. data/vendor/libgit2/deps/ntlmclient/compat.h +33 -0
  25. data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
  26. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
  27. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
  28. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
  29. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
  30. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
  31. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
  32. data/vendor/libgit2/deps/ntlmclient/ntlm.c +1420 -0
  33. data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
  34. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
  35. data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
  36. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
  37. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
  38. data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
  39. data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
  40. data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
  41. data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
  42. data/vendor/libgit2/deps/pcre/COPYING +5 -0
  43. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
  44. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
  45. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
  46. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
  47. data/vendor/libgit2/deps/pcre/config.h.in +57 -0
  48. data/vendor/libgit2/deps/pcre/pcre.h +641 -0
  49. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
  50. data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
  51. data/vendor/libgit2/deps/pcre/pcre_compile.c +9800 -0
  52. data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
  53. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
  54. data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
  55. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
  56. data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
  57. data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
  58. data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
  59. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
  60. data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
  61. data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
  62. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
  63. data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
  64. data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
  65. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
  66. data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
  67. data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
  68. data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
  69. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
  70. data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
  71. data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
  72. data/vendor/libgit2/deps/pcre/pcreposix.c +421 -0
  73. data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
  74. data/vendor/libgit2/deps/pcre/ucp.h +224 -0
  75. data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
  76. data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
  77. data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
  78. data/vendor/libgit2/deps/zlib/COPYING +27 -0
  79. data/vendor/libgit2/deps/zlib/adler32.c +0 -7
  80. data/vendor/libgit2/deps/zlib/crc32.c +0 -7
  81. data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
  82. data/vendor/libgit2/include/git2/apply.h +149 -0
  83. data/vendor/libgit2/include/git2/attr.h +20 -13
  84. data/vendor/libgit2/include/git2/blame.h +4 -4
  85. data/vendor/libgit2/include/git2/blob.h +44 -12
  86. data/vendor/libgit2/include/git2/buffer.h +20 -26
  87. data/vendor/libgit2/include/git2/cert.h +135 -0
  88. data/vendor/libgit2/include/git2/checkout.h +53 -21
  89. data/vendor/libgit2/include/git2/cherrypick.h +3 -3
  90. data/vendor/libgit2/include/git2/clone.h +5 -5
  91. data/vendor/libgit2/include/git2/commit.h +25 -3
  92. data/vendor/libgit2/include/git2/common.h +35 -10
  93. data/vendor/libgit2/include/git2/config.h +29 -19
  94. data/vendor/libgit2/include/git2/cred.h +308 -0
  95. data/vendor/libgit2/include/git2/deprecated.h +493 -0
  96. data/vendor/libgit2/include/git2/describe.h +4 -4
  97. data/vendor/libgit2/include/git2/diff.h +177 -135
  98. data/vendor/libgit2/include/git2/errors.h +53 -46
  99. data/vendor/libgit2/include/git2/filter.h +8 -0
  100. data/vendor/libgit2/include/git2/index.h +74 -52
  101. data/vendor/libgit2/include/git2/indexer.h +76 -6
  102. data/vendor/libgit2/include/git2/merge.h +25 -10
  103. data/vendor/libgit2/include/git2/net.h +0 -5
  104. data/vendor/libgit2/include/git2/notes.h +1 -1
  105. data/vendor/libgit2/include/git2/object.h +17 -29
  106. data/vendor/libgit2/include/git2/odb.h +12 -11
  107. data/vendor/libgit2/include/git2/odb_backend.h +10 -9
  108. data/vendor/libgit2/include/git2/oid.h +2 -2
  109. data/vendor/libgit2/include/git2/pack.h +14 -3
  110. data/vendor/libgit2/include/git2/proxy.h +5 -3
  111. data/vendor/libgit2/include/git2/rebase.h +46 -2
  112. data/vendor/libgit2/include/git2/refs.h +34 -16
  113. data/vendor/libgit2/include/git2/remote.h +111 -14
  114. data/vendor/libgit2/include/git2/repository.h +69 -34
  115. data/vendor/libgit2/include/git2/revert.h +1 -1
  116. data/vendor/libgit2/include/git2/revwalk.h +7 -7
  117. data/vendor/libgit2/include/git2/signature.h +2 -2
  118. data/vendor/libgit2/include/git2/stash.h +5 -5
  119. data/vendor/libgit2/include/git2/status.h +26 -17
  120. data/vendor/libgit2/include/git2/submodule.h +23 -6
  121. data/vendor/libgit2/include/git2/sys/alloc.h +18 -18
  122. data/vendor/libgit2/include/git2/sys/commit.h +1 -1
  123. data/vendor/libgit2/include/git2/sys/config.h +13 -13
  124. data/vendor/libgit2/include/git2/sys/cred.h +90 -0
  125. data/vendor/libgit2/include/git2/sys/filter.h +6 -6
  126. data/vendor/libgit2/include/git2/sys/merge.h +3 -3
  127. data/vendor/libgit2/include/git2/sys/odb_backend.h +66 -22
  128. data/vendor/libgit2/include/git2/sys/path.h +14 -5
  129. data/vendor/libgit2/include/git2/sys/refdb_backend.h +76 -40
  130. data/vendor/libgit2/include/git2/sys/repository.h +5 -1
  131. data/vendor/libgit2/include/git2/sys/stream.h +92 -12
  132. data/vendor/libgit2/include/git2/sys/transport.h +129 -83
  133. data/vendor/libgit2/include/git2/tag.h +13 -4
  134. data/vendor/libgit2/include/git2/trace.h +2 -2
  135. data/vendor/libgit2/include/git2/transport.h +11 -311
  136. data/vendor/libgit2/include/git2/tree.h +4 -4
  137. data/vendor/libgit2/include/git2/types.h +25 -106
  138. data/vendor/libgit2/include/git2/version.h +3 -3
  139. data/vendor/libgit2/include/git2/worktree.h +5 -5
  140. data/vendor/libgit2/include/git2.h +4 -0
  141. data/vendor/libgit2/src/CMakeLists.txt +104 -235
  142. data/vendor/libgit2/src/alloc.c +14 -18
  143. data/vendor/libgit2/src/{stdalloc.c → allocators/stdalloc.c} +7 -8
  144. data/vendor/libgit2/src/{stdalloc.h → allocators/stdalloc.h} +4 -4
  145. data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
  146. data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
  147. data/vendor/libgit2/src/annotated_commit.c +18 -11
  148. data/vendor/libgit2/src/apply.c +535 -28
  149. data/vendor/libgit2/src/apply.h +3 -1
  150. data/vendor/libgit2/src/array.h +2 -2
  151. data/vendor/libgit2/src/attr.c +77 -71
  152. data/vendor/libgit2/src/attr_file.c +203 -117
  153. data/vendor/libgit2/src/attr_file.h +9 -9
  154. data/vendor/libgit2/src/attrcache.c +49 -51
  155. data/vendor/libgit2/src/attrcache.h +2 -1
  156. data/vendor/libgit2/src/blame.c +38 -18
  157. data/vendor/libgit2/src/blame.h +1 -1
  158. data/vendor/libgit2/src/blame_git.c +29 -15
  159. data/vendor/libgit2/src/blob.c +123 -37
  160. data/vendor/libgit2/src/blob.h +19 -2
  161. data/vendor/libgit2/src/branch.c +47 -23
  162. data/vendor/libgit2/src/buf_text.c +7 -6
  163. data/vendor/libgit2/src/buffer.c +60 -53
  164. data/vendor/libgit2/src/cache.c +38 -45
  165. data/vendor/libgit2/src/cache.h +3 -3
  166. data/vendor/libgit2/src/cc-compat.h +20 -3
  167. data/vendor/libgit2/src/checkout.c +77 -67
  168. data/vendor/libgit2/src/cherrypick.c +12 -6
  169. data/vendor/libgit2/src/clone.c +36 -14
  170. data/vendor/libgit2/src/clone.h +4 -0
  171. data/vendor/libgit2/src/commit.c +103 -48
  172. data/vendor/libgit2/src/commit.h +7 -0
  173. data/vendor/libgit2/src/commit_list.c +36 -78
  174. data/vendor/libgit2/src/commit_list.h +2 -2
  175. data/vendor/libgit2/src/common.h +24 -90
  176. data/vendor/libgit2/src/config.c +203 -176
  177. data/vendor/libgit2/src/config.h +8 -20
  178. data/vendor/libgit2/src/config_backend.h +96 -0
  179. data/vendor/libgit2/src/config_cache.c +41 -35
  180. data/vendor/libgit2/src/config_entries.c +229 -0
  181. data/vendor/libgit2/src/config_entries.h +24 -0
  182. data/vendor/libgit2/src/config_file.c +422 -680
  183. data/vendor/libgit2/src/config_mem.c +220 -0
  184. data/vendor/libgit2/src/config_parse.c +96 -68
  185. data/vendor/libgit2/src/config_parse.h +15 -14
  186. data/vendor/libgit2/src/config_snapshot.c +206 -0
  187. data/vendor/libgit2/src/crlf.c +219 -196
  188. data/vendor/libgit2/src/delta.c +25 -18
  189. data/vendor/libgit2/src/describe.c +42 -41
  190. data/vendor/libgit2/src/diff.c +52 -67
  191. data/vendor/libgit2/src/diff.h +2 -1
  192. data/vendor/libgit2/src/diff_driver.c +44 -46
  193. data/vendor/libgit2/src/diff_file.c +16 -14
  194. data/vendor/libgit2/src/diff_file.h +1 -1
  195. data/vendor/libgit2/src/diff_generate.c +158 -103
  196. data/vendor/libgit2/src/diff_generate.h +3 -3
  197. data/vendor/libgit2/src/diff_parse.c +4 -4
  198. data/vendor/libgit2/src/diff_print.c +34 -22
  199. data/vendor/libgit2/src/diff_stats.c +22 -7
  200. data/vendor/libgit2/src/diff_tform.c +18 -16
  201. data/vendor/libgit2/src/diff_xdiff.c +3 -3
  202. data/vendor/libgit2/src/errors.c +51 -39
  203. data/vendor/libgit2/src/errors.h +81 -0
  204. data/vendor/libgit2/src/features.h.in +9 -3
  205. data/vendor/libgit2/src/fetch.c +8 -3
  206. data/vendor/libgit2/src/fetchhead.c +12 -12
  207. data/vendor/libgit2/src/filebuf.c +28 -32
  208. data/vendor/libgit2/src/filebuf.h +2 -2
  209. data/vendor/libgit2/src/filter.c +47 -33
  210. data/vendor/libgit2/src/filter.h +0 -10
  211. data/vendor/libgit2/src/{fileops.c → futils.c} +70 -63
  212. data/vendor/libgit2/src/{fileops.h → futils.h} +6 -6
  213. data/vendor/libgit2/src/global.c +35 -55
  214. data/vendor/libgit2/src/global.h +0 -2
  215. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +48 -0
  216. data/vendor/libgit2/src/hash/sha1/collisiondetect.h +19 -0
  217. data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +17 -17
  218. data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
  219. data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
  220. data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -10
  221. data/vendor/libgit2/src/hash/{hash_mbedtls.c → sha1/mbedtls.c} +15 -7
  222. data/vendor/libgit2/src/hash/{hash_mbedtls.h → sha1/mbedtls.h} +6 -7
  223. data/vendor/libgit2/src/hash/sha1/openssl.c +59 -0
  224. data/vendor/libgit2/src/hash/sha1/openssl.h +19 -0
  225. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
  226. data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +47 -37
  227. data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
  228. data/vendor/libgit2/src/hash/sha1.h +38 -0
  229. data/vendor/libgit2/src/hash.c +61 -0
  230. data/vendor/libgit2/src/hash.h +20 -21
  231. data/vendor/libgit2/src/hashsig.c +5 -5
  232. data/vendor/libgit2/src/idxmap.c +107 -61
  233. data/vendor/libgit2/src/idxmap.h +153 -31
  234. data/vendor/libgit2/src/ignore.c +38 -42
  235. data/vendor/libgit2/src/index.c +264 -199
  236. data/vendor/libgit2/src/index.h +7 -1
  237. data/vendor/libgit2/src/indexer.c +338 -167
  238. data/vendor/libgit2/src/integer.h +71 -26
  239. data/vendor/libgit2/src/iterator.c +134 -62
  240. data/vendor/libgit2/src/iterator.h +15 -0
  241. data/vendor/libgit2/src/mailmap.c +8 -8
  242. data/vendor/libgit2/src/map.h +1 -1
  243. data/vendor/libgit2/src/merge.c +137 -93
  244. data/vendor/libgit2/src/merge_driver.c +11 -11
  245. data/vendor/libgit2/src/merge_file.c +2 -2
  246. data/vendor/libgit2/src/mwindow.c +24 -29
  247. data/vendor/libgit2/src/mwindow.h +4 -4
  248. data/vendor/libgit2/src/net.c +184 -0
  249. data/vendor/libgit2/src/net.h +36 -0
  250. data/vendor/libgit2/src/netops.c +55 -156
  251. data/vendor/libgit2/src/netops.h +3 -23
  252. data/vendor/libgit2/src/notes.c +14 -9
  253. data/vendor/libgit2/src/object.c +120 -69
  254. data/vendor/libgit2/src/object.h +22 -9
  255. data/vendor/libgit2/src/object_api.c +8 -8
  256. data/vendor/libgit2/src/odb.c +111 -88
  257. data/vendor/libgit2/src/odb.h +8 -7
  258. data/vendor/libgit2/src/odb_loose.c +58 -47
  259. data/vendor/libgit2/src/odb_mempack.c +21 -34
  260. data/vendor/libgit2/src/odb_pack.c +17 -13
  261. data/vendor/libgit2/src/offmap.c +53 -35
  262. data/vendor/libgit2/src/offmap.h +108 -21
  263. data/vendor/libgit2/src/oid.c +12 -7
  264. data/vendor/libgit2/src/oidmap.c +49 -47
  265. data/vendor/libgit2/src/oidmap.h +101 -24
  266. data/vendor/libgit2/src/pack-objects.c +87 -86
  267. data/vendor/libgit2/src/pack-objects.h +2 -8
  268. data/vendor/libgit2/src/pack.c +94 -96
  269. data/vendor/libgit2/src/pack.h +16 -18
  270. data/vendor/libgit2/src/parse.c +17 -4
  271. data/vendor/libgit2/src/parse.h +3 -3
  272. data/vendor/libgit2/src/patch.c +3 -3
  273. data/vendor/libgit2/src/patch_generate.c +18 -18
  274. data/vendor/libgit2/src/patch_parse.c +147 -79
  275. data/vendor/libgit2/src/path.c +207 -62
  276. data/vendor/libgit2/src/path.h +14 -0
  277. data/vendor/libgit2/src/pathspec.c +18 -18
  278. data/vendor/libgit2/src/pool.c +26 -22
  279. data/vendor/libgit2/src/pool.h +7 -7
  280. data/vendor/libgit2/src/posix.c +10 -10
  281. data/vendor/libgit2/src/posix.h +12 -1
  282. data/vendor/libgit2/src/proxy.c +8 -3
  283. data/vendor/libgit2/src/push.c +35 -29
  284. data/vendor/libgit2/src/push.h +2 -1
  285. data/vendor/libgit2/src/reader.c +265 -0
  286. data/vendor/libgit2/src/reader.h +107 -0
  287. data/vendor/libgit2/src/rebase.c +97 -38
  288. data/vendor/libgit2/src/refdb.c +15 -3
  289. data/vendor/libgit2/src/refdb_fs.c +318 -222
  290. data/vendor/libgit2/src/reflog.c +13 -15
  291. data/vendor/libgit2/src/refs.c +122 -89
  292. data/vendor/libgit2/src/refs.h +5 -3
  293. data/vendor/libgit2/src/refspec.c +27 -33
  294. data/vendor/libgit2/src/regexp.c +221 -0
  295. data/vendor/libgit2/src/regexp.h +97 -0
  296. data/vendor/libgit2/src/remote.c +229 -178
  297. data/vendor/libgit2/src/remote.h +11 -2
  298. data/vendor/libgit2/src/repository.c +227 -172
  299. data/vendor/libgit2/src/repository.h +52 -40
  300. data/vendor/libgit2/src/reset.c +7 -7
  301. data/vendor/libgit2/src/revert.c +11 -6
  302. data/vendor/libgit2/src/revparse.c +46 -46
  303. data/vendor/libgit2/src/revwalk.c +89 -54
  304. data/vendor/libgit2/src/revwalk.h +20 -0
  305. data/vendor/libgit2/src/settings.c +22 -9
  306. data/vendor/libgit2/src/signature.c +15 -13
  307. data/vendor/libgit2/src/sortedcache.c +22 -36
  308. data/vendor/libgit2/src/sortedcache.h +1 -1
  309. data/vendor/libgit2/src/stash.c +56 -76
  310. data/vendor/libgit2/src/status.c +27 -21
  311. data/vendor/libgit2/src/stream.h +17 -2
  312. data/vendor/libgit2/src/streams/mbedtls.c +100 -80
  313. data/vendor/libgit2/src/streams/mbedtls.h +5 -2
  314. data/vendor/libgit2/src/streams/openssl.c +93 -81
  315. data/vendor/libgit2/src/streams/openssl.h +5 -2
  316. data/vendor/libgit2/src/streams/registry.c +118 -0
  317. data/vendor/libgit2/src/streams/registry.h +19 -0
  318. data/vendor/libgit2/src/streams/socket.c +55 -30
  319. data/vendor/libgit2/src/streams/stransport.c +57 -32
  320. data/vendor/libgit2/src/streams/stransport.h +5 -0
  321. data/vendor/libgit2/src/streams/tls.c +48 -20
  322. data/vendor/libgit2/src/streams/tls.h +12 -4
  323. data/vendor/libgit2/src/strmap.c +47 -74
  324. data/vendor/libgit2/src/strmap.h +108 -33
  325. data/vendor/libgit2/src/submodule.c +190 -169
  326. data/vendor/libgit2/src/submodule.h +1 -1
  327. data/vendor/libgit2/src/sysdir.c +25 -15
  328. data/vendor/libgit2/src/tag.c +39 -26
  329. data/vendor/libgit2/src/tag.h +2 -1
  330. data/vendor/libgit2/src/trace.c +2 -2
  331. data/vendor/libgit2/src/trace.h +2 -2
  332. data/vendor/libgit2/src/trailer.c +46 -32
  333. data/vendor/libgit2/src/transaction.c +30 -29
  334. data/vendor/libgit2/src/transport.c +3 -3
  335. data/vendor/libgit2/src/transports/auth.c +14 -10
  336. data/vendor/libgit2/src/transports/auth.h +10 -3
  337. data/vendor/libgit2/src/transports/auth_negotiate.c +31 -16
  338. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  339. data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
  340. data/vendor/libgit2/src/transports/auth_ntlm.h +35 -0
  341. data/vendor/libgit2/src/transports/cred.c +24 -24
  342. data/vendor/libgit2/src/transports/git.c +25 -30
  343. data/vendor/libgit2/src/transports/http.c +871 -335
  344. data/vendor/libgit2/src/transports/http.h +2 -0
  345. data/vendor/libgit2/src/transports/local.c +28 -28
  346. data/vendor/libgit2/src/transports/smart.c +64 -46
  347. data/vendor/libgit2/src/transports/smart.h +5 -6
  348. data/vendor/libgit2/src/transports/smart_pkt.c +162 -151
  349. data/vendor/libgit2/src/transports/smart_protocol.c +64 -94
  350. data/vendor/libgit2/src/transports/ssh.c +76 -65
  351. data/vendor/libgit2/src/transports/winhttp.c +328 -319
  352. data/vendor/libgit2/src/tree-cache.c +21 -14
  353. data/vendor/libgit2/src/tree.c +119 -112
  354. data/vendor/libgit2/src/tree.h +1 -0
  355. data/vendor/libgit2/src/unix/map.c +3 -3
  356. data/vendor/libgit2/src/unix/posix.h +1 -11
  357. data/vendor/libgit2/src/userdiff.h +3 -1
  358. data/vendor/libgit2/src/util.c +154 -93
  359. data/vendor/libgit2/src/util.h +19 -23
  360. data/vendor/libgit2/src/vector.c +15 -10
  361. data/vendor/libgit2/src/wildmatch.c +320 -0
  362. data/vendor/libgit2/src/wildmatch.h +23 -0
  363. data/vendor/libgit2/src/win32/dir.c +3 -3
  364. data/vendor/libgit2/src/win32/findfile.c +1 -1
  365. data/vendor/libgit2/src/win32/map.c +9 -11
  366. data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
  367. data/vendor/libgit2/src/win32/path_w32.c +113 -9
  368. data/vendor/libgit2/src/win32/path_w32.h +18 -29
  369. data/vendor/libgit2/src/win32/posix.h +1 -4
  370. data/vendor/libgit2/src/win32/posix_w32.c +69 -44
  371. data/vendor/libgit2/src/win32/precompiled.h +0 -2
  372. data/vendor/libgit2/src/win32/thread.c +5 -10
  373. data/vendor/libgit2/src/win32/w32_buffer.c +9 -5
  374. data/vendor/libgit2/src/win32/w32_common.h +39 -0
  375. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +2 -95
  376. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -2
  377. data/vendor/libgit2/src/win32/w32_stack.c +6 -11
  378. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  379. data/vendor/libgit2/src/win32/w32_util.c +27 -64
  380. data/vendor/libgit2/src/win32/w32_util.h +5 -49
  381. data/vendor/libgit2/src/worktree.c +44 -30
  382. data/vendor/libgit2/src/xdiff/xdiffi.c +5 -5
  383. data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
  384. data/vendor/libgit2/src/xdiff/xmerge.c +27 -15
  385. data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
  386. data/vendor/libgit2/src/zstream.c +4 -4
  387. metadata +115 -38
  388. data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
  389. data/vendor/libgit2/deps/regex/config.h +0 -7
  390. data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
  391. data/vendor/libgit2/deps/regex/regex.c +0 -92
  392. data/vendor/libgit2/deps/regex/regex.h +0 -582
  393. data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
  394. data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
  395. data/vendor/libgit2/deps/regex/regexec.c +0 -4369
  396. data/vendor/libgit2/include/git2/inttypes.h +0 -309
  397. data/vendor/libgit2/include/git2/sys/time.h +0 -31
  398. data/vendor/libgit2/libgit2.pc.in +0 -13
  399. data/vendor/libgit2/src/config_file.h +0 -73
  400. data/vendor/libgit2/src/fnmatch.c +0 -248
  401. data/vendor/libgit2/src/fnmatch.h +0 -48
  402. data/vendor/libgit2/src/hash/hash_collisiondetect.h +0 -47
  403. data/vendor/libgit2/src/hash/hash_openssl.h +0 -59
  404. data/vendor/libgit2/src/streams/curl.c +0 -385
  405. data/vendor/libgit2/src/streams/curl.h +0 -17
  406. /data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
  407. /data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
  408. /data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
  409. /data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
@@ -16,7 +16,7 @@
16
16
  #include "commit.h"
17
17
  #include "tag.h"
18
18
  #include "blob.h"
19
- #include "fileops.h"
19
+ #include "futils.h"
20
20
  #include "sysdir.h"
21
21
  #include "filebuf.h"
22
22
  #include "index.h"
@@ -42,23 +42,24 @@ bool git_repository__fsync_gitdir = false;
42
42
 
43
43
  static const struct {
44
44
  git_repository_item_t parent;
45
+ git_repository_item_t fallback;
45
46
  const char *name;
46
47
  bool directory;
47
48
  } items[] = {
48
- { GIT_REPOSITORY_ITEM_GITDIR, NULL, true },
49
- { GIT_REPOSITORY_ITEM_WORKDIR, NULL, true },
50
- { GIT_REPOSITORY_ITEM_COMMONDIR, NULL, true },
51
- { GIT_REPOSITORY_ITEM_GITDIR, "index", false },
52
- { GIT_REPOSITORY_ITEM_COMMONDIR, "objects", true },
53
- { GIT_REPOSITORY_ITEM_COMMONDIR, "refs", true },
54
- { GIT_REPOSITORY_ITEM_COMMONDIR, "packed-refs", false },
55
- { GIT_REPOSITORY_ITEM_COMMONDIR, "remotes", true },
56
- { GIT_REPOSITORY_ITEM_COMMONDIR, "config", false },
57
- { GIT_REPOSITORY_ITEM_COMMONDIR, "info", true },
58
- { GIT_REPOSITORY_ITEM_COMMONDIR, "hooks", true },
59
- { GIT_REPOSITORY_ITEM_COMMONDIR, "logs", true },
60
- { GIT_REPOSITORY_ITEM_GITDIR, "modules", true },
61
- { GIT_REPOSITORY_ITEM_COMMONDIR, "worktrees", true }
49
+ { GIT_REPOSITORY_ITEM_GITDIR, GIT_REPOSITORY_ITEM__LAST, NULL, true },
50
+ { GIT_REPOSITORY_ITEM_WORKDIR, GIT_REPOSITORY_ITEM__LAST, NULL, true },
51
+ { GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM__LAST, NULL, true },
52
+ { GIT_REPOSITORY_ITEM_GITDIR, GIT_REPOSITORY_ITEM__LAST, "index", false },
53
+ { GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "objects", true },
54
+ { GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "refs", true },
55
+ { GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "packed-refs", false },
56
+ { GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "remotes", true },
57
+ { GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "config", false },
58
+ { GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "info", true },
59
+ { GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "hooks", true },
60
+ { GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "logs", true },
61
+ { GIT_REPOSITORY_ITEM_GITDIR, GIT_REPOSITORY_ITEM__LAST, "modules", true },
62
+ { GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "worktrees", true }
62
63
  };
63
64
 
64
65
  static int check_repositoryformatversion(git_config *config);
@@ -121,7 +122,7 @@ static void set_config(git_repository *repo, git_config *config)
121
122
  git_config_free(config);
122
123
  }
123
124
 
124
- git_repository__cvar_cache_clear(repo);
125
+ git_repository__configmap_lookup_cache_clear(repo);
125
126
  }
126
127
 
127
128
  static void set_index(git_repository *repo, git_index *index)
@@ -160,7 +161,7 @@ void git_repository_free(git_repository *repo)
160
161
 
161
162
  git_repository__cleanup(repo);
162
163
 
163
- git_cache_free(&repo->objects);
164
+ git_cache_dispose(&repo->objects);
164
165
 
165
166
  git_diff_driver_registry_free(repo->diff_drivers);
166
167
  repo->diff_drivers = NULL;
@@ -238,14 +239,14 @@ static git_repository *repository_alloc(void)
238
239
  if (!repo->reserved_names.ptr)
239
240
  goto on_error;
240
241
 
241
- /* set all the entries in the cvar cache to `unset` */
242
- git_repository__cvar_cache_clear(repo);
242
+ /* set all the entries in the configmap cache to `unset` */
243
+ git_repository__configmap_lookup_cache_clear(repo);
243
244
 
244
245
  return repo;
245
246
 
246
247
  on_error:
247
248
  if (repo)
248
- git_cache_free(&repo->objects);
249
+ git_cache_dispose(&repo->objects);
249
250
 
250
251
  git__free(repo);
251
252
  return NULL;
@@ -256,7 +257,7 @@ int git_repository_new(git_repository **out)
256
257
  git_repository *repo;
257
258
 
258
259
  *out = repo = repository_alloc();
259
- GITERR_CHECK_ALLOC(repo);
260
+ GIT_ERROR_CHECK_ALLOC(repo);
260
261
 
261
262
  repo->is_bare = 1;
262
263
  repo->is_worktree = 0;
@@ -331,7 +332,7 @@ static int load_workdir(git_repository *repo, git_config *config, git_buf *paren
331
332
  repo->workdir = git_buf_detach(&worktree);
332
333
  }
333
334
 
334
- GITERR_CHECK_ALLOC(repo->workdir);
335
+ GIT_ERROR_CHECK_ALLOC(repo->workdir);
335
336
  cleanup:
336
337
  git_buf_dispose(&path);
337
338
  git_config_entry_free(ce);
@@ -413,7 +414,7 @@ static int read_gitfile(git_buf *path_out, const char *file_path)
413
414
  if (git_buf_len(&file) <= prefix_len ||
414
415
  memcmp(git_buf_cstr(&file), GIT_FILE_CONTENT_PREFIX, prefix_len) != 0)
415
416
  {
416
- giterr_set(GITERR_REPOSITORY,
417
+ git_error_set(GIT_ERROR_REPOSITORY,
417
418
  "the `.git` file at '%s' is malformed", file_path);
418
419
  error = -1;
419
420
  }
@@ -551,7 +552,7 @@ static int find_repo(
551
552
  /* If we didn't find the repository, and we don't have any other error
552
553
  * to report, report that. */
553
554
  if (!git_buf_len(gitdir_path) && !error) {
554
- giterr_set(GITERR_REPOSITORY,
555
+ git_error_set(GIT_ERROR_REPOSITORY,
555
556
  "could not find repository from '%s'", start_path);
556
557
  error = GIT_ENOTFOUND;
557
558
  }
@@ -576,17 +577,17 @@ int git_repository_open_bare(
576
577
  if (!valid_repository_path(&path, &common_path)) {
577
578
  git_buf_dispose(&path);
578
579
  git_buf_dispose(&common_path);
579
- giterr_set(GITERR_REPOSITORY, "path is not a repository: %s", bare_path);
580
+ git_error_set(GIT_ERROR_REPOSITORY, "path is not a repository: %s", bare_path);
580
581
  return GIT_ENOTFOUND;
581
582
  }
582
583
 
583
584
  repo = repository_alloc();
584
- GITERR_CHECK_ALLOC(repo);
585
+ GIT_ERROR_CHECK_ALLOC(repo);
585
586
 
586
587
  repo->gitdir = git_buf_detach(&path);
587
- GITERR_CHECK_ALLOC(repo->gitdir);
588
+ GIT_ERROR_CHECK_ALLOC(repo->gitdir);
588
589
  repo->commondir = git_buf_detach(&common_path);
589
- GITERR_CHECK_ALLOC(repo->commondir);
590
+ GIT_ERROR_CHECK_ALLOC(repo->commondir);
590
591
 
591
592
  /* of course we're bare! */
592
593
  repo->is_bare = 1;
@@ -620,7 +621,7 @@ static int _git_repository_open_ext_from_env(
620
621
  if (!start_path) {
621
622
  error = git__getenv(&dir_buf, "GIT_DIR");
622
623
  if (error == GIT_ENOTFOUND) {
623
- giterr_clear();
624
+ git_error_clear();
624
625
  start_path = ".";
625
626
  } else if (error < 0)
626
627
  goto error;
@@ -633,7 +634,7 @@ static int _git_repository_open_ext_from_env(
633
634
 
634
635
  error = git__getenv(&ceiling_dirs_buf, "GIT_CEILING_DIRECTORIES");
635
636
  if (error == GIT_ENOTFOUND)
636
- giterr_clear();
637
+ git_error_clear();
637
638
  else if (error < 0)
638
639
  goto error;
639
640
  else
@@ -641,7 +642,7 @@ static int _git_repository_open_ext_from_env(
641
642
 
642
643
  error = git__getenv(&across_fs_buf, "GIT_DISCOVERY_ACROSS_FILESYSTEM");
643
644
  if (error == GIT_ENOTFOUND)
644
- giterr_clear();
645
+ git_error_clear();
645
646
  else if (error < 0)
646
647
  goto error;
647
648
  else {
@@ -655,7 +656,7 @@ static int _git_repository_open_ext_from_env(
655
656
 
656
657
  error = git__getenv(&index_file_buf, "GIT_INDEX_FILE");
657
658
  if (error == GIT_ENOTFOUND)
658
- giterr_clear();
659
+ git_error_clear();
659
660
  else if (error < 0)
660
661
  goto error;
661
662
  else {
@@ -666,13 +667,13 @@ static int _git_repository_open_ext_from_env(
666
667
 
667
668
  error = git__getenv(&namespace_buf, "GIT_NAMESPACE");
668
669
  if (error == GIT_ENOTFOUND)
669
- giterr_clear();
670
+ git_error_clear();
670
671
  else if (error < 0)
671
672
  goto error;
672
673
 
673
674
  error = git__getenv(&object_dir_buf, "GIT_OBJECT_DIRECTORY");
674
675
  if (error == GIT_ENOTFOUND)
675
- giterr_clear();
676
+ git_error_clear();
676
677
  else if (error < 0)
677
678
  goto error;
678
679
  else {
@@ -683,22 +684,22 @@ static int _git_repository_open_ext_from_env(
683
684
 
684
685
  error = git__getenv(&work_tree_buf, "GIT_WORK_TREE");
685
686
  if (error == GIT_ENOTFOUND)
686
- giterr_clear();
687
+ git_error_clear();
687
688
  else if (error < 0)
688
689
  goto error;
689
690
  else {
690
- giterr_set(GITERR_INVALID, "GIT_WORK_TREE unimplemented");
691
+ git_error_set(GIT_ERROR_INVALID, "GIT_WORK_TREE unimplemented");
691
692
  error = GIT_ERROR;
692
693
  goto error;
693
694
  }
694
695
 
695
696
  error = git__getenv(&work_tree_buf, "GIT_COMMON_DIR");
696
697
  if (error == GIT_ENOTFOUND)
697
- giterr_clear();
698
+ git_error_clear();
698
699
  else if (error < 0)
699
700
  goto error;
700
701
  else {
701
- giterr_set(GITERR_INVALID, "GIT_COMMON_DIR unimplemented");
702
+ git_error_set(GIT_ERROR_INVALID, "GIT_COMMON_DIR unimplemented");
702
703
  error = GIT_ERROR;
703
704
  goto error;
704
705
  }
@@ -712,7 +713,7 @@ static int _git_repository_open_ext_from_env(
712
713
 
713
714
  error = git__getenv(&alts_buf, "GIT_ALTERNATE_OBJECT_DIRECTORIES");
714
715
  if (error == GIT_ENOTFOUND) {
715
- giterr_clear();
716
+ git_error_clear();
716
717
  error = 0;
717
718
  } else if (error < 0)
718
719
  goto error;
@@ -799,7 +800,7 @@ int git_repository_open_ext(
799
800
  unsigned is_worktree;
800
801
  git_buf gitdir = GIT_BUF_INIT, workdir = GIT_BUF_INIT,
801
802
  gitlink = GIT_BUF_INIT, commondir = GIT_BUF_INIT;
802
- git_repository *repo;
803
+ git_repository *repo = NULL;
803
804
  git_config *config = NULL;
804
805
 
805
806
  if (flags & GIT_REPOSITORY_OPEN_FROM_ENV)
@@ -812,21 +813,21 @@ int git_repository_open_ext(
812
813
  &gitdir, &workdir, &gitlink, &commondir, start_path, flags, ceiling_dirs);
813
814
 
814
815
  if (error < 0 || !repo_ptr)
815
- return error;
816
+ goto cleanup;
816
817
 
817
818
  repo = repository_alloc();
818
- GITERR_CHECK_ALLOC(repo);
819
+ GIT_ERROR_CHECK_ALLOC(repo);
819
820
 
820
821
  repo->gitdir = git_buf_detach(&gitdir);
821
- GITERR_CHECK_ALLOC(repo->gitdir);
822
+ GIT_ERROR_CHECK_ALLOC(repo->gitdir);
822
823
 
823
824
  if (gitlink.size) {
824
825
  repo->gitlink = git_buf_detach(&gitlink);
825
- GITERR_CHECK_ALLOC(repo->gitlink);
826
+ GIT_ERROR_CHECK_ALLOC(repo->gitlink);
826
827
  }
827
828
  if (commondir.size) {
828
829
  repo->commondir = git_buf_detach(&commondir);
829
- GITERR_CHECK_ALLOC(repo->commondir);
830
+ GIT_ERROR_CHECK_ALLOC(repo->commondir);
830
831
  }
831
832
 
832
833
  if ((error = repo_is_worktree(&is_worktree, repo)) < 0)
@@ -858,11 +859,14 @@ int git_repository_open_ext(
858
859
  cleanup:
859
860
  git_buf_dispose(&gitdir);
860
861
  git_buf_dispose(&workdir);
862
+ git_buf_dispose(&gitlink);
863
+ git_buf_dispose(&commondir);
861
864
  git_config_free(config);
862
865
 
863
866
  if (error < 0)
864
867
  git_repository_free(repo);
865
- else
868
+
869
+ if (repo_ptr)
866
870
  *repo_ptr = repo;
867
871
 
868
872
  return error;
@@ -878,7 +882,8 @@ int git_repository_open_from_worktree(git_repository **repo_out, git_worktree *w
878
882
  {
879
883
  git_buf path = GIT_BUF_INIT;
880
884
  git_repository *repo = NULL;
881
- int len, err;
885
+ size_t len;
886
+ int err;
882
887
 
883
888
  assert(repo_out && wt);
884
889
 
@@ -909,7 +914,7 @@ int git_repository_wrap_odb(git_repository **repo_out, git_odb *odb)
909
914
  git_repository *repo;
910
915
 
911
916
  repo = repository_alloc();
912
- GITERR_CHECK_ALLOC(repo);
917
+ GIT_ERROR_CHECK_ALLOC(repo);
913
918
 
914
919
  git_repository_set_odb(repo, odb);
915
920
  *repo_out = repo;
@@ -944,18 +949,20 @@ static int load_config(
944
949
  git_buf config_path = GIT_BUF_INIT;
945
950
  git_config *cfg = NULL;
946
951
 
947
- assert(repo && out);
952
+ assert(out);
948
953
 
949
954
  if ((error = git_config_new(&cfg)) < 0)
950
955
  return error;
951
956
 
952
- if ((error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG)) == 0)
953
- error = git_config_add_file_ondisk(cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, repo, 0);
957
+ if (repo) {
958
+ if ((error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG)) == 0)
959
+ error = git_config_add_file_ondisk(cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, repo, 0);
954
960
 
955
- if (error && error != GIT_ENOTFOUND)
956
- goto on_error;
961
+ if (error && error != GIT_ENOTFOUND)
962
+ goto on_error;
957
963
 
958
- git_buf_dispose(&config_path);
964
+ git_buf_dispose(&config_path);
965
+ }
959
966
 
960
967
  if (global_config_path != NULL &&
961
968
  (error = git_config_add_file_ondisk(
@@ -981,7 +988,7 @@ static int load_config(
981
988
  error != GIT_ENOTFOUND)
982
989
  goto on_error;
983
990
 
984
- giterr_clear(); /* clear any lingering ENOTFOUND errors */
991
+ git_error_clear(); /* clear any lingering ENOTFOUND errors */
985
992
 
986
993
  *out = cfg;
987
994
  return 0;
@@ -1184,7 +1191,8 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo)
1184
1191
  git_index_free(index);
1185
1192
  }
1186
1193
 
1187
- error = git_index_set_caps(repo->_index, GIT_INDEXCAP_FROM_OWNER);
1194
+ error = git_index_set_caps(repo->_index,
1195
+ GIT_INDEX_CAPABILITY_FROM_OWNER);
1188
1196
  }
1189
1197
 
1190
1198
  git_buf_dispose(&index_path);
@@ -1282,8 +1290,8 @@ bool git_repository__reserved_names(
1282
1290
  int (*prefixcmp)(const char *, const char *);
1283
1291
  int error, ignorecase;
1284
1292
 
1285
- error = git_repository__cvar(
1286
- &ignorecase, repo, GIT_CVAR_IGNORECASE);
1293
+ error = git_repository__configmap_lookup(
1294
+ &ignorecase, repo, GIT_CONFIGMAP_IGNORECASE);
1287
1295
  prefixcmp = (error || ignorecase) ? git__prefixcmp_icase :
1288
1296
  git__prefixcmp;
1289
1297
 
@@ -1341,7 +1349,7 @@ static int check_repositoryformatversion(git_config *config)
1341
1349
  return -1;
1342
1350
 
1343
1351
  if (GIT_REPO_VERSION < version) {
1344
- giterr_set(GITERR_REPOSITORY,
1352
+ git_error_set(GIT_ERROR_REPOSITORY,
1345
1353
  "unsupported repository version %d. Only versions up to %d are supported.",
1346
1354
  version, GIT_REPO_VERSION);
1347
1355
  return -1;
@@ -1355,10 +1363,11 @@ int git_repository_create_head(const char *git_dir, const char *ref_name)
1355
1363
  git_buf ref_path = GIT_BUF_INIT;
1356
1364
  git_filebuf ref = GIT_FILEBUF_INIT;
1357
1365
  const char *fmt;
1366
+ int error;
1358
1367
 
1359
- if (git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE) < 0 ||
1360
- git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE) < 0)
1361
- goto fail;
1368
+ if ((error = git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE)) < 0 ||
1369
+ (error = git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE)) < 0)
1370
+ goto out;
1362
1371
 
1363
1372
  if (!ref_name)
1364
1373
  ref_name = GIT_BRANCH_MASTER;
@@ -1368,17 +1377,14 @@ int git_repository_create_head(const char *git_dir, const char *ref_name)
1368
1377
  else
1369
1378
  fmt = "ref: " GIT_REFS_HEADS_DIR "%s\n";
1370
1379
 
1371
- if (git_filebuf_printf(&ref, fmt, ref_name) < 0 ||
1372
- git_filebuf_commit(&ref) < 0)
1373
- goto fail;
1374
-
1375
- git_buf_dispose(&ref_path);
1376
- return 0;
1380
+ if ((error = git_filebuf_printf(&ref, fmt, ref_name)) < 0 ||
1381
+ (error = git_filebuf_commit(&ref)) < 0)
1382
+ goto out;
1377
1383
 
1378
- fail:
1384
+ out:
1379
1385
  git_buf_dispose(&ref_path);
1380
1386
  git_filebuf_cleanup(&ref);
1381
- return -1;
1387
+ return error;
1382
1388
  }
1383
1389
 
1384
1390
  static bool is_chmod_supported(const char *file_path)
@@ -1411,24 +1417,47 @@ static bool is_filesystem_case_insensitive(const char *gitdir_path)
1411
1417
 
1412
1418
  static bool are_symlinks_supported(const char *wd_path)
1413
1419
  {
1414
- git_buf path = GIT_BUF_INIT;
1415
- int fd;
1416
- struct stat st;
1417
- int symlinks_supported = -1;
1418
-
1419
- if ((fd = git_futils_mktmp(&path, wd_path, 0666)) < 0 ||
1420
- p_close(fd) < 0 ||
1421
- p_unlink(path.ptr) < 0 ||
1422
- p_symlink("testing", path.ptr) < 0 ||
1423
- p_lstat(path.ptr, &st) < 0)
1424
- symlinks_supported = false;
1425
- else
1426
- symlinks_supported = (S_ISLNK(st.st_mode) != 0);
1420
+ git_config *config = NULL;
1421
+ git_buf global_buf = GIT_BUF_INIT;
1422
+ git_buf xdg_buf = GIT_BUF_INIT;
1423
+ git_buf system_buf = GIT_BUF_INIT;
1424
+ git_buf programdata_buf = GIT_BUF_INIT;
1425
+ int symlinks = 0;
1427
1426
 
1428
- (void)p_unlink(path.ptr);
1429
- git_buf_dispose(&path);
1427
+ /*
1428
+ * To emulate Git for Windows, symlinks on Windows must be explicitly
1429
+ * opted-in. We examine the system configuration for a core.symlinks
1430
+ * set to true. If found, we then examine the filesystem to see if
1431
+ * symlinks are _actually_ supported by the current user. If that is
1432
+ * _not_ set, then we do not test or enable symlink support.
1433
+ */
1434
+ #ifdef GIT_WIN32
1435
+ git_config_find_global(&global_buf);
1436
+ git_config_find_xdg(&xdg_buf);
1437
+ git_config_find_system(&system_buf);
1438
+ git_config_find_programdata(&programdata_buf);
1439
+
1440
+ if (load_config(&config, NULL,
1441
+ path_unless_empty(&global_buf),
1442
+ path_unless_empty(&xdg_buf),
1443
+ path_unless_empty(&system_buf),
1444
+ path_unless_empty(&programdata_buf)) < 0)
1445
+ goto done;
1446
+
1447
+ if (git_config_get_bool(&symlinks, config, "core.symlinks") < 0 || !symlinks)
1448
+ goto done;
1449
+ #endif
1430
1450
 
1431
- return symlinks_supported;
1451
+ if (!(symlinks = git_path_supports_symlinks(wd_path)))
1452
+ goto done;
1453
+
1454
+ done:
1455
+ git_buf_dispose(&global_buf);
1456
+ git_buf_dispose(&xdg_buf);
1457
+ git_buf_dispose(&system_buf);
1458
+ git_buf_dispose(&programdata_buf);
1459
+ git_config_free(config);
1460
+ return symlinks != 0;
1432
1461
  }
1433
1462
 
1434
1463
  static int create_empty_file(const char *path, mode_t mode)
@@ -1436,12 +1465,12 @@ static int create_empty_file(const char *path, mode_t mode)
1436
1465
  int fd;
1437
1466
 
1438
1467
  if ((fd = p_creat(path, mode)) < 0) {
1439
- giterr_set(GITERR_OS, "error while creating '%s'", path);
1468
+ git_error_set(GIT_ERROR_OS, "error while creating '%s'", path);
1440
1469
  return -1;
1441
1470
  }
1442
1471
 
1443
1472
  if (p_close(fd) < 0) {
1444
- giterr_set(GITERR_OS, "error while closing '%s'", path);
1473
+ git_error_set(GIT_ERROR_OS, "error while closing '%s'", path);
1445
1474
  return -1;
1446
1475
  }
1447
1476
 
@@ -1476,7 +1505,7 @@ static int repo_local_config(
1476
1505
  return error;
1477
1506
 
1478
1507
  if (git_config_open_level(out, parent, GIT_CONFIG_LEVEL_LOCAL) < 0) {
1479
- giterr_clear();
1508
+ git_error_clear();
1480
1509
 
1481
1510
  if (!(error = git_config_add_file_ondisk(
1482
1511
  parent, cfg_path, GIT_CONFIG_LEVEL_LOCAL, repo, false)))
@@ -1508,14 +1537,14 @@ static int repo_init_fs_configs(
1508
1537
  if ((error = git_config_set_bool(cfg, "core.symlinks", false)) < 0)
1509
1538
  return error;
1510
1539
  } else if (git_config_delete_entry(cfg, "core.symlinks") < 0)
1511
- giterr_clear();
1540
+ git_error_clear();
1512
1541
 
1513
1542
  if (update_ignorecase) {
1514
1543
  if (is_filesystem_case_insensitive(repo_dir)) {
1515
1544
  if ((error = git_config_set_bool(cfg, "core.ignorecase", true)) < 0)
1516
1545
  return error;
1517
1546
  } else if (git_config_delete_entry(cfg, "core.ignorecase") < 0)
1518
- giterr_clear();
1547
+ git_error_clear();
1519
1548
  }
1520
1549
 
1521
1550
  #ifdef GIT_USE_ICONV
@@ -1572,7 +1601,7 @@ static int repo_init_config(
1572
1601
  SET_REPO_CONFIG(string, "core.worktree", worktree_path.ptr);
1573
1602
  } else if (is_reinit) {
1574
1603
  if (git_config_delete_entry(config, "core.worktree") < 0)
1575
- giterr_clear();
1604
+ git_error_clear();
1576
1605
  }
1577
1606
  }
1578
1607
 
@@ -1600,7 +1629,7 @@ static int repo_reinit_submodule_fs(git_submodule *sm, const char *n, void *p)
1600
1629
 
1601
1630
  if (git_submodule_open(&smrepo, sm) < 0 ||
1602
1631
  git_repository_reinit_filesystem(smrepo, true) < 0)
1603
- giterr_clear();
1632
+ git_error_clear();
1604
1633
  git_repository_free(smrepo);
1605
1634
 
1606
1635
  return 0;
@@ -1620,7 +1649,7 @@ int git_repository_reinit_filesystem(git_repository *repo, int recurse)
1620
1649
  git_config_free(config);
1621
1650
  git_buf_dispose(&path);
1622
1651
 
1623
- git_repository__cvar_cache_clear(repo);
1652
+ git_repository__configmap_lookup_cache_clear(repo);
1624
1653
 
1625
1654
  if (!repo->is_bare && recurse)
1626
1655
  (void)git_submodule_foreach(repo, repo_reinit_submodule_fs, NULL);
@@ -1669,7 +1698,7 @@ static int repo_write_template(
1669
1698
  git_buf_dispose(&path);
1670
1699
 
1671
1700
  if (error)
1672
- giterr_set(GITERR_OS,
1701
+ git_error_set(GIT_ERROR_OS,
1673
1702
  "failed to initialize repository with template '%s'", file);
1674
1703
 
1675
1704
  return error;
@@ -1700,7 +1729,7 @@ static int repo_write_gitlink(
1700
1729
  goto cleanup;
1701
1730
 
1702
1731
  if (!p_stat(buf.ptr, &st) && !S_ISREG(st.st_mode)) {
1703
- giterr_set(GITERR_REPOSITORY,
1732
+ git_error_set(GIT_ERROR_REPOSITORY,
1704
1733
  "cannot overwrite gitlink file into path '%s'", in_dir);
1705
1734
  error = GIT_EEXISTS;
1706
1735
  goto cleanup;
@@ -1754,7 +1783,7 @@ static int repo_init_structure(
1754
1783
  #ifdef GIT_WIN32
1755
1784
  if ((opts->flags & GIT_REPOSITORY_INIT__HAS_DOTGIT) != 0) {
1756
1785
  if (git_win32__set_hidden(repo_dir, true) < 0) {
1757
- giterr_set(GITERR_OS,
1786
+ git_error_set(GIT_ERROR_OS,
1758
1787
  "failed to mark Git repository folder as hidden");
1759
1788
  return -1;
1760
1789
  }
@@ -1781,7 +1810,7 @@ static int repo_init_structure(
1781
1810
  else if ((error = git_config_open_default(&cfg)) >= 0) {
1782
1811
  if (!git_config_get_path(&template_buf, cfg, "init.templatedir"))
1783
1812
  tdir = template_buf.ptr;
1784
- giterr_clear();
1813
+ git_error_clear();
1785
1814
  }
1786
1815
 
1787
1816
  if (!tdir) {
@@ -1813,7 +1842,7 @@ static int repo_init_structure(
1813
1842
  return error;
1814
1843
 
1815
1844
  /* if template was default, ignore error and use internal */
1816
- giterr_clear();
1845
+ git_error_clear();
1817
1846
  external_tpl = false;
1818
1847
  error = 0;
1819
1848
  }
@@ -1915,7 +1944,7 @@ static int repo_init_directories(
1915
1944
  if (git_path_dirname_r(wd_path, repo_path->ptr) < 0)
1916
1945
  return -1;
1917
1946
  } else {
1918
- giterr_set(GITERR_REPOSITORY, "cannot pick working directory"
1947
+ git_error_set(GIT_ERROR_REPOSITORY, "cannot pick working directory"
1919
1948
  " for non-bare repository that isn't a '.git' directory");
1920
1949
  return -1;
1921
1950
  }
@@ -2018,53 +2047,59 @@ int git_repository_init_ext(
2018
2047
  const char *given_repo,
2019
2048
  git_repository_init_options *opts)
2020
2049
  {
2021
- int error;
2022
2050
  git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT,
2023
- common_path = GIT_BUF_INIT;
2051
+ common_path = GIT_BUF_INIT, head_path = GIT_BUF_INIT;
2024
2052
  const char *wd;
2053
+ int error;
2025
2054
 
2026
2055
  assert(out && given_repo && opts);
2027
2056
 
2028
- GITERR_CHECK_VERSION(opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION, "git_repository_init_options");
2057
+ GIT_ERROR_CHECK_VERSION(opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION, "git_repository_init_options");
2029
2058
 
2030
- error = repo_init_directories(&repo_path, &wd_path, given_repo, opts);
2031
- if (error < 0)
2032
- goto cleanup;
2059
+ if ((error = repo_init_directories(&repo_path, &wd_path, given_repo, opts)) < 0)
2060
+ goto out;
2033
2061
 
2034
2062
  wd = (opts->flags & GIT_REPOSITORY_INIT_BARE) ? NULL : git_buf_cstr(&wd_path);
2035
- if (valid_repository_path(&repo_path, &common_path)) {
2036
2063
 
2064
+ if (valid_repository_path(&repo_path, &common_path)) {
2037
2065
  if ((opts->flags & GIT_REPOSITORY_INIT_NO_REINIT) != 0) {
2038
- giterr_set(GITERR_REPOSITORY,
2066
+ git_error_set(GIT_ERROR_REPOSITORY,
2039
2067
  "attempt to reinitialize '%s'", given_repo);
2040
2068
  error = GIT_EEXISTS;
2041
- goto cleanup;
2069
+ goto out;
2042
2070
  }
2043
2071
 
2044
2072
  opts->flags |= GIT_REPOSITORY_INIT__IS_REINIT;
2045
2073
 
2046
- error = repo_init_config(
2047
- repo_path.ptr, wd, opts->flags, opts->mode);
2074
+ if ((error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0)
2075
+ goto out;
2048
2076
 
2049
2077
  /* TODO: reinitialize the templates */
2078
+ } else {
2079
+ if ((error = repo_init_structure(repo_path.ptr, wd, opts)) < 0 ||
2080
+ (error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0 ||
2081
+ (error = git_buf_joinpath(&head_path, repo_path.ptr, GIT_HEAD_FILE)) < 0)
2082
+ goto out;
2083
+
2084
+ /*
2085
+ * Only set the new HEAD if the file does not exist already via
2086
+ * a template or if the caller has explicitly supplied an
2087
+ * initial HEAD value.
2088
+ */
2089
+ if ((!git_path_exists(head_path.ptr) || opts->initial_head) &&
2090
+ (error = git_repository_create_head(repo_path.ptr, opts->initial_head)) < 0)
2091
+ goto out;
2050
2092
  }
2051
- else {
2052
- if (!(error = repo_init_structure(
2053
- repo_path.ptr, wd, opts)) &&
2054
- !(error = repo_init_config(
2055
- repo_path.ptr, wd, opts->flags, opts->mode)))
2056
- error = git_repository_create_head(
2057
- repo_path.ptr, opts->initial_head);
2058
- }
2059
- if (error < 0)
2060
- goto cleanup;
2061
2093
 
2062
- error = git_repository_open(out, repo_path.ptr);
2094
+ if ((error = git_repository_open(out, repo_path.ptr)) < 0)
2095
+ goto out;
2063
2096
 
2064
- if (!error && opts->origin_url)
2065
- error = repo_init_create_origin(*out, opts->origin_url);
2097
+ if (opts->origin_url &&
2098
+ (error = repo_init_create_origin(*out, opts->origin_url)) < 0)
2099
+ goto out;
2066
2100
 
2067
- cleanup:
2101
+ out:
2102
+ git_buf_dispose(&head_path);
2068
2103
  git_buf_dispose(&common_path);
2069
2104
  git_buf_dispose(&repo_path);
2070
2105
  git_buf_dispose(&wd_path);
@@ -2084,7 +2119,7 @@ int git_repository_head_detached(git_repository *repo)
2084
2119
  if (git_reference_lookup(&ref, repo, GIT_HEAD_FILE) < 0)
2085
2120
  return -1;
2086
2121
 
2087
- if (git_reference_type(ref) == GIT_REF_SYMBOLIC) {
2122
+ if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
2088
2123
  git_reference_free(ref);
2089
2124
  return 0;
2090
2125
  }
@@ -2111,7 +2146,7 @@ int git_repository_head_detached_for_worktree(git_repository *repo, const char *
2111
2146
  if ((error = git_repository_head_for_worktree(&ref, repo, name)) < 0)
2112
2147
  goto out;
2113
2148
 
2114
- error = (git_reference_type(ref) != GIT_REF_SYMBOLIC);
2149
+ error = (git_reference_type(ref) != GIT_REFERENCE_SYMBOLIC);
2115
2150
  out:
2116
2151
  git_reference_free(ref);
2117
2152
 
@@ -2123,10 +2158,12 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
2123
2158
  git_reference *head;
2124
2159
  int error;
2125
2160
 
2161
+ assert(head_out);
2162
+
2126
2163
  if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0)
2127
2164
  return error;
2128
2165
 
2129
- if (git_reference_type(head) == GIT_REF_OID) {
2166
+ if (git_reference_type(head) == GIT_REFERENCE_DIRECT) {
2130
2167
  *head_out = head;
2131
2168
  return 0;
2132
2169
  }
@@ -2151,7 +2188,7 @@ int git_repository_head_for_worktree(git_reference **out, git_repository *repo,
2151
2188
  (error = git_reference__read_head(&head, repo, path.ptr)) < 0)
2152
2189
  goto out;
2153
2190
 
2154
- if (git_reference_type(head) != GIT_REF_OID) {
2191
+ if (git_reference_type(head) != GIT_REFERENCE_DIRECT) {
2155
2192
  git_reference *resolved;
2156
2193
 
2157
2194
  error = git_reference_lookup_resolved(&resolved, repo, git_reference_symbolic_target(head), -1);
@@ -2170,30 +2207,37 @@ out:
2170
2207
  return error;
2171
2208
  }
2172
2209
 
2173
- int git_repository_foreach_head(git_repository *repo, git_repository_foreach_head_cb cb, void *payload)
2210
+ int git_repository_foreach_head(git_repository *repo,
2211
+ git_repository_foreach_head_cb cb,
2212
+ int flags, void *payload)
2174
2213
  {
2175
2214
  git_strarray worktrees = GIT_VECTOR_INIT;
2176
2215
  git_buf path = GIT_BUF_INIT;
2177
- int error;
2216
+ int error = 0;
2178
2217
  size_t i;
2179
2218
 
2180
- /* Execute callback for HEAD of commondir */
2181
- if ((error = git_buf_joinpath(&path, repo->commondir, GIT_HEAD_FILE)) < 0 ||
2182
- (error = cb(repo, path.ptr, payload) != 0))
2183
- goto out;
2184
2219
 
2185
- if ((error = git_worktree_list(&worktrees, repo)) < 0) {
2186
- error = 0;
2187
- goto out;
2220
+ if (!(flags & GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO)) {
2221
+ /* Gather HEAD of main repository */
2222
+ if ((error = git_buf_joinpath(&path, repo->commondir, GIT_HEAD_FILE)) < 0 ||
2223
+ (error = cb(repo, path.ptr, payload) != 0))
2224
+ goto out;
2188
2225
  }
2189
2226
 
2190
- /* Execute callback for all worktree HEADs */
2191
- for (i = 0; i < worktrees.count; i++) {
2192
- if (get_worktree_file_path(&path, repo, worktrees.strings[i], GIT_HEAD_FILE) < 0)
2193
- continue;
2194
-
2195
- if ((error = cb(repo, path.ptr, payload)) != 0)
2227
+ if (!(flags & GIT_REPOSITORY_FOREACH_HEAD_SKIP_WORKTREES)) {
2228
+ if ((error = git_worktree_list(&worktrees, repo)) < 0) {
2229
+ error = 0;
2196
2230
  goto out;
2231
+ }
2232
+
2233
+ /* Gather HEADs of all worktrees */
2234
+ for (i = 0; i < worktrees.count; i++) {
2235
+ if (get_worktree_file_path(&path, repo, worktrees.strings[i], GIT_HEAD_FILE) < 0)
2236
+ continue;
2237
+
2238
+ if ((error = cb(repo, path.ptr, payload)) != 0)
2239
+ goto out;
2240
+ }
2197
2241
  }
2198
2242
 
2199
2243
  out:
@@ -2211,7 +2255,7 @@ int git_repository_head_unborn(git_repository *repo)
2211
2255
  git_reference_free(ref);
2212
2256
 
2213
2257
  if (error == GIT_EUNBORNBRANCH) {
2214
- giterr_clear();
2258
+ git_error_clear();
2215
2259
  return 1;
2216
2260
  }
2217
2261
 
@@ -2249,7 +2293,7 @@ int git_repository_is_empty(git_repository *repo)
2249
2293
  if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0)
2250
2294
  return -1;
2251
2295
 
2252
- if (git_reference_type(head) == GIT_REF_SYMBOLIC)
2296
+ if (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC)
2253
2297
  is_empty =
2254
2298
  (strcmp(git_reference_symbolic_target(head),
2255
2299
  GIT_REFS_HEADS_DIR "master") == 0) &&
@@ -2260,11 +2304,11 @@ int git_repository_is_empty(git_repository *repo)
2260
2304
  return is_empty;
2261
2305
  }
2262
2306
 
2263
- int git_repository_item_path(git_buf *out, const git_repository *repo, git_repository_item_t item)
2307
+ static const char *resolved_parent_path(const git_repository *repo, git_repository_item_t item, git_repository_item_t fallback)
2264
2308
  {
2265
2309
  const char *parent;
2266
2310
 
2267
- switch (items[item].parent) {
2311
+ switch (item) {
2268
2312
  case GIT_REPOSITORY_ITEM_GITDIR:
2269
2313
  parent = git_repository_path(repo);
2270
2314
  break;
@@ -2275,12 +2319,20 @@ int git_repository_item_path(git_buf *out, const git_repository *repo, git_repos
2275
2319
  parent = git_repository_commondir(repo);
2276
2320
  break;
2277
2321
  default:
2278
- giterr_set(GITERR_INVALID, "invalid item directory");
2279
- return -1;
2322
+ git_error_set(GIT_ERROR_INVALID, "invalid item directory");
2323
+ return NULL;
2280
2324
  }
2325
+ if (!parent && fallback != GIT_REPOSITORY_ITEM__LAST)
2326
+ return resolved_parent_path(repo, fallback, GIT_REPOSITORY_ITEM__LAST);
2327
+
2328
+ return parent;
2329
+ }
2281
2330
 
2331
+ int git_repository_item_path(git_buf *out, const git_repository *repo, git_repository_item_t item)
2332
+ {
2333
+ const char *parent = resolved_parent_path(repo, items[item].parent, items[item].fallback);
2282
2334
  if (parent == NULL) {
2283
- giterr_set(GITERR_INVALID, "path cannot exist in repository");
2335
+ git_error_set(GIT_ERROR_INVALID, "path cannot exist in repository");
2284
2336
  return GIT_ENOTFOUND;
2285
2337
  }
2286
2338
 
@@ -2413,7 +2465,7 @@ int git_repository_head_tree(git_tree **tree, git_repository *repo)
2413
2465
  if ((error = git_repository_head(&head, repo)) < 0)
2414
2466
  return error;
2415
2467
 
2416
- if ((error = git_reference_peel(&obj, head, GIT_OBJ_TREE)) < 0)
2468
+ if ((error = git_reference_peel(&obj, head, GIT_OBJECT_TREE)) < 0)
2417
2469
  goto cleanup;
2418
2470
 
2419
2471
  *tree = (git_tree *)obj;
@@ -2433,7 +2485,7 @@ int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head
2433
2485
  git_oid_fmt(orig_head_str, orig_head);
2434
2486
 
2435
2487
  if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_ORIG_HEAD_FILE)) == 0 &&
2436
- (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) == 0 &&
2488
+ (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_CREATE_LEADING_DIRS, GIT_MERGE_FILE_MODE)) == 0 &&
2437
2489
  (error = git_filebuf_printf(&file, "%.*s\n", GIT_OID_HEXSZ, orig_head_str)) == 0)
2438
2490
  error = git_filebuf_commit(&file);
2439
2491
 
@@ -2459,7 +2511,7 @@ int git_repository_message(git_buf *out, git_repository *repo)
2459
2511
  if ((error = p_stat(git_buf_cstr(&path), &st)) < 0) {
2460
2512
  if (errno == ENOENT)
2461
2513
  error = GIT_ENOTFOUND;
2462
- giterr_set(GITERR_OS, "could not access message file");
2514
+ git_error_set(GIT_ERROR_OS, "could not access message file");
2463
2515
  } else {
2464
2516
  error = git_futils_readbuffer(out, git_buf_cstr(&path));
2465
2517
  }
@@ -2487,13 +2539,13 @@ int git_repository_hashfile(
2487
2539
  git_oid *out,
2488
2540
  git_repository *repo,
2489
2541
  const char *path,
2490
- git_otype type,
2542
+ git_object_t type,
2491
2543
  const char *as_path)
2492
2544
  {
2493
2545
  int error;
2494
2546
  git_filter_list *fl = NULL;
2495
2547
  git_file fd = -1;
2496
- git_off_t len;
2548
+ uint64_t len;
2497
2549
  git_buf full_path = GIT_BUF_INIT;
2498
2550
 
2499
2551
  assert(out && path && repo); /* as_path can be NULL */
@@ -2530,14 +2582,11 @@ int git_repository_hashfile(
2530
2582
  goto cleanup;
2531
2583
  }
2532
2584
 
2533
- len = git_futils_filesize(fd);
2534
- if (len < 0) {
2535
- error = (int)len;
2585
+ if ((error = git_futils_filesize(&len, fd)) < 0)
2536
2586
  goto cleanup;
2537
- }
2538
2587
 
2539
2588
  if (!git__is_sizet(len)) {
2540
- giterr_set(GITERR_OS, "file size overflow for 32-bit systems");
2589
+ git_error_set(GIT_ERROR_OS, "file size overflow for 32-bit systems");
2541
2590
  error = -1;
2542
2591
  goto cleanup;
2543
2592
  }
@@ -2557,7 +2606,7 @@ static int checkout_message(git_buf *out, git_reference *old, const char *new)
2557
2606
  {
2558
2607
  git_buf_puts(out, "checkout: moving from ");
2559
2608
 
2560
- if (git_reference_type(old) == GIT_REF_SYMBOLIC)
2609
+ if (git_reference_type(old) == GIT_REFERENCE_SYMBOLIC)
2561
2610
  git_buf_puts(out, git_reference__shorthand(git_reference_symbolic_target(old)));
2562
2611
  else
2563
2612
  git_buf_puts(out, git_oid_tostr_s(git_reference_target(old)));
@@ -2589,10 +2638,10 @@ static int detach(git_repository *repo, const git_oid *id, const char *new)
2589
2638
  if ((error = git_reference_lookup(&current, repo, GIT_HEAD_FILE)) < 0)
2590
2639
  return error;
2591
2640
 
2592
- if ((error = git_object_lookup(&object, repo, id, GIT_OBJ_ANY)) < 0)
2641
+ if ((error = git_object_lookup(&object, repo, id, GIT_OBJECT_ANY)) < 0)
2593
2642
  goto cleanup;
2594
2643
 
2595
- if ((error = git_object_peel(&peeled, object, GIT_OBJ_COMMIT)) < 0)
2644
+ if ((error = git_object_peel(&peeled, object, GIT_OBJECT_COMMIT)) < 0)
2596
2645
  goto cleanup;
2597
2646
 
2598
2647
  if (new == NULL)
@@ -2632,9 +2681,9 @@ int git_repository_set_head(
2632
2681
  if (error < 0 && error != GIT_ENOTFOUND)
2633
2682
  goto cleanup;
2634
2683
 
2635
- if (ref && current->type == GIT_REF_SYMBOLIC && git__strcmp(current->target.symbolic, ref->name) &&
2684
+ if (ref && current->type == GIT_REFERENCE_SYMBOLIC && git__strcmp(current->target.symbolic, ref->name) &&
2636
2685
  git_reference_is_branch(ref) && git_branch_is_checked_out(ref)) {
2637
- giterr_set(GITERR_REPOSITORY, "cannot set HEAD to reference '%s' as it is the current HEAD "
2686
+ git_error_set(GIT_ERROR_REPOSITORY, "cannot set HEAD to reference '%s' as it is the current HEAD "
2638
2687
  "of a linked repository.", git_reference_name(ref));
2639
2688
  error = -1;
2640
2689
  goto cleanup;
@@ -2692,7 +2741,7 @@ int git_repository_detach_head(git_repository* repo)
2692
2741
  if ((error = git_repository_head(&old_head, repo)) < 0)
2693
2742
  goto cleanup;
2694
2743
 
2695
- if ((error = git_object_lookup(&object, repo, git_reference_target(old_head), GIT_OBJ_COMMIT)) < 0)
2744
+ if ((error = git_object_lookup(&object, repo, git_reference_target(old_head), GIT_OBJECT_COMMIT)) < 0)
2696
2745
  goto cleanup;
2697
2746
 
2698
2747
  if ((error = checkout_message(&log_message, current, git_oid_tostr_s(git_object_id(object)))) < 0)
@@ -2814,7 +2863,7 @@ int git_repository_is_shallow(git_repository *repo)
2814
2863
  git_buf_dispose(&path);
2815
2864
 
2816
2865
  if (error == GIT_ENOTFOUND) {
2817
- giterr_clear();
2866
+ git_error_clear();
2818
2867
  return 0;
2819
2868
  }
2820
2869
 
@@ -2823,7 +2872,7 @@ int git_repository_is_shallow(git_repository *repo)
2823
2872
  return st.st_size == 0 ? 0 : 1;
2824
2873
  }
2825
2874
 
2826
- int git_repository_init_init_options(
2875
+ int git_repository_init_options_init(
2827
2876
  git_repository_init_options *opts, unsigned int version)
2828
2877
  {
2829
2878
  GIT_INIT_STRUCTURE_FROM_TEMPLATE(
@@ -2832,6 +2881,12 @@ int git_repository_init_init_options(
2832
2881
  return 0;
2833
2882
  }
2834
2883
 
2884
+ int git_repository_init_init_options(
2885
+ git_repository_init_options *opts, unsigned int version)
2886
+ {
2887
+ return git_repository_init_options_init(opts, version);
2888
+ }
2889
+
2835
2890
  int git_repository_ident(const char **name, const char **email, const git_repository *repo)
2836
2891
  {
2837
2892
  *name = repo->ident_name;
@@ -2846,12 +2901,12 @@ int git_repository_set_ident(git_repository *repo, const char *name, const char
2846
2901
 
2847
2902
  if (name) {
2848
2903
  tmp_name = git__strdup(name);
2849
- GITERR_CHECK_ALLOC(tmp_name);
2904
+ GIT_ERROR_CHECK_ALLOC(tmp_name);
2850
2905
  }
2851
2906
 
2852
2907
  if (email) {
2853
2908
  tmp_email = git__strdup(email);
2854
- GITERR_CHECK_ALLOC(tmp_email);
2909
+ GIT_ERROR_CHECK_ALLOC(tmp_email);
2855
2910
  }
2856
2911
 
2857
2912
  tmp_name = git__swap(repo->ident_name, tmp_name);
@@ -2869,7 +2924,7 @@ int git_repository_submodule_cache_all(git_repository *repo)
2869
2924
 
2870
2925
  assert(repo);
2871
2926
 
2872
- if ((error = git_strmap_alloc(&repo->submodule_cache)))
2927
+ if ((error = git_strmap_new(&repo->submodule_cache)))
2873
2928
  return error;
2874
2929
 
2875
2930
  error = git_submodule__map(repo, repo->submodule_cache);