rugged 0.27.10 → 0.27.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (420) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/AUTHORS +0 -1
  4. data/vendor/libgit2/CMakeLists.txt +54 -98
  5. data/vendor/libgit2/COPYING +0 -28
  6. data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +1 -15
  7. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +8 -9
  8. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
  9. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
  10. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
  11. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +0 -6
  12. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -2
  13. data/vendor/libgit2/deps/http-parser/{COPYING → LICENSE-MIT} +0 -0
  14. data/vendor/libgit2/deps/http-parser/http_parser.c +6 -11
  15. data/vendor/libgit2/deps/regex/CMakeLists.txt +2 -0
  16. data/vendor/libgit2/deps/regex/config.h +7 -0
  17. data/vendor/libgit2/deps/regex/regcomp.c +3857 -0
  18. data/vendor/libgit2/deps/regex/regex.c +92 -0
  19. data/vendor/libgit2/deps/regex/regex.h +582 -0
  20. data/vendor/libgit2/deps/regex/regex_internal.c +1744 -0
  21. data/vendor/libgit2/deps/regex/regex_internal.h +819 -0
  22. data/vendor/libgit2/deps/regex/regexec.c +4369 -0
  23. data/vendor/libgit2/deps/zlib/CMakeLists.txt +0 -1
  24. data/vendor/libgit2/deps/zlib/adler32.c +7 -0
  25. data/vendor/libgit2/deps/zlib/crc32.c +7 -0
  26. data/vendor/libgit2/include/git2.h +0 -5
  27. data/vendor/libgit2/include/git2/annotated_commit.h +0 -9
  28. data/vendor/libgit2/include/git2/attr.h +20 -38
  29. data/vendor/libgit2/include/git2/blame.h +25 -42
  30. data/vendor/libgit2/include/git2/blob.h +13 -45
  31. data/vendor/libgit2/include/git2/branch.h +1 -1
  32. data/vendor/libgit2/include/git2/buffer.h +16 -22
  33. data/vendor/libgit2/include/git2/checkout.h +32 -65
  34. data/vendor/libgit2/include/git2/cherrypick.h +7 -9
  35. data/vendor/libgit2/include/git2/clone.h +10 -12
  36. data/vendor/libgit2/include/git2/commit.h +3 -53
  37. data/vendor/libgit2/include/git2/common.h +8 -60
  38. data/vendor/libgit2/include/git2/config.h +19 -30
  39. data/vendor/libgit2/include/git2/describe.h +9 -32
  40. data/vendor/libgit2/include/git2/diff.h +156 -208
  41. data/vendor/libgit2/include/git2/errors.h +46 -54
  42. data/vendor/libgit2/include/git2/filter.h +0 -8
  43. data/vendor/libgit2/include/git2/ignore.h +2 -2
  44. data/vendor/libgit2/include/git2/index.h +52 -74
  45. data/vendor/libgit2/include/git2/indexer.h +6 -76
  46. data/vendor/libgit2/include/git2/inttypes.h +309 -0
  47. data/vendor/libgit2/include/git2/merge.h +18 -35
  48. data/vendor/libgit2/include/git2/net.h +5 -0
  49. data/vendor/libgit2/include/git2/notes.h +1 -1
  50. data/vendor/libgit2/include/git2/object.h +29 -17
  51. data/vendor/libgit2/include/git2/odb.h +11 -12
  52. data/vendor/libgit2/include/git2/odb_backend.h +9 -10
  53. data/vendor/libgit2/include/git2/oid.h +2 -2
  54. data/vendor/libgit2/include/git2/pack.h +3 -14
  55. data/vendor/libgit2/include/git2/proxy.h +8 -14
  56. data/vendor/libgit2/include/git2/rebase.h +6 -53
  57. data/vendor/libgit2/include/git2/refs.h +15 -33
  58. data/vendor/libgit2/include/git2/refspec.h +0 -17
  59. data/vendor/libgit2/include/git2/remote.h +24 -123
  60. data/vendor/libgit2/include/git2/repository.h +39 -76
  61. data/vendor/libgit2/include/git2/revert.h +4 -6
  62. data/vendor/libgit2/include/git2/revwalk.h +7 -7
  63. data/vendor/libgit2/include/git2/signature.h +2 -2
  64. data/vendor/libgit2/include/git2/stash.h +12 -15
  65. data/vendor/libgit2/include/git2/status.h +20 -33
  66. data/vendor/libgit2/include/git2/submodule.h +12 -30
  67. data/vendor/libgit2/include/git2/sys/commit.h +1 -1
  68. data/vendor/libgit2/include/git2/sys/config.h +13 -13
  69. data/vendor/libgit2/include/git2/sys/filter.h +6 -6
  70. data/vendor/libgit2/include/git2/sys/index.h +0 -3
  71. data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
  72. data/vendor/libgit2/include/git2/sys/merge.h +4 -9
  73. data/vendor/libgit2/include/git2/sys/odb_backend.h +22 -66
  74. data/vendor/libgit2/include/git2/sys/refdb_backend.h +40 -76
  75. data/vendor/libgit2/include/git2/sys/repository.h +1 -5
  76. data/vendor/libgit2/include/git2/sys/stream.h +12 -92
  77. data/vendor/libgit2/include/git2/sys/time.h +31 -0
  78. data/vendor/libgit2/include/git2/sys/transport.h +83 -129
  79. data/vendor/libgit2/include/git2/tag.h +4 -13
  80. data/vendor/libgit2/include/git2/trace.h +2 -2
  81. data/vendor/libgit2/include/git2/transaction.h +0 -1
  82. data/vendor/libgit2/include/git2/transport.h +311 -11
  83. data/vendor/libgit2/include/git2/tree.h +4 -4
  84. data/vendor/libgit2/include/git2/types.h +111 -33
  85. data/vendor/libgit2/include/git2/version.h +4 -4
  86. data/vendor/libgit2/include/git2/worktree.h +13 -48
  87. data/vendor/libgit2/libgit2.pc.in +13 -0
  88. data/vendor/libgit2/src/CMakeLists.txt +164 -96
  89. data/vendor/libgit2/src/annotated_commit.c +8 -15
  90. data/vendor/libgit2/src/apply.c +31 -537
  91. data/vendor/libgit2/src/apply.h +1 -3
  92. data/vendor/libgit2/src/array.h +2 -2
  93. data/vendor/libgit2/src/attr.c +75 -81
  94. data/vendor/libgit2/src/attr_file.c +121 -207
  95. data/vendor/libgit2/src/attr_file.h +9 -9
  96. data/vendor/libgit2/src/attrcache.c +53 -51
  97. data/vendor/libgit2/src/attrcache.h +1 -2
  98. data/vendor/libgit2/src/blame.c +20 -47
  99. data/vendor/libgit2/src/blame.h +1 -2
  100. data/vendor/libgit2/src/blame_git.c +20 -37
  101. data/vendor/libgit2/src/blob.c +42 -128
  102. data/vendor/libgit2/src/blob.h +2 -19
  103. data/vendor/libgit2/src/branch.c +43 -67
  104. data/vendor/libgit2/src/buf_text.c +6 -7
  105. data/vendor/libgit2/src/buffer.c +57 -69
  106. data/vendor/libgit2/src/buffer.h +1 -1
  107. data/vendor/libgit2/src/cache.c +45 -38
  108. data/vendor/libgit2/src/cache.h +3 -3
  109. data/vendor/libgit2/src/cc-compat.h +3 -20
  110. data/vendor/libgit2/src/checkout.c +90 -109
  111. data/vendor/libgit2/src/cherrypick.c +9 -15
  112. data/vendor/libgit2/src/clone.c +27 -49
  113. data/vendor/libgit2/src/clone.h +0 -4
  114. data/vendor/libgit2/src/commit.c +49 -117
  115. data/vendor/libgit2/src/commit.h +0 -7
  116. data/vendor/libgit2/src/commit_list.c +78 -30
  117. data/vendor/libgit2/src/commit_list.h +2 -2
  118. data/vendor/libgit2/src/common.h +91 -27
  119. data/vendor/libgit2/src/config.c +176 -194
  120. data/vendor/libgit2/src/config.h +20 -8
  121. data/vendor/libgit2/src/config_cache.c +35 -41
  122. data/vendor/libgit2/src/config_file.c +753 -439
  123. data/vendor/libgit2/src/config_file.h +73 -0
  124. data/vendor/libgit2/src/config_parse.c +63 -114
  125. data/vendor/libgit2/src/config_parse.h +16 -17
  126. data/vendor/libgit2/src/crlf.c +190 -219
  127. data/vendor/libgit2/src/delta.c +18 -25
  128. data/vendor/libgit2/src/describe.c +41 -42
  129. data/vendor/libgit2/src/diff.c +68 -53
  130. data/vendor/libgit2/src/diff.h +1 -2
  131. data/vendor/libgit2/src/diff_driver.c +49 -47
  132. data/vendor/libgit2/src/diff_file.c +17 -19
  133. data/vendor/libgit2/src/diff_file.h +1 -1
  134. data/vendor/libgit2/src/diff_generate.c +106 -162
  135. data/vendor/libgit2/src/diff_generate.h +3 -3
  136. data/vendor/libgit2/src/diff_parse.c +4 -4
  137. data/vendor/libgit2/src/diff_print.c +30 -42
  138. data/vendor/libgit2/src/diff_stats.c +7 -22
  139. data/vendor/libgit2/src/diff_tform.c +16 -16
  140. data/vendor/libgit2/src/diff_xdiff.c +3 -15
  141. data/vendor/libgit2/src/errors.c +39 -51
  142. data/vendor/libgit2/src/features.h.in +3 -11
  143. data/vendor/libgit2/src/fetch.c +5 -10
  144. data/vendor/libgit2/src/fetchhead.c +17 -17
  145. data/vendor/libgit2/src/filebuf.c +36 -32
  146. data/vendor/libgit2/src/filebuf.h +2 -2
  147. data/vendor/libgit2/src/{futils.c → fileops.c} +73 -80
  148. data/vendor/libgit2/src/{futils.h → fileops.h} +6 -6
  149. data/vendor/libgit2/src/filter.c +38 -46
  150. data/vendor/libgit2/src/filter.h +10 -0
  151. data/vendor/libgit2/src/fnmatch.c +248 -0
  152. data/vendor/libgit2/src/fnmatch.h +48 -0
  153. data/vendor/libgit2/src/global.c +63 -48
  154. data/vendor/libgit2/src/global.h +2 -0
  155. data/vendor/libgit2/src/hash.c +0 -61
  156. data/vendor/libgit2/src/hash.h +19 -20
  157. data/vendor/libgit2/src/hash/hash_collisiondetect.h +47 -0
  158. data/vendor/libgit2/src/hash/{sha1/common_crypto.c → hash_common_crypto.h} +17 -17
  159. data/vendor/libgit2/src/hash/{sha1/generic.c → hash_generic.c} +10 -22
  160. data/vendor/libgit2/src/hash/{sha1/generic.h → hash_generic.h} +10 -4
  161. data/vendor/libgit2/src/hash/hash_openssl.h +59 -0
  162. data/vendor/libgit2/src/hash/{sha1/win32.c → hash_win32.c} +37 -47
  163. data/vendor/libgit2/src/hash/{sha1/win32.h → hash_win32.h} +19 -6
  164. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/sha1.c +3 -14
  165. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/sha1.h +0 -0
  166. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/ubc_check.c +0 -0
  167. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/ubc_check.h +0 -0
  168. data/vendor/libgit2/src/hashsig.c +5 -5
  169. data/vendor/libgit2/src/idxmap.c +61 -107
  170. data/vendor/libgit2/src/idxmap.h +31 -153
  171. data/vendor/libgit2/src/ignore.c +47 -43
  172. data/vendor/libgit2/src/index.c +232 -337
  173. data/vendor/libgit2/src/index.h +1 -17
  174. data/vendor/libgit2/src/indexer.c +175 -346
  175. data/vendor/libgit2/src/integer.h +26 -71
  176. data/vendor/libgit2/src/iterator.c +70 -142
  177. data/vendor/libgit2/src/iterator.h +0 -15
  178. data/vendor/libgit2/src/khash.h +1 -3
  179. data/vendor/libgit2/src/map.h +1 -1
  180. data/vendor/libgit2/src/merge.c +100 -144
  181. data/vendor/libgit2/src/merge_driver.c +11 -11
  182. data/vendor/libgit2/src/merge_file.c +2 -2
  183. data/vendor/libgit2/src/mwindow.c +29 -24
  184. data/vendor/libgit2/src/mwindow.h +4 -4
  185. data/vendor/libgit2/src/netops.c +156 -55
  186. data/vendor/libgit2/src/netops.h +23 -3
  187. data/vendor/libgit2/src/notes.c +11 -16
  188. data/vendor/libgit2/src/object.c +69 -120
  189. data/vendor/libgit2/src/object.h +9 -22
  190. data/vendor/libgit2/src/object_api.c +8 -8
  191. data/vendor/libgit2/src/odb.c +93 -116
  192. data/vendor/libgit2/src/odb.h +7 -8
  193. data/vendor/libgit2/src/odb_loose.c +55 -62
  194. data/vendor/libgit2/src/odb_mempack.c +34 -21
  195. data/vendor/libgit2/src/odb_pack.c +14 -18
  196. data/vendor/libgit2/src/offmap.c +35 -53
  197. data/vendor/libgit2/src/offmap.h +21 -108
  198. data/vendor/libgit2/src/oid.c +7 -12
  199. data/vendor/libgit2/src/oidmap.c +47 -49
  200. data/vendor/libgit2/src/oidmap.h +24 -101
  201. data/vendor/libgit2/src/pack-objects.c +87 -88
  202. data/vendor/libgit2/src/pack-objects.h +8 -2
  203. data/vendor/libgit2/src/pack.c +101 -99
  204. data/vendor/libgit2/src/pack.h +19 -17
  205. data/vendor/libgit2/src/parse.c +0 -10
  206. data/vendor/libgit2/src/parse.h +3 -3
  207. data/vendor/libgit2/src/patch.c +4 -4
  208. data/vendor/libgit2/src/patch_generate.c +20 -20
  209. data/vendor/libgit2/src/patch_parse.c +63 -151
  210. data/vendor/libgit2/src/path.c +104 -117
  211. data/vendor/libgit2/src/path.h +71 -3
  212. data/vendor/libgit2/src/pathspec.c +19 -19
  213. data/vendor/libgit2/src/pool.c +22 -26
  214. data/vendor/libgit2/src/pool.h +7 -7
  215. data/vendor/libgit2/src/posix.c +10 -10
  216. data/vendor/libgit2/src/posix.h +1 -12
  217. data/vendor/libgit2/src/proxy.c +3 -8
  218. data/vendor/libgit2/src/push.c +31 -37
  219. data/vendor/libgit2/src/push.h +1 -2
  220. data/vendor/libgit2/src/rebase.c +59 -115
  221. data/vendor/libgit2/src/refdb.c +3 -15
  222. data/vendor/libgit2/src/refdb_fs.c +254 -381
  223. data/vendor/libgit2/src/reflog.c +15 -13
  224. data/vendor/libgit2/src/refs.c +88 -118
  225. data/vendor/libgit2/src/refs.h +3 -5
  226. data/vendor/libgit2/src/refspec.c +37 -56
  227. data/vendor/libgit2/src/refspec.h +1 -1
  228. data/vendor/libgit2/src/remote.c +215 -266
  229. data/vendor/libgit2/src/remote.h +2 -11
  230. data/vendor/libgit2/src/repository.c +225 -280
  231. data/vendor/libgit2/src/repository.h +40 -52
  232. data/vendor/libgit2/src/reset.c +8 -8
  233. data/vendor/libgit2/src/revert.c +9 -14
  234. data/vendor/libgit2/src/revparse.c +48 -47
  235. data/vendor/libgit2/src/revwalk.c +57 -120
  236. data/vendor/libgit2/src/revwalk.h +1 -22
  237. data/vendor/libgit2/src/settings.c +10 -47
  238. data/vendor/libgit2/src/signature.c +11 -11
  239. data/vendor/libgit2/src/sortedcache.c +36 -22
  240. data/vendor/libgit2/src/sortedcache.h +1 -1
  241. data/vendor/libgit2/src/stash.c +99 -125
  242. data/vendor/libgit2/src/status.c +22 -28
  243. data/vendor/libgit2/src/stream.h +2 -17
  244. data/vendor/libgit2/src/streams/curl.c +385 -0
  245. data/vendor/libgit2/src/{allocators/stdalloc.h → streams/curl.h} +5 -5
  246. data/vendor/libgit2/src/streams/openssl.c +114 -224
  247. data/vendor/libgit2/src/streams/openssl.h +108 -4
  248. data/vendor/libgit2/src/streams/socket.c +30 -55
  249. data/vendor/libgit2/src/streams/stransport.c +32 -57
  250. data/vendor/libgit2/src/streams/stransport.h +0 -5
  251. data/vendor/libgit2/src/streams/tls.c +19 -50
  252. data/vendor/libgit2/src/streams/tls.h +4 -12
  253. data/vendor/libgit2/src/strmap.c +74 -47
  254. data/vendor/libgit2/src/strmap.h +33 -108
  255. data/vendor/libgit2/src/submodule.c +216 -272
  256. data/vendor/libgit2/src/submodule.h +1 -1
  257. data/vendor/libgit2/src/sysdir.c +19 -29
  258. data/vendor/libgit2/src/tag.c +28 -41
  259. data/vendor/libgit2/src/tag.h +1 -2
  260. data/vendor/libgit2/src/trace.c +2 -2
  261. data/vendor/libgit2/src/trace.h +3 -3
  262. data/vendor/libgit2/src/trailer.c +38 -52
  263. data/vendor/libgit2/src/transaction.c +29 -30
  264. data/vendor/libgit2/src/transport.c +5 -5
  265. data/vendor/libgit2/src/transports/auth.c +11 -15
  266. data/vendor/libgit2/src/transports/auth.h +3 -10
  267. data/vendor/libgit2/src/transports/auth_negotiate.c +18 -33
  268. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  269. data/vendor/libgit2/src/transports/cred.c +24 -24
  270. data/vendor/libgit2/src/{allocators/win32_crtdbg.h → transports/cred.h} +4 -5
  271. data/vendor/libgit2/src/transports/git.c +31 -26
  272. data/vendor/libgit2/src/transports/http.c +348 -881
  273. data/vendor/libgit2/src/transports/http.h +0 -2
  274. data/vendor/libgit2/src/transports/local.c +35 -35
  275. data/vendor/libgit2/src/transports/smart.c +47 -70
  276. data/vendor/libgit2/src/transports/smart.h +4 -3
  277. data/vendor/libgit2/src/transports/smart_pkt.c +40 -43
  278. data/vendor/libgit2/src/transports/smart_protocol.c +116 -96
  279. data/vendor/libgit2/src/transports/ssh.c +66 -77
  280. data/vendor/libgit2/src/transports/winhttp.c +314 -318
  281. data/vendor/libgit2/src/tree-cache.c +12 -19
  282. data/vendor/libgit2/src/tree.c +142 -103
  283. data/vendor/libgit2/src/tree.h +12 -1
  284. data/vendor/libgit2/src/unix/map.c +3 -3
  285. data/vendor/libgit2/src/unix/posix.h +11 -1
  286. data/vendor/libgit2/src/userdiff.h +1 -3
  287. data/vendor/libgit2/src/util.c +56 -70
  288. data/vendor/libgit2/src/util.h +156 -28
  289. data/vendor/libgit2/src/vector.c +4 -4
  290. data/vendor/libgit2/src/win32/dir.c +3 -3
  291. data/vendor/libgit2/src/win32/findfile.c +3 -3
  292. data/vendor/libgit2/src/win32/map.c +11 -9
  293. data/vendor/libgit2/src/win32/msvc-compat.h +0 -6
  294. data/vendor/libgit2/src/win32/path_w32.c +9 -113
  295. data/vendor/libgit2/src/win32/path_w32.h +29 -18
  296. data/vendor/libgit2/src/win32/posix.h +4 -1
  297. data/vendor/libgit2/src/win32/posix_w32.c +45 -70
  298. data/vendor/libgit2/src/win32/precompiled.h +2 -0
  299. data/vendor/libgit2/src/win32/thread.c +10 -5
  300. data/vendor/libgit2/src/win32/w32_buffer.c +5 -9
  301. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +2 -3
  302. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +75 -26
  303. data/vendor/libgit2/src/win32/w32_stack.c +11 -6
  304. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  305. data/vendor/libgit2/src/win32/w32_util.c +64 -27
  306. data/vendor/libgit2/src/win32/w32_util.h +49 -5
  307. data/vendor/libgit2/src/worktree.c +60 -95
  308. data/vendor/libgit2/src/worktree.h +0 -2
  309. data/vendor/libgit2/src/xdiff/xdiffi.c +5 -7
  310. data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
  311. data/vendor/libgit2/src/xdiff/xmerge.c +15 -27
  312. data/vendor/libgit2/src/xdiff/xpatience.c +0 -3
  313. data/vendor/libgit2/src/zstream.c +4 -4
  314. metadata +33 -122
  315. data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +0 -28
  316. data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +0 -38
  317. data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +0 -37
  318. data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +0 -93
  319. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +0 -110
  320. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +0 -53
  321. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +0 -124
  322. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +0 -66
  323. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +0 -21
  324. data/vendor/libgit2/deps/ntlmclient/compat.h +0 -33
  325. data/vendor/libgit2/deps/ntlmclient/crypt.h +0 -64
  326. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +0 -120
  327. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +0 -18
  328. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +0 -145
  329. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +0 -18
  330. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +0 -130
  331. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +0 -21
  332. data/vendor/libgit2/deps/ntlmclient/ntlm.c +0 -1420
  333. data/vendor/libgit2/deps/ntlmclient/ntlm.h +0 -174
  334. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +0 -320
  335. data/vendor/libgit2/deps/ntlmclient/unicode.h +0 -36
  336. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +0 -445
  337. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +0 -201
  338. data/vendor/libgit2/deps/ntlmclient/utf8.h +0 -1257
  339. data/vendor/libgit2/deps/ntlmclient/util.c +0 -21
  340. data/vendor/libgit2/deps/ntlmclient/util.h +0 -14
  341. data/vendor/libgit2/deps/pcre/CMakeLists.txt +0 -140
  342. data/vendor/libgit2/deps/pcre/COPYING +0 -5
  343. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +0 -22
  344. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +0 -17
  345. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +0 -58
  346. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +0 -29
  347. data/vendor/libgit2/deps/pcre/config.h.in +0 -57
  348. data/vendor/libgit2/deps/pcre/pcre.h +0 -641
  349. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +0 -319
  350. data/vendor/libgit2/deps/pcre/pcre_chartables.c +0 -198
  351. data/vendor/libgit2/deps/pcre/pcre_compile.c +0 -9800
  352. data/vendor/libgit2/deps/pcre/pcre_config.c +0 -190
  353. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +0 -3676
  354. data/vendor/libgit2/deps/pcre/pcre_exec.c +0 -7173
  355. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +0 -245
  356. data/vendor/libgit2/deps/pcre/pcre_get.c +0 -669
  357. data/vendor/libgit2/deps/pcre/pcre_globals.c +0 -86
  358. data/vendor/libgit2/deps/pcre/pcre_internal.h +0 -2787
  359. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +0 -11913
  360. data/vendor/libgit2/deps/pcre/pcre_maketables.c +0 -156
  361. data/vendor/libgit2/deps/pcre/pcre_newline.c +0 -210
  362. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +0 -94
  363. data/vendor/libgit2/deps/pcre/pcre_printint.c +0 -834
  364. data/vendor/libgit2/deps/pcre/pcre_refcount.c +0 -92
  365. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +0 -211
  366. data/vendor/libgit2/deps/pcre/pcre_study.c +0 -1686
  367. data/vendor/libgit2/deps/pcre/pcre_tables.c +0 -727
  368. data/vendor/libgit2/deps/pcre/pcre_ucd.c +0 -3644
  369. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +0 -301
  370. data/vendor/libgit2/deps/pcre/pcre_version.c +0 -98
  371. data/vendor/libgit2/deps/pcre/pcre_xclass.c +0 -268
  372. data/vendor/libgit2/deps/pcre/pcreposix.c +0 -421
  373. data/vendor/libgit2/deps/pcre/pcreposix.h +0 -117
  374. data/vendor/libgit2/deps/pcre/ucp.h +0 -224
  375. data/vendor/libgit2/deps/winhttp/COPYING.GPL +0 -993
  376. data/vendor/libgit2/deps/winhttp/COPYING.LGPL +0 -502
  377. data/vendor/libgit2/deps/zlib/COPYING +0 -27
  378. data/vendor/libgit2/include/git2/apply.h +0 -149
  379. data/vendor/libgit2/include/git2/cert.h +0 -135
  380. data/vendor/libgit2/include/git2/cred.h +0 -308
  381. data/vendor/libgit2/include/git2/deprecated.h +0 -493
  382. data/vendor/libgit2/include/git2/mailmap.h +0 -115
  383. data/vendor/libgit2/include/git2/sys/alloc.h +0 -101
  384. data/vendor/libgit2/include/git2/sys/cred.h +0 -90
  385. data/vendor/libgit2/include/git2/sys/path.h +0 -64
  386. data/vendor/libgit2/src/alloc.c +0 -43
  387. data/vendor/libgit2/src/alloc.h +0 -40
  388. data/vendor/libgit2/src/allocators/stdalloc.c +0 -119
  389. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  390. data/vendor/libgit2/src/config_backend.h +0 -96
  391. data/vendor/libgit2/src/config_entries.c +0 -229
  392. data/vendor/libgit2/src/config_entries.h +0 -24
  393. data/vendor/libgit2/src/config_mem.c +0 -220
  394. data/vendor/libgit2/src/config_snapshot.c +0 -206
  395. data/vendor/libgit2/src/errors.h +0 -81
  396. data/vendor/libgit2/src/hash/sha1.h +0 -38
  397. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +0 -48
  398. data/vendor/libgit2/src/hash/sha1/collisiondetect.h +0 -19
  399. data/vendor/libgit2/src/hash/sha1/common_crypto.h +0 -19
  400. data/vendor/libgit2/src/hash/sha1/mbedtls.c +0 -46
  401. data/vendor/libgit2/src/hash/sha1/mbedtls.h +0 -19
  402. data/vendor/libgit2/src/hash/sha1/openssl.c +0 -59
  403. data/vendor/libgit2/src/hash/sha1/openssl.h +0 -19
  404. data/vendor/libgit2/src/mailmap.c +0 -485
  405. data/vendor/libgit2/src/mailmap.h +0 -35
  406. data/vendor/libgit2/src/net.c +0 -184
  407. data/vendor/libgit2/src/net.h +0 -36
  408. data/vendor/libgit2/src/reader.c +0 -265
  409. data/vendor/libgit2/src/reader.h +0 -107
  410. data/vendor/libgit2/src/regexp.c +0 -221
  411. data/vendor/libgit2/src/regexp.h +0 -97
  412. data/vendor/libgit2/src/streams/mbedtls.c +0 -483
  413. data/vendor/libgit2/src/streams/mbedtls.h +0 -23
  414. data/vendor/libgit2/src/streams/registry.c +0 -118
  415. data/vendor/libgit2/src/streams/registry.h +0 -19
  416. data/vendor/libgit2/src/transports/auth_ntlm.c +0 -223
  417. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -35
  418. data/vendor/libgit2/src/wildmatch.c +0 -320
  419. data/vendor/libgit2/src/wildmatch.h +0 -23
  420. data/vendor/libgit2/src/win32/w32_common.h +0 -39
@@ -12,7 +12,7 @@
12
12
  #include "attrcache.h"
13
13
  #include "path.h"
14
14
  #include "config.h"
15
- #include "wildmatch.h"
15
+ #include "fnmatch.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, wildmatch_flags;
104
+ int error = 0, fnflags;
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
- wildmatch_flags = WM_PATHNAME;
112
+ fnflags = FNM_PATHNAME;
113
113
  if (match->flags & GIT_ATTR_FNMATCH_ICASE)
114
- wildmatch_flags |= WM_CASEFOLD;
114
+ fnflags |= FNM_IGNORECASE;
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,8 +141,13 @@ 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
+ giterr_set(GITERR_INVALID, "error matching pattern");
146
+ goto out;
147
+ }
148
+
144
149
  /* if we found a match, we want to keep this rule */
145
- if ((wildmatch(git_buf_cstr(&buf), path, wildmatch_flags)) == WM_MATCH) {
150
+ if (error != FNM_NOMATCH) {
146
151
  *out = 1;
147
152
  error = 0;
148
153
  goto out;
@@ -153,22 +158,20 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
153
158
 
154
159
  out:
155
160
  git__free(path);
156
- git_buf_dispose(&buf);
161
+ git_buf_free(&buf);
157
162
  return error;
158
163
  }
159
164
 
160
165
  static int parse_ignore_file(
161
- git_repository *repo, git_attr_file *attrs, const char *data, bool allow_macros)
166
+ git_repository *repo, git_attr_file *attrs, const char *data)
162
167
  {
163
168
  int error = 0;
164
169
  int ignore_case = false;
165
170
  const char *scan = data, *context = NULL;
166
171
  git_attr_fnmatch *match = NULL;
167
172
 
168
- GIT_UNUSED(allow_macros);
169
-
170
- if (git_repository__configmap_lookup(&ignore_case, repo, GIT_CONFIGMAP_IGNORECASE) < 0)
171
- git_error_clear();
173
+ if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0)
174
+ giterr_clear();
172
175
 
173
176
  /* if subdir file path, convert context for file paths */
174
177
  if (attrs->entry &&
@@ -177,7 +180,7 @@ static int parse_ignore_file(
177
180
  context = attrs->entry->path;
178
181
 
179
182
  if (git_mutex_lock(&attrs->lock) < 0) {
180
- git_error_set(GIT_ERROR_OS, "failed to lock ignore file");
183
+ giterr_set(GITERR_OS, "failed to lock ignore file");
181
184
  return -1;
182
185
  }
183
186
 
@@ -190,7 +193,9 @@ static int parse_ignore_file(
190
193
  }
191
194
 
192
195
  match->flags =
193
- GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG;
196
+ GIT_ATTR_FNMATCH_ALLOWSPACE |
197
+ GIT_ATTR_FNMATCH_ALLOWNEG |
198
+ GIT_ATTR_FNMATCH_NOLEADINGDIR;
194
199
 
195
200
  if (!(error = git_attr_fnmatch__parse(
196
201
  match, &attrs->pool, context, &scan)))
@@ -241,8 +246,9 @@ static int push_ignore_file(
241
246
  int error = 0;
242
247
  git_attr_file *file = NULL;
243
248
 
244
- error = git_attr_cache__get(&file, ignores->repo, NULL, GIT_ATTR_FILE__FROM_FILE,
245
- base, filename, parse_ignore_file, false);
249
+ error = git_attr_cache__get(
250
+ &file, ignores->repo, NULL, GIT_ATTR_FILE__FROM_FILE,
251
+ base, filename, parse_ignore_file);
246
252
  if (error < 0)
247
253
  return error;
248
254
 
@@ -268,12 +274,12 @@ static int get_internal_ignores(git_attr_file **out, git_repository *repo)
268
274
  if ((error = git_attr_cache__init(repo)) < 0)
269
275
  return error;
270
276
 
271
- error = git_attr_cache__get(out, repo, NULL, GIT_ATTR_FILE__IN_MEMORY, NULL,
272
- GIT_IGNORE_INTERNAL, NULL, false);
277
+ error = git_attr_cache__get(
278
+ out, repo, NULL, GIT_ATTR_FILE__IN_MEMORY, NULL, GIT_IGNORE_INTERNAL, NULL);
273
279
 
274
280
  /* if internal rules list is empty, insert default rules */
275
281
  if (!error && !(*out)->rules.length)
276
- error = parse_ignore_file(repo, *out, GIT_IGNORE_DEFAULT_RULES, false);
282
+ error = parse_ignore_file(repo, *out, GIT_IGNORE_DEFAULT_RULES);
277
283
 
278
284
  return error;
279
285
  }
@@ -293,8 +299,8 @@ int git_ignore__for_path(
293
299
  ignores->repo = repo;
294
300
 
295
301
  /* Read the ignore_case flag */
296
- if ((error = git_repository__configmap_lookup(
297
- &ignores->ignore_case, repo, GIT_CONFIGMAP_IGNORECASE)) < 0)
302
+ if ((error = git_repository__cvar(
303
+ &ignores->ignore_case, repo, GIT_CVAR_IGNORECASE)) < 0)
298
304
  goto cleanup;
299
305
 
300
306
  if ((error = git_attr_cache__init(repo)) < 0)
@@ -309,7 +315,7 @@ int git_ignore__for_path(
309
315
  (error = git_path_to_dir(&local)) < 0 ||
310
316
  (error = git_buf_joinpath(&ignores->dir, workdir, local.ptr)) < 0)
311
317
  {;} /* Nothing, we just want to stop on the first error */
312
- git_buf_dispose(&local);
318
+ git_buf_free(&local);
313
319
  } else {
314
320
  error = git_buf_joinpath(&ignores->dir, path, "");
315
321
  }
@@ -331,13 +337,16 @@ int git_ignore__for_path(
331
337
  goto cleanup;
332
338
  }
333
339
 
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
- }
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;
341
350
 
342
351
  /* load core.excludesfile */
343
352
  if (git_repository_attr_cache(repo)->cfg_excl_file != NULL)
@@ -346,7 +355,7 @@ int git_ignore__for_path(
346
355
  git_repository_attr_cache(repo)->cfg_excl_file);
347
356
 
348
357
  cleanup:
349
- git_buf_dispose(&infopath);
358
+ git_buf_free(&infopath);
350
359
  if (error < 0)
351
360
  git_ignore__free(ignores);
352
361
 
@@ -418,7 +427,7 @@ void git_ignore__free(git_ignores *ignores)
418
427
  }
419
428
  git_vector_free(&ignores->ign_global);
420
429
 
421
- git_buf_dispose(&ignores->dir);
430
+ git_buf_free(&ignores->dir);
422
431
  }
423
432
 
424
433
  static bool ignore_lookup_in_rules(
@@ -444,7 +453,7 @@ static bool ignore_lookup_in_rules(
444
453
  int git_ignore__lookup(
445
454
  int *out, git_ignores *ignores, const char *pathname, git_dir_flag dir_flag)
446
455
  {
447
- size_t i;
456
+ unsigned int i;
448
457
  git_attr_file *file;
449
458
  git_attr_path path;
450
459
 
@@ -458,11 +467,8 @@ int git_ignore__lookup(
458
467
  if (ignore_lookup_in_rules(out, ignores->ign_internal, &path))
459
468
  goto cleanup;
460
469
 
461
- /* next process files in the path.
462
- * this process has to process ignores in reverse order
463
- * to ensure correct prioritization of rules
464
- */
465
- git_vector_rforeach(&ignores->ign_path, i, file) {
470
+ /* next process files in the path */
471
+ git_vector_foreach(&ignores->ign_path, i, file) {
466
472
  if (ignore_lookup_in_rules(out, file, &path))
467
473
  goto cleanup;
468
474
  }
@@ -486,7 +492,7 @@ int git_ignore_add_rule(git_repository *repo, const char *rules)
486
492
  if ((error = get_internal_ignores(&ign_internal, repo)) < 0)
487
493
  return error;
488
494
 
489
- error = parse_ignore_file(repo, ign_internal, rules, false);
495
+ error = parse_ignore_file(repo, ign_internal, rules);
490
496
  git_attr_file__free(ign_internal);
491
497
 
492
498
  return error;
@@ -502,7 +508,7 @@ int git_ignore_clear_internal_rules(git_repository *repo)
502
508
 
503
509
  if (!(error = git_attr_file__clear_rules(ign_internal, true)))
504
510
  error = parse_ignore_file(
505
- repo, ign_internal, GIT_IGNORE_DEFAULT_RULES, false);
511
+ repo, ign_internal, GIT_IGNORE_DEFAULT_RULES);
506
512
 
507
513
  git_attr_file__free(ign_internal);
508
514
  return error;
@@ -528,9 +534,7 @@ int git_ignore_path_is_ignored(
528
534
  memset(&path, 0, sizeof(path));
529
535
  memset(&ignores, 0, sizeof(ignores));
530
536
 
531
- if (!git__suffixcmp(pathname, "/"))
532
- dir_flag = GIT_DIR_FLAG_TRUE;
533
- else if (git_repository_is_bare(repo))
537
+ if (git_repository_is_bare(repo))
534
538
  dir_flag = GIT_DIR_FLAG_FALSE;
535
539
 
536
540
  if ((error = git_attr_path__init(&path, pathname, workdir, dir_flag)) < 0 ||
@@ -620,7 +624,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
620
624
  break;
621
625
 
622
626
  if (ignored) {
623
- git_error_set(GIT_ERROR_INVALID, "pathspec contains ignored file '%s'",
627
+ giterr_set(GITERR_INVALID, "pathspec contains ignored file '%s'",
624
628
  filename);
625
629
  error = GIT_EINVALIDSPEC;
626
630
  break;
@@ -628,7 +632,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
628
632
  }
629
633
 
630
634
  git_index_free(idx);
631
- git_buf_dispose(&path);
635
+ git_buf_free(&path);
632
636
 
633
637
  return error;
634
638
  }
@@ -29,23 +29,23 @@
29
29
 
30
30
  #define INSERT_IN_MAP_EX(idx, map, e, err) do { \
31
31
  if ((idx)->ignore_case) \
32
- (err) = git_idxmap_icase_set((git_idxmap_icase *) (map), (e), (e)); \
32
+ git_idxmap_icase_insert((khash_t(idxicase) *) (map), (e), (e), (err)); \
33
33
  else \
34
- (err) = git_idxmap_set((map), (e), (e)); \
34
+ git_idxmap_insert((map), (e), (e), (err)); \
35
35
  } while (0)
36
36
 
37
37
  #define INSERT_IN_MAP(idx, e, err) INSERT_IN_MAP_EX(idx, (idx)->entries_map, e, err)
38
38
 
39
- #define LOOKUP_IN_MAP(v, idx, k) do { \
39
+ #define LOOKUP_IN_MAP(p, idx, k) do { \
40
40
  if ((idx)->ignore_case) \
41
- (v) = git_idxmap_icase_get((git_idxmap_icase *) index->entries_map, (k)); \
41
+ (p) = git_idxmap_icase_lookup_index((khash_t(idxicase) *) index->entries_map, (k)); \
42
42
  else \
43
- (v) = git_idxmap_get(index->entries_map, (k)); \
43
+ (p) = git_idxmap_lookup_index(index->entries_map, (k)); \
44
44
  } while (0)
45
45
 
46
46
  #define DELETE_IN_MAP(idx, e) do { \
47
47
  if ((idx)->ignore_case) \
48
- git_idxmap_icase_delete((git_idxmap_icase *) (idx)->entries_map, (e)); \
48
+ git_idxmap_icase_delete((khash_t(idxicase) *) (idx)->entries_map, (e)); \
49
49
  else \
50
50
  git_idxmap_delete((idx)->entries_map, (e)); \
51
51
  } while (0)
@@ -135,10 +135,8 @@ struct reuc_entry_internal {
135
135
  char path[GIT_FLEX_ARRAY];
136
136
  };
137
137
 
138
- bool git_index__enforce_unsaved_safety = false;
139
-
140
138
  /* local declarations */
141
- static int read_extension(size_t *read_len, git_index *index, const char *buffer, size_t buffer_size);
139
+ static size_t read_extension(git_index *index, const char *buffer, size_t buffer_size);
142
140
  static int read_header(struct index_header *dest, const void *buffer);
143
141
 
144
142
  static int parse_index(git_index *index, const char *buffer, size_t buffer_size);
@@ -168,7 +166,7 @@ int git_index_entry_srch(const void *key, const void *array_member)
168
166
  return 1;
169
167
 
170
168
  if (srch_key->stage != GIT_INDEX_STAGE_ANY)
171
- return srch_key->stage - GIT_INDEX_ENTRY_STAGE(&entry->entry);
169
+ return srch_key->stage - GIT_IDXENTRY_STAGE(&entry->entry);
172
170
 
173
171
  return 0;
174
172
  }
@@ -194,7 +192,7 @@ int git_index_entry_isrch(const void *key, const void *array_member)
194
192
  return 1;
195
193
 
196
194
  if (srch_key->stage != GIT_INDEX_STAGE_ANY)
197
- return srch_key->stage - GIT_INDEX_ENTRY_STAGE(&entry->entry);
195
+ return srch_key->stage - GIT_IDXENTRY_STAGE(&entry->entry);
198
196
 
199
197
  return 0;
200
198
  }
@@ -222,7 +220,7 @@ int git_index_entry_cmp(const void *a, const void *b)
222
220
  diff = strcmp(entry_a->path, entry_b->path);
223
221
 
224
222
  if (diff == 0)
225
- diff = (GIT_INDEX_ENTRY_STAGE(entry_a) - GIT_INDEX_ENTRY_STAGE(entry_b));
223
+ diff = (GIT_IDXENTRY_STAGE(entry_a) - GIT_IDXENTRY_STAGE(entry_b));
226
224
 
227
225
  return diff;
228
226
  }
@@ -236,7 +234,7 @@ int git_index_entry_icmp(const void *a, const void *b)
236
234
  diff = strcasecmp(entry_a->path, entry_b->path);
237
235
 
238
236
  if (diff == 0)
239
- diff = (GIT_INDEX_ENTRY_STAGE(entry_a) - GIT_INDEX_ENTRY_STAGE(entry_b));
237
+ diff = (GIT_IDXENTRY_STAGE(entry_a) - GIT_IDXENTRY_STAGE(entry_b));
240
238
 
241
239
  return diff;
242
240
  }
@@ -408,7 +406,7 @@ int git_index_open(git_index **index_out, const char *index_path)
408
406
  assert(index_out);
409
407
 
410
408
  index = git__calloc(1, sizeof(git_index));
411
- GIT_ERROR_CHECK_ALLOC(index);
409
+ GITERR_CHECK_ALLOC(index);
412
410
 
413
411
  git_pool_init(&index->tree_pool, 1);
414
412
 
@@ -423,10 +421,10 @@ int git_index_open(git_index **index_out, const char *index_path)
423
421
  }
424
422
 
425
423
  if (git_vector_init(&index->entries, 32, git_index_entry_cmp) < 0 ||
426
- git_idxmap_new(&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)
424
+ git_idxmap_alloc(&index->entries_map) < 0 ||
425
+ git_vector_init(&index->names, 8, conflict_name_cmp) < 0 ||
426
+ git_vector_init(&index->reuc, 8, reuc_cmp) < 0 ||
427
+ git_vector_init(&index->deleted, 8, git_index_entry_cmp) < 0)
430
428
  goto fail;
431
429
 
432
430
  index->entries_cmp_path = git__strcmp_cb;
@@ -518,8 +516,6 @@ static int index_remove_entry(git_index *index, size_t pos)
518
516
  } else {
519
517
  index_entry_free(entry);
520
518
  }
521
-
522
- index->dirty = 1;
523
519
  }
524
520
 
525
521
  return error;
@@ -531,7 +527,6 @@ int git_index_clear(git_index *index)
531
527
 
532
528
  assert(index);
533
529
 
534
- index->dirty = 1;
535
530
  index->tree = NULL;
536
531
  git_pool_clear(&index->tree_pool);
537
532
 
@@ -550,7 +545,7 @@ int git_index_clear(git_index *index)
550
545
 
551
546
  static int create_index_error(int error, const char *msg)
552
547
  {
553
- git_error_set_str(GIT_ERROR_INDEX, msg);
548
+ giterr_set_str(GITERR_INDEX, msg);
554
549
  return error;
555
550
  }
556
551
 
@@ -562,7 +557,7 @@ int git_index_set_caps(git_index *index, int caps)
562
557
 
563
558
  old_ignore_case = index->ignore_case;
564
559
 
565
- if (caps == GIT_INDEX_CAPABILITY_FROM_OWNER) {
560
+ if (caps == GIT_INDEXCAP_FROM_OWNER) {
566
561
  git_repository *repo = INDEX_OWNER(index);
567
562
  int val;
568
563
 
@@ -570,17 +565,17 @@ int git_index_set_caps(git_index *index, int caps)
570
565
  return create_index_error(
571
566
  -1, "cannot access repository to set index caps");
572
567
 
573
- if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_IGNORECASE))
568
+ if (!git_repository__cvar(&val, repo, GIT_CVAR_IGNORECASE))
574
569
  index->ignore_case = (val != 0);
575
- if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_FILEMODE))
570
+ if (!git_repository__cvar(&val, repo, GIT_CVAR_FILEMODE))
576
571
  index->distrust_filemode = (val == 0);
577
- if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_SYMLINKS))
572
+ if (!git_repository__cvar(&val, repo, GIT_CVAR_SYMLINKS))
578
573
  index->no_symlinks = (val == 0);
579
574
  }
580
575
  else {
581
- index->ignore_case = ((caps & GIT_INDEX_CAPABILITY_IGNORE_CASE) != 0);
582
- index->distrust_filemode = ((caps & GIT_INDEX_CAPABILITY_NO_FILEMODE) != 0);
583
- index->no_symlinks = ((caps & GIT_INDEX_CAPABILITY_NO_SYMLINKS) != 0);
576
+ index->ignore_case = ((caps & GIT_INDEXCAP_IGNORE_CASE) != 0);
577
+ index->distrust_filemode = ((caps & GIT_INDEXCAP_NO_FILEMODE) != 0);
578
+ index->no_symlinks = ((caps & GIT_INDEXCAP_NO_SYMLINKS) != 0);
584
579
  }
585
580
 
586
581
  if (old_ignore_case != index->ignore_case) {
@@ -592,9 +587,9 @@ int git_index_set_caps(git_index *index, int caps)
592
587
 
593
588
  int git_index_caps(const git_index *index)
594
589
  {
595
- return ((index->ignore_case ? GIT_INDEX_CAPABILITY_IGNORE_CASE : 0) |
596
- (index->distrust_filemode ? GIT_INDEX_CAPABILITY_NO_FILEMODE : 0) |
597
- (index->no_symlinks ? GIT_INDEX_CAPABILITY_NO_SYMLINKS : 0));
590
+ return ((index->ignore_case ? GIT_INDEXCAP_IGNORE_CASE : 0) |
591
+ (index->distrust_filemode ? GIT_INDEXCAP_NO_FILEMODE : 0) |
592
+ (index->no_symlinks ? GIT_INDEXCAP_NO_SYMLINKS : 0));
598
593
  }
599
594
 
600
595
  const git_oid *git_index_checksum(git_index *index)
@@ -616,7 +611,7 @@ static int compare_checksum(git_index *index)
616
611
 
617
612
  if (p_lseek(fd, -20, SEEK_END) < 0) {
618
613
  p_close(fd);
619
- git_error_set(GIT_ERROR_OS, "failed to seek to end of file");
614
+ giterr_set(GITERR_OS, "failed to seek to end of file");
620
615
  return -1;
621
616
  }
622
617
 
@@ -642,22 +637,19 @@ int git_index_read(git_index *index, int force)
642
637
  index->on_disk = git_path_exists(index->index_file_path);
643
638
 
644
639
  if (!index->on_disk) {
645
- if (force && (error = git_index_clear(index)) < 0)
646
- return error;
647
-
648
- index->dirty = 0;
640
+ if (force)
641
+ return git_index_clear(index);
649
642
  return 0;
650
643
  }
651
644
 
652
645
  if ((updated = git_futils_filestamp_check(&stamp, index->index_file_path) < 0) ||
653
646
  ((updated = compare_checksum(index)) < 0)) {
654
- git_error_set(
655
- GIT_ERROR_INDEX,
647
+ giterr_set(
648
+ GITERR_INDEX,
656
649
  "failed to read index: '%s' no longer exists",
657
650
  index->index_file_path);
658
651
  return updated;
659
652
  }
660
-
661
653
  if (!updated && !force)
662
654
  return 0;
663
655
 
@@ -673,32 +665,19 @@ int git_index_read(git_index *index, int force)
673
665
  if (!error)
674
666
  error = parse_index(index, buffer.ptr, buffer.size);
675
667
 
676
- if (!error) {
668
+ if (!error)
677
669
  git_futils_filestamp_set(&index->stamp, &stamp);
678
- index->dirty = 0;
679
- }
680
670
 
681
- git_buf_dispose(&buffer);
671
+ git_buf_free(&buffer);
682
672
  return error;
683
673
  }
684
674
 
685
- int git_index_read_safely(git_index *index)
686
- {
687
- if (git_index__enforce_unsaved_safety && index->dirty) {
688
- git_error_set(GIT_ERROR_INDEX,
689
- "the index has unsaved changes that would be overwritten by this operation");
690
- return GIT_EINDEXDIRTY;
691
- }
692
-
693
- return git_index_read(index, false);
694
- }
695
-
696
675
  int git_index__changed_relative_to(
697
676
  git_index *index, const git_oid *checksum)
698
677
  {
699
678
  /* attempt to update index (ignoring errors) */
700
679
  if (git_index_read(index, false) < 0)
701
- git_error_clear();
680
+ giterr_clear();
702
681
 
703
682
  return !!git_oid_cmp(&index->checksum, checksum);
704
683
  }
@@ -736,7 +715,7 @@ static int truncate_racily_clean(git_index *index)
736
715
 
737
716
  diff_opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE | GIT_DIFF_IGNORE_SUBMODULES | GIT_DIFF_DISABLE_PATHSPEC_MATCH;
738
717
  git_vector_foreach(&index->entries, i, entry) {
739
- if ((entry->flags_extended & GIT_INDEX_ENTRY_UPTODATE) == 0 &&
718
+ if ((entry->flags_extended & GIT_IDXENTRY_UPTODATE) == 0 &&
740
719
  is_racy_entry(index, entry))
741
720
  git_vector_insert(&paths, (char *)entry->path);
742
721
  }
@@ -756,10 +735,8 @@ static int truncate_racily_clean(git_index *index)
756
735
  /* Ensure that we have a stage 0 for this file (ie, it's not a
757
736
  * conflict), otherwise smudging it is quite pointless.
758
737
  */
759
- if (entry) {
738
+ if (entry)
760
739
  entry->file_size = 0;
761
- index->dirty = 1;
762
- }
763
740
  }
764
741
 
765
742
  done:
@@ -781,7 +758,7 @@ int git_index_set_version(git_index *index, unsigned int version)
781
758
 
782
759
  if (version < INDEX_VERSION_NUMBER_LB ||
783
760
  version > INDEX_VERSION_NUMBER_UB) {
784
- git_error_set(GIT_ERROR_INDEX, "invalid version number");
761
+ giterr_set(GITERR_INDEX, "invalid version number");
785
762
  return -1;
786
763
  }
787
764
 
@@ -797,9 +774,8 @@ int git_index_write(git_index *index)
797
774
 
798
775
  truncate_racily_clean(index);
799
776
 
800
- if ((error = git_indexwriter_init(&writer, index)) == 0 &&
801
- (error = git_indexwriter_commit(&writer)) == 0)
802
- index->dirty = 0;
777
+ if ((error = git_indexwriter_init(&writer, index)) == 0)
778
+ error = git_indexwriter_commit(&writer);
803
779
 
804
780
  git_indexwriter_cleanup(&writer);
805
781
 
@@ -851,22 +827,21 @@ const git_index_entry *git_index_get_byindex(
851
827
  const git_index_entry *git_index_get_bypath(
852
828
  git_index *index, const char *path, int stage)
853
829
  {
830
+ khiter_t pos;
854
831
  git_index_entry key = {{ 0 }};
855
- git_index_entry *value;
856
832
 
857
833
  assert(index);
858
834
 
859
835
  key.path = path;
860
- GIT_INDEX_ENTRY_STAGE_SET(&key, stage);
836
+ GIT_IDXENTRY_STAGE_SET(&key, stage);
861
837
 
862
- LOOKUP_IN_MAP(value, index, &key);
838
+ LOOKUP_IN_MAP(pos, index, &key);
863
839
 
864
- if (!value) {
865
- git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
866
- return NULL;
867
- }
840
+ if (git_idxmap_valid_index(index->entries_map, pos))
841
+ return git_idxmap_value_at(index->entries_map, pos);
868
842
 
869
- return value;
843
+ giterr_set(GITERR_INDEX, "index does not contain '%s'", path);
844
+ return NULL;
870
845
  }
871
846
 
872
847
  void git_index_entry__init_from_stat(
@@ -891,12 +866,12 @@ static void index_entry_adjust_namemask(
891
866
  git_index_entry *entry,
892
867
  size_t path_length)
893
868
  {
894
- entry->flags &= ~GIT_INDEX_ENTRY_NAMEMASK;
869
+ entry->flags &= ~GIT_IDXENTRY_NAMEMASK;
895
870
 
896
- if (path_length < GIT_INDEX_ENTRY_NAMEMASK)
897
- entry->flags |= path_length & GIT_INDEX_ENTRY_NAMEMASK;
871
+ if (path_length < GIT_IDXENTRY_NAMEMASK)
872
+ entry->flags |= path_length & GIT_IDXENTRY_NAMEMASK;
898
873
  else
899
- entry->flags |= GIT_INDEX_ENTRY_NAMEMASK;
874
+ entry->flags |= GIT_IDXENTRY_NAMEMASK;
900
875
  }
901
876
 
902
877
  /* When `from_workdir` is true, we will validate the paths to avoid placing
@@ -927,14 +902,14 @@ static int index_entry_create(
927
902
  mode = st->st_mode;
928
903
 
929
904
  if (!git_path_isvalid(repo, path, mode, path_valid_flags)) {
930
- git_error_set(GIT_ERROR_INDEX, "invalid path: '%s'", path);
905
+ giterr_set(GITERR_INDEX, "invalid path: '%s'", path);
931
906
  return -1;
932
907
  }
933
908
 
934
- GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(struct entry_internal), pathlen);
935
- GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
909
+ GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(struct entry_internal), pathlen);
910
+ GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
936
911
  entry = git__calloc(1, alloclen);
937
- GIT_ERROR_CHECK_ALLOC(entry);
912
+ GITERR_CHECK_ALLOC(entry);
938
913
 
939
914
  entry->pathlen = pathlen;
940
915
  memcpy(entry->path, path, pathlen);
@@ -974,7 +949,7 @@ static int index_entry_init(
974
949
  return -1;
975
950
 
976
951
  error = git_path_lstat(path.ptr, &st);
977
- git_buf_dispose(&path);
952
+ git_buf_free(&path);
978
953
 
979
954
  if (error < 0)
980
955
  return error;
@@ -1031,7 +1006,7 @@ static int index_entry_reuc_init(git_index_reuc_entry **reuc_out,
1031
1006
  assert(reuc_out && path);
1032
1007
 
1033
1008
  *reuc_out = reuc = reuc_entry_alloc(path);
1034
- GIT_ERROR_CHECK_ALLOC(reuc);
1009
+ GITERR_CHECK_ALLOC(reuc);
1035
1010
 
1036
1011
  if ((reuc->mode[0] = ancestor_mode) > 0) {
1037
1012
  assert(ancestor_oid);
@@ -1079,7 +1054,7 @@ static void index_entry_cpy_nocache(
1079
1054
  git_oid_cpy(&tgt->id, &src->id);
1080
1055
  tgt->mode = src->mode;
1081
1056
  tgt->flags = src->flags;
1082
- tgt->flags_extended = (src->flags_extended & GIT_INDEX_ENTRY_EXTENDED_FLAGS);
1057
+ tgt->flags_extended = (src->flags_extended & GIT_IDXENTRY_EXTENDED_FLAGS);
1083
1058
  }
1084
1059
 
1085
1060
  static int index_entry_dup_nocache(
@@ -1097,8 +1072,9 @@ static int index_entry_dup_nocache(
1097
1072
  static int has_file_name(git_index *index,
1098
1073
  const git_index_entry *entry, size_t pos, int ok_to_replace)
1099
1074
  {
1075
+ int retval = 0;
1100
1076
  size_t len = strlen(entry->path);
1101
- int stage = GIT_INDEX_ENTRY_STAGE(entry);
1077
+ int stage = GIT_IDXENTRY_STAGE(entry);
1102
1078
  const char *name = entry->path;
1103
1079
 
1104
1080
  while (pos < index->entries.length) {
@@ -1108,17 +1084,18 @@ static int has_file_name(git_index *index,
1108
1084
  break;
1109
1085
  if (memcmp(name, p->path, len))
1110
1086
  break;
1111
- if (GIT_INDEX_ENTRY_STAGE(&p->entry) != stage)
1087
+ if (GIT_IDXENTRY_STAGE(&p->entry) != stage)
1112
1088
  continue;
1113
1089
  if (p->path[len] != '/')
1114
1090
  continue;
1091
+ retval = -1;
1115
1092
  if (!ok_to_replace)
1116
- return -1;
1093
+ break;
1117
1094
 
1118
1095
  if (index_remove_entry(index, --pos) < 0)
1119
1096
  break;
1120
1097
  }
1121
- return 0;
1098
+ return retval;
1122
1099
  }
1123
1100
 
1124
1101
  /*
@@ -1128,7 +1105,8 @@ static int has_file_name(git_index *index,
1128
1105
  static int has_dir_name(git_index *index,
1129
1106
  const git_index_entry *entry, int ok_to_replace)
1130
1107
  {
1131
- int stage = GIT_INDEX_ENTRY_STAGE(entry);
1108
+ int retval = 0;
1109
+ int stage = GIT_IDXENTRY_STAGE(entry);
1132
1110
  const char *name = entry->path;
1133
1111
  const char *slash = name + strlen(name);
1134
1112
 
@@ -1139,13 +1117,14 @@ static int has_dir_name(git_index *index,
1139
1117
  if (*--slash == '/')
1140
1118
  break;
1141
1119
  if (slash <= entry->path)
1142
- return 0;
1120
+ return retval;
1143
1121
  }
1144
1122
  len = slash - name;
1145
1123
 
1146
1124
  if (!index_find(&pos, index, name, len, stage)) {
1125
+ retval = -1;
1147
1126
  if (!ok_to_replace)
1148
- return -1;
1127
+ break;
1149
1128
 
1150
1129
  if (index_remove_entry(index, pos) < 0)
1151
1130
  break;
@@ -1165,20 +1144,22 @@ static int has_dir_name(git_index *index,
1165
1144
  memcmp(p->path, name, len))
1166
1145
  break; /* not our subdirectory */
1167
1146
 
1168
- if (GIT_INDEX_ENTRY_STAGE(&p->entry) == stage)
1169
- return 0;
1147
+ if (GIT_IDXENTRY_STAGE(&p->entry) == stage)
1148
+ return retval;
1170
1149
  }
1171
1150
  }
1172
1151
 
1173
- return 0;
1152
+ return retval;
1174
1153
  }
1175
1154
 
1176
1155
  static int check_file_directory_collision(git_index *index,
1177
1156
  git_index_entry *entry, size_t pos, int ok_to_replace)
1178
1157
  {
1179
- if (has_file_name(index, entry, pos, ok_to_replace) < 0 ||
1180
- has_dir_name(index, entry, ok_to_replace) < 0) {
1181
- git_error_set(GIT_ERROR_INDEX,
1158
+ int retval = has_file_name(index, entry, pos, ok_to_replace);
1159
+ retval = retval + has_dir_name(index, entry, ok_to_replace);
1160
+
1161
+ if (retval) {
1162
+ giterr_set(GITERR_INDEX,
1182
1163
  "'%s' appears as both a file and a directory", entry->path);
1183
1164
  return -1;
1184
1165
  }
@@ -1223,7 +1204,7 @@ static int canonicalize_directory_path(
1223
1204
  &pos, &index->entries, index->entries_search_path, search);
1224
1205
 
1225
1206
  while ((match = git_vector_get(&index->entries, pos))) {
1226
- if (GIT_INDEX_ENTRY_STAGE(match) != 0) {
1207
+ if (GIT_IDXENTRY_STAGE(match) != 0) {
1227
1208
  /* conflicts do not contribute to canonical paths */
1228
1209
  } else if (strncmp(search, match->path, search_len) == 0) {
1229
1210
  /* prefer an exact match to the input filename */
@@ -1260,8 +1241,8 @@ static int index_no_dups(void **old, void *new)
1260
1241
  {
1261
1242
  const git_index_entry *entry = new;
1262
1243
  GIT_UNUSED(old);
1263
- git_error_set(GIT_ERROR_INDEX, "'%s' appears multiple times at stage %d",
1264
- entry->path, GIT_INDEX_ENTRY_STAGE(entry));
1244
+ giterr_set(GITERR_INDEX, "'%s' appears multiple times at stage %d",
1245
+ entry->path, GIT_IDXENTRY_STAGE(entry));
1265
1246
  return GIT_EEXISTS;
1266
1247
  }
1267
1248
 
@@ -1277,7 +1258,7 @@ static void index_existing_and_best(
1277
1258
  int error;
1278
1259
 
1279
1260
  error = index_find(&pos,
1280
- index, entry->path, 0, GIT_INDEX_ENTRY_STAGE(entry));
1261
+ index, entry->path, 0, GIT_IDXENTRY_STAGE(entry));
1281
1262
 
1282
1263
  if (error == 0) {
1283
1264
  *existing = index->entries.contents[pos];
@@ -1290,7 +1271,7 @@ static void index_existing_and_best(
1290
1271
  *existing_position = 0;
1291
1272
  *best = NULL;
1292
1273
 
1293
- if (GIT_INDEX_ENTRY_STAGE(entry) == 0) {
1274
+ if (GIT_IDXENTRY_STAGE(entry) == 0) {
1294
1275
  for (; pos < index->entries.length; pos++) {
1295
1276
  int (*strcomp)(const char *a, const char *b) =
1296
1277
  index->ignore_case ? git__strcasecmp : git__strcmp;
@@ -1300,7 +1281,7 @@ static void index_existing_and_best(
1300
1281
  if (strcomp(entry->path, e->path) != 0)
1301
1282
  break;
1302
1283
 
1303
- if (GIT_INDEX_ENTRY_STAGE(e) == GIT_INDEX_STAGE_ANCESTOR) {
1284
+ if (GIT_IDXENTRY_STAGE(e) == GIT_INDEX_STAGE_ANCESTOR) {
1304
1285
  *best = e;
1305
1286
  continue;
1306
1287
  } else {
@@ -1332,58 +1313,57 @@ static int index_insert(
1332
1313
  bool trust_mode,
1333
1314
  bool trust_id)
1334
1315
  {
1335
- git_index_entry *existing, *best, *entry;
1316
+ int error = 0;
1336
1317
  size_t path_length, position;
1337
- int error;
1318
+ git_index_entry *existing, *best, *entry;
1338
1319
 
1339
1320
  assert(index && entry_ptr);
1340
1321
 
1341
1322
  entry = *entry_ptr;
1342
1323
 
1343
- /* Make sure that the path length flag is correct */
1324
+ /* make sure that the path length flag is correct */
1344
1325
  path_length = ((struct entry_internal *)entry)->pathlen;
1345
1326
  index_entry_adjust_namemask(entry, path_length);
1346
1327
 
1347
- /* This entry is now up-to-date and should not be checked for raciness */
1348
- entry->flags_extended |= GIT_INDEX_ENTRY_UPTODATE;
1328
+ /* this entry is now up-to-date and should not be checked for raciness */
1329
+ entry->flags_extended |= GIT_IDXENTRY_UPTODATE;
1349
1330
 
1350
1331
  git_vector_sort(&index->entries);
1351
1332
 
1352
- /*
1353
- * Look if an entry with this path already exists, either staged, or (if
1333
+ /* look if an entry with this path already exists, either staged, or (if
1354
1334
  * this entry is a regular staged item) as the "ours" side of a conflict.
1355
1335
  */
1356
1336
  index_existing_and_best(&existing, &position, &best, index, entry);
1357
1337
 
1358
- /* Update the file mode */
1338
+ /* update the file mode */
1359
1339
  entry->mode = trust_mode ?
1360
1340
  git_index__create_mode(entry->mode) :
1361
1341
  index_merge_mode(index, best, entry->mode);
1362
1342
 
1363
- /* Canonicalize the directory name */
1364
- if (!trust_path && (error = canonicalize_directory_path(index, entry, best)) < 0)
1365
- goto out;
1343
+ /* canonicalize the directory name */
1344
+ if (!trust_path)
1345
+ error = canonicalize_directory_path(index, entry, best);
1366
1346
 
1367
- /* Ensure that the given id exists (unless it's a submodule) */
1368
- if (!trust_id && INDEX_OWNER(index) &&
1369
- (entry->mode & GIT_FILEMODE_COMMIT) != GIT_FILEMODE_COMMIT) {
1347
+ /* ensure that the given id exists (unless it's a submodule) */
1348
+ if (!error && !trust_id && INDEX_OWNER(index) &&
1349
+ (entry->mode & GIT_FILEMODE_COMMIT) != GIT_FILEMODE_COMMIT) {
1370
1350
 
1371
1351
  if (!git_object__is_valid(INDEX_OWNER(index), &entry->id,
1372
- git_object__type_from_filemode(entry->mode))) {
1352
+ git_object__type_from_filemode(entry->mode)))
1373
1353
  error = -1;
1374
- goto out;
1375
- }
1376
1354
  }
1377
1355
 
1378
- /* Look for tree / blob name collisions, removing conflicts if requested */
1379
- if ((error = check_file_directory_collision(index, entry, position, replace)) < 0)
1380
- goto out;
1356
+ /* look for tree / blob name collisions, removing conflicts if requested */
1357
+ if (!error)
1358
+ error = check_file_directory_collision(index, entry, position, replace);
1381
1359
 
1382
- /*
1383
- * If we are replacing an existing item, overwrite the existing entry
1360
+ if (error < 0)
1361
+ /* skip changes */;
1362
+
1363
+ /* if we are replacing an existing item, overwrite the existing entry
1384
1364
  * and return it in place of the passed in one.
1385
1365
  */
1386
- if (existing) {
1366
+ else if (existing) {
1387
1367
  if (replace) {
1388
1368
  index_entry_cpy(existing, entry);
1389
1369
 
@@ -1392,22 +1372,20 @@ static int index_insert(
1392
1372
  }
1393
1373
 
1394
1374
  index_entry_free(entry);
1395
- *entry_ptr = existing;
1396
- } else {
1397
- /*
1398
- * If replace is not requested or no existing entry exists, insert
1375
+ *entry_ptr = entry = existing;
1376
+ }
1377
+ else {
1378
+ /* if replace is not requested or no existing entry exists, insert
1399
1379
  * at the sorted position. (Since we re-sort after each insert to
1400
1380
  * check for dups, this is actually cheaper in the long run.)
1401
1381
  */
1402
- if ((error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)) < 0)
1403
- goto out;
1382
+ error = git_vector_insert_sorted(&index->entries, entry, index_no_dups);
1404
1383
 
1405
- INSERT_IN_MAP(index, entry, error);
1384
+ if (error == 0) {
1385
+ INSERT_IN_MAP(index, entry, &error);
1386
+ }
1406
1387
  }
1407
1388
 
1408
- index->dirty = 1;
1409
-
1410
- out:
1411
1389
  if (error < 0) {
1412
1390
  index_entry_free(*entry_ptr);
1413
1391
  *entry_ptr = NULL;
@@ -1454,7 +1432,7 @@ GIT_INLINE(bool) valid_filemode(const int filemode)
1454
1432
  return (is_file_or_link(filemode) || filemode == GIT_FILEMODE_COMMIT);
1455
1433
  }
1456
1434
 
1457
- int git_index_add_from_buffer(
1435
+ int git_index_add_frombuffer(
1458
1436
  git_index *index, const git_index_entry *source_entry,
1459
1437
  const void *buffer, size_t len)
1460
1438
  {
@@ -1470,26 +1448,21 @@ int git_index_add_from_buffer(
1470
1448
  "Index is not backed up by an existing repository.");
1471
1449
 
1472
1450
  if (!is_file_or_link(source_entry->mode)) {
1473
- git_error_set(GIT_ERROR_INDEX, "invalid filemode");
1474
- return -1;
1475
- }
1476
-
1477
- if (len > UINT32_MAX) {
1478
- git_error_set(GIT_ERROR_INDEX, "buffer is too large");
1451
+ giterr_set(GITERR_INDEX, "invalid filemode");
1479
1452
  return -1;
1480
1453
  }
1481
1454
 
1482
1455
  if (index_entry_dup(&entry, index, source_entry) < 0)
1483
1456
  return -1;
1484
1457
 
1485
- error = git_blob_create_from_buffer(&id, INDEX_OWNER(index), buffer, len);
1458
+ error = git_blob_create_frombuffer(&id, INDEX_OWNER(index), buffer, len);
1486
1459
  if (error < 0) {
1487
1460
  index_entry_free(entry);
1488
1461
  return error;
1489
1462
  }
1490
1463
 
1491
1464
  git_oid_cpy(&entry->id, &id);
1492
- entry->file_size = (uint32_t)len;
1465
+ entry->file_size = len;
1493
1466
 
1494
1467
  if ((error = index_insert(index, &entry, 1, true, true, true)) < 0)
1495
1468
  return error;
@@ -1516,7 +1489,7 @@ static int add_repo_as_submodule(git_index_entry **out, git_index *index, const
1516
1489
  return error;
1517
1490
 
1518
1491
  if ((error = p_stat(abspath.ptr, &st)) < 0) {
1519
- git_error_set(GIT_ERROR_OS, "failed to stat repository dir");
1492
+ giterr_set(GITERR_OS, "failed to stat repository dir");
1520
1493
  return -1;
1521
1494
  }
1522
1495
 
@@ -1536,7 +1509,7 @@ static int add_repo_as_submodule(git_index_entry **out, git_index *index, const
1536
1509
 
1537
1510
  git_reference_free(head);
1538
1511
  git_repository_free(sub);
1539
- git_buf_dispose(&abspath);
1512
+ git_buf_free(&abspath);
1540
1513
 
1541
1514
  *out = entry;
1542
1515
  return 0;
@@ -1560,13 +1533,13 @@ int git_index_add_bypath(git_index *index, const char *path)
1560
1533
  git_submodule *sm;
1561
1534
  git_error_state err;
1562
1535
 
1563
- git_error_state_capture(&err, ret);
1536
+ giterr_state_capture(&err, ret);
1564
1537
 
1565
1538
  ret = git_submodule_lookup(&sm, INDEX_OWNER(index), path);
1566
1539
  if (ret == GIT_ENOTFOUND)
1567
- return git_error_state_restore(&err);
1540
+ return giterr_state_restore(&err);
1568
1541
 
1569
- git_error_state_free(&err);
1542
+ giterr_state_free(&err);
1570
1543
 
1571
1544
  /*
1572
1545
  * EEXISTS means that there is a repository at that path, but it's not known
@@ -1608,7 +1581,7 @@ int git_index_remove_bypath(git_index *index, const char *path)
1608
1581
  return ret;
1609
1582
 
1610
1583
  if (ret == GIT_ENOTFOUND)
1611
- git_error_clear();
1584
+ giterr_clear();
1612
1585
 
1613
1586
  return 0;
1614
1587
  }
@@ -1624,9 +1597,8 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
1624
1597
  if (!source_entries->length)
1625
1598
  return 0;
1626
1599
 
1627
- if (git_vector_size_hint(&index->entries, source_entries->length) < 0 ||
1628
- git_idxmap_resize(index->entries_map, (size_t)(source_entries->length * 1.3)) < 0)
1629
- return -1;
1600
+ git_vector_size_hint(&index->entries, source_entries->length);
1601
+ git_idxmap_resize(index->entries_map, (khint_t)(source_entries->length * 1.3));
1630
1602
 
1631
1603
  git_vector_foreach(source_entries, i, source_entry) {
1632
1604
  git_index_entry *entry = NULL;
@@ -1635,17 +1607,15 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
1635
1607
  break;
1636
1608
 
1637
1609
  index_entry_adjust_namemask(entry, ((struct entry_internal *)entry)->pathlen);
1638
- entry->flags_extended |= GIT_INDEX_ENTRY_UPTODATE;
1610
+ entry->flags_extended |= GIT_IDXENTRY_UPTODATE;
1639
1611
  entry->mode = git_index__create_mode(entry->mode);
1640
1612
 
1641
1613
  if ((ret = git_vector_insert(&index->entries, entry)) < 0)
1642
1614
  break;
1643
1615
 
1644
- INSERT_IN_MAP(index, entry, ret);
1616
+ INSERT_IN_MAP(index, entry, &ret);
1645
1617
  if (ret < 0)
1646
1618
  break;
1647
-
1648
- index->dirty = 1;
1649
1619
  }
1650
1620
 
1651
1621
  if (!ret)
@@ -1663,7 +1633,7 @@ int git_index_add(git_index *index, const git_index_entry *source_entry)
1663
1633
  assert(index && source_entry && source_entry->path);
1664
1634
 
1665
1635
  if (!valid_filemode(source_entry->mode)) {
1666
- git_error_set(GIT_ERROR_INDEX, "invalid entry mode");
1636
+ giterr_set(GITERR_INDEX, "invalid entry mode");
1667
1637
  return -1;
1668
1638
  }
1669
1639
 
@@ -1682,13 +1652,13 @@ int git_index_remove(git_index *index, const char *path, int stage)
1682
1652
  git_index_entry remove_key = {{ 0 }};
1683
1653
 
1684
1654
  remove_key.path = path;
1685
- GIT_INDEX_ENTRY_STAGE_SET(&remove_key, stage);
1655
+ GIT_IDXENTRY_STAGE_SET(&remove_key, stage);
1686
1656
 
1687
1657
  DELETE_IN_MAP(index, &remove_key);
1688
1658
 
1689
1659
  if (index_find(&position, index, path, 0, stage) < 0) {
1690
- git_error_set(
1691
- GIT_ERROR_INDEX, "index does not contain %s at stage %d", path, stage);
1660
+ giterr_set(
1661
+ GITERR_INDEX, "index does not contain %s at stage %d", path, stage);
1692
1662
  error = GIT_ENOTFOUND;
1693
1663
  } else {
1694
1664
  error = index_remove_entry(index, position);
@@ -1713,7 +1683,7 @@ int git_index_remove_directory(git_index *index, const char *dir, int stage)
1713
1683
  if (!entry || git__prefixcmp(entry->path, pfx.ptr) != 0)
1714
1684
  break;
1715
1685
 
1716
- if (GIT_INDEX_ENTRY_STAGE(entry) != stage) {
1686
+ if (GIT_IDXENTRY_STAGE(entry) != stage) {
1717
1687
  ++pos;
1718
1688
  continue;
1719
1689
  }
@@ -1723,7 +1693,7 @@ int git_index_remove_directory(git_index *index, const char *dir, int stage)
1723
1693
  /* removed entry at 'pos' so we don't need to increment */
1724
1694
  }
1725
1695
 
1726
- git_buf_dispose(&pfx);
1696
+ git_buf_free(&pfx);
1727
1697
 
1728
1698
  return error;
1729
1699
  }
@@ -1760,7 +1730,7 @@ int git_index_find(size_t *at_pos, git_index *index, const char *path)
1760
1730
 
1761
1731
  if (git_vector_bsearch2(
1762
1732
  &pos, &index->entries, index->entries_search_path, path) < 0) {
1763
- git_error_set(GIT_ERROR_INDEX, "index does not contain %s", path);
1733
+ giterr_set(GITERR_INDEX, "index does not contain %s", path);
1764
1734
  return GIT_ENOTFOUND;
1765
1735
  }
1766
1736
 
@@ -1802,7 +1772,7 @@ int git_index_conflict_add(git_index *index,
1802
1772
  /* Validate entries */
1803
1773
  for (i = 0; i < 3; i++) {
1804
1774
  if (entries[i] && !valid_filemode(entries[i]->mode)) {
1805
- git_error_set(GIT_ERROR_INDEX, "invalid filemode for stage %d entry",
1775
+ giterr_set(GITERR_INDEX, "invalid filemode for stage %d entry",
1806
1776
  i + 1);
1807
1777
  ret = -1;
1808
1778
  goto on_error;
@@ -1818,7 +1788,7 @@ int git_index_conflict_add(git_index *index,
1818
1788
  if (ret != GIT_ENOTFOUND)
1819
1789
  goto on_error;
1820
1790
 
1821
- git_error_clear();
1791
+ giterr_clear();
1822
1792
  ret = 0;
1823
1793
  }
1824
1794
  }
@@ -1829,7 +1799,7 @@ int git_index_conflict_add(git_index *index,
1829
1799
  continue;
1830
1800
 
1831
1801
  /* Make sure stage is correct */
1832
- GIT_INDEX_ENTRY_STAGE_SET(entries[i], i + 1);
1802
+ GIT_IDXENTRY_STAGE_SET(entries[i], i + 1);
1833
1803
 
1834
1804
  if ((ret = index_insert(index, &entries[i], 1, true, true, false)) < 0)
1835
1805
  goto on_error;
@@ -1872,7 +1842,7 @@ static int index_conflict__get_byindex(
1872
1842
  if (path && index->entries_cmp_path(conflict_entry->path, path) != 0)
1873
1843
  break;
1874
1844
 
1875
- stage = GIT_INDEX_ENTRY_STAGE(conflict_entry);
1845
+ stage = GIT_IDXENTRY_STAGE(conflict_entry);
1876
1846
  path = conflict_entry->path;
1877
1847
 
1878
1848
  switch (stage) {
@@ -1939,7 +1909,7 @@ static int index_conflict_remove(git_index *index, const char *path)
1939
1909
  index->entries_cmp_path(conflict_entry->path, path) != 0)
1940
1910
  break;
1941
1911
 
1942
- if (GIT_INDEX_ENTRY_STAGE(conflict_entry) == 0) {
1912
+ if (GIT_IDXENTRY_STAGE(conflict_entry) == 0) {
1943
1913
  pos++;
1944
1914
  continue;
1945
1915
  }
@@ -1971,58 +1941,13 @@ int git_index_has_conflicts(const git_index *index)
1971
1941
  assert(index);
1972
1942
 
1973
1943
  git_vector_foreach(&index->entries, i, entry) {
1974
- if (GIT_INDEX_ENTRY_STAGE(entry) > 0)
1944
+ if (GIT_IDXENTRY_STAGE(entry) > 0)
1975
1945
  return 1;
1976
1946
  }
1977
1947
 
1978
1948
  return 0;
1979
1949
  }
1980
1950
 
1981
- int git_index_iterator_new(
1982
- git_index_iterator **iterator_out,
1983
- git_index *index)
1984
- {
1985
- git_index_iterator *it;
1986
- int error;
1987
-
1988
- assert(iterator_out && index);
1989
-
1990
- it = git__calloc(1, sizeof(git_index_iterator));
1991
- GIT_ERROR_CHECK_ALLOC(it);
1992
-
1993
- if ((error = git_index_snapshot_new(&it->snap, index)) < 0) {
1994
- git__free(it);
1995
- return error;
1996
- }
1997
-
1998
- it->index = index;
1999
-
2000
- *iterator_out = it;
2001
- return 0;
2002
- }
2003
-
2004
- int git_index_iterator_next(
2005
- const git_index_entry **out,
2006
- git_index_iterator *it)
2007
- {
2008
- assert(out && it);
2009
-
2010
- if (it->cur >= git_vector_length(&it->snap))
2011
- return GIT_ITEROVER;
2012
-
2013
- *out = (git_index_entry *)git_vector_get(&it->snap, it->cur++);
2014
- return 0;
2015
- }
2016
-
2017
- void git_index_iterator_free(git_index_iterator *it)
2018
- {
2019
- if (it == NULL)
2020
- return;
2021
-
2022
- git_index_snapshot_release(&it->snap, it->index);
2023
- git__free(it);
2024
- }
2025
-
2026
1951
  int git_index_conflict_iterator_new(
2027
1952
  git_index_conflict_iterator **iterator_out,
2028
1953
  git_index *index)
@@ -2032,7 +1957,7 @@ int git_index_conflict_iterator_new(
2032
1957
  assert(iterator_out && index);
2033
1958
 
2034
1959
  it = git__calloc(1, sizeof(git_index_conflict_iterator));
2035
- GIT_ERROR_CHECK_ALLOC(it);
1960
+ GITERR_CHECK_ALLOC(it);
2036
1961
 
2037
1962
  it->index = index;
2038
1963
 
@@ -2118,7 +2043,7 @@ int git_index_name_add(git_index *index,
2118
2043
  assert((ancestor && ours) || (ancestor && theirs) || (ours && theirs));
2119
2044
 
2120
2045
  conflict_name = git__calloc(1, sizeof(git_index_name_entry));
2121
- GIT_ERROR_CHECK_ALLOC(conflict_name);
2046
+ GITERR_CHECK_ALLOC(conflict_name);
2122
2047
 
2123
2048
  if ((ancestor && !(conflict_name->ancestor = git__strdup(ancestor))) ||
2124
2049
  (ours && !(conflict_name->ours = git__strdup(ours))) ||
@@ -2129,7 +2054,6 @@ int git_index_name_add(git_index *index,
2129
2054
  return -1;
2130
2055
  }
2131
2056
 
2132
- index->dirty = 1;
2133
2057
  return 0;
2134
2058
  }
2135
2059
 
@@ -2144,8 +2068,6 @@ void git_index_name_clear(git_index *index)
2144
2068
  index_name_entry_free(conflict_name);
2145
2069
 
2146
2070
  git_vector_clear(&index->names);
2147
-
2148
- index->dirty = 1;
2149
2071
  }
2150
2072
 
2151
2073
  size_t git_index_reuc_entrycount(git_index *index)
@@ -2171,8 +2093,6 @@ static int index_reuc_insert(
2171
2093
  assert(git_vector_is_sorted(&index->reuc));
2172
2094
 
2173
2095
  res = git_vector_insert_sorted(&index->reuc, reuc, &index_reuc_on_dup);
2174
- index->dirty = 1;
2175
-
2176
2096
  return res == GIT_EEXISTS ? 0 : res;
2177
2097
  }
2178
2098
 
@@ -2238,7 +2158,6 @@ int git_index_reuc_remove(git_index *index, size_t position)
2238
2158
  if (!error)
2239
2159
  index_entry_reuc_free(reuc);
2240
2160
 
2241
- index->dirty = 1;
2242
2161
  return error;
2243
2162
  }
2244
2163
 
@@ -2252,13 +2171,11 @@ void git_index_reuc_clear(git_index *index)
2252
2171
  index_entry_reuc_free(git__swap(index->reuc.contents[i], NULL));
2253
2172
 
2254
2173
  git_vector_clear(&index->reuc);
2255
-
2256
- index->dirty = 1;
2257
2174
  }
2258
2175
 
2259
2176
  static int index_error_invalid(const char *message)
2260
2177
  {
2261
- git_error_set(GIT_ERROR_INDEX, "invalid data in index - %s", message);
2178
+ giterr_set(GITERR_INDEX, "invalid data in index - %s", message);
2262
2179
  return -1;
2263
2180
  }
2264
2181
 
@@ -2281,7 +2198,7 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
2281
2198
  return index_error_invalid("reading reuc entries");
2282
2199
 
2283
2200
  lost = reuc_entry_alloc(buffer);
2284
- GIT_ERROR_CHECK_ALLOC(lost);
2201
+ GITERR_CHECK_ALLOC(lost);
2285
2202
 
2286
2203
  size -= len;
2287
2204
  buffer += len;
@@ -2354,7 +2271,7 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
2354
2271
  ptr = NULL; \
2355
2272
  else { \
2356
2273
  ptr = git__malloc(len); \
2357
- GIT_ERROR_CHECK_ALLOC(ptr); \
2274
+ GITERR_CHECK_ALLOC(ptr); \
2358
2275
  memcpy(ptr, buffer, len); \
2359
2276
  } \
2360
2277
  \
@@ -2363,7 +2280,7 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
2363
2280
 
2364
2281
  while (size) {
2365
2282
  git_index_name_entry *conflict_name = git__calloc(1, sizeof(git_index_name_entry));
2366
- GIT_ERROR_CHECK_ALLOC(conflict_name);
2283
+ GITERR_CHECK_ALLOC(conflict_name);
2367
2284
 
2368
2285
  read_conflict_name(conflict_name->ancestor);
2369
2286
  read_conflict_name(conflict_name->ours);
@@ -2393,13 +2310,13 @@ out_err:
2393
2310
  static size_t index_entry_size(size_t path_len, size_t varint_len, uint32_t flags)
2394
2311
  {
2395
2312
  if (varint_len) {
2396
- if (flags & GIT_INDEX_ENTRY_EXTENDED)
2313
+ if (flags & GIT_IDXENTRY_EXTENDED)
2397
2314
  return offsetof(struct entry_long, path) + path_len + 1 + varint_len;
2398
2315
  else
2399
2316
  return offsetof(struct entry_short, path) + path_len + 1 + varint_len;
2400
2317
  } else {
2401
2318
  #define entry_size(type,len) ((offsetof(type, path) + (len) + 8) & ~7)
2402
- if (flags & GIT_INDEX_ENTRY_EXTENDED)
2319
+ if (flags & GIT_IDXENTRY_EXTENDED)
2403
2320
  return entry_size(struct entry_long, path_len);
2404
2321
  else
2405
2322
  return entry_size(struct entry_short, path_len);
@@ -2441,7 +2358,7 @@ static int read_entry(
2441
2358
  git_oid_cpy(&entry.id, &source.oid);
2442
2359
  entry.flags = ntohs(source.flags);
2443
2360
 
2444
- if (entry.flags & GIT_INDEX_ENTRY_EXTENDED) {
2361
+ if (entry.flags & GIT_IDXENTRY_EXTENDED) {
2445
2362
  uint16_t flags_raw;
2446
2363
  size_t flags_offset;
2447
2364
 
@@ -2456,7 +2373,7 @@ static int read_entry(
2456
2373
  path_ptr = (const char *) buffer + offsetof(struct entry_short, path);
2457
2374
 
2458
2375
  if (!compressed) {
2459
- path_length = entry.flags & GIT_INDEX_ENTRY_NAMEMASK;
2376
+ path_length = entry.flags & GIT_IDXENTRY_NAMEMASK;
2460
2377
 
2461
2378
  /* if this is a very long string, we must find its
2462
2379
  * real length without overflowing */
@@ -2482,17 +2399,17 @@ static int read_entry(
2482
2399
  if (varint_len == 0 || last_len < strip_len)
2483
2400
  return index_error_invalid("incorrect prefix length");
2484
2401
 
2485
- prefix_len = last_len - (size_t)strip_len;
2402
+ prefix_len = last_len - strip_len;
2486
2403
  suffix_len = strlen(path_ptr + varint_len);
2487
2404
 
2488
- GIT_ERROR_CHECK_ALLOC_ADD(&path_len, prefix_len, suffix_len);
2489
- GIT_ERROR_CHECK_ALLOC_ADD(&path_len, path_len, 1);
2405
+ GITERR_CHECK_ALLOC_ADD(&path_len, prefix_len, suffix_len);
2406
+ GITERR_CHECK_ALLOC_ADD(&path_len, path_len, 1);
2490
2407
 
2491
2408
  if (path_len > GIT_PATH_MAX)
2492
2409
  return index_error_invalid("unreasonable path length");
2493
2410
 
2494
2411
  tmp_path = git__malloc(path_len);
2495
- GIT_ERROR_CHECK_ALLOC(tmp_path);
2412
+ GITERR_CHECK_ALLOC(tmp_path);
2496
2413
 
2497
2414
  memcpy(tmp_path, last, prefix_len);
2498
2415
  memcpy(tmp_path + prefix_len, path_ptr + varint_len, suffix_len + 1);
@@ -2533,7 +2450,7 @@ static int read_header(struct index_header *dest, const void *buffer)
2533
2450
  return 0;
2534
2451
  }
2535
2452
 
2536
- static int read_extension(size_t *read_len, git_index *index, const char *buffer, size_t buffer_size)
2453
+ static size_t read_extension(git_index *index, const char *buffer, size_t buffer_size)
2537
2454
  {
2538
2455
  struct index_extension dest;
2539
2456
  size_t total_size;
@@ -2546,36 +2463,31 @@ static int read_extension(size_t *read_len, git_index *index, const char *buffer
2546
2463
 
2547
2464
  if (dest.extension_size > total_size ||
2548
2465
  buffer_size < total_size ||
2549
- buffer_size - total_size < INDEX_FOOTER_SIZE) {
2550
- index_error_invalid("extension is truncated");
2551
- return -1;
2552
- }
2466
+ buffer_size - total_size < INDEX_FOOTER_SIZE)
2467
+ return 0;
2553
2468
 
2554
2469
  /* optional extension */
2555
2470
  if (dest.signature[0] >= 'A' && dest.signature[0] <= 'Z') {
2556
2471
  /* tree cache */
2557
2472
  if (memcmp(dest.signature, INDEX_EXT_TREECACHE_SIG, 4) == 0) {
2558
2473
  if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size, &index->tree_pool) < 0)
2559
- return -1;
2474
+ return 0;
2560
2475
  } else if (memcmp(dest.signature, INDEX_EXT_UNMERGED_SIG, 4) == 0) {
2561
2476
  if (read_reuc(index, buffer + 8, dest.extension_size) < 0)
2562
- return -1;
2477
+ return 0;
2563
2478
  } else if (memcmp(dest.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4) == 0) {
2564
2479
  if (read_conflict_names(index, buffer + 8, dest.extension_size) < 0)
2565
- return -1;
2480
+ return 0;
2566
2481
  }
2567
2482
  /* else, unsupported extension. We cannot parse this, but we can skip
2568
2483
  * it by returning `total_size */
2569
2484
  } else {
2570
2485
  /* we cannot handle non-ignorable extensions;
2571
2486
  * in fact they aren't even defined in the standard */
2572
- git_error_set(GIT_ERROR_INDEX, "unsupported mandatory extension: '%.4s'", dest.signature);
2573
- return -1;
2487
+ return 0;
2574
2488
  }
2575
2489
 
2576
- *read_len = total_size;
2577
-
2578
- return 0;
2490
+ return total_size;
2579
2491
  }
2580
2492
 
2581
2493
  static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
@@ -2614,12 +2526,10 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2614
2526
 
2615
2527
  assert(!index->entries.length);
2616
2528
 
2617
- if (index->ignore_case &&
2618
- (error = git_idxmap_icase_resize((git_idxmap_icase *) index->entries_map,
2619
- header.entry_count)) < 0)
2620
- return error;
2621
- else if ((error = git_idxmap_resize(index->entries_map, header.entry_count)) < 0)
2622
- return error;
2529
+ if (index->ignore_case)
2530
+ git_idxmap_icase_resize((khash_t(idxicase) *) index->entries_map, header.entry_count);
2531
+ else
2532
+ git_idxmap_resize(index->entries_map, header.entry_count);
2623
2533
 
2624
2534
  /* Parse all the entries */
2625
2535
  for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) {
@@ -2636,7 +2546,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2636
2546
  goto done;
2637
2547
  }
2638
2548
 
2639
- INSERT_IN_MAP(index, entry, error);
2549
+ INSERT_IN_MAP(index, entry, &error);
2640
2550
 
2641
2551
  if (error < 0) {
2642
2552
  index_entry_free(entry);
@@ -2659,7 +2569,11 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2659
2569
  while (buffer_size > INDEX_FOOTER_SIZE) {
2660
2570
  size_t extension_size;
2661
2571
 
2662
- if ((error = read_extension(&extension_size, index, buffer, buffer_size)) < 0) {
2572
+ extension_size = read_extension(index, buffer, buffer_size);
2573
+
2574
+ /* see if we have read any bytes from the extension */
2575
+ if (extension_size == 0) {
2576
+ error = index_error_invalid("extension is truncated");
2663
2577
  goto done;
2664
2578
  }
2665
2579
 
@@ -2691,7 +2605,6 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2691
2605
  git_vector_set_sorted(&index->entries, !index->ignore_case);
2692
2606
  git_vector_sort(&index->entries);
2693
2607
 
2694
- index->dirty = 0;
2695
2608
  done:
2696
2609
  return error;
2697
2610
  }
@@ -2704,10 +2617,10 @@ static bool is_index_extended(git_index *index)
2704
2617
  extended = 0;
2705
2618
 
2706
2619
  git_vector_foreach(&index->entries, i, entry) {
2707
- entry->flags &= ~GIT_INDEX_ENTRY_EXTENDED;
2708
- if (entry->flags_extended & GIT_INDEX_ENTRY_EXTENDED_FLAGS) {
2620
+ entry->flags &= ~GIT_IDXENTRY_EXTENDED;
2621
+ if (entry->flags_extended & GIT_IDXENTRY_EXTENDED_FLAGS) {
2709
2622
  extended++;
2710
- entry->flags |= GIT_INDEX_ENTRY_EXTENDED;
2623
+ entry->flags |= GIT_IDXENTRY_EXTENDED;
2711
2624
  }
2712
2625
  }
2713
2626
 
@@ -2717,7 +2630,7 @@ static bool is_index_extended(git_index *index)
2717
2630
  static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const char *last)
2718
2631
  {
2719
2632
  void *mem = NULL;
2720
- struct entry_short ondisk;
2633
+ struct entry_short *ondisk;
2721
2634
  size_t path_len, disk_size;
2722
2635
  int varint_len = 0;
2723
2636
  char *path;
@@ -2745,7 +2658,9 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
2745
2658
  if (git_filebuf_reserve(file, &mem, disk_size) < 0)
2746
2659
  return -1;
2747
2660
 
2748
- memset(mem, 0x0, disk_size);
2661
+ ondisk = (struct entry_short *)mem;
2662
+
2663
+ memset(ondisk, 0x0, disk_size);
2749
2664
 
2750
2665
  /**
2751
2666
  * Yes, we have to truncate.
@@ -2757,32 +2672,30 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
2757
2672
  *
2758
2673
  * In 2038 I will be either too dead or too rich to care about this
2759
2674
  */
2760
- ondisk.ctime.seconds = htonl((uint32_t)entry->ctime.seconds);
2761
- ondisk.mtime.seconds = htonl((uint32_t)entry->mtime.seconds);
2762
- ondisk.ctime.nanoseconds = htonl(entry->ctime.nanoseconds);
2763
- ondisk.mtime.nanoseconds = htonl(entry->mtime.nanoseconds);
2764
- ondisk.dev = htonl(entry->dev);
2765
- ondisk.ino = htonl(entry->ino);
2766
- ondisk.mode = htonl(entry->mode);
2767
- ondisk.uid = htonl(entry->uid);
2768
- ondisk.gid = htonl(entry->gid);
2769
- ondisk.file_size = htonl((uint32_t)entry->file_size);
2770
-
2771
- git_oid_cpy(&ondisk.oid, &entry->id);
2772
-
2773
- ondisk.flags = htons(entry->flags);
2774
-
2775
- if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {
2776
- struct entry_long ondisk_ext;
2777
- memcpy(&ondisk_ext, &ondisk, sizeof(struct entry_short));
2778
- ondisk_ext.flags_extended = htons(entry->flags_extended &
2779
- GIT_INDEX_ENTRY_EXTENDED_FLAGS);
2780
- memcpy(mem, &ondisk_ext, offsetof(struct entry_long, path));
2781
- path = ((struct entry_long*)mem)->path;
2675
+ ondisk->ctime.seconds = htonl((uint32_t)entry->ctime.seconds);
2676
+ ondisk->mtime.seconds = htonl((uint32_t)entry->mtime.seconds);
2677
+ ondisk->ctime.nanoseconds = htonl(entry->ctime.nanoseconds);
2678
+ ondisk->mtime.nanoseconds = htonl(entry->mtime.nanoseconds);
2679
+ ondisk->dev = htonl(entry->dev);
2680
+ ondisk->ino = htonl(entry->ino);
2681
+ ondisk->mode = htonl(entry->mode);
2682
+ ondisk->uid = htonl(entry->uid);
2683
+ ondisk->gid = htonl(entry->gid);
2684
+ ondisk->file_size = htonl((uint32_t)entry->file_size);
2685
+
2686
+ git_oid_cpy(&ondisk->oid, &entry->id);
2687
+
2688
+ ondisk->flags = htons(entry->flags);
2689
+
2690
+ if (entry->flags & GIT_IDXENTRY_EXTENDED) {
2691
+ struct entry_long *ondisk_ext;
2692
+ ondisk_ext = (struct entry_long *)ondisk;
2693
+ ondisk_ext->flags_extended = htons(entry->flags_extended &
2694
+ GIT_IDXENTRY_EXTENDED_FLAGS);
2695
+ path = ondisk_ext->path;
2782
2696
  disk_size -= offsetof(struct entry_long, path);
2783
2697
  } else {
2784
- memcpy(mem, &ondisk, offsetof(struct entry_short, path));
2785
- path = ((struct entry_short*)mem)->path;
2698
+ path = ondisk->path;
2786
2699
  disk_size -= offsetof(struct entry_short, path);
2787
2700
  }
2788
2701
 
@@ -2907,7 +2820,7 @@ static int write_name_extension(git_index *index, git_filebuf *file)
2907
2820
 
2908
2821
  error = write_extension(file, &extension, &name_buf);
2909
2822
 
2910
- git_buf_dispose(&name_buf);
2823
+ git_buf_free(&name_buf);
2911
2824
 
2912
2825
  done:
2913
2826
  return error;
@@ -2955,7 +2868,7 @@ static int write_reuc_extension(git_index *index, git_filebuf *file)
2955
2868
 
2956
2869
  error = write_extension(file, &extension, &reuc_buf);
2957
2870
 
2958
- git_buf_dispose(&reuc_buf);
2871
+ git_buf_free(&reuc_buf);
2959
2872
 
2960
2873
  done:
2961
2874
  return error;
@@ -2979,7 +2892,7 @@ static int write_tree_extension(git_index *index, git_filebuf *file)
2979
2892
 
2980
2893
  error = write_extension(file, &extension, &buf);
2981
2894
 
2982
- git_buf_dispose(&buf);
2895
+ git_buf_free(&buf);
2983
2896
 
2984
2897
  return error;
2985
2898
  }
@@ -2990,7 +2903,7 @@ static void clear_uptodate(git_index *index)
2990
2903
  size_t i;
2991
2904
 
2992
2905
  git_vector_foreach(&index->entries, i, entry)
2993
- entry->flags_extended &= ~GIT_INDEX_ENTRY_UPTODATE;
2906
+ entry->flags_extended &= ~GIT_IDXENTRY_UPTODATE;
2994
2907
  }
2995
2908
 
2996
2909
  static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
@@ -3047,12 +2960,12 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
3047
2960
 
3048
2961
  int git_index_entry_stage(const git_index_entry *entry)
3049
2962
  {
3050
- return GIT_INDEX_ENTRY_STAGE(entry);
2963
+ return GIT_IDXENTRY_STAGE(entry);
3051
2964
  }
3052
2965
 
3053
2966
  int git_index_entry_is_conflict(const git_index_entry *entry)
3054
2967
  {
3055
- return (GIT_INDEX_ENTRY_STAGE(entry) > 0);
2968
+ return (GIT_IDXENTRY_STAGE(entry) > 0);
3056
2969
  }
3057
2970
 
3058
2971
  typedef struct read_tree_data {
@@ -3096,7 +3009,7 @@ static int read_tree_cb(
3096
3009
  }
3097
3010
 
3098
3011
  index_entry_adjust_namemask(entry, path.size);
3099
- git_buf_dispose(&path);
3012
+ git_buf_free(&path);
3100
3013
 
3101
3014
  if (git_vector_insert(data->new_entries, entry) < 0) {
3102
3015
  index_entry_free(entry);
@@ -3115,7 +3028,7 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3115
3028
  size_t i;
3116
3029
  git_index_entry *e;
3117
3030
 
3118
- if (git_idxmap_new(&entries_map) < 0)
3031
+ if (git_idxmap_alloc(&entries_map) < 0)
3119
3032
  return -1;
3120
3033
 
3121
3034
  git_vector_set_cmp(&entries, index->entries._cmp); /* match sort */
@@ -3133,18 +3046,16 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3133
3046
  if ((error = git_tree_walk(tree, GIT_TREEWALK_POST, read_tree_cb, &data)) < 0)
3134
3047
  goto cleanup;
3135
3048
 
3136
- if (index->ignore_case &&
3137
- (error = git_idxmap_icase_resize((git_idxmap_icase *) entries_map,
3138
- entries.length)) < 0)
3139
- goto cleanup;
3140
- else if ((error = git_idxmap_resize(entries_map, entries.length)) < 0)
3141
- goto cleanup;
3049
+ if (index->ignore_case)
3050
+ git_idxmap_icase_resize((khash_t(idxicase) *) entries_map, entries.length);
3051
+ else
3052
+ git_idxmap_resize(entries_map, entries.length);
3142
3053
 
3143
3054
  git_vector_foreach(&entries, i, e) {
3144
- INSERT_IN_MAP_EX(index, entries_map, e, error);
3055
+ INSERT_IN_MAP_EX(index, entries_map, e, &error);
3145
3056
 
3146
3057
  if (error < 0) {
3147
- git_error_set(GIT_ERROR_INDEX, "failed to insert entry into map");
3058
+ giterr_set(GITERR_INDEX, "failed to insert entry into map");
3148
3059
  return error;
3149
3060
  }
3150
3061
  }
@@ -3160,8 +3071,6 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3160
3071
  entries_map = git__swap(index->entries_map, entries_map);
3161
3072
  }
3162
3073
 
3163
- index->dirty = 1;
3164
-
3165
3074
  cleanup:
3166
3075
  git_vector_free(&entries);
3167
3076
  git_idxmap_free(entries_map);
@@ -3191,17 +3100,14 @@ static int git_index_read_iterator(
3191
3100
  assert((new_iterator->flags & GIT_ITERATOR_DONT_IGNORE_CASE));
3192
3101
 
3193
3102
  if ((error = git_vector_init(&new_entries, new_length_hint, index->entries._cmp)) < 0 ||
3194
- (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0 ||
3195
- (error = git_idxmap_new(&new_entries_map)) < 0)
3103
+ (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0 ||
3104
+ (error = git_idxmap_alloc(&new_entries_map)) < 0)
3196
3105
  goto done;
3197
3106
 
3198
- if (index->ignore_case && new_length_hint &&
3199
- (error = git_idxmap_icase_resize((git_idxmap_icase *) new_entries_map,
3200
- new_length_hint)) < 0)
3201
- goto done;
3202
- else if (new_length_hint &&
3203
- (error = git_idxmap_resize(new_entries_map, new_length_hint)) < 0)
3204
- goto done;
3107
+ if (index->ignore_case && new_length_hint)
3108
+ git_idxmap_icase_resize((khash_t(idxicase) *) new_entries_map, new_length_hint);
3109
+ else if (new_length_hint)
3110
+ git_idxmap_resize(new_entries_map, new_length_hint);
3205
3111
 
3206
3112
  opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE |
3207
3113
  GIT_ITERATOR_INCLUDE_CONFLICTS;
@@ -3265,14 +3171,14 @@ static int git_index_read_iterator(
3265
3171
 
3266
3172
  if (add_entry) {
3267
3173
  if ((error = git_vector_insert(&new_entries, add_entry)) == 0)
3268
- INSERT_IN_MAP_EX(index, new_entries_map, add_entry, error);
3174
+ INSERT_IN_MAP_EX(index, new_entries_map, add_entry, &error);
3269
3175
  }
3270
3176
 
3271
3177
  if (remove_entry && error >= 0)
3272
3178
  error = git_vector_insert(&remove_entries, remove_entry);
3273
3179
 
3274
3180
  if (error < 0) {
3275
- git_error_set(GIT_ERROR_INDEX, "failed to insert entry");
3181
+ giterr_set(GITERR_INDEX, "failed to insert entry");
3276
3182
  goto done;
3277
3183
  }
3278
3184
 
@@ -3304,7 +3210,6 @@ static int git_index_read_iterator(
3304
3210
 
3305
3211
  clear_uptodate(index);
3306
3212
 
3307
- index->dirty = 1;
3308
3213
  error = 0;
3309
3214
 
3310
3215
  done:
@@ -3381,7 +3286,7 @@ int git_index_add_all(
3381
3286
  error = index_apply_to_wd_diff(index, INDEX_ACTION_ADDALL, paths, flags, cb, payload);
3382
3287
 
3383
3288
  if (error)
3384
- git_error_set_after_callback(error);
3289
+ giterr_set_after_callback(error);
3385
3290
 
3386
3291
  cleanup:
3387
3292
  git_iterator_free(wditer);
@@ -3483,7 +3388,7 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr
3483
3388
  git_diff_free(diff);
3484
3389
 
3485
3390
  if (error) /* make sure error is set if callback stopped iteration */
3486
- git_error_set_after_callback(error);
3391
+ giterr_set_after_callback(error);
3487
3392
 
3488
3393
  cleanup:
3489
3394
  git_pathspec__clear(&ps);
@@ -3540,7 +3445,7 @@ static int index_apply_to_all(
3540
3445
  error = git_index_add_bypath(index, path.ptr);
3541
3446
 
3542
3447
  if (error == GIT_ENOTFOUND) {
3543
- git_error_clear();
3448
+ giterr_clear();
3544
3449
 
3545
3450
  error = git_index_remove_bypath(index, path.ptr);
3546
3451
 
@@ -3553,13 +3458,13 @@ static int index_apply_to_all(
3553
3458
  i--; /* back up foreach if we removed this */
3554
3459
  break;
3555
3460
  default:
3556
- git_error_set(GIT_ERROR_INVALID, "unknown index action %d", action);
3461
+ giterr_set(GITERR_INVALID, "unknown index action %d", action);
3557
3462
  error = -1;
3558
3463
  break;
3559
3464
  }
3560
3465
  }
3561
3466
 
3562
- git_buf_dispose(&path);
3467
+ git_buf_free(&path);
3563
3468
  git_pathspec__clear(&ps);
3564
3469
 
3565
3470
  return error;
@@ -3575,7 +3480,7 @@ int git_index_remove_all(
3575
3480
  index, INDEX_ACTION_REMOVE, pathspec, cb, payload);
3576
3481
 
3577
3482
  if (error) /* make sure error is set if callback stopped iteration */
3578
- git_error_set_after_callback(error);
3483
+ giterr_set_after_callback(error);
3579
3484
 
3580
3485
  return error;
3581
3486
  }
@@ -3588,7 +3493,7 @@ int git_index_update_all(
3588
3493
  {
3589
3494
  int error = index_apply_to_wd_diff(index, INDEX_ACTION_UPDATE, pathspec, 0, cb, payload);
3590
3495
  if (error) /* make sure error is set if callback stopped iteration */
3591
- git_error_set_after_callback(error);
3496
+ giterr_set_after_callback(error);
3592
3497
 
3593
3498
  return error;
3594
3499
  }
@@ -3644,7 +3549,7 @@ int git_indexwriter_init(
3644
3549
  &writer->file, index->index_file_path, GIT_FILEBUF_HASH_CONTENTS, GIT_INDEX_FILE_MODE)) < 0) {
3645
3550
 
3646
3551
  if (error == GIT_ELOCKED)
3647
- git_error_set(GIT_ERROR_INDEX, "the index is locked; this might be due to a concurrent or crashed process");
3552
+ giterr_set(GITERR_INDEX, "the index is locked; this might be due to a concurrent or crashed process");
3648
3553
 
3649
3554
  return error;
3650
3555
  }
@@ -3693,11 +3598,10 @@ int git_indexwriter_commit(git_indexwriter *writer)
3693
3598
 
3694
3599
  if ((error = git_futils_filestamp_check(
3695
3600
  &writer->index->stamp, writer->index->index_file_path)) < 0) {
3696
- git_error_set(GIT_ERROR_OS, "could not read index timestamp");
3601
+ giterr_set(GITERR_OS, "could not read index timestamp");
3697
3602
  return -1;
3698
3603
  }
3699
3604
 
3700
- writer->index->dirty = 0;
3701
3605
  writer->index->on_disk = 1;
3702
3606
  git_oid_cpy(&writer->index->checksum, &checksum);
3703
3607
 
@@ -3714,12 +3618,3 @@ void git_indexwriter_cleanup(git_indexwriter *writer)
3714
3618
  git_index_free(writer->index);
3715
3619
  writer->index = NULL;
3716
3620
  }
3717
-
3718
- /* Deprecated functions */
3719
-
3720
- int git_index_add_frombuffer(
3721
- git_index *index, const git_index_entry *source_entry,
3722
- const void *buffer, size_t len)
3723
- {
3724
- return git_index_add_from_buffer(index, source_entry, buffer, len);
3725
- }