rugged 0.25.0b2 → 0.25.0b3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/ext/rugged/extconf.rb +3 -1
- data/ext/rugged/rugged.c +1 -1
- data/ext/rugged/rugged.h +1 -1
- data/ext/rugged/rugged_blob.c +29 -38
- data/ext/rugged/rugged_commit.c +215 -78
- data/ext/rugged/rugged_rebase.c +18 -11
- data/ext/rugged/rugged_remote.c +2 -2
- data/ext/rugged/rugged_tree.c +132 -0
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +11 -3
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/include/git2/blob.h +39 -28
- data/vendor/libgit2/include/git2/commit.h +30 -0
- data/vendor/libgit2/include/git2/common.h +16 -1
- data/vendor/libgit2/include/git2/merge.h +10 -1
- data/vendor/libgit2/include/git2/proxy.h +92 -0
- data/vendor/libgit2/include/git2/refs.h +11 -0
- data/vendor/libgit2/include/git2/remote.h +17 -4
- data/vendor/libgit2/include/git2/signature.h +13 -0
- data/vendor/libgit2/include/git2/sys/merge.h +177 -0
- data/vendor/libgit2/include/git2/sys/remote.h +16 -0
- data/vendor/libgit2/include/git2/sys/stream.h +2 -1
- data/vendor/libgit2/include/git2/sys/transport.h +3 -1
- data/vendor/libgit2/include/git2/tag.h +9 -0
- data/vendor/libgit2/include/git2/tree.h +55 -0
- data/vendor/libgit2/src/annotated_commit.c +99 -80
- data/vendor/libgit2/src/annotated_commit.h +5 -2
- data/vendor/libgit2/src/array.h +40 -0
- data/vendor/libgit2/src/blame.c +8 -3
- data/vendor/libgit2/src/blame_git.c +2 -1
- data/vendor/libgit2/src/blob.c +71 -39
- data/vendor/libgit2/src/branch.c +2 -1
- data/vendor/libgit2/src/checkout.c +66 -42
- data/vendor/libgit2/src/commit.c +67 -3
- data/vendor/libgit2/src/config_cache.c +2 -1
- data/vendor/libgit2/src/config_file.c +32 -27
- data/vendor/libgit2/src/curl_stream.c +89 -6
- data/vendor/libgit2/src/delta-apply.c +36 -5
- data/vendor/libgit2/src/delta-apply.h +12 -0
- data/vendor/libgit2/src/describe.c +3 -2
- data/vendor/libgit2/src/diff.c +13 -20
- data/vendor/libgit2/src/diff_tform.c +5 -3
- data/vendor/libgit2/src/filebuf.c +12 -2
- data/vendor/libgit2/src/filebuf.h +1 -0
- data/vendor/libgit2/src/fnmatch.c +18 -5
- data/vendor/libgit2/src/global.c +18 -0
- data/vendor/libgit2/src/global.h +1 -0
- data/vendor/libgit2/src/ignore.c +11 -3
- data/vendor/libgit2/src/index.c +11 -5
- data/vendor/libgit2/src/indexer.c +11 -7
- data/vendor/libgit2/src/iterator.c +1575 -1468
- data/vendor/libgit2/src/iterator.h +52 -69
- data/vendor/libgit2/src/merge.c +160 -63
- data/vendor/libgit2/src/merge.h +61 -2
- data/vendor/libgit2/src/merge_driver.c +397 -0
- data/vendor/libgit2/src/merge_driver.h +60 -0
- data/vendor/libgit2/src/merge_file.c +11 -49
- data/vendor/libgit2/src/netops.c +12 -10
- data/vendor/libgit2/src/object.c +3 -6
- data/vendor/libgit2/src/object_api.c +19 -1
- data/vendor/libgit2/src/odb_loose.c +1 -1
- data/vendor/libgit2/src/openssl_stream.c +16 -3
- data/vendor/libgit2/src/pack-objects.c +3 -1
- data/vendor/libgit2/src/pack.c +5 -9
- data/vendor/libgit2/src/path.c +14 -0
- data/vendor/libgit2/src/path.h +12 -0
- data/vendor/libgit2/src/pathspec.c +1 -1
- data/vendor/libgit2/src/posix.c +7 -0
- data/vendor/libgit2/src/posix.h +1 -0
- data/vendor/libgit2/src/proxy.c +32 -0
- data/vendor/libgit2/src/proxy.h +14 -0
- data/vendor/libgit2/src/push.c +7 -7
- data/vendor/libgit2/src/rebase.c +61 -31
- data/vendor/libgit2/src/refdb_fs.c +1 -0
- data/vendor/libgit2/src/refs.c +16 -1
- data/vendor/libgit2/src/remote.c +20 -6
- data/vendor/libgit2/src/repository.c +1 -1
- data/vendor/libgit2/src/reset.c +1 -1
- data/vendor/libgit2/src/settings.c +23 -1
- data/vendor/libgit2/src/signature.c +26 -1
- data/vendor/libgit2/src/stransport_stream.c +5 -2
- data/vendor/libgit2/src/stream.h +2 -2
- data/vendor/libgit2/src/submodule.c +3 -2
- data/vendor/libgit2/src/tag.c +8 -2
- data/vendor/libgit2/src/transports/http.c +32 -9
- data/vendor/libgit2/src/transports/local.c +4 -1
- data/vendor/libgit2/src/transports/smart.c +6 -0
- data/vendor/libgit2/src/transports/smart.h +1 -0
- data/vendor/libgit2/src/transports/smart_protocol.c +61 -17
- data/vendor/libgit2/src/transports/winhttp.c +130 -11
- data/vendor/libgit2/src/tree.c +329 -98
- data/vendor/libgit2/src/tree.h +4 -5
- data/vendor/libgit2/src/unix/map.c +5 -0
- data/vendor/libgit2/src/win32/map.c +24 -5
- data/vendor/libgit2/src/xdiff/xprepare.c +2 -1
- metadata +10 -4
- data/vendor/libgit2/Makefile.embed +0 -60
data/ext/rugged/rugged_rebase.c
CHANGED
@@ -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]) ->
|
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
|
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 (
|
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
|
-
*
|
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
|
-
*
|
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
|
-
*
|
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
|
-
*
|
352
|
+
* rebase.finish -> nil
|
346
353
|
*
|
347
354
|
* Finish the rebase currently in progress once all patches have been
|
348
355
|
* applied.
|
data/ext/rugged/rugged_remote.c
CHANGED
@@ -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);
|
data/ext/rugged/rugged_tree.c
CHANGED
@@ -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
|
|
data/lib/rugged/version.rb
CHANGED
@@ -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)
|
@@ -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
|
-
*
|
158
|
-
*
|
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
|
-
*
|
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
|
176
|
+
* @return 0 or error code
|
186
177
|
*/
|
187
|
-
GIT_EXTERN(int)
|
188
|
-
|
178
|
+
GIT_EXTERN(int) git_blob_create_fromstream(
|
179
|
+
git_writestream **out,
|
189
180
|
git_repository *repo,
|
190
|
-
const char *hintpath
|
191
|
-
|
192
|
-
|
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
|