rugged 0.28.5 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (411) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/rugged/extconf.rb +3 -1
  4. data/ext/rugged/rugged.c +35 -31
  5. data/ext/rugged/rugged.h +13 -0
  6. data/ext/rugged/rugged_blob.c +11 -9
  7. data/ext/rugged/rugged_commit.c +18 -16
  8. data/ext/rugged/rugged_config.c +1 -1
  9. data/ext/rugged/rugged_diff.c +4 -26
  10. data/ext/rugged/rugged_index.c +4 -2
  11. data/ext/rugged/rugged_note.c +5 -3
  12. data/ext/rugged/rugged_object.c +57 -10
  13. data/ext/rugged/rugged_rebase.c +3 -1
  14. data/ext/rugged/rugged_remote.c +32 -8
  15. data/ext/rugged/rugged_repo.c +232 -17
  16. data/ext/rugged/rugged_tag.c +8 -6
  17. data/ext/rugged/rugged_tree.c +18 -16
  18. data/lib/rugged/commit.rb +17 -4
  19. data/lib/rugged/repository.rb +5 -6
  20. data/lib/rugged/submodule_collection.rb +4 -4
  21. data/lib/rugged/version.rb +1 -1
  22. data/vendor/libgit2/CMakeLists.txt +57 -75
  23. data/vendor/libgit2/COPYING +28 -0
  24. data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
  25. data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +5 -1
  26. data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +2 -2
  27. data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +1 -1
  28. data/vendor/libgit2/cmake/FindGSSFramework.cmake +28 -0
  29. data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
  30. data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
  31. data/vendor/libgit2/cmake/FindPCRE.cmake +38 -0
  32. data/vendor/libgit2/cmake/FindPCRE2.cmake +37 -0
  33. data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
  34. data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +2 -2
  35. data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +6 -0
  36. data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
  37. data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
  38. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +77 -0
  39. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -0
  40. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +48 -0
  41. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +120 -0
  42. data/vendor/libgit2/cmake/SelectHashes.cmake +61 -0
  43. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
  44. data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
  45. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +25 -0
  46. data/vendor/libgit2/deps/ntlmclient/compat.h +28 -0
  47. data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
  48. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
  49. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
  50. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
  51. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
  52. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
  53. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
  54. data/vendor/libgit2/deps/ntlmclient/ntlm.c +1419 -0
  55. data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
  56. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
  57. data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
  58. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
  59. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
  60. data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
  61. data/vendor/libgit2/deps/ntlmclient/util.c +35 -0
  62. data/vendor/libgit2/deps/ntlmclient/util.h +15 -0
  63. data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
  64. data/vendor/libgit2/deps/pcre/COPYING +5 -0
  65. data/vendor/libgit2/deps/pcre/LICENCE +93 -0
  66. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
  67. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
  68. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
  69. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
  70. data/vendor/libgit2/deps/pcre/config.h.in +57 -0
  71. data/vendor/libgit2/deps/pcre/pcre.h +641 -0
  72. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
  73. data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
  74. data/vendor/libgit2/deps/pcre/pcre_compile.c +9812 -0
  75. data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
  76. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
  77. data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
  78. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
  79. data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
  80. data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
  81. data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
  82. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
  83. data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
  84. data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
  85. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
  86. data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
  87. data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
  88. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
  89. data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
  90. data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
  91. data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
  92. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
  93. data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
  94. data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
  95. data/vendor/libgit2/deps/pcre/pcreposix.c +420 -0
  96. data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
  97. data/vendor/libgit2/deps/pcre/ucp.h +224 -0
  98. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
  99. data/vendor/libgit2/deps/zlib/adler32.c +0 -7
  100. data/vendor/libgit2/deps/zlib/crc32.c +0 -7
  101. data/vendor/libgit2/deps/zlib/deflate.c +1 -0
  102. data/vendor/libgit2/include/git2.h +2 -0
  103. data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
  104. data/vendor/libgit2/include/git2/apply.h +24 -2
  105. data/vendor/libgit2/include/git2/attr.h +23 -13
  106. data/vendor/libgit2/include/git2/blame.h +4 -2
  107. data/vendor/libgit2/include/git2/blob.h +61 -13
  108. data/vendor/libgit2/include/git2/branch.h +74 -57
  109. data/vendor/libgit2/include/git2/buffer.h +20 -14
  110. data/vendor/libgit2/include/git2/cert.h +135 -0
  111. data/vendor/libgit2/include/git2/checkout.h +46 -14
  112. data/vendor/libgit2/include/git2/cherrypick.h +3 -3
  113. data/vendor/libgit2/include/git2/clone.h +2 -2
  114. data/vendor/libgit2/include/git2/commit.h +23 -1
  115. data/vendor/libgit2/include/git2/common.h +34 -8
  116. data/vendor/libgit2/include/git2/config.h +13 -13
  117. data/vendor/libgit2/include/git2/cred_helpers.h +4 -42
  118. data/vendor/libgit2/include/git2/credential.h +314 -0
  119. data/vendor/libgit2/include/git2/credential_helpers.h +52 -0
  120. data/vendor/libgit2/include/git2/deprecated.h +362 -4
  121. data/vendor/libgit2/include/git2/describe.h +4 -4
  122. data/vendor/libgit2/include/git2/diff.h +17 -15
  123. data/vendor/libgit2/include/git2/errors.h +5 -2
  124. data/vendor/libgit2/include/git2/filter.h +8 -0
  125. data/vendor/libgit2/include/git2/index.h +5 -5
  126. data/vendor/libgit2/include/git2/indexer.h +49 -4
  127. data/vendor/libgit2/include/git2/merge.h +6 -10
  128. data/vendor/libgit2/include/git2/net.h +0 -5
  129. data/vendor/libgit2/include/git2/object.h +2 -14
  130. data/vendor/libgit2/include/git2/odb.h +18 -22
  131. data/vendor/libgit2/include/git2/odb_backend.h +5 -4
  132. data/vendor/libgit2/include/git2/oid.h +11 -6
  133. data/vendor/libgit2/include/git2/pack.h +13 -2
  134. data/vendor/libgit2/include/git2/proxy.h +6 -4
  135. data/vendor/libgit2/include/git2/rebase.h +46 -2
  136. data/vendor/libgit2/include/git2/refs.h +22 -3
  137. data/vendor/libgit2/include/git2/remote.h +40 -15
  138. data/vendor/libgit2/include/git2/repository.h +124 -58
  139. data/vendor/libgit2/include/git2/revert.h +1 -1
  140. data/vendor/libgit2/include/git2/revwalk.h +7 -3
  141. data/vendor/libgit2/include/git2/stash.h +4 -4
  142. data/vendor/libgit2/include/git2/status.h +25 -16
  143. data/vendor/libgit2/include/git2/strarray.h +6 -10
  144. data/vendor/libgit2/include/git2/submodule.h +20 -3
  145. data/vendor/libgit2/include/git2/sys/alloc.h +9 -9
  146. data/vendor/libgit2/include/git2/sys/cred.h +15 -0
  147. data/vendor/libgit2/include/git2/sys/credential.h +90 -0
  148. data/vendor/libgit2/include/git2/sys/index.h +4 -2
  149. data/vendor/libgit2/include/git2/sys/mempack.h +2 -1
  150. data/vendor/libgit2/include/git2/sys/merge.h +1 -1
  151. data/vendor/libgit2/include/git2/sys/odb_backend.h +48 -4
  152. data/vendor/libgit2/include/git2/sys/refdb_backend.h +164 -21
  153. data/vendor/libgit2/include/git2/sys/repository.h +17 -6
  154. data/vendor/libgit2/include/git2/sys/transport.h +4 -4
  155. data/vendor/libgit2/include/git2/tag.h +11 -2
  156. data/vendor/libgit2/include/git2/trace.h +2 -2
  157. data/vendor/libgit2/include/git2/transport.h +11 -340
  158. data/vendor/libgit2/include/git2/tree.h +7 -3
  159. data/vendor/libgit2/include/git2/types.h +4 -89
  160. data/vendor/libgit2/include/git2/version.h +5 -5
  161. data/vendor/libgit2/include/git2/worktree.h +5 -5
  162. data/vendor/libgit2/src/CMakeLists.txt +147 -272
  163. data/vendor/libgit2/src/alloc.c +2 -14
  164. data/vendor/libgit2/src/{stdalloc.c → allocators/stdalloc.c} +3 -4
  165. data/vendor/libgit2/src/{stdalloc.h → allocators/stdalloc.h} +4 -4
  166. data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
  167. data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
  168. data/vendor/libgit2/src/apply.c +36 -16
  169. data/vendor/libgit2/src/assert_safe.h +58 -0
  170. data/vendor/libgit2/src/attr.c +70 -64
  171. data/vendor/libgit2/src/attr_file.c +197 -99
  172. data/vendor/libgit2/src/attr_file.h +9 -9
  173. data/vendor/libgit2/src/attrcache.c +48 -49
  174. data/vendor/libgit2/src/attrcache.h +2 -1
  175. data/vendor/libgit2/src/blame.c +34 -15
  176. data/vendor/libgit2/src/blame.h +1 -1
  177. data/vendor/libgit2/src/blame_git.c +27 -10
  178. data/vendor/libgit2/src/blob.c +92 -17
  179. data/vendor/libgit2/src/blob.h +2 -2
  180. data/vendor/libgit2/src/branch.c +68 -42
  181. data/vendor/libgit2/src/buffer.c +11 -3
  182. data/vendor/libgit2/src/buffer.h +1 -0
  183. data/vendor/libgit2/src/cache.c +34 -58
  184. data/vendor/libgit2/src/cache.h +1 -1
  185. data/vendor/libgit2/src/cc-compat.h +5 -0
  186. data/vendor/libgit2/src/checkout.c +73 -86
  187. data/vendor/libgit2/src/cherrypick.c +9 -1
  188. data/vendor/libgit2/src/clone.c +130 -27
  189. data/vendor/libgit2/src/clone.h +4 -0
  190. data/vendor/libgit2/src/commit.c +70 -22
  191. data/vendor/libgit2/src/commit.h +6 -0
  192. data/vendor/libgit2/src/commit_list.c +28 -76
  193. data/vendor/libgit2/src/commit_list.h +2 -2
  194. data/vendor/libgit2/src/common.h +4 -75
  195. data/vendor/libgit2/src/config.c +34 -47
  196. data/vendor/libgit2/src/config.h +7 -6
  197. data/vendor/libgit2/src/config_backend.h +12 -0
  198. data/vendor/libgit2/src/config_cache.c +42 -39
  199. data/vendor/libgit2/src/config_entries.c +76 -98
  200. data/vendor/libgit2/src/config_entries.h +1 -0
  201. data/vendor/libgit2/src/config_file.c +346 -380
  202. data/vendor/libgit2/src/config_mem.c +12 -16
  203. data/vendor/libgit2/src/config_parse.c +50 -30
  204. data/vendor/libgit2/src/config_parse.h +13 -12
  205. data/vendor/libgit2/src/config_snapshot.c +207 -0
  206. data/vendor/libgit2/src/crlf.c +14 -14
  207. data/vendor/libgit2/src/describe.c +26 -21
  208. data/vendor/libgit2/src/diff.c +53 -75
  209. data/vendor/libgit2/src/diff.h +4 -3
  210. data/vendor/libgit2/src/diff_driver.c +37 -38
  211. data/vendor/libgit2/src/diff_file.c +15 -11
  212. data/vendor/libgit2/src/diff_file.h +2 -2
  213. data/vendor/libgit2/src/diff_generate.c +36 -37
  214. data/vendor/libgit2/src/diff_generate.h +2 -2
  215. data/vendor/libgit2/src/diff_parse.c +3 -4
  216. data/vendor/libgit2/src/diff_print.c +86 -71
  217. data/vendor/libgit2/src/diff_stats.c +13 -12
  218. data/vendor/libgit2/src/diff_tform.c +15 -16
  219. data/vendor/libgit2/src/errors.c +23 -25
  220. data/vendor/libgit2/src/errors.h +81 -0
  221. data/vendor/libgit2/src/features.h.in +9 -2
  222. data/vendor/libgit2/src/fetch.c +9 -2
  223. data/vendor/libgit2/src/fetchhead.c +9 -9
  224. data/vendor/libgit2/src/filebuf.c +1 -1
  225. data/vendor/libgit2/src/filebuf.h +1 -1
  226. data/vendor/libgit2/src/filter.c +19 -11
  227. data/vendor/libgit2/src/{fileops.c → futils.c} +23 -20
  228. data/vendor/libgit2/src/{fileops.h → futils.h} +8 -8
  229. data/vendor/libgit2/src/global.c +3 -1
  230. data/vendor/libgit2/src/hash.c +61 -0
  231. data/vendor/libgit2/src/hash.h +19 -21
  232. data/vendor/libgit2/src/hash/sha1.h +38 -0
  233. data/vendor/libgit2/src/hash/{hash_collisiondetect.h → sha1/collisiondetect.c} +14 -17
  234. data/vendor/libgit2/src/{sha1_lookup.h → hash/sha1/collisiondetect.h} +8 -8
  235. data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +15 -19
  236. data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
  237. data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
  238. data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -14
  239. data/vendor/libgit2/src/hash/{hash_mbedtls.c → sha1/mbedtls.c} +15 -7
  240. data/vendor/libgit2/src/hash/{hash_mbedtls.h → sha1/mbedtls.h} +6 -11
  241. data/vendor/libgit2/src/hash/{hash_openssl.h → sha1/openssl.c} +14 -18
  242. data/vendor/libgit2/src/{refdb_fs.h → hash/sha1/openssl.h} +8 -8
  243. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
  244. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
  245. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
  246. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
  247. data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +34 -24
  248. data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
  249. data/vendor/libgit2/src/hashsig.c +1 -1
  250. data/vendor/libgit2/src/idxmap.c +73 -69
  251. data/vendor/libgit2/src/idxmap.h +151 -15
  252. data/vendor/libgit2/src/ignore.c +26 -35
  253. data/vendor/libgit2/src/index.c +123 -95
  254. data/vendor/libgit2/src/index.h +1 -1
  255. data/vendor/libgit2/src/indexer.c +99 -78
  256. data/vendor/libgit2/src/integer.h +26 -4
  257. data/vendor/libgit2/src/iterator.c +36 -32
  258. data/vendor/libgit2/src/iterator.h +8 -8
  259. data/vendor/libgit2/src/map.h +1 -1
  260. data/vendor/libgit2/src/merge.c +93 -57
  261. data/vendor/libgit2/src/merge.h +2 -2
  262. data/vendor/libgit2/src/merge_driver.c +5 -5
  263. data/vendor/libgit2/src/merge_file.c +5 -7
  264. data/vendor/libgit2/src/midx.c +418 -0
  265. data/vendor/libgit2/src/midx.h +83 -0
  266. data/vendor/libgit2/src/mwindow.c +144 -74
  267. data/vendor/libgit2/src/mwindow.h +4 -4
  268. data/vendor/libgit2/src/net.c +416 -0
  269. data/vendor/libgit2/src/net.h +57 -0
  270. data/vendor/libgit2/src/netops.c +6 -222
  271. data/vendor/libgit2/src/netops.h +1 -37
  272. data/vendor/libgit2/src/notes.c +8 -5
  273. data/vendor/libgit2/src/object.c +5 -4
  274. data/vendor/libgit2/src/object.h +2 -0
  275. data/vendor/libgit2/src/odb.c +54 -32
  276. data/vendor/libgit2/src/odb.h +3 -2
  277. data/vendor/libgit2/src/odb_loose.c +20 -13
  278. data/vendor/libgit2/src/odb_mempack.c +15 -24
  279. data/vendor/libgit2/src/odb_pack.c +4 -5
  280. data/vendor/libgit2/src/offmap.c +43 -55
  281. data/vendor/libgit2/src/offmap.h +102 -24
  282. data/vendor/libgit2/src/oid.c +21 -8
  283. data/vendor/libgit2/src/oidmap.c +39 -57
  284. data/vendor/libgit2/src/oidmap.h +99 -19
  285. data/vendor/libgit2/src/pack-objects.c +55 -52
  286. data/vendor/libgit2/src/pack-objects.h +1 -1
  287. data/vendor/libgit2/src/pack.c +160 -149
  288. data/vendor/libgit2/src/pack.h +32 -18
  289. data/vendor/libgit2/src/parse.c +10 -0
  290. data/vendor/libgit2/src/parse.h +3 -3
  291. data/vendor/libgit2/src/patch.c +1 -1
  292. data/vendor/libgit2/src/patch_generate.c +2 -4
  293. data/vendor/libgit2/src/patch_parse.c +34 -11
  294. data/vendor/libgit2/src/path.c +47 -10
  295. data/vendor/libgit2/src/path.h +2 -0
  296. data/vendor/libgit2/src/pathspec.c +18 -17
  297. data/vendor/libgit2/src/pool.c +42 -32
  298. data/vendor/libgit2/src/pool.h +15 -7
  299. data/vendor/libgit2/src/posix.c +39 -16
  300. data/vendor/libgit2/src/posix.h +21 -1
  301. data/vendor/libgit2/src/proxy.c +9 -2
  302. data/vendor/libgit2/src/push.c +15 -7
  303. data/vendor/libgit2/src/reader.c +2 -2
  304. data/vendor/libgit2/src/rebase.c +89 -28
  305. data/vendor/libgit2/src/refdb.c +147 -0
  306. data/vendor/libgit2/src/refdb.h +69 -0
  307. data/vendor/libgit2/src/refdb_fs.c +230 -241
  308. data/vendor/libgit2/src/reflog.c +13 -19
  309. data/vendor/libgit2/src/refs.c +113 -217
  310. data/vendor/libgit2/src/refs.h +10 -21
  311. data/vendor/libgit2/src/refspec.c +57 -48
  312. data/vendor/libgit2/src/regexp.c +221 -0
  313. data/vendor/libgit2/src/regexp.h +97 -0
  314. data/vendor/libgit2/src/remote.c +102 -79
  315. data/vendor/libgit2/src/remote.h +2 -2
  316. data/vendor/libgit2/src/repository.c +322 -203
  317. data/vendor/libgit2/src/repository.h +49 -57
  318. data/vendor/libgit2/src/revert.c +8 -1
  319. data/vendor/libgit2/src/revparse.c +23 -23
  320. data/vendor/libgit2/src/revwalk.c +73 -37
  321. data/vendor/libgit2/src/revwalk.h +20 -0
  322. data/vendor/libgit2/src/settings.c +22 -1
  323. data/vendor/libgit2/src/sortedcache.c +14 -29
  324. data/vendor/libgit2/src/sortedcache.h +1 -1
  325. data/vendor/libgit2/src/stash.c +49 -67
  326. data/vendor/libgit2/src/status.c +19 -11
  327. data/vendor/libgit2/src/strarray.c +63 -0
  328. data/vendor/libgit2/src/streams/openssl.c +66 -8
  329. data/vendor/libgit2/src/streams/registry.c +5 -3
  330. data/vendor/libgit2/src/streams/socket.c +2 -2
  331. data/vendor/libgit2/src/strmap.c +37 -84
  332. data/vendor/libgit2/src/strmap.h +105 -33
  333. data/vendor/libgit2/src/submodule.c +157 -130
  334. data/vendor/libgit2/src/submodule.h +1 -1
  335. data/vendor/libgit2/src/sysdir.c +4 -20
  336. data/vendor/libgit2/src/sysdir.h +0 -11
  337. data/vendor/libgit2/src/tag.c +12 -2
  338. data/vendor/libgit2/src/thread-utils.h +163 -40
  339. data/vendor/libgit2/src/trace.c +1 -1
  340. data/vendor/libgit2/src/trace.h +3 -3
  341. data/vendor/libgit2/src/trailer.c +46 -32
  342. data/vendor/libgit2/src/transaction.c +5 -9
  343. data/vendor/libgit2/src/transports/auth.c +16 -15
  344. data/vendor/libgit2/src/transports/auth.h +18 -11
  345. data/vendor/libgit2/src/transports/auth_negotiate.c +64 -33
  346. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  347. data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
  348. data/vendor/libgit2/src/transports/auth_ntlm.h +38 -0
  349. data/vendor/libgit2/src/transports/credential.c +478 -0
  350. data/vendor/libgit2/src/transports/{cred_helpers.c → credential_helpers.c} +23 -8
  351. data/vendor/libgit2/src/transports/git.c +11 -16
  352. data/vendor/libgit2/src/transports/http.c +488 -1248
  353. data/vendor/libgit2/src/transports/http.h +4 -1
  354. data/vendor/libgit2/src/transports/httpclient.c +1552 -0
  355. data/vendor/libgit2/src/transports/httpclient.h +190 -0
  356. data/vendor/libgit2/src/transports/local.c +12 -12
  357. data/vendor/libgit2/src/transports/smart.c +21 -21
  358. data/vendor/libgit2/src/transports/smart.h +3 -3
  359. data/vendor/libgit2/src/transports/smart_protocol.c +40 -64
  360. data/vendor/libgit2/src/transports/ssh.c +77 -59
  361. data/vendor/libgit2/src/transports/winhttp.c +368 -285
  362. data/vendor/libgit2/src/tree-cache.c +14 -7
  363. data/vendor/libgit2/src/tree.c +16 -26
  364. data/vendor/libgit2/src/unix/map.c +1 -1
  365. data/vendor/libgit2/src/unix/posix.h +16 -11
  366. data/vendor/libgit2/src/userdiff.h +3 -1
  367. data/vendor/libgit2/src/util.c +75 -110
  368. data/vendor/libgit2/src/util.h +18 -23
  369. data/vendor/libgit2/src/wildmatch.c +320 -0
  370. data/vendor/libgit2/src/wildmatch.h +23 -0
  371. data/vendor/libgit2/src/win32/git2.rc +18 -3
  372. data/vendor/libgit2/src/win32/map.c +3 -5
  373. data/vendor/libgit2/src/win32/path_w32.c +42 -5
  374. data/vendor/libgit2/src/win32/path_w32.h +15 -29
  375. data/vendor/libgit2/src/win32/posix.h +1 -4
  376. data/vendor/libgit2/src/win32/posix_w32.c +117 -5
  377. data/vendor/libgit2/src/win32/precompiled.h +0 -2
  378. data/vendor/libgit2/src/win32/thread.c +5 -5
  379. data/vendor/libgit2/src/win32/w32_buffer.c +7 -3
  380. data/vendor/libgit2/src/win32/w32_common.h +39 -0
  381. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -93
  382. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -2
  383. data/vendor/libgit2/src/win32/w32_stack.c +4 -9
  384. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  385. data/vendor/libgit2/src/win32/w32_util.c +31 -0
  386. data/vendor/libgit2/src/win32/w32_util.h +6 -32
  387. data/vendor/libgit2/src/worktree.c +91 -50
  388. data/vendor/libgit2/src/xdiff/xdiffi.c +1 -1
  389. data/vendor/libgit2/src/xdiff/xmerge.c +12 -0
  390. data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
  391. data/vendor/libgit2/src/zstream.c +5 -0
  392. data/vendor/libgit2/src/zstream.h +1 -0
  393. metadata +123 -53
  394. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
  395. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
  396. data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
  397. data/vendor/libgit2/deps/regex/COPYING +0 -502
  398. data/vendor/libgit2/deps/regex/config.h +0 -7
  399. data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
  400. data/vendor/libgit2/deps/regex/regex.c +0 -92
  401. data/vendor/libgit2/deps/regex/regex.h +0 -582
  402. data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
  403. data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
  404. data/vendor/libgit2/deps/regex/regexec.c +0 -4369
  405. data/vendor/libgit2/include/git2/inttypes.h +0 -309
  406. data/vendor/libgit2/include/git2/sys/time.h +0 -31
  407. data/vendor/libgit2/libgit2.pc.in +0 -13
  408. data/vendor/libgit2/src/fnmatch.c +0 -248
  409. data/vendor/libgit2/src/fnmatch.h +0 -48
  410. data/vendor/libgit2/src/sha1_lookup.c +0 -35
  411. data/vendor/libgit2/src/transports/cred.c +0 -390
@@ -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,35 +42,38 @@ 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
- static int check_repositoryformatversion(git_config *config);
65
+ static int check_repositoryformatversion(int *version, git_config *config);
66
+ static int check_extensions(git_config *config, int version);
65
67
 
66
68
  #define GIT_COMMONDIR_FILE "commondir"
67
69
  #define GIT_GITDIR_FILE "gitdir"
68
70
 
69
71
  #define GIT_FILE_CONTENT_PREFIX "gitdir:"
70
72
 
71
- #define GIT_BRANCH_MASTER "master"
73
+ #define GIT_BRANCH_DEFAULT "master"
72
74
 
73
75
  #define GIT_REPO_VERSION 0
76
+ #define GIT_REPO_MAX_VERSION 1
74
77
 
75
78
  git_buf git_repository__reserved_names_win32[] = {
76
79
  { DOT_GIT, 0, CONST_STRLEN(DOT_GIT) },
@@ -121,7 +124,7 @@ static void set_config(git_repository *repo, git_config *config)
121
124
  git_config_free(config);
122
125
  }
123
126
 
124
- git_repository__cvar_cache_clear(repo);
127
+ git_repository__configmap_lookup_cache_clear(repo);
125
128
  }
126
129
 
127
130
  static void set_index(git_repository *repo, git_index *index)
@@ -137,7 +140,7 @@ static void set_index(git_repository *repo, git_index *index)
137
140
  }
138
141
  }
139
142
 
140
- void git_repository__cleanup(git_repository *repo)
143
+ int git_repository__cleanup(git_repository *repo)
141
144
  {
142
145
  assert(repo);
143
146
 
@@ -149,6 +152,8 @@ void git_repository__cleanup(git_repository *repo)
149
152
  set_index(repo, NULL);
150
153
  set_odb(repo, NULL);
151
154
  set_refdb(repo, NULL);
155
+
156
+ return 0;
152
157
  }
153
158
 
154
159
  void git_repository_free(git_repository *repo)
@@ -160,7 +165,7 @@ void git_repository_free(git_repository *repo)
160
165
 
161
166
  git_repository__cleanup(repo);
162
167
 
163
- git_cache_free(&repo->objects);
168
+ git_cache_dispose(&repo->objects);
164
169
 
165
170
  git_diff_driver_registry_free(repo->diff_drivers);
166
171
  repo->diff_drivers = NULL;
@@ -186,19 +191,25 @@ void git_repository_free(git_repository *repo)
186
191
  *
187
192
  * Open a repository object from its path
188
193
  */
189
- static bool valid_repository_path(git_buf *repository_path, git_buf *common_path)
194
+ static int is_valid_repository_path(bool *out, git_buf *repository_path, git_buf *common_path)
190
195
  {
196
+ int error;
197
+
198
+ *out = false;
199
+
191
200
  /* Check if we have a separate commondir (e.g. we have a
192
201
  * worktree) */
193
202
  if (git_path_contains_file(repository_path, GIT_COMMONDIR_FILE)) {
194
203
  git_buf common_link = GIT_BUF_INIT;
195
- git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE);
196
204
 
197
- git_futils_readbuffer(&common_link, common_link.ptr);
198
- git_buf_rtrim(&common_link);
205
+ if ((error = git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE)) < 0 ||
206
+ (error = git_futils_readbuffer(&common_link, common_link.ptr)) < 0)
207
+ return error;
199
208
 
209
+ git_buf_rtrim(&common_link);
200
210
  if (git_path_is_relative(common_link.ptr)) {
201
- git_buf_joinpath(common_path, repository_path->ptr, common_link.ptr);
211
+ if ((error = git_buf_joinpath(common_path, repository_path->ptr, common_link.ptr)) < 0)
212
+ return error;
202
213
  } else {
203
214
  git_buf_swap(common_path, &common_link);
204
215
  }
@@ -206,24 +217,26 @@ static bool valid_repository_path(git_buf *repository_path, git_buf *common_path
206
217
  git_buf_dispose(&common_link);
207
218
  }
208
219
  else {
209
- git_buf_set(common_path, repository_path->ptr, repository_path->size);
220
+ if ((error = git_buf_set(common_path, repository_path->ptr, repository_path->size)) < 0)
221
+ return error;
210
222
  }
211
223
 
212
224
  /* Make sure the commondir path always has a trailing * slash */
213
225
  if (git_buf_rfind(common_path, '/') != (ssize_t)common_path->size - 1)
214
- git_buf_putc(common_path, '/');
226
+ if ((error = git_buf_putc(common_path, '/')) < 0)
227
+ return error;
215
228
 
216
229
  /* Ensure HEAD file exists */
217
230
  if (git_path_contains_file(repository_path, GIT_HEAD_FILE) == false)
218
- return false;
219
-
231
+ return 0;
220
232
  /* Check files in common dir */
221
233
  if (git_path_contains_dir(common_path, GIT_OBJECTS_DIR) == false)
222
- return false;
234
+ return 0;
223
235
  if (git_path_contains_dir(common_path, GIT_REFS_DIR) == false)
224
- return false;
236
+ return 0;
225
237
 
226
- return true;
238
+ *out = true;
239
+ return 0;
227
240
  }
228
241
 
229
242
  static git_repository *repository_alloc(void)
@@ -238,14 +251,14 @@ static git_repository *repository_alloc(void)
238
251
  if (!repo->reserved_names.ptr)
239
252
  goto on_error;
240
253
 
241
- /* set all the entries in the cvar cache to `unset` */
242
- git_repository__cvar_cache_clear(repo);
254
+ /* set all the entries in the configmap cache to `unset` */
255
+ git_repository__configmap_lookup_cache_clear(repo);
243
256
 
244
257
  return repo;
245
258
 
246
259
  on_error:
247
260
  if (repo)
248
- git_cache_free(&repo->objects);
261
+ git_cache_dispose(&repo->objects);
249
262
 
250
263
  git__free(repo);
251
264
  return NULL;
@@ -438,15 +451,15 @@ static int find_repo(
438
451
  uint32_t flags,
439
452
  const char *ceiling_dirs)
440
453
  {
441
- int error;
442
454
  git_buf path = GIT_BUF_INIT;
443
455
  git_buf repo_link = GIT_BUF_INIT;
444
456
  git_buf common_link = GIT_BUF_INIT;
445
457
  struct stat st;
446
458
  dev_t initial_device = 0;
447
459
  int min_iterations;
448
- bool in_dot_git;
460
+ bool in_dot_git, is_valid;
449
461
  size_t ceiling_offset = 0;
462
+ int error;
450
463
 
451
464
  git_buf_clear(gitdir_path);
452
465
 
@@ -472,9 +485,8 @@ static int find_repo(
472
485
  for (;;) {
473
486
  if (!(flags & GIT_REPOSITORY_OPEN_NO_DOTGIT)) {
474
487
  if (!in_dot_git) {
475
- error = git_buf_joinpath(&path, path.ptr, DOT_GIT);
476
- if (error < 0)
477
- break;
488
+ if ((error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0)
489
+ goto out;
478
490
  }
479
491
  in_dot_git = !in_dot_git;
480
492
  }
@@ -488,28 +500,33 @@ static int find_repo(
488
500
  break;
489
501
 
490
502
  if (S_ISDIR(st.st_mode)) {
491
- if (valid_repository_path(&path, &common_link)) {
492
- git_path_to_dir(&path);
493
- git_buf_set(gitdir_path, path.ptr, path.size);
503
+ if ((error = is_valid_repository_path(&is_valid, &path, &common_link)) < 0)
504
+ goto out;
505
+
506
+ if (is_valid) {
507
+ if ((error = git_path_to_dir(&path)) < 0 ||
508
+ (error = git_buf_set(gitdir_path, path.ptr, path.size)) < 0)
509
+ goto out;
494
510
 
495
511
  if (gitlink_path)
496
- git_buf_attach(gitlink_path,
497
- git_worktree__read_link(path.ptr, GIT_GITDIR_FILE), 0);
512
+ if ((error = git_buf_attach(gitlink_path, git_worktree__read_link(path.ptr, GIT_GITDIR_FILE), 0)) < 0)
513
+ goto out;
498
514
  if (commondir_path)
499
515
  git_buf_swap(&common_link, commondir_path);
500
516
 
501
517
  break;
502
518
  }
503
- }
504
- else if (S_ISREG(st.st_mode) && git__suffixcmp(path.ptr, "/" DOT_GIT) == 0) {
505
- error = read_gitfile(&repo_link, path.ptr);
506
- if (error < 0)
507
- break;
508
- if (valid_repository_path(&repo_link, &common_link)) {
519
+ } else if (S_ISREG(st.st_mode) && git__suffixcmp(path.ptr, "/" DOT_GIT) == 0) {
520
+ if ((error = read_gitfile(&repo_link, path.ptr)) < 0 ||
521
+ (error = is_valid_repository_path(&is_valid, &repo_link, &common_link)) < 0)
522
+ goto out;
523
+
524
+ if (is_valid) {
509
525
  git_buf_swap(gitdir_path, &repo_link);
510
526
 
511
527
  if (gitlink_path)
512
- error = git_buf_put(gitlink_path, path.ptr, path.size);
528
+ if ((error = git_buf_put(gitlink_path, path.ptr, path.size)) < 0)
529
+ goto out;
513
530
  if (commondir_path)
514
531
  git_buf_swap(&common_link, commondir_path);
515
532
  }
@@ -520,10 +537,8 @@ static int find_repo(
520
537
  /* Move up one directory. If we're in_dot_git, we'll search the
521
538
  * parent itself next. If we're !in_dot_git, we'll search .git
522
539
  * in the parent directory next (added at the top of the loop). */
523
- if (git_path_dirname_r(&path, path.ptr) < 0) {
524
- error = -1;
525
- break;
526
- }
540
+ if ((error = git_path_dirname_r(&path, path.ptr)) < 0)
541
+ goto out;
527
542
 
528
543
  /* Once we've checked the directory (and .git if applicable),
529
544
  * find the ceiling for a search. */
@@ -531,31 +546,28 @@ static int find_repo(
531
546
  ceiling_offset = find_ceiling_dir_offset(path.ptr, ceiling_dirs);
532
547
 
533
548
  /* Check if we should stop searching here. */
534
- if (min_iterations == 0
535
- && (path.ptr[ceiling_offset] == 0
536
- || (flags & GIT_REPOSITORY_OPEN_NO_SEARCH)))
549
+ if (min_iterations == 0 &&
550
+ (path.ptr[ceiling_offset] == 0 || (flags & GIT_REPOSITORY_OPEN_NO_SEARCH)))
537
551
  break;
538
552
  }
539
553
 
540
- if (!error && workdir_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) {
554
+ if (workdir_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) {
541
555
  if (!git_buf_len(gitdir_path))
542
556
  git_buf_clear(workdir_path);
543
- else {
544
- git_path_dirname_r(workdir_path, path.ptr);
545
- git_path_to_dir(workdir_path);
546
- }
547
- if (git_buf_oom(workdir_path))
548
- return -1;
557
+ else if ((error = git_path_dirname_r(workdir_path, path.ptr)) < 0 ||
558
+ (error = git_path_to_dir(workdir_path)) < 0)
559
+ goto out;
549
560
  }
550
561
 
551
562
  /* If we didn't find the repository, and we don't have any other error
552
563
  * to report, report that. */
553
- if (!git_buf_len(gitdir_path) && !error) {
554
- git_error_set(GIT_ERROR_REPOSITORY,
555
- "could not find repository from '%s'", start_path);
564
+ if (!git_buf_len(gitdir_path)) {
565
+ git_error_set(GIT_ERROR_REPOSITORY, "could not find repository from '%s'", start_path);
556
566
  error = GIT_ENOTFOUND;
567
+ goto out;
557
568
  }
558
569
 
570
+ out:
559
571
  git_buf_dispose(&path);
560
572
  git_buf_dispose(&repo_link);
561
573
  git_buf_dispose(&common_link);
@@ -566,14 +578,16 @@ int git_repository_open_bare(
566
578
  git_repository **repo_ptr,
567
579
  const char *bare_path)
568
580
  {
569
- int error;
570
581
  git_buf path = GIT_BUF_INIT, common_path = GIT_BUF_INIT;
571
582
  git_repository *repo = NULL;
583
+ bool is_valid;
584
+ int error;
572
585
 
573
- if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0)
586
+ if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0 ||
587
+ (error = is_valid_repository_path(&is_valid, &path, &common_path)) < 0)
574
588
  return error;
575
589
 
576
- if (!valid_repository_path(&path, &common_path)) {
590
+ if (!is_valid) {
577
591
  git_buf_dispose(&path);
578
592
  git_buf_dispose(&common_path);
579
593
  git_error_set(GIT_ERROR_REPOSITORY, "path is not a repository: %s", bare_path);
@@ -801,6 +815,7 @@ int git_repository_open_ext(
801
815
  gitlink = GIT_BUF_INIT, commondir = GIT_BUF_INIT;
802
816
  git_repository *repo = NULL;
803
817
  git_config *config = NULL;
818
+ int version = 0;
804
819
 
805
820
  if (flags & GIT_REPOSITORY_OPEN_FROM_ENV)
806
821
  return _git_repository_open_ext_from_env(repo_ptr, start_path);
@@ -842,7 +857,10 @@ int git_repository_open_ext(
842
857
  if (error < 0 && error != GIT_ENOTFOUND)
843
858
  goto cleanup;
844
859
 
845
- if (config && (error = check_repositoryformatversion(config)) < 0)
860
+ if (config && (error = check_repositoryformatversion(&version, config)) < 0)
861
+ goto cleanup;
862
+
863
+ if ((error = check_extensions(config, version)) < 0)
846
864
  goto cleanup;
847
865
 
848
866
  if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0)
@@ -864,8 +882,7 @@ cleanup:
864
882
 
865
883
  if (error < 0)
866
884
  git_repository_free(repo);
867
-
868
- if (repo_ptr)
885
+ else if (repo_ptr)
869
886
  *repo_ptr = repo;
870
887
 
871
888
  return error;
@@ -881,7 +898,8 @@ int git_repository_open_from_worktree(git_repository **repo_out, git_worktree *w
881
898
  {
882
899
  git_buf path = GIT_BUF_INIT;
883
900
  git_repository *repo = NULL;
884
- int len, err;
901
+ size_t len;
902
+ int err;
885
903
 
886
904
  assert(repo_out && wt);
887
905
 
@@ -1069,10 +1087,11 @@ int git_repository_config_snapshot(git_config **out, git_repository *repo)
1069
1087
  return git_config_snapshot(out, weak);
1070
1088
  }
1071
1089
 
1072
- void git_repository_set_config(git_repository *repo, git_config *config)
1090
+ int git_repository_set_config(git_repository *repo, git_config *config)
1073
1091
  {
1074
1092
  assert(repo && config);
1075
1093
  set_config(repo, config);
1094
+ return 0;
1076
1095
  }
1077
1096
 
1078
1097
  int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
@@ -1120,10 +1139,11 @@ int git_repository_odb(git_odb **out, git_repository *repo)
1120
1139
  return 0;
1121
1140
  }
1122
1141
 
1123
- void git_repository_set_odb(git_repository *repo, git_odb *odb)
1142
+ int git_repository_set_odb(git_repository *repo, git_odb *odb)
1124
1143
  {
1125
1144
  assert(repo && odb);
1126
1145
  set_odb(repo, odb);
1146
+ return 0;
1127
1147
  }
1128
1148
 
1129
1149
  int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
@@ -1160,10 +1180,11 @@ int git_repository_refdb(git_refdb **out, git_repository *repo)
1160
1180
  return 0;
1161
1181
  }
1162
1182
 
1163
- void git_repository_set_refdb(git_repository *repo, git_refdb *refdb)
1183
+ int git_repository_set_refdb(git_repository *repo, git_refdb *refdb)
1164
1184
  {
1165
1185
  assert(repo && refdb);
1166
1186
  set_refdb(repo, refdb);
1187
+ return 0;
1167
1188
  }
1168
1189
 
1169
1190
  int git_repository_index__weakptr(git_index **out, git_repository *repo)
@@ -1209,10 +1230,11 @@ int git_repository_index(git_index **out, git_repository *repo)
1209
1230
  return 0;
1210
1231
  }
1211
1232
 
1212
- void git_repository_set_index(git_repository *repo, git_index *index)
1233
+ int git_repository_set_index(git_repository *repo, git_index *index)
1213
1234
  {
1214
1235
  assert(repo);
1215
1236
  set_index(repo, index);
1237
+ return 0;
1216
1238
  }
1217
1239
 
1218
1240
  int git_repository_set_namespace(git_repository *repo, const char *namespace)
@@ -1288,8 +1310,8 @@ bool git_repository__reserved_names(
1288
1310
  int (*prefixcmp)(const char *, const char *);
1289
1311
  int error, ignorecase;
1290
1312
 
1291
- error = git_repository__cvar(
1292
- &ignorecase, repo, GIT_CVAR_IGNORECASE);
1313
+ error = git_repository__configmap_lookup(
1314
+ &ignorecase, repo, GIT_CONFIGMAP_IGNORECASE);
1293
1315
  prefixcmp = (error || ignorecase) ? git__prefixcmp_icase :
1294
1316
  git__prefixcmp;
1295
1317
 
@@ -1334,11 +1356,11 @@ bool git_repository__reserved_names(
1334
1356
  }
1335
1357
  #endif
1336
1358
 
1337
- static int check_repositoryformatversion(git_config *config)
1359
+ static int check_repositoryformatversion(int *version, git_config *config)
1338
1360
  {
1339
- int version, error;
1361
+ int error;
1340
1362
 
1341
- error = git_config_get_int32(&version, config, "core.repositoryformatversion");
1363
+ error = git_config_get_int32(version, config, "core.repositoryformatversion");
1342
1364
  /* git ignores this if the config variable isn't there */
1343
1365
  if (error == GIT_ENOTFOUND)
1344
1366
  return 0;
@@ -1346,45 +1368,59 @@ static int check_repositoryformatversion(git_config *config)
1346
1368
  if (error < 0)
1347
1369
  return -1;
1348
1370
 
1349
- if (GIT_REPO_VERSION < version) {
1371
+ if (GIT_REPO_MAX_VERSION < *version) {
1350
1372
  git_error_set(GIT_ERROR_REPOSITORY,
1351
- "unsupported repository version %d. Only versions up to %d are supported.",
1352
- version, GIT_REPO_VERSION);
1373
+ "unsupported repository version %d; only versions up to %d are supported",
1374
+ *version, GIT_REPO_MAX_VERSION);
1353
1375
  return -1;
1354
1376
  }
1355
1377
 
1356
1378
  return 0;
1357
1379
  }
1358
1380
 
1381
+ static int check_valid_extension(const git_config_entry *entry, void *payload)
1382
+ {
1383
+ GIT_UNUSED(payload);
1384
+
1385
+ if (!strcmp(entry->name, "extensions.noop"))
1386
+ return 0;
1387
+
1388
+ git_error_set(GIT_ERROR_REPOSITORY, "unsupported extension name %s", entry->name);
1389
+ return -1;
1390
+ }
1391
+
1392
+ static int check_extensions(git_config *config, int version)
1393
+ {
1394
+ if (version < 1)
1395
+ return 0;
1396
+
1397
+ return git_config_foreach_match(config, "^extensions\\.", check_valid_extension, NULL);
1398
+ }
1399
+
1359
1400
  int git_repository_create_head(const char *git_dir, const char *ref_name)
1360
1401
  {
1361
1402
  git_buf ref_path = GIT_BUF_INIT;
1362
1403
  git_filebuf ref = GIT_FILEBUF_INIT;
1363
1404
  const char *fmt;
1405
+ int error;
1364
1406
 
1365
- if (git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE) < 0 ||
1366
- git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE) < 0)
1367
- goto fail;
1368
-
1369
- if (!ref_name)
1370
- ref_name = GIT_BRANCH_MASTER;
1407
+ if ((error = git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE)) < 0 ||
1408
+ (error = git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE)) < 0)
1409
+ goto out;
1371
1410
 
1372
1411
  if (git__prefixcmp(ref_name, GIT_REFS_DIR) == 0)
1373
1412
  fmt = "ref: %s\n";
1374
1413
  else
1375
1414
  fmt = "ref: " GIT_REFS_HEADS_DIR "%s\n";
1376
1415
 
1377
- if (git_filebuf_printf(&ref, fmt, ref_name) < 0 ||
1378
- git_filebuf_commit(&ref) < 0)
1379
- goto fail;
1380
-
1381
- git_buf_dispose(&ref_path);
1382
- return 0;
1416
+ if ((error = git_filebuf_printf(&ref, fmt, ref_name)) < 0 ||
1417
+ (error = git_filebuf_commit(&ref)) < 0)
1418
+ goto out;
1383
1419
 
1384
- fail:
1420
+ out:
1385
1421
  git_buf_dispose(&ref_path);
1386
1422
  git_filebuf_cleanup(&ref);
1387
- return -1;
1423
+ return error;
1388
1424
  }
1389
1425
 
1390
1426
  static bool is_chmod_supported(const char *file_path)
@@ -1422,9 +1458,6 @@ static bool are_symlinks_supported(const char *wd_path)
1422
1458
  git_buf xdg_buf = GIT_BUF_INIT;
1423
1459
  git_buf system_buf = GIT_BUF_INIT;
1424
1460
  git_buf programdata_buf = GIT_BUF_INIT;
1425
- git_buf path = GIT_BUF_INIT;
1426
- int fd;
1427
- struct stat st;
1428
1461
  int symlinks = 0;
1429
1462
 
1430
1463
  /*
@@ -1451,23 +1484,14 @@ static bool are_symlinks_supported(const char *wd_path)
1451
1484
  goto done;
1452
1485
  #endif
1453
1486
 
1454
- if ((fd = git_futils_mktmp(&path, wd_path, 0666)) < 0 ||
1455
- p_close(fd) < 0 ||
1456
- p_unlink(path.ptr) < 0 ||
1457
- p_symlink("testing", path.ptr) < 0 ||
1458
- p_lstat(path.ptr, &st) < 0)
1487
+ if (!(symlinks = git_path_supports_symlinks(wd_path)))
1459
1488
  goto done;
1460
1489
 
1461
- symlinks = (S_ISLNK(st.st_mode) != 0);
1462
-
1463
- (void)p_unlink(path.ptr);
1464
-
1465
1490
  done:
1466
1491
  git_buf_dispose(&global_buf);
1467
1492
  git_buf_dispose(&xdg_buf);
1468
1493
  git_buf_dispose(&system_buf);
1469
1494
  git_buf_dispose(&programdata_buf);
1470
- git_buf_dispose(&path);
1471
1495
  git_config_free(config);
1472
1496
  return symlinks != 0;
1473
1497
  }
@@ -1581,11 +1605,15 @@ static int repo_init_config(
1581
1605
  git_config *config = NULL;
1582
1606
  bool is_bare = ((flags & GIT_REPOSITORY_INIT_BARE) != 0);
1583
1607
  bool is_reinit = ((flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0);
1608
+ int version = 0;
1584
1609
 
1585
1610
  if ((error = repo_local_config(&config, &cfg_path, NULL, repo_dir)) < 0)
1586
1611
  goto cleanup;
1587
1612
 
1588
- if (is_reinit && (error = check_repositoryformatversion(config)) < 0)
1613
+ if (is_reinit && (error = check_repositoryformatversion(&version, config)) < 0)
1614
+ goto cleanup;
1615
+
1616
+ if ((error = check_extensions(config, version)) < 0)
1589
1617
  goto cleanup;
1590
1618
 
1591
1619
  #define SET_REPO_CONFIG(TYPE, NAME, VAL) do { \
@@ -1661,7 +1689,7 @@ int git_repository_reinit_filesystem(git_repository *repo, int recurse)
1661
1689
  git_config_free(config);
1662
1690
  git_buf_dispose(&path);
1663
1691
 
1664
- git_repository__cvar_cache_clear(repo);
1692
+ git_repository__configmap_lookup_cache_clear(repo);
1665
1693
 
1666
1694
  if (!repo->is_bare && recurse)
1667
1695
  (void)git_submodule_foreach(repo, repo_reinit_submodule_fs, NULL);
@@ -2030,6 +2058,44 @@ static int repo_init_directories(
2030
2058
  return error;
2031
2059
  }
2032
2060
 
2061
+ static int repo_init_head(const char *repo_dir, const char *given)
2062
+ {
2063
+ git_config *cfg = NULL;
2064
+ git_buf head_path = GIT_BUF_INIT, cfg_branch = GIT_BUF_INIT;
2065
+ const char *initial_head = NULL;
2066
+ int error;
2067
+
2068
+ if ((error = git_buf_joinpath(&head_path, repo_dir, GIT_HEAD_FILE)) < 0)
2069
+ goto out;
2070
+
2071
+ /*
2072
+ * A template may have set a HEAD; use that unless it's been
2073
+ * overridden by the caller's given initial head setting.
2074
+ */
2075
+ if (git_path_exists(head_path.ptr) && !given)
2076
+ goto out;
2077
+
2078
+ if (given) {
2079
+ initial_head = given;
2080
+ } else if ((error = git_config_open_default(&cfg)) >= 0 &&
2081
+ (error = git_config_get_string_buf(&cfg_branch, cfg, "init.defaultbranch")) >= 0 &&
2082
+ *cfg_branch.ptr) {
2083
+ initial_head = cfg_branch.ptr;
2084
+ }
2085
+
2086
+ if (!initial_head)
2087
+ initial_head = GIT_BRANCH_DEFAULT;
2088
+
2089
+ error = git_repository_create_head(repo_dir, initial_head);
2090
+
2091
+ out:
2092
+ git_config_free(cfg);
2093
+ git_buf_dispose(&head_path);
2094
+ git_buf_dispose(&cfg_branch);
2095
+
2096
+ return error;
2097
+ }
2098
+
2033
2099
  static int repo_init_create_origin(git_repository *repo, const char *url)
2034
2100
  {
2035
2101
  int error;
@@ -2059,53 +2125,53 @@ int git_repository_init_ext(
2059
2125
  const char *given_repo,
2060
2126
  git_repository_init_options *opts)
2061
2127
  {
2062
- int error;
2063
2128
  git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT,
2064
2129
  common_path = GIT_BUF_INIT;
2065
2130
  const char *wd;
2131
+ bool is_valid;
2132
+ int error;
2066
2133
 
2067
2134
  assert(out && given_repo && opts);
2068
2135
 
2069
2136
  GIT_ERROR_CHECK_VERSION(opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION, "git_repository_init_options");
2070
2137
 
2071
- error = repo_init_directories(&repo_path, &wd_path, given_repo, opts);
2072
- if (error < 0)
2073
- goto cleanup;
2138
+ if ((error = repo_init_directories(&repo_path, &wd_path, given_repo, opts)) < 0)
2139
+ goto out;
2074
2140
 
2075
2141
  wd = (opts->flags & GIT_REPOSITORY_INIT_BARE) ? NULL : git_buf_cstr(&wd_path);
2076
- if (valid_repository_path(&repo_path, &common_path)) {
2077
2142
 
2143
+ if ((error = is_valid_repository_path(&is_valid, &repo_path, &common_path)) < 0)
2144
+ goto out;
2145
+
2146
+ if (is_valid) {
2078
2147
  if ((opts->flags & GIT_REPOSITORY_INIT_NO_REINIT) != 0) {
2079
2148
  git_error_set(GIT_ERROR_REPOSITORY,
2080
2149
  "attempt to reinitialize '%s'", given_repo);
2081
2150
  error = GIT_EEXISTS;
2082
- goto cleanup;
2151
+ goto out;
2083
2152
  }
2084
2153
 
2085
2154
  opts->flags |= GIT_REPOSITORY_INIT__IS_REINIT;
2086
2155
 
2087
- error = repo_init_config(
2088
- repo_path.ptr, wd, opts->flags, opts->mode);
2156
+ if ((error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0)
2157
+ goto out;
2089
2158
 
2090
2159
  /* TODO: reinitialize the templates */
2160
+ } else {
2161
+ if ((error = repo_init_structure(repo_path.ptr, wd, opts)) < 0 ||
2162
+ (error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0 ||
2163
+ (error = repo_init_head(repo_path.ptr, opts->initial_head)) < 0)
2164
+ goto out;
2091
2165
  }
2092
- else {
2093
- if (!(error = repo_init_structure(
2094
- repo_path.ptr, wd, opts)) &&
2095
- !(error = repo_init_config(
2096
- repo_path.ptr, wd, opts->flags, opts->mode)))
2097
- error = git_repository_create_head(
2098
- repo_path.ptr, opts->initial_head);
2099
- }
2100
- if (error < 0)
2101
- goto cleanup;
2102
2166
 
2103
- error = git_repository_open(out, repo_path.ptr);
2167
+ if ((error = git_repository_open(out, repo_path.ptr)) < 0)
2168
+ goto out;
2104
2169
 
2105
- if (!error && opts->origin_url)
2106
- error = repo_init_create_origin(*out, opts->origin_url);
2170
+ if (opts->origin_url &&
2171
+ (error = repo_init_create_origin(*out, opts->origin_url)) < 0)
2172
+ goto out;
2107
2173
 
2108
- cleanup:
2174
+ out:
2109
2175
  git_buf_dispose(&common_path);
2110
2176
  git_buf_dispose(&repo_path);
2111
2177
  git_buf_dispose(&wd_path);
@@ -2136,12 +2202,6 @@ int git_repository_head_detached(git_repository *repo)
2136
2202
  return exists;
2137
2203
  }
2138
2204
 
2139
- static int get_worktree_file_path(git_buf *out, git_repository *repo, const char *worktree, const char *file)
2140
- {
2141
- git_buf_clear(out);
2142
- return git_buf_printf(out, "%s/worktrees/%s/%s", repo->commondir, worktree, file);
2143
- }
2144
-
2145
2205
  int git_repository_head_detached_for_worktree(git_repository *repo, const char *name)
2146
2206
  {
2147
2207
  git_reference *ref = NULL;
@@ -2182,7 +2242,8 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
2182
2242
 
2183
2243
  int git_repository_head_for_worktree(git_reference **out, git_repository *repo, const char *name)
2184
2244
  {
2185
- git_buf path = GIT_BUF_INIT;
2245
+ git_repository *worktree_repo = NULL;
2246
+ git_worktree *worktree = NULL;
2186
2247
  git_reference *head = NULL;
2187
2248
  int error;
2188
2249
 
@@ -2190,58 +2251,68 @@ int git_repository_head_for_worktree(git_reference **out, git_repository *repo,
2190
2251
 
2191
2252
  *out = NULL;
2192
2253
 
2193
- if ((error = get_worktree_file_path(&path, repo, name, GIT_HEAD_FILE)) < 0 ||
2194
- (error = git_reference__read_head(&head, repo, path.ptr)) < 0)
2254
+ if ((error = git_worktree_lookup(&worktree, repo, name)) < 0 ||
2255
+ (error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0 ||
2256
+ (error = git_reference_lookup(&head, worktree_repo, GIT_HEAD_FILE)) < 0)
2195
2257
  goto out;
2196
2258
 
2197
2259
  if (git_reference_type(head) != GIT_REFERENCE_DIRECT) {
2198
- git_reference *resolved;
2199
-
2200
- error = git_reference_lookup_resolved(&resolved, repo, git_reference_symbolic_target(head), -1);
2201
- git_reference_free(head);
2202
- head = resolved;
2260
+ if ((error = git_reference_lookup_resolved(out, worktree_repo, git_reference_symbolic_target(head), -1)) < 0)
2261
+ goto out;
2262
+ } else {
2263
+ *out = head;
2264
+ head = NULL;
2203
2265
  }
2204
2266
 
2205
- *out = head;
2206
-
2207
2267
  out:
2208
- if (error)
2209
- git_reference_free(head);
2210
-
2211
- git_buf_dispose(&path);
2212
-
2268
+ git_reference_free(head);
2269
+ git_worktree_free(worktree);
2270
+ git_repository_free(worktree_repo);
2213
2271
  return error;
2214
2272
  }
2215
2273
 
2216
- int git_repository_foreach_head(git_repository *repo, git_repository_foreach_head_cb cb, void *payload)
2274
+ int git_repository_foreach_worktree(git_repository *repo,
2275
+ git_repository_foreach_worktree_cb cb,
2276
+ void *payload)
2217
2277
  {
2218
- git_strarray worktrees = GIT_VECTOR_INIT;
2219
- git_buf path = GIT_BUF_INIT;
2278
+ git_strarray worktrees = {0};
2279
+ git_repository *worktree_repo = NULL;
2280
+ git_worktree *worktree = NULL;
2220
2281
  int error;
2221
2282
  size_t i;
2222
2283
 
2223
- /* Execute callback for HEAD of commondir */
2224
- if ((error = git_buf_joinpath(&path, repo->commondir, GIT_HEAD_FILE)) < 0 ||
2225
- (error = cb(repo, path.ptr, payload) != 0))
2284
+ if ((error = git_repository_open(&worktree_repo, repo->commondir)) < 0 ||
2285
+ (error = cb(worktree_repo, payload) != 0))
2226
2286
  goto out;
2227
2287
 
2228
- if ((error = git_worktree_list(&worktrees, repo)) < 0) {
2229
- error = 0;
2288
+ git_repository_free(worktree_repo);
2289
+ worktree_repo = NULL;
2290
+
2291
+ if ((error = git_worktree_list(&worktrees, repo)) < 0)
2230
2292
  goto out;
2231
- }
2232
2293
 
2233
- /* Execute callback for all worktree HEADs */
2234
2294
  for (i = 0; i < worktrees.count; i++) {
2235
- if (get_worktree_file_path(&path, repo, worktrees.strings[i], GIT_HEAD_FILE) < 0)
2295
+ git_repository_free(worktree_repo);
2296
+ worktree_repo = NULL;
2297
+ git_worktree_free(worktree);
2298
+ worktree = NULL;
2299
+
2300
+ if ((error = git_worktree_lookup(&worktree, repo, worktrees.strings[i]) < 0) ||
2301
+ (error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0) {
2302
+ if (error != GIT_ENOTFOUND)
2303
+ goto out;
2304
+ error = 0;
2236
2305
  continue;
2306
+ }
2237
2307
 
2238
- if ((error = cb(repo, path.ptr, payload)) != 0)
2308
+ if ((error = cb(worktree_repo, payload)) != 0)
2239
2309
  goto out;
2240
2310
  }
2241
2311
 
2242
2312
  out:
2243
- git_buf_dispose(&path);
2244
- git_strarray_free(&worktrees);
2313
+ git_strarray_dispose(&worktrees);
2314
+ git_repository_free(worktree_repo);
2315
+ git_worktree_free(worktree);
2245
2316
  return error;
2246
2317
  }
2247
2318
 
@@ -2264,50 +2335,85 @@ int git_repository_head_unborn(git_repository *repo)
2264
2335
  return 0;
2265
2336
  }
2266
2337
 
2267
- static int at_least_one_cb(const char *refname, void *payload)
2338
+ static int repo_contains_no_reference(git_repository *repo)
2268
2339
  {
2269
- GIT_UNUSED(refname);
2270
- GIT_UNUSED(payload);
2271
- return GIT_PASSTHROUGH;
2340
+ git_reference_iterator *iter;
2341
+ const char *refname;
2342
+ int error;
2343
+
2344
+ if ((error = git_reference_iterator_new(&iter, repo)) < 0)
2345
+ return error;
2346
+
2347
+ error = git_reference_next_name(&refname, iter);
2348
+ git_reference_iterator_free(iter);
2349
+
2350
+ if (error == GIT_ITEROVER)
2351
+ return 1;
2352
+
2353
+ return error;
2272
2354
  }
2273
2355
 
2274
- static int repo_contains_no_reference(git_repository *repo)
2356
+ int git_repository_initialbranch(git_buf *out, git_repository *repo)
2275
2357
  {
2276
- int error = git_reference_foreach_name(repo, &at_least_one_cb, NULL);
2358
+ git_config *config;
2359
+ git_config_entry *entry = NULL;
2360
+ const char *branch;
2361
+ int error;
2277
2362
 
2278
- if (error == GIT_PASSTHROUGH)
2279
- return 0;
2363
+ if ((error = git_repository_config__weakptr(&config, repo)) < 0)
2364
+ return error;
2280
2365
 
2281
- if (!error)
2282
- return 1;
2366
+ if ((error = git_config_get_entry(&entry, config, "init.defaultbranch")) == 0 &&
2367
+ *entry->value) {
2368
+ branch = entry->value;
2369
+ }
2370
+ else if (!error || error == GIT_ENOTFOUND) {
2371
+ branch = GIT_BRANCH_DEFAULT;
2372
+ }
2373
+ else {
2374
+ goto done;
2375
+ }
2376
+
2377
+ if ((error = git_buf_puts(out, GIT_REFS_HEADS_DIR)) < 0 ||
2378
+ (error = git_buf_puts(out, branch)) < 0)
2379
+ goto done;
2380
+
2381
+ if (!git_reference_is_valid_name(out->ptr)) {
2382
+ git_error_set(GIT_ERROR_INVALID, "the value of init.defaultBranch is not a valid branch name");
2383
+ error = -1;
2384
+ }
2283
2385
 
2386
+ done:
2387
+ git_config_entry_free(entry);
2284
2388
  return error;
2285
2389
  }
2286
2390
 
2287
2391
  int git_repository_is_empty(git_repository *repo)
2288
2392
  {
2289
2393
  git_reference *head = NULL;
2290
- int is_empty = 0;
2394
+ git_buf initialbranch = GIT_BUF_INIT;
2395
+ int result = 0;
2291
2396
 
2292
- if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0)
2293
- return -1;
2397
+ if ((result = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0 ||
2398
+ (result = git_repository_initialbranch(&initialbranch, repo)) < 0)
2399
+ goto done;
2294
2400
 
2295
- if (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC)
2296
- is_empty =
2297
- (strcmp(git_reference_symbolic_target(head),
2298
- GIT_REFS_HEADS_DIR "master") == 0) &&
2299
- repo_contains_no_reference(repo);
2401
+ result = (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC &&
2402
+ strcmp(git_reference_symbolic_target(head), initialbranch.ptr) == 0 &&
2403
+ repo_contains_no_reference(repo));
2300
2404
 
2405
+ done:
2301
2406
  git_reference_free(head);
2407
+ git_buf_dispose(&initialbranch);
2302
2408
 
2303
- return is_empty;
2409
+ return result;
2304
2410
  }
2305
2411
 
2306
- int git_repository_item_path(git_buf *out, const git_repository *repo, git_repository_item_t item)
2412
+ static const char *resolved_parent_path(const git_repository *repo, git_repository_item_t item, git_repository_item_t fallback)
2307
2413
  {
2308
2414
  const char *parent;
2309
2415
 
2310
- switch (items[item].parent) {
2416
+ switch (item) {
2311
2417
  case GIT_REPOSITORY_ITEM_GITDIR:
2312
2418
  parent = git_repository_path(repo);
2313
2419
  break;
@@ -2319,9 +2425,17 @@ int git_repository_item_path(git_buf *out, const git_repository *repo, git_repos
2319
2425
  break;
2320
2426
  default:
2321
2427
  git_error_set(GIT_ERROR_INVALID, "invalid item directory");
2322
- return -1;
2428
+ return NULL;
2323
2429
  }
2430
+ if (!parent && fallback != GIT_REPOSITORY_ITEM__LAST)
2431
+ return resolved_parent_path(repo, fallback, GIT_REPOSITORY_ITEM__LAST);
2324
2432
 
2433
+ return parent;
2434
+ }
2435
+
2436
+ int git_repository_item_path(git_buf *out, const git_repository *repo, git_repository_item_t item)
2437
+ {
2438
+ const char *parent = resolved_parent_path(repo, items[item].parent, items[item].fallback);
2325
2439
  if (parent == NULL) {
2326
2440
  git_error_set(GIT_ERROR_INVALID, "path cannot exist in repository");
2327
2441
  return GIT_ENOTFOUND;
@@ -2536,7 +2650,7 @@ int git_repository_hashfile(
2536
2650
  int error;
2537
2651
  git_filter_list *fl = NULL;
2538
2652
  git_file fd = -1;
2539
- git_off_t len;
2653
+ uint64_t len;
2540
2654
  git_buf full_path = GIT_BUF_INIT;
2541
2655
 
2542
2656
  assert(out && path && repo); /* as_path can be NULL */
@@ -2573,11 +2687,8 @@ int git_repository_hashfile(
2573
2687
  goto cleanup;
2574
2688
  }
2575
2689
 
2576
- len = git_futils_filesize(fd);
2577
- if (len < 0) {
2578
- error = (int)len;
2690
+ if ((error = git_futils_filesize(&len, fd)) < 0)
2579
2691
  goto cleanup;
2580
- }
2581
2692
 
2582
2693
  if (!git__is_sizet(len)) {
2583
2694
  git_error_set(GIT_ERROR_OS, "file size overflow for 32-bit systems");
@@ -2866,7 +2977,7 @@ int git_repository_is_shallow(git_repository *repo)
2866
2977
  return st.st_size == 0 ? 0 : 1;
2867
2978
  }
2868
2979
 
2869
- int git_repository_init_init_options(
2980
+ int git_repository_init_options_init(
2870
2981
  git_repository_init_options *opts, unsigned int version)
2871
2982
  {
2872
2983
  GIT_INIT_STRUCTURE_FROM_TEMPLATE(
@@ -2875,6 +2986,14 @@ int git_repository_init_init_options(
2875
2986
  return 0;
2876
2987
  }
2877
2988
 
2989
+ #ifndef GIT_DEPRECATE_HARD
2990
+ int git_repository_init_init_options(
2991
+ git_repository_init_options *opts, unsigned int version)
2992
+ {
2993
+ return git_repository_init_options_init(opts, version);
2994
+ }
2995
+ #endif
2996
+
2878
2997
  int git_repository_ident(const char **name, const char **email, const git_repository *repo)
2879
2998
  {
2880
2999
  *name = repo->ident_name;
@@ -2912,7 +3031,7 @@ int git_repository_submodule_cache_all(git_repository *repo)
2912
3031
 
2913
3032
  assert(repo);
2914
3033
 
2915
- if ((error = git_strmap_alloc(&repo->submodule_cache)))
3034
+ if ((error = git_strmap_new(&repo->submodule_cache)))
2916
3035
  return error;
2917
3036
 
2918
3037
  error = git_submodule__map(repo, repo->submodule_cache);