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
@@ -11,31 +11,167 @@
11
11
 
12
12
  #include "git2/index.h"
13
13
 
14
+ /** A map with `git_index_entry`s as key. */
14
15
  typedef struct kh_idx_s git_idxmap;
16
+ /** A map with case-insensitive `git_index_entry`s as key */
15
17
  typedef struct kh_idxicase_s git_idxmap_icase;
16
18
 
17
- int git_idxmap_alloc(git_idxmap **map);
18
- int git_idxmap_icase_alloc(git_idxmap_icase **map);
19
- void git_idxmap_insert(git_idxmap *map, const git_index_entry *key, void *value, int *rval);
20
- void git_idxmap_icase_insert(git_idxmap_icase *map, const git_index_entry *key, void *value, int *rval);
19
+ /**
20
+ * Allocate a new index entry map.
21
+ *
22
+ * @param out Pointer to the map that shall be allocated.
23
+ * @return 0 on success, an error code if allocation has failed.
24
+ */
25
+ int git_idxmap_new(git_idxmap **out);
21
26
 
22
- size_t git_idxmap_lookup_index(git_idxmap *map, const git_index_entry *key);
23
- size_t git_idxmap_icase_lookup_index(git_idxmap_icase *map, const git_index_entry *key);
24
- void *git_idxmap_value_at(git_idxmap *map, size_t idx);
25
- int git_idxmap_valid_index(git_idxmap *map, size_t idx);
26
- int git_idxmap_has_data(git_idxmap *map, size_t idx);
27
+ /**
28
+ * Allocate a new case-insensitive index entry map.
29
+ *
30
+ * @param out Pointer to the map that shall be allocated.
31
+ * @return 0 on success, an error code if allocation has failed.
32
+ */
33
+ int git_idxmap_icase_new(git_idxmap_icase **out);
27
34
 
28
- void git_idxmap_resize(git_idxmap *map, size_t size);
29
- void git_idxmap_icase_resize(git_idxmap_icase *map, size_t size);
35
+ /**
36
+ * Free memory associated with the map.
37
+ *
38
+ * Note that this function will _not_ free values added to this
39
+ * map.
40
+ *
41
+ * @param map Pointer to the map that is to be free'd. May be
42
+ * `NULL`.
43
+ */
30
44
  void git_idxmap_free(git_idxmap *map);
45
+
46
+ /**
47
+ * Free memory associated with the map.
48
+ *
49
+ * Note that this function will _not_ free values added to this
50
+ * map.
51
+ *
52
+ * @param map Pointer to the map that is to be free'd. May be
53
+ * `NULL`.
54
+ */
31
55
  void git_idxmap_icase_free(git_idxmap_icase *map);
56
+
57
+ /**
58
+ * Clear all entries from the map.
59
+ *
60
+ * This function will remove all entries from the associated map.
61
+ * Memory associated with it will not be released, though.
62
+ *
63
+ * @param map Pointer to the map that shall be cleared. May be
64
+ * `NULL`.
65
+ */
32
66
  void git_idxmap_clear(git_idxmap *map);
67
+
68
+ /**
69
+ * Clear all entries from the map.
70
+ *
71
+ * This function will remove all entries from the associated map.
72
+ * Memory associated with it will not be released, though.
73
+ *
74
+ * @param map Pointer to the map that shall be cleared. May be
75
+ * `NULL`.
76
+ */
33
77
  void git_idxmap_icase_clear(git_idxmap_icase *map);
34
78
 
35
- void git_idxmap_delete_at(git_idxmap *map, size_t idx);
36
- void git_idxmap_icase_delete_at(git_idxmap_icase *map, size_t idx);
79
+ /**
80
+ * Resize the map by allocating more memory.
81
+ *
82
+ * @param map map that shall be resized
83
+ * @param size count of entries that the map shall hold
84
+ * @return `0` if the map was successfully resized, a negative
85
+ * error code otherwise
86
+ */
87
+ int git_idxmap_resize(git_idxmap *map, size_t size);
37
88
 
38
- void git_idxmap_delete(git_idxmap *map, const git_index_entry *key);
39
- void git_idxmap_icase_delete(git_idxmap_icase *map, const git_index_entry *key);
89
+ /**
90
+ * Resize the map by allocating more memory.
91
+ *
92
+ * @param map map that shall be resized
93
+ * @param size count of entries that the map shall hold
94
+ * @return `0` if the map was successfully resized, a negative
95
+ * error code otherwise
96
+ */
97
+ int git_idxmap_icase_resize(git_idxmap_icase *map, size_t size);
98
+
99
+ /**
100
+ * Return value associated with the given key.
101
+ *
102
+ * @param map map to search key in
103
+ * @param key key to search for; the index entry will be searched
104
+ * for by its case-sensitive path
105
+ * @return value associated with the given key or NULL if the key was not found
106
+ */
107
+ void *git_idxmap_get(git_idxmap *map, const git_index_entry *key);
108
+
109
+ /**
110
+ * Return value associated with the given key.
111
+ *
112
+ * @param map map to search key in
113
+ * @param key key to search for; the index entry will be searched
114
+ * for by its case-insensitive path
115
+ * @return value associated with the given key or NULL if the key was not found
116
+ */
117
+ void *git_idxmap_icase_get(git_idxmap_icase *map, const git_index_entry *key);
118
+
119
+ /**
120
+ * Set the entry for key to value.
121
+ *
122
+ * If the map has no corresponding entry for the given key, a new
123
+ * entry will be created with the given value. If an entry exists
124
+ * already, its value will be updated to match the given value.
125
+ *
126
+ * @param map map to create new entry in
127
+ * @param key key to set
128
+ * @param value value to associate the key with; may be NULL
129
+ * @return zero if the key was successfully set, a negative error
130
+ * code otherwise
131
+ */
132
+ int git_idxmap_set(git_idxmap *map, const git_index_entry *key, void *value);
133
+
134
+ /**
135
+ * Set the entry for key to value.
136
+ *
137
+ * If the map has no corresponding entry for the given key, a new
138
+ * entry will be created with the given value. If an entry exists
139
+ * already, its value will be updated to match the given value.
140
+ *
141
+ * @param map map to create new entry in
142
+ * @param key key to set
143
+ * @param value value to associate the key with; may be NULL
144
+ * @return zero if the key was successfully set, a negative error
145
+ * code otherwise
146
+ */
147
+ int git_idxmap_icase_set(git_idxmap_icase *map, const git_index_entry *key, void *value);
148
+
149
+ /**
150
+ * Delete an entry from the map.
151
+ *
152
+ * Delete the given key and its value from the map. If no such
153
+ * key exists, this will do nothing.
154
+ *
155
+ * @param map map to delete key in
156
+ * @param key key to delete
157
+ * @return `0` if the key has been deleted, GIT_ENOTFOUND if no
158
+ * such key was found, a negative code in case of an
159
+ * error
160
+ */
161
+ int git_idxmap_delete(git_idxmap *map, const git_index_entry *key);
162
+
163
+ /**
164
+ * Delete an entry from the map.
165
+ *
166
+ * Delete the given key and its value from the map. If no such
167
+ * key exists, this will do nothing.
168
+ *
169
+ * @param map map to delete key in
170
+ * @param key key to delete
171
+ * @return `0` if the key has been deleted, GIT_ENOTFOUND if no
172
+ * such key was found, a negative code in case of an
173
+ * error
174
+ */
175
+ int git_idxmap_icase_delete(git_idxmap_icase *map, const git_index_entry *key);
40
176
 
41
177
  #endif
@@ -12,7 +12,7 @@
12
12
  #include "attrcache.h"
13
13
  #include "path.h"
14
14
  #include "config.h"
15
- #include "fnmatch.h"
15
+ #include "wildmatch.h"
16
16
 
17
17
  #define GIT_IGNORE_INTERNAL "[internal]exclude"
18
18
 
@@ -101,7 +101,7 @@ static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg)
101
101
  */
102
102
  static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match)
103
103
  {
104
- int error = 0, fnflags;
104
+ int error = 0, wildmatch_flags;
105
105
  size_t i;
106
106
  git_attr_fnmatch *rule;
107
107
  char *path;
@@ -109,9 +109,9 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
109
109
 
110
110
  *out = 0;
111
111
 
112
- fnflags = FNM_PATHNAME;
112
+ wildmatch_flags = WM_PATHNAME;
113
113
  if (match->flags & GIT_ATTR_FNMATCH_ICASE)
114
- fnflags |= FNM_IGNORECASE;
114
+ wildmatch_flags |= WM_CASEFOLD;
115
115
 
116
116
  /* path of the file relative to the workdir, so we match the rules in subdirs */
117
117
  if (match->containing_dir) {
@@ -141,13 +141,8 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
141
141
  if (git_buf_oom(&buf))
142
142
  goto out;
143
143
 
144
- if ((error = p_fnmatch(git_buf_cstr(&buf), path, fnflags)) < 0) {
145
- git_error_set(GIT_ERROR_INVALID, "error matching pattern");
146
- goto out;
147
- }
148
-
149
144
  /* if we found a match, we want to keep this rule */
150
- if (error != FNM_NOMATCH) {
145
+ if ((wildmatch(git_buf_cstr(&buf), path, wildmatch_flags)) == WM_MATCH) {
151
146
  *out = 1;
152
147
  error = 0;
153
148
  goto out;
@@ -163,14 +158,16 @@ out:
163
158
  }
164
159
 
165
160
  static int parse_ignore_file(
166
- git_repository *repo, git_attr_file *attrs, const char *data)
161
+ git_repository *repo, git_attr_file *attrs, const char *data, bool allow_macros)
167
162
  {
168
163
  int error = 0;
169
164
  int ignore_case = false;
170
165
  const char *scan = data, *context = NULL;
171
166
  git_attr_fnmatch *match = NULL;
172
167
 
173
- if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0)
168
+ GIT_UNUSED(allow_macros);
169
+
170
+ if (git_repository__configmap_lookup(&ignore_case, repo, GIT_CONFIGMAP_IGNORECASE) < 0)
174
171
  git_error_clear();
175
172
 
176
173
  /* if subdir file path, convert context for file paths */
@@ -193,9 +190,7 @@ static int parse_ignore_file(
193
190
  }
194
191
 
195
192
  match->flags =
196
- GIT_ATTR_FNMATCH_ALLOWSPACE |
197
- GIT_ATTR_FNMATCH_ALLOWNEG |
198
- GIT_ATTR_FNMATCH_NOLEADINGDIR;
193
+ GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG;
199
194
 
200
195
  if (!(error = git_attr_fnmatch__parse(
201
196
  match, &attrs->pool, context, &scan)))
@@ -246,9 +241,8 @@ static int push_ignore_file(
246
241
  int error = 0;
247
242
  git_attr_file *file = NULL;
248
243
 
249
- error = git_attr_cache__get(
250
- &file, ignores->repo, NULL, GIT_ATTR_FILE__FROM_FILE,
251
- base, filename, parse_ignore_file);
244
+ error = git_attr_cache__get(&file, ignores->repo, NULL, GIT_ATTR_FILE__FROM_FILE,
245
+ base, filename, parse_ignore_file, false);
252
246
  if (error < 0)
253
247
  return error;
254
248
 
@@ -274,12 +268,12 @@ static int get_internal_ignores(git_attr_file **out, git_repository *repo)
274
268
  if ((error = git_attr_cache__init(repo)) < 0)
275
269
  return error;
276
270
 
277
- error = git_attr_cache__get(
278
- out, repo, NULL, GIT_ATTR_FILE__IN_MEMORY, NULL, GIT_IGNORE_INTERNAL, NULL);
271
+ error = git_attr_cache__get(out, repo, NULL, GIT_ATTR_FILE__IN_MEMORY, NULL,
272
+ GIT_IGNORE_INTERNAL, NULL, false);
279
273
 
280
274
  /* if internal rules list is empty, insert default rules */
281
275
  if (!error && !(*out)->rules.length)
282
- error = parse_ignore_file(repo, *out, GIT_IGNORE_DEFAULT_RULES);
276
+ error = parse_ignore_file(repo, *out, GIT_IGNORE_DEFAULT_RULES, false);
283
277
 
284
278
  return error;
285
279
  }
@@ -299,8 +293,8 @@ int git_ignore__for_path(
299
293
  ignores->repo = repo;
300
294
 
301
295
  /* Read the ignore_case flag */
302
- if ((error = git_repository__cvar(
303
- &ignores->ignore_case, repo, GIT_CVAR_IGNORECASE)) < 0)
296
+ if ((error = git_repository__configmap_lookup(
297
+ &ignores->ignore_case, repo, GIT_CONFIGMAP_IGNORECASE)) < 0)
304
298
  goto cleanup;
305
299
 
306
300
  if ((error = git_attr_cache__init(repo)) < 0)
@@ -337,16 +331,13 @@ int git_ignore__for_path(
337
331
  goto cleanup;
338
332
  }
339
333
 
340
- if ((error = git_repository_item_path(&infopath,
341
- repo, GIT_REPOSITORY_ITEM_INFO)) < 0)
342
- goto cleanup;
343
-
344
- /* load .git/info/exclude */
345
- error = push_ignore_file(
346
- ignores, &ignores->ign_global,
347
- infopath.ptr, GIT_IGNORE_FILE_INREPO);
348
- if (error < 0)
349
- goto cleanup;
334
+ /* load .git/info/exclude if possible */
335
+ if ((error = git_repository_item_path(&infopath, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
336
+ (error = push_ignore_file(ignores, &ignores->ign_global, infopath.ptr, GIT_IGNORE_FILE_INREPO)) < 0) {
337
+ if (error != GIT_ENOTFOUND)
338
+ goto cleanup;
339
+ error = 0;
340
+ }
350
341
 
351
342
  /* load core.excludesfile */
352
343
  if (git_repository_attr_cache(repo)->cfg_excl_file != NULL)
@@ -495,7 +486,7 @@ int git_ignore_add_rule(git_repository *repo, const char *rules)
495
486
  if ((error = get_internal_ignores(&ign_internal, repo)) < 0)
496
487
  return error;
497
488
 
498
- error = parse_ignore_file(repo, ign_internal, rules);
489
+ error = parse_ignore_file(repo, ign_internal, rules, false);
499
490
  git_attr_file__free(ign_internal);
500
491
 
501
492
  return error;
@@ -511,7 +502,7 @@ int git_ignore_clear_internal_rules(git_repository *repo)
511
502
 
512
503
  if (!(error = git_attr_file__clear_rules(ign_internal, true)))
513
504
  error = parse_ignore_file(
514
- repo, ign_internal, GIT_IGNORE_DEFAULT_RULES);
505
+ repo, ign_internal, GIT_IGNORE_DEFAULT_RULES, false);
515
506
 
516
507
  git_attr_file__free(ign_internal);
517
508
  return error;
@@ -27,29 +27,6 @@
27
27
  #include "git2/config.h"
28
28
  #include "git2/sys/index.h"
29
29
 
30
- #define INSERT_IN_MAP_EX(idx, map, e, err) do { \
31
- if ((idx)->ignore_case) \
32
- git_idxmap_icase_insert((git_idxmap_icase *) (map), (e), (e), (err)); \
33
- else \
34
- git_idxmap_insert((map), (e), (e), (err)); \
35
- } while (0)
36
-
37
- #define INSERT_IN_MAP(idx, e, err) INSERT_IN_MAP_EX(idx, (idx)->entries_map, e, err)
38
-
39
- #define LOOKUP_IN_MAP(p, idx, k) do { \
40
- if ((idx)->ignore_case) \
41
- (p) = git_idxmap_icase_lookup_index((git_idxmap_icase *) index->entries_map, (k)); \
42
- else \
43
- (p) = git_idxmap_lookup_index(index->entries_map, (k)); \
44
- } while (0)
45
-
46
- #define DELETE_IN_MAP(idx, e) do { \
47
- if ((idx)->ignore_case) \
48
- git_idxmap_icase_delete((git_idxmap_icase *) (idx)->entries_map, (e)); \
49
- else \
50
- git_idxmap_delete((idx)->entries_map, (e)); \
51
- } while (0)
52
-
53
30
  static int index_apply_to_wd_diff(git_index *index, int action, const git_strarray *paths,
54
31
  unsigned int flags,
55
32
  git_index_matched_path_cb cb, void *payload);
@@ -148,6 +125,30 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file);
148
125
  static void index_entry_free(git_index_entry *entry);
149
126
  static void index_entry_reuc_free(git_index_reuc_entry *reuc);
150
127
 
128
+ GIT_INLINE(int) index_map_set(git_idxmap *map, git_index_entry *e, bool ignore_case)
129
+ {
130
+ if (ignore_case)
131
+ return git_idxmap_icase_set((git_idxmap_icase *) map, e, e);
132
+ else
133
+ return git_idxmap_set(map, e, e);
134
+ }
135
+
136
+ GIT_INLINE(int) index_map_delete(git_idxmap *map, git_index_entry *e, bool ignore_case)
137
+ {
138
+ if (ignore_case)
139
+ return git_idxmap_icase_delete((git_idxmap_icase *) map, e);
140
+ else
141
+ return git_idxmap_delete(map, e);
142
+ }
143
+
144
+ GIT_INLINE(int) index_map_resize(git_idxmap *map, size_t count, bool ignore_case)
145
+ {
146
+ if (ignore_case)
147
+ return git_idxmap_icase_resize((git_idxmap_icase *) map, count);
148
+ else
149
+ return git_idxmap_resize(map, count);
150
+ }
151
+
151
152
  int git_index_entry_srch(const void *key, const void *array_member)
152
153
  {
153
154
  const struct entry_srch_key *srch_key = key;
@@ -410,7 +411,8 @@ int git_index_open(git_index **index_out, const char *index_path)
410
411
  index = git__calloc(1, sizeof(git_index));
411
412
  GIT_ERROR_CHECK_ALLOC(index);
412
413
 
413
- git_pool_init(&index->tree_pool, 1);
414
+ if (git_pool_init(&index->tree_pool, 1) < 0)
415
+ goto fail;
414
416
 
415
417
  if (index_path != NULL) {
416
418
  index->index_file_path = git__strdup(index_path);
@@ -423,10 +425,10 @@ int git_index_open(git_index **index_out, const char *index_path)
423
425
  }
424
426
 
425
427
  if (git_vector_init(&index->entries, 32, git_index_entry_cmp) < 0 ||
426
- git_idxmap_alloc(&index->entries_map) < 0 ||
427
- git_vector_init(&index->names, 8, conflict_name_cmp) < 0 ||
428
- git_vector_init(&index->reuc, 8, reuc_cmp) < 0 ||
429
- git_vector_init(&index->deleted, 8, git_index_entry_cmp) < 0)
428
+ git_idxmap_new(&index->entries_map) < 0 ||
429
+ git_vector_init(&index->names, 8, conflict_name_cmp) < 0 ||
430
+ git_vector_init(&index->reuc, 8, reuc_cmp) < 0 ||
431
+ git_vector_init(&index->deleted, 8, git_index_entry_cmp) < 0)
430
432
  goto fail;
431
433
 
432
434
  index->entries_cmp_path = git__strcmp_cb;
@@ -507,7 +509,7 @@ static int index_remove_entry(git_index *index, size_t pos)
507
509
 
508
510
  if (entry != NULL) {
509
511
  git_tree_cache_invalidate_path(index->tree, entry->path);
510
- DELETE_IN_MAP(index, entry);
512
+ index_map_delete(index->entries_map, entry, index->ignore_case);
511
513
  }
512
514
 
513
515
  error = git_vector_remove(&index->entries, pos);
@@ -538,13 +540,19 @@ int git_index_clear(git_index *index)
538
540
  git_idxmap_clear(index->entries_map);
539
541
  while (!error && index->entries.length > 0)
540
542
  error = index_remove_entry(index, index->entries.length - 1);
543
+
544
+ if (error)
545
+ goto done;
546
+
541
547
  index_free_deleted(index);
542
548
 
543
- git_index_reuc_clear(index);
544
- git_index_name_clear(index);
549
+ if ((error = git_index_name_clear(index)) < 0 ||
550
+ (error = git_index_reuc_clear(index)) < 0)
551
+ goto done;
545
552
 
546
553
  git_futils_filestamp_set(&index->stamp, NULL);
547
554
 
555
+ done:
548
556
  return error;
549
557
  }
550
558
 
@@ -570,11 +578,11 @@ int git_index_set_caps(git_index *index, int caps)
570
578
  return create_index_error(
571
579
  -1, "cannot access repository to set index caps");
572
580
 
573
- if (!git_repository__cvar(&val, repo, GIT_CVAR_IGNORECASE))
581
+ if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_IGNORECASE))
574
582
  index->ignore_case = (val != 0);
575
- if (!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE))
583
+ if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_FILEMODE))
576
584
  index->distrust_filemode = (val == 0);
577
- if (!git_repository__cvar(&val, repo, GIT_CVAR_SYMLINKS))
585
+ if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_SYMLINKS))
578
586
  index->no_symlinks = (val == 0);
579
587
  }
580
588
  else {
@@ -852,20 +860,24 @@ const git_index_entry *git_index_get_bypath(
852
860
  git_index *index, const char *path, int stage)
853
861
  {
854
862
  git_index_entry key = {{ 0 }};
855
- size_t pos;
863
+ git_index_entry *value;
856
864
 
857
865
  assert(index);
858
866
 
859
867
  key.path = path;
860
868
  GIT_INDEX_ENTRY_STAGE_SET(&key, stage);
861
869
 
862
- LOOKUP_IN_MAP(pos, index, &key);
870
+ if (index->ignore_case)
871
+ value = git_idxmap_icase_get((git_idxmap_icase *) index->entries_map, &key);
872
+ else
873
+ value = git_idxmap_get(index->entries_map, &key);
863
874
 
864
- if (git_idxmap_valid_index(index->entries_map, pos))
865
- return git_idxmap_value_at(index->entries_map, pos);
875
+ if (!value) {
876
+ git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
877
+ return NULL;
878
+ }
866
879
 
867
- git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
868
- return NULL;
880
+ return value;
869
881
  }
870
882
 
871
883
  void git_index_entry__init_from_stat(
@@ -1398,10 +1410,9 @@ static int index_insert(
1398
1410
  * at the sorted position. (Since we re-sort after each insert to
1399
1411
  * check for dups, this is actually cheaper in the long run.)
1400
1412
  */
1401
- if ((error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)) < 0)
1413
+ if ((error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)) < 0 ||
1414
+ (error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0)
1402
1415
  goto out;
1403
-
1404
- INSERT_IN_MAP(index, entry, &error);
1405
1416
  }
1406
1417
 
1407
1418
  index->dirty = 1;
@@ -1453,7 +1464,7 @@ GIT_INLINE(bool) valid_filemode(const int filemode)
1453
1464
  return (is_file_or_link(filemode) || filemode == GIT_FILEMODE_COMMIT);
1454
1465
  }
1455
1466
 
1456
- int git_index_add_frombuffer(
1467
+ int git_index_add_from_buffer(
1457
1468
  git_index *index, const git_index_entry *source_entry,
1458
1469
  const void *buffer, size_t len)
1459
1470
  {
@@ -1473,17 +1484,22 @@ int git_index_add_frombuffer(
1473
1484
  return -1;
1474
1485
  }
1475
1486
 
1487
+ if (len > UINT32_MAX) {
1488
+ git_error_set(GIT_ERROR_INDEX, "buffer is too large");
1489
+ return -1;
1490
+ }
1491
+
1476
1492
  if (index_entry_dup(&entry, index, source_entry) < 0)
1477
1493
  return -1;
1478
1494
 
1479
- error = git_blob_create_frombuffer(&id, INDEX_OWNER(index), buffer, len);
1495
+ error = git_blob_create_from_buffer(&id, INDEX_OWNER(index), buffer, len);
1480
1496
  if (error < 0) {
1481
1497
  index_entry_free(entry);
1482
1498
  return error;
1483
1499
  }
1484
1500
 
1485
1501
  git_oid_cpy(&entry->id, &id);
1486
- entry->file_size = len;
1502
+ entry->file_size = (uint32_t)len;
1487
1503
 
1488
1504
  if ((error = index_insert(index, &entry, 1, true, true, true)) < 0)
1489
1505
  return error;
@@ -1610,41 +1626,42 @@ int git_index_remove_bypath(git_index *index, const char *path)
1610
1626
  int git_index__fill(git_index *index, const git_vector *source_entries)
1611
1627
  {
1612
1628
  const git_index_entry *source_entry = NULL;
1629
+ int error = 0;
1613
1630
  size_t i;
1614
- int ret = 0;
1615
1631
 
1616
1632
  assert(index);
1617
1633
 
1618
1634
  if (!source_entries->length)
1619
1635
  return 0;
1620
1636
 
1621
- git_vector_size_hint(&index->entries, source_entries->length);
1622
- git_idxmap_resize(index->entries_map, (size_t)(source_entries->length * 1.3));
1637
+ if (git_vector_size_hint(&index->entries, source_entries->length) < 0 ||
1638
+ index_map_resize(index->entries_map, (size_t)(source_entries->length * 1.3),
1639
+ index->ignore_case) < 0)
1640
+ return -1;
1623
1641
 
1624
1642
  git_vector_foreach(source_entries, i, source_entry) {
1625
1643
  git_index_entry *entry = NULL;
1626
1644
 
1627
- if ((ret = index_entry_dup(&entry, index, source_entry)) < 0)
1645
+ if ((error = index_entry_dup(&entry, index, source_entry)) < 0)
1628
1646
  break;
1629
1647
 
1630
1648
  index_entry_adjust_namemask(entry, ((struct entry_internal *)entry)->pathlen);
1631
1649
  entry->flags_extended |= GIT_INDEX_ENTRY_UPTODATE;
1632
1650
  entry->mode = git_index__create_mode(entry->mode);
1633
1651
 
1634
- if ((ret = git_vector_insert(&index->entries, entry)) < 0)
1652
+ if ((error = git_vector_insert(&index->entries, entry)) < 0)
1635
1653
  break;
1636
1654
 
1637
- INSERT_IN_MAP(index, entry, &ret);
1638
- if (ret < 0)
1655
+ if ((error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0)
1639
1656
  break;
1640
1657
 
1641
1658
  index->dirty = 1;
1642
1659
  }
1643
1660
 
1644
- if (!ret)
1661
+ if (!error)
1645
1662
  git_vector_sort(&index->entries);
1646
1663
 
1647
- return ret;
1664
+ return error;
1648
1665
  }
1649
1666
 
1650
1667
 
@@ -1677,7 +1694,7 @@ int git_index_remove(git_index *index, const char *path, int stage)
1677
1694
  remove_key.path = path;
1678
1695
  GIT_INDEX_ENTRY_STAGE_SET(&remove_key, stage);
1679
1696
 
1680
- DELETE_IN_MAP(index, &remove_key);
1697
+ index_map_delete(index->entries_map, &remove_key, index->ignore_case);
1681
1698
 
1682
1699
  if (index_find(&position, index, path, 0, stage) < 0) {
1683
1700
  git_error_set(
@@ -2126,7 +2143,7 @@ int git_index_name_add(git_index *index,
2126
2143
  return 0;
2127
2144
  }
2128
2145
 
2129
- void git_index_name_clear(git_index *index)
2146
+ int git_index_name_clear(git_index *index)
2130
2147
  {
2131
2148
  size_t i;
2132
2149
  git_index_name_entry *conflict_name;
@@ -2139,6 +2156,8 @@ void git_index_name_clear(git_index *index)
2139
2156
  git_vector_clear(&index->names);
2140
2157
 
2141
2158
  index->dirty = 1;
2159
+
2160
+ return 0;
2142
2161
  }
2143
2162
 
2144
2163
  size_t git_index_reuc_entrycount(git_index *index)
@@ -2235,7 +2254,7 @@ int git_index_reuc_remove(git_index *index, size_t position)
2235
2254
  return error;
2236
2255
  }
2237
2256
 
2238
- void git_index_reuc_clear(git_index *index)
2257
+ int git_index_reuc_clear(git_index *index)
2239
2258
  {
2240
2259
  size_t i;
2241
2260
 
@@ -2247,6 +2266,8 @@ void git_index_reuc_clear(git_index *index)
2247
2266
  git_vector_clear(&index->reuc);
2248
2267
 
2249
2268
  index->dirty = 1;
2269
+
2270
+ return 0;
2250
2271
  }
2251
2272
 
2252
2273
  static int index_error_invalid(const char *message)
@@ -2607,10 +2628,8 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2607
2628
 
2608
2629
  assert(!index->entries.length);
2609
2630
 
2610
- if (index->ignore_case)
2611
- git_idxmap_icase_resize((git_idxmap_icase *) index->entries_map, header.entry_count);
2612
- else
2613
- git_idxmap_resize(index->entries_map, header.entry_count);
2631
+ if ((error = index_map_resize(index->entries_map, header.entry_count, index->ignore_case)) < 0)
2632
+ return error;
2614
2633
 
2615
2634
  /* Parse all the entries */
2616
2635
  for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) {
@@ -2627,9 +2646,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2627
2646
  goto done;
2628
2647
  }
2629
2648
 
2630
- INSERT_IN_MAP(index, entry, &error);
2631
-
2632
- if (error < 0) {
2649
+ if ((error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0) {
2633
2650
  index_entry_free(entry);
2634
2651
  goto done;
2635
2652
  }
@@ -2728,7 +2745,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
2728
2745
  ++same_len;
2729
2746
  }
2730
2747
  path_len -= same_len;
2731
- varint_len = git_encode_varint(NULL, 0, same_len);
2748
+ varint_len = git_encode_varint(NULL, 0, strlen(last) - same_len);
2732
2749
  }
2733
2750
 
2734
2751
  disk_size = index_entry_size(path_len, varint_len, entry->flags);
@@ -2764,22 +2781,24 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
2764
2781
  ondisk.flags = htons(entry->flags);
2765
2782
 
2766
2783
  if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {
2784
+ const size_t path_offset = offsetof(struct entry_long, path);
2767
2785
  struct entry_long ondisk_ext;
2768
2786
  memcpy(&ondisk_ext, &ondisk, sizeof(struct entry_short));
2769
2787
  ondisk_ext.flags_extended = htons(entry->flags_extended &
2770
2788
  GIT_INDEX_ENTRY_EXTENDED_FLAGS);
2771
- memcpy(mem, &ondisk_ext, offsetof(struct entry_long, path));
2772
- path = ((struct entry_long*)mem)->path;
2773
- disk_size -= offsetof(struct entry_long, path);
2789
+ memcpy(mem, &ondisk_ext, path_offset);
2790
+ path = (char *)mem + path_offset;
2791
+ disk_size -= path_offset;
2774
2792
  } else {
2775
- memcpy(mem, &ondisk, offsetof(struct entry_short, path));
2776
- path = ((struct entry_short*)mem)->path;
2777
- disk_size -= offsetof(struct entry_short, path);
2793
+ const size_t path_offset = offsetof(struct entry_short, path);
2794
+ memcpy(mem, &ondisk, path_offset);
2795
+ path = (char *)mem + path_offset;
2796
+ disk_size -= path_offset;
2778
2797
  }
2779
2798
 
2780
2799
  if (last) {
2781
2800
  varint_len = git_encode_varint((unsigned char *) path,
2782
- disk_size, same_len);
2801
+ disk_size, strlen(last) - same_len);
2783
2802
  assert(varint_len > 0);
2784
2803
  path += varint_len;
2785
2804
  disk_size -= varint_len;
@@ -2807,14 +2826,16 @@ static int write_entries(git_index *index, git_filebuf *file)
2807
2826
  {
2808
2827
  int error = 0;
2809
2828
  size_t i;
2810
- git_vector case_sorted, *entries;
2829
+ git_vector case_sorted = GIT_VECTOR_INIT, *entries = NULL;
2811
2830
  git_index_entry *entry;
2812
2831
  const char *last = NULL;
2813
2832
 
2814
2833
  /* If index->entries is sorted case-insensitively, then we need
2815
2834
  * to re-sort it case-sensitively before writing */
2816
2835
  if (index->ignore_case) {
2817
- git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp);
2836
+ if ((error = git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp)) < 0)
2837
+ goto done;
2838
+
2818
2839
  git_vector_sort(&case_sorted);
2819
2840
  entries = &case_sorted;
2820
2841
  } else {
@@ -2831,9 +2852,8 @@ static int write_entries(git_index *index, git_filebuf *file)
2831
2852
  last = entry->path;
2832
2853
  }
2833
2854
 
2834
- if (index->ignore_case)
2835
- git_vector_free(&case_sorted);
2836
-
2855
+ done:
2856
+ git_vector_free(&case_sorted);
2837
2857
  return error;
2838
2858
  }
2839
2859
 
@@ -3106,7 +3126,7 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3106
3126
  size_t i;
3107
3127
  git_index_entry *e;
3108
3128
 
3109
- if (git_idxmap_alloc(&entries_map) < 0)
3129
+ if (git_idxmap_new(&entries_map) < 0)
3110
3130
  return -1;
3111
3131
 
3112
3132
  git_vector_set_cmp(&entries, index->entries._cmp); /* match sort */
@@ -3124,15 +3144,11 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3124
3144
  if ((error = git_tree_walk(tree, GIT_TREEWALK_POST, read_tree_cb, &data)) < 0)
3125
3145
  goto cleanup;
3126
3146
 
3127
- if (index->ignore_case)
3128
- git_idxmap_icase_resize((git_idxmap_icase *) entries_map, entries.length);
3129
- else
3130
- git_idxmap_resize(entries_map, entries.length);
3147
+ if ((error = index_map_resize(entries_map, entries.length, index->ignore_case)) < 0)
3148
+ goto cleanup;
3131
3149
 
3132
3150
  git_vector_foreach(&entries, i, e) {
3133
- INSERT_IN_MAP_EX(index, entries_map, e, &error);
3134
-
3135
- if (error < 0) {
3151
+ if ((error = index_map_set(entries_map, e, index->ignore_case)) < 0) {
3136
3152
  git_error_set(GIT_ERROR_INDEX, "failed to insert entry into map");
3137
3153
  return error;
3138
3154
  }
@@ -3180,14 +3196,13 @@ static int git_index_read_iterator(
3180
3196
  assert((new_iterator->flags & GIT_ITERATOR_DONT_IGNORE_CASE));
3181
3197
 
3182
3198
  if ((error = git_vector_init(&new_entries, new_length_hint, index->entries._cmp)) < 0 ||
3183
- (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0 ||
3184
- (error = git_idxmap_alloc(&new_entries_map)) < 0)
3199
+ (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0 ||
3200
+ (error = git_idxmap_new(&new_entries_map)) < 0)
3185
3201
  goto done;
3186
3202
 
3187
- if (index->ignore_case && new_length_hint)
3188
- git_idxmap_icase_resize((git_idxmap_icase *) new_entries_map, new_length_hint);
3189
- else if (new_length_hint)
3190
- git_idxmap_resize(new_entries_map, new_length_hint);
3203
+ if (new_length_hint && (error = index_map_resize(new_entries_map, new_length_hint,
3204
+ index->ignore_case)) < 0)
3205
+ goto done;
3191
3206
 
3192
3207
  opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE |
3193
3208
  GIT_ITERATOR_INCLUDE_CONFLICTS;
@@ -3251,7 +3266,8 @@ static int git_index_read_iterator(
3251
3266
 
3252
3267
  if (add_entry) {
3253
3268
  if ((error = git_vector_insert(&new_entries, add_entry)) == 0)
3254
- INSERT_IN_MAP_EX(index, new_entries_map, add_entry, &error);
3269
+ error = index_map_set(new_entries_map, add_entry,
3270
+ index->ignore_case);
3255
3271
  }
3256
3272
 
3257
3273
  if (remove_entry && error >= 0)
@@ -3275,8 +3291,9 @@ static int git_index_read_iterator(
3275
3291
  }
3276
3292
  }
3277
3293
 
3278
- git_index_name_clear(index);
3279
- git_index_reuc_clear(index);
3294
+ if ((error = git_index_name_clear(index)) < 0 ||
3295
+ (error = git_index_reuc_clear(index)) < 0)
3296
+ goto done;
3280
3297
 
3281
3298
  git_vector_swap(&new_entries, &index->entries);
3282
3299
  new_entries_map = git__swap(index->entries_map, new_entries_map);
@@ -3700,3 +3717,14 @@ void git_indexwriter_cleanup(git_indexwriter *writer)
3700
3717
  git_index_free(writer->index);
3701
3718
  writer->index = NULL;
3702
3719
  }
3720
+
3721
+ /* Deprecated functions */
3722
+
3723
+ #ifndef GIT_DEPRECATE_HARD
3724
+ int git_index_add_frombuffer(
3725
+ git_index *index, const git_index_entry *source_entry,
3726
+ const void *buffer, size_t len)
3727
+ {
3728
+ return git_index_add_from_buffer(index, source_entry, buffer, len);
3729
+ }
3730
+ #endif