rugged 0.24.6.1 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/ext/rugged/extconf.rb +9 -2
  4. data/ext/rugged/rugged.c +85 -21
  5. data/ext/rugged/rugged.h +7 -21
  6. data/ext/rugged/rugged_backend.c +3 -20
  7. data/ext/rugged/rugged_blame.c +7 -24
  8. data/ext/rugged/rugged_blob.c +136 -59
  9. data/ext/rugged/rugged_branch.c +3 -20
  10. data/ext/rugged/rugged_branch_collection.c +3 -20
  11. data/ext/rugged/rugged_commit.c +251 -101
  12. data/ext/rugged/rugged_config.c +3 -20
  13. data/ext/rugged/rugged_cred.c +3 -20
  14. data/ext/rugged/rugged_diff.c +3 -20
  15. data/ext/rugged/rugged_diff_delta.c +3 -20
  16. data/ext/rugged/rugged_diff_hunk.c +3 -20
  17. data/ext/rugged/rugged_diff_line.c +3 -20
  18. data/ext/rugged/rugged_index.c +46 -229
  19. data/ext/rugged/rugged_note.c +3 -20
  20. data/ext/rugged/rugged_object.c +3 -20
  21. data/ext/rugged/rugged_patch.c +192 -34
  22. data/ext/rugged/rugged_rebase.c +90 -48
  23. data/ext/rugged/rugged_reference.c +4 -21
  24. data/ext/rugged/rugged_reference_collection.c +3 -20
  25. data/ext/rugged/rugged_remote.c +70 -42
  26. data/ext/rugged/rugged_remote_collection.c +3 -20
  27. data/ext/rugged/rugged_repo.c +50 -59
  28. data/ext/rugged/rugged_revwalk.c +4 -21
  29. data/ext/rugged/rugged_settings.c +3 -20
  30. data/ext/rugged/rugged_signature.c +3 -20
  31. data/ext/rugged/rugged_submodule.c +4 -21
  32. data/ext/rugged/rugged_submodule_collection.c +3 -20
  33. data/ext/rugged/rugged_tag.c +3 -20
  34. data/ext/rugged/rugged_tag_collection.c +3 -20
  35. data/ext/rugged/rugged_tree.c +189 -184
  36. data/lib/rugged/attributes.rb +5 -0
  37. data/lib/rugged/blob.rb +5 -0
  38. data/lib/rugged/branch.rb +6 -1
  39. data/lib/rugged/commit.rb +5 -0
  40. data/lib/rugged/console.rb +5 -0
  41. data/lib/rugged/credentials.rb +5 -0
  42. data/lib/rugged/diff/delta.rb +5 -0
  43. data/lib/rugged/diff/hunk.rb +5 -0
  44. data/lib/rugged/diff/line.rb +5 -0
  45. data/lib/rugged/diff.rb +5 -0
  46. data/lib/rugged/index.rb +120 -0
  47. data/lib/rugged/object.rb +5 -0
  48. data/lib/rugged/patch.rb +5 -0
  49. data/lib/rugged/reference.rb +5 -0
  50. data/lib/rugged/remote.rb +5 -0
  51. data/lib/rugged/repository.rb +9 -4
  52. data/lib/rugged/submodule_collection.rb +5 -0
  53. data/lib/rugged/tag.rb +5 -0
  54. data/lib/rugged/tree.rb +156 -1
  55. data/lib/rugged/version.rb +6 -1
  56. data/lib/rugged/walker.rb +5 -0
  57. data/lib/rugged.rb +5 -0
  58. data/vendor/libgit2/CMakeLists.txt +12 -2
  59. data/vendor/libgit2/include/git2/blob.h +39 -28
  60. data/vendor/libgit2/include/git2/commit.h +76 -0
  61. data/vendor/libgit2/include/git2/common.h +21 -1
  62. data/vendor/libgit2/include/git2/describe.h +5 -2
  63. data/vendor/libgit2/include/git2/diff.h +62 -7
  64. data/vendor/libgit2/include/git2/errors.h +2 -1
  65. data/vendor/libgit2/include/git2/index.h +25 -0
  66. data/vendor/libgit2/include/git2/merge.h +10 -1
  67. data/vendor/libgit2/include/git2/odb.h +47 -1
  68. data/vendor/libgit2/include/git2/pack.h +4 -4
  69. data/vendor/libgit2/include/git2/patch.h +1 -1
  70. data/vendor/libgit2/include/git2/proxy.h +92 -0
  71. data/vendor/libgit2/include/git2/refs.h +11 -0
  72. data/vendor/libgit2/include/git2/remote.h +21 -8
  73. data/vendor/libgit2/include/git2/repository.h +20 -1
  74. data/vendor/libgit2/include/git2/revwalk.h +4 -6
  75. data/vendor/libgit2/include/git2/signature.h +13 -0
  76. data/vendor/libgit2/include/git2/submodule.h +11 -3
  77. data/vendor/libgit2/include/git2/sys/merge.h +177 -0
  78. data/vendor/libgit2/include/git2/sys/odb_backend.h +11 -0
  79. data/vendor/libgit2/include/git2/sys/remote.h +16 -0
  80. data/vendor/libgit2/include/git2/sys/stream.h +2 -1
  81. data/vendor/libgit2/include/git2/sys/time.h +31 -0
  82. data/vendor/libgit2/include/git2/sys/transport.h +3 -1
  83. data/vendor/libgit2/include/git2/tag.h +9 -0
  84. data/vendor/libgit2/include/git2/transaction.h +9 -0
  85. data/vendor/libgit2/include/git2/tree.h +55 -0
  86. data/vendor/libgit2/include/git2/version.h +4 -4
  87. data/vendor/libgit2/include/git2.h +1 -0
  88. data/vendor/libgit2/src/annotated_commit.c +99 -80
  89. data/vendor/libgit2/src/annotated_commit.h +5 -2
  90. data/vendor/libgit2/src/apply.c +377 -0
  91. data/vendor/libgit2/src/apply.h +21 -0
  92. data/vendor/libgit2/src/array.h +0 -1
  93. data/vendor/libgit2/src/blob.c +71 -39
  94. data/vendor/libgit2/src/branch.c +7 -5
  95. data/vendor/libgit2/src/buffer.c +252 -20
  96. data/vendor/libgit2/src/buffer.h +8 -0
  97. data/vendor/libgit2/src/checkout.c +69 -42
  98. data/vendor/libgit2/src/clone.c +0 -8
  99. data/vendor/libgit2/src/commit.c +193 -49
  100. data/vendor/libgit2/src/commit_list.c +8 -3
  101. data/vendor/libgit2/src/commit_list.h +1 -0
  102. data/vendor/libgit2/src/common.h +2 -1
  103. data/vendor/libgit2/src/config.c +3 -3
  104. data/vendor/libgit2/src/config_file.c +20 -10
  105. data/vendor/libgit2/src/crlf.c +1 -0
  106. data/vendor/libgit2/src/curl_stream.c +106 -6
  107. data/vendor/libgit2/src/delta.c +238 -62
  108. data/vendor/libgit2/src/delta.h +79 -58
  109. data/vendor/libgit2/src/describe.c +1 -1
  110. data/vendor/libgit2/src/diff.c +32 -1554
  111. data/vendor/libgit2/src/diff.h +14 -122
  112. data/vendor/libgit2/src/diff_driver.c +4 -6
  113. data/vendor/libgit2/src/diff_file.c +3 -0
  114. data/vendor/libgit2/src/diff_generate.c +1613 -0
  115. data/vendor/libgit2/src/diff_generate.h +123 -0
  116. data/vendor/libgit2/src/diff_parse.c +101 -0
  117. data/vendor/libgit2/src/diff_parse.h +18 -0
  118. data/vendor/libgit2/src/diff_print.c +263 -144
  119. data/vendor/libgit2/src/diff_stats.c +21 -12
  120. data/vendor/libgit2/src/diff_tform.c +1 -0
  121. data/vendor/libgit2/src/diff_tform.h +22 -0
  122. data/vendor/libgit2/src/diff_xdiff.c +9 -9
  123. data/vendor/libgit2/src/diff_xdiff.h +5 -5
  124. data/vendor/libgit2/src/fetchhead.c +8 -8
  125. data/vendor/libgit2/src/filebuf.c +6 -1
  126. data/vendor/libgit2/src/filebuf.h +1 -0
  127. data/vendor/libgit2/src/fileops.c +22 -1
  128. data/vendor/libgit2/src/fileops.h +8 -2
  129. data/vendor/libgit2/src/fnmatch.c +18 -5
  130. data/vendor/libgit2/src/global.c +21 -4
  131. data/vendor/libgit2/src/global.h +6 -0
  132. data/vendor/libgit2/src/graph.c +1 -1
  133. data/vendor/libgit2/src/index.c +159 -46
  134. data/vendor/libgit2/src/index.h +2 -0
  135. data/vendor/libgit2/src/iterator.c +1573 -1468
  136. data/vendor/libgit2/src/iterator.h +52 -69
  137. data/vendor/libgit2/src/merge.c +163 -64
  138. data/vendor/libgit2/src/merge.h +61 -2
  139. data/vendor/libgit2/src/merge_driver.c +397 -0
  140. data/vendor/libgit2/src/merge_driver.h +60 -0
  141. data/vendor/libgit2/src/merge_file.c +11 -49
  142. data/vendor/libgit2/src/netops.c +12 -10
  143. data/vendor/libgit2/src/object_api.c +19 -1
  144. data/vendor/libgit2/src/odb.c +228 -52
  145. data/vendor/libgit2/src/odb_loose.c +19 -1
  146. data/vendor/libgit2/src/odb_mempack.c +1 -1
  147. data/vendor/libgit2/src/odb_pack.c +27 -1
  148. data/vendor/libgit2/src/openssl_stream.c +4 -5
  149. data/vendor/libgit2/src/pack-objects.c +105 -76
  150. data/vendor/libgit2/src/pack-objects.h +13 -12
  151. data/vendor/libgit2/src/pack.c +16 -10
  152. data/vendor/libgit2/src/pack.h +2 -0
  153. data/vendor/libgit2/src/patch.c +216 -0
  154. data/vendor/libgit2/src/patch.h +66 -0
  155. data/vendor/libgit2/src/{diff_patch.c → patch_generate.c} +203 -376
  156. data/vendor/libgit2/src/patch_generate.h +68 -0
  157. data/vendor/libgit2/src/patch_parse.c +1159 -0
  158. data/vendor/libgit2/src/patch_parse.h +56 -0
  159. data/vendor/libgit2/src/path.c +38 -2
  160. data/vendor/libgit2/src/path.h +18 -0
  161. data/vendor/libgit2/src/pathspec.c +1 -1
  162. data/vendor/libgit2/src/pool.h +5 -0
  163. data/vendor/libgit2/src/pqueue.c +12 -5
  164. data/vendor/libgit2/src/pqueue.h +1 -0
  165. data/vendor/libgit2/src/proxy.c +32 -0
  166. data/vendor/libgit2/src/proxy.h +14 -0
  167. data/vendor/libgit2/src/push.c +1 -1
  168. data/vendor/libgit2/src/rebase.c +63 -36
  169. data/vendor/libgit2/src/refdb.c +4 -2
  170. data/vendor/libgit2/src/refdb_fs.c +82 -54
  171. data/vendor/libgit2/src/refs.c +13 -1
  172. data/vendor/libgit2/src/remote.c +20 -81
  173. data/vendor/libgit2/src/repository.c +212 -29
  174. data/vendor/libgit2/src/reset.c +1 -1
  175. data/vendor/libgit2/src/revparse.c +1 -1
  176. data/vendor/libgit2/src/revwalk.c +260 -184
  177. data/vendor/libgit2/src/settings.c +11 -3
  178. data/vendor/libgit2/src/signature.c +27 -2
  179. data/vendor/libgit2/src/sortedcache.c +14 -5
  180. data/vendor/libgit2/src/stash.c +1 -0
  181. data/vendor/libgit2/src/status.c +1 -0
  182. data/vendor/libgit2/src/stransport_stream.c +4 -2
  183. data/vendor/libgit2/src/stream.h +2 -2
  184. data/vendor/libgit2/src/submodule.c +16 -4
  185. data/vendor/libgit2/src/sysdir.c +1 -1
  186. data/vendor/libgit2/src/transport.c +3 -5
  187. data/vendor/libgit2/src/transports/http.c +38 -13
  188. data/vendor/libgit2/src/transports/local.c +4 -1
  189. data/vendor/libgit2/src/transports/smart.c +6 -0
  190. data/vendor/libgit2/src/transports/smart.h +1 -0
  191. data/vendor/libgit2/src/transports/smart_pkt.c +5 -13
  192. data/vendor/libgit2/src/transports/smart_protocol.c +22 -7
  193. data/vendor/libgit2/src/transports/winhttp.c +144 -11
  194. data/vendor/libgit2/src/tree.c +267 -2
  195. data/vendor/libgit2/src/unix/posix.h +10 -0
  196. data/vendor/libgit2/src/unix/pthread.h +2 -0
  197. data/vendor/libgit2/src/util.c +25 -2
  198. data/vendor/libgit2/src/util.h +10 -0
  199. data/vendor/libgit2/src/varint.c +44 -0
  200. data/vendor/libgit2/src/varint.h +15 -0
  201. data/vendor/libgit2/src/vector.c +58 -0
  202. data/vendor/libgit2/src/vector.h +8 -0
  203. data/vendor/libgit2/src/win32/posix.h +3 -0
  204. data/vendor/libgit2/src/win32/thread.c +18 -0
  205. data/vendor/libgit2/src/win32/thread.h +2 -0
  206. data/vendor/libgit2/src/win32/w32_util.h +1 -1
  207. data/vendor/libgit2/src/zstream.c +37 -8
  208. data/vendor/libgit2/src/zstream.h +8 -1
  209. metadata +100 -82
  210. data/vendor/libgit2/Makefile.embed +0 -60
  211. data/vendor/libgit2/src/delta-apply.c +0 -166
  212. data/vendor/libgit2/src/delta-apply.h +0 -62
  213. data/vendor/libgit2/src/diff_patch.h +0 -83
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4b1489ad0847a3a4701d7f5f9ea3e6e78a9d556
4
- data.tar.gz: be07145f99c3be07bf0c970c70932e2ef4b7a94c
3
+ metadata.gz: e7c6702ff8d1ff0c9c82ed452dc97b5f070f0bfa
4
+ data.tar.gz: a8e2f585ba932121e5e26ea29bfe7fe0b60a8d9a
5
5
  SHA512:
6
- metadata.gz: 2ff1cce3c75a0027c9003ce19021cd589a3fdffeaf2c69ccd5dd6614c77e80964256580a230c7e61fa1fd9dbe871fd79029c17d3f027f7f2d3eb6a7346f3633d
7
- data.tar.gz: c63797d882cf388ad42a9d83c054dfe4b1bd5091654c89433fe2fa43481d9b7122d659a3ed53de95241e74125f030c8e06f375216b8618e57effe5f19de1ef08
6
+ metadata.gz: 8f5079be650d4c3af4f7cf786e531a114f272bf777bc7f3c71dec98955bbcadb85676d4b96384eef2ded67666f80dc0957f628e5565f4657ca5d288ba0d5c8dd
7
+ data.tar.gz: b88543357bc283cd08a8214e56e4bd6f3172293e46e2ddcab93aca4bf2197e7187c08e0ed6a3e7924b82504605622563f6de3c2a71a6ee7d7ff832a5f7f9165c
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2015 GitHub, Inc
3
+ Copyright (c) 2016 GitHub, Inc
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,3 +1,8 @@
1
+ # Copyright (C) the Rugged contributors. All rights reserved.
2
+ #
3
+ # This file is part of Rugged, distributed under the MIT license.
4
+ # For full terms see the included LICENSE file.
5
+
1
6
  require 'mkmf'
2
7
 
3
8
  RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
@@ -67,7 +72,9 @@ else
67
72
  Dir.mkdir("build") if !Dir.exists?("build")
68
73
 
69
74
  Dir.chdir("build") do
70
- sys("cmake .. -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo -G \"Unix Makefiles\"")
75
+ # On Windows, Ruby-DevKit is MSYS-based, so ensure to use MSYS Makefiles.
76
+ generator = "-G \"MSYS Makefiles\"" if windows?
77
+ sys("cmake .. -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo #{generator}")
71
78
  sys(MAKE)
72
79
 
73
80
  # "normal" libraries (and libgit2 builds) get all these when they build but we're doing it
@@ -75,7 +82,7 @@ else
75
82
  # in $LIBS or the final linking stage won't pick them up
76
83
  if windows?
77
84
  $LDFLAGS << " " + "-L#{Dir.pwd}/deps/winhttp"
78
- $LIBS << " -lwinhttp -lcrypt32 -lrpcrt4 -lole32"
85
+ $LIBS << " -lwinhttp -lcrypt32 -lrpcrt4 -lole32 -lz"
79
86
  else
80
87
  pcfile = File.join(LIBGIT2_DIR, "build", "libgit2.pc")
81
88
  $LDFLAGS << " " + `pkg-config --libs --static #{pcfile}`.strip
data/ext/rugged/rugged.c CHANGED
@@ -1,25 +1,8 @@
1
1
  /*
2
- * The MIT License
2
+ * Copyright (C) the Rugged contributors. All rights reserved.
3
3
  *
4
- * Copyright (c) 2014 GitHub, Inc
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- * THE SOFTWARE.
4
+ * This file is part of Rugged, distributed under the MIT license.
5
+ * For full terms see the included LICENSE file.
23
6
  */
24
7
 
25
8
  #include "rugged.h"
@@ -181,7 +164,7 @@ static VALUE rb_git_raw_to_hex(VALUE self, VALUE raw)
181
164
  git_oid_fromraw(&oid, (const unsigned char *)RSTRING_PTR(raw));
182
165
  git_oid_fmt(out, &oid);
183
166
 
184
- return rb_str_new(out, 40);
167
+ return rb_usascii_str_new(out, 40);
185
168
  }
186
169
 
187
170
  /*
@@ -428,6 +411,87 @@ void rugged_rb_ary_to_strarray(VALUE rb_array, git_strarray *str_array)
428
411
  }
429
412
  }
430
413
 
414
+ void rugged_parse_merge_file_options(git_merge_file_options *opts, VALUE rb_options)
415
+ {
416
+ VALUE rb_value;
417
+
418
+ Check_Type(rb_options, T_HASH);
419
+
420
+ rb_value = rb_hash_aref(rb_options, CSTR2SYM("ancestor_label"));
421
+ if (!NIL_P(rb_value)) {
422
+ Check_Type(rb_value, T_STRING);
423
+ opts->ancestor_label = StringValueCStr(rb_value);
424
+ }
425
+
426
+ rb_value = rb_hash_aref(rb_options, CSTR2SYM("our_label"));
427
+ if (!NIL_P(rb_value)) {
428
+ Check_Type(rb_value, T_STRING);
429
+ opts->our_label = StringValueCStr(rb_value);
430
+ }
431
+
432
+ rb_value = rb_hash_aref(rb_options, CSTR2SYM("their_label"));
433
+ if (!NIL_P(rb_value)) {
434
+ Check_Type(rb_value, T_STRING);
435
+ opts->their_label = StringValueCStr(rb_value);
436
+ }
437
+
438
+ rb_value = rb_hash_aref(rb_options, CSTR2SYM("favor"));
439
+ if (!NIL_P(rb_value)) {
440
+ ID id_favor;
441
+
442
+ Check_Type(rb_value, T_SYMBOL);
443
+ id_favor = SYM2ID(rb_value);
444
+
445
+ if (id_favor == rb_intern("normal")) {
446
+ opts->favor = GIT_MERGE_FILE_FAVOR_NORMAL;
447
+ } else if (id_favor == rb_intern("ours")) {
448
+ opts->favor = GIT_MERGE_FILE_FAVOR_OURS;
449
+ } else if (id_favor == rb_intern("theirs")) {
450
+ opts->favor = GIT_MERGE_FILE_FAVOR_THEIRS;
451
+ } else if (id_favor == rb_intern("union")) {
452
+ opts->favor = GIT_MERGE_FILE_FAVOR_UNION;
453
+ } else {
454
+ rb_raise(rb_eTypeError,
455
+ "Invalid favor mode. Expected `:normal`, `:ours`, `:theirs` or `:union`");
456
+ }
457
+ }
458
+
459
+ rb_value = rb_hash_aref(rb_options, CSTR2SYM("style"));
460
+ if (!NIL_P(rb_value)) {
461
+ ID id_style;
462
+
463
+ Check_Type(rb_value, T_SYMBOL);
464
+ id_style = SYM2ID(rb_value);
465
+
466
+ if (id_style == rb_intern("standard")) {
467
+ opts->flags |= GIT_MERGE_FILE_STYLE_MERGE;
468
+ } else if (id_style == rb_intern("diff3")) {
469
+ opts->flags |= GIT_MERGE_FILE_STYLE_DIFF3;
470
+ } else {
471
+ rb_raise(rb_eTypeError,
472
+ "Invalid style mode. Expected `:standard`, or `:diff3`");
473
+ }
474
+ } else {
475
+ opts->flags |= GIT_MERGE_FILE_STYLE_MERGE;
476
+ }
477
+
478
+ if (RTEST(rb_hash_aref(rb_options, CSTR2SYM("simplify")))) {
479
+ opts->flags |= GIT_MERGE_FILE_SIMPLIFY_ALNUM;
480
+ }
481
+ }
482
+
483
+ VALUE rb_merge_file_result_fromC(const git_merge_file_result *result)
484
+ {
485
+ VALUE rb_result = rb_hash_new();
486
+
487
+ rb_hash_aset(rb_result, CSTR2SYM("automergeable"), result->automergeable ? Qtrue : Qfalse);
488
+ rb_hash_aset(rb_result, CSTR2SYM("path"), result->path ? rb_str_new_utf8(result->path) : Qnil);
489
+ rb_hash_aset(rb_result, CSTR2SYM("filemode"), INT2FIX(result->mode));
490
+ rb_hash_aset(rb_result, CSTR2SYM("data"), rb_str_new(result->ptr, result->len));
491
+
492
+ return rb_result;
493
+ }
494
+
431
495
  void Init_rugged(void)
432
496
  {
433
497
  rb_mRugged = rb_define_module("Rugged");
data/ext/rugged/rugged.h CHANGED
@@ -1,25 +1,8 @@
1
1
  /*
2
- * The MIT License
2
+ * Copyright (C) the Rugged contributors. All rights reserved.
3
3
  *
4
- * Copyright (c) 2014 GitHub, Inc
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- * THE SOFTWARE.
4
+ * This file is part of Rugged, distributed under the MIT license.
5
+ * For full terms see the included LICENSE file.
23
6
  */
24
7
 
25
8
  #ifndef __H_RUGGED_BINDINGS__
@@ -96,10 +79,12 @@ VALUE rugged_diff_hunk_new(VALUE owner, size_t hunk_idx, const git_diff_hunk *hu
96
79
  VALUE rugged_diff_line_new(const git_diff_line *line);
97
80
  VALUE rugged_remote_new(VALUE owner, git_remote *remote);
98
81
  VALUE rb_git_delta_file_fromC(const git_diff_file *file);
82
+ VALUE rb_merge_file_result_fromC(const git_merge_file_result *results);
99
83
 
100
84
  void rugged_parse_diff_options(git_diff_options *opts, VALUE rb_options);
101
85
  void rugged_parse_merge_options(git_merge_options *opts, VALUE rb_options);
102
86
  void rugged_parse_checkout_options(git_checkout_options *opts, VALUE rb_options);
87
+ void rugged_parse_merge_file_options(git_merge_file_options *opts, VALUE rb_options);
103
88
 
104
89
  void rugged_cred_extract(git_cred **cred, int allowed_types, VALUE rb_credential);
105
90
 
@@ -157,6 +142,7 @@ struct rugged_remote_cb_payload
157
142
  VALUE transfer_progress;
158
143
  VALUE update_tips;
159
144
  VALUE credentials;
145
+ VALUE certificate_check;
160
146
  VALUE result;
161
147
  int exception;
162
148
  };
@@ -176,7 +162,7 @@ static inline VALUE rugged_create_oid(const git_oid *oid)
176
162
  {
177
163
  char out[40];
178
164
  git_oid_fmt(out, oid);
179
- return rb_str_new(out, 40);
165
+ return rb_usascii_str_new(out, 40);
180
166
  }
181
167
 
182
168
 
@@ -1,25 +1,8 @@
1
1
  /*
2
- * The MIT License
2
+ * Copyright (C) the Rugged contributors. All rights reserved.
3
3
  *
4
- * Copyright (c) 2014 GitHub, Inc
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- * THE SOFTWARE.
4
+ * This file is part of Rugged, distributed under the MIT license.
5
+ * For full terms see the included LICENSE file.
23
6
  */
24
7
 
25
8
  #include "rugged.h"
@@ -1,25 +1,8 @@
1
1
  /*
2
- * The MIT License
2
+ * Copyright (C) the Rugged contributors. All rights reserved.
3
3
  *
4
- * Copyright (c) 2014 GitHub, Inc
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- * THE SOFTWARE.
4
+ * This file is part of Rugged, distributed under the MIT license.
5
+ * For full terms see the included LICENSE file.
23
6
  */
24
7
 
25
8
  #include "rugged.h"
@@ -125,19 +108,19 @@ static void rugged_parse_blame_options(git_blame_options *opts, git_repository *
125
108
  * The last line in the file to blame. Defaults to the last line in
126
109
  * the file.
127
110
  *
128
- * :track_copies_same_file
111
+ * :track_copies_same_file ::
129
112
  * If this value is +true+, lines that have moved within a file will be
130
113
  * tracked (like `git blame -M`).
131
114
  *
132
- * :track_copies_same_commit_moves
115
+ * :track_copies_same_commit_moves ::
133
116
  * If this value is +true+, lines that have moved across files in the same
134
117
  * commit will be tracked (like `git blame -C`).
135
118
  *
136
- * :track_copies_same_commit_copies
119
+ * :track_copies_same_commit_copies ::
137
120
  * If this value is +true+, lines that have been copied from another file
138
121
  * that exists in the same commit will be tracked (like `git blame -CC`).
139
122
  *
140
- * :track_copies_any_commit_copies
123
+ * :track_copies_any_commit_copies ::
141
124
  * If this value is +true+, lines that have been copied from another file
142
125
  * that exists in *any* commit will be tracked (like `git blame -CCC`).
143
126
  *
@@ -1,25 +1,8 @@
1
1
  /*
2
- * The MIT License
3
- *
4
- * Copyright (c) 2014 GitHub, Inc
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- * THE SOFTWARE.
2
+ * Copyright (C) the Rugged contributors. All rights reserved.
3
+ *
4
+ * This file is part of Rugged, distributed under the MIT license.
5
+ * For full terms see the included LICENSE file.
23
6
  */
24
7
 
25
8
  #include "rugged.h"
@@ -231,30 +214,6 @@ static VALUE rb_read_check(VALUE pointer) {
231
214
  return rb_buffer;
232
215
  }
233
216
 
234
- static int cb_blob__get__chunk(char *content, size_t max_length, void *data)
235
- {
236
- VALUE rb_buffer, rb_args[2];
237
- size_t str_len, safe_len;
238
- struct rugged_cb_payload *payload = data;
239
-
240
- rb_args[0] = payload->rb_data;
241
- rb_args[1] = INT2FIX(max_length);
242
-
243
- rb_buffer = rb_protect(rb_read_check, (VALUE)rb_args, &payload->exception);
244
-
245
- if (payload->exception)
246
- return GIT_ERROR;
247
-
248
- if (NIL_P(rb_buffer))
249
- return 0;
250
-
251
- str_len = (size_t)RSTRING_LEN(rb_buffer);
252
- safe_len = str_len > max_length ? max_length : str_len;
253
- memcpy(content, StringValuePtr(rb_buffer), safe_len);
254
-
255
- return (int)safe_len;
256
- }
257
-
258
217
  /*
259
218
  * call-seq:
260
219
  * Blob.from_io(repository, io [, hint_path]) -> oid
@@ -282,11 +241,10 @@ static int cb_blob__get__chunk(char *content, size_t max_length, void *data)
282
241
  */
283
242
  static VALUE rb_git_blob_from_io(int argc, VALUE *argv, VALUE klass)
284
243
  {
285
- VALUE rb_repo, rb_io, rb_hint_path;
286
- struct rugged_cb_payload payload;
244
+ VALUE rb_repo, rb_io, rb_hint_path, rb_buffer, rb_read_args[2];
287
245
  const char * hint_path = NULL;
288
-
289
- int error;
246
+ git_writestream *stream;
247
+ int error = 0, exception = 0, max_length = 4096;
290
248
  git_oid oid;
291
249
  git_repository *repo;
292
250
 
@@ -300,18 +258,34 @@ static VALUE rb_git_blob_from_io(int argc, VALUE *argv, VALUE klass)
300
258
  hint_path = StringValueCStr(rb_hint_path);
301
259
  }
302
260
 
303
- payload.exception = 0;
304
- payload.rb_data = rb_io;
261
+ error = git_blob_create_fromstream(&stream, repo, hint_path);
262
+ if (error)
263
+ goto cleanup;
264
+
265
+ rb_read_args[0] = rb_io;
266
+ rb_read_args[1] = INT2FIX(max_length);
267
+
268
+ do {
269
+ rb_buffer = rb_protect(rb_read_check, (VALUE)rb_read_args, &exception);
305
270
 
306
- error = git_blob_create_fromchunks(
307
- &oid,
308
- repo,
309
- hint_path,
310
- cb_blob__get__chunk,
311
- (void *)&payload);
271
+ if (exception)
272
+ goto cleanup;
273
+
274
+ if (NIL_P(rb_buffer))
275
+ break;
276
+
277
+ error = stream->write(stream, RSTRING_PTR(rb_buffer), RSTRING_LEN(rb_buffer));
278
+ if (error)
279
+ goto cleanup;
280
+ } while (RSTRING_LEN(rb_buffer) == max_length);
281
+
282
+ error = git_blob_create_fromstream_commit(&oid, stream);
283
+
284
+ cleanup:
285
+
286
+ if (exception)
287
+ rb_jump_tag(exception);
312
288
 
313
- if (payload.exception)
314
- rb_jump_tag(payload.exception);
315
289
  rugged_exception_check(error);
316
290
 
317
291
  return rugged_create_oid(&oid);
@@ -560,6 +534,108 @@ static VALUE rb_git_blob_to_buffer(int argc, VALUE *argv, VALUE self)
560
534
  return rb_ret;
561
535
  }
562
536
 
537
+ #define RUGGED_MERGE_FILE_INPUT_INIT { GIT_MERGE_FILE_INPUT_INIT }
538
+
539
+ typedef struct {
540
+ git_merge_file_input parent;
541
+ int has_id;
542
+ git_oid id;
543
+ } rugged_merge_file_input;
544
+
545
+ static void rugged_parse_merge_file_input(rugged_merge_file_input *input, git_repository *repo, VALUE rb_input)
546
+ {
547
+ VALUE rb_value;
548
+
549
+ Check_Type(rb_input, T_HASH);
550
+
551
+ if (!NIL_P(rb_value = rb_hash_aref(rb_input, CSTR2SYM("content")))) {
552
+ input->parent.ptr = RSTRING_PTR(rb_value);
553
+ input->parent.size = RSTRING_LEN(rb_value);
554
+ } else if (!NIL_P(rb_value = rb_hash_aref(rb_input, CSTR2SYM("oid")))) {
555
+ if (!repo)
556
+ rb_raise(rb_eArgError, "Rugged repository is required when file input is `:oid`.");
557
+
558
+ rugged_exception_check(git_oid_fromstr(&input->id, RSTRING_PTR(rb_value)));
559
+ input->has_id = 1;
560
+ } else {
561
+ rb_raise(rb_eArgError, "File input must have `:content` or `:oid`.");
562
+ }
563
+
564
+ rb_value = rb_hash_aref(rb_input, CSTR2SYM("filemode"));
565
+ if (!NIL_P(rb_value))
566
+ input->parent.mode = FIX2UINT(rb_value);
567
+
568
+ rb_value = rb_hash_aref(rb_input, CSTR2SYM("path"));
569
+ if (!NIL_P(rb_value)) {
570
+ Check_Type(rb_value, T_STRING);
571
+ input->parent.path = RSTRING_PTR(rb_value);
572
+ }
573
+ }
574
+
575
+ static int rugged_load_merge_file_input(git_blob **out, git_repository *repo, rugged_merge_file_input *input)
576
+ {
577
+ int error;
578
+
579
+ if (!input->has_id)
580
+ return 0;
581
+
582
+ if ((error = git_blob_lookup(out, repo, &input->id)) < 0)
583
+ return error;
584
+
585
+ input->parent.ptr = git_blob_rawcontent(*out);
586
+ input->parent.size = git_blob_rawsize(*out);
587
+
588
+ return 0;
589
+ }
590
+
591
+ static VALUE rb_git_blob_merge_files(int argc, VALUE *argv, VALUE klass)
592
+ {
593
+ VALUE rb_repo, rb_ancestor, rb_ours, rb_theirs, rb_options, rb_result = Qnil;
594
+
595
+ git_repository *repo = NULL;
596
+ rugged_merge_file_input ancestor = RUGGED_MERGE_FILE_INPUT_INIT,
597
+ ours = RUGGED_MERGE_FILE_INPUT_INIT,
598
+ theirs = RUGGED_MERGE_FILE_INPUT_INIT;
599
+ git_blob *ancestor_blob = NULL, *our_blob = NULL, *their_blob = NULL;
600
+ git_merge_file_options opts = GIT_MERGE_FILE_OPTIONS_INIT;
601
+ git_merge_file_result result = {0};
602
+ int error;
603
+
604
+ rb_scan_args(argc, argv, "41", &rb_repo, &rb_ancestor, &rb_ours, &rb_theirs, &rb_options);
605
+
606
+ if (!NIL_P(rb_repo)) {
607
+ rugged_check_repo(rb_repo);
608
+ Data_Get_Struct(rb_repo, git_repository, repo);
609
+ }
610
+
611
+ if (!NIL_P(rb_options))
612
+ rugged_parse_merge_file_options(&opts, rb_options);
613
+
614
+ if (!NIL_P(rb_ancestor))
615
+ rugged_parse_merge_file_input(&ancestor, repo, rb_ancestor);
616
+ if (!NIL_P(rb_ours))
617
+ rugged_parse_merge_file_input(&ours, repo, rb_ours);
618
+ if (!NIL_P(rb_theirs))
619
+ rugged_parse_merge_file_input(&theirs, repo, rb_theirs);
620
+
621
+ if ((error = rugged_load_merge_file_input(&ancestor_blob, repo, &ancestor)) < 0 ||
622
+ (error = rugged_load_merge_file_input(&our_blob, repo, &ours)) < 0 ||
623
+ (error = rugged_load_merge_file_input(&their_blob, repo, &theirs)) < 0 ||
624
+ (error = git_merge_file(&result, &ancestor.parent, &ours.parent, &theirs.parent, &opts)) < 0)
625
+ goto done;
626
+
627
+ rb_result = rb_merge_file_result_fromC(&result);
628
+
629
+ done:
630
+ git_blob_free(ancestor_blob);
631
+ git_blob_free(our_blob);
632
+ git_blob_free(their_blob);
633
+ git_merge_file_result_free(&result);
634
+
635
+ rugged_exception_check(error);
636
+ return rb_result;
637
+ }
638
+
563
639
  static VALUE rb_git_blob_sig_new(int argc, VALUE *argv, VALUE klass)
564
640
  {
565
641
  int error, opts = 0;
@@ -631,6 +707,7 @@ void Init_rugged_blob(void)
631
707
  rb_define_singleton_method(rb_cRuggedBlob, "from_io", rb_git_blob_from_io, -1);
632
708
 
633
709
  rb_define_singleton_method(rb_cRuggedBlob, "to_buffer", rb_git_blob_to_buffer, -1);
710
+ rb_define_singleton_method(rb_cRuggedBlob, "merge_files", rb_git_blob_merge_files, -1);
634
711
 
635
712
  rb_cRuggedBlobSig = rb_define_class_under(rb_cRuggedBlob, "HashSignature", rb_cObject);
636
713
  rb_define_singleton_method(rb_cRuggedBlobSig, "new", rb_git_blob_sig_new, -1);
@@ -1,25 +1,8 @@
1
1
  /*
2
- * The MIT License
2
+ * Copyright (C) the Rugged contributors. All rights reserved.
3
3
  *
4
- * Copyright (c) 2014 GitHub, Inc
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- * THE SOFTWARE.
4
+ * This file is part of Rugged, distributed under the MIT license.
5
+ * For full terms see the included LICENSE file.
23
6
  */
24
7
 
25
8
  #include "rugged.h"
@@ -1,25 +1,8 @@
1
1
  /*
2
- * The MIT License
2
+ * Copyright (C) the Rugged contributors. All rights reserved.
3
3
  *
4
- * Copyright (c) 2014 GitHub, Inc
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- * THE SOFTWARE.
4
+ * This file is part of Rugged, distributed under the MIT license.
5
+ * For full terms see the included LICENSE file.
23
6
  */
24
7
 
25
8
  #include "rugged.h"