rugged 0.1.2 → 0.16.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (277) hide show
  1. data/README.md +25 -36
  2. data/Rakefile +20 -98
  3. data/ext/rugged/extconf.rb +44 -4
  4. data/ext/rugged/remote.c +215 -0
  5. data/ext/rugged/rugged.c +171 -0
  6. data/ext/rugged/rugged.h +126 -0
  7. data/ext/rugged/rugged_blob.c +99 -0
  8. data/ext/rugged/rugged_commit.c +224 -0
  9. data/ext/rugged/rugged_config.c +238 -0
  10. data/ext/rugged/rugged_index.c +440 -0
  11. data/ext/rugged/rugged_object.c +203 -0
  12. data/ext/rugged/rugged_reference.c +401 -0
  13. data/ext/rugged/rugged_repo.c +482 -0
  14. data/ext/rugged/rugged_revwalk.c +138 -0
  15. data/ext/rugged/rugged_signature.c +80 -0
  16. data/ext/rugged/rugged_tag.c +216 -0
  17. data/ext/rugged/rugged_tree.c +322 -0
  18. data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
  19. data/ext/rugged/vendor/libgit2-dist/deps/http-parser/http_parser.c +1778 -0
  20. data/ext/rugged/vendor/libgit2-dist/deps/http-parser/http_parser.h +267 -0
  21. data/ext/rugged/vendor/libgit2-dist/deps/zlib/adler32.c +169 -0
  22. data/ext/rugged/vendor/libgit2-dist/deps/zlib/crc32.c +442 -0
  23. data/ext/rugged/vendor/libgit2-dist/deps/zlib/crc32.h +441 -0
  24. data/ext/rugged/vendor/libgit2-dist/deps/zlib/deflate.c +1834 -0
  25. data/ext/rugged/vendor/libgit2-dist/deps/zlib/deflate.h +342 -0
  26. data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffast.c +340 -0
  27. data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffast.h +11 -0
  28. data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffixed.h +94 -0
  29. data/ext/rugged/vendor/libgit2-dist/deps/zlib/inflate.c +1480 -0
  30. data/ext/rugged/vendor/libgit2-dist/deps/zlib/inflate.h +122 -0
  31. data/ext/rugged/vendor/libgit2-dist/deps/zlib/inftrees.c +330 -0
  32. data/ext/rugged/vendor/libgit2-dist/deps/zlib/inftrees.h +62 -0
  33. data/ext/rugged/vendor/libgit2-dist/deps/zlib/trees.c +1244 -0
  34. data/ext/rugged/vendor/libgit2-dist/deps/zlib/trees.h +128 -0
  35. data/ext/rugged/vendor/libgit2-dist/deps/zlib/zconf.h +54 -0
  36. data/ext/rugged/vendor/libgit2-dist/deps/zlib/zlib.h +1613 -0
  37. data/ext/rugged/vendor/libgit2-dist/deps/zlib/zutil.c +318 -0
  38. data/ext/rugged/vendor/libgit2-dist/deps/zlib/zutil.h +274 -0
  39. data/ext/rugged/vendor/libgit2-dist/examples/general.c +451 -0
  40. data/ext/rugged/vendor/libgit2-dist/examples/network/common.h +14 -0
  41. data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +97 -0
  42. data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +58 -0
  43. data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +47 -0
  44. data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +76 -0
  45. data/ext/rugged/vendor/libgit2-dist/examples/showindex.c +43 -0
  46. data/ext/rugged/vendor/libgit2-dist/include/git2.h +44 -0
  47. data/ext/rugged/vendor/libgit2-dist/include/git2/blob.h +120 -0
  48. data/ext/rugged/vendor/libgit2-dist/include/git2/branch.h +15 -0
  49. data/ext/rugged/vendor/libgit2-dist/include/git2/commit.h +263 -0
  50. data/ext/rugged/vendor/libgit2-dist/include/git2/common.h +103 -0
  51. data/ext/rugged/vendor/libgit2-dist/include/git2/config.h +278 -0
  52. data/ext/rugged/vendor/libgit2-dist/include/git2/errors.h +144 -0
  53. data/ext/rugged/vendor/libgit2-dist/include/git2/index.h +306 -0
  54. data/ext/rugged/vendor/libgit2-dist/include/git2/indexer.h +76 -0
  55. data/ext/rugged/vendor/libgit2-dist/include/git2/inttypes.h +305 -0
  56. data/ext/rugged/vendor/libgit2-dist/include/git2/net.h +51 -0
  57. data/ext/rugged/vendor/libgit2-dist/include/git2/object.h +173 -0
  58. data/ext/rugged/vendor/libgit2-dist/include/git2/odb.h +331 -0
  59. data/ext/rugged/vendor/libgit2-dist/include/git2/odb_backend.h +100 -0
  60. data/ext/rugged/vendor/libgit2-dist/include/git2/oid.h +218 -0
  61. data/ext/rugged/vendor/libgit2-dist/include/git2/reflog.h +128 -0
  62. data/ext/rugged/vendor/libgit2-dist/include/git2/refs.h +309 -0
  63. data/ext/rugged/vendor/libgit2-dist/include/git2/refspec.h +60 -0
  64. data/ext/rugged/vendor/libgit2-dist/include/git2/remote.h +176 -0
  65. data/ext/rugged/vendor/libgit2-dist/include/git2/repository.h +290 -0
  66. data/ext/rugged/vendor/libgit2-dist/include/git2/revwalk.h +169 -0
  67. data/ext/rugged/vendor/libgit2-dist/include/git2/signature.h +65 -0
  68. data/ext/rugged/vendor/libgit2-dist/include/git2/status.h +63 -0
  69. data/ext/rugged/vendor/libgit2-dist/include/git2/stdint.h +247 -0
  70. data/ext/rugged/vendor/libgit2-dist/include/git2/tag.h +279 -0
  71. data/ext/rugged/vendor/libgit2-dist/include/git2/threads.h +48 -0
  72. data/ext/rugged/vendor/libgit2-dist/include/git2/tree.h +318 -0
  73. data/ext/rugged/vendor/libgit2-dist/include/git2/types.h +169 -0
  74. data/ext/rugged/vendor/libgit2-dist/include/git2/version.h +15 -0
  75. data/ext/rugged/vendor/libgit2-dist/include/git2/windows.h +59 -0
  76. data/ext/rugged/vendor/libgit2-dist/include/git2/zlib.h +40 -0
  77. data/ext/rugged/vendor/libgit2-dist/src/blob.c +135 -0
  78. data/ext/rugged/vendor/libgit2-dist/src/blob.h +23 -0
  79. data/ext/rugged/vendor/libgit2-dist/src/bswap.h +97 -0
  80. data/ext/rugged/vendor/libgit2-dist/src/buffer.c +113 -0
  81. data/ext/rugged/vendor/libgit2-dist/src/buffer.h +32 -0
  82. data/ext/rugged/vendor/libgit2-dist/src/cache.c +111 -0
  83. data/ext/rugged/vendor/libgit2-dist/src/cache.h +64 -0
  84. data/ext/rugged/vendor/libgit2-dist/src/cc-compat.h +67 -0
  85. data/ext/rugged/vendor/libgit2-dist/src/commit.c +299 -0
  86. data/ext/rugged/vendor/libgit2-dist/src/commit.h +34 -0
  87. data/ext/rugged/vendor/libgit2-dist/src/common.h +64 -0
  88. data/ext/rugged/vendor/libgit2-dist/src/config.c +418 -0
  89. data/ext/rugged/vendor/libgit2-dist/src/config.h +24 -0
  90. data/ext/rugged/vendor/libgit2-dist/src/config_file.c +1210 -0
  91. data/ext/rugged/vendor/libgit2-dist/src/delta-apply.c +115 -0
  92. data/ext/rugged/vendor/libgit2-dist/src/delta-apply.h +33 -0
  93. data/ext/rugged/vendor/libgit2-dist/src/dir.h +47 -0
  94. data/ext/rugged/vendor/libgit2-dist/src/errors.c +104 -0
  95. data/ext/rugged/vendor/libgit2-dist/src/fetch.c +172 -0
  96. data/ext/rugged/vendor/libgit2-dist/src/fetch.h +18 -0
  97. data/ext/rugged/vendor/libgit2-dist/src/filebuf.c +400 -0
  98. data/ext/rugged/vendor/libgit2-dist/src/filebuf.h +72 -0
  99. data/ext/rugged/vendor/libgit2-dist/src/fileops.c +358 -0
  100. data/ext/rugged/vendor/libgit2-dist/src/fileops.h +151 -0
  101. data/ext/rugged/vendor/libgit2-dist/src/global.c +134 -0
  102. data/ext/rugged/vendor/libgit2-dist/src/global.h +24 -0
  103. data/ext/rugged/vendor/libgit2-dist/src/hash.c +74 -0
  104. data/ext/rugged/vendor/libgit2-dist/src/hash.h +29 -0
  105. data/ext/rugged/vendor/libgit2-dist/src/hashtable.c +243 -0
  106. data/ext/rugged/vendor/libgit2-dist/src/hashtable.h +80 -0
  107. data/ext/rugged/vendor/libgit2-dist/src/index.c +918 -0
  108. data/ext/rugged/vendor/libgit2-dist/src/index.h +34 -0
  109. data/ext/rugged/vendor/libgit2-dist/src/indexer.c +401 -0
  110. data/ext/rugged/vendor/libgit2-dist/src/map.h +37 -0
  111. data/ext/rugged/vendor/libgit2-dist/src/mwindow.c +272 -0
  112. data/ext/rugged/vendor/libgit2-dist/src/mwindow.h +45 -0
  113. data/ext/rugged/vendor/libgit2-dist/src/netops.c +198 -0
  114. data/ext/rugged/vendor/libgit2-dist/src/netops.h +36 -0
  115. data/ext/rugged/vendor/libgit2-dist/src/object.c +295 -0
  116. data/ext/rugged/vendor/libgit2-dist/src/odb.c +672 -0
  117. data/ext/rugged/vendor/libgit2-dist/src/odb.h +43 -0
  118. data/ext/rugged/vendor/libgit2-dist/src/odb_loose.c +855 -0
  119. data/ext/rugged/vendor/libgit2-dist/src/odb_pack.c +485 -0
  120. data/ext/rugged/vendor/libgit2-dist/src/oid.c +388 -0
  121. data/ext/rugged/vendor/libgit2-dist/src/pack.c +788 -0
  122. data/ext/rugged/vendor/libgit2-dist/src/pack.h +99 -0
  123. data/ext/rugged/vendor/libgit2-dist/src/path.c +270 -0
  124. data/ext/rugged/vendor/libgit2-dist/src/path.h +84 -0
  125. data/ext/rugged/vendor/libgit2-dist/src/pkt.c +426 -0
  126. data/ext/rugged/vendor/libgit2-dist/src/pkt.h +77 -0
  127. data/ext/rugged/vendor/libgit2-dist/src/posix.c +94 -0
  128. data/ext/rugged/vendor/libgit2-dist/src/posix.h +69 -0
  129. data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.c +70 -0
  130. data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.h +26 -0
  131. data/ext/rugged/vendor/libgit2-dist/src/pqueue.c +141 -0
  132. data/ext/rugged/vendor/libgit2-dist/src/pqueue.h +81 -0
  133. data/ext/rugged/vendor/libgit2-dist/src/protocol.c +50 -0
  134. data/ext/rugged/vendor/libgit2-dist/src/protocol.h +23 -0
  135. data/ext/rugged/vendor/libgit2-dist/src/reflog.c +318 -0
  136. data/ext/rugged/vendor/libgit2-dist/src/reflog.h +34 -0
  137. data/ext/rugged/vendor/libgit2-dist/src/refs.c +1693 -0
  138. data/ext/rugged/vendor/libgit2-dist/src/refs.h +58 -0
  139. data/ext/rugged/vendor/libgit2-dist/src/refspec.c +95 -0
  140. data/ext/rugged/vendor/libgit2-dist/src/refspec.h +23 -0
  141. data/ext/rugged/vendor/libgit2-dist/src/remote.c +339 -0
  142. data/ext/rugged/vendor/libgit2-dist/src/remote.h +25 -0
  143. data/ext/rugged/vendor/libgit2-dist/src/repository.c +849 -0
  144. data/ext/rugged/vendor/libgit2-dist/src/repository.h +60 -0
  145. data/ext/rugged/vendor/libgit2-dist/src/revwalk.c +569 -0
  146. data/ext/rugged/vendor/libgit2-dist/src/sha1.c +280 -0
  147. data/ext/rugged/vendor/libgit2-dist/src/sha1.h +21 -0
  148. data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.c +177 -0
  149. data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.h +18 -0
  150. data/ext/rugged/vendor/libgit2-dist/src/signature.c +335 -0
  151. data/ext/rugged/vendor/libgit2-dist/src/signature.h +18 -0
  152. data/ext/rugged/vendor/libgit2-dist/src/status.c +696 -0
  153. data/ext/rugged/vendor/libgit2-dist/src/tag.c +446 -0
  154. data/ext/rugged/vendor/libgit2-dist/src/tag.h +28 -0
  155. data/ext/rugged/vendor/libgit2-dist/src/thread-utils.c +55 -0
  156. data/ext/rugged/vendor/libgit2-dist/src/thread-utils.h +108 -0
  157. data/ext/rugged/vendor/libgit2-dist/src/transport.c +85 -0
  158. data/ext/rugged/vendor/libgit2-dist/src/transport.h +110 -0
  159. data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +502 -0
  160. data/ext/rugged/vendor/libgit2-dist/src/transports/http.c +756 -0
  161. data/ext/rugged/vendor/libgit2-dist/src/transports/local.c +235 -0
  162. data/ext/rugged/vendor/libgit2-dist/src/tree-cache.c +201 -0
  163. data/ext/rugged/vendor/libgit2-dist/src/tree-cache.h +31 -0
  164. data/ext/rugged/vendor/libgit2-dist/src/tree.c +758 -0
  165. data/ext/rugged/vendor/libgit2-dist/src/tree.h +37 -0
  166. data/ext/rugged/vendor/libgit2-dist/src/tsort.c +365 -0
  167. data/ext/rugged/vendor/libgit2-dist/src/unix/map.c +70 -0
  168. data/ext/rugged/vendor/libgit2-dist/src/unix/posix.h +25 -0
  169. data/ext/rugged/vendor/libgit2-dist/src/util.c +381 -0
  170. data/ext/rugged/vendor/libgit2-dist/src/util.h +137 -0
  171. data/ext/rugged/vendor/libgit2-dist/src/vector.c +174 -0
  172. data/ext/rugged/vendor/libgit2-dist/src/vector.h +45 -0
  173. data/ext/rugged/vendor/libgit2-dist/src/win32/dir.c +115 -0
  174. data/ext/rugged/vendor/libgit2-dist/src/win32/fnmatch.c +180 -0
  175. data/ext/rugged/vendor/libgit2-dist/src/win32/fnmatch.h +27 -0
  176. data/ext/rugged/vendor/libgit2-dist/src/win32/map.c +131 -0
  177. data/ext/rugged/vendor/libgit2-dist/src/win32/mingw-compat.h +24 -0
  178. data/ext/rugged/vendor/libgit2-dist/src/win32/msvc-compat.h +38 -0
  179. data/ext/rugged/vendor/libgit2-dist/src/win32/posix.h +53 -0
  180. data/ext/rugged/vendor/libgit2-dist/src/win32/posix_w32.c +404 -0
  181. data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.c +65 -0
  182. data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.h +40 -0
  183. data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.c +88 -0
  184. data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.h +17 -0
  185. data/ext/rugged/vendor/libgit2-dist/tests-clay/buf/basic.c +29 -0
  186. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay.h +187 -0
  187. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_libgit2.h +28 -0
  188. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_main.c +1073 -0
  189. data/ext/rugged/vendor/libgit2-dist/tests-clay/config/add.c +37 -0
  190. data/ext/rugged/vendor/libgit2-dist/tests-clay/config/new.c +36 -0
  191. data/ext/rugged/vendor/libgit2-dist/tests-clay/config/read.c +209 -0
  192. data/ext/rugged/vendor/libgit2-dist/tests-clay/config/stress.c +39 -0
  193. data/ext/rugged/vendor/libgit2-dist/tests-clay/config/write.c +77 -0
  194. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/dirent.c +222 -0
  195. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/filebuf.c +106 -0
  196. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/oid.c +18 -0
  197. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/path.c +139 -0
  198. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/rmdir.c +50 -0
  199. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/string.c +28 -0
  200. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/strtol.c +37 -0
  201. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/vector.c +66 -0
  202. data/ext/rugged/vendor/libgit2-dist/tests-clay/index/rename.c +60 -0
  203. data/ext/rugged/vendor/libgit2-dist/tests-clay/network/remotes.c +50 -0
  204. data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/chars.c +52 -0
  205. data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/compare.c +124 -0
  206. data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/convert.c +75 -0
  207. data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/data.h +323 -0
  208. data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/fromstr.c +30 -0
  209. data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/hash.c +162 -0
  210. data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/short.c +94 -0
  211. data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/size.c +13 -0
  212. data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/type2string.c +54 -0
  213. data/ext/rugged/vendor/libgit2-dist/tests-clay/object/tree/frompath.c +75 -0
  214. data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/loose.c +84 -0
  215. data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/loose_data.h +522 -0
  216. data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/pack_data.h +151 -0
  217. data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/packed.c +78 -0
  218. data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/sorting.c +71 -0
  219. data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/getters.c +68 -0
  220. data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/init.c +104 -0
  221. data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/open.c +54 -0
  222. data/ext/rugged/vendor/libgit2-dist/tests-clay/status/single.c +38 -0
  223. data/ext/rugged/vendor/libgit2-dist/tests-clay/status/status_data.h +48 -0
  224. data/ext/rugged/vendor/libgit2-dist/tests-clay/status/worktree.c +124 -0
  225. data/ext/rugged/vendor/libgit2-dist/tests/t00-core.c +628 -0
  226. data/ext/rugged/vendor/libgit2-dist/tests/t01-data.h +322 -0
  227. data/ext/rugged/vendor/libgit2-dist/tests/t01-rawobj.c +638 -0
  228. data/ext/rugged/vendor/libgit2-dist/tests/t03-data.h +344 -0
  229. data/ext/rugged/vendor/libgit2-dist/tests/t03-objwrite.c +255 -0
  230. data/ext/rugged/vendor/libgit2-dist/tests/t04-commit.c +788 -0
  231. data/ext/rugged/vendor/libgit2-dist/tests/t05-revwalk.c +140 -0
  232. data/ext/rugged/vendor/libgit2-dist/tests/t06-index.c +219 -0
  233. data/ext/rugged/vendor/libgit2-dist/tests/t07-hashtable.c +192 -0
  234. data/ext/rugged/vendor/libgit2-dist/tests/t08-tag.c +357 -0
  235. data/ext/rugged/vendor/libgit2-dist/tests/t09-tree.c +221 -0
  236. data/ext/rugged/vendor/libgit2-dist/tests/t10-refs.c +1294 -0
  237. data/ext/rugged/vendor/libgit2-dist/tests/t12-repo.c +174 -0
  238. data/ext/rugged/vendor/libgit2-dist/tests/t13-threads.c +41 -0
  239. data/ext/rugged/vendor/libgit2-dist/tests/t17-bufs.c +61 -0
  240. data/ext/rugged/vendor/libgit2-dist/tests/t18-status.c +448 -0
  241. data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.c +310 -0
  242. data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.h +83 -0
  243. data/ext/rugged/vendor/libgit2-dist/tests/test_lib.c +198 -0
  244. data/ext/rugged/vendor/libgit2-dist/tests/test_lib.h +54 -0
  245. data/ext/rugged/vendor/libgit2-dist/tests/test_main.c +89 -0
  246. data/lib/rugged.rb +4 -3
  247. data/lib/rugged/index.rb +0 -8
  248. data/lib/rugged/objects.rb +45 -0
  249. data/lib/rugged/repository.rb +29 -0
  250. data/lib/rugged/tree.rb +16 -6
  251. data/lib/rugged/version.rb +1 -1
  252. data/lib/rugged/walker.rb +5 -0
  253. data/test/blob_test.rb +18 -14
  254. data/test/commit_test.rb +28 -26
  255. data/test/coverage/HEAD.json +1 -0
  256. data/test/coverage/cover.rb +106 -0
  257. data/test/fixtures/testrepo.git/refs/heads/new_name +1 -0
  258. data/test/index_test.rb +101 -78
  259. data/test/lib_test.rb +4 -4
  260. data/test/object_test.rb +3 -3
  261. data/test/reference_test.rb +75 -0
  262. data/test/remote_test.rb +19 -0
  263. data/test/repo_pack_test.rb +4 -4
  264. data/test/repo_test.rb +44 -15
  265. data/test/tag_test.rb +7 -17
  266. data/test/test_helper.rb +24 -5
  267. data/test/tree_test.rb +30 -12
  268. data/test/walker_test.rb +40 -31
  269. metadata +273 -50
  270. data/lib/rugged/person.rb +0 -20
  271. data/lib/rugged/tree_entry.rb +0 -9
  272. data/test/fixtures/testrepo.git/objects/1d/83f106355e4309a293e42ad2a2c4b8bdbe77ae +0 -0
  273. data/test/fixtures/testrepo.git/objects/2f/3321418db5b2a841375b8b70880a8ab5a4148f +0 -0
  274. data/test/fixtures/testrepo.git/objects/36/9b00a7700cca3a506d79e301d6ad8bf735d9ee +0 -3
  275. data/test/fixtures/testrepo.git/objects/3d/b1b5ceace59ff65279757003763046fd4cbbe6 +0 -0
  276. data/test/fixtures/testrepo.git/objects/4c/d1604907792e2c43e03dcec1216f99d63e68c4 +0 -3
  277. data/test/fixtures/testrepo.git/objects/e0/f46d77041c149296549b01ed4a18b02c4b7400 +0 -0
@@ -0,0 +1,97 @@
1
+ /*
2
+ * Copyright (C) 2009-2011 the libgit2 contributors
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
+
8
+ #include "common.h"
9
+
10
+ /*
11
+ * Default version that the compiler ought to optimize properly with
12
+ * constant values.
13
+ */
14
+ GIT_INLINE(uint32_t) default_swab32(uint32_t val)
15
+ {
16
+ return (((val & 0xff000000) >> 24) |
17
+ ((val & 0x00ff0000) >> 8) |
18
+ ((val & 0x0000ff00) << 8) |
19
+ ((val & 0x000000ff) << 24));
20
+ }
21
+
22
+ #undef bswap32
23
+
24
+ GIT_INLINE(uint16_t) default_swab16(uint16_t val)
25
+ {
26
+ return (((val & 0xff00) >> 8) |
27
+ ((val & 0x00ff) << 8));
28
+ }
29
+
30
+ #undef bswap16
31
+
32
+ #if defined(__GNUC__) && defined(__i386__)
33
+
34
+ #define bswap32(x) ({ \
35
+ uint32_t __res; \
36
+ if (__builtin_constant_p(x)) { \
37
+ __res = default_swab32(x); \
38
+ } else { \
39
+ __asm__("bswap %0" : "=r" (__res) : "0" ((uint32_t)(x))); \
40
+ } \
41
+ __res; })
42
+
43
+ #define bswap16(x) ({ \
44
+ uint16_t __res; \
45
+ if (__builtin_constant_p(x)) { \
46
+ __res = default_swab16(x); \
47
+ } else { \
48
+ __asm__("xchgb %b0,%h0" : "=q" (__res) : "0" ((uint16_t)(x))); \
49
+ } \
50
+ __res; })
51
+
52
+ #elif defined(__GNUC__) && defined(__x86_64__)
53
+
54
+ #define bswap32(x) ({ \
55
+ uint32_t __res; \
56
+ if (__builtin_constant_p(x)) { \
57
+ __res = default_swab32(x); \
58
+ } else { \
59
+ __asm__("bswapl %0" : "=r" (__res) : "0" ((uint32_t)(x))); \
60
+ } \
61
+ __res; })
62
+
63
+ #define bswap16(x) ({ \
64
+ uint16_t __res; \
65
+ if (__builtin_constant_p(x)) { \
66
+ __res = default_swab16(x); \
67
+ } else { \
68
+ __asm__("xchgb %b0,%h0" : "=Q" (__res) : "0" ((uint16_t)(x))); \
69
+ } \
70
+ __res; })
71
+
72
+ #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
73
+
74
+ #include <stdlib.h>
75
+
76
+ #define bswap32(x) _byteswap_ulong(x)
77
+ #define bswap16(x) _byteswap_ushort(x)
78
+
79
+ #endif
80
+
81
+ #ifdef bswap32
82
+
83
+ #undef ntohl
84
+ #undef htonl
85
+ #define ntohl(x) bswap32(x)
86
+ #define htonl(x) bswap32(x)
87
+
88
+ #endif
89
+
90
+ #ifdef bswap16
91
+
92
+ #undef ntohs
93
+ #undef htons
94
+ #define ntohs(x) bswap16(x)
95
+ #define htons(x) bswap16(x)
96
+
97
+ #endif
@@ -0,0 +1,113 @@
1
+ /*
2
+ * Copyright (C) 2009-2011 the libgit2 contributors
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
+ #include "buffer.h"
8
+ #include "posix.h"
9
+ #include <stdarg.h>
10
+
11
+ #define ENSURE_SIZE(b, d) \
12
+ if ((ssize_t)(d) >= buf->asize && git_buf_grow(b, (d)) < GIT_SUCCESS)\
13
+ return;
14
+
15
+ int git_buf_grow(git_buf *buf, size_t target_size)
16
+ {
17
+ char *new_ptr;
18
+
19
+ if (buf->asize < 0)
20
+ return GIT_ENOMEM;
21
+
22
+ if (buf->asize == 0)
23
+ buf->asize = target_size;
24
+
25
+ /* grow the buffer size by 1.5, until it's big enough
26
+ * to fit our target size */
27
+ while (buf->asize < (int)target_size)
28
+ buf->asize = (buf->asize << 1) - (buf->asize >> 1);
29
+
30
+ new_ptr = git__realloc(buf->ptr, buf->asize);
31
+ if (!new_ptr) {
32
+ buf->asize = -1;
33
+ return GIT_ENOMEM;
34
+ }
35
+
36
+ buf->ptr = new_ptr;
37
+ return GIT_SUCCESS;
38
+ }
39
+
40
+ int git_buf_oom(const git_buf *buf)
41
+ {
42
+ return (buf->asize < 0);
43
+ }
44
+
45
+ void git_buf_putc(git_buf *buf, char c)
46
+ {
47
+ ENSURE_SIZE(buf, buf->size + 1);
48
+ buf->ptr[buf->size++] = c;
49
+ }
50
+
51
+ void git_buf_put(git_buf *buf, const char *data, size_t len)
52
+ {
53
+ ENSURE_SIZE(buf, buf->size + len);
54
+ memcpy(buf->ptr + buf->size, data, len);
55
+ buf->size += len;
56
+ }
57
+
58
+ void git_buf_puts(git_buf *buf, const char *string)
59
+ {
60
+ git_buf_put(buf, string, strlen(string));
61
+ }
62
+
63
+ void git_buf_printf(git_buf *buf, const char *format, ...)
64
+ {
65
+ int len;
66
+ va_list arglist;
67
+
68
+ ENSURE_SIZE(buf, buf->size + 1);
69
+
70
+ while (1) {
71
+ va_start(arglist, format);
72
+ len = p_vsnprintf(buf->ptr + buf->size, buf->asize - buf->size, format, arglist);
73
+ va_end(arglist);
74
+
75
+ if (len < 0) {
76
+ buf->asize = -1;
77
+ return;
78
+ }
79
+
80
+ if (len + 1 <= buf->asize - buf->size) {
81
+ buf->size += len;
82
+ return;
83
+ }
84
+
85
+ ENSURE_SIZE(buf, buf->size + len + 1);
86
+ }
87
+ }
88
+
89
+ const char *git_buf_cstr(git_buf *buf)
90
+ {
91
+ if (buf->size + 1 >= buf->asize && git_buf_grow(buf, buf->size + 1) < GIT_SUCCESS)
92
+ return NULL;
93
+
94
+ buf->ptr[buf->size] = '\0';
95
+ return buf->ptr;
96
+ }
97
+
98
+ void git_buf_free(git_buf *buf)
99
+ {
100
+ git__free(buf->ptr);
101
+ }
102
+
103
+ void git_buf_clear(git_buf *buf)
104
+ {
105
+ buf->size = 0;
106
+ }
107
+
108
+ void git_buf_consume(git_buf *buf, const char *end)
109
+ {
110
+ size_t consumed = end - buf->ptr;
111
+ memmove(buf->ptr, end, buf->size - consumed);
112
+ buf->size -= consumed;
113
+ }
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Copyright (C) 2009-2011 the libgit2 contributors
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
+ #ifndef INCLUDE_buffer_h__
8
+ #define INCLUDE_buffer_h__
9
+
10
+ #include "common.h"
11
+
12
+ typedef struct {
13
+ char *ptr;
14
+ ssize_t asize, size;
15
+ } git_buf;
16
+
17
+ #define GIT_BUF_INIT {NULL, 0, 0}
18
+
19
+ int git_buf_grow(git_buf *buf, size_t target_size);
20
+ int git_buf_oom(const git_buf *buf);
21
+ void git_buf_putc(git_buf *buf, char c);
22
+ void git_buf_put(git_buf *buf, const char *data, size_t len);
23
+ void git_buf_puts(git_buf *buf, const char *string);
24
+ void git_buf_printf(git_buf *buf, const char *format, ...) GIT_FORMAT_PRINTF(2, 3);
25
+ const char *git_buf_cstr(git_buf *buf);
26
+ void git_buf_free(git_buf *buf);
27
+ void git_buf_clear(git_buf *buf);
28
+ void git_buf_consume(git_buf *buf, const char *end);
29
+
30
+ #define git_buf_PUTS(buf, str) git_buf_put(buf, str, sizeof(str) - 1)
31
+
32
+ #endif
@@ -0,0 +1,111 @@
1
+ /*
2
+ * Copyright (C) 2009-2011 the libgit2 contributors
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
+
8
+ #include "common.h"
9
+ #include "repository.h"
10
+ #include "commit.h"
11
+ #include "thread-utils.h"
12
+ #include "cache.h"
13
+
14
+ int git_cache_init(git_cache *cache, size_t size, git_cached_obj_freeptr free_ptr)
15
+ {
16
+ size_t i;
17
+
18
+ if (size < 8)
19
+ size = 8;
20
+
21
+ /* round up size to closest power of 2 */
22
+ size--;
23
+ size |= size >> 1;
24
+ size |= size >> 2;
25
+ size |= size >> 4;
26
+ size |= size >> 8;
27
+ size |= size >> 16;
28
+
29
+ cache->size_mask = size;
30
+ cache->lru_count = 0;
31
+ cache->free_obj = free_ptr;
32
+
33
+ cache->nodes = git__malloc((size + 1) * sizeof(cache_node));
34
+ if (cache->nodes == NULL)
35
+ return GIT_ENOMEM;
36
+
37
+ for (i = 0; i < (size + 1); ++i) {
38
+ git_mutex_init(&cache->nodes[i].lock);
39
+ cache->nodes[i].ptr = NULL;
40
+ }
41
+
42
+ return GIT_SUCCESS;
43
+ }
44
+
45
+ void git_cache_free(git_cache *cache)
46
+ {
47
+ size_t i;
48
+
49
+ for (i = 0; i < (cache->size_mask + 1); ++i) {
50
+ if (cache->nodes[i].ptr)
51
+ git_cached_obj_decref(cache->nodes[i].ptr, cache->free_obj);
52
+
53
+ git_mutex_free(&cache->nodes[i].lock);
54
+ }
55
+
56
+ git__free(cache->nodes);
57
+ }
58
+
59
+ void *git_cache_get(git_cache *cache, const git_oid *oid)
60
+ {
61
+ uint32_t hash;
62
+ cache_node *node = NULL;
63
+ void *result = NULL;
64
+
65
+ memcpy(&hash, oid->id, sizeof(hash));
66
+ node = &cache->nodes[hash & cache->size_mask];
67
+
68
+ git_mutex_lock(&node->lock);
69
+ {
70
+ if (node->ptr && git_cached_obj_compare(node->ptr, oid) == 0) {
71
+ git_cached_obj_incref(node->ptr);
72
+ result = node->ptr;
73
+ }
74
+ }
75
+ git_mutex_unlock(&node->lock);
76
+
77
+ return result;
78
+ }
79
+
80
+ void *git_cache_try_store(git_cache *cache, void *entry)
81
+ {
82
+ uint32_t hash;
83
+ const git_oid *oid;
84
+ cache_node *node = NULL;
85
+
86
+ oid = &((git_cached_obj*)entry)->oid;
87
+ memcpy(&hash, oid->id, sizeof(hash));
88
+ node = &cache->nodes[hash & cache->size_mask];
89
+
90
+ /* increase the refcount on this object, because
91
+ * the cache now owns it */
92
+ git_cached_obj_incref(entry);
93
+ git_mutex_lock(&node->lock);
94
+
95
+ if (node->ptr == NULL) {
96
+ node->ptr = entry;
97
+ } else if (git_cached_obj_compare(node->ptr, oid) == 0) {
98
+ git_cached_obj_decref(entry, cache->free_obj);
99
+ entry = node->ptr;
100
+ } else {
101
+ git_cached_obj_decref(node->ptr, cache->free_obj);
102
+ node->ptr = entry;
103
+ }
104
+
105
+ /* increase the refcount again, because we are
106
+ * returning it to the user */
107
+ git_cached_obj_incref(entry);
108
+ git_mutex_unlock(&node->lock);
109
+
110
+ return entry;
111
+ }
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright (C) 2009-2011 the libgit2 contributors
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
+ #ifndef INCLUDE_cache_h__
8
+ #define INCLUDE_cache_h__
9
+
10
+ #include "git2/common.h"
11
+ #include "git2/oid.h"
12
+ #include "git2/odb.h"
13
+
14
+ #include "thread-utils.h"
15
+
16
+ #define GIT_DEFAULT_CACHE_SIZE 128
17
+
18
+ typedef void (*git_cached_obj_freeptr)(void *);
19
+
20
+ typedef struct {
21
+ git_oid oid;
22
+ git_atomic refcount;
23
+ } git_cached_obj;
24
+
25
+ typedef struct {
26
+ git_cached_obj *ptr;
27
+ git_mutex lock;
28
+ } cache_node;
29
+
30
+ typedef struct {
31
+ cache_node *nodes;
32
+
33
+ unsigned int lru_count;
34
+ size_t size_mask;
35
+ git_cached_obj_freeptr free_obj;
36
+ } git_cache;
37
+
38
+
39
+ int git_cache_init(git_cache *cache, size_t size, git_cached_obj_freeptr free_ptr);
40
+ void git_cache_free(git_cache *cache);
41
+
42
+ void *git_cache_try_store(git_cache *cache, void *entry);
43
+ void *git_cache_get(git_cache *cache, const git_oid *oid);
44
+
45
+
46
+ GIT_INLINE(int) git_cached_obj_compare(git_cached_obj *obj, const git_oid *oid)
47
+ {
48
+ return git_oid_cmp(&obj->oid, oid);
49
+ }
50
+
51
+ GIT_INLINE(void) git_cached_obj_incref(git_cached_obj *obj)
52
+ {
53
+ git_atomic_inc(&obj->refcount);
54
+ }
55
+
56
+ GIT_INLINE(void) git_cached_obj_decref(git_cached_obj *obj, git_cached_obj_freeptr free_obj)
57
+ {
58
+ if (git_atomic_dec(&obj->refcount) == 0)
59
+ free_obj(obj);
60
+ }
61
+
62
+
63
+
64
+ #endif
@@ -0,0 +1,67 @@
1
+ /*
2
+ * Copyright (C) 2009-2011 the libgit2 contributors
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
+ #ifndef INCLUDE_compat_h__
8
+ #define INCLUDE_compat_h__
9
+
10
+ /*
11
+ * See if our compiler is known to support flexible array members.
12
+ */
13
+ #ifndef GIT_FLEX_ARRAY
14
+ # if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
15
+ # define GIT_FLEX_ARRAY /* empty */
16
+ # elif defined(__GNUC__)
17
+ # if (__GNUC__ >= 3)
18
+ # define GIT_FLEX_ARRAY /* empty */
19
+ # else
20
+ # define GIT_FLEX_ARRAY 0 /* older GNU extension */
21
+ # endif
22
+ # endif
23
+
24
+ /* Default to safer but a bit wasteful traditional style */
25
+ # ifndef GIT_FLEX_ARRAY
26
+ # define GIT_FLEX_ARRAY 1
27
+ # endif
28
+ #endif
29
+
30
+ #ifdef __GNUC__
31
+ # define GIT_TYPEOF(x) (__typeof__(x))
32
+ #else
33
+ # define GIT_TYPEOF(x)
34
+ #endif
35
+
36
+ #ifdef __cplusplus
37
+ # define GIT_UNUSED(x)
38
+ #else
39
+ # ifdef __GNUC__
40
+ # define GIT_UNUSED(x) x __attribute__ ((__unused__))
41
+ # else
42
+ # define GIT_UNUSED(x) x
43
+ # endif
44
+ #endif
45
+
46
+ #if defined(_MSC_VER)
47
+ #define GIT_UNUSED_ARG(x) ((void)(x)); /* note trailing ; */
48
+ #else
49
+ #define GIT_UNUSED_ARG(x)
50
+ #endif
51
+
52
+ /* Define the printf format specifer to use for size_t output */
53
+ #if defined(_MSC_VER) || defined(__MINGW32__)
54
+ # define PRIuZ "Iu"
55
+ #else
56
+ # define PRIuZ "zu"
57
+ #endif
58
+
59
+ /* Micosoft Visual C/C++ */
60
+ #if defined(_MSC_VER)
61
+ /* disable "deprecated function" warnings */
62
+ # pragma warning ( disable : 4996 )
63
+ /* disable "conditional expression is constant" level 4 warnings */
64
+ # pragma warning ( disable : 4127 )
65
+ #endif
66
+
67
+ #endif /* INCLUDE_compat_h__ */