rugged 0.23.0b2 → 0.23.0b4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_blob.c +39 -0
  3. data/ext/rugged/rugged_diff.c +7 -3
  4. data/ext/rugged/rugged_index.c +2 -2
  5. data/ext/rugged/rugged_remote.c +27 -148
  6. data/ext/rugged/rugged_remote_collection.c +134 -12
  7. data/ext/rugged/rugged_repo.c +74 -5
  8. data/ext/rugged/rugged_submodule.c +18 -208
  9. data/ext/rugged/rugged_submodule_collection.c +148 -0
  10. data/lib/rugged/version.rb +1 -1
  11. data/vendor/libgit2/AUTHORS +1 -0
  12. data/vendor/libgit2/CMakeLists.txt +33 -25
  13. data/vendor/libgit2/deps/winhttp/winhttp.def +29 -29
  14. data/vendor/libgit2/include/git2.h +1 -1
  15. data/vendor/libgit2/include/git2/blob.h +4 -6
  16. data/vendor/libgit2/include/git2/checkout.h +10 -1
  17. data/vendor/libgit2/include/git2/clone.h +6 -7
  18. data/vendor/libgit2/include/git2/commit.h +11 -0
  19. data/vendor/libgit2/include/git2/cred_helpers.h +2 -2
  20. data/vendor/libgit2/include/git2/describe.h +1 -1
  21. data/vendor/libgit2/include/git2/diff.h +68 -11
  22. data/vendor/libgit2/include/git2/errors.h +4 -1
  23. data/vendor/libgit2/include/git2/filter.h +16 -0
  24. data/vendor/libgit2/include/git2/index.h +38 -11
  25. data/vendor/libgit2/include/git2/odb.h +1 -1
  26. data/vendor/libgit2/include/git2/odb_backend.h +2 -2
  27. data/vendor/libgit2/include/git2/remote.h +300 -207
  28. data/vendor/libgit2/include/git2/reset.h +1 -0
  29. data/vendor/libgit2/include/git2/stash.h +135 -4
  30. data/vendor/libgit2/include/git2/status.h +1 -0
  31. data/vendor/libgit2/include/git2/submodule.h +46 -75
  32. data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
  33. data/vendor/libgit2/include/git2/sys/stream.h +2 -0
  34. data/vendor/libgit2/include/git2/sys/transport.h +1 -21
  35. data/vendor/libgit2/include/git2/transport.h +27 -0
  36. data/vendor/libgit2/include/git2/types.h +20 -10
  37. data/vendor/libgit2/include/git2/version.h +3 -3
  38. data/vendor/libgit2/libgit2.pc.in +4 -2
  39. data/vendor/libgit2/src/attr.c +2 -1
  40. data/vendor/libgit2/src/attr_file.c +18 -37
  41. data/vendor/libgit2/src/blame.c +2 -2
  42. data/vendor/libgit2/src/blob.c +4 -3
  43. data/vendor/libgit2/src/branch.c +6 -3
  44. data/vendor/libgit2/src/buf_text.c +4 -6
  45. data/vendor/libgit2/src/buf_text.h +1 -2
  46. data/vendor/libgit2/src/buffer.c +8 -6
  47. data/vendor/libgit2/src/buffer.h +1 -1
  48. data/vendor/libgit2/src/cache.c +1 -0
  49. data/vendor/libgit2/src/checkout.c +34 -20
  50. data/vendor/libgit2/src/clone.c +29 -29
  51. data/vendor/libgit2/src/commit.c +65 -0
  52. data/vendor/libgit2/src/common.h +5 -0
  53. data/vendor/libgit2/src/config.c +20 -0
  54. data/vendor/libgit2/src/config.h +6 -0
  55. data/vendor/libgit2/src/config_file.c +2 -2
  56. data/vendor/libgit2/src/crlf.c +39 -17
  57. data/vendor/libgit2/src/curl_stream.c +257 -0
  58. data/vendor/libgit2/src/curl_stream.h +14 -0
  59. data/vendor/libgit2/src/diff.c +223 -88
  60. data/vendor/libgit2/src/diff.h +21 -1
  61. data/vendor/libgit2/src/diff_file.c +23 -13
  62. data/vendor/libgit2/src/diff_file.h +4 -2
  63. data/vendor/libgit2/src/diff_patch.c +266 -71
  64. data/vendor/libgit2/src/diff_patch.h +36 -0
  65. data/vendor/libgit2/src/diff_print.c +156 -126
  66. data/vendor/libgit2/src/diff_tform.c +32 -54
  67. data/vendor/libgit2/src/fetch.c +27 -10
  68. data/vendor/libgit2/src/fetch.h +2 -2
  69. data/vendor/libgit2/src/filebuf.c +1 -1
  70. data/vendor/libgit2/src/fileops.c +6 -2
  71. data/vendor/libgit2/src/filter.c +28 -7
  72. data/vendor/libgit2/src/fnmatch.c +5 -5
  73. data/vendor/libgit2/src/global.c +16 -0
  74. data/vendor/libgit2/src/ident.c +2 -2
  75. data/vendor/libgit2/src/ignore.c +1 -0
  76. data/vendor/libgit2/src/index.c +338 -80
  77. data/vendor/libgit2/src/index.h +4 -1
  78. data/vendor/libgit2/src/indexer.c +19 -5
  79. data/vendor/libgit2/src/iterator.c +118 -11
  80. data/vendor/libgit2/src/iterator.h +25 -0
  81. data/vendor/libgit2/src/merge.c +96 -106
  82. data/vendor/libgit2/src/merge.h +14 -4
  83. data/vendor/libgit2/src/netops.c +3 -3
  84. data/vendor/libgit2/src/odb.c +17 -9
  85. data/vendor/libgit2/src/odb.h +1 -1
  86. data/vendor/libgit2/src/odb_loose.c +2 -2
  87. data/vendor/libgit2/src/odb_pack.c +1 -1
  88. data/vendor/libgit2/src/openssl_stream.c +118 -27
  89. data/vendor/libgit2/src/pack-objects.c +28 -0
  90. data/vendor/libgit2/src/pack-objects.h +1 -0
  91. data/vendor/libgit2/src/pack.c +18 -10
  92. data/vendor/libgit2/src/path.c +16 -11
  93. data/vendor/libgit2/src/path.h +1 -1
  94. data/vendor/libgit2/src/push.c +26 -42
  95. data/vendor/libgit2/src/push.h +2 -34
  96. data/vendor/libgit2/src/rebase.c +1 -1
  97. data/vendor/libgit2/src/refs.c +1 -1
  98. data/vendor/libgit2/src/refspec.c +6 -0
  99. data/vendor/libgit2/src/remote.c +381 -274
  100. data/vendor/libgit2/src/remote.h +0 -4
  101. data/vendor/libgit2/src/repository.c +33 -12
  102. data/vendor/libgit2/src/repository.h +0 -1
  103. data/vendor/libgit2/src/reset.c +1 -0
  104. data/vendor/libgit2/src/stash.c +439 -17
  105. data/vendor/libgit2/src/status.c +6 -0
  106. data/vendor/libgit2/src/stransport_stream.c +58 -21
  107. data/vendor/libgit2/src/stream.h +15 -0
  108. data/vendor/libgit2/src/submodule.c +410 -664
  109. data/vendor/libgit2/src/submodule.h +0 -24
  110. data/vendor/libgit2/src/transaction.c +1 -0
  111. data/vendor/libgit2/src/transports/cred.c +55 -1
  112. data/vendor/libgit2/src/transports/http.c +18 -2
  113. data/vendor/libgit2/src/transports/local.c +60 -59
  114. data/vendor/libgit2/src/transports/smart.h +1 -1
  115. data/vendor/libgit2/src/transports/smart_protocol.c +11 -11
  116. data/vendor/libgit2/src/transports/ssh.c +46 -7
  117. data/vendor/libgit2/src/unix/posix.h +4 -0
  118. data/vendor/libgit2/src/util.c +9 -9
  119. data/vendor/libgit2/src/util.h +9 -0
  120. data/vendor/libgit2/src/win32/posix.h +3 -0
  121. data/vendor/libgit2/src/win32/posix_w32.c +38 -0
  122. data/vendor/libgit2/src/win32/w32_util.h +10 -0
  123. metadata +4 -3
  124. data/vendor/libgit2/include/git2/push.h +0 -94
@@ -410,7 +410,6 @@ static VALUE rb_git_repo_init_at(int argc, VALUE *argv, VALUE klass)
410
410
 
411
411
  static void parse_clone_options(git_clone_options *ret, VALUE rb_options, struct rugged_remote_cb_payload *remote_payload)
412
412
  {
413
- git_remote_callbacks remote_callbacks = GIT_REMOTE_CALLBACKS_INIT;
414
413
  VALUE val;
415
414
 
416
415
  if (NIL_P(rb_options))
@@ -426,9 +425,7 @@ static void parse_clone_options(git_clone_options *ret, VALUE rb_options, struct
426
425
  ret->checkout_branch = StringValueCStr(val);
427
426
  }
428
427
 
429
- rugged_remote_init_callbacks_and_payload_from_options(rb_options, &remote_callbacks, remote_payload);
430
-
431
- ret->remote_callbacks = remote_callbacks;
428
+ rugged_remote_init_callbacks_and_payload_from_options(rb_options, &ret->fetch_opts.callbacks, remote_payload);
432
429
  }
433
430
 
434
431
  /*
@@ -593,6 +590,75 @@ static VALUE rb_git_repo_get_config(VALUE self)
593
590
  RB_GIT_REPO_OWNED_GET(rb_cRuggedConfig, config);
594
591
  }
595
592
 
593
+ /*
594
+ * call-seq:
595
+ * repo.ident = ident
596
+ *
597
+ * Set the identity to be used for writing reflogs.
598
+ *
599
+ * +ident+ can be either +nil+ or a Hash containing +name+ and/or +email+ entries.
600
+ */
601
+ static VALUE rb_git_repo_set_ident(VALUE self, VALUE rb_ident) {
602
+ VALUE rb_val;
603
+
604
+ git_repository *repo;
605
+ const char *name = NULL, *email = NULL;
606
+
607
+ Data_Get_Struct(self, git_repository, repo);
608
+
609
+ if (!NIL_P(rb_ident)) {
610
+ Check_Type(rb_ident, T_HASH);
611
+
612
+ if (!NIL_P(rb_val = rb_hash_aref(rb_ident, CSTR2SYM("name")))) {
613
+ Check_Type(rb_val, T_STRING);
614
+ name = StringValueCStr(rb_val);
615
+ }
616
+
617
+ if (!NIL_P(rb_val = rb_hash_aref(rb_ident, CSTR2SYM("email")))) {
618
+ Check_Type(rb_val, T_STRING);
619
+ email = StringValueCStr(rb_val);
620
+ }
621
+ }
622
+
623
+ rugged_exception_check(
624
+ git_repository_set_ident(repo, name, email)
625
+ );
626
+
627
+ return Qnil;
628
+ }
629
+
630
+ /*
631
+ * call-seq:
632
+ * repo.ident -> ident
633
+ *
634
+ * Return a Hash containing the identity that is used to write reflogs.
635
+ *
636
+ * +ident+ is a Hash containing +name+ and/or +email+ entries, or `nil`.
637
+ */
638
+ static VALUE rb_git_repo_get_ident(VALUE self)
639
+ {
640
+ VALUE rb_ident = rb_hash_new();
641
+
642
+ git_repository *repo;
643
+ const char *name = NULL, *email = NULL;
644
+
645
+ Data_Get_Struct(self, git_repository, repo);
646
+
647
+ rugged_exception_check(
648
+ git_repository_ident(&name, &email, repo)
649
+ );
650
+
651
+ if (name) {
652
+ rb_hash_aset(rb_ident, CSTR2SYM("name"), rb_str_new_utf8(name));
653
+ }
654
+
655
+ if (email) {
656
+ rb_hash_aset(rb_ident, CSTR2SYM("email"), rb_str_new_utf8(email));
657
+ }
658
+
659
+ return rb_ident;
660
+ }
661
+
596
662
  /*
597
663
  * call-seq:
598
664
  * repo.merge_base(oid1, oid2, ...)
@@ -2240,7 +2306,7 @@ static VALUE rb_git_repo_attributes(int argc, VALUE *argv, VALUE self)
2240
2306
  VALUE rb_result;
2241
2307
  const char **values;
2242
2308
  const char **names;
2243
- int i, num_attr = RARRAY_LEN(rb_names);
2309
+ long i, num_attr = RARRAY_LEN(rb_names);
2244
2310
 
2245
2311
  if (num_attr > 32)
2246
2312
  rb_raise(rb_eRuntimeError, "Too many attributes requested");
@@ -2386,6 +2452,9 @@ void Init_rugged_repo(void)
2386
2452
  rb_define_method(rb_cRuggedRepo, "config", rb_git_repo_get_config, 0);
2387
2453
  rb_define_method(rb_cRuggedRepo, "config=", rb_git_repo_set_config, 1);
2388
2454
 
2455
+ rb_define_method(rb_cRuggedRepo, "ident", rb_git_repo_get_ident, 0);
2456
+ rb_define_method(rb_cRuggedRepo, "ident=", rb_git_repo_set_ident, 1);
2457
+
2389
2458
  rb_define_method(rb_cRuggedRepo, "bare?", rb_git_repo_is_bare, 0);
2390
2459
  rb_define_method(rb_cRuggedRepo, "shallow?", rb_git_repo_is_shallow, 0);
2391
2460
  rb_define_method(rb_cRuggedRepo, "empty?", rb_git_repo_is_empty, 0);
@@ -164,13 +164,18 @@ static VALUE submodule_status_flags_to_rb(unsigned int flags)
164
164
  */
165
165
  static VALUE rb_git_submodule_status(VALUE self)
166
166
  {
167
+ VALUE rb_repo = rugged_owner(self);
167
168
  git_submodule *submodule;
169
+ git_repository *repo;
168
170
  unsigned int flags;
169
171
 
172
+ rugged_check_repo(rb_repo);
173
+ Data_Get_Struct(rb_repo, git_repository, repo);
170
174
  Data_Get_Struct(self, git_submodule, submodule);
171
175
 
172
176
  rugged_exception_check(
173
- git_submodule_status(&flags, submodule)
177
+ git_submodule_status(&flags, repo, git_submodule_name(submodule),
178
+ GIT_SUBMODULE_IGNORE_UNSPECIFIED)
174
179
  );
175
180
 
176
181
  return submodule_status_flags_to_rb(flags);
@@ -231,11 +236,16 @@ static VALUE rb_git_submodule_status_in_workdir(VALUE self)
231
236
  }
232
237
 
233
238
  #define RB_GIT_SUBMODULE_STATUS_FLAG_CHECK(flag) \
239
+ VALUE rb_repo = rugged_owner(self); \
240
+ git_repository *repo; \
234
241
  git_submodule *submodule; \
235
242
  unsigned int flags; \
243
+ rugged_check_repo(rb_repo); \
244
+ Data_Get_Struct(rb_repo, git_repository, repo); \
236
245
  Data_Get_Struct(self, git_submodule, submodule); \
237
246
  rugged_exception_check( \
238
- git_submodule_status(&flags, submodule) \
247
+ git_submodule_status(&flags, repo, git_submodule_name(submodule), \
248
+ GIT_SUBMODULE_IGNORE_UNSPECIFIED) \
239
249
  ); \
240
250
  return (flags & flag) ? Qtrue : Qfalse; \
241
251
 
@@ -350,11 +360,16 @@ static VALUE rb_git_submodule_status_untracked_files_in_workdir(VALUE self)
350
360
  }
351
361
 
352
362
  #define RB_GIT_SUBMODULE_STATUS_CHECK(check) \
363
+ VALUE rb_repo = rugged_owner(self); \
364
+ git_repository *repo; \
353
365
  git_submodule *submodule; \
354
366
  unsigned int flags; \
367
+ rugged_check_repo(rb_repo); \
368
+ Data_Get_Struct(rb_repo, git_repository, repo); \
355
369
  Data_Get_Struct(self, git_submodule, submodule); \
356
370
  rugged_exception_check( \
357
- git_submodule_status(&flags, submodule) \
371
+ git_submodule_status(&flags, repo, git_submodule_name(submodule), \
372
+ GIT_SUBMODULE_IGNORE_UNSPECIFIED) \
358
373
  ); \
359
374
  return check(flags) ? Qtrue : Qfalse; \
360
375
 
@@ -442,27 +457,6 @@ static VALUE rb_git_submodule_reload(VALUE self)
442
457
  return self;
443
458
  }
444
459
 
445
- /*
446
- * call-seq:
447
- * submodule.save -> submodule
448
- *
449
- * Write submodule settings to +.gitmodules+ file.
450
- *
451
- * This commits any in-memory changes to the submodule to the +.gitmodules+
452
- * file on disk.
453
- */
454
- static VALUE rb_git_submodule_save(VALUE self)
455
- {
456
- git_submodule *submodule;
457
- Data_Get_Struct(self, git_submodule, submodule);
458
-
459
- rugged_exception_check(
460
- git_submodule_save(submodule)
461
- );
462
-
463
- return self;
464
- }
465
-
466
460
  /*
467
461
  * call-seq:
468
462
  * submodule.sync -> submodule
@@ -563,33 +557,6 @@ static VALUE rb_git_submodule_url(VALUE self)
563
557
  return url ? rb_str_new_utf8(url) : Qnil;
564
558
  }
565
559
 
566
- /*
567
- * call-seq:
568
- * submodule.url = url -> url
569
- *
570
- * Set the URL in memory for the submodule.
571
- *
572
- * This will be used for any following submodule actions while this submodule
573
- * data is in memory.
574
- *
575
- * After calling this, #save can be called to write the changes back to
576
- * the +.gitmodules+ file and #sync to write the changes to the checked out
577
- * submodule repository.
578
- */
579
- static VALUE rb_git_submodule_set_url(VALUE self, VALUE rb_url)
580
- {
581
- git_submodule *submodule;
582
-
583
- Check_Type(rb_url, T_STRING);
584
-
585
- Data_Get_Struct(self, git_submodule, submodule);
586
-
587
- rugged_exception_check(
588
- git_submodule_set_url(submodule, StringValueCStr(rb_url))
589
- );
590
- return rb_url;
591
- }
592
-
593
560
  /*
594
561
  * call-seq:
595
562
  * submodule.path -> string
@@ -680,28 +647,6 @@ static VALUE rb_git_submodule_fetch_recurse_submodules(VALUE self)
680
647
  return git_submodule_fetch_recurse_submodules(submodule) ? Qtrue : Qfalse;
681
648
  }
682
649
 
683
- /*
684
- * call-seq:
685
- * submodule.fetch_recurse_submodules= bool -> bool
686
- *
687
- * Set the +fetchRecurseSubmodules+ rule in memory for a submodule.
688
- *
689
- * This sets the <tt>submodule.<name>.fetchRecurseSubmodules</tt> value for
690
- * the submodule. #save can be called to persist the new value.
691
- */
692
- static VALUE rb_git_submodule_set_fetch_recurse_submodules(VALUE self, VALUE rb_fetch_recursive)
693
- {
694
- git_submodule *submodule;
695
- Data_Get_Struct(self, git_submodule, submodule);
696
-
697
- git_submodule_set_fetch_recurse_submodules(
698
- submodule,
699
- rugged_parse_bool(rb_fetch_recursive)
700
- );
701
-
702
- return rb_fetch_recursive;
703
- }
704
-
705
650
  static VALUE rb_git_subm_ignore_rule_fromC(git_submodule_ignore_t rule)
706
651
  {
707
652
  switch(rule) {
@@ -754,72 +699,6 @@ static VALUE rb_git_submodule_ignore_rule(VALUE self)
754
699
  return rb_git_subm_ignore_rule_fromC(ignore);
755
700
  }
756
701
 
757
- static git_submodule_ignore_t rb_git_subm_ignore_rule_toC(VALUE rb_ignore_rule)
758
- {
759
- ID id_ignore_rule;
760
-
761
- Check_Type(rb_ignore_rule, T_SYMBOL);
762
- id_ignore_rule = SYM2ID(rb_ignore_rule);
763
-
764
- if (id_ignore_rule == id_ignore_none) {
765
- return GIT_SUBMODULE_IGNORE_NONE;
766
- } else if (id_ignore_rule == id_ignore_untracked) {
767
- return GIT_SUBMODULE_IGNORE_UNTRACKED;
768
- } else if (id_ignore_rule == id_ignore_dirty) {
769
- return GIT_SUBMODULE_IGNORE_DIRTY;
770
- } else if (id_ignore_rule == id_ignore_all) {
771
- return GIT_SUBMODULE_IGNORE_ALL;
772
- } else {
773
- rb_raise(rb_eArgError, "Invalid submodule ignore rule type.");
774
- }
775
- }
776
-
777
- /*
778
- * call-seq:
779
- * submodule.ignore_rule = rule -> rule
780
- *
781
- * Set the ignore_rule to +rule+ in memory for a submodule.
782
- * See #ignore for a list of accepted rules.
783
- *
784
- * This will be used for any following actions (such as
785
- * #status) while the submodule is in memory. The ignore
786
- * rule can be persisted to the config with #save.
787
- *
788
- * Calling #reset_ignore_rule or #reload will
789
- * revert the rule to the value that was in the config.
790
- */
791
- static VALUE rb_git_submodule_set_ignore_rule(VALUE self, VALUE rb_ignore_rule)
792
- {
793
- git_submodule *submodule;
794
-
795
- Data_Get_Struct(self, git_submodule, submodule);
796
-
797
- git_submodule_set_ignore(
798
- submodule,
799
- rb_git_subm_ignore_rule_toC(rb_ignore_rule)
800
- );
801
-
802
- return rb_ignore_rule;
803
- }
804
-
805
- /*
806
- * call-seq:
807
- * submodule.reset_ignore_rule -> submodule
808
- *
809
- * Revert the ignore rule set by #ignore_rule= to the value that
810
- * was in the config.
811
- */
812
- static VALUE rb_git_submodule_reset_ignore_rule(VALUE self)
813
- {
814
- git_submodule *submodule;
815
-
816
- Data_Get_Struct(self, git_submodule, submodule);
817
-
818
- git_submodule_set_ignore(submodule, GIT_SUBMODULE_IGNORE_RESET);
819
-
820
- return self;
821
- }
822
-
823
702
  static VALUE rb_git_subm_update_rule_fromC(git_submodule_update_t rule)
824
703
  {
825
704
  switch(rule) {
@@ -867,68 +746,6 @@ static VALUE rb_git_submodule_update_rule(VALUE self)
867
746
  return rb_git_subm_update_rule_fromC(update);
868
747
  }
869
748
 
870
- static git_submodule_update_t rb_git_subm_update_rule_toC(VALUE rb_update_rule)
871
- {
872
- ID id_update_rule;
873
-
874
- Check_Type(rb_update_rule, T_SYMBOL);
875
- id_update_rule = SYM2ID(rb_update_rule);
876
-
877
- if (id_update_rule == id_update_checkout) {
878
- return GIT_SUBMODULE_UPDATE_CHECKOUT;
879
- } else if (id_update_rule == id_update_rebase) {
880
- return GIT_SUBMODULE_UPDATE_REBASE;
881
- } else if (id_update_rule == id_update_merge) {
882
- return GIT_SUBMODULE_UPDATE_MERGE;
883
- } else if (id_update_rule == id_update_none) {
884
- return GIT_SUBMODULE_UPDATE_NONE;
885
- } else {
886
- rb_raise(rb_eArgError, "Invalid submodule update rule type.");
887
- }
888
- }
889
-
890
- /*
891
- * call-seq:
892
- * submodule.update_rule = rule -> rule
893
- *
894
- * Set the update_rule to +rule+ in memory for a submodule.
895
- * See #update_rule for a list of accepted rules.
896
- *
897
- * Calling #reset_update_rule or #reload will
898
- * revert the +rule+ to the value that was in the config.
899
- */
900
- static VALUE rb_git_submodule_set_update_rule(VALUE self, VALUE rb_update_rule)
901
- {
902
- git_submodule *submodule;
903
-
904
- Data_Get_Struct(self, git_submodule, submodule);
905
-
906
- git_submodule_set_update(
907
- submodule,
908
- rb_git_subm_update_rule_toC(rb_update_rule)
909
- );
910
-
911
- return rb_update_rule;
912
- }
913
-
914
- /*
915
- * call-seq:
916
- * submodule.reset_update_rule -> submodule
917
- *
918
- * Revert the update rule set by #update_rule= to the value that
919
- * was in the config.
920
- */
921
- static VALUE rb_git_submodule_reset_update_rule(VALUE self)
922
- {
923
- git_submodule *submodule;
924
-
925
- Data_Get_Struct(self, git_submodule, submodule);
926
-
927
- git_submodule_set_update(submodule, GIT_SUBMODULE_UPDATE_RESET);
928
-
929
- return self;
930
- }
931
-
932
749
  /*
933
750
  * call-seq:
934
751
  * submodule.repository -> repository
@@ -997,17 +814,11 @@ void Init_rugged_submodule(void)
997
814
 
998
815
  rb_define_method(rb_cRuggedSubmodule, "name", rb_git_submodule_name, 0);
999
816
  rb_define_method(rb_cRuggedSubmodule, "url", rb_git_submodule_url, 0);
1000
- rb_define_method(rb_cRuggedSubmodule, "url=", rb_git_submodule_set_url, 1);
1001
817
  rb_define_method(rb_cRuggedSubmodule, "path", rb_git_submodule_path, 0);
1002
818
  rb_define_method(rb_cRuggedSubmodule, "fetch_recurse_submodules?", rb_git_submodule_fetch_recurse_submodules, 0);
1003
- rb_define_method(rb_cRuggedSubmodule, "fetch_recurse_submodules=", rb_git_submodule_set_fetch_recurse_submodules, 1);
1004
819
 
1005
820
  rb_define_method(rb_cRuggedSubmodule, "ignore_rule", rb_git_submodule_ignore_rule, 0);
1006
- rb_define_method(rb_cRuggedSubmodule, "ignore_rule=", rb_git_submodule_set_ignore_rule, 1);
1007
- rb_define_method(rb_cRuggedSubmodule, "reset_ignore_rule", rb_git_submodule_reset_ignore_rule, 0);
1008
821
  rb_define_method(rb_cRuggedSubmodule, "update_rule", rb_git_submodule_update_rule, 0);
1009
- rb_define_method(rb_cRuggedSubmodule, "update_rule=", rb_git_submodule_set_update_rule, 1);
1010
- rb_define_method(rb_cRuggedSubmodule, "reset_update_rule", rb_git_submodule_reset_update_rule, 0);
1011
822
 
1012
823
  rb_define_method(rb_cRuggedSubmodule, "head_oid", rb_git_submodule_head_id, 0);
1013
824
  rb_define_method(rb_cRuggedSubmodule, "index_oid", rb_git_submodule_index_id, 0);
@@ -1036,7 +847,6 @@ void Init_rugged_submodule(void)
1036
847
 
1037
848
  rb_define_method(rb_cRuggedSubmodule, "add_to_index", rb_git_submodule_add_to_index, -1);
1038
849
  rb_define_method(rb_cRuggedSubmodule, "reload", rb_git_submodule_reload, 0);
1039
- rb_define_method(rb_cRuggedSubmodule, "save", rb_git_submodule_save, 0);
1040
850
  rb_define_method(rb_cRuggedSubmodule, "sync", rb_git_submodule_sync, 0);
1041
851
  rb_define_method(rb_cRuggedSubmodule, "init", rb_git_submodule_init, -1);
1042
852
  }
@@ -224,6 +224,151 @@ static VALUE rb_git_submodule_setup_add(int argc, VALUE *argv, VALUE self)
224
224
  return rugged_submodule_new(rb_repo, submodule);
225
225
  }
226
226
 
227
+ static git_submodule_ignore_t rb_git_subm_ignore_rule_toC(VALUE rb_ignore_rule)
228
+ {
229
+ ID id_ignore_rule;
230
+
231
+ Check_Type(rb_ignore_rule, T_SYMBOL);
232
+ id_ignore_rule = SYM2ID(rb_ignore_rule);
233
+
234
+ if (id_ignore_rule == rb_intern("none")) {
235
+ return GIT_SUBMODULE_IGNORE_NONE;
236
+ } else if (id_ignore_rule == rb_intern("untracked")) {
237
+ return GIT_SUBMODULE_IGNORE_UNTRACKED;
238
+ } else if (id_ignore_rule == rb_intern("dirty")) {
239
+ return GIT_SUBMODULE_IGNORE_DIRTY;
240
+ } else if (id_ignore_rule == rb_intern("all")) {
241
+ return GIT_SUBMODULE_IGNORE_ALL;
242
+ } else {
243
+ rb_raise(rb_eArgError, "Invalid submodule ignore rule type.");
244
+ }
245
+ }
246
+
247
+ static git_submodule_update_t rb_git_subm_update_rule_toC(VALUE rb_update_rule)
248
+ {
249
+ ID id_update_rule;
250
+
251
+ Check_Type(rb_update_rule, T_SYMBOL);
252
+ id_update_rule = SYM2ID(rb_update_rule);
253
+
254
+ if (id_update_rule == rb_intern("checkout")) {
255
+ return GIT_SUBMODULE_UPDATE_CHECKOUT;
256
+ } else if (id_update_rule == rb_intern("rebase")) {
257
+ return GIT_SUBMODULE_UPDATE_REBASE;
258
+ } else if (id_update_rule == rb_intern("merge")) {
259
+ return GIT_SUBMODULE_UPDATE_MERGE;
260
+ } else if (id_update_rule == rb_intern("none")) {
261
+ return GIT_SUBMODULE_UPDATE_NONE;
262
+ } else {
263
+ rb_raise(rb_eArgError, "Invalid submodule update rule type.");
264
+ }
265
+ }
266
+
267
+ /*
268
+ * call-seq:
269
+ * submodules.update(submodule, settings) -> nil
270
+ * submodules.update(name, settings) -> nil
271
+ *
272
+ * Update settings for the given submodule in the submodule config.
273
+ *
274
+ * Existing `Rugged::Submodule` instances are not updated, but can be
275
+ * reloaded by calling `#reload`.
276
+ *
277
+ * The following options can be passed in the +settings+ Hash:
278
+ *
279
+ * :url ::
280
+ * Updates the URL for the submodule.
281
+ *
282
+ * :ignore_rule ::
283
+ * See `Rugged::Submodule#ignore_rule` for a list of accepted rules.
284
+ *
285
+ * :update_rule ::
286
+ * See `Rugged::Submodule#update_rule` for a list of accepted rules.
287
+ *
288
+ * :fetch_recurse_submodules ::
289
+ * Updates the +fetchRecurseSubmodules+ rule.
290
+ */
291
+ static VALUE rb_git_submodule_update(VALUE self, VALUE rb_name_or_submodule, VALUE rb_settings)
292
+ {
293
+ git_repository *repo;
294
+ git_submodule_ignore_t ignore_rule;
295
+ git_submodule_update_t update_rule;
296
+ const char *submodule_name;
297
+ int fetch_recurse_submodules;
298
+ VALUE rb_repo = rugged_owner(self);
299
+ VALUE rb_url, rb_fetch_recurse_submodules, rb_ignore_rule, rb_update_rule;
300
+
301
+ rugged_check_repo(rb_repo);
302
+ Data_Get_Struct(rb_repo, git_repository, repo);
303
+
304
+ if (rb_obj_is_kind_of(rb_name_or_submodule, rb_cRuggedSubmodule))
305
+ rb_name_or_submodule = rb_funcall(rb_name_or_submodule, rb_intern("name"), 0);
306
+
307
+ if (TYPE(rb_name_or_submodule) != T_STRING)
308
+ rb_raise(rb_eTypeError, "Expecting a String or Rugged::Submodule instance");
309
+
310
+ rb_url = rb_hash_aref(rb_settings, CSTR2SYM("url"));
311
+ rb_fetch_recurse_submodules = rb_hash_aref(rb_settings, CSTR2SYM("fetch_recurse_submodules"));
312
+ rb_ignore_rule = rb_hash_aref(rb_settings, CSTR2SYM("ignore_rule"));
313
+ rb_update_rule = rb_hash_aref(rb_settings, CSTR2SYM("update_rule"));
314
+
315
+ if (!NIL_P(rb_url)) {
316
+ Check_Type(rb_url, T_STRING);
317
+ }
318
+
319
+ if (!NIL_P(rb_fetch_recurse_submodules)) {
320
+ fetch_recurse_submodules = rugged_parse_bool(rb_fetch_recurse_submodules);
321
+ }
322
+
323
+ if (!NIL_P(rb_ignore_rule)) {
324
+ ignore_rule = rb_git_subm_ignore_rule_toC(rb_ignore_rule);
325
+ }
326
+
327
+ if (!NIL_P(rb_update_rule)) {
328
+ update_rule = rb_git_subm_update_rule_toC(rb_update_rule);
329
+ }
330
+
331
+ submodule_name = StringValueCStr(rb_name_or_submodule);
332
+
333
+ if (!NIL_P(rb_url)) {
334
+ rugged_exception_check(
335
+ git_submodule_set_url(repo,
336
+ submodule_name,
337
+ StringValueCStr(rb_url)
338
+ )
339
+ );
340
+ }
341
+
342
+ if (!NIL_P(rb_fetch_recurse_submodules)) {
343
+ rugged_exception_check(
344
+ git_submodule_set_fetch_recurse_submodules(repo,
345
+ submodule_name,
346
+ fetch_recurse_submodules
347
+ )
348
+ );
349
+ }
350
+
351
+ if (!NIL_P(rb_ignore_rule)) {
352
+ rugged_exception_check(
353
+ git_submodule_set_ignore(repo,
354
+ submodule_name,
355
+ ignore_rule
356
+ )
357
+ );
358
+ }
359
+
360
+ if (!NIL_P(rb_update_rule)) {
361
+ rugged_exception_check(
362
+ git_submodule_set_update(repo,
363
+ submodule_name,
364
+ update_rule
365
+ )
366
+ );
367
+ }
368
+
369
+ return Qnil;
370
+ }
371
+
227
372
  void Init_rugged_submodule_collection(void)
228
373
  {
229
374
  rb_cRuggedSubmoduleCollection = rb_define_class_under(rb_mRugged, "SubmoduleCollection", rb_cObject);
@@ -232,5 +377,8 @@ void Init_rugged_submodule_collection(void)
232
377
  rb_define_method(rb_cRuggedSubmoduleCollection, "initialize", rb_git_submodule_collection_initialize, 1);
233
378
  rb_define_method(rb_cRuggedSubmoduleCollection, "[]", rb_git_submodule_collection_aref, 1);
234
379
  rb_define_method(rb_cRuggedSubmoduleCollection, "each", rb_git_submodule_collection_each, 0);
380
+
381
+ rb_define_method(rb_cRuggedSubmoduleCollection, "update", rb_git_submodule_update, 2);
382
+
235
383
  rb_define_method(rb_cRuggedSubmoduleCollection, "setup_add", rb_git_submodule_setup_add, -1);
236
384
  }