rugged 0.25.0b2 → 0.25.0b3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/ext/rugged/extconf.rb +3 -1
  4. data/ext/rugged/rugged.c +1 -1
  5. data/ext/rugged/rugged.h +1 -1
  6. data/ext/rugged/rugged_blob.c +29 -38
  7. data/ext/rugged/rugged_commit.c +215 -78
  8. data/ext/rugged/rugged_rebase.c +18 -11
  9. data/ext/rugged/rugged_remote.c +2 -2
  10. data/ext/rugged/rugged_tree.c +132 -0
  11. data/lib/rugged/version.rb +1 -1
  12. data/vendor/libgit2/CMakeLists.txt +11 -3
  13. data/vendor/libgit2/include/git2.h +1 -0
  14. data/vendor/libgit2/include/git2/blob.h +39 -28
  15. data/vendor/libgit2/include/git2/commit.h +30 -0
  16. data/vendor/libgit2/include/git2/common.h +16 -1
  17. data/vendor/libgit2/include/git2/merge.h +10 -1
  18. data/vendor/libgit2/include/git2/proxy.h +92 -0
  19. data/vendor/libgit2/include/git2/refs.h +11 -0
  20. data/vendor/libgit2/include/git2/remote.h +17 -4
  21. data/vendor/libgit2/include/git2/signature.h +13 -0
  22. data/vendor/libgit2/include/git2/sys/merge.h +177 -0
  23. data/vendor/libgit2/include/git2/sys/remote.h +16 -0
  24. data/vendor/libgit2/include/git2/sys/stream.h +2 -1
  25. data/vendor/libgit2/include/git2/sys/transport.h +3 -1
  26. data/vendor/libgit2/include/git2/tag.h +9 -0
  27. data/vendor/libgit2/include/git2/tree.h +55 -0
  28. data/vendor/libgit2/src/annotated_commit.c +99 -80
  29. data/vendor/libgit2/src/annotated_commit.h +5 -2
  30. data/vendor/libgit2/src/array.h +40 -0
  31. data/vendor/libgit2/src/blame.c +8 -3
  32. data/vendor/libgit2/src/blame_git.c +2 -1
  33. data/vendor/libgit2/src/blob.c +71 -39
  34. data/vendor/libgit2/src/branch.c +2 -1
  35. data/vendor/libgit2/src/checkout.c +66 -42
  36. data/vendor/libgit2/src/commit.c +67 -3
  37. data/vendor/libgit2/src/config_cache.c +2 -1
  38. data/vendor/libgit2/src/config_file.c +32 -27
  39. data/vendor/libgit2/src/curl_stream.c +89 -6
  40. data/vendor/libgit2/src/delta-apply.c +36 -5
  41. data/vendor/libgit2/src/delta-apply.h +12 -0
  42. data/vendor/libgit2/src/describe.c +3 -2
  43. data/vendor/libgit2/src/diff.c +13 -20
  44. data/vendor/libgit2/src/diff_tform.c +5 -3
  45. data/vendor/libgit2/src/filebuf.c +12 -2
  46. data/vendor/libgit2/src/filebuf.h +1 -0
  47. data/vendor/libgit2/src/fnmatch.c +18 -5
  48. data/vendor/libgit2/src/global.c +18 -0
  49. data/vendor/libgit2/src/global.h +1 -0
  50. data/vendor/libgit2/src/ignore.c +11 -3
  51. data/vendor/libgit2/src/index.c +11 -5
  52. data/vendor/libgit2/src/indexer.c +11 -7
  53. data/vendor/libgit2/src/iterator.c +1575 -1468
  54. data/vendor/libgit2/src/iterator.h +52 -69
  55. data/vendor/libgit2/src/merge.c +160 -63
  56. data/vendor/libgit2/src/merge.h +61 -2
  57. data/vendor/libgit2/src/merge_driver.c +397 -0
  58. data/vendor/libgit2/src/merge_driver.h +60 -0
  59. data/vendor/libgit2/src/merge_file.c +11 -49
  60. data/vendor/libgit2/src/netops.c +12 -10
  61. data/vendor/libgit2/src/object.c +3 -6
  62. data/vendor/libgit2/src/object_api.c +19 -1
  63. data/vendor/libgit2/src/odb_loose.c +1 -1
  64. data/vendor/libgit2/src/openssl_stream.c +16 -3
  65. data/vendor/libgit2/src/pack-objects.c +3 -1
  66. data/vendor/libgit2/src/pack.c +5 -9
  67. data/vendor/libgit2/src/path.c +14 -0
  68. data/vendor/libgit2/src/path.h +12 -0
  69. data/vendor/libgit2/src/pathspec.c +1 -1
  70. data/vendor/libgit2/src/posix.c +7 -0
  71. data/vendor/libgit2/src/posix.h +1 -0
  72. data/vendor/libgit2/src/proxy.c +32 -0
  73. data/vendor/libgit2/src/proxy.h +14 -0
  74. data/vendor/libgit2/src/push.c +7 -7
  75. data/vendor/libgit2/src/rebase.c +61 -31
  76. data/vendor/libgit2/src/refdb_fs.c +1 -0
  77. data/vendor/libgit2/src/refs.c +16 -1
  78. data/vendor/libgit2/src/remote.c +20 -6
  79. data/vendor/libgit2/src/repository.c +1 -1
  80. data/vendor/libgit2/src/reset.c +1 -1
  81. data/vendor/libgit2/src/settings.c +23 -1
  82. data/vendor/libgit2/src/signature.c +26 -1
  83. data/vendor/libgit2/src/stransport_stream.c +5 -2
  84. data/vendor/libgit2/src/stream.h +2 -2
  85. data/vendor/libgit2/src/submodule.c +3 -2
  86. data/vendor/libgit2/src/tag.c +8 -2
  87. data/vendor/libgit2/src/transports/http.c +32 -9
  88. data/vendor/libgit2/src/transports/local.c +4 -1
  89. data/vendor/libgit2/src/transports/smart.c +6 -0
  90. data/vendor/libgit2/src/transports/smart.h +1 -0
  91. data/vendor/libgit2/src/transports/smart_protocol.c +61 -17
  92. data/vendor/libgit2/src/transports/winhttp.c +130 -11
  93. data/vendor/libgit2/src/tree.c +329 -98
  94. data/vendor/libgit2/src/tree.h +4 -5
  95. data/vendor/libgit2/src/unix/map.c +5 -0
  96. data/vendor/libgit2/src/win32/map.c +24 -5
  97. data/vendor/libgit2/src/xdiff/xprepare.c +2 -1
  98. metadata +10 -4
  99. data/vendor/libgit2/Makefile.embed +0 -60
@@ -128,7 +128,7 @@ static int rugged_get_annotated_commit(
128
128
 
129
129
  /*
130
130
  * call-seq:
131
- * Rebase.new(repo, branch, upstream[, onto][, options]) -> Rebase
131
+ * Rebase.new(repo, branch, upstream[, onto][, options]) -> new_rebase
132
132
  *
133
133
  * Initialize a new rebase operation. This will put +repo+ in a
134
134
  * rebase state.
@@ -148,8 +148,8 @@ static int rugged_get_annotated_commit(
148
148
  *
149
149
  * :inmemory ::
150
150
  * Do not put the repository in a rebase state but perform all the
151
- * operations in-memory. In case of conflicts, the RebaseOperation
152
- * returned by #next will contain the index which can be used to
151
+ * operations in-memory. In case of conflicts, the rebase operation
152
+ * Hash returned by #next will contain the index which can be used to
153
153
  * resolve conflicts.
154
154
  *
155
155
  * :rewrite_notes_ref ::
@@ -189,11 +189,10 @@ cleanup:
189
189
  git_annotated_commit_free(upstream);
190
190
  git_annotated_commit_free(onto);
191
191
 
192
- if (error) {
193
- rugged_exception_check(error);
194
- } else if (exception) {
192
+ if (exception)
195
193
  rb_jump_tag(exception);
196
- }
194
+
195
+ rugged_exception_check(error);
197
196
 
198
197
  return rugged_rebase_new(klass, rb_repo, rebase);
199
198
  }
@@ -252,7 +251,7 @@ static VALUE rb_git_rebase_next(VALUE self)
252
251
  }
253
252
  /*
254
253
  * call-seq:
255
- * Rebase.inmemory_index -> Index
254
+ * rebase.inmemory_index -> index
256
255
  *
257
256
  * Gets the index produced by the last operation, which is the result
258
257
  * of +next+ and which will be committed by the next invocation of
@@ -276,12 +275,15 @@ static VALUE rb_git_rebase_inmemory_index(VALUE self)
276
275
 
277
276
  /*
278
277
  * call-seq:
279
- * Rebase.commit(author = nil, committer, message = nil)
278
+ * rebase.commit(author: nil, committer: committer, message: nil) -> oid or nil
280
279
  *
281
280
  * Commit the current patch. Any conflicts must have been resolved.
282
281
  *
283
282
  * If +author+ is +nil+, the existing author for the commit will be
284
283
  * used. If +message+ is +nil+, the existing message will be used.
284
+ *
285
+ * Returns a string containing the oid of the newly created commit,
286
+ * or +nil+ if there are no changes to be committed.
285
287
  */
286
288
  static VALUE rb_git_rebase_commit(int argc, VALUE *argv, VALUE self)
287
289
  {
@@ -318,6 +320,11 @@ static VALUE rb_git_rebase_commit(int argc, VALUE *argv, VALUE self)
318
320
  git_signature_free(author);
319
321
  git_signature_free(committer);
320
322
 
323
+ if (error == GIT_EAPPLIED) {
324
+ giterr_clear();
325
+ return Qnil;
326
+ }
327
+
321
328
  rugged_exception_check(error);
322
329
 
323
330
  return rugged_create_oid(&id);
@@ -325,7 +332,7 @@ static VALUE rb_git_rebase_commit(int argc, VALUE *argv, VALUE self)
325
332
 
326
333
  /*
327
334
  * call-seq:
328
- * Rebase.abort()
335
+ * rebase.abort -> nil
329
336
  *
330
337
  * Abort the rebase currently in process, resetting the repository
331
338
  * and working directory to their state before the rebase began.
@@ -342,7 +349,7 @@ static VALUE rb_git_rebase_abort(VALUE self)
342
349
 
343
350
  /*
344
351
  * call-seq:
345
- * Rebase.finish()
352
+ * rebase.finish -> nil
346
353
  *
347
354
  * Finish the rebase currently in progress once all patches have been
348
355
  * applied.
@@ -291,7 +291,7 @@ static VALUE rb_git_remote_ls(int argc, VALUE *argv, VALUE self)
291
291
  rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
292
292
  init_custom_headers(rb_options, &custom_headers);
293
293
 
294
- if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, &callbacks, &custom_headers)) ||
294
+ if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, &callbacks, NULL, &custom_headers)) ||
295
295
  (error = git_remote_ls(&heads, &heads_len, remote)))
296
296
  goto cleanup;
297
297
 
@@ -491,7 +491,7 @@ static VALUE rb_git_remote_check_connection(int argc, VALUE *argv, VALUE self)
491
491
  rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
492
492
  init_custom_headers(rb_options, &custom_headers);
493
493
 
494
- error = git_remote_connect(remote, direction, &callbacks, &custom_headers);
494
+ error = git_remote_connect(remote, direction, &callbacks, NULL, &custom_headers);
495
495
  git_remote_disconnect(remote);
496
496
 
497
497
  git_strarray_free(&custom_headers);
@@ -702,6 +702,136 @@ static VALUE rb_git_tree_merge(int argc, VALUE *argv, VALUE self)
702
702
  return rugged_index_new(rb_cRuggedIndex, rb_repo, index);
703
703
  }
704
704
 
705
+ static git_oid empty_tree = {{ 0x4b, 0x82, 0x5d, 0xc6, 0x42, 0xcb, 0x6e, 0xb9, 0xa0, 0x60,
706
+ 0xe5, 0x4b, 0xf8, 0xd6, 0x92, 0x88, 0xfb, 0xee, 0x49, 0x04 }};
707
+
708
+ /*
709
+ * call-seq:
710
+ * Tree.empty(repo) -> tree
711
+ *
712
+ * Look up the empty tree in the given repository +repo+. The empty
713
+ * tree's id is hard-coded to exist in a repository.
714
+ *
715
+ * Returns a new instance of the empty tree.
716
+ */
717
+ static VALUE rb_git_tree_empty(VALUE self, VALUE rb_repo)
718
+ {
719
+ git_repository *repo;
720
+ git_tree *tree;
721
+
722
+ rugged_check_repo(rb_repo);
723
+ Data_Get_Struct(rb_repo, git_repository, repo);
724
+
725
+ rugged_exception_check(git_tree_lookup(&tree, repo, &empty_tree));
726
+
727
+ return rugged_object_new(rb_repo, (git_object *) tree);
728
+ }
729
+
730
+ /**
731
+ * Parse the updates and convert them into libgit2 ones. They will be
732
+ * heap-allocated and returned in 'out'. The strings will also be
733
+ * heap-allocated and will be stored in 'strings'.
734
+ */
735
+ static void parse_tree_updates(git_tree_update **out, int *nupdates_out, VALUE rb_updates)
736
+ {
737
+ int i, nupdates;
738
+ git_tree_update *updates;
739
+
740
+ Check_Type(rb_updates, T_ARRAY);
741
+ nupdates = RARRAY_LEN(rb_updates);
742
+ updates = xcalloc(nupdates, sizeof(git_tree_update));
743
+
744
+ for (i = 0; i < nupdates; i++) {
745
+ VALUE rb_update = rb_ary_entry(rb_updates, i);
746
+ VALUE rb_action, rb_oid, rb_filemode, rb_path;
747
+ ID action;
748
+ git_tree_update *update = &updates[i];
749
+
750
+ if (!RB_TYPE_P(rb_update, T_HASH))
751
+ goto on_error;
752
+
753
+ rb_action = rb_hash_aref(rb_update, CSTR2SYM("action"));
754
+ rb_oid = rb_hash_aref(rb_update, CSTR2SYM("oid"));
755
+ rb_filemode = rb_hash_aref(rb_update, CSTR2SYM("filemode"));
756
+ rb_path = rb_hash_aref(rb_update, CSTR2SYM("path"));
757
+
758
+ if (!SYMBOL_P(rb_action) || !RB_TYPE_P(rb_path, T_STRING))
759
+ goto on_error;
760
+
761
+ update->path = StringValueCStr(rb_path);
762
+
763
+ action = SYM2ID(rb_action);
764
+
765
+ if (action == rb_intern("upsert")) {
766
+ if (!RB_TYPE_P(rb_oid, T_STRING) ||!RB_TYPE_P(rb_filemode, T_FIXNUM))
767
+ goto on_error;
768
+
769
+ update->action = GIT_TREE_UPDATE_UPSERT;
770
+ update->filemode = NUM2INT(rb_filemode);
771
+
772
+ if (git_oid_fromstr(&update->id, StringValueCStr(rb_oid)) < 0)
773
+ goto on_error;
774
+ } else if (action == rb_intern("remove")) {
775
+ update->action = GIT_TREE_UPDATE_REMOVE;
776
+ } else {
777
+ goto on_error;
778
+ }
779
+ }
780
+
781
+ *out = updates;
782
+ *nupdates_out = nupdates;
783
+
784
+ return;
785
+
786
+ on_error:
787
+ xfree(updates);
788
+ rb_raise(rb_eTypeError, "Invalid type for tree update object");
789
+ }
790
+
791
+ /*
792
+ * call-seq:
793
+ * tree.update(updates)
794
+ *
795
+ * Create a new Rugged::Tree based on the curent one by applying the
796
+ * changes described in +updates+.
797
+ *
798
+ * The updates are given as a list of +Hash+ containing:
799
+ *
800
+ * :action ::
801
+ * +:upsert+ or +:remove+ to add/insert an entry, or to remove it resp.
802
+ *
803
+ * :oid ::
804
+ * The +oid+ of the entry. This is ignored for removals.
805
+ *
806
+ * :filemode ::
807
+ * The octal filemode for the entry. This is ignored for remvals.
808
+ *
809
+ * :path ::
810
+ * The path of the entry. This may contain slashes and the
811
+ * intermediate trees will be created.
812
+ *
813
+ */
814
+ static VALUE rb_git_tree_update(VALUE self, VALUE rb_updates)
815
+ {
816
+ git_repository *repo;
817
+ git_tree *tree = NULL;
818
+ git_tree_update *updates;
819
+ int nupdates, error;
820
+ git_oid id;
821
+
822
+ Data_Get_Struct(self, git_tree, tree);
823
+ repo = git_tree_owner(tree);
824
+
825
+ parse_tree_updates(&updates, &nupdates, rb_updates);
826
+
827
+ error = git_tree_create_updated(&id, repo, tree, nupdates, updates);
828
+ xfree(updates);
829
+
830
+ rugged_exception_check(error);
831
+
832
+ return rugged_create_oid(&id);
833
+ }
834
+
705
835
  static void rb_git_treebuilder_free(git_treebuilder *bld)
706
836
  {
707
837
  git_treebuilder_free(bld);
@@ -904,6 +1034,8 @@ void Init_rugged_tree(void)
904
1034
  rb_define_method(rb_cRuggedTree, "each", rb_git_tree_each, 0);
905
1035
  rb_define_method(rb_cRuggedTree, "walk", rb_git_tree_walk, 1);
906
1036
  rb_define_method(rb_cRuggedTree, "merge", rb_git_tree_merge, -1);
1037
+ rb_define_method(rb_cRuggedTree, "update", rb_git_tree_update, 1);
1038
+ rb_define_singleton_method(rb_cRuggedTree, "empty", rb_git_tree_empty, 1);
907
1039
 
908
1040
  rb_define_singleton_method(rb_cRuggedTree, "diff", rb_git_tree_diff_, -1);
909
1041
 
@@ -1,3 +1,3 @@
1
1
  module Rugged
2
- Version = VERSION = '0.25.0b2'
2
+ Version = VERSION = '0.25.0b3'
3
3
  end
@@ -161,6 +161,8 @@ FUNCTION(TARGET_OS_LIBRARIES target)
161
161
 
162
162
  IF(THREADSAFE)
163
163
  TARGET_LINK_LIBRARIES(${target} ${CMAKE_THREAD_LIBS_INIT})
164
+ LIST(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT})
165
+ SET(LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE)
164
166
  ENDIF()
165
167
  ENDFUNCTION()
166
168
 
@@ -412,7 +414,7 @@ IF (MSVC)
412
414
  # /MTd - Statically link the multithreaded debug version of the CRT
413
415
  # /MDd - Dynamically link the multithreaded debug version of the CRT
414
416
  # /RTC1 - Run time checks
415
- SET(CMAKE_C_FLAGS_DEBUG "/Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
417
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
416
418
 
417
419
  # /DNDEBUG - Disables asserts
418
420
  # /MT - Statically link the multithreaded release version of the CRT
@@ -464,7 +466,7 @@ ELSE ()
464
466
  ENDIF()
465
467
 
466
468
  IF (WIN32 AND NOT CYGWIN)
467
- SET(CMAKE_C_FLAGS_DEBUG "-D_DEBUG")
469
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
468
470
  ENDIF ()
469
471
 
470
472
  IF (MINGW) # MinGW always does PIC and complains if we tell it to
@@ -580,8 +582,10 @@ IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
580
582
  ADD_DEFINITIONS(-DGIT_ARCH_64)
581
583
  ELSEIF (CMAKE_SIZEOF_VOID_P EQUAL 4)
582
584
  ADD_DEFINITIONS(-DGIT_ARCH_32)
585
+ ELSEIF (CMAKE_SIZEOF_VOID_P)
586
+ MESSAGE(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)")
583
587
  ELSE()
584
- MESSAGE(FATAL_ERROR "Unsupported architecture")
588
+ MESSAGE(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)")
585
589
  ENDIF()
586
590
 
587
591
  # Compile and link libgit2
@@ -608,6 +612,8 @@ IF (SONAME)
608
612
  IF (LIBGIT2_FILENAME)
609
613
  ADD_DEFINITIONS(-DLIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
610
614
  SET_TARGET_PROPERTIES(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
615
+ ELSEIF (DEFINED LIBGIT2_PREFIX)
616
+ SET_TARGET_PROPERTIES(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
611
617
  ENDIF()
612
618
  ENDIF()
613
619
  STRING(REPLACE ";" " " LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS}")
@@ -686,6 +692,8 @@ IF (BUILD_CLAR)
686
692
  # Add a test target which runs the cred callback tests, to be
687
693
  # called after setting the url and user
688
694
  ADD_TEST(libgit2_clar-cred_callback libgit2_clar -v -sonline::clone::cred_callback)
695
+ ADD_TEST(libgit2_clar-proxy_credentials_in_url libgit2_clar -v -sonline::clone::proxy_credentials_in_url)
696
+ ADD_TEST(libgit2_clar-proxy_credentials_request libgit2_clar -v -sonline::clone::proxy_credentials_request)
689
697
  ENDIF ()
690
698
 
691
699
  IF (TAGS)
@@ -40,6 +40,7 @@
40
40
  #include "git2/pack.h"
41
41
  #include "git2/patch.h"
42
42
  #include "git2/pathspec.h"
43
+ #include "git2/proxy.h"
43
44
  #include "git2/rebase.h"
44
45
  #include "git2/refdb.h"
45
46
  #include "git2/reflog.h"
@@ -150,46 +150,48 @@ GIT_EXTERN(int) git_blob_create_fromworkdir(git_oid *id, git_repository *repo, c
150
150
  */
151
151
  GIT_EXTERN(int) git_blob_create_fromdisk(git_oid *id, git_repository *repo, const char *path);
152
152
 
153
-
154
- typedef int (*git_blob_chunk_cb)(char *content, size_t max_length, void *payload);
155
-
156
153
  /**
157
- * Write a loose blob to the Object Database from a
158
- * provider of chunks of data.
154
+ * Create a stream to write a new blob into the object db
155
+ *
156
+ * This function may need to buffer the data on disk and will in
157
+ * general not be the right choice if you know the size of the data
158
+ * to write. If you have data in memory, use
159
+ * `git_blob_create_frombuffer()`. If you do not, but know the size of
160
+ * the contents (and don't want/need to perform filtering), use
161
+ * `git_odb_open_wstream()`.
162
+ *
163
+ * Don't close this stream yourself but pass it to
164
+ * `git_blob_create_fromstream_commit()` to commit the write to the
165
+ * object db and get the object id.
159
166
  *
160
167
  * If the `hintpath` parameter is filled, it will be used to determine
161
168
  * what git filters should be applied to the object before it is written
162
169
  * to the object database.
163
170
  *
164
- * The implementation of the callback MUST respect the following rules:
165
- *
166
- * - `content` must be filled by the callback. The maximum number of
167
- * bytes that the buffer can accept per call is defined by the
168
- * `max_length` parameter. Allocation and freeing of the buffer will
169
- * be taken care of by libgit2.
170
- *
171
- * - The `callback` must return the number of bytes that have been
172
- * written to the `content` buffer.
173
- *
174
- * - When there is no more data to stream, `callback` should return 0.
175
- * This will prevent it from being invoked anymore.
176
- *
177
- * - If an error occurs, the callback should return a negative value.
178
- * This value will be returned to the caller.
179
- *
180
- * @param id Return the id of the written blob
171
+ * @param out the stream into which to write
181
172
  * @param repo Repository where the blob will be written.
182
173
  * This repository can be bare or not.
183
174
  * @param hintpath If not NULL, will be used to select data filters
184
175
  * to apply onto the content of the blob to be created.
185
- * @return 0 or error code (from either libgit2 or callback function)
176
+ * @return 0 or error code
186
177
  */
187
- GIT_EXTERN(int) git_blob_create_fromchunks(
188
- git_oid *id,
178
+ GIT_EXTERN(int) git_blob_create_fromstream(
179
+ git_writestream **out,
189
180
  git_repository *repo,
190
- const char *hintpath,
191
- git_blob_chunk_cb callback,
192
- void *payload);
181
+ const char *hintpath);
182
+
183
+ /**
184
+ * Close the stream and write the blob to the object db
185
+ *
186
+ * The stream will be closed and freed.
187
+ *
188
+ * @param out the id of the new blob
189
+ * @param stream the stream to close
190
+ * @return 0 or an error code
191
+ */
192
+ GIT_EXTERN(int) git_blob_create_fromstream_commit(
193
+ git_oid *out,
194
+ git_writestream *stream);
193
195
 
194
196
  /**
195
197
  * Write an in-memory buffer to the ODB as a blob
@@ -216,6 +218,15 @@ GIT_EXTERN(int) git_blob_create_frombuffer(
216
218
  */
217
219
  GIT_EXTERN(int) git_blob_is_binary(const git_blob *blob);
218
220
 
221
+ /**
222
+ * Create an in-memory copy of a blob. The copy must be explicitly
223
+ * free'd or it will leak.
224
+ *
225
+ * @param out Pointer to store the copy of the object
226
+ * @param source Original object to copy
227
+ */
228
+ GIT_EXTERN(int) git_blob_dup(git_blob **out, git_blob *source);
229
+
219
230
  /** @} */
220
231
  GIT_END_DECL
221
232
  #endif
@@ -440,6 +440,36 @@ GIT_EXTERN(int) git_commit_create_buffer(
440
440
  size_t parent_count,
441
441
  const git_commit *parents[]);
442
442
 
443
+ /**
444
+ * Create a commit object from the given buffer and signature
445
+ *
446
+ * Given the unsigned commit object's contents, its signature and the
447
+ * header field in which to store the signature, attach the signature
448
+ * to the commit and write it into the given repository.
449
+ *
450
+ * @param out the resulting commit id
451
+ * @param commit_content the content of the unsigned commit object
452
+ * @param signature the signature to add to the commit
453
+ * @param signature_field which header field should contain this
454
+ * signature. Leave `NULL` for the default of "gpgsig"
455
+ * @return 0 or an error code
456
+ */
457
+ GIT_EXTERN(int) git_commit_create_with_signature(
458
+ git_oid *out,
459
+ git_repository *repo,
460
+ const char *commit_content,
461
+ const char *signature,
462
+ const char *signature_field);
463
+
464
+ /**
465
+ * Create an in-memory copy of a commit. The copy must be explicitly
466
+ * free'd or it will leak.
467
+ *
468
+ * @param out Pointer to store the copy of the commit
469
+ * @param source Original commit to copy
470
+ */
471
+ GIT_EXTERN(int) git_commit_dup(git_commit **out, git_commit *source);
472
+
443
473
  /** @} */
444
474
  GIT_END_DECL
445
475
  #endif