rugged 1.1.0 → 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 +18 -5
- data/vendor/libgit2/deps/ntlmclient/compat.h +0 -34
- 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 +156 -124
- 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/deps/ntlmclient/util.c +15 -1
- data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
- data/vendor/libgit2/include/git2/apply.h +2 -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 +31 -3
- 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 +19 -4
- data/vendor/libgit2/include/git2/config.h +1 -1
- data/vendor/libgit2/include/git2/deprecated.h +206 -6
- data/vendor/libgit2/include/git2/diff.h +35 -20
- 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 +3 -3
- data/vendor/libgit2/include/git2/indexer.h +2 -1
- data/vendor/libgit2/include/git2/odb.h +44 -20
- 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 +9 -5
- data/vendor/libgit2/include/git2/remote.h +59 -6
- data/vendor/libgit2/include/git2/repository.h +95 -52
- 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/transport.h +1 -1
- data/vendor/libgit2/include/git2/tree.h +2 -14
- data/vendor/libgit2/include/git2/types.h +9 -0
- data/vendor/libgit2/include/git2/version.h +3 -3
- 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 +26 -15
- data/vendor/libgit2/src/blob.c +44 -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 +26 -11
- 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 +9 -4
- 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 +11 -10
- 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 +112 -75
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +50 -32
- data/vendor/libgit2/src/integer.h +79 -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 +75 -32
- 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 +106 -60
- 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 +289 -51
- 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 +339 -125
- 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 +43 -12
- data/vendor/libgit2/src/posix.h +9 -0
- 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 +125 -71
- data/vendor/libgit2/src/reflog.c +19 -14
- data/vendor/libgit2/src/refs.c +91 -43
- data/vendor/libgit2/src/refs.h +1 -1
- data/vendor/libgit2/src/refspec.c +80 -44
- data/vendor/libgit2/src/remote.c +281 -105
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +191 -118
- data/vendor/libgit2/src/repository.h +13 -2
- 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 +62 -30
- 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 +138 -81
- 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/posix.h +3 -0
- 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 +77 -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 +32 -14
- 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 -364
- 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
@@ -655,7 +655,8 @@ int git_describe_commit(
|
|
655
655
|
int error = -1;
|
656
656
|
git_describe_options normalized;
|
657
657
|
|
658
|
-
|
658
|
+
GIT_ASSERT_ARG(result);
|
659
|
+
GIT_ASSERT_ARG(committish);
|
659
660
|
|
660
661
|
data.result = git__calloc(1, sizeof(git_describe_result));
|
661
662
|
GIT_ERROR_CHECK_ALLOC(data.result);
|
@@ -775,12 +776,14 @@ int git_describe_format(git_buf *out, const git_describe_result *result, const g
|
|
775
776
|
struct commit_name *name;
|
776
777
|
git_describe_format_options opts;
|
777
778
|
|
778
|
-
|
779
|
+
GIT_ASSERT_ARG(out);
|
780
|
+
GIT_ASSERT_ARG(result);
|
779
781
|
|
780
782
|
GIT_ERROR_CHECK_VERSION(given, GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, "git_describe_format_options");
|
781
783
|
normalize_format_options(&opts, given);
|
782
784
|
|
783
|
-
git_buf_sanitize(out)
|
785
|
+
if ((error = git_buf_sanitize(out)) < 0)
|
786
|
+
return error;
|
784
787
|
|
785
788
|
|
786
789
|
if (opts.always_use_long_format && opts.abbreviated_size == 0) {
|
data/vendor/libgit2/src/diff.c
CHANGED
@@ -77,7 +77,7 @@ void git_diff_addref(git_diff *diff)
|
|
77
77
|
|
78
78
|
size_t git_diff_num_deltas(const git_diff *diff)
|
79
79
|
{
|
80
|
-
|
80
|
+
GIT_ASSERT_ARG(diff);
|
81
81
|
return diff->deltas.length;
|
82
82
|
}
|
83
83
|
|
@@ -86,7 +86,7 @@ size_t git_diff_num_deltas_of_type(const git_diff *diff, git_delta_t type)
|
|
86
86
|
size_t i, count = 0;
|
87
87
|
const git_diff_delta *delta;
|
88
88
|
|
89
|
-
|
89
|
+
GIT_ASSERT_ARG(diff);
|
90
90
|
|
91
91
|
git_vector_foreach(&diff->deltas, i, delta) {
|
92
92
|
count += (delta->status == type);
|
@@ -97,7 +97,7 @@ size_t git_diff_num_deltas_of_type(const git_diff *diff, git_delta_t type)
|
|
97
97
|
|
98
98
|
const git_diff_delta *git_diff_get_delta(const git_diff *diff, size_t idx)
|
99
99
|
{
|
100
|
-
|
100
|
+
GIT_ASSERT_ARG_WITH_RETVAL(diff, NULL);
|
101
101
|
return git_vector_get(&diff->deltas, idx);
|
102
102
|
}
|
103
103
|
|
@@ -108,7 +108,7 @@ int git_diff_is_sorted_icase(const git_diff *diff)
|
|
108
108
|
|
109
109
|
int git_diff_get_perfdata(git_diff_perfdata *out, const git_diff *diff)
|
110
110
|
{
|
111
|
-
|
111
|
+
GIT_ASSERT_ARG(out);
|
112
112
|
GIT_ERROR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata");
|
113
113
|
out->stat_calls = diff->perf.stat_calls;
|
114
114
|
out->oid_calculations = diff->perf.oid_calculations;
|
@@ -127,7 +127,7 @@ int git_diff_foreach(
|
|
127
127
|
git_diff_delta *delta;
|
128
128
|
size_t idx;
|
129
129
|
|
130
|
-
|
130
|
+
GIT_ASSERT_ARG(diff);
|
131
131
|
|
132
132
|
git_vector_foreach(&diff->deltas, idx, delta) {
|
133
133
|
git_patch *patch;
|
@@ -243,8 +243,9 @@ int git_diff_format_email(
|
|
243
243
|
size_t allocsize;
|
244
244
|
int error;
|
245
245
|
|
246
|
-
|
247
|
-
|
246
|
+
GIT_ASSERT_ARG(out);
|
247
|
+
GIT_ASSERT_ARG(diff);
|
248
|
+
GIT_ASSERT_ARG(opts && opts->summary && opts->id && opts->author);
|
248
249
|
|
249
250
|
GIT_ERROR_CHECK_VERSION(opts,
|
250
251
|
GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION,
|
@@ -326,7 +327,9 @@ int git_diff_commit_as_email(
|
|
326
327
|
GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
|
327
328
|
int error;
|
328
329
|
|
329
|
-
|
330
|
+
GIT_ASSERT_ARG(out);
|
331
|
+
GIT_ASSERT_ARG(repo);
|
332
|
+
GIT_ASSERT_ARG(commit);
|
330
333
|
|
331
334
|
opts.flags = flags;
|
332
335
|
opts.patch_no = patch_no;
|
@@ -13,7 +13,6 @@
|
|
13
13
|
#include "diff.h"
|
14
14
|
#include "strmap.h"
|
15
15
|
#include "map.h"
|
16
|
-
#include "buf_text.h"
|
17
16
|
#include "config.h"
|
18
17
|
#include "regexp.h"
|
19
18
|
#include "repository.h"
|
@@ -142,18 +141,23 @@ static int diff_driver_funcname(const git_config_entry *entry, void *payload)
|
|
142
141
|
static git_diff_driver_registry *git_repository_driver_registry(
|
143
142
|
git_repository *repo)
|
144
143
|
{
|
145
|
-
|
146
|
-
|
147
|
-
|
144
|
+
git_diff_driver_registry *reg = git_atomic_load(repo->diff_drivers), *newreg;
|
145
|
+
if (reg)
|
146
|
+
return reg;
|
148
147
|
|
149
|
-
|
150
|
-
|
151
|
-
}
|
152
|
-
|
153
|
-
if (!repo->diff_drivers)
|
148
|
+
newreg = git_diff_driver_registry_new();
|
149
|
+
if (!newreg) {
|
154
150
|
git_error_set(GIT_ERROR_REPOSITORY, "unable to create diff driver registry");
|
155
|
-
|
156
|
-
|
151
|
+
return newreg;
|
152
|
+
}
|
153
|
+
reg = git_atomic_compare_and_swap(&repo->diff_drivers, NULL, newreg);
|
154
|
+
if (!reg) {
|
155
|
+
reg = newreg;
|
156
|
+
} else {
|
157
|
+
/* if we race, free losing allocation */
|
158
|
+
git_diff_driver_registry_free(newreg);
|
159
|
+
}
|
160
|
+
return reg;
|
157
161
|
}
|
158
162
|
|
159
163
|
static int diff_driver_alloc(
|
@@ -358,7 +362,7 @@ int git_diff_driver_lookup(
|
|
358
362
|
int error = 0;
|
359
363
|
const char *values[1], *attrs[] = { "diff" };
|
360
364
|
|
361
|
-
|
365
|
+
GIT_ASSERT_ARG(out);
|
362
366
|
*out = NULL;
|
363
367
|
|
364
368
|
if (!repo || !path || !strlen(path))
|
@@ -390,13 +394,13 @@ int git_diff_driver_lookup(
|
|
390
394
|
|
391
395
|
void git_diff_driver_free(git_diff_driver *driver)
|
392
396
|
{
|
393
|
-
|
397
|
+
git_diff_driver_pattern *pat;
|
394
398
|
|
395
399
|
if (!driver)
|
396
400
|
return;
|
397
401
|
|
398
|
-
|
399
|
-
git_regexp_dispose(&
|
402
|
+
while ((pat = git_array_pop(driver->fn_patterns)) != NULL)
|
403
|
+
git_regexp_dispose(&pat->re);
|
400
404
|
git_array_clear(driver->fn_patterns);
|
401
405
|
|
402
406
|
git_regexp_dispose(&driver->word_pattern);
|
@@ -428,8 +432,8 @@ int git_diff_driver_content_is_binary(
|
|
428
432
|
* let's just use the simple NUL-byte detection that core git uses.
|
429
433
|
*/
|
430
434
|
|
431
|
-
/* previously was: if (
|
432
|
-
if (
|
435
|
+
/* previously was: if (git_buf_is_binary(&search)) */
|
436
|
+
if (git_buf_contains_nul(&search))
|
433
437
|
return 1;
|
434
438
|
|
435
439
|
return 0;
|
@@ -362,10 +362,7 @@ static int diff_file_content_load_workdir_file(
|
|
362
362
|
if (!(error = git_futils_readbuffer_fd(&raw, fd, (size_t)fc->file->size))) {
|
363
363
|
git_buf out = GIT_BUF_INIT;
|
364
364
|
|
365
|
-
error =
|
366
|
-
|
367
|
-
if (out.ptr != raw.ptr)
|
368
|
-
git_buf_dispose(&raw);
|
365
|
+
error = git_filter_list__convert_buf(&out, fl, &raw);
|
369
366
|
|
370
367
|
if (!error) {
|
371
368
|
fc->map.len = out.size;
|
@@ -394,8 +391,7 @@ static int diff_file_content_load_workdir(
|
|
394
391
|
if (fc->file->mode == GIT_FILEMODE_TREE)
|
395
392
|
return 0;
|
396
393
|
|
397
|
-
if (
|
398
|
-
&path, git_repository_workdir(fc->repo), fc->file->path) < 0)
|
394
|
+
if (git_repository_workdir_path(&path, fc->repo, fc->file->path) < 0)
|
399
395
|
return -1;
|
400
396
|
|
401
397
|
if (S_ISLNK(fc->file->mode))
|
@@ -128,7 +128,7 @@ static int diff_delta__from_one(
|
|
128
128
|
git_diff_delta *delta;
|
129
129
|
const char *matched_pathspec;
|
130
130
|
|
131
|
-
|
131
|
+
GIT_ASSERT_ARG((oitem != NULL) ^ (nitem != NULL));
|
132
132
|
|
133
133
|
if (oitem) {
|
134
134
|
entry = oitem;
|
@@ -160,7 +160,7 @@ static int diff_delta__from_one(
|
|
160
160
|
GIT_ERROR_CHECK_ALLOC(delta);
|
161
161
|
|
162
162
|
/* This fn is just for single-sided diffs */
|
163
|
-
|
163
|
+
GIT_ASSERT(status != GIT_DELTA_MODIFIED);
|
164
164
|
delta->nfiles = 1;
|
165
165
|
|
166
166
|
if (has_old) {
|
@@ -408,7 +408,9 @@ static git_diff_generated *diff_generated_alloc(
|
|
408
408
|
git_diff_generated *diff;
|
409
409
|
git_diff_options dflt = GIT_DIFF_OPTIONS_INIT;
|
410
410
|
|
411
|
-
|
411
|
+
GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
|
412
|
+
GIT_ASSERT_ARG_WITH_RETVAL(old_iter, NULL);
|
413
|
+
GIT_ASSERT_ARG_WITH_RETVAL(new_iter, NULL);
|
412
414
|
|
413
415
|
if ((diff = git__calloc(1, sizeof(git_diff_generated))) == NULL)
|
414
416
|
return NULL;
|
@@ -589,13 +591,12 @@ int git_diff__oid_for_entry(
|
|
589
591
|
git_filter_list *fl = NULL;
|
590
592
|
int error = 0;
|
591
593
|
|
592
|
-
|
594
|
+
GIT_ASSERT(d->type == GIT_DIFF_TYPE_GENERATED);
|
593
595
|
diff = (git_diff_generated *)d;
|
594
596
|
|
595
597
|
memset(out, 0, sizeof(*out));
|
596
598
|
|
597
|
-
if (
|
598
|
-
git_repository_workdir(diff->base.repo), entry.path) < 0)
|
599
|
+
if (git_repository_workdir_path(&full_path, diff->base.repo, entry.path) < 0)
|
599
600
|
return -1;
|
600
601
|
|
601
602
|
if (!mode) {
|
@@ -678,6 +679,8 @@ typedef struct {
|
|
678
679
|
git_iterator *new_iter;
|
679
680
|
const git_index_entry *oitem;
|
680
681
|
const git_index_entry *nitem;
|
682
|
+
git_strmap *submodule_cache;
|
683
|
+
bool submodule_cache_initialized;
|
681
684
|
} diff_in_progress;
|
682
685
|
|
683
686
|
#define MODE_BITS_MASK 0000777
|
@@ -692,6 +695,7 @@ static int maybe_modified_submodule(
|
|
692
695
|
git_submodule *sub;
|
693
696
|
unsigned int sm_status = 0;
|
694
697
|
git_submodule_ignore_t ign = diff->base.opts.ignore_submodules;
|
698
|
+
git_strmap *submodule_cache = NULL;
|
695
699
|
|
696
700
|
*status = GIT_DELTA_UNMODIFIED;
|
697
701
|
|
@@ -699,8 +703,23 @@ static int maybe_modified_submodule(
|
|
699
703
|
ign == GIT_SUBMODULE_IGNORE_ALL)
|
700
704
|
return 0;
|
701
705
|
|
702
|
-
if (
|
703
|
-
|
706
|
+
if (diff->base.repo->submodule_cache != NULL) {
|
707
|
+
submodule_cache = diff->base.repo->submodule_cache;
|
708
|
+
} else {
|
709
|
+
if (!info->submodule_cache_initialized) {
|
710
|
+
info->submodule_cache_initialized = true;
|
711
|
+
/*
|
712
|
+
* Try to cache the submodule information to avoid having to parse it for
|
713
|
+
* every submodule. It is okay if it fails, the cache will still be NULL
|
714
|
+
* and the submodules will be attempted to be looked up individually.
|
715
|
+
*/
|
716
|
+
git_submodule_cache_init(&info->submodule_cache, diff->base.repo);
|
717
|
+
}
|
718
|
+
submodule_cache = info->submodule_cache;
|
719
|
+
}
|
720
|
+
|
721
|
+
if ((error = git_submodule__lookup_with_cache(
|
722
|
+
&sub, diff->base.repo, info->nitem->path, submodule_cache)) < 0) {
|
704
723
|
|
705
724
|
/* GIT_EEXISTS means dir with .git in it was found - ignore it */
|
706
725
|
if (error == GIT_EEXISTS) {
|
@@ -1190,7 +1209,7 @@ int git_diff__from_iterators(
|
|
1190
1209
|
const git_diff_options *opts)
|
1191
1210
|
{
|
1192
1211
|
git_diff_generated *diff;
|
1193
|
-
diff_in_progress info;
|
1212
|
+
diff_in_progress info = {0};
|
1194
1213
|
int error = 0;
|
1195
1214
|
|
1196
1215
|
*out = NULL;
|
@@ -1204,8 +1223,9 @@ int git_diff__from_iterators(
|
|
1204
1223
|
|
1205
1224
|
/* make iterators have matching icase behavior */
|
1206
1225
|
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE)) {
|
1207
|
-
git_iterator_set_ignore_case(old_iter, true)
|
1208
|
-
|
1226
|
+
if ((error = git_iterator_set_ignore_case(old_iter, true)) < 0 ||
|
1227
|
+
(error = git_iterator_set_ignore_case(new_iter, true)) < 0)
|
1228
|
+
goto cleanup;
|
1209
1229
|
}
|
1210
1230
|
|
1211
1231
|
/* finish initialization */
|
@@ -1257,6 +1277,8 @@ cleanup:
|
|
1257
1277
|
*out = &diff->base;
|
1258
1278
|
else
|
1259
1279
|
git_diff_free(&diff->base);
|
1280
|
+
if (info.submodule_cache)
|
1281
|
+
git_submodule_cache_free(info.submodule_cache);
|
1260
1282
|
|
1261
1283
|
return error;
|
1262
1284
|
}
|
@@ -1302,7 +1324,8 @@ int git_diff_tree_to_tree(
|
|
1302
1324
|
char *prefix = NULL;
|
1303
1325
|
int error = 0;
|
1304
1326
|
|
1305
|
-
|
1327
|
+
GIT_ASSERT_ARG(out);
|
1328
|
+
GIT_ASSERT_ARG(repo);
|
1306
1329
|
|
1307
1330
|
*out = NULL;
|
1308
1331
|
|
@@ -1358,7 +1381,8 @@ int git_diff_tree_to_index(
|
|
1358
1381
|
bool index_ignore_case = false;
|
1359
1382
|
int error = 0;
|
1360
1383
|
|
1361
|
-
|
1384
|
+
GIT_ASSERT_ARG(out);
|
1385
|
+
GIT_ASSERT_ARG(repo);
|
1362
1386
|
|
1363
1387
|
*out = NULL;
|
1364
1388
|
|
@@ -1401,7 +1425,8 @@ int git_diff_index_to_workdir(
|
|
1401
1425
|
char *prefix = NULL;
|
1402
1426
|
int error = 0;
|
1403
1427
|
|
1404
|
-
|
1428
|
+
GIT_ASSERT_ARG(out);
|
1429
|
+
GIT_ASSERT_ARG(repo);
|
1405
1430
|
|
1406
1431
|
*out = NULL;
|
1407
1432
|
|
@@ -1444,7 +1469,8 @@ int git_diff_tree_to_workdir(
|
|
1444
1469
|
git_index *index;
|
1445
1470
|
int error;
|
1446
1471
|
|
1447
|
-
|
1472
|
+
GIT_ASSERT_ARG(out);
|
1473
|
+
GIT_ASSERT_ARG(repo);
|
1448
1474
|
|
1449
1475
|
*out = NULL;
|
1450
1476
|
|
@@ -1477,7 +1503,8 @@ int git_diff_tree_to_workdir_with_index(
|
|
1477
1503
|
git_index *index = NULL;
|
1478
1504
|
int error = 0;
|
1479
1505
|
|
1480
|
-
|
1506
|
+
GIT_ASSERT_ARG(out);
|
1507
|
+
GIT_ASSERT_ARG(repo);
|
1481
1508
|
|
1482
1509
|
*out = NULL;
|
1483
1510
|
|
@@ -1513,7 +1540,9 @@ int git_diff_index_to_index(
|
|
1513
1540
|
char *prefix = NULL;
|
1514
1541
|
int error;
|
1515
1542
|
|
1516
|
-
|
1543
|
+
GIT_ASSERT_ARG(out);
|
1544
|
+
GIT_ASSERT_ARG(old_index);
|
1545
|
+
GIT_ASSERT_ARG(new_index);
|
1517
1546
|
|
1518
1547
|
*out = NULL;
|
1519
1548
|
|
@@ -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;
|
@@ -1038,7 +1039,7 @@ find_best_matches:
|
|
1038
1039
|
memcpy(&src->old_file, &swap, sizeof(src->old_file));
|
1039
1040
|
|
1040
1041
|
/* if we've just swapped the new element into the correct
|
1041
|
-
* place, clear the SPLIT
|
1042
|
+
* place, clear the SPLIT and RENAME_TARGET flags
|
1042
1043
|
*/
|
1043
1044
|
if (tgt2src[s].idx == t &&
|
1044
1045
|
tgt2src[s].similarity >
|
@@ -1046,7 +1047,7 @@ find_best_matches:
|
|
1046
1047
|
src->status = GIT_DELTA_RENAMED;
|
1047
1048
|
src->similarity = tgt2src[s].similarity;
|
1048
1049
|
tgt2src[s].similarity = 0;
|
1049
|
-
src->flags &= ~GIT_DIFF_FLAG__TO_SPLIT;
|
1050
|
+
src->flags &= ~(GIT_DIFF_FLAG__TO_SPLIT | GIT_DIFF_FLAG__IS_RENAME_TARGET);
|
1050
1051
|
num_rewrites--;
|
1051
1052
|
}
|
1052
1053
|
/* otherwise, if we just overwrote a source, update mapping */
|
@@ -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
|
|