rugged 0.23.0b1 → 0.23.0b2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_note.c +7 -2
  3. data/ext/rugged/rugged_revwalk.c +321 -145
  4. data/lib/rugged/version.rb +1 -1
  5. data/vendor/libgit2/CMakeLists.txt +83 -8
  6. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +9 -0
  7. data/vendor/libgit2/cmake/Modules/FindIconv.cmake +0 -3
  8. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +9 -0
  9. data/vendor/libgit2/deps/winhttp/urlmon.h +45 -0
  10. data/vendor/libgit2/deps/winhttp/winhttp.def +29 -0
  11. data/vendor/libgit2/deps/winhttp/winhttp.h +592 -0
  12. data/vendor/libgit2/deps/winhttp/winhttp64.def +29 -0
  13. data/vendor/libgit2/include/git2/diff.h +6 -1
  14. data/vendor/libgit2/include/git2/index.h +1 -1
  15. data/vendor/libgit2/include/git2/merge.h +2 -1
  16. data/vendor/libgit2/include/git2/notes.h +2 -2
  17. data/vendor/libgit2/include/git2/pack.h +12 -0
  18. data/vendor/libgit2/include/git2/push.h +30 -0
  19. data/vendor/libgit2/include/git2/rebase.h +36 -16
  20. data/vendor/libgit2/include/git2/remote.h +6 -0
  21. data/vendor/libgit2/include/git2/reset.h +2 -2
  22. data/vendor/libgit2/include/git2/revwalk.h +10 -8
  23. data/vendor/libgit2/include/git2/submodule.h +16 -0
  24. data/vendor/libgit2/include/git2/sys/transport.h +12 -4
  25. data/vendor/libgit2/include/git2/types.h +1 -0
  26. data/vendor/libgit2/src/attr.c +3 -3
  27. data/vendor/libgit2/src/attr_file.c +24 -3
  28. data/vendor/libgit2/src/attr_file.h +3 -1
  29. data/vendor/libgit2/src/checkout.c +31 -7
  30. data/vendor/libgit2/src/config.c +5 -6
  31. data/vendor/libgit2/src/config_file.c +533 -469
  32. data/vendor/libgit2/src/describe.c +1 -1
  33. data/vendor/libgit2/src/diff.c +20 -10
  34. data/vendor/libgit2/src/diff_driver.c +1 -1
  35. data/vendor/libgit2/src/diff_tform.c +8 -2
  36. data/vendor/libgit2/src/filter.c +6 -3
  37. data/vendor/libgit2/src/global.c +17 -15
  38. data/vendor/libgit2/src/global.h +3 -1
  39. data/vendor/libgit2/src/ignore.c +48 -8
  40. data/vendor/libgit2/src/ignore.h +1 -1
  41. data/vendor/libgit2/src/index.c +12 -8
  42. data/vendor/libgit2/src/iterator.c +133 -12
  43. data/vendor/libgit2/src/netops.h +2 -2
  44. data/vendor/libgit2/src/notes.c +40 -21
  45. data/vendor/libgit2/src/openssl_stream.c +5 -1
  46. data/vendor/libgit2/src/pack-objects.c +36 -0
  47. data/vendor/libgit2/src/path.c +277 -140
  48. data/vendor/libgit2/src/path.h +132 -60
  49. data/vendor/libgit2/src/posix.h +0 -1
  50. data/vendor/libgit2/src/push.c +43 -4
  51. data/vendor/libgit2/src/push.h +8 -1
  52. data/vendor/libgit2/src/rebase.c +139 -119
  53. data/vendor/libgit2/src/reflog.c +1 -1
  54. data/vendor/libgit2/src/refs.c +3 -5
  55. data/vendor/libgit2/src/remote.c +6 -5
  56. data/vendor/libgit2/src/repository.c +7 -3
  57. data/vendor/libgit2/src/reset.c +3 -3
  58. data/vendor/libgit2/src/revwalk.c +26 -2
  59. data/vendor/libgit2/src/settings.c +3 -3
  60. data/vendor/libgit2/src/stransport_stream.c +249 -0
  61. data/vendor/libgit2/src/stransport_stream.h +14 -0
  62. data/vendor/libgit2/src/submodule.c +26 -2
  63. data/vendor/libgit2/src/tls_stream.c +28 -0
  64. data/vendor/libgit2/src/tls_stream.h +21 -0
  65. data/vendor/libgit2/src/transport.c +4 -4
  66. data/vendor/libgit2/src/transports/git.c +4 -1
  67. data/vendor/libgit2/src/transports/http.c +6 -4
  68. data/vendor/libgit2/src/transports/local.c +2 -1
  69. data/vendor/libgit2/src/transports/smart.c +1 -1
  70. data/vendor/libgit2/src/transports/ssh.c +5 -1
  71. data/vendor/libgit2/src/transports/winhttp.c +30 -23
  72. data/vendor/libgit2/src/tree.c +2 -2
  73. data/vendor/libgit2/src/unix/posix.h +1 -0
  74. data/vendor/libgit2/src/util.h +117 -0
  75. data/vendor/libgit2/src/win32/buffer.c +55 -0
  76. data/vendor/libgit2/src/win32/buffer.h +18 -0
  77. data/vendor/libgit2/src/win32/path_w32.c +75 -0
  78. data/vendor/libgit2/src/win32/path_w32.h +3 -0
  79. data/vendor/libgit2/src/win32/posix.h +2 -2
  80. data/vendor/libgit2/src/win32/posix_w32.c +2 -118
  81. data/vendor/libgit2/src/win32/pthread.c +2 -0
  82. data/vendor/libgit2/src/win32/utf-conv.c +0 -4
  83. data/vendor/libgit2/src/win32/utf-conv.h +4 -0
  84. data/vendor/libgit2/src/win32/w32_util.h +72 -0
  85. metadata +14 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3ccaada5f69a36af35645687caa0f1a638a4b0b
4
- data.tar.gz: c4bce14c10e3fe2a221414f741b165c7e66d7172
3
+ metadata.gz: 113f78e6f34a503f2f1f27e377f5077337e39fd9
4
+ data.tar.gz: b01d276a151b57fc82070fe82392efbb1acb8473
5
5
  SHA512:
6
- metadata.gz: 6fa91bf79f6400ec811298aab161e8204606e203dd9aa90e7f723a02d0ee84cd15dbb9b337a8d4f2ad0d8e635403a372cb81540ee4335163d9867a92de81c50d
7
- data.tar.gz: db2139a478a8c3d357fabd5ff73a8206628b21feb6e8fef06124346da4b3b796cf38320ec50b18f0e8d5dae69aa05b1ea7ead18cb902803ca407f05c749a9fac
6
+ metadata.gz: 2b6a7770eb347c4f368dd87f5af01d307c6631dd2dd9dc531d71f3a735e23fc6921d8fd88159bff9fa7c5c9382ba9086caa26b9a26a75c626e2ec447c1c94940
7
+ data.tar.gz: 732025da8feceec8a4620025992d9833c1059c6e0d1ef21e8c4f8efbf4c3fb53e0ba872ee8f101f37ce42a3ebdc250bc5943ac8a01baca6372e2a2818e1efe66
@@ -349,7 +349,8 @@ static VALUE rb_git_note_each(int argc, VALUE *argv, VALUE self)
349
349
  static VALUE rb_git_note_default_ref_GET(VALUE self)
350
350
  {
351
351
  git_repository *repo = NULL;
352
- const char * ref_name;
352
+ git_buf ref_name = { 0 };
353
+ VALUE rb_result;
353
354
 
354
355
  Data_Get_Struct(self, git_repository, repo);
355
356
 
@@ -357,7 +358,11 @@ static VALUE rb_git_note_default_ref_GET(VALUE self)
357
358
  git_note_default_ref(&ref_name, repo)
358
359
  );
359
360
 
360
- return rb_str_new_utf8(ref_name);
361
+ rb_result = rb_enc_str_new(ref_name.ptr, ref_name.size, rb_utf8_encoding());
362
+
363
+ git_buf_free(&ref_name);
364
+
365
+ return rb_result;
361
366
  }
362
367
 
363
368
  void Init_rugged_notes(void)
@@ -25,6 +25,7 @@
25
25
  #include "rugged.h"
26
26
 
27
27
  extern VALUE rb_mRugged;
28
+ extern VALUE rb_cRuggedObject;
28
29
  VALUE rb_cRuggedWalker;
29
30
 
30
31
  static void rb_git_walk__free(git_revwalk *walk)
@@ -39,153 +40,77 @@ VALUE rugged_walker_new(VALUE klass, VALUE owner, git_revwalk *walk)
39
40
  return rb_walk;
40
41
  }
41
42
 
42
- /*
43
- * call-seq:
44
- * Walker.new(repository) -> walker
45
- *
46
- * Create a new +Walker+ instance able to walk commits found
47
- * in +repository+, which is a <tt>Rugged::Repository</tt> instance.
48
- */
49
- static VALUE rb_git_walker_new(VALUE klass, VALUE rb_repo)
43
+ static void push_commit_oid(git_revwalk *walk, const git_oid *oid, int hide)
50
44
  {
51
- git_repository *repo;
52
- git_revwalk *walk;
53
45
  int error;
54
-
55
- Data_Get_Struct(rb_repo, git_repository, repo);
56
-
57
- error = git_revwalk_new(&walk, repo);
46
+ if (hide) error = git_revwalk_hide(walk, oid);
47
+ else error = git_revwalk_push(walk, oid);
58
48
  rugged_exception_check(error);
59
-
60
- return rugged_walker_new(klass, rb_repo, walk);;
61
49
  }
62
50
 
63
- static VALUE rb_git_walker_each_with_opts(int argc, VALUE *argv, VALUE self, int oid_only)
51
+ static void push_commit_ref(git_revwalk *walk, const char *ref, int hide)
64
52
  {
65
- git_revwalk *walk;
66
- git_commit *commit;
67
- git_repository *repo;
68
- git_oid commit_oid;
69
-
70
- int error, exception = 0;
71
- uint64_t offset = 0, limit = UINT64_MAX;
72
-
73
- VALUE rb_options;
53
+ int error;
54
+ if (hide) error = git_revwalk_hide_ref(walk, ref);
55
+ else error = git_revwalk_push_ref(walk, ref);
56
+ rugged_exception_check(error);
57
+ }
74
58
 
75
- rb_scan_args(argc, argv, "01", &rb_options);
59
+ static void push_commit_1(git_revwalk *walk, VALUE rb_commit, int hide)
60
+ {
61
+ if (rb_obj_is_kind_of(rb_commit, rb_cRuggedObject)) {
62
+ git_object *object;
63
+ Data_Get_Struct(rb_commit, git_object, object);
76
64
 
77
- if (!rb_block_given_p()) {
78
- ID iter_method = ID2SYM(rb_intern(oid_only ? "each_oid" : "each"));
79
- return rb_funcall(self, rb_intern("to_enum"), 2, iter_method, rb_options);
65
+ push_commit_oid(walk, git_object_id(object), hide);
66
+ return;
80
67
  }
81
68
 
82
- if (!NIL_P(rb_options)) {
83
- VALUE rb_value = rb_hash_aref(rb_options, CSTR2SYM("offset"));
84
- if (!NIL_P(rb_value)) {
85
- Check_Type(rb_value, T_FIXNUM);
86
- offset = FIX2ULONG(rb_value);
87
- }
69
+ Check_Type(rb_commit, T_STRING);
88
70
 
89
- rb_value = rb_hash_aref(rb_options, CSTR2SYM("limit"));
90
- if (!NIL_P(rb_value)) {
91
- Check_Type(rb_value, T_FIXNUM);
92
- limit = FIX2ULONG(rb_value);
71
+ if (RSTRING_LEN(rb_commit) == 40) {
72
+ git_oid commit_oid;
73
+ if (git_oid_fromstr(&commit_oid, RSTRING_PTR(rb_commit)) == 0) {
74
+ push_commit_oid(walk, &commit_oid, hide);
75
+ return;
93
76
  }
94
77
  }
95
78
 
96
- Data_Get_Struct(self, git_revwalk, walk);
97
- repo = git_revwalk_repository(walk);
98
-
99
- while ((error = git_revwalk_next(&commit_oid, walk)) == 0) {
100
- if (offset > 0) {
101
- offset--;
102
- continue;
103
- }
104
-
105
- if (oid_only) {
106
- rb_protect(rb_yield,
107
- rugged_create_oid(&commit_oid),
108
- &exception);
109
- } else {
110
- error = git_commit_lookup(&commit, repo, &commit_oid);
111
- rugged_exception_check(error);
79
+ push_commit_ref(walk, StringValueCStr(rb_commit), hide);
80
+ }
112
81
 
113
- rb_protect(rb_yield,
114
- rugged_object_new(rugged_owner(self), (git_object *)commit),
115
- &exception);
116
- }
82
+ static void push_commit(git_revwalk *walk, VALUE rb_commit, int hide)
83
+ {
84
+ if (rb_type(rb_commit) == T_ARRAY) {
85
+ long i;
86
+ for (i = 0; i < RARRAY_LEN(rb_commit); ++i)
87
+ push_commit_1(walk, rb_ary_entry(rb_commit, i), hide);
117
88
 
118
- if (exception || --limit == 0)
119
- break;
89
+ return;
120
90
  }
121
91
 
122
- if (exception)
123
- rb_jump_tag(exception);
124
-
125
- if (error != GIT_ITEROVER)
126
- rugged_exception_check(error);
127
-
128
- return Qnil;
92
+ push_commit_1(walk, rb_commit, hide);
129
93
  }
130
94
 
131
95
  /*
132
96
  * call-seq:
133
- * walker.each { |commit| block }
134
- * walker.each -> Iterator
135
- *
136
- * Perform the walk through the repository, yielding each
137
- * one of the commits found as a <tt>Rugged::Commit</tt> instance
138
- * to +block+.
139
- *
140
- * If no +block+ is given, an +Iterator+ will be returned.
141
- *
142
- * The walker must have been previously set-up before a walk can be performed
143
- * (i.e. at least one commit must have been pushed).
144
- *
145
- * walker.push("92b22bbcb37caf4f6f53d30292169e84f5e4283b")
146
- * walker.each { |commit| puts commit.oid }
147
- *
148
- * generates:
97
+ * Walker.new(repository) -> walker
149
98
  *
150
- * 92b22bbcb37caf4f6f53d30292169e84f5e4283b
151
- * 6b750d5800439b502de669465b385e5f469c78b6
152
- * ef9207141549f4ffcd3c4597e270d32e10d0a6bc
153
- * cb75e05f0f8ac3407fb3bd0ebd5ff07573b16c9f
154
- * ...
99
+ * Create a new +Walker+ instance able to walk commits found
100
+ * in +repository+, which is a <tt>Rugged::Repository</tt> instance.
155
101
  */
156
- static VALUE rb_git_walker_each(int argc, VALUE *argv, VALUE self)
102
+ static VALUE rb_git_walker_new(VALUE klass, VALUE rb_repo)
157
103
  {
158
- return rb_git_walker_each_with_opts(argc, argv, self, 0);
159
- }
104
+ git_repository *repo;
105
+ git_revwalk *walk;
106
+ int error;
160
107
 
161
- /*
162
- * call-seq:
163
- * walker.each_oid { |commit| block }
164
- * walker.each_oid -> Iterator
165
- *
166
- * Perform the walk through the repository, yielding each
167
- * one of the commit oids found as a <tt>String</tt>
168
- * to +block+.
169
- *
170
- * If no +block+ is given, an +Iterator+ will be returned.
171
- *
172
- * The walker must have been previously set-up before a walk can be performed
173
- * (i.e. at least one commit must have been pushed).
174
- *
175
- * walker.push("92b22bbcb37caf4f6f53d30292169e84f5e4283b")
176
- * walker.each { |commit_oid| puts commit_oid }
177
- *
178
- * generates:
179
- *
180
- * 92b22bbcb37caf4f6f53d30292169e84f5e4283b
181
- * 6b750d5800439b502de669465b385e5f469c78b6
182
- * ef9207141549f4ffcd3c4597e270d32e10d0a6bc
183
- * cb75e05f0f8ac3407fb3bd0ebd5ff07573b16c9f
184
- * ...
185
- */
186
- static VALUE rb_git_walker_each_oid(int argc, VALUE *argv, VALUE self)
187
- {
188
- return rb_git_walker_each_with_opts(argc, argv, self, 1);
108
+ Data_Get_Struct(rb_repo, git_repository, repo);
109
+
110
+ error = git_revwalk_new(&walk, repo);
111
+ rugged_exception_check(error);
112
+
113
+ return rugged_walker_new(klass, rb_repo, walk);;
189
114
  }
190
115
 
191
116
  /*
@@ -207,19 +132,8 @@ static VALUE rb_git_walker_each_oid(int argc, VALUE *argv, VALUE self)
207
132
  static VALUE rb_git_walker_push(VALUE self, VALUE rb_commit)
208
133
  {
209
134
  git_revwalk *walk;
210
- git_commit *commit;
211
- int error;
212
-
213
135
  Data_Get_Struct(self, git_revwalk, walk);
214
-
215
- commit = (git_commit *)rugged_object_get(
216
- git_revwalk_repository(walk), rb_commit, GIT_OBJ_COMMIT);
217
-
218
- error = git_revwalk_push(walk, git_object_id((git_object *)commit));
219
-
220
- git_commit_free(commit);
221
- rugged_exception_check(error);
222
-
136
+ push_commit(walk, rb_commit, 0);
223
137
  return Qnil;
224
138
  }
225
139
 
@@ -241,19 +155,8 @@ static VALUE rb_git_walker_push_range(VALUE self, VALUE range)
241
155
  static VALUE rb_git_walker_hide(VALUE self, VALUE rb_commit)
242
156
  {
243
157
  git_revwalk *walk;
244
- git_commit *commit;
245
- int error;
246
-
247
158
  Data_Get_Struct(self, git_revwalk, walk);
248
-
249
- commit = (git_commit *)rugged_object_get(
250
- git_revwalk_repository(walk), rb_commit, GIT_OBJ_COMMIT);
251
-
252
- error = git_revwalk_hide(walk, git_object_id((git_object *)commit));
253
-
254
- git_commit_free(commit);
255
- rugged_exception_check(error);
256
-
159
+ push_commit(walk, rb_commit, 1);
257
160
  return Qnil;
258
161
  }
259
162
 
@@ -302,10 +205,283 @@ static VALUE rb_git_walker_reset(VALUE self)
302
205
  return Qnil;
303
206
  }
304
207
 
208
+ struct walk_options {
209
+ VALUE rb_owner;
210
+ VALUE rb_options;
211
+
212
+ git_repository *repo;
213
+ git_revwalk *walk;
214
+ int oid_only;
215
+ uint64_t offset, limit;
216
+ };
217
+
218
+ static void load_walk_limits(struct walk_options *w, VALUE rb_options)
219
+ {
220
+ VALUE rb_value = rb_hash_lookup(rb_options, CSTR2SYM("offset"));
221
+ if (!NIL_P(rb_value)) {
222
+ Check_Type(rb_value, T_FIXNUM);
223
+ w->offset = FIX2ULONG(rb_value);
224
+ }
225
+
226
+ rb_value = rb_hash_lookup(rb_options, CSTR2SYM("limit"));
227
+ if (!NIL_P(rb_value)) {
228
+ Check_Type(rb_value, T_FIXNUM);
229
+ w->limit = FIX2ULONG(rb_value);
230
+ }
231
+ }
232
+
233
+ static VALUE load_all_options(VALUE _payload)
234
+ {
235
+ struct walk_options *w = (struct walk_options *)_payload;
236
+ VALUE rb_options = w->rb_options;
237
+ VALUE rb_show, rb_hide, rb_sort, rb_simp, rb_oid_only;
238
+
239
+ load_walk_limits(w, rb_options);
240
+
241
+ rb_sort = rb_hash_lookup(rb_options, CSTR2SYM("sort"));
242
+ if (!NIL_P(rb_sort)) {
243
+ Check_Type(rb_sort, T_FIXNUM);
244
+ git_revwalk_sorting(w->walk, FIX2INT(rb_sort));
245
+ }
246
+
247
+ rb_show = rb_hash_lookup(rb_options, CSTR2SYM("show"));
248
+ if (!NIL_P(rb_show)) {
249
+ push_commit(w->walk, rb_show, 0);
250
+ }
251
+
252
+ rb_hide = rb_hash_lookup(rb_options, CSTR2SYM("hide"));
253
+ if (!NIL_P(rb_hide)) {
254
+ push_commit(w->walk, rb_hide, 1);
255
+ }
256
+
257
+ rb_simp = rb_hash_lookup(rb_options, CSTR2SYM("simplify"));
258
+ if (RTEST(rb_simp)) {
259
+ git_revwalk_simplify_first_parent(w->walk);
260
+ }
261
+
262
+ rb_oid_only = rb_hash_lookup(rb_options, CSTR2SYM("oid_only"));
263
+ if (RTEST(rb_oid_only)) {
264
+ w->oid_only = 1;
265
+ }
266
+
267
+ return Qnil;
268
+ }
269
+
270
+ static VALUE do_walk(VALUE _payload)
271
+ {
272
+ struct walk_options *w = (struct walk_options *)_payload;
273
+ int error;
274
+ git_oid commit_oid;
275
+
276
+ while ((error = git_revwalk_next(&commit_oid, w->walk)) == 0) {
277
+ if (w->offset > 0) {
278
+ w->offset--;
279
+ continue;
280
+ }
281
+
282
+ if (w->oid_only) {
283
+ rb_yield(rugged_create_oid(&commit_oid));
284
+ } else {
285
+ git_commit *commit;
286
+
287
+ error = git_commit_lookup(&commit, w->repo, &commit_oid);
288
+ rugged_exception_check(error);
289
+
290
+ rb_yield(
291
+ rugged_object_new(w->rb_owner, (git_object *)commit)
292
+ );
293
+ }
294
+
295
+ if (--w->limit == 0)
296
+ break;
297
+ }
298
+
299
+ if (error != GIT_ITEROVER)
300
+ rugged_exception_check(error);
301
+
302
+ return Qnil;
303
+ }
304
+
305
+ /*
306
+ * call-seq:
307
+ * Rugged::Walker.walk(repo, options={}) { |commit| block }
308
+ *
309
+ * Create a Walker object, initialize it with the given options
310
+ * and perform a walk on the repository; the lifetime of the
311
+ * walker is bound to the call and it is immediately cleaned
312
+ * up after the walk is over.
313
+ *
314
+ * The following options are available:
315
+ *
316
+ * - +sort+: Sorting mode for the walk (or an OR combination
317
+ * of several sorting modes).
318
+ *
319
+ * - +show+: Tips of the repository that will be walked;
320
+ * this is necessary for the walk to yield any results.
321
+ * A tip can be a 40-char object ID, an existing +Rugged::Commit+
322
+ * object, a reference, or an +Array+ of several of these
323
+ * (if you'd like to walk several tips in parallel).
324
+ *
325
+ * - +hide+: Same as +show+, but hides the given tips instead
326
+ * so they don't appear on the walk.
327
+ *
328
+ * - +oid_only+: if +true+, the walker will yield 40-char OIDs
329
+ * for each commit, instead of real +Rugged::Commit+ objects.
330
+ * Defaults to +false+.
331
+ *
332
+ * - +simplify+: if +true+, the walk will be simplified
333
+ * to the first parent of each commit.
334
+ *
335
+ * Example:
336
+ *
337
+ * Rugged::Walker.walk(repo,
338
+ * show: "92b22bbcb37caf4f6f53d30292169e84f5e4283b",
339
+ * sort: Rugged::SORT_DATE|Rugged::SORT_TOPO,
340
+ * oid_only: true) do |commit_oid|
341
+ * puts commit_oid
342
+ * end
343
+ *
344
+ * generates:
345
+ *
346
+ * 92b22bbcb37caf4f6f53d30292169e84f5e4283b
347
+ * 6b750d5800439b502de669465b385e5f469c78b6
348
+ * ef9207141549f4ffcd3c4597e270d32e10d0a6bc
349
+ * cb75e05f0f8ac3407fb3bd0ebd5ff07573b16c9f
350
+ * ...
351
+ */
352
+ static VALUE rb_git_walk(int argc, VALUE *argv, VALUE self)
353
+ {
354
+ VALUE rb_repo, rb_options;
355
+ struct walk_options w;
356
+ int exception = 0;
357
+
358
+ rb_scan_args(argc, argv, "10:", &rb_repo, &rb_options);
359
+
360
+ if (!rb_block_given_p()) {
361
+ ID iter_method = ID2SYM(rb_intern("walk"));
362
+ return rb_funcall(self, rb_intern("to_enum"), 3,
363
+ iter_method, rb_repo, rb_options);
364
+ }
365
+
366
+ Data_Get_Struct(rb_repo, git_repository, w.repo);
367
+ rugged_exception_check(git_revwalk_new(&w.walk, w.repo));
368
+
369
+ w.rb_owner = rb_repo;
370
+ w.rb_options = rb_options;
371
+
372
+ w.oid_only = 0;
373
+ w.offset = 0;
374
+ w.limit = UINT64_MAX;
375
+
376
+ if (!NIL_P(w.rb_options))
377
+ rb_protect(load_all_options, (VALUE)&w, &exception);
378
+
379
+ if (!exception)
380
+ rb_protect(do_walk, (VALUE)&w, &exception);
381
+
382
+ git_revwalk_free(w.walk);
383
+
384
+ if (exception)
385
+ rb_jump_tag(exception);
386
+
387
+ return Qnil;
388
+ }
389
+
390
+ static VALUE rb_git_walk_with_opts(int argc, VALUE *argv, VALUE self, int oid_only)
391
+ {
392
+ VALUE rb_options;
393
+ struct walk_options w;
394
+
395
+ rb_scan_args(argc, argv, "01", &rb_options);
396
+
397
+ if (!rb_block_given_p()) {
398
+ ID iter_method = ID2SYM(rb_intern(oid_only ? "each_oid" : "each"));
399
+ return rb_funcall(self, rb_intern("to_enum"), 2, iter_method, rb_options);
400
+ }
401
+
402
+ Data_Get_Struct(self, git_revwalk, w.walk);
403
+ w.repo = git_revwalk_repository(w.walk);
404
+
405
+ w.rb_owner = rugged_owner(self);
406
+ w.rb_options = Qnil;
407
+
408
+ w.oid_only = oid_only;
409
+ w.offset = 0;
410
+ w.limit = UINT64_MAX;
411
+
412
+ if (!NIL_P(rb_options))
413
+ load_walk_limits(&w, rb_options);
414
+
415
+ return do_walk((VALUE)&w);
416
+ }
417
+
418
+ /*
419
+ * call-seq:
420
+ * walker.each { |commit| block }
421
+ * walker.each -> Iterator
422
+ *
423
+ * Perform the walk through the repository, yielding each
424
+ * one of the commits found as a <tt>Rugged::Commit</tt> instance
425
+ * to +block+.
426
+ *
427
+ * If no +block+ is given, an +Iterator+ will be returned.
428
+ *
429
+ * The walker must have been previously set-up before a walk can be performed
430
+ * (i.e. at least one commit must have been pushed).
431
+ *
432
+ * walker.push("92b22bbcb37caf4f6f53d30292169e84f5e4283b")
433
+ * walker.each { |commit| puts commit.oid }
434
+ *
435
+ * generates:
436
+ *
437
+ * 92b22bbcb37caf4f6f53d30292169e84f5e4283b
438
+ * 6b750d5800439b502de669465b385e5f469c78b6
439
+ * ef9207141549f4ffcd3c4597e270d32e10d0a6bc
440
+ * cb75e05f0f8ac3407fb3bd0ebd5ff07573b16c9f
441
+ * ...
442
+ */
443
+ static VALUE rb_git_walker_each(int argc, VALUE *argv, VALUE self)
444
+ {
445
+ return rb_git_walk_with_opts(argc, argv, self, 0);
446
+ }
447
+
448
+ /*
449
+ * call-seq:
450
+ * walker.each_oid { |commit| block }
451
+ * walker.each_oid -> Iterator
452
+ *
453
+ * Perform the walk through the repository, yielding each
454
+ * one of the commit oids found as a <tt>String</tt>
455
+ * to +block+.
456
+ *
457
+ * If no +block+ is given, an +Iterator+ will be returned.
458
+ *
459
+ * The walker must have been previously set-up before a walk can be performed
460
+ * (i.e. at least one commit must have been pushed).
461
+ *
462
+ * walker.push("92b22bbcb37caf4f6f53d30292169e84f5e4283b")
463
+ * walker.each { |commit_oid| puts commit_oid }
464
+ *
465
+ * generates:
466
+ *
467
+ * 92b22bbcb37caf4f6f53d30292169e84f5e4283b
468
+ * 6b750d5800439b502de669465b385e5f469c78b6
469
+ * ef9207141549f4ffcd3c4597e270d32e10d0a6bc
470
+ * cb75e05f0f8ac3407fb3bd0ebd5ff07573b16c9f
471
+ * ...
472
+ */
473
+ static VALUE rb_git_walker_each_oid(int argc, VALUE *argv, VALUE self)
474
+ {
475
+ return rb_git_walk_with_opts(argc, argv, self, 1);
476
+ }
477
+
478
+
479
+
305
480
  void Init_rugged_revwalk(void)
306
481
  {
307
482
  rb_cRuggedWalker = rb_define_class_under(rb_mRugged, "Walker", rb_cObject);
308
483
  rb_define_singleton_method(rb_cRuggedWalker, "new", rb_git_walker_new, 1);
484
+ rb_define_singleton_method(rb_cRuggedWalker, "walk", rb_git_walk, -1);
309
485
 
310
486
  rb_define_method(rb_cRuggedWalker, "push", rb_git_walker_push, 1);
311
487
  rb_define_method(rb_cRuggedWalker, "push_range", rb_git_walker_push_range, 1);
@@ -1,3 +1,3 @@
1
1
  module Rugged
2
- Version = VERSION = '0.23.0b1'
2
+ Version = VERSION = '0.23.0b2'
3
3
  end