rugged 0.26.7 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/rugged/rugged_blame.c +6 -3
  4. data/ext/rugged/rugged_branch_collection.c +3 -6
  5. data/ext/rugged/rugged_commit.c +56 -0
  6. data/ext/rugged/rugged_config.c +44 -9
  7. data/ext/rugged/rugged_diff.c +3 -14
  8. data/ext/rugged/rugged_diff_hunk.c +1 -3
  9. data/ext/rugged/rugged_index.c +1 -5
  10. data/ext/rugged/rugged_note.c +1 -4
  11. data/ext/rugged/rugged_patch.c +1 -4
  12. data/ext/rugged/rugged_reference_collection.c +1 -7
  13. data/ext/rugged/rugged_remote.c +5 -8
  14. data/ext/rugged/rugged_remote_collection.c +1 -6
  15. data/ext/rugged/rugged_repo.c +16 -48
  16. data/ext/rugged/rugged_revwalk.c +7 -16
  17. data/ext/rugged/rugged_settings.c +28 -0
  18. data/ext/rugged/rugged_submodule_collection.c +3 -4
  19. data/ext/rugged/rugged_tag_collection.c +1 -5
  20. data/ext/rugged/rugged_tree.c +2 -3
  21. data/lib/rugged/repository.rb +43 -0
  22. data/lib/rugged/version.rb +1 -1
  23. data/vendor/libgit2/AUTHORS +1 -0
  24. data/vendor/libgit2/CMakeLists.txt +61 -510
  25. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +14 -0
  26. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +25 -8
  27. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +27 -8
  28. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +20 -0
  29. data/vendor/libgit2/cmake/Modules/IdeSplitSources.cmake +22 -0
  30. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +3 -0
  31. data/vendor/libgit2/deps/regex/CMakeLists.txt +2 -0
  32. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +26 -0
  33. data/vendor/libgit2/deps/zlib/CMakeLists.txt +4 -0
  34. data/vendor/libgit2/include/git2/config.h +29 -2
  35. data/vendor/libgit2/include/git2/describe.h +1 -1
  36. data/vendor/libgit2/include/git2/diff.h +59 -8
  37. data/vendor/libgit2/include/git2/graph.h +3 -0
  38. data/vendor/libgit2/include/git2/merge.h +6 -0
  39. data/vendor/libgit2/include/git2/message.h +43 -3
  40. data/vendor/libgit2/include/git2/notes.h +89 -0
  41. data/vendor/libgit2/include/git2/odb.h +8 -1
  42. data/vendor/libgit2/include/git2/patch.h +2 -2
  43. data/vendor/libgit2/include/git2/pathspec.h +35 -18
  44. data/vendor/libgit2/include/git2/refs.h +3 -0
  45. data/vendor/libgit2/include/git2/remote.h +34 -4
  46. data/vendor/libgit2/include/git2/repository.h +6 -6
  47. data/vendor/libgit2/include/git2/reset.h +4 -4
  48. data/vendor/libgit2/include/git2/status.h +4 -0
  49. data/vendor/libgit2/include/git2/sys/config.h +4 -1
  50. data/vendor/libgit2/include/git2/sys/odb_backend.h +2 -1
  51. data/vendor/libgit2/include/git2/tree.h +4 -3
  52. data/vendor/libgit2/include/git2/types.h +1 -0
  53. data/vendor/libgit2/include/git2/version.h +4 -4
  54. data/vendor/libgit2/include/git2/worktree.h +1 -1
  55. data/vendor/libgit2/src/CMakeLists.txt +463 -0
  56. data/vendor/libgit2/src/annotated_commit.c +1 -1
  57. data/vendor/libgit2/src/annotated_commit.h +2 -0
  58. data/vendor/libgit2/src/apply.c +2 -1
  59. data/vendor/libgit2/src/apply.h +2 -0
  60. data/vendor/libgit2/src/attr.c +24 -4
  61. data/vendor/libgit2/src/attr.h +2 -0
  62. data/vendor/libgit2/src/attr_file.c +9 -2
  63. data/vendor/libgit2/src/attr_file.h +2 -0
  64. data/vendor/libgit2/src/attrcache.c +9 -1
  65. data/vendor/libgit2/src/attrcache.h +2 -0
  66. data/vendor/libgit2/src/blame.c +1 -0
  67. data/vendor/libgit2/src/blame.h +2 -1
  68. data/vendor/libgit2/src/blame_git.c +1 -0
  69. data/vendor/libgit2/src/blame_git.h +2 -0
  70. data/vendor/libgit2/src/blob.c +2 -2
  71. data/vendor/libgit2/src/blob.h +2 -0
  72. data/vendor/libgit2/src/branch.c +8 -1
  73. data/vendor/libgit2/src/branch.h +2 -0
  74. data/vendor/libgit2/src/buf_text.c +7 -7
  75. data/vendor/libgit2/src/buf_text.h +3 -3
  76. data/vendor/libgit2/src/buffer.c +31 -1
  77. data/vendor/libgit2/src/buffer.h +3 -0
  78. data/vendor/libgit2/src/cache.c +2 -2
  79. data/vendor/libgit2/src/cache.h +2 -0
  80. data/vendor/libgit2/src/cc-compat.h +3 -3
  81. data/vendor/libgit2/src/checkout.c +30 -19
  82. data/vendor/libgit2/src/checkout.h +2 -0
  83. data/vendor/libgit2/src/cherrypick.c +1 -0
  84. data/vendor/libgit2/src/clone.c +2 -1
  85. data/vendor/libgit2/src/clone.h +4 -0
  86. data/vendor/libgit2/src/commit.c +2 -1
  87. data/vendor/libgit2/src/commit.h +2 -0
  88. data/vendor/libgit2/src/commit_list.c +1 -1
  89. data/vendor/libgit2/src/commit_list.h +2 -0
  90. data/vendor/libgit2/src/common.h +11 -5
  91. data/vendor/libgit2/src/config.c +12 -10
  92. data/vendor/libgit2/src/config.h +2 -0
  93. data/vendor/libgit2/src/config_cache.c +1 -0
  94. data/vendor/libgit2/src/config_file.c +287 -786
  95. data/vendor/libgit2/src/config_file.h +4 -3
  96. data/vendor/libgit2/src/config_parse.c +525 -0
  97. data/vendor/libgit2/src/config_parse.h +64 -0
  98. data/vendor/libgit2/src/crlf.c +2 -1
  99. data/vendor/libgit2/src/delta.c +28 -30
  100. data/vendor/libgit2/src/delta.h +1 -0
  101. data/vendor/libgit2/src/describe.c +3 -1
  102. data/vendor/libgit2/src/diff.c +148 -2
  103. data/vendor/libgit2/src/diff.h +3 -1
  104. data/vendor/libgit2/src/diff_driver.c +12 -9
  105. data/vendor/libgit2/src/diff_driver.h +4 -1
  106. data/vendor/libgit2/src/diff_file.c +7 -4
  107. data/vendor/libgit2/src/diff_file.h +1 -0
  108. data/vendor/libgit2/src/diff_generate.c +6 -3
  109. data/vendor/libgit2/src/diff_generate.h +6 -1
  110. data/vendor/libgit2/src/diff_parse.c +5 -4
  111. data/vendor/libgit2/src/diff_parse.h +2 -0
  112. data/vendor/libgit2/src/diff_print.c +2 -0
  113. data/vendor/libgit2/src/diff_stats.c +2 -0
  114. data/vendor/libgit2/src/diff_tform.c +2 -1
  115. data/vendor/libgit2/src/diff_tform.h +4 -1
  116. data/vendor/libgit2/src/diff_xdiff.c +5 -2
  117. data/vendor/libgit2/src/diff_xdiff.h +2 -0
  118. data/vendor/libgit2/src/errors.c +2 -0
  119. data/vendor/libgit2/src/features.h.in +36 -0
  120. data/vendor/libgit2/src/fetch.c +2 -2
  121. data/vendor/libgit2/src/fetch.h +4 -0
  122. data/vendor/libgit2/src/fetchhead.c +3 -3
  123. data/vendor/libgit2/src/fetchhead.h +3 -0
  124. data/vendor/libgit2/src/filebuf.c +2 -1
  125. data/vendor/libgit2/src/filebuf.h +2 -0
  126. data/vendor/libgit2/src/fileops.c +12 -1
  127. data/vendor/libgit2/src/fileops.h +7 -1
  128. data/vendor/libgit2/src/filter.c +2 -1
  129. data/vendor/libgit2/src/filter.h +1 -0
  130. data/vendor/libgit2/src/fnmatch.c +2 -2
  131. data/vendor/libgit2/src/fnmatch.h +3 -4
  132. data/vendor/libgit2/src/global.c +4 -3
  133. data/vendor/libgit2/src/global.h +1 -5
  134. data/vendor/libgit2/src/graph.c +2 -0
  135. data/vendor/libgit2/src/hash.c +0 -1
  136. data/vendor/libgit2/src/hash.h +3 -1
  137. data/vendor/libgit2/src/hash/hash_collisiondetect.h +3 -3
  138. data/vendor/libgit2/src/hash/hash_common_crypto.h +18 -5
  139. data/vendor/libgit2/src/hash/hash_generic.c +2 -2
  140. data/vendor/libgit2/src/hash/hash_generic.h +5 -3
  141. data/vendor/libgit2/src/hash/hash_openssl.h +3 -3
  142. data/vendor/libgit2/src/hash/hash_win32.c +57 -14
  143. data/vendor/libgit2/src/hash/hash_win32.h +4 -3
  144. data/vendor/libgit2/src/hashsig.c +3 -0
  145. data/vendor/libgit2/src/ident.c +2 -0
  146. data/vendor/libgit2/src/idxmap.h +2 -1
  147. data/vendor/libgit2/src/ignore.c +14 -2
  148. data/vendor/libgit2/src/ignore.h +2 -0
  149. data/vendor/libgit2/src/index.c +20 -40
  150. data/vendor/libgit2/src/index.h +2 -0
  151. data/vendor/libgit2/src/indexer.c +13 -5
  152. data/vendor/libgit2/src/indexer.h +5 -1
  153. data/vendor/libgit2/src/integer.h +1 -1
  154. data/vendor/libgit2/src/iterator.c +44 -3
  155. data/vendor/libgit2/src/iterator.h +3 -0
  156. data/vendor/libgit2/src/map.h +1 -1
  157. data/vendor/libgit2/src/merge.c +155 -33
  158. data/vendor/libgit2/src/merge.h +2 -0
  159. data/vendor/libgit2/src/merge_driver.c +2 -2
  160. data/vendor/libgit2/src/merge_driver.h +2 -0
  161. data/vendor/libgit2/src/merge_file.c +3 -0
  162. data/vendor/libgit2/src/message.h +3 -1
  163. data/vendor/libgit2/src/mwindow.c +1 -1
  164. data/vendor/libgit2/src/mwindow.h +2 -0
  165. data/vendor/libgit2/src/netops.c +75 -62
  166. data/vendor/libgit2/src/netops.h +2 -1
  167. data/vendor/libgit2/src/notes.c +164 -48
  168. data/vendor/libgit2/src/notes.h +1 -1
  169. data/vendor/libgit2/src/object.c +14 -3
  170. data/vendor/libgit2/src/object.h +4 -0
  171. data/vendor/libgit2/src/object_api.c +3 -2
  172. data/vendor/libgit2/src/odb.c +104 -38
  173. data/vendor/libgit2/src/odb.h +3 -1
  174. data/vendor/libgit2/src/odb_loose.c +414 -267
  175. data/vendor/libgit2/src/odb_mempack.c +1 -0
  176. data/vendor/libgit2/src/odb_pack.c +2 -1
  177. data/vendor/libgit2/src/offmap.h +1 -0
  178. data/vendor/libgit2/src/oid.c +2 -1
  179. data/vendor/libgit2/src/oid.h +3 -8
  180. data/vendor/libgit2/src/oidarray.c +2 -1
  181. data/vendor/libgit2/src/oidarray.h +1 -0
  182. data/vendor/libgit2/src/oidmap.h +1 -0
  183. data/vendor/libgit2/src/pack-objects.c +5 -1
  184. data/vendor/libgit2/src/pack-objects.h +1 -1
  185. data/vendor/libgit2/src/pack.c +2 -6
  186. data/vendor/libgit2/src/pack.h +2 -1
  187. data/vendor/libgit2/src/parse.c +121 -0
  188. data/vendor/libgit2/src/parse.h +61 -0
  189. data/vendor/libgit2/src/patch.c +9 -2
  190. data/vendor/libgit2/src/patch.h +2 -0
  191. data/vendor/libgit2/src/patch_generate.c +6 -5
  192. data/vendor/libgit2/src/patch_generate.h +1 -0
  193. data/vendor/libgit2/src/patch_parse.c +265 -276
  194. data/vendor/libgit2/src/patch_parse.h +6 -11
  195. data/vendor/libgit2/src/path.c +24 -181
  196. data/vendor/libgit2/src/path.h +14 -73
  197. data/vendor/libgit2/src/pathspec.c +2 -1
  198. data/vendor/libgit2/src/pathspec.h +2 -1
  199. data/vendor/libgit2/src/pool.c +8 -0
  200. data/vendor/libgit2/src/pool.h +1 -0
  201. data/vendor/libgit2/src/posix.c +2 -1
  202. data/vendor/libgit2/src/posix.h +1 -0
  203. data/vendor/libgit2/src/pqueue.c +1 -0
  204. data/vendor/libgit2/src/pqueue.h +2 -0
  205. data/vendor/libgit2/src/proxy.c +2 -1
  206. data/vendor/libgit2/src/proxy.h +3 -1
  207. data/vendor/libgit2/src/push.c +4 -171
  208. data/vendor/libgit2/src/push.h +2 -0
  209. data/vendor/libgit2/src/rebase.c +1 -0
  210. data/vendor/libgit2/src/refdb.c +2 -3
  211. data/vendor/libgit2/src/refdb.h +2 -0
  212. data/vendor/libgit2/src/refdb_fs.c +5 -3
  213. data/vendor/libgit2/src/refdb_fs.h +4 -0
  214. data/vendor/libgit2/src/reflog.c +1 -0
  215. data/vendor/libgit2/src/reflog.h +2 -1
  216. data/vendor/libgit2/src/refs.c +1 -0
  217. data/vendor/libgit2/src/refs.h +2 -1
  218. data/vendor/libgit2/src/refspec.c +2 -2
  219. data/vendor/libgit2/src/refspec.h +2 -0
  220. data/vendor/libgit2/src/remote.c +56 -10
  221. data/vendor/libgit2/src/remote.h +2 -0
  222. data/vendor/libgit2/src/repository.c +16 -14
  223. data/vendor/libgit2/src/repository.h +2 -0
  224. data/vendor/libgit2/src/reset.c +6 -5
  225. data/vendor/libgit2/src/revert.c +1 -0
  226. data/vendor/libgit2/src/revparse.c +3 -5
  227. data/vendor/libgit2/src/revwalk.c +2 -2
  228. data/vendor/libgit2/src/revwalk.h +2 -0
  229. data/vendor/libgit2/src/settings.c +6 -8
  230. data/vendor/libgit2/src/sha1_lookup.c +2 -216
  231. data/vendor/libgit2/src/sha1_lookup.h +2 -6
  232. data/vendor/libgit2/src/signature.c +8 -3
  233. data/vendor/libgit2/src/signature.h +2 -0
  234. data/vendor/libgit2/src/sortedcache.c +7 -0
  235. data/vendor/libgit2/src/sortedcache.h +2 -0
  236. data/vendor/libgit2/src/stash.c +1 -0
  237. data/vendor/libgit2/src/status.c +14 -9
  238. data/vendor/libgit2/src/status.h +2 -0
  239. data/vendor/libgit2/src/{curl_stream.c → streams/curl.c} +2 -0
  240. data/vendor/libgit2/src/{curl_stream.h → streams/curl.h} +4 -2
  241. data/vendor/libgit2/src/{openssl_stream.c → streams/openssl.c} +47 -18
  242. data/vendor/libgit2/src/{openssl_stream.h → streams/openssl.h} +6 -2
  243. data/vendor/libgit2/src/{socket_stream.c → streams/socket.c} +2 -2
  244. data/vendor/libgit2/src/{socket_stream.h → streams/socket.h} +4 -2
  245. data/vendor/libgit2/src/{stransport_stream.c → streams/stransport.c} +4 -2
  246. data/vendor/libgit2/src/{stransport_stream.h → streams/stransport.h} +4 -2
  247. data/vendor/libgit2/src/{tls_stream.c → streams/tls.c} +4 -3
  248. data/vendor/libgit2/src/{tls_stream.h → streams/tls.h} +4 -2
  249. data/vendor/libgit2/src/submodule.c +28 -80
  250. data/vendor/libgit2/src/submodule.h +2 -13
  251. data/vendor/libgit2/src/sysdir.c +75 -8
  252. data/vendor/libgit2/src/sysdir.h +2 -1
  253. data/vendor/libgit2/src/tag.c +2 -2
  254. data/vendor/libgit2/src/tag.h +2 -0
  255. data/vendor/libgit2/src/thread-utils.c +1 -0
  256. data/vendor/libgit2/src/thread-utils.h +1 -1
  257. data/vendor/libgit2/src/trace.c +2 -2
  258. data/vendor/libgit2/src/trace.h +2 -0
  259. data/vendor/libgit2/src/trailer.c +416 -0
  260. data/vendor/libgit2/src/transaction.c +2 -1
  261. data/vendor/libgit2/src/transport.c +2 -0
  262. data/vendor/libgit2/src/transports/auth.c +2 -1
  263. data/vendor/libgit2/src/transports/auth.h +4 -3
  264. data/vendor/libgit2/src/transports/auth_negotiate.c +2 -1
  265. data/vendor/libgit2/src/transports/auth_negotiate.h +3 -3
  266. data/vendor/libgit2/src/transports/cred.c +2 -0
  267. data/vendor/libgit2/src/transports/cred.h +4 -2
  268. data/vendor/libgit2/src/transports/cred_helpers.c +1 -0
  269. data/vendor/libgit2/src/transports/git.c +3 -1
  270. data/vendor/libgit2/src/transports/http.c +10 -14
  271. data/vendor/libgit2/src/transports/http.h +23 -0
  272. data/vendor/libgit2/src/transports/local.c +23 -5
  273. data/vendor/libgit2/src/transports/smart.c +3 -1
  274. data/vendor/libgit2/src/transports/smart.h +23 -16
  275. data/vendor/libgit2/src/transports/smart_pkt.c +114 -130
  276. data/vendor/libgit2/src/transports/smart_protocol.c +26 -22
  277. data/vendor/libgit2/src/transports/ssh.c +12 -7
  278. data/vendor/libgit2/src/transports/ssh.h +4 -2
  279. data/vendor/libgit2/src/transports/winhttp.c +19 -21
  280. data/vendor/libgit2/src/tree-cache.c +1 -0
  281. data/vendor/libgit2/src/tree-cache.h +1 -0
  282. data/vendor/libgit2/src/tree.c +20 -14
  283. data/vendor/libgit2/src/tree.h +2 -0
  284. data/vendor/libgit2/src/tsort.c +0 -1
  285. data/vendor/libgit2/src/unix/map.c +4 -1
  286. data/vendor/libgit2/src/unix/posix.h +8 -4
  287. data/vendor/libgit2/src/unix/pthread.h +1 -1
  288. data/vendor/libgit2/src/unix/realpath.c +4 -1
  289. data/vendor/libgit2/src/util.c +6 -5
  290. data/vendor/libgit2/src/util.h +39 -111
  291. data/vendor/libgit2/src/varint.c +0 -1
  292. data/vendor/libgit2/src/varint.h +2 -0
  293. data/vendor/libgit2/src/vector.c +1 -1
  294. data/vendor/libgit2/src/win32/dir.c +3 -0
  295. data/vendor/libgit2/src/win32/dir.h +4 -3
  296. data/vendor/libgit2/src/win32/error.c +1 -1
  297. data/vendor/libgit2/src/win32/error.h +4 -2
  298. data/vendor/libgit2/src/win32/findfile.c +2 -1
  299. data/vendor/libgit2/src/win32/findfile.h +4 -2
  300. data/vendor/libgit2/src/win32/map.c +2 -0
  301. data/vendor/libgit2/src/win32/mingw-compat.h +3 -3
  302. data/vendor/libgit2/src/win32/msvc-compat.h +3 -3
  303. data/vendor/libgit2/src/win32/path_w32.c +7 -12
  304. data/vendor/libgit2/src/win32/path_w32.h +3 -2
  305. data/vendor/libgit2/src/win32/posix.h +2 -2
  306. data/vendor/libgit2/src/win32/posix_w32.c +11 -5
  307. data/vendor/libgit2/src/win32/precompiled.h +2 -1
  308. data/vendor/libgit2/src/win32/reparse.h +2 -2
  309. data/vendor/libgit2/src/win32/thread.c +1 -0
  310. data/vendor/libgit2/src/win32/thread.h +2 -2
  311. data/vendor/libgit2/src/win32/utf-conv.c +0 -1
  312. data/vendor/libgit2/src/win32/utf-conv.h +4 -3
  313. data/vendor/libgit2/src/win32/w32_buffer.c +1 -1
  314. data/vendor/libgit2/src/win32/w32_buffer.h +4 -2
  315. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +2 -1
  316. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +85 -2
  317. data/vendor/libgit2/src/win32/w32_stack.c +2 -1
  318. data/vendor/libgit2/src/win32/w32_stack.h +5 -3
  319. data/vendor/libgit2/src/win32/w32_util.h +4 -2
  320. data/vendor/libgit2/src/win32/win32-compat.h +3 -3
  321. data/vendor/libgit2/src/worktree.c +4 -5
  322. data/vendor/libgit2/src/worktree.h +2 -0
  323. data/vendor/libgit2/src/xdiff/xdiff.h +22 -13
  324. data/vendor/libgit2/src/xdiff/xdiffi.c +523 -81
  325. data/vendor/libgit2/src/xdiff/xdiffi.h +2 -2
  326. data/vendor/libgit2/src/xdiff/xemit.c +63 -39
  327. data/vendor/libgit2/src/xdiff/xemit.h +2 -2
  328. data/vendor/libgit2/src/xdiff/xhistogram.c +0 -1
  329. data/vendor/libgit2/src/xdiff/xinclude.h +3 -2
  330. data/vendor/libgit2/src/xdiff/xmacros.h +2 -2
  331. data/vendor/libgit2/src/xdiff/xmerge.c +80 -20
  332. data/vendor/libgit2/src/xdiff/xpatience.c +41 -9
  333. data/vendor/libgit2/src/xdiff/xprepare.c +2 -2
  334. data/vendor/libgit2/src/xdiff/xprepare.h +2 -2
  335. data/vendor/libgit2/src/xdiff/xtypes.h +2 -2
  336. data/vendor/libgit2/src/xdiff/xutils.c +47 -27
  337. data/vendor/libgit2/src/xdiff/xutils.h +2 -5
  338. data/vendor/libgit2/src/zstream.c +65 -45
  339. data/vendor/libgit2/src/zstream.h +9 -2
  340. metadata +27 -13
  341. data/vendor/libgit2/include/git2/sys/remote.h +0 -16
@@ -5,225 +5,11 @@
5
5
  * a Linking Exception. For full terms see the included COPYING file.
6
6
  */
7
7
 
8
- #include <stdio.h>
9
-
10
8
  #include "sha1_lookup.h"
11
- #include "common.h"
12
- #include "oid.h"
13
9
 
14
- /*
15
- * Conventional binary search loop looks like this:
16
- *
17
- * unsigned lo, hi;
18
- * do {
19
- * unsigned mi = (lo + hi) / 2;
20
- * int cmp = "entry pointed at by mi" minus "target";
21
- * if (!cmp)
22
- * return (mi is the wanted one)
23
- * if (cmp > 0)
24
- * hi = mi; "mi is larger than target"
25
- * else
26
- * lo = mi+1; "mi is smaller than target"
27
- * } while (lo < hi);
28
- *
29
- * The invariants are:
30
- *
31
- * - When entering the loop, lo points at a slot that is never
32
- * above the target (it could be at the target), hi points at a
33
- * slot that is guaranteed to be above the target (it can never
34
- * be at the target).
35
- *
36
- * - We find a point 'mi' between lo and hi (mi could be the same
37
- * as lo, but never can be as same as hi), and check if it hits
38
- * the target. There are three cases:
39
- *
40
- * - if it is a hit, we are happy.
41
- *
42
- * - if it is strictly higher than the target, we set it to hi,
43
- * and repeat the search.
44
- *
45
- * - if it is strictly lower than the target, we update lo to
46
- * one slot after it, because we allow lo to be at the target.
47
- *
48
- * If the loop exits, there is no matching entry.
49
- *
50
- * When choosing 'mi', we do not have to take the "middle" but
51
- * anywhere in between lo and hi, as long as lo <= mi < hi is
52
- * satisfied. When we somehow know that the distance between the
53
- * target and lo is much shorter than the target and hi, we could
54
- * pick mi that is much closer to lo than the midway.
55
- *
56
- * Now, we can take advantage of the fact that SHA-1 is a good hash
57
- * function, and as long as there are enough entries in the table, we
58
- * can expect uniform distribution. An entry that begins with for
59
- * example "deadbeef..." is much likely to appear much later than in
60
- * the midway of the table. It can reasonably be expected to be near
61
- * 87% (222/256) from the top of the table.
62
- *
63
- * However, we do not want to pick "mi" too precisely. If the entry at
64
- * the 87% in the above example turns out to be higher than the target
65
- * we are looking for, we would end up narrowing the search space down
66
- * only by 13%, instead of 50% we would get if we did a simple binary
67
- * search. So we would want to hedge our bets by being less aggressive.
68
- *
69
- * The table at "table" holds at least "nr" entries of "elem_size"
70
- * bytes each. Each entry has the SHA-1 key at "key_offset". The
71
- * table is sorted by the SHA-1 key of the entries. The caller wants
72
- * to find the entry with "key", and knows that the entry at "lo" is
73
- * not higher than the entry it is looking for, and that the entry at
74
- * "hi" is higher than the entry it is looking for.
75
- */
76
- int sha1_entry_pos(const void *table,
77
- size_t elem_size,
78
- size_t key_offset,
79
- unsigned lo, unsigned hi, unsigned nr,
80
- const unsigned char *key)
81
- {
82
- const unsigned char *base = (const unsigned char*)table;
83
- const unsigned char *hi_key, *lo_key;
84
- unsigned ofs_0;
85
-
86
- if (!nr || lo >= hi)
87
- return -1;
88
-
89
- if (nr == hi)
90
- hi_key = NULL;
91
- else
92
- hi_key = base + elem_size * hi + key_offset;
93
- lo_key = base + elem_size * lo + key_offset;
94
-
95
- ofs_0 = 0;
96
- do {
97
- int cmp;
98
- unsigned ofs, mi, range;
99
- unsigned lov, hiv, kyv;
100
- const unsigned char *mi_key;
101
-
102
- range = hi - lo;
103
- if (hi_key) {
104
- for (ofs = ofs_0; ofs < 20; ofs++)
105
- if (lo_key[ofs] != hi_key[ofs])
106
- break;
107
- ofs_0 = ofs;
108
- /*
109
- * byte 0 thru (ofs-1) are the same between
110
- * lo and hi; ofs is the first byte that is
111
- * different.
112
- *
113
- * If ofs==20, then no bytes are different,
114
- * meaning we have entries with duplicate
115
- * keys. We know that we are in a solid run
116
- * of this entry (because the entries are
117
- * sorted, and our lo and hi are the same,
118
- * there can be nothing but this single key
119
- * in between). So we can stop the search.
120
- * Either one of these entries is it (and
121
- * we do not care which), or we do not have
122
- * it.
123
- *
124
- * Furthermore, we know that one of our
125
- * endpoints must be the edge of the run of
126
- * duplicates. For example, given this
127
- * sequence:
128
- *
129
- * idx 0 1 2 3 4 5
130
- * key A C C C C D
131
- *
132
- * If we are searching for "B", we might
133
- * hit the duplicate run at lo=1, hi=3
134
- * (e.g., by first mi=3, then mi=0). But we
135
- * can never have lo > 1, because B < C.
136
- * That is, if our key is less than the
137
- * run, we know that "lo" is the edge, but
138
- * we can say nothing of "hi". Similarly,
139
- * if our key is greater than the run, we
140
- * know that "hi" is the edge, but we can
141
- * say nothing of "lo".
142
- *
143
- * Therefore if we do not find it, we also
144
- * know where it would go if it did exist:
145
- * just on the far side of the edge that we
146
- * know about.
147
- */
148
- if (ofs == 20) {
149
- mi = lo;
150
- mi_key = base + elem_size * mi + key_offset;
151
- cmp = memcmp(mi_key, key, 20);
152
- if (!cmp)
153
- return mi;
154
- if (cmp < 0)
155
- return -1 - hi;
156
- else
157
- return -1 - lo;
158
- }
159
-
160
- hiv = hi_key[ofs_0];
161
- if (ofs_0 < 19)
162
- hiv = (hiv << 8) | hi_key[ofs_0+1];
163
- } else {
164
- hiv = 256;
165
- if (ofs_0 < 19)
166
- hiv <<= 8;
167
- }
168
- lov = lo_key[ofs_0];
169
- kyv = key[ofs_0];
170
- if (ofs_0 < 19) {
171
- lov = (lov << 8) | lo_key[ofs_0+1];
172
- kyv = (kyv << 8) | key[ofs_0+1];
173
- }
174
- assert(lov < hiv);
175
-
176
- if (kyv < lov)
177
- return -1 - lo;
178
- if (hiv < kyv)
179
- return -1 - hi;
180
-
181
- /*
182
- * Even if we know the target is much closer to 'hi'
183
- * than 'lo', if we pick too precisely and overshoot
184
- * (e.g. when we know 'mi' is closer to 'hi' than to
185
- * 'lo', pick 'mi' that is higher than the target), we
186
- * end up narrowing the search space by a smaller
187
- * amount (i.e. the distance between 'mi' and 'hi')
188
- * than what we would have (i.e. about half of 'lo'
189
- * and 'hi'). Hedge our bets to pick 'mi' less
190
- * aggressively, i.e. make 'mi' a bit closer to the
191
- * middle than we would otherwise pick.
192
- */
193
- kyv = (kyv * 6 + lov + hiv) / 8;
194
- if (lov < hiv - 1) {
195
- if (kyv == lov)
196
- kyv++;
197
- else if (kyv == hiv)
198
- kyv--;
199
- }
200
- mi = (range - 1) * (kyv - lov) / (hiv - lov) + lo;
201
-
202
- #ifdef INDEX_DEBUG_LOOKUP
203
- printf("lo %u hi %u rg %u mi %u ", lo, hi, range, mi);
204
- printf("ofs %u lov %x, hiv %x, kyv %x\n",
205
- ofs_0, lov, hiv, kyv);
206
- #endif
207
-
208
- if (!(lo <= mi && mi < hi)) {
209
- giterr_set(GITERR_INVALID, "assertion failure: binary search invariant is false");
210
- return -1;
211
- }
10
+ #include <stdio.h>
212
11
 
213
- mi_key = base + elem_size * mi + key_offset;
214
- cmp = memcmp(mi_key + ofs_0, key + ofs_0, 20 - ofs_0);
215
- if (!cmp)
216
- return mi;
217
- if (cmp > 0) {
218
- hi = mi;
219
- hi_key = mi_key;
220
- } else {
221
- lo = mi + 1;
222
- lo_key = mi_key + elem_size;
223
- }
224
- } while (lo < hi);
225
- return -((int)lo)-1;
226
- }
12
+ #include "oid.h"
227
13
 
228
14
  int sha1_position(const void *table,
229
15
  size_t stride,
@@ -7,13 +7,9 @@
7
7
  #ifndef INCLUDE_sha1_lookup_h__
8
8
  #define INCLUDE_sha1_lookup_h__
9
9
 
10
- #include <stdlib.h>
10
+ #include "common.h"
11
11
 
12
- int sha1_entry_pos(const void *table,
13
- size_t elem_size,
14
- size_t key_offset,
15
- unsigned lo, unsigned hi, unsigned nr,
16
- const unsigned char *key);
12
+ #include <stdlib.h>
17
13
 
18
14
  int sha1_position(const void *table,
19
15
  size_t stride,
@@ -5,8 +5,8 @@
5
5
  * a Linking Exception. For full terms see the included COPYING file.
6
6
  */
7
7
 
8
- #include "common.h"
9
8
  #include "signature.h"
9
+
10
10
  #include "repository.h"
11
11
  #include "git2/common.h"
12
12
  #include "posix.h"
@@ -90,6 +90,7 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
90
90
 
91
91
  p->when.time = time;
92
92
  p->when.offset = offset;
93
+ p->when.sign = (offset < 0) ? '-' : '+';
93
94
 
94
95
  *sig_out = p;
95
96
  return 0;
@@ -113,6 +114,7 @@ int git_signature_dup(git_signature **dest, const git_signature *source)
113
114
 
114
115
  signature->when.time = source->when.time;
115
116
  signature->when.offset = source->when.offset;
117
+ signature->when.sign = source->when.sign;
116
118
 
117
119
  *dest = signature;
118
120
 
@@ -137,6 +139,7 @@ int git_signature__pdup(git_signature **dest, const git_signature *source, git_p
137
139
 
138
140
  signature->when.time = source->when.time;
139
141
  signature->when.offset = source->when.offset;
142
+ signature->when.sign = source->when.sign;
140
143
 
141
144
  *dest = signature;
142
145
 
@@ -257,6 +260,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
257
260
  */
258
261
  if (hours <= 14 && mins <= 59) {
259
262
  sig->when.offset = (hours * 60) + mins;
263
+ sig->when.sign = tz_start[0];
260
264
  if (tz_start[0] == '-')
261
265
  sig->when.offset = -sig->when.offset;
262
266
  }
@@ -299,7 +303,7 @@ void git_signature__writebuf(git_buf *buf, const char *header, const git_signatu
299
303
  assert(buf && sig);
300
304
 
301
305
  offset = sig->when.offset;
302
- sign = (sig->when.offset < 0) ? '-' : '+';
306
+ sign = (sig->when.offset < 0 || sig->when.sign == '-') ? '-' : '+';
303
307
 
304
308
  if (offset < 0)
305
309
  offset = -offset;
@@ -320,6 +324,7 @@ bool git_signature__equal(const git_signature *one, const git_signature *two)
320
324
  git__strcmp(one->name, two->name) == 0 &&
321
325
  git__strcmp(one->email, two->email) == 0 &&
322
326
  one->when.time == two->when.time &&
323
- one->when.offset == two->when.offset;
327
+ one->when.offset == two->when.offset &&
328
+ one->when.sign == two->when.sign;
324
329
  }
325
330
 
@@ -7,6 +7,8 @@
7
7
  #ifndef INCLUDE_signature_h__
8
8
  #define INCLUDE_signature_h__
9
9
 
10
+ #include "common.h"
11
+
10
12
  #include "git2/common.h"
11
13
  #include "git2/signature.h"
12
14
  #include "repository.h"
@@ -1,3 +1,10 @@
1
+ /*
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
+ *
4
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
5
+ * a Linking Exception. For full terms see the included COPYING file.
6
+ */
7
+
1
8
  #include "sortedcache.h"
2
9
 
3
10
  int git_sortedcache_new(
@@ -7,6 +7,8 @@
7
7
  #ifndef INCLUDE_sorted_cache_h__
8
8
  #define INCLUDE_sorted_cache_h__
9
9
 
10
+ #include "common.h"
11
+
10
12
  #include "util.h"
11
13
  #include "fileops.h"
12
14
  #include "vector.h"
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  #include "common.h"
9
+
9
10
  #include "repository.h"
10
11
  #include "commit.h"
11
12
  #include "message.h"
@@ -5,13 +5,13 @@
5
5
  * a Linking Exception. For full terms see the included COPYING file.
6
6
  */
7
7
 
8
- #include "common.h"
8
+ #include "status.h"
9
+
9
10
  #include "git2.h"
10
11
  #include "fileops.h"
11
12
  #include "hash.h"
12
13
  #include "vector.h"
13
14
  #include "tree.h"
14
- #include "status.h"
15
15
  #include "git2/status.h"
16
16
  #include "repository.h"
17
17
  #include "ignore.h"
@@ -280,12 +280,16 @@ int git_status_list_new(
280
280
  if ((error = git_repository__ensure_not_bare(repo, "status")) < 0 ||
281
281
  (error = git_repository_index(&index, repo)) < 0)
282
282
  return error;
283
-
284
- /* if there is no HEAD, that's okay - we'll make an empty iterator */
285
- if ((error = git_repository_head_tree(&head, repo)) < 0) {
286
- if (error != GIT_ENOTFOUND && error != GIT_EUNBORNBRANCH)
287
- goto done;
288
- giterr_clear();
283
+
284
+ if (opts != NULL && opts->baseline != NULL) {
285
+ head = opts->baseline;
286
+ } else {
287
+ /* if there is no HEAD, that's okay - we'll make an empty iterator */
288
+ if ((error = git_repository_head_tree(&head, repo)) < 0) {
289
+ if (error != GIT_ENOTFOUND && error != GIT_EUNBORNBRANCH)
290
+ goto done;
291
+ giterr_clear();
292
+ }
289
293
  }
290
294
 
291
295
  /* refresh index from disk unless prevented */
@@ -377,7 +381,8 @@ done:
377
381
 
378
382
  *out = status;
379
383
 
380
- git_tree_free(head);
384
+ if (opts == NULL || opts->baseline != head)
385
+ git_tree_free(head);
381
386
  git_index_free(index);
382
387
 
383
388
  return error;
@@ -7,6 +7,8 @@
7
7
  #ifndef INCLUDE_status_h__
8
8
  #define INCLUDE_status_h__
9
9
 
10
+ #include "common.h"
11
+
10
12
  #include "diff.h"
11
13
  #include "git2/status.h"
12
14
  #include "git2/diff.h"
@@ -5,6 +5,8 @@
5
5
  * a Linking Exception. For full terms see the included COPYING file.
6
6
  */
7
7
 
8
+ #include "streams/curl.h"
9
+
8
10
  #ifdef GIT_CURL
9
11
 
10
12
  #include <curl/curl.h>
@@ -4,8 +4,10 @@
4
4
  * This file is part of libgit2, distributed under the GNU GPL v2 with
5
5
  * a Linking Exception. For full terms see the included COPYING file.
6
6
  */
7
- #ifndef INCLUDE_curl_stream_h__
8
- #define INCLUDE_curl_stream_h__
7
+ #ifndef INCLUDE_streams_curl_h__
8
+ #define INCLUDE_streams_curl_h__
9
+
10
+ #include "common.h"
9
11
 
10
12
  #include "git2/sys/stream.h"
11
13
 
@@ -5,6 +5,8 @@
5
5
  * a Linking Exception. For full terms see the included COPYING file.
6
6
  */
7
7
 
8
+ #include "streams/openssl.h"
9
+
8
10
  #ifdef GIT_OPENSSL
9
11
 
10
12
  #include <ctype.h>
@@ -12,14 +14,13 @@
12
14
  #include "global.h"
13
15
  #include "posix.h"
14
16
  #include "stream.h"
15
- #include "socket_stream.h"
16
- #include "openssl_stream.h"
17
+ #include "streams/socket.h"
17
18
  #include "netops.h"
18
19
  #include "git2/transport.h"
19
20
  #include "git2/sys/openssl.h"
20
21
 
21
22
  #ifdef GIT_CURL
22
- # include "curl_stream.h"
23
+ # include "streams/curl.h"
23
24
  #endif
24
25
 
25
26
  #ifndef GIT_WIN32
@@ -335,7 +336,7 @@ static int check_host_name(const char *name, const char *host)
335
336
 
336
337
  static int verify_server_cert(SSL *ssl, const char *host)
337
338
  {
338
- X509 *cert;
339
+ X509 *cert = NULL;
339
340
  X509_NAME *peer_name;
340
341
  ASN1_STRING *str;
341
342
  unsigned char *peer_cn = NULL;
@@ -343,8 +344,8 @@ static int verify_server_cert(SSL *ssl, const char *host)
343
344
  GENERAL_NAMES *alts;
344
345
  struct in6_addr addr6;
345
346
  struct in_addr addr4;
346
- void *addr;
347
- int i = -1,j;
347
+ void *addr = NULL;
348
+ int i = -1, j, error = 0;
348
349
 
349
350
  if (SSL_get_verify_result(ssl) != X509_V_OK) {
350
351
  giterr_set(GITERR_SSL, "the SSL certificate is invalid");
@@ -356,7 +357,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
356
357
  type = GEN_IPADD;
357
358
  addr = &addr4;
358
359
  } else {
359
- if(p_inet_pton(AF_INET6, host, &addr6)) {
360
+ if (p_inet_pton(AF_INET6, host, &addr6)) {
360
361
  type = GEN_IPADD;
361
362
  addr = &addr6;
362
363
  }
@@ -365,8 +366,9 @@ static int verify_server_cert(SSL *ssl, const char *host)
365
366
 
366
367
  cert = SSL_get_peer_certificate(ssl);
367
368
  if (!cert) {
369
+ error = -1;
368
370
  giterr_set(GITERR_SSL, "the server did not provide a certificate");
369
- return -1;
371
+ goto cleanup;
370
372
  }
371
373
 
372
374
  /* Check the alternative names */
@@ -395,7 +397,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
395
397
  matched = 1;
396
398
  } else if (type == GEN_IPADD) {
397
399
  /* Here name isn't so much a name but a binary representation of the IP */
398
- matched = !!memcmp(name, addr, namelen);
400
+ matched = addr && !!memcmp(name, addr, namelen);
399
401
  }
400
402
  }
401
403
  }
@@ -404,8 +406,9 @@ static int verify_server_cert(SSL *ssl, const char *host)
404
406
  if (matched == 0)
405
407
  goto cert_fail_name;
406
408
 
407
- if (matched == 1)
408
- return 0;
409
+ if (matched == 1) {
410
+ goto cleanup;
411
+ }
409
412
 
410
413
  /* If no alternative names are available, check the common name */
411
414
  peer_name = X509_get_subject_name(cert);
@@ -447,18 +450,21 @@ static int verify_server_cert(SSL *ssl, const char *host)
447
450
  if (check_host_name((char *)peer_cn, host) < 0)
448
451
  goto cert_fail_name;
449
452
 
450
- OPENSSL_free(peer_cn);
453
+ goto cleanup;
451
454
 
452
- return 0;
455
+ cert_fail_name:
456
+ error = GIT_ECERTIFICATE;
457
+ giterr_set(GITERR_SSL, "hostname does not match certificate");
458
+ goto cleanup;
453
459
 
454
460
  on_error:
455
- OPENSSL_free(peer_cn);
456
- return ssl_set_error(ssl, 0);
461
+ error = ssl_set_error(ssl, 0);
462
+ goto cleanup;
457
463
 
458
- cert_fail_name:
464
+ cleanup:
465
+ X509_free(cert);
459
466
  OPENSSL_free(peer_cn);
460
- giterr_set(GITERR_SSL, "hostname does not match certificate");
461
- return GIT_ECERTIFICATE;
467
+ return error;
462
468
  }
463
469
 
464
470
  typedef struct {
@@ -640,6 +646,20 @@ out_err:
640
646
  return error;
641
647
  }
642
648
 
649
+ int git_openssl__set_cert_location(const char *file, const char *path)
650
+ {
651
+ if (SSL_CTX_load_verify_locations(git__ssl_ctx, file, path) == 0) {
652
+ char errmsg[256];
653
+
654
+ ERR_error_string_n(ERR_get_error(), errmsg, sizeof(errmsg));
655
+ giterr_set(GITERR_SSL, "OpenSSL error: failed to load certificates: %s",
656
+ errmsg);
657
+
658
+ return -1;
659
+ }
660
+ return 0;
661
+ }
662
+
643
663
  #else
644
664
 
645
665
  #include "stream.h"
@@ -666,4 +686,13 @@ int git_openssl_stream_new(git_stream **out, const char *host, const char *port)
666
686
  return -1;
667
687
  }
668
688
 
689
+ int git_openssl__set_cert_location(const char *file, const char *path)
690
+ {
691
+ GIT_UNUSED(file);
692
+ GIT_UNUSED(path);
693
+
694
+ giterr_set(GITERR_SSL, "openssl is not supported in this version");
695
+ return -1;
696
+ }
697
+
669
698
  #endif