rugged 0.16.0 → 0.17.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (392) hide show
  1. data/README.md +373 -243
  2. data/Rakefile +22 -0
  3. data/ext/rugged/extconf.rb +9 -6
  4. data/ext/rugged/rugged.c +123 -31
  5. data/ext/rugged/rugged.h +11 -10
  6. data/ext/rugged/rugged_blob.c +181 -18
  7. data/ext/rugged/rugged_commit.c +196 -18
  8. data/ext/rugged/rugged_config.c +94 -5
  9. data/ext/rugged/rugged_object.c +54 -1
  10. data/ext/rugged/rugged_reference.c +203 -15
  11. data/ext/rugged/{remote.c → rugged_remote.c} +35 -10
  12. data/ext/rugged/rugged_repo.c +323 -81
  13. data/ext/rugged/rugged_revwalk.c +57 -4
  14. data/ext/rugged/rugged_signature.c +3 -3
  15. data/ext/rugged/rugged_tag.c +72 -1
  16. data/ext/rugged/rugged_tree.c +70 -2
  17. data/ext/rugged/vendor/libgit2-dist/deps/regex/config.h +7 -0
  18. data/ext/rugged/vendor/libgit2-dist/deps/regex/regcomp.c +3856 -0
  19. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex.c +85 -0
  20. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex.h +582 -0
  21. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex_internal.c +1744 -0
  22. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex_internal.h +810 -0
  23. data/ext/rugged/vendor/libgit2-dist/deps/regex/regexec.c +4369 -0
  24. data/ext/rugged/vendor/libgit2-dist/examples/diff.c +238 -0
  25. data/ext/rugged/vendor/libgit2-dist/examples/general.c +4 -4
  26. data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +101 -85
  27. data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +7 -3
  28. data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +80 -25
  29. data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +6 -6
  30. data/ext/rugged/vendor/libgit2-dist/include/git2/attr.h +224 -0
  31. data/ext/rugged/vendor/libgit2-dist/include/git2/blob.h +59 -5
  32. data/ext/rugged/vendor/libgit2-dist/include/git2/branch.h +114 -7
  33. data/ext/rugged/vendor/libgit2-dist/include/git2/commit.h +14 -7
  34. data/ext/rugged/vendor/libgit2-dist/include/git2/common.h +4 -3
  35. data/ext/rugged/vendor/libgit2-dist/include/git2/config.h +105 -27
  36. data/ext/rugged/vendor/libgit2-dist/include/git2/diff.h +409 -0
  37. data/ext/rugged/vendor/libgit2-dist/include/git2/errors.h +47 -82
  38. data/ext/rugged/vendor/libgit2-dist/include/git2/index.h +25 -10
  39. data/ext/rugged/vendor/libgit2-dist/include/git2/indexer.h +46 -1
  40. data/ext/rugged/vendor/libgit2-dist/include/git2/merge.h +35 -0
  41. data/ext/rugged/vendor/libgit2-dist/include/git2/net.h +1 -1
  42. data/ext/rugged/vendor/libgit2-dist/include/git2/notes.h +139 -0
  43. data/ext/rugged/vendor/libgit2-dist/include/git2/object.h +5 -5
  44. data/ext/rugged/vendor/libgit2-dist/include/git2/odb.h +13 -13
  45. data/ext/rugged/vendor/libgit2-dist/include/git2/odb_backend.h +8 -8
  46. data/ext/rugged/vendor/libgit2-dist/include/git2/oid.h +14 -9
  47. data/ext/rugged/vendor/libgit2-dist/include/git2/reflog.h +5 -5
  48. data/ext/rugged/vendor/libgit2-dist/include/git2/refs.h +37 -17
  49. data/ext/rugged/vendor/libgit2-dist/include/git2/refspec.h +17 -9
  50. data/ext/rugged/vendor/libgit2-dist/include/git2/remote.h +83 -16
  51. data/ext/rugged/vendor/libgit2-dist/include/git2/repository.h +24 -10
  52. data/ext/rugged/vendor/libgit2-dist/include/git2/reset.h +44 -0
  53. data/ext/rugged/vendor/libgit2-dist/include/git2/revparse.h +36 -0
  54. data/ext/rugged/vendor/libgit2-dist/include/git2/revwalk.h +74 -6
  55. data/ext/rugged/vendor/libgit2-dist/include/git2/signature.h +3 -3
  56. data/ext/rugged/vendor/libgit2-dist/include/git2/status.h +120 -19
  57. data/ext/rugged/vendor/libgit2-dist/include/git2/submodule.h +103 -0
  58. data/ext/rugged/vendor/libgit2-dist/include/git2/tag.h +28 -10
  59. data/ext/rugged/vendor/libgit2-dist/include/git2/threads.h +1 -1
  60. data/ext/rugged/vendor/libgit2-dist/include/git2/tree.h +13 -13
  61. data/ext/rugged/vendor/libgit2-dist/include/git2/types.h +16 -2
  62. data/ext/rugged/vendor/libgit2-dist/include/git2/version.h +3 -3
  63. data/ext/rugged/vendor/libgit2-dist/include/git2/windows.h +1 -1
  64. data/ext/rugged/vendor/libgit2-dist/include/git2.h +7 -2
  65. data/ext/rugged/vendor/libgit2-dist/src/attr.c +677 -0
  66. data/ext/rugged/vendor/libgit2-dist/src/attr.h +56 -0
  67. data/ext/rugged/vendor/libgit2-dist/src/attr_file.c +609 -0
  68. data/ext/rugged/vendor/libgit2-dist/src/attr_file.h +145 -0
  69. data/ext/rugged/vendor/libgit2-dist/src/blob.c +213 -60
  70. data/ext/rugged/vendor/libgit2-dist/src/blob.h +2 -1
  71. data/ext/rugged/vendor/libgit2-dist/src/branch.c +208 -0
  72. data/ext/rugged/vendor/libgit2-dist/src/branch.h +17 -0
  73. data/ext/rugged/vendor/libgit2-dist/src/bswap.h +1 -1
  74. data/ext/rugged/vendor/libgit2-dist/src/buffer.c +395 -46
  75. data/ext/rugged/vendor/libgit2-dist/src/buffer.h +112 -9
  76. data/ext/rugged/vendor/libgit2-dist/src/cache.c +37 -49
  77. data/ext/rugged/vendor/libgit2-dist/src/cache.h +7 -17
  78. data/ext/rugged/vendor/libgit2-dist/src/cc-compat.h +18 -16
  79. data/ext/rugged/vendor/libgit2-dist/src/commit.c +56 -90
  80. data/ext/rugged/vendor/libgit2-dist/src/commit.h +1 -1
  81. data/ext/rugged/vendor/libgit2-dist/src/common.h +12 -5
  82. data/ext/rugged/vendor/libgit2-dist/src/{win32 → compat}/fnmatch.c +1 -1
  83. data/ext/rugged/vendor/libgit2-dist/src/{win32 → compat}/fnmatch.h +3 -3
  84. data/ext/rugged/vendor/libgit2-dist/src/config.c +247 -158
  85. data/ext/rugged/vendor/libgit2-dist/src/config.h +10 -1
  86. data/ext/rugged/vendor/libgit2-dist/src/config_cache.c +94 -0
  87. data/ext/rugged/vendor/libgit2-dist/src/config_file.c +606 -496
  88. data/ext/rugged/vendor/libgit2-dist/src/config_file.h +31 -0
  89. data/ext/rugged/vendor/libgit2-dist/src/crlf.c +228 -0
  90. data/ext/rugged/vendor/libgit2-dist/src/date.c +876 -0
  91. data/ext/rugged/vendor/libgit2-dist/src/delta-apply.c +15 -9
  92. data/ext/rugged/vendor/libgit2-dist/src/delta-apply.h +2 -2
  93. data/ext/rugged/vendor/libgit2-dist/src/diff.c +814 -0
  94. data/ext/rugged/vendor/libgit2-dist/src/diff.h +43 -0
  95. data/ext/rugged/vendor/libgit2-dist/src/diff_output.c +794 -0
  96. data/ext/rugged/vendor/libgit2-dist/src/errors.c +89 -74
  97. data/ext/rugged/vendor/libgit2-dist/src/fetch.c +94 -66
  98. data/ext/rugged/vendor/libgit2-dist/src/fetch.h +5 -4
  99. data/ext/rugged/vendor/libgit2-dist/src/filebuf.c +157 -100
  100. data/ext/rugged/vendor/libgit2-dist/src/filebuf.h +22 -8
  101. data/ext/rugged/vendor/libgit2-dist/src/fileops.c +330 -206
  102. data/ext/rugged/vendor/libgit2-dist/src/fileops.h +82 -51
  103. data/ext/rugged/vendor/libgit2-dist/src/filter.c +165 -0
  104. data/ext/rugged/vendor/libgit2-dist/src/filter.h +119 -0
  105. data/ext/rugged/vendor/libgit2-dist/src/global.c +4 -4
  106. data/ext/rugged/vendor/libgit2-dist/src/global.h +4 -1
  107. data/ext/rugged/vendor/libgit2-dist/src/hash.c +1 -1
  108. data/ext/rugged/vendor/libgit2-dist/src/hash.h +1 -1
  109. data/ext/rugged/vendor/libgit2-dist/src/ignore.c +203 -0
  110. data/ext/rugged/vendor/libgit2-dist/src/ignore.h +38 -0
  111. data/ext/rugged/vendor/libgit2-dist/src/index.c +220 -169
  112. data/ext/rugged/vendor/libgit2-dist/src/index.h +5 -1
  113. data/ext/rugged/vendor/libgit2-dist/src/indexer.c +601 -102
  114. data/ext/rugged/vendor/libgit2-dist/src/iterator.c +748 -0
  115. data/ext/rugged/vendor/libgit2-dist/src/iterator.h +151 -0
  116. data/ext/rugged/vendor/libgit2-dist/src/khash.h +608 -0
  117. data/ext/rugged/vendor/libgit2-dist/src/map.h +6 -1
  118. data/ext/rugged/vendor/libgit2-dist/src/message.c +61 -0
  119. data/ext/rugged/vendor/libgit2-dist/src/message.h +14 -0
  120. data/ext/rugged/vendor/libgit2-dist/src/mwindow.c +27 -29
  121. data/ext/rugged/vendor/libgit2-dist/src/mwindow.h +4 -4
  122. data/ext/rugged/vendor/libgit2-dist/src/netops.c +375 -56
  123. data/ext/rugged/vendor/libgit2-dist/src/netops.h +12 -9
  124. data/ext/rugged/vendor/libgit2-dist/src/notes.c +548 -0
  125. data/ext/rugged/vendor/libgit2-dist/src/notes.h +28 -0
  126. data/ext/rugged/vendor/libgit2-dist/src/object.c +59 -21
  127. data/ext/rugged/vendor/libgit2-dist/src/odb.c +212 -175
  128. data/ext/rugged/vendor/libgit2-dist/src/odb.h +39 -2
  129. data/ext/rugged/vendor/libgit2-dist/src/odb_loose.c +238 -241
  130. data/ext/rugged/vendor/libgit2-dist/src/odb_pack.c +94 -106
  131. data/ext/rugged/vendor/libgit2-dist/src/oid.c +59 -60
  132. data/ext/rugged/vendor/libgit2-dist/src/oidmap.h +42 -0
  133. data/ext/rugged/vendor/libgit2-dist/src/pack.c +198 -170
  134. data/ext/rugged/vendor/libgit2-dist/src/pack.h +16 -9
  135. data/ext/rugged/vendor/libgit2-dist/src/path.c +496 -106
  136. data/ext/rugged/vendor/libgit2-dist/src/path.h +214 -20
  137. data/ext/rugged/vendor/libgit2-dist/src/pkt.c +88 -159
  138. data/ext/rugged/vendor/libgit2-dist/src/pkt.h +9 -5
  139. data/ext/rugged/vendor/libgit2-dist/src/pool.c +294 -0
  140. data/ext/rugged/vendor/libgit2-dist/src/pool.h +125 -0
  141. data/ext/rugged/vendor/libgit2-dist/src/posix.c +38 -16
  142. data/ext/rugged/vendor/libgit2-dist/src/posix.h +20 -2
  143. data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.c +1 -1
  144. data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.h +1 -1
  145. data/ext/rugged/vendor/libgit2-dist/src/pqueue.c +7 -7
  146. data/ext/rugged/vendor/libgit2-dist/src/pqueue.h +1 -1
  147. data/ext/rugged/vendor/libgit2-dist/src/protocol.c +21 -13
  148. data/ext/rugged/vendor/libgit2-dist/src/protocol.h +1 -1
  149. data/ext/rugged/vendor/libgit2-dist/src/reflog.c +125 -103
  150. data/ext/rugged/vendor/libgit2-dist/src/reflog.h +1 -1
  151. data/ext/rugged/vendor/libgit2-dist/src/refs.c +713 -640
  152. data/ext/rugged/vendor/libgit2-dist/src/refs.h +27 -3
  153. data/ext/rugged/vendor/libgit2-dist/src/refspec.c +51 -17
  154. data/ext/rugged/vendor/libgit2-dist/src/refspec.h +13 -1
  155. data/ext/rugged/vendor/libgit2-dist/src/remote.c +307 -119
  156. data/ext/rugged/vendor/libgit2-dist/src/remote.h +3 -2
  157. data/ext/rugged/vendor/libgit2-dist/src/repository.c +593 -442
  158. data/ext/rugged/vendor/libgit2-dist/src/repository.h +80 -2
  159. data/ext/rugged/vendor/libgit2-dist/src/reset.c +103 -0
  160. data/ext/rugged/vendor/libgit2-dist/src/revparse.c +753 -0
  161. data/ext/rugged/vendor/libgit2-dist/src/revwalk.c +434 -158
  162. data/ext/rugged/vendor/libgit2-dist/src/sha1.c +3 -3
  163. data/ext/rugged/vendor/libgit2-dist/src/sha1.h +2 -2
  164. data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.c +3 -2
  165. data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.h +1 -1
  166. data/ext/rugged/vendor/libgit2-dist/src/signature.c +69 -80
  167. data/ext/rugged/vendor/libgit2-dist/src/signature.h +1 -1
  168. data/ext/rugged/vendor/libgit2-dist/src/status.c +184 -638
  169. data/ext/rugged/vendor/libgit2-dist/src/strmap.h +64 -0
  170. data/ext/rugged/vendor/libgit2-dist/src/submodule.c +387 -0
  171. data/ext/rugged/vendor/libgit2-dist/src/tag.c +162 -137
  172. data/ext/rugged/vendor/libgit2-dist/src/tag.h +2 -1
  173. data/ext/rugged/vendor/libgit2-dist/src/thread-utils.c +1 -1
  174. data/ext/rugged/vendor/libgit2-dist/src/thread-utils.h +8 -8
  175. data/ext/rugged/vendor/libgit2-dist/src/transport.c +31 -19
  176. data/ext/rugged/vendor/libgit2-dist/src/transport.h +31 -11
  177. data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +168 -193
  178. data/ext/rugged/vendor/libgit2-dist/src/transports/http.c +192 -241
  179. data/ext/rugged/vendor/libgit2-dist/src/transports/local.c +92 -86
  180. data/ext/rugged/vendor/libgit2-dist/src/tree-cache.c +32 -49
  181. data/ext/rugged/vendor/libgit2-dist/src/tree-cache.h +1 -1
  182. data/ext/rugged/vendor/libgit2-dist/src/tree.c +172 -145
  183. data/ext/rugged/vendor/libgit2-dist/src/tree.h +16 -2
  184. data/ext/rugged/vendor/libgit2-dist/src/tsort.c +16 -14
  185. data/ext/rugged/vendor/libgit2-dist/src/unix/map.c +8 -24
  186. data/ext/rugged/vendor/libgit2-dist/src/unix/posix.h +9 -3
  187. data/ext/rugged/vendor/libgit2-dist/src/util.c +94 -38
  188. data/ext/rugged/vendor/libgit2-dist/src/util.h +119 -13
  189. data/ext/rugged/vendor/libgit2-dist/src/vector.c +84 -31
  190. data/ext/rugged/vendor/libgit2-dist/src/vector.h +37 -4
  191. data/ext/rugged/vendor/libgit2-dist/src/win32/dir.c +81 -41
  192. data/ext/rugged/vendor/libgit2-dist/src/{dir.h → win32/dir.h} +4 -9
  193. data/ext/rugged/vendor/libgit2-dist/src/win32/map.c +19 -35
  194. data/ext/rugged/vendor/libgit2-dist/src/win32/mingw-compat.h +1 -1
  195. data/ext/rugged/vendor/libgit2-dist/src/win32/msvc-compat.h +5 -1
  196. data/ext/rugged/vendor/libgit2-dist/src/win32/posix.h +10 -8
  197. data/ext/rugged/vendor/libgit2-dist/src/win32/posix_w32.c +262 -118
  198. data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.c +12 -9
  199. data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.h +1 -1
  200. data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.c +30 -26
  201. data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.h +2 -1
  202. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiff.h +135 -0
  203. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiffi.c +572 -0
  204. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiffi.h +63 -0
  205. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xemit.c +253 -0
  206. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xemit.h +36 -0
  207. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xhistogram.c +371 -0
  208. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xinclude.h +46 -0
  209. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xmacros.h +54 -0
  210. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xmerge.c +619 -0
  211. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xpatience.c +358 -0
  212. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xprepare.c +483 -0
  213. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xprepare.h +34 -0
  214. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xtypes.h +67 -0
  215. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xutils.c +419 -0
  216. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xutils.h +49 -0
  217. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/attr_expect.h +43 -0
  218. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/file.c +226 -0
  219. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/flags.c +108 -0
  220. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/lookup.c +262 -0
  221. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/repo.c +273 -0
  222. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/buf/basic.c +5 -5
  223. data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_helpers.c +181 -0
  224. data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_libgit2.h +55 -0
  225. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/commit.c +44 -0
  226. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/parse.c +350 -0
  227. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/signature.c +65 -0
  228. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/write.c +140 -0
  229. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/add.c +3 -3
  230. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/multivar.c +151 -0
  231. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/new.c +5 -5
  232. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/read.c +44 -32
  233. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/stress.c +61 -0
  234. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/write.c +20 -5
  235. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/buffer.c +613 -0
  236. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/dirent.c +39 -26
  237. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/env.c +115 -0
  238. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/errors.c +60 -0
  239. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/filebuf.c +4 -18
  240. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/hex.c +22 -0
  241. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/oid.c +6 -6
  242. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/path.c +420 -0
  243. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/pool.c +85 -0
  244. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/rmdir.c +68 -0
  245. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/string.c +1 -1
  246. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/strmap.c +102 -0
  247. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/strtol.c +1 -1
  248. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/vector.c +191 -0
  249. data/ext/rugged/vendor/libgit2-dist/tests-clar/date/date.c +15 -0
  250. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/blob.c +254 -0
  251. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.c +104 -0
  252. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.h +47 -0
  253. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/index.c +92 -0
  254. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/iterator.c +572 -0
  255. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/patch.c +99 -0
  256. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/tree.c +210 -0
  257. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/workdir.c +543 -0
  258. data/ext/rugged/vendor/libgit2-dist/tests-clar/index/read_tree.c +46 -0
  259. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/index/rename.c +2 -12
  260. data/ext/rugged/vendor/libgit2-dist/tests-clar/index/tests.c +246 -0
  261. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/createremotethenload.c +33 -0
  262. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotelocal.c +137 -0
  263. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotes.c +183 -0
  264. data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notes.c +133 -0
  265. data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notesref.c +57 -0
  266. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/filter.c +125 -0
  267. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/fromchunks.c +87 -0
  268. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/write.c +69 -0
  269. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/commit/commitstagedfile.c +126 -0
  270. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/lookup.c +63 -0
  271. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/message.c +171 -0
  272. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/chars.c +3 -14
  273. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/compare.c +4 -4
  274. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/convert.c +10 -10
  275. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/data.h +0 -0
  276. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/fromstr.c +1 -1
  277. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/hash.c +21 -17
  278. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/short.c +1 -1
  279. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/size.c +1 -1
  280. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/type2string.c +14 -14
  281. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/write.c +455 -0
  282. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/peel.c +56 -0
  283. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/read.c +130 -0
  284. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/write.c +192 -0
  285. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/tree/frompath.c +22 -16
  286. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/read.c +75 -0
  287. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/write.c +84 -0
  288. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/loose.c +1 -1
  289. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/loose_data.h +0 -0
  290. data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/mixed.c +24 -0
  291. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/pack_data.h +0 -0
  292. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/packed.c +1 -1
  293. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/sorting.c +1 -1
  294. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/create.c +113 -0
  295. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/delete.c +91 -0
  296. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/listall.c +78 -0
  297. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/move.c +72 -0
  298. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/crashes.c +17 -0
  299. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/create.c +149 -0
  300. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/delete.c +85 -0
  301. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/list.c +53 -0
  302. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/listall.c +36 -0
  303. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/lookup.c +42 -0
  304. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/normalize.c +200 -0
  305. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/overwrite.c +136 -0
  306. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/pack.c +67 -0
  307. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/read.c +194 -0
  308. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/reflog.c +123 -0
  309. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/rename.c +339 -0
  310. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/revparse.c +174 -0
  311. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/unicode.c +42 -0
  312. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/discover.c +142 -0
  313. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/repo/getters.c +19 -1
  314. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/init.c +235 -0
  315. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/open.c +282 -0
  316. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/setters.c +80 -0
  317. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/mixed.c +47 -0
  318. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.c +10 -0
  319. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.h +6 -0
  320. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/soft.c +102 -0
  321. data/ext/rugged/vendor/libgit2-dist/{tests/t05-revwalk.c → tests-clar/revwalk/basic.c} +85 -44
  322. data/ext/rugged/vendor/libgit2-dist/tests-clar/revwalk/mergebase.c +148 -0
  323. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/ignore.c +133 -0
  324. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/status/single.c +2 -11
  325. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_data.h +202 -0
  326. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.c +49 -0
  327. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.h +33 -0
  328. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/submodules.c +112 -0
  329. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/worktree.c +649 -0
  330. data/ext/rugged/vendor/libgit2-dist/tests-clar/threads/basic.c +20 -0
  331. data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
  332. data/lib/rugged/commit.rb +35 -0
  333. data/lib/rugged/object.rb +7 -0
  334. data/lib/rugged/reference.rb +9 -0
  335. data/lib/rugged/repository.rb +99 -3
  336. data/lib/rugged/tag.rb +22 -0
  337. data/lib/rugged/tree.rb +8 -0
  338. data/lib/rugged/version.rb +1 -1
  339. data/lib/rugged.rb +4 -1
  340. data/test/blob_test.rb +2 -2
  341. data/test/commit_test.rb +27 -13
  342. data/test/config_test.rb +44 -0
  343. data/test/coverage/HEAD.json +1 -1
  344. data/test/fixtures/testrepo.git/config +2 -0
  345. data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
  346. data/test/lib_test.rb +7 -0
  347. data/test/object_test.rb +3 -3
  348. data/test/reference_test.rb +46 -8
  349. data/test/remote_test.rb +8 -2
  350. data/test/repo_pack_test.rb +3 -3
  351. data/test/repo_test.rb +79 -11
  352. data/test/tag_test.rb +9 -2
  353. data/test/test_helper.rb +21 -0
  354. data/test/tree_test.rb +18 -6
  355. metadata +205 -81
  356. data/ext/rugged/vendor/libgit2-dist/include/git2/zlib.h +0 -40
  357. data/ext/rugged/vendor/libgit2-dist/src/hashtable.c +0 -243
  358. data/ext/rugged/vendor/libgit2-dist/src/hashtable.h +0 -80
  359. data/ext/rugged/vendor/libgit2-dist/tests/t00-core.c +0 -628
  360. data/ext/rugged/vendor/libgit2-dist/tests/t01-data.h +0 -322
  361. data/ext/rugged/vendor/libgit2-dist/tests/t01-rawobj.c +0 -638
  362. data/ext/rugged/vendor/libgit2-dist/tests/t03-data.h +0 -344
  363. data/ext/rugged/vendor/libgit2-dist/tests/t03-objwrite.c +0 -255
  364. data/ext/rugged/vendor/libgit2-dist/tests/t04-commit.c +0 -788
  365. data/ext/rugged/vendor/libgit2-dist/tests/t06-index.c +0 -219
  366. data/ext/rugged/vendor/libgit2-dist/tests/t07-hashtable.c +0 -192
  367. data/ext/rugged/vendor/libgit2-dist/tests/t08-tag.c +0 -357
  368. data/ext/rugged/vendor/libgit2-dist/tests/t09-tree.c +0 -221
  369. data/ext/rugged/vendor/libgit2-dist/tests/t10-refs.c +0 -1294
  370. data/ext/rugged/vendor/libgit2-dist/tests/t12-repo.c +0 -174
  371. data/ext/rugged/vendor/libgit2-dist/tests/t13-threads.c +0 -41
  372. data/ext/rugged/vendor/libgit2-dist/tests/t17-bufs.c +0 -61
  373. data/ext/rugged/vendor/libgit2-dist/tests/t18-status.c +0 -448
  374. data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.c +0 -310
  375. data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.h +0 -83
  376. data/ext/rugged/vendor/libgit2-dist/tests/test_lib.c +0 -198
  377. data/ext/rugged/vendor/libgit2-dist/tests/test_lib.h +0 -54
  378. data/ext/rugged/vendor/libgit2-dist/tests/test_main.c +0 -89
  379. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay.h +0 -187
  380. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_libgit2.h +0 -28
  381. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_main.c +0 -1073
  382. data/ext/rugged/vendor/libgit2-dist/tests-clay/config/stress.c +0 -39
  383. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/path.c +0 -139
  384. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/rmdir.c +0 -50
  385. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/vector.c +0 -66
  386. data/ext/rugged/vendor/libgit2-dist/tests-clay/network/remotes.c +0 -50
  387. data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/init.c +0 -104
  388. data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/open.c +0 -54
  389. data/ext/rugged/vendor/libgit2-dist/tests-clay/status/status_data.h +0 -48
  390. data/ext/rugged/vendor/libgit2-dist/tests-clay/status/worktree.c +0 -124
  391. data/lib/rugged/objects.rb +0 -45
  392. data/test/fixtures/testrepo.git/refs/heads/new_name +0 -1
data/README.md CHANGED
@@ -1,279 +1,409 @@
1
- Rugged - libgit2 bindings in Ruby
2
- ===================================
1
+ # Rugged
2
+ **libgit2 bindings in Ruby**
3
3
 
4
- Rugged is a Ruby bindings to the libgit2 linkable C Git library. This is
5
- for testing and using the libgit2 library in a language that is awesome.
4
+ Rugged is a library for accessing libgit2 in Ruby. It gives you the speed and
5
+ portability of libgit2 with the beauty of the Ruby language.
6
6
 
7
- INSTALLING AND RUNNING
8
- ========================
7
+ ### libgit2
9
8
 
10
- First you need to install libgit2:
9
+ libgit2 is a pure C implementation of the Git core methods. It's designed to be
10
+ fast and portable. For more information about libgit2,
11
+ [check out libgit2's website](http://libgit2.github.com) or browse the
12
+ [libgit2 organization](https://github.com/libgit2) on GitHub.
11
13
 
12
- $ git clone git://github.com/libgit2/libgit2.git
13
- $ cd libgit2
14
- $ mdkir build && cd build
15
- $ cmake ..
16
- $ make
17
- $ make install
14
+ ## Install
18
15
 
19
- Next, you need to install rake-compiler:
16
+ Rugged is a self-contained gem. You can install it by running:
20
17
 
21
- $ sudo gem install rake-compiler
18
+ $ gem install rugged
22
19
 
23
- Now that those are installed, you can install Rugged:
20
+ To load Rugged, you'll usually want to add something like this:
24
21
 
25
- $ git clone git://github.com/libgit2/rugged.git
26
- $ cd rugged
27
- $ rake compile
28
- $ rake test
22
+ ```ruby
23
+ require 'rugged'
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Rugged gives you access to the many parts of a Git repository. You can read and
29
+ write objects, walk a tree, access the staging area, and lots more. Let's look
30
+ at each area individually.
31
+
32
+ ### Repositories
33
+
34
+ #### Instantiation
35
+
36
+ The repository is naturally central to Git. Rugged has a `Repository` class that
37
+ you can instantiate with a path:
38
+
39
+ ```ruby
40
+ repo = Rugged::Repository.new('path/to/my/repository')
41
+ # => #<Rugged::Repository:2228536260 {path: "path/to/my/repository/.git/"}>
42
+ ```
43
+
44
+ If you're working against a bare repository, you'll need to indicate that:
45
+
46
+ ```ruby
47
+ # Second parameter indicates whether the repo is a bare repository
48
+ Rugged::Repository.init_at('.', true)
49
+ ```
50
+
51
+ You can also let Rugged discover the path to the .git directory if you give it a
52
+ subdirectory.
53
+
54
+ ```ruby
55
+ Rugged::Repository.discover("/Users/me/projects/repo/lib/subdir/")
56
+ # => "/Users/me/projects/repo/.git/"
57
+ ```
58
+
59
+ Once your Repository instantiated (in the following examples, as `repo`), you
60
+ can access or modify it.
61
+
62
+ #### Accessing a Repository
63
+
64
+ ```ruby
65
+ # Does the given SHA1 exist in this repository?
66
+ repo.exists?('07b44cbda23b726e5d54e2ef383495922c024202')
67
+ # => true
68
+
69
+ # Boolean repository state values:
70
+ repo.bare?
71
+ # => false
72
+ repo.empty?
73
+ # => true
74
+ repo.head_orphan?
75
+ # => false
76
+ repo.head_detached?
77
+ # => false
78
+
79
+ # Path accessors
80
+ repo.path
81
+ # => "path/to/my/repository/.git/"
82
+ repo.workdir
83
+ # => "path/to/my/repository/"
84
+
85
+ # The HEAD of the repository.
86
+ ref = repo.head
87
+ # => #<Rugged::Reference:2228467240 {name: "refs/heads/master", target: "07b44cbda23b726e5d54e2ef383495922c024202"}>
88
+
89
+ # From the returned ref, you can also access the `name` and `target`:
90
+ ref.name
91
+ # => "refs/heads/master"
92
+ ref.target
93
+ # => "07b44cbda23b726e5d54e2ef383495922c024202"
94
+
95
+ # Reading an object
96
+ object = repo.read('a0ae5566e3c8a3bddffab21022056f0b5e03ef07')
97
+ # => #<Rugged::OdbObject:0x109a64780>
98
+ object.len
99
+ # => 237
100
+ object.data
101
+ # => "tree 76f23f186076fc291742816721ea8c3e95567241\nparent 8e3c5c52b8f29da0adc7e8be8a037cbeaea6de6b\nauthor Vicent Mart\303\255 <tanoku@gmail.com> 1333859005 +0200\ncommitter Vicent Mart\303\255 <tanoku@gmail.com> 1333859005 +0200\n\nAdd `Repository#file_at`\n"
102
+ object.type
103
+ # => :commit
104
+ ```
105
+
106
+ #### Writing to a Repository
107
+
108
+ There's a few ways to write to a repository. To write directly from your
109
+ instantiated repository object:
110
+
111
+ ```ruby
112
+ sha = repo.hash(content, type)
113
+ sha = repo.write(content, type)
114
+ ```
115
+
116
+ You can also use the `Commit` object directly to craft a commit; this is a bit
117
+ more high-level, so it may be preferable.
118
+
119
+ ---
120
+
121
+ ### Objects
122
+
123
+ `Object` is the main object class - it shouldn't be created directly, but all of
124
+ these methods should be useful in their derived classes.
125
+
126
+ ```ruby
127
+ obj = repo.lookup(sha)
128
+ obj.oid # object sha
129
+ obj.type [OBJ_COMMIT, OBJ_TREE, OBJ_BLOB, OBJ_TAG]
130
+
131
+ robj = obj.read_raw
132
+ str = robj.data
133
+ int = robj.len
134
+ ```
135
+
136
+ There are four base object types in Git: **blobs**, **commits**, **tags**, and
137
+ **trees**. Each of these object types have a corresponding class within Rugged.
138
+
139
+ ### Commit Objects
140
+
141
+ ```ruby
142
+ commit = repo.lookup('a0ae5566e3c8a3bddffab21022056f0b5e03ef07')
143
+ # => #<Rugged::Commit:2245304380>
144
+
145
+ commit.message
146
+ # => "Add `Repository#file_at`\n"
147
+
148
+ commit.time
149
+ # => Sat Apr 07 21:23:25 -0700 2012
150
+
151
+ commit.author
152
+ # => {:email=>"tanoku@gmail.com", :name=>"Vicent Mart\303\255", :time=>Sun Apr 08 04:23:25 UTC 2012}
153
+
154
+ commit.tree
155
+ # => #<Rugged::Tree:2245269740>
156
+
157
+ commit.parents
158
+ => [#<Rugged::Commit:2245264600 {message: "Merge pull request #47 from isaac/remotes\n\nAdd Rugged::Repository#remotes", tree: #<Rugged::Tree:2245264240 {oid: 6a2aee58a41fa007d07aa55565e2231f9b39b4a9}>
159
+ ```
160
+
161
+ You can also write new objects to the database this way:
162
+
163
+ ```ruby
164
+ author = {:email=>"tanoku@gmail.com", :time=>Time.now, :name=>"Vicent Mart\303\255"}
165
+
166
+ Rugged::Commit.create(r,
167
+ :author => author,
168
+ :message => "Hello world\n\n",
169
+ :committer => author,
170
+ :parents => ["2cb831a8aea28b2c1b9c63385585b864e4d3bad1"],
171
+ :tree => some_tree) #=> "f148106ca58764adc93ad4e2d6b1d168422b9796"
172
+ ```
173
+
174
+ ### Tag Objects
175
+
176
+ ```ruby
177
+ tag = repo.lookup(tag_sha)
178
+
179
+ object = tag.target
180
+ sha = tag.target.oid
181
+ str = tag.target_type # "commit", "tag", "blob"
182
+ str = tag.name # "v1.0"
183
+ str = tag.message
184
+ person = tag.tagger
185
+ ```
186
+
187
+ ### Tree Objects
188
+
189
+ ```ruby
190
+ tree = repo.lookup('779fbb1e17e666832773a9825875300ea736c2da')
191
+ # => #<Rugged::Tree:2245194360>
192
+
193
+ # number of tree entries
194
+ tree.count
195
+
196
+ tree[0] # or...
197
+ tree.first # or...
198
+ tree.get_entry(0)
199
+ # => {:type=>:blob, :oid=>"99e7edb53db9355f10c6f2dfaa5a183f205d93bf", :attributes=>33188, :name=>".gitignore"}
200
+ ```
29
201
 
202
+ The tree object is an Enumerable, so you can also do stuff like this:
30
203
 
31
- API
32
- ==============
33
-
34
- There is a general library for some basic Gitty methods. So far, just converting
35
- a raw sha (20 bytes) into a readable hex sha (40 char).
36
-
37
- raw = Rugged.hex_to_raw(hex_sha)
38
- hex = Rugged.raw_to_hex(20_byte_raw_sha)
39
-
40
-
41
- Repository Access
42
- -----------------
43
-
44
- There is a Repository class that you can instantiate with a path.
45
- This lets you check for objects, read raw object data, write raw object data and
46
- get a hash (SHA1 checksum) of what contents would be without writing them out.
47
- You also use it to lookup Git objects from it.
48
-
49
- Repository is the main repository object that everything
50
- else will emanate from.
51
-
52
- repo =
53
- Rugged::Repository.new(path)
54
- ctnt, type = repo.read(sha)
55
- gobj = repo.lookup(sha, type[?]) # optional type argument for checking
56
- sha = repo.write(content, type)
57
- sha = repo.hash(content, type)
58
- bool = repo.exists(sha)
59
- index = repo.index
60
-
61
- The 'path' argument must point to an actual git repository folder. The library
62
- will automatically guess if it's a bare repository or a '.git' folder inside a
63
- working repository, and locate the working path accordingly.
64
-
65
- Object Access
66
- -----------------
67
-
68
- Object is the main object class - it shouldn't be created directly,
69
- but all of these methods should be useful in it's derived classes
70
-
71
- object =
72
- # Constructor is inherited by all the repository objects
73
- # 'sha' is the ID of the object;
74
- # 'repo' is the repository where the object resides
75
- # If both 'sha' and 'repo' exist, the object will be looked up on
76
- # the repository and instantiated
77
- # If the 'sha' ID of the object is missing, the object will be
78
- # created in memory and can be written later on to the repository
79
- Rugged::Object.new(repo, sha)
80
- obj.oid
81
- obj.type
82
-
83
- str = obj.read_raw # read the raw data of the object
84
-
85
- The next classes are for consuming and creating the 4 base
86
- git object types. Just about every method should be able to take
87
- a parameter to change the value so the object can be re-written
88
- slightly different or no parameter to simply read the current
89
- value out.
90
-
91
- gobjc = Rugged::Commit.new
92
- # Rugged::Commit.new < Rugged::Object
93
- str = gobjc.message
94
- str = gobjc.message_short
95
- str = gobjc.message_body # TODO
96
- prsn = gobjc.author
97
- prsn = gobjc.committer
98
- gobjr = gobjc.tree
99
- sha = gobjc.tree_sha
100
- arr = gobjc.parents [*] # TODO: write
101
-
102
- gobtg = Rugged::Tag.new
103
- # Rugged::Tag.new < Rugged::Object
104
- gobj = gobtg.target
105
- int = gobtg.target_type
106
- str = gobtg.name
107
- prsn = gobtg.tagger
108
- str = gobtg.message
109
-
110
- gobtr = Rugged::Tree.new
111
- # Rugged::Tree.new < Rugged::Object
112
- gobtr.add(ent) # TODO
113
- gobtr.remove(name) # TODO
114
- int = gobtr.entry_count
115
- ent = gobtr.get_entry
116
-
117
- ent =
118
- Rugged::TreeEntry.new(attributes, name, sha)
119
- int = ent.attributes
120
- str = ent.name
121
- sha = ent.sha
122
- gobj = ent.to_object
123
-
124
- // * Person information is returned as a hash table
125
-
126
-
127
- Commit Walker
128
- -----------------
129
-
130
- There is also a Walker class that currently takes a repo object. You can push
131
- head SHAs onto the walker, then call next to get a list of the reachable commit
132
- objects, one at a time. You can also hide() commits if you are not interested in
133
- anything beneath them (useful for a `git log master ^origin/master` type deal).
134
-
135
- walker =
136
- Rugged::Walker.new(repo)
137
- walker.walk { |c| puts c.inspect } # walk is just an alias of each
138
- walker.each { |c| puts c.inspect }
139
- walker.push(hex_sha_interesting)
140
- walker.hide(hex_sha_uninteresting)
141
- walker.reset
142
-
143
-
144
-
145
- Index/Staging Area
146
- -------------------
147
-
148
- We can inspect and manipulate the Git Index as well. To work with the index inside
149
- of an existing repository, instantiate it by using the `Repository.index` method instead
150
- of manually opening the Index by its path.
151
-
152
- # TODO: the remove and add functions immediately flush to the index file on disk
153
- index =
154
- Rugged::Index.new(path)
155
- index.reload # re-read the index file from disk
156
- int = index.count # count of index entries
157
- index.entries # collection of index entries
158
- index.each { |i| puts i.inspect }
159
- ent = index.get_entry(i/path)
160
- index.remove(i/path)
161
- index.add(ientry) # also updates existing entry if there is one
162
- index.add(path) # create ientry from file in path, update index
163
- #TODO index.read_tree(gobtr, path='/')
164
- #TODO index.write_tree
165
-
166
-
167
- Index Status # TODO
168
- -------------------
169
-
170
- #TODO index.status # how does the index differ from the work tree and the last commit
171
-
172
- # >> pp stat
173
- # [ ['file1', :staged],
174
- # ['file2', :modified],
175
- # ['file3', :deleted],
176
- # ['file4', :untracked],
177
- # ['file4', :unmerged],
178
- # ]
179
-
180
-
181
- Ref Management # TODO
182
- -------------------
183
-
184
- The RefList class allows you to list, create and delete packed and loose refs.
185
-
186
- list =
187
- Rugged::RefList.new(repo)
188
- ref = list.head # can retrieve and set HEAD with this - returns ref obj or commit obj if detatched
189
- array = list.list([type]) # type is 'heads', 'tags', 'remotes', 'notes', et
190
- list.add(oref)
191
- list.pack
192
- list.unpack
193
-
194
- oref =
195
- Rugged::Ref.new(ref, sha)
196
- br.name # master
197
- br.ref # refs/heads/master
198
- br.type # heads
199
- br.object
200
- br.sha
201
- br.delete
202
- br.save
203
-
204
-
205
- Config Management # TODO
206
- ------------------------
204
+ ```ruby
205
+ tree.each { |e| puts e[:oid] }
206
+ tree.sort { |a, b| a[:oid] <=> b[:oid] }.map { |e| e[:name] }.join(':')
207
+ ```
207
208
 
208
- conf =
209
- Rugged::Config.new(repo)
210
- hash = conf.list([section])
211
- val = conf.get(key, [scope])
212
- bool = conf.set(key, value, [scope]) # scope is 'local'(default), 'global', 'system'
209
+ And there are some Rugged-specific methods, too:
213
210
 
211
+ ```ruby
212
+ tree.each_tree { |entry| puts entry[:name] } # list subdirs
213
+ tree.each_blob { |entry| puts entry[:name] } # list only files
214
+ ```
214
215
 
215
- Client Transport # TODO
216
- -----------------------
216
+ You can also write trees with the `TreeBuilder`:
217
217
 
218
- client =
219
- Rugged::Client.new(repo)
220
- summry = client.fetch(url, [refs])
221
- summry = client.push(url, refs)
222
- refs = client.refs(url) # ls-remote
218
+ ```ruby
219
+ entry = {:type => :blob,
220
+ :name => "README.txt",
221
+ :oid => "1385f264afb75a56a5bec74243be9b367ba4ca08",
222
+ :attributes => 33188}
223
223
 
224
+ builder = Rugged::Tree::Builder.new
225
+ builder << entry
226
+ sha = builder.write(repo)
227
+ ```
224
228
 
225
- Remote Management # TODO
226
- ------------------------
229
+ ---
227
230
 
228
- remlist =
229
- Rugged::RemoteList.new(repo)
230
- array = remlist.list
231
- rem = remlist.add(alias, url)
231
+ ### Commit Walker
232
232
 
233
- rem =
234
- Rugged::Remote.new(repo)
235
- summry = rem.fetch([refs])
236
- summry = rem.push(refs)
237
- summry = rem.remove(refs)
238
- bool = rem.delete
239
- heads = rem.heads
233
+ `Rugged::Walker` is a class designed to help you traverse a set of commits over
234
+ a repository.
240
235
 
236
+ You first push head SHAs onto the walker, and then call next to get a list of
237
+ the reachable commit objects one at a time. You can also `hide()` commits if you
238
+ are not interested in anything beneath them (useful in situations like when
239
+ you're running something like `git log master ^origin/master`).
241
240
 
242
- Server Transport # TODO
243
- ------------------------
241
+ ```ruby
242
+ walker = Rugged::Walker.new(repo)
243
+ walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE) # optional
244
+ walker.push(hex_sha_interesting)
245
+ walker.hide(hex_sha_uninteresting)
246
+ walker.each { |c| puts c.inspect }
247
+ walker.reset
248
+ ```
244
249
 
245
- server =
246
- Rugged::Server.new
247
- server.listen(port = 8080, ip = 0.0.0.0)
248
- server.export_repo(path/repo)
249
- server.export_path(path)
250
+ ---
250
251
 
252
+ ### Index ("staging") area
251
253
 
252
- TODO
253
- ==============
254
+ We can inspect and manipulate the Git Index as well. To work with the index
255
+ inside an existing repository, instantiate it by using the `Repository.index`
256
+ method instead of manually opening the Index by its path.
254
257
 
255
- I will try to keep this up to date with the working public API available in
256
- the libgit2 linkable library. Whatever is available there should be here
257
- as well. The latest libgit2 commit known to link and build successfully will
258
- be listed in the LIBGIT2_VERSION file.
258
+ ```ruby
259
+ index = Rugged::Index.new(path)
259
260
 
261
+ # Re-read the index file from disk.
262
+ index.reload
260
263
 
261
- CONTRIBUTING
262
- ==============
264
+ # Count up index entries.
265
+ count = index.count
266
+
267
+ # The collection of index entries.
268
+ index.entries
269
+
270
+ # Iterating over index entries.
271
+ index.each { |i| puts i.inspect }
272
+
273
+ # Get a particular entry in the index.
274
+ index.get_entry(path)
275
+
276
+ # Unstage.
277
+ index.remove(i/path)
278
+
279
+ # Stage. Also updates existing entry if there is one.
280
+ index.add(ientry)
281
+
282
+ # Stage. Create ientry from file in path, updates the index.
283
+ index.add(path)
284
+ ```
285
+
286
+ ---
287
+
288
+ ### Refs
289
+
290
+ The `RefList` class allows you to list, create and delete packed and loose refs.
291
+
292
+ ```ruby
293
+ ref = repo.head # or...
294
+ ref = Rugged::Reference.lookup(repo, "refs/heads/master")
295
+
296
+ sha = ref.target
297
+ str = ref.type # "commit"
298
+ str = ref.name # "refs/heads/master"
299
+ ```
300
+
301
+ You can also easily get an array of references:
302
+
303
+ ```ruby
304
+ repo.refs.each do |ref|
305
+ puts ref.name
306
+ end
307
+ ```
308
+
309
+ Or use a pattern (regex):
310
+
311
+ ```ruby
312
+ repo.refs(/tags/).each do |ref|
313
+ puts ref.name
314
+ end
315
+ ```
316
+
317
+ It is also easy to create, update, rename or delete a reference:
318
+
319
+ ```ruby
320
+ ref = Rugged::Reference.create(repo, "refs/heads/unit_test", some_commit_sha)
321
+
322
+ ref.target = new_sha
323
+
324
+ ref.rename("refs/heads/blead")
325
+
326
+ ref.delete!
327
+ ```
328
+
329
+ Finally, you can access the reflog for any branch:
330
+
331
+ ```ruby
332
+ ref = Rugged::Reference.lookup(repo, "refs/heads/master")
333
+ entry = ref.log.first
334
+ sha = entry[:oid_old]
335
+ sha = entry[:oid_new]
336
+ str = entry[:message]
337
+ prsn = entry[:committer]
338
+ ```
339
+
340
+ ---
341
+
342
+ ### Config files
343
+
344
+ It's also easy to read and manipulate the Git config file data with Rugged.
345
+
346
+ ```ruby
347
+ # Read values
348
+ repo.config['core.bare']
349
+
350
+ # Set values
351
+ repo.config['user.name'] = true
352
+
353
+ # Delete values
354
+ repo.config.delete('user.name')
355
+ ```
356
+
357
+ ---
358
+
359
+ ### General methods
360
+
361
+ Rugged also includes a general library for handling basic Git operations. One of
362
+ these is converting a raw sha (20 bytes) into a readable hex sha (40
363
+ characters).
364
+
365
+ ```ruby
366
+ Rugged.hex_to_raw('bfde59cdd0dfac1d892814f66a95641abd8a1faf')
367
+ # => "\277\336Y\315\320\337\254\035\211(\024\366j\225d\032\275\212\037\257"
368
+
369
+ Rugged.raw_to_hex("\277\336Y\315\320\337\254\035\211(\024\366j\225d\032\275\212\037\257")
370
+ => "bfde59cdd0dfac1d892814f66a95641abd8a1faf"
371
+ ```
372
+
373
+ ---
374
+
375
+ ## Contributing
263
376
 
264
377
  Fork libgit2/rugged on GitHub, make it awesomer (preferably in a branch named
265
378
  for the topic), send a pull request.
266
379
 
267
380
 
268
- AUTHORS
269
- ==============
381
+ ## Development
270
382
 
271
- * Scott Chacon <schacon@gmail.com>
272
- * Vicent Marti <tanoku@gmail.com>
383
+ First you need to install libgit2:
384
+
385
+ $ git clone https://github.com/libgit2/libgit2.git
386
+ $ cd libgit2
387
+ $ mkdir build && cd build
388
+ $ cmake ..
389
+ $ make
390
+ $ make install
273
391
 
392
+ Now that those are installed, you can install Rugged:
393
+
394
+ $ git clone https://github.com/libgit2/rugged.git
395
+ $ cd rugged
396
+ $ bundle install
397
+ $ rake compile
398
+ $ rake test
399
+
400
+
401
+ ## Authors
402
+
403
+ * Vicent Marti <tanoku@gmail.com>
404
+ * Scott Chacon <schacon@gmail.com>
274
405
 
275
- LICENSE
276
- ==============
277
406
 
278
- MIT. See LICENSE file.
407
+ ## License
279
408
 
409
+ MIT. See LICENSE file.
data/Rakefile CHANGED
@@ -14,6 +14,17 @@ Rake::ExtensionTask.new('rugged') do |r|
14
14
  r.lib_dir = 'lib/rugged'
15
15
  end
16
16
 
17
+ task :embedded_clean do
18
+ lib_path = File.expand_path '../ext/rugged/libgit2_embed.a', __FILE__
19
+ system "rm #{lib_path}"
20
+ end
21
+ Rake::Task[:clean].prerequisites << :embedded_clean
22
+
23
+ desc "Open an irb session preloaded with Rugged"
24
+ task :console do
25
+ sh "irb -rubygems -I lib -r ./lib/rugged"
26
+ end
27
+
17
28
  #
18
29
  # Tests
19
30
  #
@@ -36,3 +47,14 @@ Rake::TestTask.new do |t|
36
47
  t.pattern = 'test/**/*_test.rb'
37
48
  t.verbose = false
38
49
  end
50
+
51
+ begin
52
+ require 'rdoc/task'
53
+ Rake::RDocTask.new do |rdoc|
54
+ rdoc.rdoc_dir = 'rdoc'
55
+ rdoc.rdoc_files.include('ext/**/*.c')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
58
+ rescue LoadError
59
+ end
60
+
@@ -26,14 +26,17 @@ else
26
26
 
27
27
  LIBGIT2_DIST = 'libgit2-dist.tar.gz'
28
28
  LIBGIT2_DIR = File.basename(LIBGIT2_DIST, '.tar.gz')
29
+ LIBGIT2_LIB_PATH = "#{CWD}/libgit2_embed.a"
29
30
 
30
- Dir.chdir("#{CWD}/vendor") do
31
- FileUtils.rm_rf(LIBGIT2_DIR) if File.exists?(LIBGIT2_DIR)
31
+ if !File.exists?(LIBGIT2_LIB_PATH)
32
+ Dir.chdir("#{CWD}/vendor") do
33
+ FileUtils.rm_rf(LIBGIT2_DIR) if File.exists?(LIBGIT2_DIR)
32
34
 
33
- sys("tar zxvf #{LIBGIT2_DIST}")
34
- Dir.chdir(LIBGIT2_DIR) do
35
- sys("make -f Makefile.embed")
36
- FileUtils.cp "libgit2.a", "#{CWD}/libgit2_embed.a"
35
+ sys("tar zxvf #{LIBGIT2_DIST}")
36
+ Dir.chdir(LIBGIT2_DIR) do
37
+ sys("make -f Makefile.embed")
38
+ FileUtils.cp "libgit2.a", LIBGIT2_LIB_PATH
39
+ end
37
40
  end
38
41
  end
39
42