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
@@ -13,6 +13,8 @@ extern VALUE rb_cRuggedReference;
13
13
 
14
14
  VALUE rb_cRuggedReferenceCollection;
15
15
 
16
+ extern const rb_data_type_t rugged_repository_type;
17
+
16
18
  /*
17
19
  * call-seq:
18
20
  * ReferenceCollection.new(repo) -> refs
@@ -56,7 +58,7 @@ static VALUE rb_git_reference_collection_create(int argc, VALUE *argv, VALUE sel
56
58
  rb_scan_args(argc, argv, "20:", &rb_name, &rb_target, &rb_options);
57
59
 
58
60
  rugged_check_repo(rb_repo);
59
- Data_Get_Struct(rb_repo, git_repository, repo);
61
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
60
62
  Check_Type(rb_name, T_STRING);
61
63
  Check_Type(rb_target, T_STRING);
62
64
 
@@ -95,7 +97,7 @@ static VALUE rb_git_reference_collection_aref(VALUE self, VALUE rb_name) {
95
97
  git_reference *ref;
96
98
  int error;
97
99
 
98
- Data_Get_Struct(rb_repo, git_repository, repo);
100
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
99
101
 
100
102
  error = git_reference_lookup(&ref, repo, StringValueCStr(rb_name));
101
103
 
@@ -119,7 +121,7 @@ static VALUE rb_git_reference_collection__each(int argc, VALUE *argv, VALUE self
119
121
 
120
122
  rugged_check_repo(rb_repo);
121
123
 
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
  if (!NIL_P(rb_glob)) {
125
127
  Check_Type(rb_glob, T_STRING);
@@ -210,7 +212,7 @@ static VALUE rb_git_reference_collection_exist_p(VALUE self, VALUE rb_name_or_re
210
212
  if (TYPE(rb_name_or_ref) != T_STRING)
211
213
  rb_raise(rb_eTypeError, "Expecting a String or Rugged::Reference instance");
212
214
 
213
- Data_Get_Struct(rb_repo, git_repository, repo);
215
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
214
216
 
215
217
  error = git_reference_lookup(&ref, repo, StringValueCStr(rb_name_or_ref));
216
218
  git_reference_free(ref);
@@ -265,7 +267,7 @@ static VALUE rb_git_reference_collection_rename(int argc, VALUE *argv, VALUE sel
265
267
  rb_raise(rb_eTypeError, "Expecting a String or Rugged::Reference instance");
266
268
 
267
269
  rugged_check_repo(rb_repo);
268
- Data_Get_Struct(rb_repo, git_repository, repo);
270
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
269
271
 
270
272
  if (!NIL_P(rb_options)) {
271
273
  VALUE rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
@@ -337,7 +339,7 @@ static VALUE rb_git_reference_collection_update(int argc, VALUE *argv, VALUE sel
337
339
  }
338
340
 
339
341
  rugged_check_repo(rb_repo);
340
- Data_Get_Struct(rb_repo, git_repository, repo);
342
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
341
343
 
342
344
  error = git_reference_lookup(&ref, repo, StringValueCStr(rb_name_or_ref));
343
345
  rugged_exception_check(error);
@@ -388,7 +390,7 @@ static VALUE rb_git_reference_collection_delete(VALUE self, VALUE rb_name_or_ref
388
390
  rb_raise(rb_eTypeError, "Expecting a String or Rugged::Reference instance");
389
391
 
390
392
  rugged_check_repo(rb_repo);
391
- Data_Get_Struct(rb_repo, git_repository, repo);
393
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
392
394
 
393
395
  error = git_reference_lookup(&ref, repo, StringValueCStr(rb_name_or_ref));
394
396
  rugged_exception_check(error);
@@ -12,6 +12,8 @@ extern VALUE rb_cRuggedRepo;
12
12
  extern VALUE rb_eRuggedError;
13
13
  VALUE rb_cRuggedRemote;
14
14
 
15
+ extern const rb_data_type_t rugged_repository_type;
16
+
15
17
  static int progress_cb(const char *str, int len, void *data)
16
18
  {
17
19
  struct rugged_remote_cb_payload *payload = data;
@@ -243,16 +245,25 @@ static int parse_prune_type(VALUE rb_prune_type)
243
245
  }
244
246
  }
245
247
 
246
- static void rb_git_remote__free(git_remote *remote)
248
+ static void rb_git_remote__free(void *data)
247
249
  {
250
+ git_remote *remote = (git_remote *) data;
248
251
  git_remote_free(remote);
249
252
  }
250
253
 
254
+ const rb_data_type_t rugged_remote_type = {
255
+ .wrap_struct_name = "Rugged::Remote",
256
+ .function = {
257
+ .dfree = rb_git_remote__free,
258
+ },
259
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
260
+ };
261
+
251
262
  VALUE rugged_remote_new(VALUE owner, git_remote *remote)
252
263
  {
253
264
  VALUE rb_remote;
254
265
 
255
- rb_remote = Data_Wrap_Struct(rb_cRuggedRemote, NULL, &rb_git_remote__free, remote);
266
+ rb_remote = TypedData_Wrap_Struct(rb_cRuggedRemote, &rugged_remote_type, remote);
256
267
  rugged_set_owner(rb_remote, owner);
257
268
  return rb_remote;
258
269
  }
@@ -326,7 +337,7 @@ static VALUE rb_git_remote_ls(int argc, VALUE *argv, VALUE self)
326
337
  size_t heads_len, i;
327
338
 
328
339
  RETURN_ENUMERATOR(self, argc, argv);
329
- Data_Get_Struct(self, git_remote, remote);
340
+ TypedData_Get_Struct(self, git_remote, &rugged_remote_type, remote);
330
341
  rb_scan_args(argc, argv, ":", &rb_options);
331
342
 
332
343
  rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
@@ -365,7 +376,7 @@ static VALUE rb_git_remote_name(VALUE self)
365
376
  {
366
377
  git_remote *remote;
367
378
  const char * name;
368
- Data_Get_Struct(self, git_remote, remote);
379
+ TypedData_Get_Struct(self, git_remote, &rugged_remote_type, remote);
369
380
 
370
381
  name = git_remote_name(remote);
371
382
 
@@ -383,7 +394,7 @@ static VALUE rb_git_remote_name(VALUE self)
383
394
  static VALUE rb_git_remote_url(VALUE self)
384
395
  {
385
396
  git_remote *remote;
386
- Data_Get_Struct(self, git_remote, remote);
397
+ TypedData_Get_Struct(self, git_remote, &rugged_remote_type, remote);
387
398
 
388
399
  return rb_str_new_utf8(git_remote_url(remote));
389
400
  }
@@ -402,7 +413,7 @@ static VALUE rb_git_remote_push_url(VALUE self)
402
413
  git_remote *remote;
403
414
  const char * push_url;
404
415
 
405
- Data_Get_Struct(self, git_remote, remote);
416
+ TypedData_Get_Struct(self, git_remote, &rugged_remote_type, remote);
406
417
 
407
418
  push_url = git_remote_pushurl(remote);
408
419
  return push_url ? rb_str_new_utf8(push_url) : Qnil;
@@ -424,10 +435,10 @@ static VALUE rb_git_remote_set_push_url(VALUE self, VALUE rb_url)
424
435
  git_repository *repo;
425
436
 
426
437
  rugged_check_repo(rb_repo);
427
- Data_Get_Struct(rb_repo, git_repository, repo);
438
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
428
439
 
429
440
  Check_Type(rb_url, T_STRING);
430
- Data_Get_Struct(self, git_remote, remote);
441
+ TypedData_Get_Struct(self, git_remote, &rugged_remote_type, remote);
431
442
 
432
443
  rugged_exception_check(
433
444
  git_remote_set_pushurl(repo, git_remote_name(remote), StringValueCStr(rb_url))
@@ -443,7 +454,7 @@ static VALUE rb_git_remote_refspecs(VALUE self, git_direction direction)
443
454
  git_strarray refspecs;
444
455
  VALUE rb_refspec_array;
445
456
 
446
- Data_Get_Struct(self, git_remote, remote);
457
+ TypedData_Get_Struct(self, git_remote, &rugged_remote_type, remote);
447
458
 
448
459
  if (direction == GIT_DIRECTION_FETCH)
449
460
  error = git_remote_get_fetch_refspecs(&refspecs, remote);
@@ -522,7 +533,7 @@ static VALUE rb_git_remote_check_connection(int argc, VALUE *argv, VALUE self)
522
533
  ID id_direction;
523
534
  int error, direction;
524
535
 
525
- Data_Get_Struct(self, git_remote, remote);
536
+ TypedData_Get_Struct(self, git_remote, &rugged_remote_type, remote);
526
537
  rb_scan_args(argc, argv, "01:", &rb_direction, &rb_options);
527
538
 
528
539
  Check_Type(rb_direction, T_SYMBOL);
@@ -625,7 +636,7 @@ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
625
636
 
626
637
  rugged_rb_ary_to_strarray(rb_refspecs, &refspecs);
627
638
 
628
- Data_Get_Struct(self, git_remote, remote);
639
+ TypedData_Get_Struct(self, git_remote, &rugged_remote_type, remote);
629
640
 
630
641
  rugged_remote_init_callbacks_and_payload_from_options(rb_options, &opts.callbacks, &payload);
631
642
  rugged_remote_init_custom_headers(rb_options, &opts.custom_headers);
@@ -720,7 +731,7 @@ static VALUE rb_git_remote_push(int argc, VALUE *argv, VALUE self)
720
731
 
721
732
  rugged_rb_ary_to_strarray(rb_refspecs, &refspecs);
722
733
 
723
- Data_Get_Struct(self, git_remote, remote);
734
+ TypedData_Get_Struct(self, git_remote, &rugged_remote_type, remote);
724
735
 
725
736
  rugged_remote_init_callbacks_and_payload_from_options(rb_options, &opts.callbacks, &payload);
726
737
  rugged_remote_init_custom_headers(rb_options, &opts.custom_headers);
@@ -13,6 +13,8 @@ extern VALUE rb_eRuggedError;
13
13
  extern VALUE rb_cRuggedRemote;
14
14
  VALUE rb_cRuggedRemoteCollection;
15
15
 
16
+ extern const rb_data_type_t rugged_repository_type;
17
+
16
18
  /*
17
19
  * call-seq:
18
20
  * RemoteCollection.new(repo) -> remotes
@@ -45,7 +47,7 @@ static VALUE rb_git_remote_collection_create_anonymous(VALUE self, VALUE rb_url)
45
47
  VALUE rb_repo = rugged_owner(self);
46
48
 
47
49
  rugged_check_repo(rb_repo);
48
- Data_Get_Struct(rb_repo, git_repository, repo);
50
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
49
51
 
50
52
  Check_Type(rb_url, T_STRING);
51
53
 
@@ -80,7 +82,7 @@ static VALUE rb_git_remote_collection_create(VALUE self, VALUE rb_name, VALUE rb
80
82
  VALUE rb_repo = rugged_owner(self);
81
83
 
82
84
  rugged_check_repo(rb_repo);
83
- Data_Get_Struct(rb_repo, git_repository, repo);
85
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
84
86
 
85
87
  Check_Type(rb_name, T_STRING);
86
88
  Check_Type(rb_url, T_STRING);
@@ -115,7 +117,7 @@ static VALUE rb_git_remote_collection_aref(VALUE self, VALUE rb_name)
115
117
 
116
118
  VALUE rb_repo = rugged_owner(self);
117
119
  rugged_check_repo(rb_repo);
118
- Data_Get_Struct(rb_repo, git_repository, repo);
120
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
119
121
 
120
122
  Check_Type(rb_name, T_STRING);
121
123
 
@@ -143,7 +145,7 @@ static VALUE rb_git_remote_collection__each(VALUE self, int only_names)
143
145
 
144
146
  rb_repo = rugged_owner(self);
145
147
  rugged_check_repo(rb_repo);
146
- Data_Get_Struct(rb_repo, git_repository, repo);
148
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
147
149
 
148
150
  error = git_remote_list(&remotes, repo);
149
151
  rugged_exception_check(error);
@@ -244,7 +246,7 @@ static VALUE rb_git_remote_collection_rename(VALUE self, VALUE rb_name_or_remote
244
246
  rb_raise(rb_eTypeError, "Expecting a String or Rugged::Remote instance");
245
247
 
246
248
  rugged_check_repo(rb_repo);
247
- Data_Get_Struct(rb_repo, git_repository, repo);
249
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
248
250
 
249
251
  error = git_remote_rename(&problems, repo, StringValueCStr(rb_name_or_remote), StringValueCStr(rb_new_name));
250
252
  rugged_exception_check(error);
@@ -283,7 +285,7 @@ static VALUE rb_git_remote_collection_delete(VALUE self, VALUE rb_name_or_remote
283
285
  rb_raise(rb_eTypeError, "Expecting a String or Rugged::Remote instance");
284
286
 
285
287
  rugged_check_repo(rb_repo);
286
- Data_Get_Struct(rb_repo, git_repository, repo);
288
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
287
289
 
288
290
  rugged_exception_check(
289
291
  git_remote_delete(repo, StringValueCStr(rb_name_or_remote))
@@ -314,7 +316,7 @@ static VALUE rb_git_remote_collection_set_url(VALUE self, VALUE rb_name_or_remot
314
316
  rb_raise(rb_eTypeError, "Expecting a String or Rugged::Remote instance");
315
317
 
316
318
  rugged_check_repo(rb_repo);
317
- Data_Get_Struct(rb_repo, git_repository, repo);
319
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
318
320
 
319
321
  Check_Type(rb_url, T_STRING);
320
322
 
@@ -347,7 +349,7 @@ static VALUE rb_git_remote_collection_set_push_url(VALUE self, VALUE rb_name_or_
347
349
  rb_raise(rb_eTypeError, "Expecting a String or Rugged::Remote instance");
348
350
 
349
351
  rugged_check_repo(rb_repo);
350
- Data_Get_Struct(rb_repo, git_repository, repo);
352
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
351
353
 
352
354
  Check_Type(rb_url, T_STRING);
353
355
 
@@ -371,7 +373,7 @@ static VALUE rb_git_remote_collection_add_refspec(VALUE self, VALUE rb_name_or_r
371
373
  rb_raise(rb_eTypeError, "Expecting a String or Rugged::Remote instance");
372
374
 
373
375
  rugged_check_repo(rb_repo);
374
- Data_Get_Struct(rb_repo, git_repository, repo);
376
+ TypedData_Get_Struct(rb_repo, git_repository, &rugged_repository_type, repo);
375
377
 
376
378
  Check_Type(rb_refspec, T_STRING);
377
379
 
@@ -34,6 +34,10 @@ VALUE rb_cRuggedOdbObject;
34
34
 
35
35
  static ID id_call;
36
36
 
37
+ extern const rb_data_type_t rugged_config_type;
38
+ extern const rb_data_type_t rugged_diff_type;
39
+ extern const rb_data_type_t rugged_index_type;
40
+ const rb_data_type_t rugged_repository_type;
37
41
  extern const rb_data_type_t rugged_object_type;
38
42
  static const rb_data_type_t rugged_odb_object_type;
39
43
 
@@ -143,14 +147,23 @@ VALUE rugged_raw_read(git_repository *repo, const git_oid *oid)
143
147
  return TypedData_Wrap_Struct(rb_cRuggedOdbObject, &rugged_odb_object_type, obj);
144
148
  }
145
149
 
146
- void rb_git_repo__free(git_repository *repo)
150
+ void rb_git_repo__free(void *data)
147
151
  {
152
+ git_repository *repo = (git_repository *) data;
148
153
  git_repository_free(repo);
149
154
  }
150
155
 
156
+ const rb_data_type_t rugged_repository_type = {
157
+ .wrap_struct_name = "Rugged::Repository",
158
+ .function = {
159
+ .dfree = rb_git_repo__free,
160
+ },
161
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
162
+ };
163
+
151
164
  VALUE rugged_repo_new(VALUE klass, git_repository *repo)
152
165
  {
153
- VALUE rb_repo = Data_Wrap_Struct(klass, NULL, &rb_git_repo__free, repo);
166
+ VALUE rb_repo = TypedData_Wrap_Struct(klass, &rugged_repository_type, repo);
154
167
 
155
168
  #ifdef HAVE_RUBY_ENCODING_H
156
169
  /* TODO: set this properly */
@@ -212,7 +225,9 @@ static void rugged_repo_new_with_backend(git_repository **repo, VALUE rb_path, V
212
225
  rb_raise(rb_eRuggedError, "Backend must be an instance of Rugged::Backend");
213
226
  }
214
227
 
215
- Data_Get_Struct(rb_backend, rugged_backend, backend);
228
+ /* Backends are wrapped by external code with a type descriptor we don't
229
+ * own, so we can't TypedData_Get_Struct against a known type. */
230
+ backend = (rugged_backend *)RTYPEDDATA_DATA(rb_backend);
216
231
 
217
232
  error = git_odb_new(&odb);
218
233
  if (error) goto cleanup;
@@ -613,7 +628,7 @@ static VALUE rb_git_repo_clone_at(int argc, VALUE *argv, VALUE klass)
613
628
  git_repository *repo; \
614
629
  git_##_object *data; \
615
630
  int error; \
616
- Data_Get_Struct(self, git_repository, repo); \
631
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo); \
617
632
  error = git_repository_##_object(&data, repo); \
618
633
  rugged_exception_check(error); \
619
634
  rb_data = rugged_##_object##_new(_klass, self, data); \
@@ -631,8 +646,8 @@ static VALUE rb_git_repo_clone_at(int argc, VALUE *argv, VALUE klass)
631
646
  if (!NIL_P(rugged_owner(rb_data))) \
632
647
  rb_raise(rb_eRuntimeError, \
633
648
  "The given object is already owned by another repository"); \
634
- Data_Get_Struct(self, git_repository, repo); \
635
- Data_Get_Struct(rb_data, git_##_object, data); \
649
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo); \
650
+ TypedData_Get_Struct(rb_data, git_##_object, &rugged_##_object##_type, data); \
636
651
  git_repository_set_##_object(repo, data); \
637
652
  rb_old_data = rb_iv_get(self, "@" #_object); \
638
653
  if (!NIL_P(rb_old_data)) rugged_set_owner(rb_old_data, Qnil); \
@@ -712,7 +727,7 @@ static VALUE rb_git_repo_set_ident(VALUE self, VALUE rb_ident) {
712
727
  git_repository *repo;
713
728
  const char *name = NULL, *email = NULL;
714
729
 
715
- Data_Get_Struct(self, git_repository, repo);
730
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
716
731
 
717
732
  if (!NIL_P(rb_ident)) {
718
733
  Check_Type(rb_ident, T_HASH);
@@ -750,7 +765,7 @@ static VALUE rb_git_repo_get_ident(VALUE self)
750
765
  git_repository *repo;
751
766
  const char *name = NULL, *email = NULL;
752
767
 
753
- Data_Get_Struct(self, git_repository, repo);
768
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
754
769
 
755
770
  rugged_exception_check(
756
771
  git_repository_ident(&name, &email, repo)
@@ -786,7 +801,7 @@ static VALUE rb_git_repo_merge_base(VALUE self, VALUE rb_args)
786
801
  if (len < 2)
787
802
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", len);
788
803
 
789
- Data_Get_Struct(self, git_repository, repo);
804
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
790
805
 
791
806
  for (i = 0; !error && i < len; ++i) {
792
807
  error = rugged_oid_get(&input_array[i], repo, rb_ary_entry(rb_args, i));
@@ -830,7 +845,7 @@ static VALUE rb_git_repo_merge_bases(VALUE self, VALUE rb_args)
830
845
  if (len < 2)
831
846
  rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2+)", RARRAY_LEN(rb_args));
832
847
 
833
- Data_Get_Struct(self, git_repository, repo);
848
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
834
849
 
835
850
  input_array = xmalloc(sizeof(git_oid) * len);
836
851
 
@@ -898,7 +913,7 @@ static VALUE rb_git_repo_merge_analysis(int argc, VALUE *argv, VALUE self)
898
913
 
899
914
  rb_scan_args(argc, argv, "10", &rb_their_commit);
900
915
 
901
- Data_Get_Struct(self, git_repository, repo);
916
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
902
917
 
903
918
  if (TYPE(rb_their_commit) == T_STRING) {
904
919
  rb_their_commit = rugged_object_rev_parse(self, rb_their_commit, 1);
@@ -975,7 +990,7 @@ static VALUE rb_git_repo_revert_commit(int argc, VALUE *argv, VALUE self)
975
990
  }
976
991
  }
977
992
 
978
- Data_Get_Struct(self, git_repository, repo);
993
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
979
994
  TypedData_Get_Struct(rb_revert_commit, git_commit, &rugged_object_type, revert_commit);
980
995
  TypedData_Get_Struct(rb_our_commit, git_commit, &rugged_object_type, our_commit);
981
996
 
@@ -1024,7 +1039,7 @@ static VALUE rb_git_repo_apply(int argc, VALUE *argv, VALUE self)
1024
1039
  struct rugged_apply_cb_payload payload = { Qnil, Qnil, 0 };
1025
1040
  int error;
1026
1041
 
1027
- Data_Get_Struct(self, git_repository, repo);
1042
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1028
1043
  if (git_repository_is_bare(repo)) {
1029
1044
  location = GIT_APPLY_LOCATION_INDEX;
1030
1045
  } else {
@@ -1042,7 +1057,7 @@ static VALUE rb_git_repo_apply(int argc, VALUE *argv, VALUE self)
1042
1057
  rugged_parse_apply_options(&opts, &location, rb_options, &payload);
1043
1058
  }
1044
1059
 
1045
- Data_Get_Struct(rb_diff, git_diff, diff);
1060
+ TypedData_Get_Struct(rb_diff, git_diff, &rugged_diff_type, diff);
1046
1061
 
1047
1062
  error = git_apply(repo, diff, location, &opts);
1048
1063
 
@@ -1093,7 +1108,7 @@ static VALUE rb_git_repo_merge_commits(int argc, VALUE *argv, VALUE self)
1093
1108
  rugged_parse_merge_options(&opts, rb_options);
1094
1109
  }
1095
1110
 
1096
- Data_Get_Struct(self, git_repository, repo);
1111
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1097
1112
  TypedData_Get_Struct(rb_our_commit, git_commit, &rugged_object_type, our_commit);
1098
1113
  TypedData_Get_Struct(rb_their_commit, git_commit, &rugged_object_type, their_commit);
1099
1114
 
@@ -1124,7 +1139,7 @@ static VALUE rb_git_repo_exists(VALUE self, VALUE hex)
1124
1139
  git_oid oid;
1125
1140
  int error;
1126
1141
 
1127
- Data_Get_Struct(self, git_repository, repo);
1142
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1128
1143
  Check_Type(hex, T_STRING);
1129
1144
 
1130
1145
  error = git_oid_fromstrn(&oid, RSTRING_PTR(hex), RSTRING_LEN(hex));
@@ -1154,7 +1169,7 @@ static VALUE rb_git_repo_read(VALUE self, VALUE hex)
1154
1169
  git_oid oid;
1155
1170
  int error;
1156
1171
 
1157
- Data_Get_Struct(self, git_repository, repo);
1172
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1158
1173
  Check_Type(hex, T_STRING);
1159
1174
 
1160
1175
  error = git_oid_fromstr(&oid, StringValueCStr(hex));
@@ -1188,7 +1203,7 @@ static VALUE rb_git_repo_read_header(VALUE self, VALUE hex)
1188
1203
  VALUE rb_hash;
1189
1204
  int error;
1190
1205
 
1191
- Data_Get_Struct(self, git_repository, repo);
1206
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1192
1207
  Check_Type(hex, T_STRING);
1193
1208
 
1194
1209
  error = git_oid_fromstr(&oid, StringValueCStr(hex));
@@ -1233,7 +1248,7 @@ static VALUE rb_git_repo_expand_oids(int argc, VALUE *argv, VALUE self)
1233
1248
  long i, expand_count;
1234
1249
  int error;
1235
1250
 
1236
- Data_Get_Struct(self, git_repository, repo);
1251
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1237
1252
  rb_scan_args(argc, argv, "11", &rb_oids, &rb_expected_type);
1238
1253
 
1239
1254
  Check_Type(rb_oids, T_ARRAY);
@@ -1303,7 +1318,7 @@ static VALUE rb_git_repo_descendant_of(VALUE self, VALUE rb_commit, VALUE rb_anc
1303
1318
  git_repository *repo;
1304
1319
  git_oid commit, ancestor;
1305
1320
 
1306
- Data_Get_Struct(self, git_repository, repo);
1321
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1307
1322
 
1308
1323
  error = rugged_oid_get(&commit, repo, rb_commit);
1309
1324
  rugged_exception_check(error);
@@ -1396,7 +1411,7 @@ static VALUE rb_git_repo_write(VALUE self, VALUE rb_buffer, VALUE rub_type)
1396
1411
 
1397
1412
  git_otype type;
1398
1413
 
1399
- Data_Get_Struct(self, git_repository, repo);
1414
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1400
1415
  Check_Type(rb_buffer, T_STRING);
1401
1416
 
1402
1417
  error = git_repository_odb(&odb, repo);
@@ -1421,7 +1436,7 @@ static VALUE rb_git_repo_write(VALUE self, VALUE rb_buffer, VALUE rub_type)
1421
1436
  #define RB_GIT_REPO_GETTER(method) \
1422
1437
  git_repository *repo; \
1423
1438
  int error; \
1424
- Data_Get_Struct(self, git_repository, repo); \
1439
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo); \
1425
1440
  error = git_repository_##method(repo); \
1426
1441
  rugged_exception_check(error); \
1427
1442
  return error ? Qtrue : Qfalse; \
@@ -1497,7 +1512,7 @@ static VALUE rb_git_repo_set_head(VALUE self, VALUE rb_head)
1497
1512
  git_repository *repo;
1498
1513
  int error;
1499
1514
 
1500
- Data_Get_Struct(self, git_repository, repo);
1515
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1501
1516
 
1502
1517
  Check_Type(rb_head, T_STRING);
1503
1518
  error = git_repository_set_head(repo, StringValueCStr(rb_head));
@@ -1520,7 +1535,7 @@ static VALUE rb_git_repo_get_head(VALUE self)
1520
1535
  git_reference *head;
1521
1536
  int error;
1522
1537
 
1523
- Data_Get_Struct(self, git_repository, repo);
1538
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1524
1539
 
1525
1540
  error = git_repository_head(&head, repo);
1526
1541
  if (error == GIT_ENOTFOUND)
@@ -1545,7 +1560,7 @@ static VALUE rb_git_repo_path(VALUE self)
1545
1560
  git_repository *repo;
1546
1561
  const char *path;
1547
1562
 
1548
- Data_Get_Struct(self, git_repository, repo);
1563
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1549
1564
  path = git_repository_path(repo);
1550
1565
 
1551
1566
  return path ? rb_str_new_utf8(path) : Qnil;
@@ -1569,7 +1584,7 @@ static VALUE rb_git_repo_workdir(VALUE self)
1569
1584
  git_repository *repo;
1570
1585
  const char *workdir;
1571
1586
 
1572
- Data_Get_Struct(self, git_repository, repo);
1587
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1573
1588
  workdir = git_repository_workdir(repo);
1574
1589
 
1575
1590
  return workdir ? rb_str_new_utf8(workdir) : Qnil;
@@ -1595,7 +1610,7 @@ static VALUE rb_git_repo_set_workdir(VALUE self, VALUE rb_workdir)
1595
1610
  {
1596
1611
  git_repository *repo;
1597
1612
 
1598
- Data_Get_Struct(self, git_repository, repo);
1613
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1599
1614
  Check_Type(rb_workdir, T_STRING);
1600
1615
 
1601
1616
  rugged_exception_check(
@@ -1691,7 +1706,7 @@ static VALUE rb_git_repo_file_status(VALUE self, VALUE rb_path)
1691
1706
  int error;
1692
1707
  git_repository *repo;
1693
1708
 
1694
- Data_Get_Struct(self, git_repository, repo);
1709
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1695
1710
  FilePathValue(rb_path);
1696
1711
  error = git_status_file(&flags, repo, StringValueCStr(rb_path));
1697
1712
  rugged_exception_check(error);
@@ -1706,7 +1721,7 @@ static VALUE rb_git_repo_file_each_status(VALUE self)
1706
1721
  git_repository *repo;
1707
1722
  git_status_list *list;
1708
1723
 
1709
- Data_Get_Struct(self, git_repository, repo);
1724
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1710
1725
 
1711
1726
  if (!rb_block_given_p())
1712
1727
  rb_raise(rb_eRuntimeError,
@@ -1764,7 +1779,7 @@ static VALUE rb_git_repo_each_id(VALUE self)
1764
1779
 
1765
1780
  RETURN_ENUMERATOR(self, 0, 0);
1766
1781
 
1767
- Data_Get_Struct(self, git_repository, repo);
1782
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1768
1783
 
1769
1784
  error = git_repository_odb(&odb, repo);
1770
1785
  rugged_exception_check(error);
@@ -1828,7 +1843,7 @@ static VALUE rb_git_repo_reset(VALUE self, VALUE rb_target, VALUE rb_reset_type)
1828
1843
  git_object *target = NULL;
1829
1844
  int error;
1830
1845
 
1831
- Data_Get_Struct(self, git_repository, repo);
1846
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1832
1847
 
1833
1848
  reset_type = parse_reset_type(rb_reset_type);
1834
1849
  target = rugged_object_get(repo, rb_target, GIT_OBJ_ANY);
@@ -1869,7 +1884,7 @@ static VALUE rb_git_repo_reset_path(int argc, VALUE *argv, VALUE self)
1869
1884
  pathspecs.strings = NULL;
1870
1885
  pathspecs.count = 0;
1871
1886
 
1872
- Data_Get_Struct(self, git_repository, repo);
1887
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1873
1888
 
1874
1889
  rb_scan_args(argc, argv, "11", &rb_paths, &rb_target);
1875
1890
 
@@ -1901,7 +1916,7 @@ static VALUE rb_git_repo_reset_path(int argc, VALUE *argv, VALUE self)
1901
1916
  static VALUE rb_git_repo_close(VALUE self)
1902
1917
  {
1903
1918
  git_repository *repo;
1904
- Data_Get_Struct(self, git_repository, repo);
1919
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1905
1920
 
1906
1921
  git_repository__cleanup(repo);
1907
1922
 
@@ -1920,7 +1935,7 @@ static VALUE rb_git_repo_set_namespace(VALUE self, VALUE rb_namespace)
1920
1935
  git_repository *repo;
1921
1936
  int error;
1922
1937
 
1923
- Data_Get_Struct(self, git_repository, repo);
1938
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1924
1939
 
1925
1940
  if (!NIL_P(rb_namespace)) {
1926
1941
  Check_Type(rb_namespace, T_STRING);
@@ -1944,7 +1959,7 @@ static VALUE rb_git_repo_get_namespace(VALUE self)
1944
1959
  git_repository *repo;
1945
1960
  const char *namespace;
1946
1961
 
1947
- Data_Get_Struct(self, git_repository, repo);
1962
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1948
1963
 
1949
1964
  namespace = git_repository_get_namespace(repo);
1950
1965
  return namespace ? rb_str_new_utf8(namespace) : Qnil;
@@ -1967,7 +1982,7 @@ static VALUE rb_git_repo_ahead_behind(VALUE self, VALUE rb_local, VALUE rb_upstr
1967
1982
  size_t ahead, behind;
1968
1983
  VALUE rb_result;
1969
1984
 
1970
- Data_Get_Struct(self, git_repository, repo);
1985
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
1971
1986
 
1972
1987
  error = rugged_oid_get(&local, repo, rb_local);
1973
1988
  rugged_exception_check(error);
@@ -2006,7 +2021,7 @@ static VALUE rb_git_repo_default_signature(VALUE self) {
2006
2021
  git_signature *signature;
2007
2022
  VALUE rb_signature;
2008
2023
 
2009
- Data_Get_Struct(self, git_repository, repo);
2024
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
2010
2025
 
2011
2026
  error = git_signature_default(&signature, repo);
2012
2027
 
@@ -2372,7 +2387,7 @@ static VALUE rb_git_checkout_tree(int argc, VALUE *argv, VALUE self)
2372
2387
  rb_raise(rb_eTypeError, "Expected Rugged::Commit, Rugged::Tag or Rugged::Tree");
2373
2388
  }
2374
2389
 
2375
- Data_Get_Struct(self, git_repository, repo);
2390
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
2376
2391
  TypedData_Get_Struct(rb_treeish, git_object, &rugged_object_type, treeish);
2377
2392
 
2378
2393
  rugged_parse_checkout_options(&opts, rb_options);
@@ -2420,8 +2435,8 @@ static VALUE rb_git_checkout_index(int argc, VALUE *argv, VALUE self)
2420
2435
  if (!rb_obj_is_kind_of(rb_index, rb_cRuggedIndex))
2421
2436
  rb_raise(rb_eTypeError, "Expected Rugged::Index");
2422
2437
 
2423
- Data_Get_Struct(self, git_repository, repo);
2424
- Data_Get_Struct(rb_index, git_index, index);
2438
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
2439
+ TypedData_Get_Struct(rb_index, git_index, &rugged_index_type, index);
2425
2440
 
2426
2441
  rugged_parse_checkout_options(&opts, rb_options);
2427
2442
 
@@ -2464,7 +2479,7 @@ static VALUE rb_git_checkout_head(int argc, VALUE *argv, VALUE self)
2464
2479
 
2465
2480
  rb_scan_args(argc, argv, "00:", &rb_options);
2466
2481
 
2467
- Data_Get_Struct(self, git_repository, repo);
2482
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
2468
2483
 
2469
2484
  rugged_parse_checkout_options(&opts, rb_options);
2470
2485
 
@@ -2501,7 +2516,7 @@ static VALUE rb_git_repo_is_path_ignored(VALUE self, VALUE rb_path) {
2501
2516
  int error;
2502
2517
  int ignored;
2503
2518
 
2504
- Data_Get_Struct(self, git_repository, repo);
2519
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
2505
2520
  path = StringValueCStr(rb_path);
2506
2521
  error = git_ignore_path_is_ignored(&ignored, repo, path);
2507
2522
  rugged_exception_check(error);
@@ -2557,7 +2572,7 @@ static VALUE rb_git_repo_attributes(int argc, VALUE *argv, VALUE self)
2557
2572
 
2558
2573
  rb_scan_args(argc, argv, "12", &rb_path, &rb_names, &rb_options);
2559
2574
 
2560
- Data_Get_Struct(self, git_repository, repo);
2575
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
2561
2576
  FilePathValue(rb_path);
2562
2577
 
2563
2578
  if (!NIL_P(rb_options)) {
@@ -2670,7 +2685,7 @@ static VALUE rb_git_repo_cherrypick(int argc, VALUE *argv, VALUE self)
2670
2685
  rb_raise(rb_eArgError, "Expected a Rugged::Commit.");
2671
2686
  }
2672
2687
 
2673
- Data_Get_Struct(self, git_repository, repo);
2688
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
2674
2689
  TypedData_Get_Struct(rb_commit, git_commit, &rugged_object_type, commit);
2675
2690
 
2676
2691
  rugged_parse_cherrypick_options(&opts, rb_options);
@@ -2723,7 +2738,7 @@ static VALUE rb_git_repo_cherrypick_commit(int argc, VALUE *argv, VALUE self)
2723
2738
  rb_raise(rb_eArgError, "Expected a Rugged::Commit.");
2724
2739
  }
2725
2740
 
2726
- Data_Get_Struct(self, git_repository, repo);
2741
+ TypedData_Get_Struct(self, git_repository, &rugged_repository_type, repo);
2727
2742
  TypedData_Get_Struct(rb_commit, git_commit, &rugged_object_type, commit);
2728
2743
  TypedData_Get_Struct(rb_our_commit, git_commit, &rugged_object_type, our_commit);
2729
2744