rugged 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +1 -1
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_repo.c +3 -3
- data/lib/rugged/repository.rb +2 -2
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +11 -6
- data/vendor/libgit2/COPYING +109 -1
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +4 -0
- data/vendor/libgit2/cmake/SelectHashes.cmake +1 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +17 -5
- data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +150 -118
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
- data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
- data/vendor/libgit2/include/git2/attr.h +89 -0
- data/vendor/libgit2/include/git2/blame.h +93 -42
- data/vendor/libgit2/include/git2/blob.h +14 -2
- data/vendor/libgit2/include/git2/branch.h +25 -0
- data/vendor/libgit2/include/git2/cert.h +42 -5
- data/vendor/libgit2/include/git2/checkout.h +28 -12
- data/vendor/libgit2/include/git2/commit.h +35 -19
- data/vendor/libgit2/include/git2/common.h +14 -4
- data/vendor/libgit2/include/git2/deprecated.h +206 -6
- data/vendor/libgit2/include/git2/diff.h +34 -19
- data/vendor/libgit2/include/git2/errors.h +6 -6
- data/vendor/libgit2/include/git2/filter.h +57 -17
- data/vendor/libgit2/include/git2/graph.h +20 -2
- data/vendor/libgit2/include/git2/index.h +2 -2
- data/vendor/libgit2/include/git2/odb.h +29 -0
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/rebase.h +25 -1
- data/vendor/libgit2/include/git2/refs.h +6 -2
- data/vendor/libgit2/include/git2/remote.h +59 -6
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/status.h +115 -59
- data/vendor/libgit2/include/git2/submodule.h +9 -0
- data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
- data/vendor/libgit2/include/git2/sys/filter.h +49 -28
- data/vendor/libgit2/include/git2/sys/midx.h +74 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
- data/vendor/libgit2/include/git2/sys/transport.h +1 -0
- data/vendor/libgit2/include/git2/tag.h +12 -0
- data/vendor/libgit2/include/git2/tree.h +0 -14
- data/vendor/libgit2/include/git2/types.h +9 -0
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +25 -4
- data/vendor/libgit2/src/alloc.c +21 -8
- data/vendor/libgit2/src/allocators/failalloc.c +92 -0
- data/vendor/libgit2/src/allocators/failalloc.h +23 -0
- data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
- data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
- data/vendor/libgit2/src/annotated_commit.c +21 -9
- data/vendor/libgit2/src/apply.c +16 -7
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/attr.c +181 -74
- data/vendor/libgit2/src/attr_file.c +84 -39
- data/vendor/libgit2/src/attr_file.h +32 -11
- data/vendor/libgit2/src/attrcache.c +42 -37
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +11 -5
- data/vendor/libgit2/src/blob.c +35 -24
- data/vendor/libgit2/src/branch.c +69 -17
- data/vendor/libgit2/src/buffer.c +334 -25
- data/vendor/libgit2/src/buffer.h +153 -2
- data/vendor/libgit2/src/cache.c +2 -2
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +10 -2
- data/vendor/libgit2/src/checkout.c +48 -26
- data/vendor/libgit2/src/cherrypick.c +6 -2
- data/vendor/libgit2/src/clone.c +41 -47
- data/vendor/libgit2/src/commit.c +41 -28
- data/vendor/libgit2/src/commit_graph.c +1209 -0
- data/vendor/libgit2/src/commit_graph.h +162 -0
- data/vendor/libgit2/src/commit_list.c +46 -0
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +25 -2
- data/vendor/libgit2/src/config.c +37 -15
- data/vendor/libgit2/src/config_cache.c +5 -3
- data/vendor/libgit2/src/config_file.c +16 -8
- data/vendor/libgit2/src/config_parse.c +4 -6
- data/vendor/libgit2/src/crlf.c +16 -6
- data/vendor/libgit2/src/date.c +4 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/describe.c +6 -3
- data/vendor/libgit2/src/diff.c +11 -8
- data/vendor/libgit2/src/diff_driver.c +21 -17
- data/vendor/libgit2/src/diff_file.c +2 -6
- data/vendor/libgit2/src/diff_generate.c +46 -17
- data/vendor/libgit2/src/diff_print.c +19 -6
- data/vendor/libgit2/src/diff_stats.c +7 -5
- data/vendor/libgit2/src/diff_tform.c +9 -8
- data/vendor/libgit2/src/diff_xdiff.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/errors.c +24 -19
- data/vendor/libgit2/src/features.h.in +5 -1
- data/vendor/libgit2/src/fetch.c +5 -2
- data/vendor/libgit2/src/fetchhead.c +8 -4
- data/vendor/libgit2/src/filebuf.c +9 -7
- data/vendor/libgit2/src/filter.c +206 -110
- data/vendor/libgit2/src/filter.h +24 -5
- data/vendor/libgit2/src/futils.c +5 -5
- data/vendor/libgit2/src/futils.h +1 -1
- data/vendor/libgit2/src/graph.c +64 -9
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
- data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
- data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
- data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
- data/vendor/libgit2/src/hash.c +16 -13
- data/vendor/libgit2/src/hash.h +1 -1
- data/vendor/libgit2/src/hashsig.c +23 -10
- data/vendor/libgit2/src/ident.c +13 -3
- data/vendor/libgit2/src/ignore.c +35 -19
- data/vendor/libgit2/src/index.c +106 -70
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +31 -29
- data/vendor/libgit2/src/integer.h +64 -2
- data/vendor/libgit2/src/iterator.c +36 -24
- data/vendor/libgit2/src/iterator.h +1 -1
- data/vendor/libgit2/src/khash.h +2 -11
- data/vendor/libgit2/src/{settings.c → libgit2.c} +117 -50
- data/vendor/libgit2/src/libgit2.h +15 -0
- data/vendor/libgit2/src/mailmap.c +23 -10
- data/vendor/libgit2/src/map.h +3 -3
- data/vendor/libgit2/src/merge.c +70 -30
- data/vendor/libgit2/src/merge.h +2 -1
- data/vendor/libgit2/src/merge_driver.c +19 -13
- data/vendor/libgit2/src/merge_file.c +11 -3
- data/vendor/libgit2/src/message.c +3 -1
- data/vendor/libgit2/src/midx.c +471 -10
- data/vendor/libgit2/src/midx.h +28 -1
- data/vendor/libgit2/src/mwindow.c +103 -59
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +127 -3
- data/vendor/libgit2/src/net.h +16 -2
- data/vendor/libgit2/src/netops.c +6 -4
- data/vendor/libgit2/src/netops.h +2 -2
- data/vendor/libgit2/src/notes.c +10 -10
- data/vendor/libgit2/src/object.c +22 -14
- data/vendor/libgit2/src/odb.c +285 -48
- data/vendor/libgit2/src/odb.h +16 -2
- data/vendor/libgit2/src/odb_loose.c +28 -18
- data/vendor/libgit2/src/odb_mempack.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +391 -114
- data/vendor/libgit2/src/oid.c +5 -4
- data/vendor/libgit2/src/pack-objects.c +54 -48
- data/vendor/libgit2/src/pack.c +329 -119
- data/vendor/libgit2/src/pack.h +25 -7
- data/vendor/libgit2/src/patch.c +14 -7
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +2 -1
- data/vendor/libgit2/src/path.c +98 -53
- data/vendor/libgit2/src/path.h +79 -6
- data/vendor/libgit2/src/pathspec.c +8 -8
- data/vendor/libgit2/src/pool.c +13 -7
- data/vendor/libgit2/src/posix.c +11 -3
- data/vendor/libgit2/src/reader.c +10 -6
- data/vendor/libgit2/src/rebase.c +93 -49
- data/vendor/libgit2/src/refdb.c +30 -13
- data/vendor/libgit2/src/refdb_fs.c +121 -69
- data/vendor/libgit2/src/reflog.c +19 -14
- data/vendor/libgit2/src/refs.c +76 -41
- data/vendor/libgit2/src/refspec.c +32 -12
- data/vendor/libgit2/src/remote.c +272 -102
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +176 -103
- data/vendor/libgit2/src/repository.h +12 -1
- data/vendor/libgit2/src/reset.c +7 -6
- data/vendor/libgit2/src/revert.c +6 -2
- data/vendor/libgit2/src/revparse.c +14 -9
- data/vendor/libgit2/src/revwalk.c +32 -15
- data/vendor/libgit2/src/runtime.c +162 -0
- data/vendor/libgit2/src/runtime.h +62 -0
- data/vendor/libgit2/src/settings.h +11 -0
- data/vendor/libgit2/src/signature.c +6 -5
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +3 -1
- data/vendor/libgit2/src/status.c +7 -4
- data/vendor/libgit2/src/strarray.c +2 -1
- data/vendor/libgit2/src/streams/mbedtls.c +14 -17
- data/vendor/libgit2/src/streams/mbedtls.h +1 -1
- data/vendor/libgit2/src/streams/openssl.c +101 -201
- data/vendor/libgit2/src/streams/openssl.h +9 -1
- data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
- data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
- data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
- data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
- data/vendor/libgit2/src/streams/registry.c +5 -6
- data/vendor/libgit2/src/streams/socket.c +6 -2
- data/vendor/libgit2/src/streams/stransport.c +6 -3
- data/vendor/libgit2/src/streams/tls.c +5 -3
- data/vendor/libgit2/src/submodule.c +128 -62
- data/vendor/libgit2/src/submodule.h +9 -9
- data/vendor/libgit2/src/sysdir.c +4 -6
- data/vendor/libgit2/src/tag.c +47 -11
- data/vendor/libgit2/src/thread.c +140 -0
- data/vendor/libgit2/src/thread.h +479 -0
- data/vendor/libgit2/src/threadstate.c +83 -0
- data/vendor/libgit2/src/threadstate.h +24 -0
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +17 -13
- data/vendor/libgit2/src/transaction.c +19 -8
- data/vendor/libgit2/src/transport.c +3 -3
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
- data/vendor/libgit2/src/transports/credential.c +15 -7
- data/vendor/libgit2/src/transports/git.c +1 -3
- data/vendor/libgit2/src/transports/http.c +19 -17
- data/vendor/libgit2/src/transports/http.h +1 -0
- data/vendor/libgit2/src/transports/httpclient.c +53 -26
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +3 -3
- data/vendor/libgit2/src/transports/smart.c +12 -7
- data/vendor/libgit2/src/transports/smart.h +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
- data/vendor/libgit2/src/transports/ssh.c +51 -17
- data/vendor/libgit2/src/transports/winhttp.c +41 -31
- data/vendor/libgit2/src/tree.c +100 -77
- data/vendor/libgit2/src/tree.h +1 -0
- data/vendor/libgit2/src/tsort.c +0 -2
- data/vendor/libgit2/src/unix/map.c +3 -1
- data/vendor/libgit2/src/unix/pthread.h +2 -1
- data/vendor/libgit2/src/utf8.c +150 -0
- data/vendor/libgit2/src/utf8.h +52 -0
- data/vendor/libgit2/src/util.c +53 -129
- data/vendor/libgit2/src/util.h +33 -39
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +4 -2
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
- data/vendor/libgit2/src/win32/path_w32.c +22 -24
- data/vendor/libgit2/src/win32/path_w32.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +7 -1
- data/vendor/libgit2/src/win32/precompiled.h +0 -1
- data/vendor/libgit2/src/win32/reparse.h +4 -4
- data/vendor/libgit2/src/win32/thread.c +24 -15
- data/vendor/libgit2/src/win32/thread.h +1 -1
- data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
- data/vendor/libgit2/src/win32/w32_common.h +18 -9
- data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
- data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -6
- data/vendor/libgit2/src/worktree.c +27 -16
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +32 -16
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/buf_text.c +0 -316
- data/vendor/libgit2/src/buf_text.h +0 -122
- data/vendor/libgit2/src/global.c +0 -363
- data/vendor/libgit2/src/global.h +0 -41
- data/vendor/libgit2/src/thread-utils.c +0 -58
- data/vendor/libgit2/src/thread-utils.h +0 -369
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
- data/vendor/libgit2/src/win32/w32_stack.c +0 -188
- data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -95,7 +95,7 @@ static int diff_print_info_init_frompatch(
|
|
95
95
|
git_diff_line_cb cb,
|
96
96
|
void *payload)
|
97
97
|
{
|
98
|
-
|
98
|
+
GIT_ASSERT_ARG(patch);
|
99
99
|
|
100
100
|
memset(pi, 0, sizeof(diff_print_info));
|
101
101
|
|
@@ -764,8 +764,14 @@ int git_diff_print_callback__to_file_handle(
|
|
764
764
|
/* print a git_diff to a git_buf */
|
765
765
|
int git_diff_to_buf(git_buf *out, git_diff *diff, git_diff_format_t format)
|
766
766
|
{
|
767
|
-
|
768
|
-
|
767
|
+
int error;
|
768
|
+
|
769
|
+
GIT_ASSERT_ARG(out);
|
770
|
+
GIT_ASSERT_ARG(diff);
|
771
|
+
|
772
|
+
if ((error = git_buf_sanitize(out)) < 0)
|
773
|
+
return error;
|
774
|
+
|
769
775
|
return git_diff_print(diff, format, git_diff_print_callback__to_buf, out);
|
770
776
|
}
|
771
777
|
|
@@ -779,7 +785,8 @@ int git_patch_print(
|
|
779
785
|
diff_print_info pi;
|
780
786
|
int error;
|
781
787
|
|
782
|
-
|
788
|
+
GIT_ASSERT_ARG(patch);
|
789
|
+
GIT_ASSERT_ARG(print_cb);
|
783
790
|
|
784
791
|
if ((error = diff_print_info_init_frompatch(&pi, &temp, patch,
|
785
792
|
GIT_DIFF_FORMAT_PATCH, print_cb, payload)) < 0)
|
@@ -799,7 +806,13 @@ out:
|
|
799
806
|
/* print a git_patch to a git_buf */
|
800
807
|
int git_patch_to_buf(git_buf *out, git_patch *patch)
|
801
808
|
{
|
802
|
-
|
803
|
-
|
809
|
+
int error;
|
810
|
+
|
811
|
+
GIT_ASSERT_ARG(out);
|
812
|
+
GIT_ASSERT_ARG(patch);
|
813
|
+
|
814
|
+
if ((error = git_buf_sanitize(out)) < 0)
|
815
|
+
return error;
|
816
|
+
|
804
817
|
return git_patch_print(patch, git_diff_print_callback__to_buf, out);
|
805
818
|
}
|
@@ -183,7 +183,8 @@ int git_diff_get_stats(
|
|
183
183
|
git_diff_stats *stats = NULL;
|
184
184
|
int error = 0;
|
185
185
|
|
186
|
-
|
186
|
+
GIT_ASSERT_ARG(out);
|
187
|
+
GIT_ASSERT_ARG(diff);
|
187
188
|
|
188
189
|
stats = git__calloc(1, sizeof(git_diff_stats));
|
189
190
|
GIT_ERROR_CHECK_ALLOC(stats);
|
@@ -251,7 +252,7 @@ int git_diff_get_stats(
|
|
251
252
|
size_t git_diff_stats_files_changed(
|
252
253
|
const git_diff_stats *stats)
|
253
254
|
{
|
254
|
-
|
255
|
+
GIT_ASSERT_ARG(stats);
|
255
256
|
|
256
257
|
return stats->files_changed;
|
257
258
|
}
|
@@ -259,7 +260,7 @@ size_t git_diff_stats_files_changed(
|
|
259
260
|
size_t git_diff_stats_insertions(
|
260
261
|
const git_diff_stats *stats)
|
261
262
|
{
|
262
|
-
|
263
|
+
GIT_ASSERT_ARG(stats);
|
263
264
|
|
264
265
|
return stats->insertions;
|
265
266
|
}
|
@@ -267,7 +268,7 @@ size_t git_diff_stats_insertions(
|
|
267
268
|
size_t git_diff_stats_deletions(
|
268
269
|
const git_diff_stats *stats)
|
269
270
|
{
|
270
|
-
|
271
|
+
GIT_ASSERT_ARG(stats);
|
271
272
|
|
272
273
|
return stats->deletions;
|
273
274
|
}
|
@@ -282,7 +283,8 @@ int git_diff_stats_to_buf(
|
|
282
283
|
size_t i;
|
283
284
|
const git_diff_delta *delta;
|
284
285
|
|
285
|
-
|
286
|
+
GIT_ASSERT_ARG(out);
|
287
|
+
GIT_ASSERT_ARG(stats);
|
286
288
|
|
287
289
|
if (format & GIT_DIFF_STATS_NUMBER) {
|
288
290
|
for (i = 0; i < stats->files_changed; ++i) {
|
@@ -87,7 +87,7 @@ git_diff_delta *git_diff__merge_like_cgit(
|
|
87
87
|
a->status == GIT_DELTA_UNREADABLE)
|
88
88
|
return dup;
|
89
89
|
|
90
|
-
|
90
|
+
GIT_ASSERT_WITH_RETVAL(b->status != GIT_DELTA_UNMODIFIED, NULL);
|
91
91
|
|
92
92
|
/* A cgit exception is that the diff of a file that is only in the
|
93
93
|
* index (i.e. not in HEAD nor workdir) is given as empty.
|
@@ -121,7 +121,8 @@ int git_diff__merge(
|
|
121
121
|
bool ignore_case, reversed;
|
122
122
|
unsigned int i, j;
|
123
123
|
|
124
|
-
|
124
|
+
GIT_ASSERT_ARG(onto);
|
125
|
+
GIT_ASSERT_ARG(from);
|
125
126
|
|
126
127
|
if (!from->deltas.length)
|
127
128
|
return 0;
|
@@ -475,8 +476,8 @@ static int similarity_sig(
|
|
475
476
|
git_diff_file *file = info->file;
|
476
477
|
|
477
478
|
if (info->src == GIT_ITERATOR_WORKDIR) {
|
478
|
-
if ((error =
|
479
|
-
&info->data,
|
479
|
+
if ((error = git_repository_workdir_path(
|
480
|
+
&info->data, info->repo, file->path)) < 0)
|
480
481
|
return error;
|
481
482
|
|
482
483
|
/* if path is not a regular file, just skip this item */
|
@@ -815,7 +816,7 @@ int git_diff_find_similar(
|
|
815
816
|
diff_find_match *best_match;
|
816
817
|
git_diff_file swap;
|
817
818
|
|
818
|
-
|
819
|
+
GIT_ASSERT_ARG(diff);
|
819
820
|
|
820
821
|
if ((error = normalize_find_opts(diff, &opts, given_opts)) < 0)
|
821
822
|
return error;
|
@@ -978,7 +979,7 @@ find_best_matches:
|
|
978
979
|
src->flags |= GIT_DIFF_FLAG__TO_DELETE;
|
979
980
|
num_rewrites++;
|
980
981
|
} else {
|
981
|
-
|
982
|
+
GIT_ASSERT(delta_is_split(tgt));
|
982
983
|
|
983
984
|
if (best_match->similarity < opts.rename_from_rewrite_threshold)
|
984
985
|
continue;
|
@@ -988,7 +989,7 @@ find_best_matches:
|
|
988
989
|
delta_make_rename(tgt, src, best_match->similarity);
|
989
990
|
num_rewrites--;
|
990
991
|
|
991
|
-
|
992
|
+
GIT_ASSERT(src->status == GIT_DELTA_DELETED);
|
992
993
|
memcpy(&src->old_file, &swap, sizeof(src->old_file));
|
993
994
|
memset(&src->new_file, 0, sizeof(src->new_file));
|
994
995
|
src->new_file.path = src->old_file.path;
|
@@ -1024,7 +1025,7 @@ find_best_matches:
|
|
1024
1025
|
|
1025
1026
|
num_updates++;
|
1026
1027
|
} else {
|
1027
|
-
|
1028
|
+
GIT_ASSERT(delta_is_split(src));
|
1028
1029
|
|
1029
1030
|
if (best_match->similarity < opts.rename_from_rewrite_threshold)
|
1030
1031
|
continue;
|
@@ -6,7 +6,6 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
#include "diff_xdiff.h"
|
9
|
-
#include "util.h"
|
10
9
|
|
11
10
|
#include "git2/errors.h"
|
12
11
|
#include "diff.h"
|
@@ -128,7 +127,7 @@ static int git_xdiff_cb(void *priv, mmbuffer_t *bufs, int len)
|
|
128
127
|
info->hunk.header_len = sizeof(info->hunk.header) - 1;
|
129
128
|
|
130
129
|
/* Sanitize the hunk header in case there is invalid Unicode */
|
131
|
-
buffer_len =
|
130
|
+
buffer_len = git_utf8_valid_buf_length(bufs[0].ptr, info->hunk.header_len);
|
132
131
|
/* Sanitizing the hunk header may delete the newline, so add it back again if there is room */
|
133
132
|
if (buffer_len < info->hunk.header_len) {
|
134
133
|
bufs[0].ptr[buffer_len] = '\n';
|
@@ -259,5 +258,8 @@ void git_xdiff_init(git_xdiff_output *xo, const git_diff_options *opts)
|
|
259
258
|
if (flags & GIT_DIFF_MINIMAL)
|
260
259
|
xo->params.flags |= XDF_NEED_MINIMAL;
|
261
260
|
|
261
|
+
if (flags & GIT_DIFF_IGNORE_BLANK_LINES)
|
262
|
+
xo->params.flags |= XDF_IGNORE_BLANK_LINES;
|
263
|
+
|
262
264
|
xo->callback.outf = git_xdiff_cb;
|
263
265
|
}
|
@@ -16,7 +16,7 @@
|
|
16
16
|
/* xdiff cannot cope with large files. these files should not be passed to
|
17
17
|
* xdiff. callers should treat these large files as binary.
|
18
18
|
*/
|
19
|
-
#define GIT_XDIFF_MAX_SIZE (
|
19
|
+
#define GIT_XDIFF_MAX_SIZE (INT64_C(1024) * 1024 * 1023)
|
20
20
|
|
21
21
|
/* A git_xdiff_output is a git_patch_generate_output with extra fields
|
22
22
|
* necessary to use libxdiff. Calling git_xdiff_init() will set the diff_cb
|
data/vendor/libgit2/src/errors.c
CHANGED
@@ -7,9 +7,10 @@
|
|
7
7
|
|
8
8
|
#include "common.h"
|
9
9
|
|
10
|
-
#include "
|
10
|
+
#include "threadstate.h"
|
11
11
|
#include "posix.h"
|
12
12
|
#include "buffer.h"
|
13
|
+
#include "libgit2.h"
|
13
14
|
|
14
15
|
/********************************************
|
15
16
|
* New error handling
|
@@ -20,20 +21,25 @@ static git_error g_git_oom_error = {
|
|
20
21
|
GIT_ERROR_NOMEMORY
|
21
22
|
};
|
22
23
|
|
24
|
+
static git_error g_git_uninitialized_error = {
|
25
|
+
"libgit2 has not been initialized; you must call git_libgit2_init",
|
26
|
+
GIT_ERROR_INVALID
|
27
|
+
};
|
28
|
+
|
23
29
|
static void set_error_from_buffer(int error_class)
|
24
30
|
{
|
25
|
-
git_error *error = &
|
26
|
-
git_buf *buf = &
|
31
|
+
git_error *error = &GIT_THREADSTATE->error_t;
|
32
|
+
git_buf *buf = &GIT_THREADSTATE->error_buf;
|
27
33
|
|
28
34
|
error->message = buf->ptr;
|
29
35
|
error->klass = error_class;
|
30
36
|
|
31
|
-
|
37
|
+
GIT_THREADSTATE->last_error = error;
|
32
38
|
}
|
33
39
|
|
34
40
|
static void set_error(int error_class, char *string)
|
35
41
|
{
|
36
|
-
git_buf *buf = &
|
42
|
+
git_buf *buf = &GIT_THREADSTATE->error_buf;
|
37
43
|
|
38
44
|
git_buf_clear(buf);
|
39
45
|
if (string) {
|
@@ -46,7 +52,7 @@ static void set_error(int error_class, char *string)
|
|
46
52
|
|
47
53
|
void git_error_set_oom(void)
|
48
54
|
{
|
49
|
-
|
55
|
+
GIT_THREADSTATE->last_error = &g_git_oom_error;
|
50
56
|
}
|
51
57
|
|
52
58
|
void git_error_set(int error_class, const char *fmt, ...)
|
@@ -64,7 +70,7 @@ void git_error_vset(int error_class, const char *fmt, va_list ap)
|
|
64
70
|
DWORD win32_error_code = (error_class == GIT_ERROR_OS) ? GetLastError() : 0;
|
65
71
|
#endif
|
66
72
|
int error_code = (error_class == GIT_ERROR_OS) ? errno : 0;
|
67
|
-
git_buf *buf = &
|
73
|
+
git_buf *buf = &GIT_THREADSTATE->error_buf;
|
68
74
|
|
69
75
|
git_buf_clear(buf);
|
70
76
|
if (fmt) {
|
@@ -97,14 +103,9 @@ void git_error_vset(int error_class, const char *fmt, va_list ap)
|
|
97
103
|
|
98
104
|
int git_error_set_str(int error_class, const char *string)
|
99
105
|
{
|
100
|
-
git_buf *buf = &
|
101
|
-
|
102
|
-
assert(string);
|
106
|
+
git_buf *buf = &GIT_THREADSTATE->error_buf;
|
103
107
|
|
104
|
-
|
105
|
-
git_error_set(GIT_ERROR_INVALID, "unspecified caller error");
|
106
|
-
return -1;
|
107
|
-
}
|
108
|
+
GIT_ASSERT_ARG(string);
|
108
109
|
|
109
110
|
git_buf_clear(buf);
|
110
111
|
git_buf_puts(buf, string);
|
@@ -118,9 +119,9 @@ int git_error_set_str(int error_class, const char *string)
|
|
118
119
|
|
119
120
|
void git_error_clear(void)
|
120
121
|
{
|
121
|
-
if (
|
122
|
+
if (GIT_THREADSTATE->last_error != NULL) {
|
122
123
|
set_error(0, NULL);
|
123
|
-
|
124
|
+
GIT_THREADSTATE->last_error = NULL;
|
124
125
|
}
|
125
126
|
|
126
127
|
errno = 0;
|
@@ -131,13 +132,17 @@ void git_error_clear(void)
|
|
131
132
|
|
132
133
|
const git_error *git_error_last(void)
|
133
134
|
{
|
134
|
-
return
|
135
|
+
/* If the library is not initialized, return a static error. */
|
136
|
+
if (!git_libgit2_init_count())
|
137
|
+
return &g_git_uninitialized_error;
|
138
|
+
|
139
|
+
return GIT_THREADSTATE->last_error;
|
135
140
|
}
|
136
141
|
|
137
142
|
int git_error_state_capture(git_error_state *state, int error_code)
|
138
143
|
{
|
139
|
-
git_error *error =
|
140
|
-
git_buf *error_buf = &
|
144
|
+
git_error *error = GIT_THREADSTATE->last_error;
|
145
|
+
git_buf *error_buf = &GIT_THREADSTATE->error_buf;
|
141
146
|
|
142
147
|
memset(state, 0, sizeof(git_error_state));
|
143
148
|
|
@@ -2,9 +2,12 @@
|
|
2
2
|
#define INCLUDE_features_h__
|
3
3
|
|
4
4
|
#cmakedefine GIT_DEBUG_POOL 1
|
5
|
+
#cmakedefine GIT_DEBUG_STRICT_ALLOC 1
|
6
|
+
#cmakedefine GIT_DEBUG_STRICT_OPEN 1
|
7
|
+
|
5
8
|
#cmakedefine GIT_TRACE 1
|
6
9
|
#cmakedefine GIT_THREADS 1
|
7
|
-
#cmakedefine
|
10
|
+
#cmakedefine GIT_WIN32_LEAKCHECK 1
|
8
11
|
|
9
12
|
#cmakedefine GIT_ARCH_64 1
|
10
13
|
#cmakedefine GIT_ARCH_32 1
|
@@ -32,6 +35,7 @@
|
|
32
35
|
#cmakedefine GIT_WINHTTP 1
|
33
36
|
#cmakedefine GIT_HTTPS 1
|
34
37
|
#cmakedefine GIT_OPENSSL 1
|
38
|
+
#cmakedefine GIT_OPENSSL_DYNAMIC 1
|
35
39
|
#cmakedefine GIT_SECURE_TRANSPORT 1
|
36
40
|
#cmakedefine GIT_MBEDTLS 1
|
37
41
|
|
data/vendor/libgit2/src/fetch.c
CHANGED
@@ -21,9 +21,12 @@
|
|
21
21
|
|
22
22
|
static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec, git_remote_autotag_option_t tagopt)
|
23
23
|
{
|
24
|
-
int match = 0;
|
24
|
+
int match = 0, valid;
|
25
25
|
|
26
|
-
if (
|
26
|
+
if (git_reference_name_is_valid(&valid, head->name) < 0)
|
27
|
+
return -1;
|
28
|
+
|
29
|
+
if (!valid)
|
27
30
|
return 0;
|
28
31
|
|
29
32
|
if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
|
@@ -73,7 +73,8 @@ int git_fetchhead_ref_create(
|
|
73
73
|
{
|
74
74
|
git_fetchhead_ref *fetchhead_ref;
|
75
75
|
|
76
|
-
|
76
|
+
GIT_ASSERT_ARG(out);
|
77
|
+
GIT_ASSERT_ARG(oid);
|
77
78
|
|
78
79
|
*out = NULL;
|
79
80
|
|
@@ -108,7 +109,8 @@ static int fetchhead_ref_write(
|
|
108
109
|
const char *type, *name;
|
109
110
|
int head = 0;
|
110
111
|
|
111
|
-
|
112
|
+
GIT_ASSERT_ARG(file);
|
113
|
+
GIT_ASSERT_ARG(fetchhead_ref);
|
112
114
|
|
113
115
|
git_oid_fmt(oid, &fetchhead_ref->oid);
|
114
116
|
oid[GIT_OID_HEXSZ] = '\0';
|
@@ -145,7 +147,8 @@ int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs)
|
|
145
147
|
unsigned int i;
|
146
148
|
git_fetchhead_ref *fetchhead_ref;
|
147
149
|
|
148
|
-
|
150
|
+
GIT_ASSERT_ARG(repo);
|
151
|
+
GIT_ASSERT_ARG(fetchhead_refs);
|
149
152
|
|
150
153
|
if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0)
|
151
154
|
return -1;
|
@@ -279,7 +282,8 @@ int git_repository_fetchhead_foreach(git_repository *repo,
|
|
279
282
|
size_t line_num = 0;
|
280
283
|
int error = 0;
|
281
284
|
|
282
|
-
|
285
|
+
GIT_ASSERT_ARG(repo);
|
286
|
+
GIT_ASSERT_ARG(cb);
|
283
287
|
|
284
288
|
if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0)
|
285
289
|
return -1;
|
@@ -184,7 +184,7 @@ static int write_deflate(git_filebuf *file, void *source, size_t len)
|
|
184
184
|
|
185
185
|
} while (zs->avail_out == 0);
|
186
186
|
|
187
|
-
|
187
|
+
GIT_ASSERT(zs->avail_in == 0);
|
188
188
|
|
189
189
|
if (file->compute_digest)
|
190
190
|
git_hash_update(&file->digest, source, len);
|
@@ -278,10 +278,9 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
|
|
278
278
|
int compression, error = -1;
|
279
279
|
size_t path_len, alloc_len;
|
280
280
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
assert(file && path && file->buffer == NULL);
|
281
|
+
GIT_ASSERT_ARG(file);
|
282
|
+
GIT_ASSERT_ARG(path);
|
283
|
+
GIT_ASSERT(file->buffer == NULL);
|
285
284
|
|
286
285
|
memset(file, 0x0, sizeof(git_filebuf));
|
287
286
|
|
@@ -389,7 +388,9 @@ cleanup:
|
|
389
388
|
|
390
389
|
int git_filebuf_hash(git_oid *oid, git_filebuf *file)
|
391
390
|
{
|
392
|
-
|
391
|
+
GIT_ASSERT_ARG(oid);
|
392
|
+
GIT_ASSERT_ARG(file);
|
393
|
+
GIT_ASSERT_ARG(file->compute_digest);
|
393
394
|
|
394
395
|
flush_buffer(file);
|
395
396
|
|
@@ -415,7 +416,8 @@ int git_filebuf_commit_at(git_filebuf *file, const char *path)
|
|
415
416
|
int git_filebuf_commit(git_filebuf *file)
|
416
417
|
{
|
417
418
|
/* temporary files cannot be committed */
|
418
|
-
|
419
|
+
GIT_ASSERT_ARG(file);
|
420
|
+
GIT_ASSERT(file->path_original);
|
419
421
|
|
420
422
|
file->flush_mode = Z_FINISH;
|
421
423
|
flush_buffer(file);
|
data/vendor/libgit2/src/filter.c
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#include "futils.h"
|
12
12
|
#include "hash.h"
|
13
13
|
#include "repository.h"
|
14
|
-
#include "
|
14
|
+
#include "runtime.h"
|
15
15
|
#include "git2/sys/filter.h"
|
16
16
|
#include "git2/config.h"
|
17
17
|
#include "blob.h"
|
@@ -19,12 +19,12 @@
|
|
19
19
|
#include "array.h"
|
20
20
|
|
21
21
|
struct git_filter_source {
|
22
|
-
git_repository
|
23
|
-
const char
|
24
|
-
git_oid
|
25
|
-
uint16_t
|
26
|
-
git_filter_mode_t
|
27
|
-
|
22
|
+
git_repository *repo;
|
23
|
+
const char *path;
|
24
|
+
git_oid oid; /* zero if unknown (which is likely) */
|
25
|
+
uint16_t filemode; /* zero if unknown */
|
26
|
+
git_filter_mode_t mode;
|
27
|
+
git_filter_options options;
|
28
28
|
};
|
29
29
|
|
30
30
|
typedef struct {
|
@@ -206,7 +206,8 @@ int git_filter_global_init(void)
|
|
206
206
|
GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0)
|
207
207
|
error = -1;
|
208
208
|
|
209
|
-
|
209
|
+
if (!error)
|
210
|
+
error = git_runtime_shutdown_register(git_filter_global_shutdown);
|
210
211
|
|
211
212
|
done:
|
212
213
|
if (error) {
|
@@ -266,7 +267,8 @@ int git_filter_register(
|
|
266
267
|
{
|
267
268
|
int error;
|
268
269
|
|
269
|
-
|
270
|
+
GIT_ASSERT_ARG(name);
|
271
|
+
GIT_ASSERT_ARG(filter);
|
270
272
|
|
271
273
|
if (git_rwlock_wrlock(&filter_registry.lock) < 0) {
|
272
274
|
git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
|
@@ -293,7 +295,7 @@ int git_filter_unregister(const char *name)
|
|
293
295
|
git_filter_def *fdef;
|
294
296
|
int error = 0;
|
295
297
|
|
296
|
-
|
298
|
+
GIT_ASSERT_ARG(name);
|
297
299
|
|
298
300
|
/* cannot unregister default filters */
|
299
301
|
if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) {
|
@@ -395,7 +397,7 @@ git_filter_mode_t git_filter_source_mode(const git_filter_source *src)
|
|
395
397
|
|
396
398
|
uint32_t git_filter_source_flags(const git_filter_source *src)
|
397
399
|
{
|
398
|
-
return src->flags;
|
400
|
+
return src->options.flags;
|
399
401
|
}
|
400
402
|
|
401
403
|
static int filter_list_new(
|
@@ -415,7 +417,8 @@ static int filter_list_new(
|
|
415
417
|
fl->source.repo = src->repo;
|
416
418
|
fl->source.path = fl->path;
|
417
419
|
fl->source.mode = src->mode;
|
418
|
-
|
420
|
+
|
421
|
+
memcpy(&fl->source.options, &src->options, sizeof(git_filter_options));
|
419
422
|
|
420
423
|
*out = fl;
|
421
424
|
return 0;
|
@@ -424,25 +427,30 @@ static int filter_list_new(
|
|
424
427
|
static int filter_list_check_attributes(
|
425
428
|
const char ***out,
|
426
429
|
git_repository *repo,
|
427
|
-
|
430
|
+
git_filter_session *filter_session,
|
428
431
|
git_filter_def *fdef,
|
429
432
|
const git_filter_source *src)
|
430
433
|
{
|
431
434
|
const char **strs = git__calloc(fdef->nattrs, sizeof(const char *));
|
432
|
-
|
435
|
+
git_attr_options attr_opts = GIT_ATTR_OPTIONS_INIT;
|
433
436
|
size_t i;
|
434
437
|
int error;
|
435
438
|
|
436
439
|
GIT_ERROR_CHECK_ALLOC(strs);
|
437
440
|
|
438
|
-
if ((src->flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
|
439
|
-
flags |= GIT_ATTR_CHECK_NO_SYSTEM;
|
441
|
+
if ((src->options.flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
|
442
|
+
attr_opts.flags |= GIT_ATTR_CHECK_NO_SYSTEM;
|
443
|
+
|
444
|
+
if ((src->options.flags & GIT_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
|
445
|
+
attr_opts.flags |= GIT_ATTR_CHECK_INCLUDE_HEAD;
|
440
446
|
|
441
|
-
if ((src->flags &
|
442
|
-
flags |=
|
447
|
+
if ((src->options.flags & GIT_FILTER_ATTRIBUTES_FROM_COMMIT) != 0) {
|
448
|
+
attr_opts.flags |= GIT_ATTR_CHECK_INCLUDE_COMMIT;
|
449
|
+
attr_opts.commit_id = src->options.commit_id;
|
450
|
+
}
|
443
451
|
|
444
452
|
error = git_attr_get_many_with_session(
|
445
|
-
strs, repo, attr_session,
|
453
|
+
strs, repo, filter_session->attr_session, &attr_opts, src->path, fdef->nattrs, fdef->attrs);
|
446
454
|
|
447
455
|
/* if no values were found but no matches are needed, it's okay! */
|
448
456
|
if (error == GIT_ENOTFOUND && !fdef->nmatches) {
|
@@ -487,17 +495,17 @@ int git_filter_list_new(
|
|
487
495
|
src.repo = repo;
|
488
496
|
src.path = NULL;
|
489
497
|
src.mode = mode;
|
490
|
-
src.flags = flags;
|
498
|
+
src.options.flags = flags;
|
491
499
|
return filter_list_new(out, &src);
|
492
500
|
}
|
493
501
|
|
494
|
-
int
|
502
|
+
int git_filter_list__load(
|
495
503
|
git_filter_list **filters,
|
496
504
|
git_repository *repo,
|
497
505
|
git_blob *blob, /* can be NULL */
|
498
506
|
const char *path,
|
499
507
|
git_filter_mode_t mode,
|
500
|
-
|
508
|
+
git_filter_session *filter_session)
|
501
509
|
{
|
502
510
|
int error = 0;
|
503
511
|
git_filter_list *fl = NULL;
|
@@ -514,7 +522,8 @@ int git_filter_list__load_ext(
|
|
514
522
|
src.repo = repo;
|
515
523
|
src.path = path;
|
516
524
|
src.mode = mode;
|
517
|
-
|
525
|
+
|
526
|
+
memcpy(&src.options, &filter_session->options, sizeof(git_filter_options));
|
518
527
|
|
519
528
|
if (blob)
|
520
529
|
git_oid_cpy(&src.oid, git_blob_id(blob));
|
@@ -528,7 +537,8 @@ int git_filter_list__load_ext(
|
|
528
537
|
|
529
538
|
if (fdef->nattrs > 0) {
|
530
539
|
error = filter_list_check_attributes(
|
531
|
-
&values, repo,
|
540
|
+
&values, repo,
|
541
|
+
filter_session, fdef, &src);
|
532
542
|
|
533
543
|
if (error == GIT_ENOTFOUND) {
|
534
544
|
error = 0;
|
@@ -555,7 +565,7 @@ int git_filter_list__load_ext(
|
|
555
565
|
if ((error = filter_list_new(&fl, &src)) < 0)
|
556
566
|
break;
|
557
567
|
|
558
|
-
fl->temp_buf =
|
568
|
+
fl->temp_buf = filter_session->temp_buf;
|
559
569
|
}
|
560
570
|
|
561
571
|
fe = git_array_alloc(fl->filters);
|
@@ -579,6 +589,23 @@ int git_filter_list__load_ext(
|
|
579
589
|
return error;
|
580
590
|
}
|
581
591
|
|
592
|
+
int git_filter_list_load_ext(
|
593
|
+
git_filter_list **filters,
|
594
|
+
git_repository *repo,
|
595
|
+
git_blob *blob, /* can be NULL */
|
596
|
+
const char *path,
|
597
|
+
git_filter_mode_t mode,
|
598
|
+
git_filter_options *opts)
|
599
|
+
{
|
600
|
+
git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
|
601
|
+
|
602
|
+
if (opts)
|
603
|
+
memcpy(&filter_session.options, opts, sizeof(git_filter_options));
|
604
|
+
|
605
|
+
return git_filter_list__load(
|
606
|
+
filters, repo, blob, path, mode, &filter_session);
|
607
|
+
}
|
608
|
+
|
582
609
|
int git_filter_list_load(
|
583
610
|
git_filter_list **filters,
|
584
611
|
git_repository *repo,
|
@@ -587,12 +614,12 @@ int git_filter_list_load(
|
|
587
614
|
git_filter_mode_t mode,
|
588
615
|
uint32_t flags)
|
589
616
|
{
|
590
|
-
|
617
|
+
git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
|
591
618
|
|
592
|
-
|
619
|
+
filter_session.options.flags = flags;
|
593
620
|
|
594
|
-
return
|
595
|
-
filters, repo, blob, path, mode, &
|
621
|
+
return git_filter_list__load(
|
622
|
+
filters, repo, blob, path, mode, &filter_session);
|
596
623
|
}
|
597
624
|
|
598
625
|
void git_filter_list_free(git_filter_list *fl)
|
@@ -618,7 +645,7 @@ int git_filter_list_contains(
|
|
618
645
|
{
|
619
646
|
size_t i;
|
620
647
|
|
621
|
-
|
648
|
+
GIT_ASSERT_ARG(name);
|
622
649
|
|
623
650
|
if (!fl)
|
624
651
|
return 0;
|
@@ -639,7 +666,8 @@ int git_filter_list_push(
|
|
639
666
|
git_filter_def *fdef = NULL;
|
640
667
|
git_filter_entry *fe;
|
641
668
|
|
642
|
-
|
669
|
+
GIT_ASSERT_ARG(fl);
|
670
|
+
GIT_ASSERT_ARG(filter);
|
643
671
|
|
644
672
|
if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
|
645
673
|
git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
|
@@ -684,9 +712,8 @@ static int buf_stream_write(
|
|
684
712
|
git_writestream *s, const char *buffer, size_t len)
|
685
713
|
{
|
686
714
|
struct buf_stream *buf_stream = (struct buf_stream *)s;
|
687
|
-
|
688
|
-
|
689
|
-
assert(buf_stream->complete == 0);
|
715
|
+
GIT_ASSERT_ARG(buf_stream);
|
716
|
+
GIT_ASSERT(buf_stream->complete == 0);
|
690
717
|
|
691
718
|
return git_buf_put(buf_stream->target, buffer, len);
|
692
719
|
}
|
@@ -694,9 +721,9 @@ static int buf_stream_write(
|
|
694
721
|
static int buf_stream_close(git_writestream *s)
|
695
722
|
{
|
696
723
|
struct buf_stream *buf_stream = (struct buf_stream *)s;
|
697
|
-
|
724
|
+
GIT_ASSERT_ARG(buf_stream);
|
698
725
|
|
699
|
-
|
726
|
+
GIT_ASSERT(buf_stream->complete == 0);
|
700
727
|
buf_stream->complete = 1;
|
701
728
|
|
702
729
|
return 0;
|
@@ -719,27 +746,47 @@ static void buf_stream_init(struct buf_stream *writer, git_buf *target)
|
|
719
746
|
git_buf_clear(target);
|
720
747
|
}
|
721
748
|
|
722
|
-
int
|
723
|
-
git_buf *
|
749
|
+
int git_filter_list_apply_to_buffer(
|
750
|
+
git_buf *out,
|
751
|
+
git_filter_list *filters,
|
752
|
+
const char *in,
|
753
|
+
size_t in_len)
|
724
754
|
{
|
725
755
|
struct buf_stream writer;
|
726
756
|
int error;
|
727
757
|
|
728
|
-
git_buf_sanitize(
|
729
|
-
|
758
|
+
if ((error = git_buf_sanitize(out)) < 0)
|
759
|
+
return error;
|
730
760
|
|
731
|
-
|
732
|
-
|
761
|
+
buf_stream_init(&writer, out);
|
762
|
+
|
763
|
+
if ((error = git_filter_list_stream_buffer(filters,
|
764
|
+
in, in_len, &writer.parent)) < 0)
|
765
|
+
return error;
|
766
|
+
|
767
|
+
GIT_ASSERT(writer.complete);
|
768
|
+
return error;
|
769
|
+
}
|
770
|
+
|
771
|
+
int git_filter_list__convert_buf(
|
772
|
+
git_buf *out,
|
773
|
+
git_filter_list *filters,
|
774
|
+
git_buf *in)
|
775
|
+
{
|
776
|
+
int error;
|
777
|
+
|
778
|
+
if (!filters || git_filter_list_length(filters) == 0) {
|
779
|
+
git_buf_swap(out, in);
|
780
|
+
git_buf_dispose(in);
|
733
781
|
return 0;
|
734
782
|
}
|
735
783
|
|
736
|
-
|
784
|
+
error = git_filter_list_apply_to_buffer(out, filters,
|
785
|
+
in->ptr, in->size);
|
737
786
|
|
738
|
-
if (
|
739
|
-
|
740
|
-
return error;
|
787
|
+
if (!error)
|
788
|
+
git_buf_dispose(in);
|
741
789
|
|
742
|
-
assert(writer.complete);
|
743
790
|
return error;
|
744
791
|
}
|
745
792
|
|
@@ -758,7 +805,7 @@ int git_filter_list_apply_to_file(
|
|
758
805
|
filters, repo, path, &writer.parent)) < 0)
|
759
806
|
return error;
|
760
807
|
|
761
|
-
|
808
|
+
GIT_ASSERT(writer.complete);
|
762
809
|
return error;
|
763
810
|
}
|
764
811
|
|
@@ -789,13 +836,14 @@ int git_filter_list_apply_to_blob(
|
|
789
836
|
filters, blob, &writer.parent)) < 0)
|
790
837
|
return error;
|
791
838
|
|
792
|
-
|
839
|
+
GIT_ASSERT(writer.complete);
|
793
840
|
return error;
|
794
841
|
}
|
795
842
|
|
796
|
-
struct
|
843
|
+
struct buffered_stream {
|
797
844
|
git_writestream parent;
|
798
845
|
git_filter *filter;
|
846
|
+
int (*write_fn)(git_filter *, void **, git_buf *, const git_buf *, const git_filter_source *);
|
799
847
|
const git_filter_source *source;
|
800
848
|
void **payload;
|
801
849
|
git_buf input;
|
@@ -804,89 +852,120 @@ struct proxy_stream {
|
|
804
852
|
git_writestream *target;
|
805
853
|
};
|
806
854
|
|
807
|
-
static int
|
855
|
+
static int buffered_stream_write(
|
808
856
|
git_writestream *s, const char *buffer, size_t len)
|
809
857
|
{
|
810
|
-
struct
|
811
|
-
|
858
|
+
struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
|
859
|
+
GIT_ASSERT_ARG(buffered_stream);
|
812
860
|
|
813
|
-
return git_buf_put(&
|
861
|
+
return git_buf_put(&buffered_stream->input, buffer, len);
|
814
862
|
}
|
815
863
|
|
816
|
-
static int
|
864
|
+
static int buffered_stream_close(git_writestream *s)
|
817
865
|
{
|
818
|
-
struct
|
866
|
+
struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
|
819
867
|
git_buf *writebuf;
|
820
868
|
git_error_state error_state = {0};
|
821
869
|
int error;
|
822
870
|
|
823
|
-
|
871
|
+
GIT_ASSERT_ARG(buffered_stream);
|
824
872
|
|
825
|
-
error =
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
&
|
830
|
-
|
873
|
+
error = buffered_stream->write_fn(
|
874
|
+
buffered_stream->filter,
|
875
|
+
buffered_stream->payload,
|
876
|
+
buffered_stream->output,
|
877
|
+
&buffered_stream->input,
|
878
|
+
buffered_stream->source);
|
831
879
|
|
832
880
|
if (error == GIT_PASSTHROUGH) {
|
833
|
-
writebuf = &
|
881
|
+
writebuf = &buffered_stream->input;
|
834
882
|
} else if (error == 0) {
|
835
|
-
git_buf_sanitize(
|
836
|
-
|
883
|
+
if ((error = git_buf_sanitize(buffered_stream->output)) < 0)
|
884
|
+
return error;
|
885
|
+
|
886
|
+
writebuf = buffered_stream->output;
|
837
887
|
} else {
|
838
888
|
/* close stream before erroring out taking care
|
839
889
|
* to preserve the original error */
|
840
890
|
git_error_state_capture(&error_state, error);
|
841
|
-
|
891
|
+
buffered_stream->target->close(buffered_stream->target);
|
842
892
|
git_error_state_restore(&error_state);
|
843
893
|
return error;
|
844
894
|
}
|
845
895
|
|
846
|
-
if ((error =
|
847
|
-
|
848
|
-
error =
|
896
|
+
if ((error = buffered_stream->target->write(
|
897
|
+
buffered_stream->target, writebuf->ptr, writebuf->size)) == 0)
|
898
|
+
error = buffered_stream->target->close(buffered_stream->target);
|
849
899
|
|
850
900
|
return error;
|
851
901
|
}
|
852
902
|
|
853
|
-
static void
|
903
|
+
static void buffered_stream_free(git_writestream *s)
|
854
904
|
{
|
855
|
-
struct
|
856
|
-
assert(proxy_stream);
|
905
|
+
struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
|
857
906
|
|
858
|
-
|
859
|
-
|
860
|
-
|
907
|
+
if (buffered_stream) {
|
908
|
+
git_buf_dispose(&buffered_stream->input);
|
909
|
+
git_buf_dispose(&buffered_stream->temp_buf);
|
910
|
+
git__free(buffered_stream);
|
911
|
+
}
|
861
912
|
}
|
862
913
|
|
863
|
-
|
914
|
+
int git_filter_buffered_stream_new(
|
864
915
|
git_writestream **out,
|
865
916
|
git_filter *filter,
|
917
|
+
int (*write_fn)(git_filter *, void **, git_buf *, const git_buf *, const git_filter_source *),
|
866
918
|
git_buf *temp_buf,
|
867
919
|
void **payload,
|
868
920
|
const git_filter_source *source,
|
869
921
|
git_writestream *target)
|
870
922
|
{
|
871
|
-
struct
|
872
|
-
GIT_ERROR_CHECK_ALLOC(
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
923
|
+
struct buffered_stream *buffered_stream = git__calloc(1, sizeof(struct buffered_stream));
|
924
|
+
GIT_ERROR_CHECK_ALLOC(buffered_stream);
|
925
|
+
|
926
|
+
buffered_stream->parent.write = buffered_stream_write;
|
927
|
+
buffered_stream->parent.close = buffered_stream_close;
|
928
|
+
buffered_stream->parent.free = buffered_stream_free;
|
929
|
+
buffered_stream->filter = filter;
|
930
|
+
buffered_stream->write_fn = write_fn;
|
931
|
+
buffered_stream->output = temp_buf ? temp_buf : &buffered_stream->temp_buf;
|
932
|
+
buffered_stream->payload = payload;
|
933
|
+
buffered_stream->source = source;
|
934
|
+
buffered_stream->target = target;
|
882
935
|
|
883
936
|
if (temp_buf)
|
884
937
|
git_buf_clear(temp_buf);
|
885
938
|
|
886
|
-
*out = (git_writestream *)
|
939
|
+
*out = (git_writestream *)buffered_stream;
|
887
940
|
return 0;
|
888
941
|
}
|
889
942
|
|
943
|
+
static int setup_stream(
|
944
|
+
git_writestream **out,
|
945
|
+
git_filter_entry *fe,
|
946
|
+
git_filter_list *filters,
|
947
|
+
git_writestream *last_stream)
|
948
|
+
{
|
949
|
+
#ifndef GIT_DEPRECATE_HARD
|
950
|
+
GIT_ASSERT(fe->filter->stream || fe->filter->apply);
|
951
|
+
|
952
|
+
/*
|
953
|
+
* If necessary, create a stream that proxies the traditional
|
954
|
+
* application.
|
955
|
+
*/
|
956
|
+
if (!fe->filter->stream) {
|
957
|
+
/* Create a stream that proxies the one-shot apply */
|
958
|
+
return git_filter_buffered_stream_new(out,
|
959
|
+
fe->filter, fe->filter->apply, filters->temp_buf,
|
960
|
+
&fe->payload, &filters->source, last_stream);
|
961
|
+
}
|
962
|
+
#endif
|
963
|
+
|
964
|
+
GIT_ASSERT(fe->filter->stream);
|
965
|
+
return fe->filter->stream(out, fe->filter,
|
966
|
+
&fe->payload, &filters->source, last_stream);
|
967
|
+
}
|
968
|
+
|
890
969
|
static int stream_list_init(
|
891
970
|
git_writestream **out,
|
892
971
|
git_vector *streams,
|
@@ -908,22 +987,11 @@ static int stream_list_init(
|
|
908
987
|
for (i = 0; i < git_array_size(filters->filters); ++i) {
|
909
988
|
size_t filter_idx = (filters->source.mode == GIT_FILTER_TO_WORKTREE) ?
|
910
989
|
git_array_size(filters->filters) - 1 - i : i;
|
990
|
+
|
911
991
|
git_filter_entry *fe = git_array_get(filters->filters, filter_idx);
|
912
992
|
git_writestream *filter_stream;
|
913
993
|
|
914
|
-
|
915
|
-
|
916
|
-
/* If necessary, create a stream that proxies the traditional
|
917
|
-
* application.
|
918
|
-
*/
|
919
|
-
if (fe->filter->stream)
|
920
|
-
error = fe->filter->stream(&filter_stream, fe->filter,
|
921
|
-
&fe->payload, &filters->source, last_stream);
|
922
|
-
else
|
923
|
-
/* Create a stream that proxies the one-shot apply */
|
924
|
-
error = proxy_stream_init(&filter_stream, fe->filter,
|
925
|
-
filters->temp_buf, &fe->payload, &filters->source,
|
926
|
-
last_stream);
|
994
|
+
error = setup_stream(&filter_stream, fe, filters, last_stream);
|
927
995
|
|
928
996
|
if (error < 0)
|
929
997
|
goto out;
|
@@ -967,8 +1035,10 @@ int git_filter_list_stream_file(
|
|
967
1035
|
|
968
1036
|
if ((error = stream_list_init(
|
969
1037
|
&stream_start, &filter_streams, filters, target)) < 0 ||
|
970
|
-
|
1038
|
+
(error = git_path_join_unrooted(&abspath, path, base, NULL)) < 0 ||
|
1039
|
+
(error = git_path_validate_workdir_buf(repo, &abspath)) < 0)
|
971
1040
|
goto done;
|
1041
|
+
|
972
1042
|
initialized = 1;
|
973
1043
|
|
974
1044
|
if ((fd = git_futils_open_ro(abspath.ptr)) < 0) {
|
@@ -995,23 +1065,21 @@ done:
|
|
995
1065
|
return error;
|
996
1066
|
}
|
997
1067
|
|
998
|
-
int
|
1068
|
+
int git_filter_list_stream_buffer(
|
999
1069
|
git_filter_list *filters,
|
1000
|
-
|
1070
|
+
const char *buffer,
|
1071
|
+
size_t len,
|
1001
1072
|
git_writestream *target)
|
1002
1073
|
{
|
1003
1074
|
git_vector filter_streams = GIT_VECTOR_INIT;
|
1004
1075
|
git_writestream *stream_start;
|
1005
1076
|
int error, initialized = 0;
|
1006
1077
|
|
1007
|
-
git_buf_sanitize(data);
|
1008
|
-
|
1009
1078
|
if ((error = stream_list_init(&stream_start, &filter_streams, filters, target)) < 0)
|
1010
1079
|
goto out;
|
1011
1080
|
initialized = 1;
|
1012
1081
|
|
1013
|
-
if ((error = stream_start->write(
|
1014
|
-
stream_start, data->ptr, data->size)) < 0)
|
1082
|
+
if ((error = stream_start->write(stream_start, buffer, len)) < 0)
|
1015
1083
|
goto out;
|
1016
1084
|
|
1017
1085
|
out:
|
@@ -1035,7 +1103,7 @@ int git_filter_list_stream_blob(
|
|
1035
1103
|
if (filters)
|
1036
1104
|
git_oid_cpy(&filters->source.oid, git_blob_id(blob));
|
1037
1105
|
|
1038
|
-
return
|
1106
|
+
return git_filter_list_stream_buffer(filters, in.ptr, in.size, target);
|
1039
1107
|
}
|
1040
1108
|
|
1041
1109
|
int git_filter_init(git_filter *filter, unsigned int version)
|
@@ -1043,3 +1111,31 @@ int git_filter_init(git_filter *filter, unsigned int version)
|
|
1043
1111
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(filter, version, git_filter, GIT_FILTER_INIT);
|
1044
1112
|
return 0;
|
1045
1113
|
}
|
1114
|
+
|
1115
|
+
#ifndef GIT_DEPRECATE_HARD
|
1116
|
+
|
1117
|
+
int git_filter_list_stream_data(
|
1118
|
+
git_filter_list *filters,
|
1119
|
+
git_buf *data,
|
1120
|
+
git_writestream *target)
|
1121
|
+
{
|
1122
|
+
int error;
|
1123
|
+
|
1124
|
+
if ((error = git_buf_sanitize(data)) < 0)
|
1125
|
+
return error;
|
1126
|
+
|
1127
|
+
return git_filter_list_stream_buffer(filters, data->ptr, data->size, target);
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
int git_filter_list_apply_to_data(
|
1131
|
+
git_buf *tgt, git_filter_list *filters, git_buf *src)
|
1132
|
+
{
|
1133
|
+
int error;
|
1134
|
+
|
1135
|
+
if ((error = git_buf_sanitize(src)) < 0)
|
1136
|
+
return error;
|
1137
|
+
|
1138
|
+
return git_filter_list_apply_to_buffer(tgt, filters, src->ptr, src->size);
|
1139
|
+
}
|
1140
|
+
|
1141
|
+
#endif
|