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,30 @@
1
+
2
+ #include "clay_libgit2.h"
3
+
4
+ #include "odb.h"
5
+
6
+ void test_object_raw_fromstr__fail_on_invalid_oid_string(void)
7
+ {
8
+ git_oid out;
9
+ cl_git_fail(git_oid_fromstr(&out, ""));
10
+ cl_git_fail(git_oid_fromstr(&out, "moo"));
11
+ cl_git_fail(git_oid_fromstr(&out, "16a67770b7d8d72317c4b775213c23a8bd74f5ez"));
12
+ }
13
+
14
+ void test_object_raw_fromstr__succeed_on_valid_oid_string(void)
15
+ {
16
+ git_oid out;
17
+ unsigned char exp[] = {
18
+ 0x16, 0xa6, 0x77, 0x70, 0xb7,
19
+ 0xd8, 0xd7, 0x23, 0x17, 0xc4,
20
+ 0xb7, 0x75, 0x21, 0x3c, 0x23,
21
+ 0xa8, 0xbd, 0x74, 0xf5, 0xe0,
22
+ };
23
+
24
+ cl_git_pass(git_oid_fromstr(&out, "16a67770b7d8d72317c4b775213c23a8bd74f5e0"));
25
+ cl_git_pass(memcmp(out.id, exp, sizeof(out.id)));
26
+
27
+ cl_git_pass(git_oid_fromstr(&out, "16A67770B7D8D72317C4b775213C23A8BD74F5E0"));
28
+ cl_git_pass(memcmp(out.id, exp, sizeof(out.id)));
29
+
30
+ }
@@ -0,0 +1,162 @@
1
+
2
+ #include "clay_libgit2.h"
3
+
4
+ #include "odb.h"
5
+ #include "hash.h"
6
+
7
+ #include "data.h"
8
+
9
+ static int hash_object(git_oid *oid, git_rawobj *obj)
10
+ {
11
+ return git_odb_hash(oid, obj->data, obj->len, obj->type);
12
+ }
13
+
14
+ static char *hello_id = "22596363b3de40b06f981fb85d82312e8c0ed511";
15
+ static char *hello_text = "hello world\n";
16
+
17
+ static char *bye_id = "ce08fe4884650f067bd5703b6a59a8b3b3c99a09";
18
+ static char *bye_text = "bye world\n";
19
+
20
+ void test_object_raw_hash__hash_by_blocks(void)
21
+ {
22
+ git_hash_ctx *ctx;
23
+ git_oid id1, id2;
24
+
25
+ cl_assert((ctx = git_hash_new_ctx()) != NULL);
26
+
27
+ /* should already be init'd */
28
+ git_hash_update(ctx, hello_text, strlen(hello_text));
29
+ git_hash_final(&id2, ctx);
30
+ cl_git_pass(git_oid_fromstr(&id1, hello_id));
31
+ cl_assert(git_oid_cmp(&id1, &id2) == 0);
32
+
33
+ /* reinit should permit reuse */
34
+ git_hash_init(ctx);
35
+ git_hash_update(ctx, bye_text, strlen(bye_text));
36
+ git_hash_final(&id2, ctx);
37
+ cl_git_pass(git_oid_fromstr(&id1, bye_id));
38
+ cl_assert(git_oid_cmp(&id1, &id2) == 0);
39
+
40
+ git_hash_free_ctx(ctx);
41
+ }
42
+
43
+ void test_object_raw_hash__hash_buffer_in_single_call(void)
44
+ {
45
+ git_oid id1, id2;
46
+
47
+ cl_git_pass(git_oid_fromstr(&id1, hello_id));
48
+ git_hash_buf(&id2, hello_text, strlen(hello_text));
49
+ cl_assert(git_oid_cmp(&id1, &id2) == 0);
50
+ }
51
+
52
+ void test_object_raw_hash__hash_vector(void)
53
+ {
54
+ git_oid id1, id2;
55
+ git_buf_vec vec[2];
56
+
57
+ cl_git_pass(git_oid_fromstr(&id1, hello_id));
58
+
59
+ vec[0].data = hello_text;
60
+ vec[0].len = 4;
61
+ vec[1].data = hello_text+4;
62
+ vec[1].len = strlen(hello_text)-4;
63
+
64
+ git_hash_vec(&id2, vec, 2);
65
+
66
+ cl_assert(git_oid_cmp(&id1, &id2) == 0);
67
+ }
68
+
69
+ void test_object_raw_hash__hash_junk_data(void)
70
+ {
71
+ git_oid id, id_zero;
72
+
73
+ cl_git_pass(git_oid_fromstr(&id_zero, zero_id));
74
+
75
+ /* invalid types: */
76
+ junk_obj.data = some_data;
77
+ cl_git_fail(hash_object(&id, &junk_obj));
78
+
79
+ junk_obj.type = GIT_OBJ__EXT1;
80
+ cl_git_fail(hash_object(&id, &junk_obj));
81
+
82
+ junk_obj.type = GIT_OBJ__EXT2;
83
+ cl_git_fail(hash_object(&id, &junk_obj));
84
+
85
+ junk_obj.type = GIT_OBJ_OFS_DELTA;
86
+ cl_git_fail(hash_object(&id, &junk_obj));
87
+
88
+ junk_obj.type = GIT_OBJ_REF_DELTA;
89
+ cl_git_fail(hash_object(&id, &junk_obj));
90
+
91
+ /* data can be NULL only if len is zero: */
92
+ junk_obj.type = GIT_OBJ_BLOB;
93
+ junk_obj.data = NULL;
94
+ cl_git_pass(hash_object(&id, &junk_obj));
95
+ cl_assert(git_oid_cmp(&id, &id_zero) == 0);
96
+
97
+ junk_obj.len = 1;
98
+ cl_git_fail(hash_object(&id, &junk_obj));
99
+ }
100
+
101
+ void test_object_raw_hash__hash_commit_object(void)
102
+ {
103
+ git_oid id1, id2;
104
+
105
+ cl_git_pass(git_oid_fromstr(&id1, commit_id));
106
+ cl_git_pass(hash_object(&id2, &commit_obj));
107
+ cl_assert(git_oid_cmp(&id1, &id2) == 0);
108
+ }
109
+
110
+ void test_object_raw_hash__hash_tree_object(void)
111
+ {
112
+ git_oid id1, id2;
113
+
114
+ cl_git_pass(git_oid_fromstr(&id1, tree_id));
115
+ cl_git_pass(hash_object(&id2, &tree_obj));
116
+ cl_assert(git_oid_cmp(&id1, &id2) == 0);
117
+ }
118
+
119
+ void test_object_raw_hash__hash_tag_object(void)
120
+ {
121
+ git_oid id1, id2;
122
+
123
+ cl_git_pass(git_oid_fromstr(&id1, tag_id));
124
+ cl_git_pass(hash_object(&id2, &tag_obj));
125
+ cl_assert(git_oid_cmp(&id1, &id2) == 0);
126
+ }
127
+
128
+ void test_object_raw_hash__hash_zero_length_object(void)
129
+ {
130
+ git_oid id1, id2;
131
+
132
+ cl_git_pass(git_oid_fromstr(&id1, zero_id));
133
+ cl_git_pass(hash_object(&id2, &zero_obj));
134
+ cl_assert(git_oid_cmp(&id1, &id2) == 0);
135
+ }
136
+
137
+ void test_object_raw_hash__hash_one_byte_object(void)
138
+ {
139
+ git_oid id1, id2;
140
+
141
+ cl_git_pass(git_oid_fromstr(&id1, one_id));
142
+ cl_git_pass(hash_object(&id2, &one_obj));
143
+ cl_assert(git_oid_cmp(&id1, &id2) == 0);
144
+ }
145
+
146
+ void test_object_raw_hash__hash_two_byte_object(void)
147
+ {
148
+ git_oid id1, id2;
149
+
150
+ cl_git_pass(git_oid_fromstr(&id1, two_id));
151
+ cl_git_pass(hash_object(&id2, &two_obj));
152
+ cl_assert(git_oid_cmp(&id1, &id2) == 0);
153
+ }
154
+
155
+ void test_object_raw_hash__hash_multi_byte_object(void)
156
+ {
157
+ git_oid id1, id2;
158
+
159
+ cl_git_pass(git_oid_fromstr(&id1, some_id));
160
+ cl_git_pass(hash_object(&id2, &some_obj));
161
+ cl_assert(git_oid_cmp(&id1, &id2) == 0);
162
+ }
@@ -0,0 +1,94 @@
1
+
2
+ #include "clay_libgit2.h"
3
+
4
+ #include "odb.h"
5
+ #include "hash.h"
6
+
7
+ void test_object_raw_short__oid_shortener_no_duplicates(void)
8
+ {
9
+ git_oid_shorten *os;
10
+ int min_len;
11
+
12
+ os = git_oid_shorten_new(0);
13
+ cl_assert(os != NULL);
14
+
15
+ git_oid_shorten_add(os, "22596363b3de40b06f981fb85d82312e8c0ed511");
16
+ git_oid_shorten_add(os, "ce08fe4884650f067bd5703b6a59a8b3b3c99a09");
17
+ git_oid_shorten_add(os, "16a0123456789abcdef4b775213c23a8bd74f5e0");
18
+ min_len = git_oid_shorten_add(os, "ce08fe4884650f067bd5703b6a59a8b3b3c99a09");
19
+
20
+ cl_assert(min_len == GIT_OID_HEXSZ + 1);
21
+
22
+ git_oid_shorten_free(os);
23
+ }
24
+
25
+ void test_object_raw_short__oid_shortener_stresstest_git_oid_shorten(void)
26
+ {
27
+ #define MAX_OIDS 1000
28
+
29
+ git_oid_shorten *os;
30
+ char *oids[MAX_OIDS];
31
+ char number_buffer[16];
32
+ git_oid oid;
33
+ size_t i, j;
34
+
35
+ int min_len = 0, found_collision;
36
+
37
+ os = git_oid_shorten_new(0);
38
+ cl_assert(os != NULL);
39
+
40
+ /*
41
+ * Insert in the shortener 1000 unique SHA1 ids
42
+ */
43
+ for (i = 0; i < MAX_OIDS; ++i) {
44
+ char *oid_text;
45
+
46
+ sprintf(number_buffer, "%u", (unsigned int)i);
47
+ git_hash_buf(&oid, number_buffer, strlen(number_buffer));
48
+
49
+ oid_text = git__malloc(GIT_OID_HEXSZ + 1);
50
+ git_oid_fmt(oid_text, &oid);
51
+ oid_text[GIT_OID_HEXSZ] = 0;
52
+
53
+ min_len = git_oid_shorten_add(os, oid_text);
54
+ cl_assert(min_len >= 0);
55
+
56
+ oids[i] = oid_text;
57
+ }
58
+
59
+ /*
60
+ * Compare the first `min_char - 1` characters of each
61
+ * SHA1 OID. If the minimizer worked, we should find at
62
+ * least one collision
63
+ */
64
+ found_collision = 0;
65
+ for (i = 0; i < MAX_OIDS; ++i) {
66
+ for (j = 0; j < MAX_OIDS; ++j) {
67
+ if (i != j && memcmp(oids[i], oids[j], min_len - 1) == 0)
68
+ found_collision = 1;
69
+ }
70
+ }
71
+ cl_assert(found_collision == 1);
72
+
73
+ /*
74
+ * Compare the first `min_char` characters of each
75
+ * SHA1 OID. If the minimizer worked, every single preffix
76
+ * should be unique.
77
+ */
78
+ found_collision = 0;
79
+ for (i = 0; i < MAX_OIDS; ++i) {
80
+ for (j = 0; j < MAX_OIDS; ++j) {
81
+ if (i != j && memcmp(oids[i], oids[j], min_len) == 0)
82
+ found_collision = 1;
83
+ }
84
+ }
85
+ cl_assert(found_collision == 0);
86
+
87
+ /* cleanup */
88
+ for (i = 0; i < MAX_OIDS; ++i)
89
+ git__free(oids[i]);
90
+
91
+ git_oid_shorten_free(os);
92
+
93
+ #undef MAX_OIDS
94
+ }
@@ -0,0 +1,13 @@
1
+
2
+ #include "clay_libgit2.h"
3
+
4
+ #include "odb.h"
5
+
6
+ void test_object_raw_size__validate_oid_size(void)
7
+ {
8
+ git_oid out;
9
+ cl_assert(20 == GIT_OID_RAWSZ);
10
+ cl_assert(40 == GIT_OID_HEXSZ);
11
+ cl_assert(sizeof(out) == GIT_OID_RAWSZ);
12
+ cl_assert(sizeof(out.id) == GIT_OID_RAWSZ);
13
+ }
@@ -0,0 +1,54 @@
1
+
2
+ #include "clay_libgit2.h"
3
+
4
+ #include "odb.h"
5
+ #include "hash.h"
6
+
7
+ void test_object_raw_type2string__convert_type_to_string(void)
8
+ {
9
+ cl_assert(!strcmp(git_object_type2string(GIT_OBJ_BAD), ""));
10
+ cl_assert(!strcmp(git_object_type2string(GIT_OBJ__EXT1), ""));
11
+ cl_assert(!strcmp(git_object_type2string(GIT_OBJ_COMMIT), "commit"));
12
+ cl_assert(!strcmp(git_object_type2string(GIT_OBJ_TREE), "tree"));
13
+ cl_assert(!strcmp(git_object_type2string(GIT_OBJ_BLOB), "blob"));
14
+ cl_assert(!strcmp(git_object_type2string(GIT_OBJ_TAG), "tag"));
15
+ cl_assert(!strcmp(git_object_type2string(GIT_OBJ__EXT2), ""));
16
+ cl_assert(!strcmp(git_object_type2string(GIT_OBJ_OFS_DELTA), "OFS_DELTA"));
17
+ cl_assert(!strcmp(git_object_type2string(GIT_OBJ_REF_DELTA), "REF_DELTA"));
18
+
19
+ cl_assert(!strcmp(git_object_type2string(-2), ""));
20
+ cl_assert(!strcmp(git_object_type2string(8), ""));
21
+ cl_assert(!strcmp(git_object_type2string(1234), ""));
22
+ }
23
+
24
+ void test_object_raw_type2string__convert_string_to_type(void)
25
+ {
26
+ cl_assert(git_object_string2type(NULL) == GIT_OBJ_BAD);
27
+ cl_assert(git_object_string2type("") == GIT_OBJ_BAD);
28
+ cl_assert(git_object_string2type("commit") == GIT_OBJ_COMMIT);
29
+ cl_assert(git_object_string2type("tree") == GIT_OBJ_TREE);
30
+ cl_assert(git_object_string2type("blob") == GIT_OBJ_BLOB);
31
+ cl_assert(git_object_string2type("tag") == GIT_OBJ_TAG);
32
+ cl_assert(git_object_string2type("OFS_DELTA") == GIT_OBJ_OFS_DELTA);
33
+ cl_assert(git_object_string2type("REF_DELTA") == GIT_OBJ_REF_DELTA);
34
+
35
+ cl_assert(git_object_string2type("CoMmIt") == GIT_OBJ_BAD);
36
+ cl_assert(git_object_string2type("hohoho") == GIT_OBJ_BAD);
37
+ }
38
+
39
+ void test_object_raw_type2string__check_type_is_loose(void)
40
+ {
41
+ cl_assert(git_object_typeisloose(GIT_OBJ_BAD) == 0);
42
+ cl_assert(git_object_typeisloose(GIT_OBJ__EXT1) == 0);
43
+ cl_assert(git_object_typeisloose(GIT_OBJ_COMMIT) == 1);
44
+ cl_assert(git_object_typeisloose(GIT_OBJ_TREE) == 1);
45
+ cl_assert(git_object_typeisloose(GIT_OBJ_BLOB) == 1);
46
+ cl_assert(git_object_typeisloose(GIT_OBJ_TAG) == 1);
47
+ cl_assert(git_object_typeisloose(GIT_OBJ__EXT2) == 0);
48
+ cl_assert(git_object_typeisloose(GIT_OBJ_OFS_DELTA) == 0);
49
+ cl_assert(git_object_typeisloose(GIT_OBJ_REF_DELTA) == 0);
50
+
51
+ cl_assert(git_object_typeisloose(-2) == 0);
52
+ cl_assert(git_object_typeisloose(8) == 0);
53
+ cl_assert(git_object_typeisloose(1234) == 0);
54
+ }
@@ -0,0 +1,75 @@
1
+ #include "clay_libgit2.h"
2
+
3
+ static git_repository *repo;
4
+ const char *tree_with_subtrees_oid = "ae90f12eea699729ed24555e40b9fd669da12a12";
5
+ static git_tree *tree;
6
+
7
+ void test_object_tree_frompath__initialize(void)
8
+ {
9
+ git_oid id;
10
+
11
+ cl_fixture_sandbox("testrepo.git");
12
+ cl_git_pass(git_repository_open(&repo, "testrepo.git"));
13
+ cl_assert(repo != NULL);
14
+
15
+ cl_git_pass(git_oid_fromstr(&id, tree_with_subtrees_oid));
16
+ cl_git_pass(git_tree_lookup(&tree, repo, &id));
17
+ cl_assert(tree != NULL);
18
+ }
19
+
20
+ void test_object_tree_frompath__cleanup(void)
21
+ {
22
+ git_tree_free(tree);
23
+ git_repository_free(repo);
24
+ cl_fixture_cleanup("testrepo.git");
25
+ }
26
+
27
+ static void assert_tree_from_path(git_tree *root, const char *path, git_error expected_result, const char *expected_raw_oid)
28
+ {
29
+ git_tree *containing_tree = NULL;
30
+
31
+ cl_assert(git_tree_get_subtree(&containing_tree, root, path) == expected_result);
32
+
33
+ if (containing_tree == NULL && expected_result != GIT_SUCCESS)
34
+ return;
35
+
36
+ cl_assert(containing_tree != NULL && expected_result == GIT_SUCCESS);
37
+
38
+ cl_assert(git_oid_streq(git_object_id((const git_object *)containing_tree), expected_raw_oid) == GIT_SUCCESS);
39
+
40
+ git_tree_free(containing_tree);
41
+ }
42
+
43
+ void test_object_tree_frompath__retrieve_tree_from_path_to_treeentry(void)
44
+ {
45
+ /* Will return self if given a one path segment... */
46
+ assert_tree_from_path(tree, "README", GIT_SUCCESS, tree_with_subtrees_oid);
47
+
48
+ /* ...even one that lead to a non existent tree entry. */
49
+ assert_tree_from_path(tree, "i-do-not-exist.txt", GIT_SUCCESS, tree_with_subtrees_oid);
50
+
51
+ /* Will return fgh tree oid given this following path... */
52
+ assert_tree_from_path(tree, "ab/de/fgh/1.txt", GIT_SUCCESS, "3259a6bd5b57fb9c1281bb7ed3167b50f224cb54");
53
+
54
+ /* ... and ab tree oid given this one. */
55
+ assert_tree_from_path(tree, "ab/de", GIT_SUCCESS, "f1425cef211cc08caa31e7b545ffb232acb098c3");
56
+
57
+ /* Will succeed if given a valid path which leads to a tree entry which doesn't exist */
58
+ assert_tree_from_path(tree, "ab/de/fgh/i-do-not-exist.txt", GIT_SUCCESS, "3259a6bd5b57fb9c1281bb7ed3167b50f224cb54");
59
+ }
60
+
61
+ void test_object_tree_frompath__fail_when_processing_an_unknown_tree_segment(void)
62
+ {
63
+ assert_tree_from_path(tree, "nope/de/fgh/1.txt", GIT_ENOTFOUND, NULL);
64
+ assert_tree_from_path(tree, "ab/me-neither/fgh/2.txt", GIT_ENOTFOUND, NULL);
65
+ }
66
+
67
+ void test_object_tree_frompath__fail_when_processing_an_invalid_path(void)
68
+ {
69
+ assert_tree_from_path(tree, "/", GIT_EINVALIDPATH, NULL);
70
+ assert_tree_from_path(tree, "/ab", GIT_EINVALIDPATH, NULL);
71
+ assert_tree_from_path(tree, "/ab/de", GIT_EINVALIDPATH, NULL);
72
+ assert_tree_from_path(tree, "ab/", GIT_EINVALIDPATH, NULL);
73
+ assert_tree_from_path(tree, "ab//de", GIT_EINVALIDPATH, NULL);
74
+ assert_tree_from_path(tree, "ab/de/", GIT_EINVALIDPATH, NULL);
75
+ }
@@ -0,0 +1,84 @@
1
+ #include "clay_libgit2.h"
2
+ #include "odb.h"
3
+ #include "posix.h"
4
+ #include "loose_data.h"
5
+
6
+ static void write_object_files(object_data *d)
7
+ {
8
+ int fd;
9
+
10
+ if (p_mkdir(d->dir, GIT_OBJECT_DIR_MODE) < 0)
11
+ cl_assert(errno == EEXIST);
12
+
13
+ cl_assert((fd = p_creat(d->file, S_IREAD | S_IWRITE)) >= 0);
14
+ cl_must_pass(p_write(fd, d->bytes, d->blen));
15
+
16
+ p_close(fd);
17
+ }
18
+
19
+ static void cmp_objects(git_rawobj *o, object_data *d)
20
+ {
21
+ cl_assert(o->type == git_object_string2type(d->type));
22
+ cl_assert(o->len == d->dlen);
23
+
24
+ if (o->len > 0)
25
+ cl_assert(memcmp(o->data, d->data, o->len) == 0);
26
+ }
27
+
28
+ static void test_read_object(object_data *data)
29
+ {
30
+ git_oid id;
31
+ git_odb_object *obj;
32
+ git_odb *odb;
33
+
34
+ write_object_files(data);
35
+
36
+ cl_git_pass(git_odb_open(&odb, "test-objects"));
37
+ cl_git_pass(git_oid_fromstr(&id, data->id));
38
+ cl_git_pass(git_odb_read(&obj, odb, &id));
39
+
40
+ cmp_objects((git_rawobj *)&obj->raw, data);
41
+
42
+ git_odb_object_free(obj);
43
+ git_odb_free(odb);
44
+ }
45
+
46
+ void test_odb_loose__initialize(void)
47
+ {
48
+ cl_must_pass(p_mkdir("test-objects", GIT_OBJECT_DIR_MODE));
49
+ }
50
+
51
+ void test_odb_loose__cleanup(void)
52
+ {
53
+ cl_fixture_cleanup("test-objects");
54
+ }
55
+
56
+ void test_odb_loose__exists(void)
57
+ {
58
+ git_oid id, id2;
59
+ git_odb *odb;
60
+
61
+ write_object_files(&one);
62
+ cl_git_pass(git_odb_open(&odb, "test-objects"));
63
+
64
+ cl_git_pass(git_oid_fromstr(&id, one.id));
65
+
66
+ cl_assert(git_odb_exists(odb, &id));
67
+
68
+ /* Test for a non-existant object */
69
+ cl_git_pass(git_oid_fromstr(&id2, "8b137891791fe96927ad78e64b0aad7bded08baa"));
70
+ cl_assert(!git_odb_exists(odb, &id2));
71
+
72
+ git_odb_free(odb);
73
+ }
74
+
75
+ void test_odb_loose__simple_reads(void)
76
+ {
77
+ test_read_object(&commit);
78
+ test_read_object(&tree);
79
+ test_read_object(&tag);
80
+ test_read_object(&zero);
81
+ test_read_object(&one);
82
+ test_read_object(&two);
83
+ test_read_object(&some);
84
+ }