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,238 @@
1
+ /*
2
+ * The MIT License
3
+ *
4
+ * Copyright (c) 2011 GitHub, Inc
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ */
24
+
25
+ #include "rugged.h"
26
+
27
+ extern VALUE rb_mRugged;
28
+ VALUE rb_cRuggedConfig;
29
+
30
+ void rb_git_config__free(git_config *config)
31
+ {
32
+ git_config_free(config);
33
+ }
34
+
35
+ VALUE rugged_config_new(VALUE klass, VALUE owner, git_config *cfg)
36
+ {
37
+ VALUE rb_config = Data_Wrap_Struct(klass, NULL, &rb_git_config__free, cfg);
38
+ rugged_set_owner(rb_config, owner);
39
+ return owner;
40
+ }
41
+
42
+ static VALUE rb_git_config_new(VALUE klass, VALUE rb_path)
43
+ {
44
+ git_config *config = NULL;
45
+ int error, i;
46
+
47
+ if (TYPE(rb_path) == T_ARRAY) {
48
+ error = git_config_new(&config);
49
+ rugged_exception_check(error);
50
+
51
+ for (i = 0; i < RARRAY_LEN(rb_path); ++i) {
52
+ VALUE f = rb_ary_entry(rb_path, i);
53
+ Check_Type(f, T_STRING);
54
+ error = git_config_add_file_ondisk(config, StringValueCStr(f), i + 1);
55
+ rugged_exception_check(error);
56
+ }
57
+ } else if (TYPE(rb_path) == T_STRING) {
58
+ error = git_config_open_ondisk(&config, StringValueCStr(rb_path));
59
+ rugged_exception_check(error);
60
+ } else {
61
+ rb_raise(rb_eTypeError, "Expecting a filename or an array of filenames");
62
+ }
63
+
64
+ return rugged_config_new(klass, Qnil, config);
65
+ }
66
+
67
+ static VALUE rb_git_config_get(VALUE self, VALUE rb_key)
68
+ {
69
+ git_config *config;
70
+ const char *value;
71
+ int error;
72
+
73
+ Data_Get_Struct(self, git_config, config);
74
+ Check_Type(rb_key, T_STRING);
75
+
76
+ error = git_config_get_string(config, StringValueCStr(rb_key), &value);
77
+ if (error == GIT_ENOTFOUND)
78
+ return Qnil;
79
+
80
+ rugged_exception_check(error);
81
+
82
+ /* Return all config values as ASCII strings */
83
+ return rugged_str_new2(value, NULL);
84
+ }
85
+
86
+ static VALUE rb_git_config_store(VALUE self, VALUE rb_key, VALUE rb_val)
87
+ {
88
+ git_config *config;
89
+ const char *key;
90
+ int error;
91
+
92
+ Data_Get_Struct(self, git_config, config);
93
+ Check_Type(rb_key, T_STRING);
94
+
95
+ key = StringValueCStr(rb_key);
96
+
97
+ switch (TYPE(rb_val)) {
98
+ case T_STRING:
99
+ error = git_config_set_string(config, key, StringValueCStr(rb_val));
100
+ break;
101
+
102
+ case T_TRUE:
103
+ case T_FALSE:
104
+ error = git_config_set_bool(config, key, (rb_val == Qtrue));
105
+ break;
106
+
107
+ case T_FIXNUM:
108
+ error = git_config_set_int32(config, key, FIX2INT(rb_val));
109
+ break;
110
+
111
+ default:
112
+ rb_raise(rb_eTypeError,
113
+ "Invalid value; config files can only store string, bool or int keys");
114
+ }
115
+
116
+ rugged_exception_check(error);
117
+ return Qnil;
118
+ }
119
+
120
+ static VALUE rb_git_config_delete(VALUE self, VALUE rb_key)
121
+ {
122
+ git_config *config;
123
+ int error;
124
+ VALUE result;
125
+
126
+ Data_Get_Struct(self, git_config, config);
127
+ Check_Type(rb_key, T_STRING);
128
+
129
+ error = git_config_delete(config, StringValueCStr(rb_key));
130
+ if (error == GIT_ENOTFOUND)
131
+ return Qfalse;
132
+
133
+ rugged_exception_check(error);
134
+ return Qtrue;
135
+ }
136
+
137
+ static int cb_config__each_key(const char *key, const char *value, void *opaque)
138
+ {
139
+ rb_funcall((VALUE)opaque, rb_intern("call"), 1, rugged_str_new2(key, NULL));
140
+ return GIT_SUCCESS;
141
+ }
142
+
143
+ static int cb_config__each_pair(const char *key, const char *value, void *opaque)
144
+ {
145
+ rb_funcall((VALUE)opaque, rb_intern("call"), 2,
146
+ rugged_str_new2(key, NULL),
147
+ rugged_str_new2(value, NULL));
148
+
149
+ return GIT_SUCCESS;
150
+ }
151
+
152
+ static int cb_config__to_hash(const char *key, const char *value, void *opaque)
153
+ {
154
+ rb_hash_aset((VALUE)opaque,
155
+ rugged_str_new2(key, NULL),
156
+ rugged_str_new2(value, NULL));
157
+
158
+ return GIT_SUCCESS;
159
+ }
160
+
161
+ static VALUE rb_git_config_each_key(VALUE self)
162
+ {
163
+ git_config *config;
164
+ int error;
165
+
166
+ Data_Get_Struct(self, git_config, config);
167
+
168
+ if (!rb_block_given_p())
169
+ return rb_funcall(self, rb_intern("to_enum"), 1, CSTR2SYM("each_key"));
170
+
171
+ error = git_config_foreach(config, &cb_config__each_key, (void *)rb_block_proc());
172
+ rugged_exception_check(error);
173
+ return Qnil;
174
+ }
175
+
176
+ static VALUE rb_git_config_each_pair(VALUE self)
177
+ {
178
+ git_config *config;
179
+ int error;
180
+
181
+ Data_Get_Struct(self, git_config, config);
182
+
183
+ if (!rb_block_given_p())
184
+ return rb_funcall(self, rb_intern("to_enum"), 1, CSTR2SYM("each_pair"));
185
+
186
+ error = git_config_foreach(config, &cb_config__each_pair, (void *)rb_block_proc());
187
+ rugged_exception_check(error);
188
+ return Qnil;
189
+ }
190
+
191
+ static VALUE rb_git_config_to_hash(VALUE self)
192
+ {
193
+ git_config *config;
194
+ int error;
195
+ VALUE hash;
196
+
197
+ Data_Get_Struct(self, git_config, config);
198
+ hash = rb_hash_new();
199
+
200
+ error = git_config_foreach(config, &cb_config__to_hash, (void *)hash);
201
+ rugged_exception_check(error);
202
+ return hash;
203
+ }
204
+
205
+ static VALUE rb_git_config_open_global(VALUE klass)
206
+ {
207
+ git_config *cfg;
208
+ int error;
209
+
210
+ error = git_config_open_global(&cfg);
211
+ rugged_exception_check(error);
212
+
213
+ return rugged_config_new(klass, Qnil, cfg);
214
+ }
215
+
216
+ void Init_rugged_config()
217
+ {
218
+ /*
219
+ * Config
220
+ */
221
+ rb_cRuggedConfig = rb_define_class_under(rb_mRugged, "Config", rb_cObject);
222
+ rb_define_singleton_method(rb_cRuggedConfig, "new", rb_git_config_new, 1);
223
+ rb_define_singleton_method(rb_cRuggedConfig, "open_global", rb_git_config_open_global, 0);
224
+
225
+ rb_define_method(rb_cRuggedConfig, "delete", rb_git_config_delete, 1);
226
+
227
+ rb_define_method(rb_cRuggedConfig, "store", rb_git_config_store, 2);
228
+ rb_define_method(rb_cRuggedConfig, "[]=", rb_git_config_store, 2);
229
+
230
+ rb_define_method(rb_cRuggedConfig, "get", rb_git_config_get, 1);
231
+ rb_define_method(rb_cRuggedConfig, "[]", rb_git_config_get, 1);
232
+
233
+ rb_define_method(rb_cRuggedConfig, "each_key", rb_git_config_each_key, 0);
234
+ rb_define_method(rb_cRuggedConfig, "each_pair", rb_git_config_each_pair, 0);
235
+ rb_define_method(rb_cRuggedConfig, "each", rb_git_config_each_pair, 0);
236
+ rb_define_method(rb_cRuggedConfig, "to_hash", rb_git_config_to_hash, 0);
237
+
238
+ }
@@ -0,0 +1,440 @@
1
+ /*
2
+ * The MIT License
3
+ *
4
+ * Copyright (c) 2011 GitHub, Inc
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ */
24
+
25
+ #include "rugged.h"
26
+
27
+ extern VALUE rb_mRugged;
28
+ VALUE rb_cRuggedIndex;
29
+
30
+ static void rb_git_indexentry_toC(git_index_entry *entry, VALUE rb_entry);
31
+ static VALUE rb_git_indexentry_fromC(git_index_entry *entry);
32
+ static VALUE rb_git_unmerged_fromC(const git_index_entry_unmerged *entry);
33
+
34
+ /*
35
+ * Index
36
+ */
37
+
38
+ void rb_git_index__free(git_index *index)
39
+ {
40
+ git_index_free(index);
41
+ }
42
+
43
+ VALUE rugged_index_new(VALUE klass, VALUE owner, git_index *index)
44
+ {
45
+ VALUE rb_index = Data_Wrap_Struct(klass, NULL, &rb_git_index__free, index);
46
+ rugged_set_owner(rb_index, owner);
47
+ return rb_index;
48
+ }
49
+
50
+ static VALUE rb_git_index_new(VALUE klass, VALUE path)
51
+ {
52
+ git_index *index;
53
+ int error;
54
+
55
+ Check_Type(path, T_STRING);
56
+
57
+ error = git_index_open(&index, StringValueCStr(path));
58
+ rugged_exception_check(error);
59
+
60
+ return rugged_index_new(klass, Qnil, index);
61
+ }
62
+
63
+ static VALUE rb_git_index_clear(VALUE self)
64
+ {
65
+ git_index *index;
66
+ Data_Get_Struct(self, git_index, index);
67
+ git_index_clear(index);
68
+ return Qnil;
69
+ }
70
+
71
+ static VALUE rb_git_index_read(VALUE self)
72
+ {
73
+ git_index *index;
74
+ int error;
75
+
76
+ Data_Get_Struct(self, git_index, index);
77
+
78
+ error = git_index_read(index);
79
+ rugged_exception_check(error);
80
+
81
+ return Qnil;
82
+ }
83
+
84
+ static VALUE rb_git_index_write(VALUE self)
85
+ {
86
+ git_index *index;
87
+ int error;
88
+
89
+ Data_Get_Struct(self, git_index, index);
90
+
91
+ error = git_index_write(index);
92
+ rugged_exception_check(error);
93
+
94
+ return Qnil;
95
+ }
96
+
97
+ static VALUE rb_git_index_uniq(VALUE self)
98
+ {
99
+ git_index *index;
100
+ Data_Get_Struct(self, git_index, index);
101
+ git_index_uniq(index);
102
+ return Qnil;
103
+ }
104
+
105
+ static VALUE rb_git_index_count(VALUE self)
106
+ {
107
+ git_index *index;
108
+ Data_Get_Struct(self, git_index, index);
109
+ return INT2FIX(git_index_entrycount(index));
110
+ }
111
+
112
+ static VALUE rb_git_index_count_unmerged(VALUE self)
113
+ {
114
+ git_index *index;
115
+ Data_Get_Struct(self, git_index, index);
116
+ return INT2FIX(git_index_entrycount_unmerged(index));
117
+ }
118
+
119
+ static VALUE rb_git_index_get(VALUE self, VALUE entry)
120
+ {
121
+ git_index *index;
122
+ Data_Get_Struct(self, git_index, index);
123
+
124
+ if (TYPE(entry) == T_STRING)
125
+ entry = INT2FIX(git_index_find(index, StringValueCStr(entry)));
126
+
127
+ Check_Type(entry, T_FIXNUM);
128
+ return rb_git_indexentry_fromC(git_index_get(index, FIX2INT(entry)));
129
+ }
130
+
131
+ static VALUE rb_git_index_each(VALUE self)
132
+ {
133
+ git_index *index;
134
+ unsigned int i, count;
135
+
136
+ Data_Get_Struct(self, git_index, index);
137
+
138
+ if (!rb_block_given_p())
139
+ return rb_funcall(self, rb_intern("to_enum"), 0);
140
+
141
+ count = git_index_entrycount(index);
142
+ for (i = 0; i < count; ++i) {
143
+ git_index_entry *entry = git_index_get(index, i);
144
+ if (entry)
145
+ rb_yield(rb_git_indexentry_fromC(entry));
146
+ }
147
+
148
+ return Qnil;
149
+ }
150
+
151
+ static VALUE rb_git_index_get_unmerged(VALUE self, VALUE entry)
152
+ {
153
+ git_index *index;
154
+ Data_Get_Struct(self, git_index, index);
155
+
156
+ if (TYPE(entry) == T_STRING)
157
+ return rb_git_unmerged_fromC(git_index_get_unmerged_bypath(index, StringValueCStr(entry)));
158
+
159
+ if (TYPE(entry) == T_FIXNUM)
160
+ return rb_git_unmerged_fromC(git_index_get_unmerged_byindex(index, FIX2INT(entry)));
161
+
162
+ rb_raise(rb_eTypeError, "Expecting a path name or index for unmerged entries");
163
+ }
164
+
165
+ static VALUE rb_git_index_remove(VALUE self, VALUE entry)
166
+ {
167
+ git_index *index;
168
+ int error;
169
+ Data_Get_Struct(self, git_index, index);
170
+
171
+ if (TYPE(entry) == T_STRING)
172
+ entry = INT2FIX(git_index_find(index, StringValueCStr(entry)));
173
+
174
+ Check_Type(entry, T_FIXNUM);
175
+
176
+ error = git_index_remove(index, FIX2INT(entry));
177
+ rugged_exception_check(error);
178
+
179
+ return Qnil;
180
+ }
181
+
182
+ static VALUE rb_git_index_add(int argc, VALUE *argv, VALUE self)
183
+ {
184
+ git_index *index;
185
+ int error;
186
+ VALUE rb_entry, rb_stage;
187
+
188
+ rb_scan_args(argc, argv, "11", &rb_entry, &rb_stage);
189
+
190
+ Data_Get_Struct(self, git_index, index);
191
+
192
+ if (TYPE(rb_entry) == T_HASH) {
193
+ git_index_entry entry;
194
+ if (argc > 1)
195
+ rb_raise(rb_eTypeError,
196
+ "Wrong number or arguments (only an Index Entry is expected");
197
+
198
+ rb_git_indexentry_toC(&entry, rb_entry);
199
+ error = git_index_add2(index, &entry);
200
+ } else if (TYPE(rb_entry) == T_STRING) {
201
+ int stage = 0;
202
+ if (!NIL_P(rb_stage))
203
+ stage = NUM2INT(rb_stage);
204
+ error = git_index_add(index, StringValueCStr(rb_entry), stage);
205
+ } else {
206
+ rb_raise(rb_eTypeError,
207
+ "Expecting a hash defining an Index Entry or a path to a file in the repository");
208
+ }
209
+
210
+ rugged_exception_check(error);
211
+ return Qnil;
212
+ }
213
+
214
+ static VALUE rb_git_index_append(int argc, VALUE *argv, VALUE self)
215
+ {
216
+ git_index *index;
217
+ int error;
218
+ VALUE rb_entry, rb_stage;
219
+
220
+ rb_scan_args(argc, argv, "11", &rb_entry, &rb_stage);
221
+
222
+ Data_Get_Struct(self, git_index, index);
223
+
224
+ if (TYPE(rb_entry) == T_HASH) {
225
+ git_index_entry entry;
226
+ rb_git_indexentry_toC(&entry, rb_entry);
227
+ error = git_index_append2(index, &entry);
228
+ } else if (TYPE(rb_entry) == T_STRING) {
229
+ Check_Type(rb_stage, T_FIXNUM);
230
+ error = git_index_append(index, StringValueCStr(rb_entry), FIX2INT(rb_stage));
231
+ } else {
232
+ rb_raise(rb_eTypeError,
233
+ "Expecting a hash defining an Index Entry or a path to a file in the repository");
234
+ }
235
+
236
+ rugged_exception_check(error);
237
+ return Qnil;
238
+ }
239
+
240
+
241
+ /*
242
+ * Index Entry
243
+ */
244
+ static VALUE rb_git_unmerged_fromC(const git_index_entry_unmerged *entry)
245
+ {
246
+ int i;
247
+ VALUE rb_entry, rb_modes, rb_oids;
248
+
249
+ if (!entry)
250
+ return Qnil;
251
+
252
+ rb_modes = rb_ary_new2(3);
253
+ rb_oids = rb_ary_new2(3);
254
+ for (i = 0; i < 3; ++i) {
255
+ rb_ary_push(rb_modes, INT2FIX(entry->mode[i]));
256
+ rb_ary_push(rb_oids, rugged_create_oid(&entry->oid[i]));
257
+ }
258
+
259
+ rb_entry = rb_hash_new();
260
+ rb_hash_aset(rb_entry, CSTR2SYM("path"), rugged_str_new2(entry->path, NULL));
261
+ rb_hash_aset(rb_entry, CSTR2SYM("oids"), rb_oids);
262
+ rb_hash_aset(rb_entry, CSTR2SYM("modes"), rb_modes);
263
+
264
+ return rb_entry;
265
+ }
266
+
267
+
268
+
269
+ static VALUE rb_git_indexentry_fromC(git_index_entry *entry)
270
+ {
271
+ VALUE rb_entry, rb_mtime, rb_ctime;
272
+ unsigned int valid, stage;
273
+
274
+ if (!entry)
275
+ return Qnil;
276
+
277
+ rb_entry = rb_hash_new();
278
+
279
+ rb_hash_aset(rb_entry, CSTR2SYM("path"), rugged_str_new2(entry->path, NULL));
280
+ rb_hash_aset(rb_entry, CSTR2SYM("oid"), rugged_create_oid(&entry->oid));
281
+
282
+ rb_hash_aset(rb_entry, CSTR2SYM("dev"), INT2FIX(entry->dev));
283
+ rb_hash_aset(rb_entry, CSTR2SYM("ino"), INT2FIX(entry->ino));
284
+ rb_hash_aset(rb_entry, CSTR2SYM("mode"), INT2FIX(entry->mode));
285
+ rb_hash_aset(rb_entry, CSTR2SYM("gid"), INT2FIX(entry->gid));
286
+ rb_hash_aset(rb_entry, CSTR2SYM("uid"), INT2FIX(entry->uid));
287
+ rb_hash_aset(rb_entry, CSTR2SYM("file_size"), INT2FIX(entry->file_size));
288
+
289
+ valid = (entry->flags & GIT_IDXENTRY_VALID);
290
+ rb_hash_aset(rb_entry, CSTR2SYM("valid"), valid ? Qtrue : Qfalse);
291
+
292
+ stage = (entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT;
293
+ rb_hash_aset(rb_entry, CSTR2SYM("stage"), INT2FIX(stage));
294
+
295
+ rb_mtime = rb_time_new(entry->mtime.seconds, entry->mtime.nanoseconds / 1000);
296
+ rb_ctime = rb_time_new(entry->ctime.seconds, entry->ctime.nanoseconds / 1000);
297
+
298
+ rb_hash_aset(rb_entry, CSTR2SYM("ctime"), rb_ctime);
299
+ rb_hash_aset(rb_entry, CSTR2SYM("mtime"), rb_mtime);
300
+
301
+ return rb_entry;
302
+ }
303
+
304
+ static void rb_git_indexentry_toC(git_index_entry *entry, VALUE rb_entry)
305
+ {
306
+ VALUE val;
307
+
308
+ Check_Type(rb_entry, T_HASH);
309
+
310
+ #define GET_ENTRY_VAL(v, t) \
311
+ rb_hash_aref(rb_entry, CSTR2SYM(v)); \
312
+ Check_Type(val, t);
313
+
314
+ val = GET_ENTRY_VAL("path", T_STRING);
315
+ entry->path = StringValueCStr(val);
316
+
317
+ val = GET_ENTRY_VAL("oid", T_STRING);
318
+ rugged_exception_check(git_oid_fromstr(&entry->oid, StringValueCStr(val)));
319
+
320
+ val = GET_ENTRY_VAL("dev", T_FIXNUM);
321
+ entry->dev = FIX2INT(val);
322
+
323
+ val = GET_ENTRY_VAL("ino", T_FIXNUM);
324
+ entry->ino = FIX2INT(val);
325
+
326
+ val = GET_ENTRY_VAL("mode", T_FIXNUM);
327
+ entry->mode = FIX2INT(val);
328
+
329
+ val = GET_ENTRY_VAL("gid", T_FIXNUM);
330
+ entry->gid = FIX2INT(val);
331
+
332
+ val = GET_ENTRY_VAL("uid", T_FIXNUM);
333
+ entry->uid = FIX2INT(val);
334
+
335
+ val = GET_ENTRY_VAL("file_size", T_FIXNUM);
336
+ entry->file_size = FIX2INT(val);
337
+
338
+ entry->flags = 0x0;
339
+ entry->flags_extended = 0x0;
340
+
341
+ val = rb_hash_aref(rb_entry, CSTR2SYM("stage"));
342
+ if (!NIL_P(val)) {
343
+ unsigned int stage = NUM2INT(val);
344
+ entry->flags &= ~GIT_IDXENTRY_STAGEMASK;
345
+ entry->flags |= (stage << GIT_IDXENTRY_STAGESHIFT) & GIT_IDXENTRY_STAGEMASK;
346
+ }
347
+
348
+ val = rb_hash_aref(rb_entry, CSTR2SYM("valid"));
349
+ if (!NIL_P(val)) {
350
+ entry->flags &= ~GIT_IDXENTRY_VALID;
351
+ if (rugged_parse_bool(val))
352
+ entry->flags |= GIT_IDXENTRY_VALID;
353
+ } /* TODO: always valid by default? */
354
+
355
+ val = rb_hash_aref(rb_entry, CSTR2SYM("mtime"));
356
+ if (!rb_obj_is_kind_of(val, rb_cTime))
357
+ rb_raise(rb_eTypeError, ":mtime must be a Time instance");
358
+ entry->mtime.seconds = NUM2INT(rb_funcall(val, rb_intern("to_i"), 0));
359
+ entry->mtime.nanoseconds = NUM2INT(rb_funcall(val, rb_intern("usec"), 0)) * 1000;
360
+
361
+ val = rb_hash_aref(rb_entry, CSTR2SYM("ctime"));
362
+ if (!rb_obj_is_kind_of(val, rb_cTime))
363
+ rb_raise(rb_eTypeError, ":ctime must be a Time instance");
364
+ entry->ctime.seconds = NUM2INT(rb_funcall(val, rb_intern("to_i"), 0));
365
+ entry->ctime.nanoseconds = NUM2INT(rb_funcall(val, rb_intern("usec"), 0)) * 1000;
366
+
367
+ #undef GET_ENTRY_VAL
368
+ }
369
+
370
+ VALUE rb_git_indexer(VALUE self, VALUE rb_packfile_path)
371
+ {
372
+ int error;
373
+ git_indexer *indexer;
374
+ VALUE rb_oid;
375
+
376
+ Check_Type(rb_packfile_path, T_STRING);
377
+
378
+ error = git_indexer_new(&indexer, StringValueCStr(rb_packfile_path));
379
+ rugged_exception_check(error);
380
+
381
+ error = git_indexer_run(indexer, NULL);
382
+ rugged_exception_check(error);
383
+
384
+ error = git_indexer_write(indexer);
385
+ rugged_exception_check(error);
386
+
387
+ rb_oid = rugged_create_oid(git_indexer_hash(indexer));
388
+
389
+ git_indexer_free(indexer);
390
+ return rb_oid;
391
+ }
392
+
393
+ VALUE rb_git_index_writetree(VALUE self)
394
+ {
395
+ git_index *index;
396
+ git_oid tree_oid;
397
+ int error;
398
+
399
+ Data_Get_Struct(self, git_index, index);
400
+
401
+ error = git_tree_create_fromindex(&tree_oid, index);
402
+ rugged_exception_check(error);
403
+
404
+ return rugged_create_oid(&tree_oid);
405
+ }
406
+
407
+ void Init_rugged_index()
408
+ {
409
+ /*
410
+ * Index
411
+ */
412
+ rb_cRuggedIndex = rb_define_class_under(rb_mRugged, "Index", rb_cObject);
413
+ rb_define_singleton_method(rb_cRuggedIndex, "new", rb_git_index_new, 1);
414
+
415
+ rb_define_method(rb_cRuggedIndex, "count", rb_git_index_count, 0);
416
+ rb_define_method(rb_cRuggedIndex, "count_unmerged", rb_git_index_count_unmerged, 0);
417
+ rb_define_method(rb_cRuggedIndex, "reload", rb_git_index_read, 0);
418
+ rb_define_method(rb_cRuggedIndex, "clear", rb_git_index_clear, 0);
419
+ rb_define_method(rb_cRuggedIndex, "write", rb_git_index_write, 0);
420
+ rb_define_method(rb_cRuggedIndex, "uniq!", rb_git_index_uniq, 0);
421
+ rb_define_method(rb_cRuggedIndex, "get_entry", rb_git_index_get, 1);
422
+ rb_define_method(rb_cRuggedIndex, "get_unmerged", rb_git_index_get_unmerged, 1);
423
+ rb_define_method(rb_cRuggedIndex, "[]", rb_git_index_get, 1);
424
+ rb_define_method(rb_cRuggedIndex, "each", rb_git_index_each, 0);
425
+
426
+ rb_define_method(rb_cRuggedIndex, "add", rb_git_index_add, -1);
427
+ rb_define_method(rb_cRuggedIndex, "update", rb_git_index_add, -1);
428
+
429
+ rb_define_method(rb_cRuggedIndex, "append", rb_git_index_append, -1);
430
+ rb_define_method(rb_cRuggedIndex, "<<", rb_git_index_append, -1);
431
+
432
+ rb_define_method(rb_cRuggedIndex, "remove", rb_git_index_remove, 1);
433
+ rb_define_method(rb_cRuggedIndex, "write_tree", rb_git_index_writetree, 0);
434
+
435
+ rb_define_singleton_method(rb_cRuggedIndex, "index_pack", rb_git_indexer, 1);
436
+
437
+ rb_const_set(rb_cRuggedIndex, rb_intern("ENTRY_FLAGS_STAGE"), INT2FIX(GIT_IDXENTRY_STAGEMASK));
438
+ rb_const_set(rb_cRuggedIndex, rb_intern("ENTRY_FLAGS_STAGE_SHIFT"), INT2FIX(GIT_IDXENTRY_STAGESHIFT));
439
+ rb_const_set(rb_cRuggedIndex, rb_intern("ENTRY_FLAGS_VALID"), INT2FIX(GIT_IDXENTRY_VALID));
440
+ }