rugged 0.17.0.b7 → 0.18.0.b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +88 -32
  3. data/ext/rugged/extconf.rb +4 -2
  4. data/ext/rugged/rugged.c +72 -10
  5. data/ext/rugged/rugged.h +14 -10
  6. data/ext/rugged/rugged_blob.c +8 -10
  7. data/ext/rugged/rugged_branch.c +11 -14
  8. data/ext/rugged/rugged_commit.c +31 -24
  9. data/ext/rugged/rugged_config.c +2 -2
  10. data/ext/rugged/rugged_index.c +133 -198
  11. data/ext/rugged/rugged_note.c +372 -0
  12. data/ext/rugged/rugged_object.c +50 -22
  13. data/ext/rugged/rugged_reference.c +122 -130
  14. data/ext/rugged/rugged_remote.c +72 -29
  15. data/ext/rugged/rugged_repo.c +402 -20
  16. data/ext/rugged/rugged_revwalk.c +7 -3
  17. data/ext/rugged/rugged_settings.c +110 -0
  18. data/ext/rugged/rugged_signature.c +23 -7
  19. data/ext/rugged/rugged_tag.c +32 -16
  20. data/ext/rugged/rugged_tree.c +44 -15
  21. data/lib/rugged.rb +1 -0
  22. data/lib/rugged/index.rb +8 -0
  23. data/lib/rugged/remote.rb +13 -0
  24. data/lib/rugged/repository.rb +3 -3
  25. data/lib/rugged/version.rb +1 -1
  26. data/test/blob_test.rb +13 -15
  27. data/test/branch_test.rb +32 -67
  28. data/test/commit_test.rb +50 -12
  29. data/test/config_test.rb +12 -11
  30. data/test/coverage/HEAD.json +1 -1
  31. data/test/coverage/cover.rb +40 -21
  32. data/test/errors_test.rb +34 -0
  33. data/test/fixtures/alternate/objects/14/6ae76773c91e3b1d00cf7a338ec55ae58297e2 +0 -0
  34. data/test/fixtures/alternate/objects/14/9c32d47e99d0a3572ff1e70a2e0051bbf347a9 +0 -0
  35. data/test/fixtures/alternate/objects/14/fb3108588f9421bf764041e5e3ac305eb6277f +0 -0
  36. data/test/fixtures/testrepo.git/logs/refs/notes/commits +1 -0
  37. data/test/fixtures/testrepo.git/objects/44/1034f860c1d5d90e4188d11ae0d325176869a8 +1 -0
  38. data/test/fixtures/testrepo.git/objects/60/d415052a33de2150bf68757f6461df4f563ae4 +0 -0
  39. data/test/fixtures/testrepo.git/objects/68/8a8f4ef7496901d15322972f96e212a9e466cc +1 -0
  40. data/test/fixtures/testrepo.git/objects/94/eca2de348d5f672faf56b0decafa5937e3235e +0 -0
  41. data/test/fixtures/testrepo.git/objects/9b/7384fe1676186192842f5d3e129457b62db9e3 +0 -0
  42. data/test/fixtures/testrepo.git/objects/b7/4713326bc972cc15751ed504dca6f6f3b91f7a +3 -0
  43. data/test/fixtures/testrepo.git/refs/notes/commits +1 -0
  44. data/test/index_test.rb +65 -69
  45. data/test/lib_test.rb +76 -11
  46. data/test/note_test.rb +158 -0
  47. data/test/object_test.rb +8 -11
  48. data/test/reference_test.rb +77 -85
  49. data/test/remote_test.rb +86 -8
  50. data/test/repo_pack_test.rb +9 -7
  51. data/test/repo_reset_test.rb +80 -0
  52. data/test/repo_test.rb +176 -53
  53. data/test/tag_test.rb +44 -7
  54. data/test/test_helper.rb +63 -35
  55. data/test/tree_test.rb +34 -13
  56. data/test/walker_test.rb +14 -14
  57. data/vendor/libgit2/Makefile.embed +1 -1
  58. data/vendor/libgit2/deps/http-parser/http_parser.c +974 -578
  59. data/vendor/libgit2/deps/http-parser/http_parser.h +106 -70
  60. data/vendor/libgit2/deps/regex/regcomp.c +7 -6
  61. data/vendor/libgit2/deps/regex/regex_internal.c +1 -1
  62. data/vendor/libgit2/deps/regex/regex_internal.h +12 -3
  63. data/vendor/libgit2/deps/regex/regexec.c +5 -5
  64. data/vendor/libgit2/include/git2.h +5 -1
  65. data/vendor/libgit2/include/git2/attr.h +4 -2
  66. data/vendor/libgit2/include/git2/blob.h +39 -12
  67. data/vendor/libgit2/include/git2/branch.h +123 -35
  68. data/vendor/libgit2/include/git2/checkout.h +206 -48
  69. data/vendor/libgit2/include/git2/clone.h +72 -27
  70. data/vendor/libgit2/include/git2/commit.h +20 -17
  71. data/vendor/libgit2/include/git2/common.h +67 -1
  72. data/vendor/libgit2/include/git2/config.h +81 -60
  73. data/vendor/libgit2/include/git2/cred_helpers.h +53 -0
  74. data/vendor/libgit2/include/git2/diff.h +459 -150
  75. data/vendor/libgit2/include/git2/errors.h +9 -1
  76. data/vendor/libgit2/include/git2/graph.h +41 -0
  77. data/vendor/libgit2/include/git2/ignore.h +7 -6
  78. data/vendor/libgit2/include/git2/index.h +323 -97
  79. data/vendor/libgit2/include/git2/indexer.h +27 -59
  80. data/vendor/libgit2/include/git2/inttypes.h +4 -0
  81. data/vendor/libgit2/include/git2/merge.h +13 -3
  82. data/vendor/libgit2/include/git2/message.h +14 -8
  83. data/vendor/libgit2/include/git2/net.h +9 -7
  84. data/vendor/libgit2/include/git2/notes.h +88 -29
  85. data/vendor/libgit2/include/git2/object.h +16 -6
  86. data/vendor/libgit2/include/git2/odb.h +80 -17
  87. data/vendor/libgit2/include/git2/odb_backend.h +47 -11
  88. data/vendor/libgit2/include/git2/oid.h +26 -17
  89. data/vendor/libgit2/include/git2/pack.h +62 -8
  90. data/vendor/libgit2/include/git2/push.h +131 -0
  91. data/vendor/libgit2/include/git2/refdb.h +103 -0
  92. data/vendor/libgit2/include/git2/refdb_backend.h +109 -0
  93. data/vendor/libgit2/include/git2/reflog.h +30 -21
  94. data/vendor/libgit2/include/git2/refs.h +215 -193
  95. data/vendor/libgit2/include/git2/refspec.h +22 -2
  96. data/vendor/libgit2/include/git2/remote.h +158 -37
  97. data/vendor/libgit2/include/git2/repository.h +150 -31
  98. data/vendor/libgit2/include/git2/reset.h +43 -9
  99. data/vendor/libgit2/include/git2/revparse.h +48 -4
  100. data/vendor/libgit2/include/git2/revwalk.h +25 -10
  101. data/vendor/libgit2/include/git2/signature.h +20 -12
  102. data/vendor/libgit2/include/git2/stash.h +121 -0
  103. data/vendor/libgit2/include/git2/status.h +122 -53
  104. data/vendor/libgit2/include/git2/strarray.h +17 -11
  105. data/vendor/libgit2/include/git2/submodule.h +42 -7
  106. data/vendor/libgit2/include/git2/tag.h +72 -59
  107. data/vendor/libgit2/include/git2/threads.h +4 -2
  108. data/vendor/libgit2/include/git2/trace.h +68 -0
  109. data/vendor/libgit2/include/git2/transport.h +328 -0
  110. data/vendor/libgit2/include/git2/tree.h +149 -120
  111. data/vendor/libgit2/include/git2/types.h +13 -12
  112. data/vendor/libgit2/include/git2/version.h +3 -3
  113. data/vendor/libgit2/src/amiga/map.c +2 -2
  114. data/vendor/libgit2/src/attr.c +58 -48
  115. data/vendor/libgit2/src/attr.h +4 -18
  116. data/vendor/libgit2/src/attr_file.c +30 -6
  117. data/vendor/libgit2/src/attr_file.h +6 -8
  118. data/vendor/libgit2/src/attrcache.h +24 -0
  119. data/vendor/libgit2/src/blob.c +30 -7
  120. data/vendor/libgit2/src/blob.h +1 -1
  121. data/vendor/libgit2/src/branch.c +361 -68
  122. data/vendor/libgit2/src/branch.h +17 -0
  123. data/vendor/libgit2/src/bswap.h +1 -1
  124. data/vendor/libgit2/src/buf_text.c +291 -0
  125. data/vendor/libgit2/src/buf_text.h +122 -0
  126. data/vendor/libgit2/src/buffer.c +27 -101
  127. data/vendor/libgit2/src/buffer.h +54 -39
  128. data/vendor/libgit2/src/cache.c +15 -6
  129. data/vendor/libgit2/src/cache.h +1 -1
  130. data/vendor/libgit2/src/cc-compat.h +3 -1
  131. data/vendor/libgit2/src/checkout.c +1165 -222
  132. data/vendor/libgit2/src/checkout.h +24 -0
  133. data/vendor/libgit2/src/clone.c +171 -86
  134. data/vendor/libgit2/src/commit.c +44 -45
  135. data/vendor/libgit2/src/commit.h +3 -3
  136. data/vendor/libgit2/src/commit_list.c +194 -0
  137. data/vendor/libgit2/src/commit_list.h +49 -0
  138. data/vendor/libgit2/src/common.h +44 -10
  139. data/vendor/libgit2/src/compress.c +1 -1
  140. data/vendor/libgit2/src/compress.h +1 -1
  141. data/vendor/libgit2/src/config.c +211 -124
  142. data/vendor/libgit2/src/config.h +23 -4
  143. data/vendor/libgit2/src/config_cache.c +2 -2
  144. data/vendor/libgit2/src/config_file.c +129 -53
  145. data/vendor/libgit2/src/config_file.h +10 -8
  146. data/vendor/libgit2/src/crlf.c +66 -67
  147. data/vendor/libgit2/src/date.c +12 -12
  148. data/vendor/libgit2/src/delta-apply.c +14 -1
  149. data/vendor/libgit2/src/delta-apply.h +18 -1
  150. data/vendor/libgit2/src/delta.c +40 -107
  151. data/vendor/libgit2/src/delta.h +19 -17
  152. data/vendor/libgit2/src/diff.c +347 -496
  153. data/vendor/libgit2/src/diff.h +27 -1
  154. data/vendor/libgit2/src/diff_output.c +564 -249
  155. data/vendor/libgit2/src/diff_output.h +15 -8
  156. data/vendor/libgit2/src/diff_tform.c +687 -0
  157. data/vendor/libgit2/src/errors.c +27 -36
  158. data/vendor/libgit2/src/fetch.c +13 -351
  159. data/vendor/libgit2/src/fetch.h +13 -3
  160. data/vendor/libgit2/src/fetchhead.c +295 -0
  161. data/vendor/libgit2/src/fetchhead.h +34 -0
  162. data/vendor/libgit2/src/filebuf.c +42 -15
  163. data/vendor/libgit2/src/filebuf.h +4 -2
  164. data/vendor/libgit2/src/fileops.c +466 -113
  165. data/vendor/libgit2/src/fileops.h +154 -28
  166. data/vendor/libgit2/src/filter.c +3 -75
  167. data/vendor/libgit2/src/filter.h +1 -29
  168. data/vendor/libgit2/src/fnmatch.c +1 -1
  169. data/vendor/libgit2/src/fnmatch.h +1 -1
  170. data/vendor/libgit2/src/global.c +54 -10
  171. data/vendor/libgit2/src/global.h +10 -1
  172. data/vendor/libgit2/src/graph.c +178 -0
  173. data/vendor/libgit2/src/hash.c +25 -52
  174. data/vendor/libgit2/src/hash.h +21 -9
  175. data/vendor/libgit2/src/{sha1/sha1.c → hash/hash_generic.c} +20 -12
  176. data/vendor/libgit2/src/hash/hash_generic.h +24 -0
  177. data/vendor/libgit2/src/hash/hash_openssl.h +45 -0
  178. data/vendor/libgit2/src/hash/hash_win32.c +291 -0
  179. data/vendor/libgit2/src/hash/hash_win32.h +140 -0
  180. data/vendor/libgit2/src/hashsig.c +368 -0
  181. data/vendor/libgit2/src/hashsig.h +72 -0
  182. data/vendor/libgit2/src/ignore.c +22 -15
  183. data/vendor/libgit2/src/ignore.h +6 -1
  184. data/vendor/libgit2/src/index.c +770 -171
  185. data/vendor/libgit2/src/index.h +13 -5
  186. data/vendor/libgit2/src/indexer.c +286 -431
  187. data/vendor/libgit2/src/iterator.c +854 -466
  188. data/vendor/libgit2/src/iterator.h +134 -109
  189. data/vendor/libgit2/src/map.h +1 -1
  190. data/vendor/libgit2/src/merge.c +296 -0
  191. data/vendor/libgit2/src/merge.h +22 -0
  192. data/vendor/libgit2/src/message.c +1 -1
  193. data/vendor/libgit2/src/message.h +1 -1
  194. data/vendor/libgit2/src/mwindow.c +35 -30
  195. data/vendor/libgit2/src/mwindow.h +2 -2
  196. data/vendor/libgit2/src/netops.c +162 -98
  197. data/vendor/libgit2/src/netops.h +50 -15
  198. data/vendor/libgit2/src/notes.c +109 -58
  199. data/vendor/libgit2/src/notes.h +2 -1
  200. data/vendor/libgit2/src/object.c +46 -57
  201. data/vendor/libgit2/src/object.h +1 -8
  202. data/vendor/libgit2/src/odb.c +151 -40
  203. data/vendor/libgit2/src/odb.h +5 -1
  204. data/vendor/libgit2/src/odb_loose.c +4 -5
  205. data/vendor/libgit2/src/odb_pack.c +122 -80
  206. data/vendor/libgit2/src/offmap.h +65 -0
  207. data/vendor/libgit2/src/oid.c +12 -4
  208. data/vendor/libgit2/src/oidmap.h +1 -1
  209. data/vendor/libgit2/src/pack-objects.c +88 -61
  210. data/vendor/libgit2/src/pack-objects.h +8 -8
  211. data/vendor/libgit2/src/pack.c +293 -28
  212. data/vendor/libgit2/src/pack.h +49 -4
  213. data/vendor/libgit2/src/path.c +103 -14
  214. data/vendor/libgit2/src/path.h +23 -7
  215. data/vendor/libgit2/src/pathspec.c +168 -0
  216. data/vendor/libgit2/src/pathspec.h +40 -0
  217. data/vendor/libgit2/src/pool.c +29 -4
  218. data/vendor/libgit2/src/pool.h +8 -1
  219. data/vendor/libgit2/src/posix.c +26 -27
  220. data/vendor/libgit2/src/posix.h +2 -3
  221. data/vendor/libgit2/src/pqueue.c +23 -1
  222. data/vendor/libgit2/src/pqueue.h +23 -1
  223. data/vendor/libgit2/src/push.c +653 -0
  224. data/vendor/libgit2/src/push.h +51 -0
  225. data/vendor/libgit2/src/refdb.c +185 -0
  226. data/vendor/libgit2/src/refdb.h +46 -0
  227. data/vendor/libgit2/src/refdb_fs.c +1024 -0
  228. data/vendor/libgit2/src/refdb_fs.h +15 -0
  229. data/vendor/libgit2/src/reflog.c +77 -45
  230. data/vendor/libgit2/src/reflog.h +1 -3
  231. data/vendor/libgit2/src/refs.c +366 -1326
  232. data/vendor/libgit2/src/refs.h +22 -13
  233. data/vendor/libgit2/src/refspec.c +46 -7
  234. data/vendor/libgit2/src/refspec.h +11 -1
  235. data/vendor/libgit2/src/remote.c +758 -120
  236. data/vendor/libgit2/src/remote.h +10 -5
  237. data/vendor/libgit2/src/repo_template.h +6 -6
  238. data/vendor/libgit2/src/repository.c +315 -96
  239. data/vendor/libgit2/src/repository.h +5 -3
  240. data/vendor/libgit2/src/reset.c +99 -81
  241. data/vendor/libgit2/src/revparse.c +157 -84
  242. data/vendor/libgit2/src/revwalk.c +68 -470
  243. data/vendor/libgit2/src/revwalk.h +44 -0
  244. data/vendor/libgit2/src/sha1_lookup.c +1 -1
  245. data/vendor/libgit2/src/sha1_lookup.h +1 -1
  246. data/vendor/libgit2/src/signature.c +68 -200
  247. data/vendor/libgit2/src/signature.h +1 -1
  248. data/vendor/libgit2/src/stash.c +663 -0
  249. data/vendor/libgit2/src/status.c +101 -79
  250. data/vendor/libgit2/src/strmap.h +1 -1
  251. data/vendor/libgit2/src/submodule.c +67 -51
  252. data/vendor/libgit2/src/submodule.h +1 -1
  253. data/vendor/libgit2/src/tag.c +35 -29
  254. data/vendor/libgit2/src/tag.h +1 -1
  255. data/vendor/libgit2/src/thread-utils.c +1 -1
  256. data/vendor/libgit2/src/thread-utils.h +2 -2
  257. data/vendor/libgit2/src/trace.c +39 -0
  258. data/vendor/libgit2/src/trace.h +56 -0
  259. data/vendor/libgit2/src/transport.c +81 -34
  260. data/vendor/libgit2/src/transports/cred.c +60 -0
  261. data/vendor/libgit2/src/transports/cred_helpers.c +49 -0
  262. data/vendor/libgit2/src/transports/git.c +234 -127
  263. data/vendor/libgit2/src/transports/http.c +761 -433
  264. data/vendor/libgit2/src/transports/local.c +460 -64
  265. data/vendor/libgit2/src/transports/smart.c +345 -0
  266. data/vendor/libgit2/src/transports/smart.h +179 -0
  267. data/vendor/libgit2/src/{pkt.c → transports/smart_pkt.c} +131 -12
  268. data/vendor/libgit2/src/transports/smart_protocol.c +856 -0
  269. data/vendor/libgit2/src/transports/winhttp.c +1136 -0
  270. data/vendor/libgit2/src/tree-cache.c +2 -2
  271. data/vendor/libgit2/src/tree-cache.h +1 -1
  272. data/vendor/libgit2/src/tree.c +239 -166
  273. data/vendor/libgit2/src/tree.h +11 -2
  274. data/vendor/libgit2/src/tsort.c +39 -23
  275. data/vendor/libgit2/src/unix/map.c +1 -1
  276. data/vendor/libgit2/src/unix/posix.h +12 -2
  277. data/vendor/libgit2/src/unix/realpath.c +30 -0
  278. data/vendor/libgit2/src/util.c +250 -13
  279. data/vendor/libgit2/src/util.h +71 -14
  280. data/vendor/libgit2/src/vector.c +123 -60
  281. data/vendor/libgit2/src/vector.h +24 -22
  282. data/vendor/libgit2/src/win32/dir.c +1 -1
  283. data/vendor/libgit2/src/win32/dir.h +1 -1
  284. data/vendor/libgit2/src/win32/error.c +77 -0
  285. data/vendor/libgit2/src/win32/error.h +13 -0
  286. data/vendor/libgit2/src/win32/findfile.c +143 -54
  287. data/vendor/libgit2/src/win32/findfile.h +10 -6
  288. data/vendor/libgit2/src/win32/map.c +1 -1
  289. data/vendor/libgit2/src/win32/mingw-compat.h +1 -1
  290. data/vendor/libgit2/src/win32/msvc-compat.h +10 -1
  291. data/vendor/libgit2/src/win32/posix.h +10 -1
  292. data/vendor/libgit2/src/win32/posix_w32.c +132 -63
  293. data/vendor/libgit2/src/win32/precompiled.c +1 -1
  294. data/vendor/libgit2/src/win32/pthread.c +1 -1
  295. data/vendor/libgit2/src/win32/pthread.h +1 -1
  296. data/vendor/libgit2/src/win32/utf-conv.c +5 -5
  297. data/vendor/libgit2/src/win32/utf-conv.h +3 -3
  298. data/vendor/libgit2/src/win32/version.h +20 -0
  299. metadata +308 -252
  300. data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  301. data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
  302. data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
  303. data/test/index_test.rb~ +0 -218
  304. data/vendor/libgit2/src/pkt.h +0 -91
  305. data/vendor/libgit2/src/ppc/sha1.c +0 -70
  306. data/vendor/libgit2/src/ppc/sha1.h +0 -26
  307. data/vendor/libgit2/src/protocol.c +0 -110
  308. data/vendor/libgit2/src/protocol.h +0 -21
  309. data/vendor/libgit2/src/sha1.h +0 -33
  310. data/vendor/libgit2/src/transport.h +0 -148
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * The MIT License
3
3
  *
4
- * Copyright (c) 2011 GitHub, Inc
4
+ * Copyright (c) 2013 GitHub, Inc
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
@@ -33,45 +33,83 @@ static void rb_git_remote__free(git_remote *remote)
33
33
  git_remote_free(remote);
34
34
  }
35
35
 
36
- static VALUE rb_git_remote__new(int argc, VALUE *argv, VALUE klass)
36
+ VALUE rugged_remote_new(VALUE klass, VALUE owner, git_remote *remote)
37
+ {
38
+ VALUE rb_remote = Data_Wrap_Struct(klass, NULL, &rb_git_remote__free, remote);
39
+ rugged_set_owner(rb_remote, owner);
40
+ return rb_remote;
41
+ }
42
+
43
+ /*
44
+ * call-seq:
45
+ * Remote.new(repository, url) -> remote
46
+ *
47
+ * Return a new remote from +url+ in +repository+ , the remote is not persisted:
48
+ * - +url+: a valid remote url
49
+ *
50
+ * Returns a new <tt>Rugged::Remote</tt> object
51
+ *
52
+ * Rugged::Remote.new(@repo, 'git://github.com/libgit2/libgit2.git') #=> #<Rugged::Remote:0x00000001fbfa80>
53
+ */
54
+ static VALUE rb_git_remote_new(VALUE klass, VALUE rb_repo, VALUE rb_url)
37
55
  {
38
- VALUE rb_remote, rb_repo, rb_url, rb_name;
39
56
  git_remote *remote;
40
57
  git_repository *repo;
41
58
  const char *url;
42
59
  int error;
43
60
 
44
- rb_scan_args(argc, argv, "21", &rb_repo, &rb_url, &rb_name);
45
-
46
61
  Check_Type(rb_url, T_STRING);
47
-
48
- if (!rb_obj_is_instance_of(rb_repo, rb_cRuggedRepo))
49
- rb_raise(rb_eTypeError, "Expecting a Rugged Repository");
62
+ rugged_check_repo(rb_repo);
50
63
 
51
64
  Data_Get_Struct(rb_repo, git_repository, repo);
52
65
 
53
66
  url = StringValueCStr(rb_url);
54
67
 
55
68
  if (git_remote_valid_url(url)) {
56
- if (!NIL_P(rb_name))
57
- Check_Type(rb_name, T_STRING);
58
-
59
- error = git_remote_new(
60
- &remote,
61
- repo,
62
- NIL_P(rb_name) ? NULL : StringValueCStr(rb_name),
63
- StringValueCStr(rb_url),
64
- NULL
65
- );
69
+ error = git_remote_create_inmemory(
70
+ &remote,
71
+ repo,
72
+ NULL,
73
+ url);
66
74
  } else {
67
- error = git_remote_load(&remote, repo, url);
75
+ rb_raise(rb_eArgError, "Invalid URL format");
68
76
  }
69
77
 
70
78
  rugged_exception_check(error);
71
79
 
72
- rb_remote = Data_Wrap_Struct(klass, NULL, &rb_git_remote__free, remote);
73
- rugged_set_owner(rb_remote, rb_repo);
74
- return rb_remote;
80
+ return rugged_remote_new(klass, rb_repo, remote);
81
+ }
82
+
83
+ /*
84
+ * call-seq:
85
+ * Remote.lookup(repository, name) -> new_remote or nil
86
+ *
87
+ * Return an existing remote with +name+ in +repository+:
88
+ * - +name+: a valid remote name
89
+ *
90
+ * Returns a new <tt>Rugged::Remote</tt> object or +nil+ if the
91
+ * remote doesn't exist
92
+ *
93
+ * Rugged::Remote.lookup(@repo, 'origin') #=> #<Rugged::Remote:0x00000001fbfa80>
94
+ */
95
+ static VALUE rb_git_remote_lookup(VALUE klass, VALUE rb_repo, VALUE rb_name)
96
+ {
97
+ git_remote *remote;
98
+ git_repository *repo;
99
+ int error;
100
+
101
+ Check_Type(rb_name, T_STRING);
102
+ rugged_check_repo(rb_repo);
103
+ Data_Get_Struct(rb_repo, git_repository, repo);
104
+
105
+ error = git_remote_load(&remote, repo, StringValueCStr(rb_name));
106
+
107
+ if (error == GIT_ENOTFOUND)
108
+ return Qnil;
109
+
110
+ rugged_exception_check(error);
111
+
112
+ return rugged_remote_new(klass, rb_repo, remote);
75
113
  }
76
114
 
77
115
  static VALUE rb_git_remote_disconnect(VALUE self)
@@ -95,9 +133,9 @@ static VALUE rb_git_remote_connect(VALUE self, VALUE rb_direction)
95
133
  id_direction = SYM2ID(rb_direction);
96
134
 
97
135
  if (id_direction == rb_intern("fetch"))
98
- direction = GIT_DIR_FETCH;
136
+ direction = GIT_DIRECTION_FETCH;
99
137
  else if (id_direction == rb_intern("push"))
100
- direction = GIT_DIR_PUSH;
138
+ direction = GIT_DIRECTION_PUSH;
101
139
  else
102
140
  rb_raise(rb_eTypeError,
103
141
  "Invalid remote direction. Expected `:fetch` or `:push`");
@@ -147,9 +185,15 @@ static VALUE rb_git_remote_ls(VALUE self)
147
185
  static VALUE rb_git_remote_name(VALUE self)
148
186
  {
149
187
  git_remote *remote;
188
+ const char * name;
150
189
  Data_Get_Struct(self, git_remote, remote);
151
190
 
152
- return rugged_str_new2(git_remote_name(remote), NULL);
191
+ name = git_remote_name(remote);
192
+
193
+ if (name)
194
+ return rugged_str_new2(name, NULL);
195
+ else
196
+ return Qnil;
153
197
  }
154
198
 
155
199
  static VALUE rb_git_remote_url(VALUE self)
@@ -172,12 +216,10 @@ static VALUE rb_git_remote_download(VALUE self)
172
216
  {
173
217
  int error;
174
218
  git_remote *remote;
175
- git_off_t bytes = 0;
176
- git_indexer_stats stats;
177
219
 
178
220
  Data_Get_Struct(self, git_remote, remote);
179
221
 
180
- error = git_remote_download(remote, &bytes, &stats);
222
+ error = git_remote_download(remote, NULL, NULL);
181
223
  rugged_exception_check(error);
182
224
 
183
225
  return Qnil;
@@ -226,7 +268,8 @@ void Init_rugged_remote()
226
268
  {
227
269
  rb_cRuggedRemote = rb_define_class_under(rb_mRugged, "Remote", rb_cObject);
228
270
 
229
- rb_define_singleton_method(rb_cRuggedRemote, "new", rb_git_remote__new, -1);
271
+ rb_define_singleton_method(rb_cRuggedRemote, "new", rb_git_remote_new, 2);
272
+ rb_define_singleton_method(rb_cRuggedRemote, "lookup", rb_git_remote_lookup, 2);
230
273
  rb_define_singleton_method(rb_cRuggedRemote, "each", rb_git_remote_each, 1);
231
274
 
232
275
  rb_define_method(rb_cRuggedRemote, "connect", rb_git_remote_connect, 1);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * The MIT License
3
3
  *
4
- * Copyright (c) 2011 GitHub, Inc
4
+ * Copyright (c) 2013 GitHub, Inc
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
@@ -25,9 +25,11 @@
25
25
  #include "rugged.h"
26
26
 
27
27
  extern VALUE rb_mRugged;
28
+ extern VALUE rb_eRuggedError;
28
29
  extern VALUE rb_cRuggedIndex;
29
30
  extern VALUE rb_cRuggedConfig;
30
31
  extern VALUE rb_cRuggedBackend;
32
+ extern VALUE rb_cRuggedRemote;
31
33
 
32
34
  VALUE rb_cRuggedRepo;
33
35
  VALUE rb_cRuggedOdbObject;
@@ -114,9 +116,8 @@ VALUE rugged_raw_read(git_repository *repo, const git_oid *oid)
114
116
  rugged_exception_check(error);
115
117
 
116
118
  error = git_odb_read(&obj, odb, oid);
117
- rugged_exception_check(error);
118
-
119
119
  git_odb_free(odb);
120
+ rugged_exception_check(error);
120
121
 
121
122
  return Data_Wrap_Struct(rb_cRuggedOdbObject, NULL, rb_git__odbobj_free, obj);
122
123
  }
@@ -142,9 +143,67 @@ static VALUE rugged_repo_new(VALUE klass, git_repository *repo)
142
143
  return rb_repo;
143
144
  }
144
145
 
146
+ static void load_alternates(git_repository *repo, VALUE rb_alternates)
147
+ {
148
+ git_odb *odb = NULL;
149
+ int i, error;
150
+
151
+ if (NIL_P(rb_alternates))
152
+ return;
153
+
154
+ Check_Type(rb_alternates, T_ARRAY);
155
+
156
+ if (RARRAY_LEN(rb_alternates) == 0)
157
+ return;
158
+
159
+ for (i = 0; i < RARRAY_LEN(rb_alternates); ++i)
160
+ Check_Type(rb_ary_entry(rb_alternates, i), T_STRING);
161
+
162
+ error = git_repository_odb(&odb, repo);
163
+ rugged_exception_check(error);
164
+
165
+ for (i = 0; !error && i < RARRAY_LEN(rb_alternates); ++i) {
166
+ VALUE alt = rb_ary_entry(rb_alternates, i);
167
+ error = git_odb_add_disk_alternate(odb, StringValueCStr(alt));
168
+ }
169
+
170
+ git_odb_free(odb);
171
+ rugged_exception_check(error);
172
+ }
173
+
174
+ static void set_repository_options(git_repository *repo, VALUE rb_options)
175
+ {
176
+ int error = 0;
177
+
178
+ if (NIL_P(rb_options))
179
+ return;
180
+
181
+ Check_Type(rb_options, T_HASH);
182
+
183
+ /* Check for `:alternates` */
184
+ load_alternates(repo, rb_hash_aref(rb_options, CSTR2SYM("alternates")));
185
+ }
186
+
187
+ static VALUE rb_git_repo_open_bare(int argc, VALUE *argv, VALUE klass)
188
+ {
189
+ git_repository *repo;
190
+ int error = 0;
191
+ VALUE rb_path, rb_alternates;
192
+
193
+ rb_scan_args(argc, argv, "11", &rb_path, &rb_alternates);
194
+ Check_Type(rb_path, T_STRING);
195
+
196
+ error = git_repository_open_bare(&repo, StringValueCStr(rb_path));
197
+ rugged_exception_check(error);
198
+
199
+ load_alternates(repo, rb_alternates);
200
+
201
+ return rugged_repo_new(klass, repo);
202
+ }
203
+
145
204
  /*
146
205
  * call-seq:
147
- * Rugged::Repository.new(path) -> repository
206
+ * Rugged::Repository.new(path, options = {}) -> repository
148
207
  *
149
208
  * Open a Git repository in the given +path+ and return a +Repository+ object
150
209
  * representing it. An exception will be thrown if +path+ doesn't point to a
@@ -156,44 +215,58 @@ static VALUE rugged_repo_new(VALUE klass, git_repository *repo)
156
215
  * instead.
157
216
  *
158
217
  * Rugged::Repository.new('~/test/.git') #=> #<Rugged::Repository:0x108849488>
218
+ *
219
+ * +options+ is an optional hash with the following keys:
220
+ *
221
+ * - +:alternates+: +Array+ with a list of alternate object folders, e.g.
222
+ *
223
+ * Rugged::Repository.new(path, :alternates => ['./other/repo/.git/objects'])
159
224
  */
160
- static VALUE rb_git_repo_new(VALUE klass, VALUE rb_path)
225
+ static VALUE rb_git_repo_new(int argc, VALUE *argv, VALUE klass)
161
226
  {
162
227
  git_repository *repo;
163
228
  int error = 0;
229
+ VALUE rb_path, rb_options;
164
230
 
231
+ rb_scan_args(argc, argv, "11", &rb_path, &rb_options);
165
232
  Check_Type(rb_path, T_STRING);
166
233
 
167
234
  error = git_repository_open(&repo, StringValueCStr(rb_path));
168
235
  rugged_exception_check(error);
236
+ set_repository_options(repo, rb_options);
169
237
 
170
238
  return rugged_repo_new(klass, repo);
171
239
  }
172
240
 
173
241
  /*
174
242
  * call-seq:
175
- * Rugged::Repository.init_at(path, is_bare) -> repository
243
+ * init_at(path, is_bare = false) -> repository
176
244
  *
177
245
  * Initialize a Git repository in +path+. This implies creating all the
178
246
  * necessary files on the FS, or re-initializing an already existing
179
247
  * repository if the files have already been created.
180
248
  *
181
- * The +is_bare+ attribute specifies whether the Repository should be
182
- * created on disk as bare or not. Bare repositories have no working
183
- * directory and are created in the root of +path+. Non-bare repositories
184
- * are created in a +.git+ folder and use +path+ as working directory.
249
+ * The +is_bare+ (optional, defaults to false) attribute specifies whether
250
+ * the Repository should be created on disk as bare or not.
251
+ * Bare repositories have no working directory and are created in the root
252
+ * of +path+. Non-bare repositories are created in a +.git+ folder and
253
+ * use +path+ as working directory.
185
254
  *
186
- * Rugged::Repository.init_at('~/repository') #=> #<Rugged::Repository:0x108849488>
255
+ * Rugged::Repository.init_at('~/repository', :bare) #=> #<Rugged::Repository:0x108849488>
187
256
  */
188
- static VALUE rb_git_repo_init_at(VALUE klass, VALUE path, VALUE rb_is_bare)
257
+ static VALUE rb_git_repo_init_at(int argc, VALUE *argv, VALUE klass)
189
258
  {
190
259
  git_repository *repo;
191
- int error, is_bare;
260
+ VALUE rb_path, rb_is_bare;
261
+ int error, is_bare = 0;
262
+
263
+ rb_scan_args(argc, argv, "11", &rb_path, &rb_is_bare);
264
+ Check_Type(rb_path, T_STRING);
192
265
 
193
- is_bare = rugged_parse_bool(rb_is_bare);
194
- Check_Type(path, T_STRING);
266
+ if (!NIL_P(rb_is_bare))
267
+ is_bare = rb_is_bare ? 1 : 0;
195
268
 
196
- error = git_repository_init(&repo, StringValueCStr(path), is_bare);
269
+ error = git_repository_init(&repo, StringValueCStr(rb_path), is_bare);
197
270
  rugged_exception_check(error);
198
271
 
199
272
  return rugged_repo_new(klass, repo);
@@ -278,6 +351,33 @@ static VALUE rb_git_repo_get_config(VALUE self)
278
351
  RB_GIT_REPO_OWNED_GET(rb_cRuggedConfig, config);
279
352
  }
280
353
 
354
+ /*
355
+ * call-seq:
356
+ * repo.merge_base(oid1, oid2)
357
+ * repo.merge_base(ref1, ref2)
358
+ * repo.merge_base(commit1, commit2)
359
+ *
360
+ * Find a merge base, given two commits or oids.
361
+ * Returns nil if a merge base is not found.
362
+ */
363
+ static VALUE rb_git_repo_merge_base(VALUE self, VALUE obj1, VALUE obj2)
364
+ {
365
+ int error;
366
+ git_oid oid1, oid2, base;
367
+ git_repository *repo;
368
+
369
+ Data_Get_Struct(self, git_repository, repo);
370
+ rugged_oid_get(&oid1, repo, obj1);
371
+ rugged_oid_get(&oid2, repo, obj2);
372
+
373
+ error = git_merge_base(&base, repo, &oid1, &oid2);
374
+ if (error == GIT_ENOTFOUND)
375
+ return Qnil;
376
+
377
+ rugged_exception_check(error);
378
+ return rugged_create_oid(&base);
379
+ }
380
+
281
381
  /*
282
382
  * call-seq:
283
383
  * repo.include?(oid) -> true or false
@@ -326,6 +426,36 @@ static VALUE rb_git_repo_read(VALUE self, VALUE hex)
326
426
  return rugged_raw_read(repo, &oid);
327
427
  }
328
428
 
429
+ static VALUE rb_git_repo_read_header(VALUE self, VALUE hex)
430
+ {
431
+ git_repository *repo;
432
+ git_oid oid;
433
+ git_odb *odb;
434
+ git_otype type;
435
+ size_t len;
436
+ VALUE rb_hash;
437
+ int error;
438
+
439
+ Data_Get_Struct(self, git_repository, repo);
440
+ Check_Type(hex, T_STRING);
441
+
442
+ error = git_oid_fromstr(&oid, StringValueCStr(hex));
443
+ rugged_exception_check(error);
444
+
445
+ error = git_repository_odb(&odb, repo);
446
+ rugged_exception_check(error);
447
+
448
+ error = git_odb_read_header(&len, &type, odb, &oid);
449
+ git_odb_free(odb);
450
+ rugged_exception_check(error);
451
+
452
+ rb_hash = rb_hash_new();
453
+ rb_hash_aset(rb_hash, CSTR2SYM("type"), CSTR2SYM(git_object_type2string(type)));
454
+ rb_hash_aset(rb_hash, CSTR2SYM("len"), INT2FIX(len));
455
+
456
+ return rb_hash;
457
+ }
458
+
329
459
  /*
330
460
  * call-seq:
331
461
  * Repository.hash(buffer, type) -> oid
@@ -395,6 +525,7 @@ static VALUE rb_git_repo_write(VALUE self, VALUE rb_buffer, VALUE rub_type)
395
525
  git_otype type;
396
526
 
397
527
  Data_Get_Struct(self, git_repository, repo);
528
+ Check_Type(rb_buffer, T_STRING);
398
529
 
399
530
  error = git_repository_odb(&odb, repo);
400
531
  rugged_exception_check(error);
@@ -402,14 +533,14 @@ static VALUE rb_git_repo_write(VALUE self, VALUE rb_buffer, VALUE rub_type)
402
533
  type = rugged_otype_get(rub_type);
403
534
 
404
535
  error = git_odb_open_wstream(&stream, odb, RSTRING_LEN(rb_buffer), type);
405
- rugged_exception_check(error);
406
-
407
536
  git_odb_free(odb);
537
+ rugged_exception_check(error);
408
538
 
409
539
  error = stream->write(stream, RSTRING_PTR(rb_buffer), RSTRING_LEN(rb_buffer));
410
540
  rugged_exception_check(error);
411
541
 
412
542
  error = stream->finalize_write(&oid, stream);
543
+ stream->free(stream);
413
544
  rugged_exception_check(error);
414
545
 
415
546
  return rugged_create_oid(&oid);
@@ -688,26 +819,273 @@ static VALUE rb_git_repo_status(int argc, VALUE *argv, VALUE self)
688
819
  return Qnil;
689
820
  }
690
821
 
822
+ static int rugged__each_id_cb(const git_oid *id, void *payload)
823
+ {
824
+ rb_yield(rugged_create_oid(id));
825
+ return 0;
826
+ }
827
+
828
+ /*
829
+ * call-seq:
830
+ * repo.each_id { |id| block }
831
+ * repo.each_id -> Iterator
832
+ *
833
+ * Call the given +block+ once with every object ID found in +repo+
834
+ * and all its alternates. Object IDs are passed as 40-character
835
+ * strings.
836
+ */
837
+ static VALUE rb_git_repo_each_id(VALUE self)
838
+ {
839
+ git_repository *repo;
840
+ git_odb *odb;
841
+ int error;
842
+
843
+ if (!rb_block_given_p())
844
+ return rb_funcall(self, rb_intern("to_enum"), 1, CSTR2SYM("each_id"));
845
+
846
+ Data_Get_Struct(self, git_repository, repo);
847
+
848
+ error = git_repository_odb(&odb, repo);
849
+ rugged_exception_check(error);
850
+
851
+ error = git_odb_foreach(odb, &rugged__each_id_cb, NULL);
852
+ git_odb_free(odb);
853
+
854
+ rugged_exception_check(error);
855
+ return Qnil;
856
+ }
857
+
858
+ static int parse_reset_type(VALUE rb_reset_type)
859
+ {
860
+ ID id_reset_type;
861
+
862
+ Check_Type(rb_reset_type, T_SYMBOL);
863
+ id_reset_type = SYM2ID(rb_reset_type);
864
+
865
+ if (id_reset_type == rb_intern("soft")) {
866
+ return GIT_RESET_SOFT;
867
+ } else if (id_reset_type == rb_intern("mixed")) {
868
+ return GIT_RESET_MIXED;
869
+ } else if (id_reset_type == rb_intern("hard")) {
870
+ return GIT_RESET_HARD;
871
+ } else {
872
+ rb_raise(rb_eArgError,
873
+ "Invalid reset type. Expected `:soft`, `:mixed` or `:hard`");
874
+ }
875
+ }
876
+
877
+ /*
878
+ * call-seq:
879
+ * repo.reset(target, reset_type) -> nil
880
+ *
881
+ * Sets the current head to the specified commit oid and optionally
882
+ * resets the index and working tree to match.
883
+ * - +target+: Rugged::Commit, Rugged::Tag or rev that resolves to a commit or tag object
884
+ * - +reset_type+: :soft, :mixed: or :hard
885
+ * [:soft] the head will be moved to the commit.
886
+ * [:mixed] will trigger a +:soft+ reset, plus the index will be replaced
887
+ * with the content of the commit tree.
888
+ * [:hard] will trigger a +:mixed+ reset and the working directory will be
889
+ * replaced with the content of the index. (Untracked and ignored files
890
+ * will be left alone)
891
+ *
892
+ * Examples:
893
+ * repo.reset('origin/master', :hard) #=> nil
894
+ */
895
+ static VALUE rb_git_repo_reset(VALUE self, VALUE rb_target, VALUE rb_reset_type)
896
+ {
897
+ git_repository *repo;
898
+ int reset_type;
899
+ git_object *target = NULL;
900
+ int error;
901
+
902
+ Data_Get_Struct(self, git_repository, repo);
903
+
904
+ reset_type = parse_reset_type(rb_reset_type);
905
+ target = rugged_object_get(repo, rb_target, GIT_OBJ_ANY);
906
+
907
+ error = git_reset(repo, target, reset_type);
908
+
909
+ git_object_free(target);
910
+ rugged_exception_check(error);
911
+
912
+ return Qnil;
913
+ }
914
+
915
+ /*
916
+ * call-seq:
917
+ * repo.reset_path(pathspecs, target=nil) -> nil
918
+ *
919
+ * Updates entries in the index from the +target+ commit tree, matching
920
+ * the given +pathspecs+.
921
+ *
922
+ * Passing a nil +target+ will result in removing
923
+ * entries in the index matching the provided pathspecs.
924
+ *
925
+ * - +pahtspecs+: list of pathspecs to operate on (+String+ or +Array+ of +String+ objects)
926
+ * - +target+(optional): Rugged::Commit, Rugged::Tag or rev that resolves to a commit or tag object.
927
+ *
928
+ * Examples:
929
+ * reset_path(File.join('subdir','file.txt'), '441034f860c1d5d90e4188d11ae0d325176869a8') #=> nil
930
+ */
931
+ static VALUE rb_git_repo_reset_path(int argc, VALUE *argv, VALUE self)
932
+ {
933
+ git_repository *repo;
934
+ git_object *target = NULL;
935
+ git_strarray pathspecs;
936
+ VALUE rb_target, rb_paths;
937
+ VALUE rb_path_array;
938
+ int i, error = 0;
939
+
940
+ pathspecs.strings = NULL;
941
+ pathspecs.count = 0;
942
+
943
+ Data_Get_Struct(self, git_repository, repo);
944
+
945
+ rb_scan_args(argc, argv, "11", &rb_paths, &rb_target);
946
+
947
+ rb_path_array = rb_ary_to_ary(rb_paths);
948
+
949
+ for (i = 0; i < RARRAY_LEN(rb_path_array); ++i)
950
+ Check_Type(rb_ary_entry(rb_path_array, i), T_STRING);
951
+
952
+ pathspecs.count = RARRAY_LEN(rb_path_array);
953
+ pathspecs.strings = xmalloc(pathspecs.count * sizeof(char *));
954
+
955
+ for (i = 0; i < RARRAY_LEN(rb_path_array); ++i) {
956
+ VALUE fpath = rb_ary_entry(rb_path_array, i);
957
+ pathspecs.strings[i] = StringValueCStr(fpath);
958
+ }
959
+
960
+ if (!NIL_P(rb_target))
961
+ target = rugged_object_get(repo, rb_target, GIT_OBJ_ANY);
962
+
963
+ error = git_reset_default(repo, target, &pathspecs);
964
+
965
+ xfree(pathspecs.strings);
966
+ git_object_free(target);
967
+
968
+ rugged_exception_check(error);
969
+
970
+ return Qnil;
971
+ }
972
+
973
+
974
+ static int rugged__push_status_cb(const char *ref, const char *msg, void *payload)
975
+ {
976
+ VALUE rb_result_hash = (VALUE)payload;
977
+ if (msg != NULL)
978
+ rb_hash_aset(rb_result_hash, rugged_str_new2(ref, rb_utf8_encoding()),
979
+ rugged_str_new2(msg, NULL));
980
+ return GIT_OK;
981
+ }
982
+
983
+ /*
984
+ * call-seq:
985
+ * repo.push("origin", ["refs/heads/master", ":refs/heads/to_be_deleted"])
986
+ *
987
+ * Pushes the given refspecs to the given remote. Returns a hash that contains key-value pairs that
988
+ * reflect pushed refs and error messages, if applicable.
989
+ */
990
+ static VALUE rb_git_repo_push(VALUE self, VALUE rb_remote, VALUE rb_refspecs)
991
+ {
992
+ VALUE rb_refspec, rb_exception = Qnil, rb_result = rb_hash_new();
993
+ git_repository *repo;
994
+ git_remote *remote = NULL;
995
+ git_push *push = NULL;
996
+
997
+ int error = 0, i = 0;
998
+
999
+ Check_Type(rb_refspecs, T_ARRAY);
1000
+ for (i = 0; i < RARRAY_LEN(rb_refspecs); ++i) {
1001
+ rb_refspec = rb_ary_entry(rb_refspecs, i);
1002
+ Check_Type(rb_refspec, T_STRING);
1003
+ }
1004
+
1005
+ Data_Get_Struct(self, git_repository, repo);
1006
+
1007
+ if (rb_obj_is_kind_of(rb_remote, rb_cRuggedRemote)) {
1008
+ Data_Get_Struct(rb_remote, git_remote, remote);
1009
+ } else if (TYPE(rb_remote) == T_STRING) {
1010
+ error = git_remote_load(&remote, repo, StringValueCStr(rb_remote));
1011
+ if (error) goto cleanup;
1012
+ } else {
1013
+ rb_raise(rb_eTypeError, "Expecting a String or Rugged::Remote instance");
1014
+ }
1015
+
1016
+ error = git_push_new(&push, remote);
1017
+ if (error) goto cleanup;
1018
+
1019
+ for (i = 0; !error && i < RARRAY_LEN(rb_refspecs); ++i) {
1020
+ rb_refspec = rb_ary_entry(rb_refspecs, i);
1021
+ error = git_push_add_refspec(push, StringValueCStr(rb_refspec));
1022
+ }
1023
+ if (error) goto cleanup;
1024
+
1025
+ error = git_push_finish(push);
1026
+
1027
+ if (error) {
1028
+ if (error == GIT_ENONFASTFORWARD) {
1029
+ rb_exception = rb_exc_new2(rb_eRuggedError, "non-fast-forward update rejected");
1030
+ } else if (error == -1) {
1031
+ rb_exception = rb_exc_new2(rb_eRuggedError, "could not push to repo (check for non-bare repo)");
1032
+ }
1033
+
1034
+ goto cleanup;
1035
+ }
1036
+
1037
+ if (!git_push_unpack_ok(push)) {
1038
+ rb_exception = rb_exc_new2(rb_eRuggedError, "the remote side did not unpack successfully");
1039
+ goto cleanup;
1040
+ }
1041
+
1042
+ error = git_push_status_foreach(push, &rugged__push_status_cb, (void *)rb_result);
1043
+ if (error) goto cleanup;
1044
+
1045
+ error = git_push_update_tips(push);
1046
+
1047
+ cleanup:
1048
+ git_push_free(push);
1049
+
1050
+ // We can only free the remote if we have loaded it ourselves.
1051
+ if (!rb_obj_is_kind_of(rb_remote, rb_cRuggedRemote)) {
1052
+ git_remote_free(remote);
1053
+ }
1054
+
1055
+ if (!NIL_P(rb_exception))
1056
+ rb_exc_raise(rb_exception);
1057
+
1058
+ rugged_exception_check(error);
1059
+
1060
+ return rb_result;
1061
+ }
1062
+
691
1063
  void Init_rugged_repo()
692
1064
  {
693
1065
  rb_cRuggedRepo = rb_define_class_under(rb_mRugged, "Repository", rb_cObject);
694
1066
 
695
- rb_define_singleton_method(rb_cRuggedRepo, "new", rb_git_repo_new, 1);
1067
+ rb_define_singleton_method(rb_cRuggedRepo, "new", rb_git_repo_new, -1);
1068
+ rb_define_singleton_method(rb_cRuggedRepo, "bare", rb_git_repo_open_bare, -1);
696
1069
  rb_define_singleton_method(rb_cRuggedRepo, "hash", rb_git_repo_hash, 2);
697
1070
  rb_define_singleton_method(rb_cRuggedRepo, "hash_file", rb_git_repo_hashfile, 2);
698
- rb_define_singleton_method(rb_cRuggedRepo, "init_at", rb_git_repo_init_at, 2);
1071
+ rb_define_singleton_method(rb_cRuggedRepo, "init_at", rb_git_repo_init_at, -1);
699
1072
  rb_define_singleton_method(rb_cRuggedRepo, "discover", rb_git_repo_discover, -1);
700
1073
 
701
1074
  rb_define_method(rb_cRuggedRepo, "exists?", rb_git_repo_exists, 1);
702
1075
  rb_define_method(rb_cRuggedRepo, "include?", rb_git_repo_exists, 1);
703
1076
 
704
1077
  rb_define_method(rb_cRuggedRepo, "read", rb_git_repo_read, 1);
1078
+ rb_define_method(rb_cRuggedRepo, "read_header", rb_git_repo_read_header, 1);
705
1079
  rb_define_method(rb_cRuggedRepo, "write", rb_git_repo_write, 2);
1080
+ rb_define_method(rb_cRuggedRepo, "each_id", rb_git_repo_each_id, 0);
1081
+
706
1082
  rb_define_method(rb_cRuggedRepo, "path", rb_git_repo_path, 0);
707
1083
  rb_define_method(rb_cRuggedRepo, "workdir", rb_git_repo_workdir, 0);
708
1084
  rb_define_method(rb_cRuggedRepo, "workdir=", rb_git_repo_set_workdir, 1);
709
1085
  rb_define_method(rb_cRuggedRepo, "status", rb_git_repo_status, -1);
710
1086
 
1087
+ rb_define_method(rb_cRuggedRepo, "push", rb_git_repo_push, 2);
1088
+
711
1089
  rb_define_method(rb_cRuggedRepo, "index", rb_git_repo_get_index, 0);
712
1090
  rb_define_method(rb_cRuggedRepo, "index=", rb_git_repo_set_index, 1);
713
1091
  rb_define_method(rb_cRuggedRepo, "config", rb_git_repo_get_config, 0);
@@ -719,6 +1097,10 @@ void Init_rugged_repo()
719
1097
  rb_define_method(rb_cRuggedRepo, "head_detached?", rb_git_repo_head_detached, 0);
720
1098
  rb_define_method(rb_cRuggedRepo, "head_orphan?", rb_git_repo_head_orphan, 0);
721
1099
 
1100
+ rb_define_method(rb_cRuggedRepo, "merge_base", rb_git_repo_merge_base, 2);
1101
+ rb_define_method(rb_cRuggedRepo, "reset", rb_git_repo_reset, 2);
1102
+ rb_define_method(rb_cRuggedRepo, "reset_path", rb_git_repo_reset_path, -1);
1103
+
722
1104
  rb_cRuggedOdbObject = rb_define_class_under(rb_mRugged, "OdbObject", rb_cObject);
723
1105
  rb_define_method(rb_cRuggedOdbObject, "data", rb_git_odbobj_data, 0);
724
1106
  rb_define_method(rb_cRuggedOdbObject, "len", rb_git_odbobj_size, 0);