rugged 1.9.0 → 1.9.4

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 (108) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/extconf.rb +4 -4
  3. data/ext/rugged/rugged.c +12 -1
  4. data/ext/rugged/rugged_blame.c +22 -6
  5. data/ext/rugged/rugged_blob.c +24 -9
  6. data/ext/rugged/rugged_branch.c +10 -7
  7. data/ext/rugged/rugged_branch_collection.c +8 -6
  8. data/ext/rugged/rugged_commit.c +7 -6
  9. data/ext/rugged/rugged_config.c +20 -11
  10. data/ext/rugged/rugged_diff.c +26 -12
  11. data/ext/rugged/rugged_diff_hunk.c +2 -1
  12. data/ext/rugged/rugged_index.c +39 -29
  13. data/ext/rugged/rugged_note.c +7 -6
  14. data/ext/rugged/rugged_object.c +3 -2
  15. data/ext/rugged/rugged_patch.c +23 -9
  16. data/ext/rugged/rugged_rebase.c +22 -10
  17. data/ext/rugged/rugged_reference.c +22 -13
  18. data/ext/rugged/rugged_reference_collection.c +9 -7
  19. data/ext/rugged/rugged_remote.c +23 -12
  20. data/ext/rugged/rugged_remote_collection.c +11 -9
  21. data/ext/rugged/rugged_repo.c +60 -45
  22. data/ext/rugged/rugged_revwalk.c +22 -12
  23. data/ext/rugged/rugged_submodule.c +23 -20
  24. data/ext/rugged/rugged_submodule_collection.c +20 -9
  25. data/ext/rugged/rugged_tag.c +6 -4
  26. data/ext/rugged/rugged_tag_collection.c +7 -5
  27. data/ext/rugged/rugged_tree.c +27 -15
  28. data/lib/rugged/version.rb +1 -1
  29. data/vendor/libgit2/AUTHORS +2 -0
  30. data/vendor/libgit2/CMakeLists.txt +1 -1
  31. data/vendor/libgit2/cmake/DefaultCFlags.cmake +4 -1
  32. data/vendor/libgit2/cmake/SelectSSH.cmake +9 -3
  33. data/vendor/libgit2/deps/pcre/CMakeLists.txt +2 -3
  34. data/vendor/libgit2/deps/xdiff/CMakeLists.txt +1 -1
  35. data/vendor/libgit2/deps/xdiff/xmerge.c +14 -10
  36. data/vendor/libgit2/include/git2/deprecated.h +1 -1
  37. data/vendor/libgit2/include/git2/index.h +1 -1
  38. data/vendor/libgit2/include/git2/merge.h +4 -2
  39. data/vendor/libgit2/include/git2/oid.h +0 -1
  40. data/vendor/libgit2/include/git2/proxy.h +2 -3
  41. data/vendor/libgit2/include/git2/remote.h +19 -7
  42. data/vendor/libgit2/include/git2/stdint.h +1 -1
  43. data/vendor/libgit2/include/git2/sys/transport.h +1 -1
  44. data/vendor/libgit2/include/git2/version.h +4 -2
  45. data/vendor/libgit2/src/cli/CMakeLists.txt +1 -2
  46. data/vendor/libgit2/src/cli/opt.c +3 -3
  47. data/vendor/libgit2/src/cli/opt_usage.c +1 -1
  48. data/vendor/libgit2/src/libgit2/CMakeLists.txt +32 -16
  49. data/vendor/libgit2/src/libgit2/attr_file.c +10 -3
  50. data/vendor/libgit2/src/libgit2/clone.c +6 -0
  51. data/vendor/libgit2/src/libgit2/commit.c +1 -1
  52. data/vendor/libgit2/src/libgit2/commit_graph.c +1 -2
  53. data/vendor/libgit2/src/libgit2/config.c +1 -1
  54. data/vendor/libgit2/src/libgit2/config_file.c +2 -1
  55. data/vendor/libgit2/src/libgit2/config_mem.c +1 -0
  56. data/vendor/libgit2/src/libgit2/config_parse.c +2 -1
  57. data/vendor/libgit2/src/libgit2/delta.c +5 -1
  58. data/vendor/libgit2/src/libgit2/diff_driver.c +1 -1
  59. data/vendor/libgit2/src/libgit2/diff_stats.c +19 -12
  60. data/vendor/libgit2/src/libgit2/fetchhead.c +1 -1
  61. data/vendor/libgit2/src/libgit2/index.c +8 -8
  62. data/vendor/libgit2/src/libgit2/index.h +3 -0
  63. data/vendor/libgit2/src/libgit2/indexer.c +2 -2
  64. data/vendor/libgit2/src/libgit2/merge.c +1 -1
  65. data/vendor/libgit2/src/libgit2/merge.h +4 -0
  66. data/vendor/libgit2/src/libgit2/merge_file.c +43 -30
  67. data/vendor/libgit2/src/libgit2/message.c +1 -1
  68. data/vendor/libgit2/src/libgit2/midx.c +2 -3
  69. data/vendor/libgit2/src/libgit2/odb.c +2 -6
  70. data/vendor/libgit2/src/libgit2/odb_loose.c +24 -14
  71. data/vendor/libgit2/src/libgit2/oid.c +4 -5
  72. data/vendor/libgit2/src/libgit2/pack-objects.c +2 -4
  73. data/vendor/libgit2/src/libgit2/pack.c +3 -0
  74. data/vendor/libgit2/src/libgit2/refs.c +15 -6
  75. data/vendor/libgit2/src/libgit2/remote.c +4 -1
  76. data/vendor/libgit2/src/libgit2/remote.h +0 -1
  77. data/vendor/libgit2/src/libgit2/repository.c +5 -4
  78. data/vendor/libgit2/src/libgit2/streams/socket.c +30 -0
  79. data/vendor/libgit2/src/libgit2/submodule.c +12 -5
  80. data/vendor/libgit2/src/libgit2/tag.c +3 -1
  81. data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +2 -0
  82. data/vendor/libgit2/src/libgit2/transports/credential.c +1 -1
  83. data/vendor/libgit2/src/libgit2/transports/git.c +1 -1
  84. data/vendor/libgit2/src/libgit2/transports/httpclient.c +12 -9
  85. data/vendor/libgit2/src/libgit2/transports/local.c +8 -1
  86. data/vendor/libgit2/src/libgit2/transports/smart.c +5 -5
  87. data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +3 -3
  88. data/vendor/libgit2/src/libgit2/transports/ssh_exec.c +57 -18
  89. data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.c +3 -3
  90. data/vendor/libgit2/src/util/CMakeLists.txt +3 -4
  91. data/vendor/libgit2/src/util/fs_path.c +66 -6
  92. data/vendor/libgit2/src/util/fs_path.h +6 -0
  93. data/vendor/libgit2/src/util/futils.h +11 -3
  94. data/vendor/libgit2/src/util/hash/builtin.c +14 -4
  95. data/vendor/libgit2/src/util/hash/openssl.c +0 -4
  96. data/vendor/libgit2/src/util/hash/rfc6234/sha224-256.c +8 -6
  97. data/vendor/libgit2/src/util/hashmap.h +1 -0
  98. data/vendor/libgit2/src/util/net.c +5 -5
  99. data/vendor/libgit2/src/util/process.h +2 -1
  100. data/vendor/libgit2/src/util/runtime.c +2 -2
  101. data/vendor/libgit2/src/util/str.c +18 -6
  102. data/vendor/libgit2/src/util/str.h +5 -3
  103. data/vendor/libgit2/src/util/unix/process.c +92 -15
  104. data/vendor/libgit2/src/util/util.c +16 -3
  105. data/vendor/libgit2/src/util/util.h +1 -0
  106. data/vendor/libgit2/src/util/win32/path_w32.c +81 -5
  107. data/vendor/libgit2/src/util/win32/process.c +22 -6
  108. metadata +17 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35b9bacf8b8490fe35d015f3a47ba27bfa63105f4e6657c2fdb77f99181e378b
4
- data.tar.gz: 5d229542f5c4f156bd0b4c5add9730314e7a003c923d712d415731efe85d9a49
3
+ metadata.gz: ac3cbe7a9ea4030190d35d29db06a489ec5b6e6622e5a12fbf03c14a990baa2d
4
+ data.tar.gz: 6bfbf05eca385efc69ddc30f7bd892f302be1d0cd63e2ed09e007db478f7350e
5
5
  SHA512:
6
- metadata.gz: 3af4216e9c917c87757c9c387a01a10d2173e00a3f9b834eb8a429c252fafc32a0a211f905ea74168bb8c46e6c95434b1eaa50c41feba3388ddfd7446ac9e162
7
- data.tar.gz: 61c7da1b73112564d53e78a61de842de5d12a93515317d52e0b22c95f5e9312ca2aef3443eeb0e482dcf4208a86b60f9f831cf525948b49031ac7af28f6b2557
6
+ metadata.gz: 983ba1468a4066f98fbb0111037aa94ed23a3ff70c73f8b3e2c3e0a1229aa181f06f84bfeacb2f7ef16b3ede1433154f8729e024f1facc98ac1e99e1945aa62a
7
+ data.tar.gz: 70a96d4099de21a1e61e19a78ecb015d13e22d5b794145dcad485c555574c839052ffe015f818d62caf73a435d1d284c3649982a91c8c8d585ac07d496f89d71
@@ -71,12 +71,12 @@ if arg_config("--use-system-libraries", !!ENV['RUGGED_USE_SYSTEM_LIBRARIES'])
71
71
  major = minor = nil
72
72
 
73
73
  File.readlines(File.join(LIBGIT2_DIR, "include", "git2", "version.h")).each do |line|
74
- if !major && (matches = line.match(/^#define LIBGIT2_VER_MAJOR\s+([0-9]+)$/))
74
+ if !major && (matches = line.match(/^#define LIBGIT2_VERSION_MAJOR\s+([0-9]+)$/))
75
75
  major = matches[1]
76
76
  next
77
77
  end
78
78
 
79
- if !minor && (matches = line.match(/^#define LIBGIT2_VER_MINOR\s+([0-9]+)$/))
79
+ if !minor && (matches = line.match(/^#define LIBGIT2_VERSION_MINOR\s+([0-9]+)$/))
80
80
  minor = matches[1]
81
81
  next
82
82
  end
@@ -85,9 +85,9 @@ if arg_config("--use-system-libraries", !!ENV['RUGGED_USE_SYSTEM_LIBRARIES'])
85
85
  end
86
86
 
87
87
  try_compile(<<-SRC) or abort "libgit2 version is not compatible, expected ~> #{major}.#{minor}.0"
88
- #include <git2/version.h>
88
+ #include <git2.h>
89
89
 
90
- #if LIBGIT2_VER_MAJOR != #{major} || LIBGIT2_VER_MINOR != #{minor}
90
+ #if LIBGIT2_VERSION_MAJOR != #{major} || LIBGIT2_VERSION_MINOR != #{minor}
91
91
  #error libgit2 version is not compatible
92
92
  #endif
93
93
  SRC
data/ext/rugged/rugged.c CHANGED
@@ -336,6 +336,16 @@ static void cleanup_cb(void *unused)
336
336
  git_libgit2_shutdown();
337
337
  }
338
338
 
339
+ static const rb_data_type_t rugged_shutdown_hook_type = {
340
+ .wrap_struct_name = "Rugged::ShutdownHook",
341
+ .function = {
342
+ .dmark = NULL,
343
+ .dfree = cleanup_cb,
344
+ .dsize = NULL,
345
+ },
346
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
347
+ };
348
+
339
349
  void rugged_exception_raise(void)
340
350
  {
341
351
  VALUE err_klass, err_obj;
@@ -678,6 +688,7 @@ void Init_rugged(void)
678
688
 
679
689
  /* Hook a global object to cleanup the library
680
690
  * on shutdown */
681
- rb_mShutdownHook = Data_Wrap_Struct(rb_cObject, NULL, &cleanup_cb, NULL);
691
+ /* Non-NULL data so the GC actually invokes cleanup_cb on shutdown. */
692
+ rb_mShutdownHook = TypedData_Wrap_Struct(rb_cObject, &rugged_shutdown_hook_type, (void *)1);
682
693
  rb_global_variable(&rb_mShutdownHook);
683
694
  }
@@ -10,6 +10,8 @@
10
10
  extern VALUE rb_mRugged;
11
11
  VALUE rb_cRuggedBlame;
12
12
 
13
+ extern const rb_data_type_t rugged_repository_type;
14
+
13
15
  static VALUE rb_git_blame_hunk_fromC(const git_blame_hunk *hunk)
14
16
  {
15
17
  VALUE rb_hunk;
@@ -82,6 +84,20 @@ static void rugged_parse_blame_options(git_blame_options *opts, git_repository *
82
84
  }
83
85
  }
84
86
 
87
+ static void rb_git_blame__free(void *data)
88
+ {
89
+ git_blame *blame = (git_blame *) data;
90
+ git_blame_free(blame);
91
+ }
92
+
93
+ const rb_data_type_t rugged_blame_type = {
94
+ .wrap_struct_name = "Rugged::Blame",
95
+ .function = {
96
+ .dfree = rb_git_blame__free,
97
+ },
98
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
99
+ };
100
+
85
101
  /*
86
102
  * call-seq:
87
103
  * Blame.new(repo, path, options = {}) -> blame
@@ -135,7 +151,7 @@ static VALUE rb_git_blame_new(int argc, VALUE *argv, VALUE klass)
135
151
  rb_scan_args(argc, argv, "20:", &rb_repo, &rb_path, &rb_options);
136
152
 
137
153
  rugged_check_repo(rb_repo);
138
- Data_Get_Struct(rb_repo, git_repository, repo);
154
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
139
155
 
140
156
  Check_Type(rb_path, T_STRING);
141
157
 
@@ -145,7 +161,7 @@ static VALUE rb_git_blame_new(int argc, VALUE *argv, VALUE klass)
145
161
  &blame, repo, StringValueCStr(rb_path), &opts
146
162
  ));
147
163
 
148
- return Data_Wrap_Struct(klass, NULL, &git_blame_free, blame);
164
+ return TypedData_Wrap_Struct(klass, &rugged_blame_type, blame);
149
165
  }
150
166
 
151
167
  /*
@@ -160,7 +176,7 @@ static VALUE rb_git_blame_for_line(VALUE self, VALUE rb_line_no)
160
176
  git_blame *blame;
161
177
  int line_no;
162
178
 
163
- Data_Get_Struct(self, git_blame, blame);
179
+ TypedData_Get_Struct(self, git_blame, &rugged_blame_type, blame);
164
180
  Check_Type(rb_line_no, T_FIXNUM);
165
181
 
166
182
  line_no = NUM2INT(rb_line_no);
@@ -184,7 +200,7 @@ static VALUE rb_git_blame_for_line(VALUE self, VALUE rb_line_no)
184
200
  static VALUE rb_git_blame_count(VALUE self)
185
201
  {
186
202
  git_blame *blame;
187
- Data_Get_Struct(self, git_blame, blame);
203
+ TypedData_Get_Struct(self, git_blame, &rugged_blame_type, blame);
188
204
  return UINT2NUM(git_blame_get_hunk_count(blame));
189
205
  }
190
206
 
@@ -210,7 +226,7 @@ static VALUE rb_git_blame_get_by_index(VALUE self, VALUE rb_index)
210
226
  int index;
211
227
  uint32_t blame_count;
212
228
 
213
- Data_Get_Struct(self, git_blame, blame);
229
+ TypedData_Get_Struct(self, git_blame, &rugged_blame_type, blame);
214
230
  Check_Type(rb_index, T_FIXNUM);
215
231
 
216
232
  index = NUM2INT(rb_index);
@@ -249,7 +265,7 @@ static VALUE rb_git_blame_each(VALUE self)
249
265
 
250
266
  RETURN_SIZED_ENUMERATOR(self, 0, 0, rugged_blame_enum_size);
251
267
 
252
- Data_Get_Struct(self, git_blame, blame);
268
+ TypedData_Get_Struct(self, git_blame, &rugged_blame_type, blame);
253
269
 
254
270
  blame_count = git_blame_get_hunk_count(blame);
255
271
  for (i = 0; i < blame_count; ++i) {
@@ -18,6 +18,7 @@ VALUE rb_cRuggedBlob;
18
18
  VALUE rb_cRuggedBlobSig;
19
19
 
20
20
  extern const rb_data_type_t rugged_object_type;
21
+ extern const rb_data_type_t rugged_repository_type;
21
22
 
22
23
  /*
23
24
  * call-seq:
@@ -143,7 +144,7 @@ static VALUE rb_git_blob_from_buffer(VALUE self, VALUE rb_repo, VALUE rb_buffer)
143
144
  Check_Type(rb_buffer, T_STRING);
144
145
  rugged_check_repo(rb_repo);
145
146
 
146
- Data_Get_Struct(rb_repo, git_repository, repo);
147
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
147
148
 
148
149
  error = git_blob_create_frombuffer(&oid, repo, RSTRING_PTR(rb_buffer), RSTRING_LEN(rb_buffer));
149
150
  rugged_exception_check(error);
@@ -170,7 +171,7 @@ static VALUE rb_git_blob_from_workdir(VALUE self, VALUE rb_repo, VALUE rb_path)
170
171
  FilePathValue(rb_path);
171
172
  rugged_check_repo(rb_repo);
172
173
 
173
- Data_Get_Struct(rb_repo, git_repository, repo);
174
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
174
175
 
175
176
  error = git_blob_create_fromworkdir(&oid, repo, StringValueCStr(rb_path));
176
177
  rugged_exception_check(error);
@@ -198,7 +199,7 @@ static VALUE rb_git_blob_from_disk(VALUE self, VALUE rb_repo, VALUE rb_path)
198
199
  FilePathValue(rb_path);
199
200
  rugged_check_repo(rb_repo);
200
201
 
201
- Data_Get_Struct(rb_repo, git_repository, repo);
202
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
202
203
 
203
204
  error = git_blob_create_fromdisk(&oid, repo, StringValueCStr(rb_path));
204
205
  rugged_exception_check(error);
@@ -253,7 +254,7 @@ static VALUE rb_git_blob_from_io(int argc, VALUE *argv, VALUE klass)
253
254
  rb_scan_args(argc, argv, "21", &rb_repo, &rb_io, &rb_hint_path);
254
255
 
255
256
  rugged_check_repo(rb_repo);
256
- Data_Get_Struct(rb_repo, git_repository, repo);
257
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
257
258
 
258
259
  if (!NIL_P(rb_hint_path)) {
259
260
  FilePathValue(rb_hint_path);
@@ -507,7 +508,7 @@ static VALUE rb_git_blob_to_buffer(int argc, VALUE *argv, VALUE self)
507
508
  rb_scan_args(argc, argv, "21", &rb_repo, &rb_sha1, &rb_max_bytes);
508
509
 
509
510
  rugged_check_repo(rb_repo);
510
- Data_Get_Struct(rb_repo, git_repository, repo);
511
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
511
512
 
512
513
  blob = (git_blob *)rugged_object_get(repo, rb_sha1, GIT_OBJ_BLOB);
513
514
 
@@ -607,7 +608,7 @@ static VALUE rb_git_blob_merge_files(int argc, VALUE *argv, VALUE klass)
607
608
 
608
609
  if (!NIL_P(rb_repo)) {
609
610
  rugged_check_repo(rb_repo);
610
- Data_Get_Struct(rb_repo, git_repository, repo);
611
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
611
612
  }
612
613
 
613
614
  if (!NIL_P(rb_options))
@@ -638,6 +639,20 @@ done:
638
639
  return rb_result;
639
640
  }
640
641
 
642
+ static void rb_git_hashsig__free(void *data)
643
+ {
644
+ git_hashsig *sig = (git_hashsig *) data;
645
+ git_hashsig_free(sig);
646
+ }
647
+
648
+ const rb_data_type_t rugged_hashsig_type = {
649
+ .wrap_struct_name = "Rugged::Blob::HashSignature",
650
+ .function = {
651
+ .dfree = rb_git_hashsig__free,
652
+ },
653
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
654
+ };
655
+
641
656
  static VALUE rb_git_blob_sig_new(int argc, VALUE *argv, VALUE klass)
642
657
  {
643
658
  int error, opts = 0;
@@ -664,7 +679,7 @@ static VALUE rb_git_blob_sig_new(int argc, VALUE *argv, VALUE klass)
664
679
 
665
680
  rugged_exception_check(error);
666
681
 
667
- return Data_Wrap_Struct(klass, NULL, &git_hashsig_free, sig);
682
+ return TypedData_Wrap_Struct(klass, &rugged_hashsig_type, sig);
668
683
  }
669
684
 
670
685
  static VALUE rb_git_blob_sig_compare(VALUE self, VALUE rb_sig_a, VALUE rb_sig_b)
@@ -678,8 +693,8 @@ static VALUE rb_git_blob_sig_compare(VALUE self, VALUE rb_sig_a, VALUE rb_sig_b)
678
693
  rb_raise(rb_eTypeError, "Expected Rugged::Blob::HashSignature");
679
694
  }
680
695
 
681
- Data_Get_Struct(rb_sig_a, git_hashsig, sig_a);
682
- Data_Get_Struct(rb_sig_b, git_hashsig, sig_b);
696
+ TypedData_Get_Struct(rb_sig_a, git_hashsig, &rugged_hashsig_type, sig_a);
697
+ TypedData_Get_Struct(rb_sig_b, git_hashsig, &rugged_hashsig_type, sig_b);
683
698
 
684
699
  result = git_hashsig_compare(sig_a, sig_b);
685
700
 
@@ -13,6 +13,9 @@ extern VALUE rb_cRuggedObject;
13
13
  extern VALUE rb_cRuggedReference;
14
14
  VALUE rb_cRuggedBranch;
15
15
 
16
+ extern const rb_data_type_t rugged_reference_type;
17
+ extern const rb_data_type_t rugged_repository_type;
18
+
16
19
  static inline VALUE rugged_branch_new(VALUE owner, git_reference *ref)
17
20
  {
18
21
  return rugged_ref_new(rb_cRuggedBranch, owner, ref);
@@ -27,7 +30,7 @@ static inline VALUE rugged_branch_new(VALUE owner, git_reference *ref)
27
30
  static VALUE rb_git_branch_head_p(VALUE self)
28
31
  {
29
32
  git_reference *branch;
30
- Data_Get_Struct(self, git_reference, branch);
33
+ TypedData_Get_Struct(self, git_reference, &rugged_reference_type, branch);
31
34
  return git_branch_is_head(branch) ? Qtrue : Qfalse;
32
35
  }
33
36
 
@@ -44,7 +47,7 @@ static VALUE rb_git_branch_name(VALUE self)
44
47
  {
45
48
  git_reference *branch;
46
49
  const char *branch_name;
47
- Data_Get_Struct(self, git_reference, branch);
50
+ TypedData_Get_Struct(self, git_reference, &rugged_reference_type, branch);
48
51
 
49
52
  rugged_exception_check(git_branch_name(&branch_name, branch));
50
53
 
@@ -58,7 +61,7 @@ static VALUE rb_git_branch__remote_name(VALUE rb_repo, const char *canonical_nam
58
61
  int error;
59
62
  VALUE result = Qnil;
60
63
 
61
- Data_Get_Struct(rb_repo, git_repository, repo);
64
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
62
65
 
63
66
  if ((error = git_branch_remote_name(&remote_name, repo, canonical_name)) == GIT_OK)
64
67
  result = rb_enc_str_new(remote_name.ptr, remote_name.size, rb_utf8_encoding());
@@ -86,7 +89,7 @@ static VALUE rb_git_branch_remote_name(VALUE self)
86
89
  git_reference *branch, *remote_ref;
87
90
  int error = 0;
88
91
 
89
- Data_Get_Struct(self, git_reference, branch);
92
+ TypedData_Get_Struct(self, git_reference, &rugged_reference_type, branch);
90
93
 
91
94
  if (git_reference_is_remote(branch)) {
92
95
  remote_ref = branch;
@@ -116,7 +119,7 @@ static VALUE rb_git_branch_upstream(VALUE self)
116
119
  git_reference *branch, *upstream_branch;
117
120
  int error;
118
121
 
119
- Data_Get_Struct(self, git_reference, branch);
122
+ TypedData_Get_Struct(self, git_reference, &rugged_reference_type, branch);
120
123
 
121
124
  if (git_reference_is_remote(branch))
122
125
  return Qnil;
@@ -145,12 +148,12 @@ static VALUE rb_git_branch_set_upstream(VALUE self, VALUE rb_branch)
145
148
  git_reference *branch, *target_branch;
146
149
  const char *target_branch_name;
147
150
 
148
- Data_Get_Struct(self, git_reference, branch);
151
+ TypedData_Get_Struct(self, git_reference, &rugged_reference_type, branch);
149
152
  if (!NIL_P(rb_branch)) {
150
153
  if (!rb_obj_is_kind_of(rb_branch, rb_cRuggedReference))
151
154
  rb_raise(rb_eTypeError, "Expecting a Rugged::Reference instance");
152
155
 
153
- Data_Get_Struct(rb_branch, git_reference, target_branch);
156
+ TypedData_Get_Struct(rb_branch, git_reference, &rugged_reference_type, target_branch);
154
157
 
155
158
  rugged_exception_check(
156
159
  git_branch_name(&target_branch_name, target_branch)
@@ -13,6 +13,8 @@ extern VALUE rb_cRuggedBranch;
13
13
 
14
14
  VALUE rb_cRuggedBranchCollection;
15
15
 
16
+ extern const rb_data_type_t rugged_repository_type;
17
+
16
18
  static inline VALUE rugged_branch_new(VALUE owner, git_reference *ref)
17
19
  {
18
20
  return rugged_ref_new(rb_cRuggedBranch, owner, ref);
@@ -119,7 +121,7 @@ static VALUE rb_git_branch_collection_create(int argc, VALUE *argv, VALUE self)
119
121
  rb_scan_args(argc, argv, "20:", &rb_name, &rb_target, &rb_options);
120
122
 
121
123
  rugged_check_repo(rb_repo);
122
- Data_Get_Struct(rb_repo, git_repository, repo);
124
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
123
125
 
124
126
  Check_Type(rb_name, T_STRING);
125
127
  Check_Type(rb_target, T_STRING);
@@ -164,7 +166,7 @@ static VALUE rb_git_branch_collection_aref(VALUE self, VALUE rb_name) {
164
166
  int error;
165
167
 
166
168
  rugged_check_repo(rb_repo);
167
- Data_Get_Struct(rb_repo, git_repository, repo);
169
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
168
170
 
169
171
  Check_Type(rb_name, T_STRING);
170
172
 
@@ -193,7 +195,7 @@ static VALUE each_branch(int argc, VALUE *argv, VALUE self, int branch_names_onl
193
195
  if (!NIL_P(rb_filter))
194
196
  filter = parse_branch_type(rb_filter);
195
197
 
196
- Data_Get_Struct(rb_repo, git_repository, repo);
198
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
197
199
 
198
200
  error = git_branch_iterator_new(&iter, repo, filter);
199
201
  rugged_exception_check(error);
@@ -273,7 +275,7 @@ static VALUE rb_git_branch_collection_delete(VALUE self, VALUE rb_name_or_branch
273
275
  int error;
274
276
 
275
277
  rugged_check_repo(rb_repo);
276
- Data_Get_Struct(rb_repo, git_repository, repo);
278
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
277
279
 
278
280
  error = rugged_branch_lookup(&branch, repo, rb_name_or_branch);
279
281
  rugged_exception_check(error);
@@ -320,7 +322,7 @@ static VALUE rb_git_branch_collection_move(int argc, VALUE *argv, VALUE self)
320
322
  Check_Type(rb_new_branch_name, T_STRING);
321
323
 
322
324
  rugged_check_repo(rb_repo);
323
- Data_Get_Struct(rb_repo, git_repository, repo);
325
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
324
326
 
325
327
  error = rugged_branch_lookup(&old_branch, repo, rb_name_or_branch);
326
328
  rugged_exception_check(error);
@@ -353,7 +355,7 @@ static VALUE rb_git_branch_collection_exist_p(VALUE self, VALUE rb_name)
353
355
  int error;
354
356
 
355
357
  Check_Type(rb_name, T_STRING);
356
- Data_Get_Struct(rb_repo, git_repository, repo);
358
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
357
359
 
358
360
  error = rugged_branch_lookup(&branch, repo, rb_name);
359
361
  git_reference_free(branch);
@@ -16,6 +16,7 @@ extern VALUE rb_cRuggedSignature;
16
16
  VALUE rb_cRuggedCommit;
17
17
 
18
18
  extern const rb_data_type_t rugged_object_type;
19
+ extern const rb_data_type_t rugged_repository_type;
19
20
 
20
21
  /*
21
22
  * call-seq:
@@ -357,7 +358,7 @@ static VALUE rb_git_commit_amend(VALUE self, VALUE rb_data)
357
358
  TypedData_Get_Struct(self, git_commit, &rugged_object_type, commit_to_amend);
358
359
 
359
360
  owner = rugged_owner(self);
360
- Data_Get_Struct(owner, git_repository, repo);
361
+ TypedData_Get_Struct(owner, git_repository, &rugged_repository_type, repo);
361
362
 
362
363
  rb_ref = rb_hash_aref(rb_data, CSTR2SYM("update_ref"));
363
364
  if (!NIL_P(rb_ref)) {
@@ -549,7 +550,7 @@ static VALUE rb_git_commit_create(VALUE self, VALUE rb_repo, VALUE rb_data)
549
550
  Check_Type(rb_data, T_HASH);
550
551
 
551
552
  rugged_check_repo(rb_repo);
552
- Data_Get_Struct(rb_repo, git_repository, repo);
553
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
553
554
 
554
555
  if ((error = parse_commit_options(&commit_data, repo, rb_data)) < 0)
555
556
  goto cleanup;
@@ -614,7 +615,7 @@ static VALUE rb_git_commit_to_mbox(int argc, VALUE *argv, VALUE self)
614
615
  rb_scan_args(argc, argv, ":", &rb_options);
615
616
 
616
617
  rugged_check_repo(rb_repo);
617
- Data_Get_Struct(rb_repo, git_repository, repo);
618
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
618
619
 
619
620
  TypedData_Get_Struct(self, git_commit, &rugged_object_type, commit);
620
621
 
@@ -735,7 +736,7 @@ static VALUE rb_git_commit_extract_signature(int argc, VALUE *argv, VALUE self)
735
736
  rb_scan_args(argc, argv, "21", &rb_repo, &rb_commit, &rb_field);
736
737
 
737
738
  rugged_check_repo(rb_repo);
738
- Data_Get_Struct(rb_repo, git_repository, repo);
739
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
739
740
 
740
741
  error = git_oid_fromstr(&commit_id, StringValueCStr(rb_commit));
741
742
  rugged_exception_check(error);
@@ -799,7 +800,7 @@ static VALUE rb_git_commit_create_to_s(VALUE self, VALUE rb_repo, VALUE rb_data)
799
800
  Check_Type(rb_data, T_HASH);
800
801
 
801
802
  rugged_check_repo(rb_repo);
802
- Data_Get_Struct(rb_repo, git_repository, repo);
803
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
803
804
 
804
805
  if ((error = parse_commit_options(&commit_data, repo, rb_data)) < 0)
805
806
  goto cleanup;
@@ -850,7 +851,7 @@ static VALUE rb_git_commit_create_with_signature(int argc, VALUE *argv, VALUE se
850
851
  rb_scan_args(argc, argv, "31", &rb_repo, &rb_content, &rb_signature, &rb_field);
851
852
 
852
853
  rugged_check_repo(rb_repo);
853
- Data_Get_Struct(rb_repo, git_repository, repo);
854
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
854
855
 
855
856
  Check_Type(rb_content, T_STRING);
856
857
  Check_Type(rb_signature, T_STRING);
@@ -10,14 +10,23 @@
10
10
  extern VALUE rb_mRugged;
11
11
  VALUE rb_cRuggedConfig;
12
12
 
13
- void rb_git_config__free(git_config *config)
13
+ void rb_git_config__free(void *data)
14
14
  {
15
+ git_config *config = (git_config *) data;
15
16
  git_config_free(config);
16
17
  }
17
18
 
19
+ const rb_data_type_t rugged_config_type = {
20
+ .wrap_struct_name = "Rugged::config",
21
+ .function = {
22
+ .dfree = rb_git_config__free,
23
+ },
24
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
25
+ };
26
+
18
27
  VALUE rugged_config_new(VALUE klass, VALUE owner, git_config *cfg)
19
28
  {
20
- VALUE rb_config = Data_Wrap_Struct(klass, NULL, &rb_git_config__free, cfg);
29
+ VALUE rb_config = TypedData_Wrap_Struct(klass, &rugged_config_type, cfg);
21
30
  rugged_set_owner(rb_config, owner);
22
31
  return rb_config;
23
32
  }
@@ -80,7 +89,7 @@ static VALUE rb_git_config_get(VALUE self, VALUE rb_key)
80
89
  int error;
81
90
  VALUE rb_result;
82
91
 
83
- Data_Get_Struct(self, git_config, config);
92
+ TypedData_Get_Struct(self, git_config, &rugged_config_type, config);
84
93
  Check_Type(rb_key, T_STRING);
85
94
 
86
95
  error = git_config_get_string_buf(&buf, config, StringValueCStr(rb_key));
@@ -115,7 +124,7 @@ static VALUE rb_git_config_store(VALUE self, VALUE rb_key, VALUE rb_val)
115
124
  const char *key;
116
125
  int error;
117
126
 
118
- Data_Get_Struct(self, git_config, config);
127
+ TypedData_Get_Struct(self, git_config, &rugged_config_type, config);
119
128
  Check_Type(rb_key, T_STRING);
120
129
 
121
130
  key = StringValueCStr(rb_key);
@@ -158,7 +167,7 @@ static VALUE rb_git_config_delete(VALUE self, VALUE rb_key)
158
167
  git_config *config;
159
168
  int error;
160
169
 
161
- Data_Get_Struct(self, git_config, config);
170
+ TypedData_Get_Struct(self, git_config, &rugged_config_type, config);
162
171
  Check_Type(rb_key, T_STRING);
163
172
 
164
173
  error = git_config_delete_entry(config, StringValueCStr(rb_key));
@@ -220,7 +229,7 @@ static VALUE rb_git_config_each_key(VALUE self)
220
229
  int error, exception;
221
230
 
222
231
  RETURN_ENUMERATOR(self, 0, 0);
223
- Data_Get_Struct(self, git_config, config);
232
+ TypedData_Get_Struct(self, git_config, &rugged_config_type, config);
224
233
 
225
234
  error = git_config_foreach(config, &cb_config__each_key, &exception);
226
235
  if (error == GIT_EUSER)
@@ -250,7 +259,7 @@ static VALUE rb_git_config_each_pair(VALUE self)
250
259
  int error, exception;
251
260
 
252
261
  RETURN_ENUMERATOR(self, 0, 0);
253
- Data_Get_Struct(self, git_config, config);
262
+ TypedData_Get_Struct(self, git_config, &rugged_config_type, config);
254
263
 
255
264
  error = git_config_foreach(config, &cb_config__each_pair, &exception);
256
265
  if (error == GIT_EUSER)
@@ -276,7 +285,7 @@ static VALUE rb_git_config_to_hash(VALUE self)
276
285
  int error;
277
286
  VALUE hash;
278
287
 
279
- Data_Get_Struct(self, git_config, config);
288
+ TypedData_Get_Struct(self, git_config, &rugged_config_type, config);
280
289
  hash = rb_hash_new();
281
290
 
282
291
  error = git_config_foreach(config, &cb_config__to_hash, (void *)hash);
@@ -317,7 +326,7 @@ static VALUE rb_git_config_snapshot(VALUE self)
317
326
  {
318
327
  git_config *config, *snapshot;
319
328
 
320
- Data_Get_Struct(self, git_config, config);
329
+ TypedData_Get_Struct(self, git_config, &rugged_config_type, config);
321
330
 
322
331
  rugged_exception_check(
323
332
  git_config_snapshot(&snapshot, config)
@@ -348,7 +357,7 @@ static VALUE rb_git_config_transaction(VALUE self)
348
357
  VALUE rb_result;
349
358
  int error = 0, exception = 0;
350
359
 
351
- Data_Get_Struct(self, git_config, config);
360
+ TypedData_Get_Struct(self, git_config, &rugged_config_type, config);
352
361
 
353
362
  git_config_lock(&tx, config);
354
363
 
@@ -392,7 +401,7 @@ static VALUE rb_git_config_get_all(VALUE self, VALUE key)
392
401
  VALUE list;
393
402
  int error;
394
403
 
395
- Data_Get_Struct(self, git_config, config);
404
+ TypedData_Get_Struct(self, git_config, &rugged_config_type, config);
396
405
 
397
406
  list = rb_ary_new();
398
407
  error = git_config_get_multivar_foreach(
@@ -10,9 +10,23 @@
10
10
  extern VALUE rb_mRugged;
11
11
  VALUE rb_cRuggedDiff;
12
12
 
13
+ static void rb_git_diff__free(void *data)
14
+ {
15
+ git_diff *diff = (git_diff *) data;
16
+ git_diff_free(diff);
17
+ }
18
+
19
+ const rb_data_type_t rugged_diff_type = {
20
+ .wrap_struct_name = "Rugged::Diff",
21
+ .function = {
22
+ .dfree = rb_git_diff__free,
23
+ },
24
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
25
+ };
26
+
13
27
  VALUE rugged_diff_new(VALUE klass, VALUE owner, git_diff *diff)
14
28
  {
15
- VALUE rb_diff = Data_Wrap_Struct(klass, NULL, git_diff_free, diff);
29
+ VALUE rb_diff = TypedData_Wrap_Struct(klass, &rugged_diff_type, diff);
16
30
  rugged_set_owner(rb_diff, owner);
17
31
  return rb_diff;
18
32
  }
@@ -212,7 +226,7 @@ static VALUE rb_git_diff_patch(int argc, VALUE *argv, VALUE self)
212
226
 
213
227
  rb_scan_args(argc, argv, "00:", &rb_opts);
214
228
 
215
- Data_Get_Struct(self, git_diff, diff);
229
+ TypedData_Get_Struct(self, git_diff, &rugged_diff_type, diff);
216
230
 
217
231
  if (!NIL_P(rb_opts)) {
218
232
  if (rb_hash_aref(rb_opts, CSTR2SYM("compact")) == Qtrue)
@@ -256,7 +270,7 @@ static VALUE rb_git_diff_write_patch(int argc, VALUE *argv, VALUE self)
256
270
  if (!rb_respond_to(rb_io, rb_intern("write")))
257
271
  rb_raise(rb_eArgError, "Expected io to respond to \"write\"");
258
272
 
259
- Data_Get_Struct(self, git_diff, diff);
273
+ TypedData_Get_Struct(self, git_diff, &rugged_diff_type, diff);
260
274
 
261
275
  if (!NIL_P(rb_opts)) {
262
276
  if (rb_hash_aref(rb_opts, CSTR2SYM("compact")) == Qtrue)
@@ -285,8 +299,8 @@ static VALUE rb_git_diff_merge(VALUE self, VALUE rb_other)
285
299
  if (!rb_obj_is_kind_of(rb_other, rb_cRuggedDiff))
286
300
  rb_raise(rb_eTypeError, "A Rugged::Diff instance is required");
287
301
 
288
- Data_Get_Struct(self, git_diff, diff);
289
- Data_Get_Struct(rb_other, git_diff, other);
302
+ TypedData_Get_Struct(self, git_diff, &rugged_diff_type, diff);
303
+ TypedData_Get_Struct(rb_other, git_diff, &rugged_diff_type, other);
290
304
 
291
305
  error = git_diff_merge(diff, other);
292
306
  rugged_exception_check(error);
@@ -358,7 +372,7 @@ static VALUE rb_git_diff_find_similar(int argc, VALUE *argv, VALUE self)
358
372
  VALUE rb_options;
359
373
  int error;
360
374
 
361
- Data_Get_Struct(self, git_diff, diff);
375
+ TypedData_Get_Struct(self, git_diff, &rugged_diff_type, diff);
362
376
 
363
377
  rb_scan_args(argc, argv, "00:", &rb_options);
364
378
 
@@ -448,7 +462,7 @@ static VALUE rb_git_diff_each_patch(VALUE self)
448
462
  size_t d, delta_count;
449
463
 
450
464
  RETURN_ENUMERATOR(self, 0, 0);
451
- Data_Get_Struct(self, git_diff, diff);
465
+ TypedData_Get_Struct(self, git_diff, &rugged_diff_type, diff);
452
466
 
453
467
  delta_count = git_diff_num_deltas(diff);
454
468
  for (d = 0; d < delta_count; ++d) {
@@ -481,7 +495,7 @@ static VALUE rb_git_diff_each_delta(VALUE self)
481
495
  size_t d, delta_count;
482
496
 
483
497
  RETURN_ENUMERATOR(self, 0, 0);
484
- Data_Get_Struct(self, git_diff, diff);
498
+ TypedData_Get_Struct(self, git_diff, &rugged_diff_type, diff);
485
499
 
486
500
  delta_count = git_diff_num_deltas(diff);
487
501
  for (d = 0; d < delta_count; ++d) {
@@ -516,7 +530,7 @@ static VALUE rb_git_diff_each_line(int argc, VALUE *argv, VALUE self)
516
530
  int exception = 0, error;
517
531
 
518
532
  RETURN_ENUMERATOR(self, argc, argv);
519
- Data_Get_Struct(self, git_diff, diff);
533
+ TypedData_Get_Struct(self, git_diff, &rugged_diff_type, diff);
520
534
 
521
535
  if (rb_scan_args(argc, argv, "01", &rb_format) == 1) {
522
536
  Check_Type(rb_format, T_SYMBOL);
@@ -557,7 +571,7 @@ static VALUE rb_git_diff_size(VALUE self)
557
571
  {
558
572
  git_diff *diff;
559
573
 
560
- Data_Get_Struct(self, git_diff, diff);
574
+ TypedData_Get_Struct(self, git_diff, &rugged_diff_type, diff);
561
575
 
562
576
  return INT2FIX(git_diff_num_deltas(diff));
563
577
  }
@@ -616,7 +630,7 @@ static VALUE rb_git_diff_stat(VALUE self)
616
630
  git_diff *diff;
617
631
  struct diff_stats stats = { 0, 0, 0 };
618
632
 
619
- Data_Get_Struct(self, git_diff, diff);
633
+ TypedData_Get_Struct(self, git_diff, &rugged_diff_type, diff);
620
634
 
621
635
  git_diff_foreach(
622
636
  diff, diff_file_stats_cb, NULL, NULL, diff_line_stats_cb, &stats);
@@ -633,7 +647,7 @@ static VALUE rb_git_diff_stat(VALUE self)
633
647
  static VALUE rb_git_diff_sorted_icase_p(VALUE self)
634
648
  {
635
649
  git_diff *diff;
636
- Data_Get_Struct(self, git_diff, diff);
650
+ TypedData_Get_Struct(self, git_diff, &rugged_diff_type, diff);
637
651
  return git_diff_is_sorted_icase(diff) ? Qtrue : Qfalse;
638
652
  }
639
653
 
@@ -10,6 +10,7 @@
10
10
  extern VALUE rb_cRuggedDiff;
11
11
  VALUE rb_cRuggedDiffHunk;
12
12
 
13
+ extern const rb_data_type_t rugged_patch_type;
13
14
 
14
15
  VALUE rugged_diff_hunk_new(VALUE owner, size_t hunk_idx, const git_diff_hunk *hunk, size_t lines_in_hunk)
15
16
  {
@@ -44,7 +45,7 @@ static VALUE rb_git_diff_hunk_each_line(VALUE self)
44
45
 
45
46
  RETURN_ENUMERATOR(self, 0, 0);
46
47
 
47
- Data_Get_Struct(rugged_owner(self), git_patch, patch);
48
+ TypedData_Get_Struct(rugged_owner(self), git_patch, &rugged_patch_type, patch);
48
49
 
49
50
  lines_count = FIX2INT(rb_iv_get(self, "@line_count"));
50
51
  hunk_idx = FIX2INT(rb_iv_get(self, "@hunk_index"));