rugged 1.5.0.1 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/extconf.rb +2 -2
- data/ext/rugged/rugged_allocator.c +0 -54
- data/ext/rugged/rugged_blame.c +2 -0
- data/ext/rugged/rugged_blob.c +3 -0
- data/ext/rugged/rugged_commit.c +1 -0
- data/ext/rugged/rugged_config.c +2 -0
- data/ext/rugged/rugged_diff.c +1 -0
- data/ext/rugged/rugged_index.c +2 -0
- data/ext/rugged/rugged_patch.c +1 -0
- data/ext/rugged/rugged_rebase.c +1 -0
- data/ext/rugged/rugged_reference.c +1 -0
- data/ext/rugged/rugged_remote.c +1 -0
- data/ext/rugged/rugged_repo.c +5 -2
- data/ext/rugged/rugged_revwalk.c +5 -1
- data/ext/rugged/rugged_submodule.c +1 -0
- data/ext/rugged/rugged_tag.c +1 -0
- data/ext/rugged/rugged_tree.c +4 -0
- data/lib/rugged/index.rb +1 -1
- data/lib/rugged/tree.rb +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +7 -8
- data/vendor/libgit2/COPYING +30 -0
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
- data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +3 -3
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +21 -2
- data/vendor/libgit2/cmake/SelectHashes.cmake +4 -0
- data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/pcre/LICENCE +5 -5
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
- data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
- data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +24 -22
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
- data/vendor/libgit2/include/git2/common.h +38 -6
- data/vendor/libgit2/include/git2/deprecated.h +6 -0
- data/vendor/libgit2/include/git2/diff.h +42 -4
- data/vendor/libgit2/include/git2/errors.h +4 -2
- data/vendor/libgit2/include/git2/experimental.h +20 -0
- data/vendor/libgit2/include/git2/index.h +9 -0
- data/vendor/libgit2/include/git2/indexer.h +29 -0
- data/vendor/libgit2/include/git2/object.h +28 -2
- data/vendor/libgit2/include/git2/odb.h +58 -7
- data/vendor/libgit2/include/git2/odb_backend.h +106 -18
- data/vendor/libgit2/include/git2/oid.h +116 -16
- data/vendor/libgit2/include/git2/remote.h +18 -0
- data/vendor/libgit2/include/git2/repository.h +32 -3
- data/vendor/libgit2/include/git2/stash.h +60 -6
- data/vendor/libgit2/include/git2/strarray.h +0 -13
- data/vendor/libgit2/include/git2/sys/alloc.h +0 -34
- data/vendor/libgit2/include/git2/sys/commit_graph.h +12 -2
- data/vendor/libgit2/include/git2/sys/midx.h +5 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/sys/stream.h +16 -2
- data/vendor/libgit2/include/git2/sys/transport.h +32 -2
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +3 -1
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +34 -17
- data/vendor/libgit2/src/cli/CMakeLists.txt +5 -2
- data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
- data/vendor/libgit2/src/cli/cmd_hash_object.c +27 -8
- data/vendor/libgit2/src/cli/opt.c +1 -1
- data/vendor/libgit2/src/cli/progress.c +9 -8
- data/vendor/libgit2/src/cli/progress.h +4 -4
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +25 -34
- data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
- data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
- data/vendor/libgit2/src/libgit2/apply.c +4 -3
- data/vendor/libgit2/src/libgit2/attr_file.c +1 -1
- data/vendor/libgit2/src/libgit2/attrcache.c +1 -1
- data/vendor/libgit2/src/libgit2/blame.c +23 -14
- data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
- data/vendor/libgit2/src/libgit2/blob.c +4 -2
- data/vendor/libgit2/src/libgit2/blob.h +2 -2
- data/vendor/libgit2/src/libgit2/branch.c +2 -2
- data/vendor/libgit2/src/libgit2/cherrypick.c +3 -3
- data/vendor/libgit2/src/libgit2/clone.c +34 -3
- data/vendor/libgit2/src/libgit2/commit.c +78 -21
- data/vendor/libgit2/src/libgit2/commit.h +25 -7
- data/vendor/libgit2/src/libgit2/commit_graph.c +129 -47
- data/vendor/libgit2/src/libgit2/commit_graph.h +23 -4
- data/vendor/libgit2/src/libgit2/commit_list.c +16 -5
- data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
- data/vendor/libgit2/src/libgit2/config.c +6 -3
- data/vendor/libgit2/src/libgit2/config_file.c +16 -10
- data/vendor/libgit2/src/libgit2/describe.c +11 -8
- data/vendor/libgit2/src/libgit2/diff.c +19 -6
- data/vendor/libgit2/src/libgit2/diff.h +6 -6
- data/vendor/libgit2/src/libgit2/diff_file.c +16 -7
- data/vendor/libgit2/src/libgit2/diff_generate.c +37 -11
- data/vendor/libgit2/src/libgit2/diff_parse.c +20 -4
- data/vendor/libgit2/src/libgit2/diff_print.c +26 -7
- data/vendor/libgit2/src/libgit2/diff_tform.c +4 -0
- data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/libgit2/email.c +4 -3
- data/vendor/libgit2/src/libgit2/errors.c +73 -18
- data/vendor/libgit2/src/libgit2/experimental.h.in +13 -0
- data/vendor/libgit2/src/libgit2/fetch.c +38 -13
- data/vendor/libgit2/src/libgit2/fetch.h +0 -2
- data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
- data/vendor/libgit2/src/libgit2/grafts.c +272 -0
- data/vendor/libgit2/src/libgit2/grafts.h +36 -0
- data/vendor/libgit2/src/libgit2/ident.c +3 -3
- data/vendor/libgit2/src/libgit2/index.c +327 -123
- data/vendor/libgit2/src/libgit2/index.h +14 -1
- data/vendor/libgit2/src/libgit2/indexer.c +116 -46
- data/vendor/libgit2/src/libgit2/iterator.c +21 -4
- data/vendor/libgit2/src/libgit2/iterator.h +3 -0
- data/vendor/libgit2/src/libgit2/libgit2.c +58 -0
- data/vendor/libgit2/src/libgit2/merge.c +14 -9
- data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
- data/vendor/libgit2/src/libgit2/midx.c +68 -38
- data/vendor/libgit2/src/libgit2/midx.h +13 -3
- data/vendor/libgit2/src/libgit2/mwindow.c +5 -2
- data/vendor/libgit2/src/libgit2/mwindow.h +4 -1
- data/vendor/libgit2/src/libgit2/notes.c +9 -8
- data/vendor/libgit2/src/libgit2/object.c +118 -29
- data/vendor/libgit2/src/libgit2/object.h +17 -2
- data/vendor/libgit2/src/libgit2/odb.c +224 -55
- data/vendor/libgit2/src/libgit2/odb.h +43 -4
- data/vendor/libgit2/src/libgit2/odb_loose.c +128 -70
- data/vendor/libgit2/src/libgit2/odb_pack.c +111 -46
- data/vendor/libgit2/src/libgit2/oid.c +141 -77
- data/vendor/libgit2/src/libgit2/oid.h +183 -9
- data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
- data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
- data/vendor/libgit2/src/libgit2/pack-objects.c +31 -13
- data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
- data/vendor/libgit2/src/libgit2/pack.c +93 -70
- data/vendor/libgit2/src/libgit2/pack.h +29 -15
- data/vendor/libgit2/src/libgit2/parse.c +8 -4
- data/vendor/libgit2/src/libgit2/parse.h +1 -1
- data/vendor/libgit2/src/libgit2/patch.h +7 -1
- data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
- data/vendor/libgit2/src/libgit2/patch_parse.c +16 -8
- data/vendor/libgit2/src/libgit2/push.c +13 -3
- data/vendor/libgit2/src/libgit2/reader.c +1 -1
- data/vendor/libgit2/src/libgit2/rebase.c +72 -83
- data/vendor/libgit2/src/libgit2/refdb_fs.c +92 -52
- data/vendor/libgit2/src/libgit2/reflog.c +7 -5
- data/vendor/libgit2/src/libgit2/reflog.h +1 -2
- data/vendor/libgit2/src/libgit2/refs.c +9 -0
- data/vendor/libgit2/src/libgit2/remote.c +47 -37
- data/vendor/libgit2/src/libgit2/remote.h +41 -0
- data/vendor/libgit2/src/libgit2/repository.c +784 -329
- data/vendor/libgit2/src/libgit2/repository.h +26 -2
- data/vendor/libgit2/src/libgit2/reset.c +2 -2
- data/vendor/libgit2/src/libgit2/revert.c +8 -11
- data/vendor/libgit2/src/libgit2/revparse.c +23 -7
- data/vendor/libgit2/src/libgit2/revwalk.c +31 -5
- data/vendor/libgit2/src/libgit2/stash.c +209 -33
- data/vendor/libgit2/src/libgit2/strarray.c +1 -0
- data/vendor/libgit2/src/libgit2/strarray.h +25 -0
- data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
- data/vendor/libgit2/src/libgit2/streams/openssl.c +9 -17
- data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +7 -3
- data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
- data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
- data/vendor/libgit2/src/libgit2/streams/socket.c +240 -51
- data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
- data/vendor/libgit2/src/libgit2/streams/stransport.c +40 -12
- data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
- data/vendor/libgit2/src/libgit2/submodule.c +6 -2
- data/vendor/libgit2/src/libgit2/submodule.h +3 -3
- data/vendor/libgit2/src/libgit2/sysdir.c +294 -7
- data/vendor/libgit2/src/libgit2/sysdir.h +41 -9
- data/vendor/libgit2/src/libgit2/tag.c +29 -10
- data/vendor/libgit2/src/libgit2/tag.h +2 -2
- data/vendor/libgit2/src/libgit2/threadstate.c +15 -2
- data/vendor/libgit2/src/libgit2/threadstate.h +1 -3
- data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
- data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
- data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
- data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
- data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
- data/vendor/libgit2/src/libgit2/transports/http.c +15 -9
- data/vendor/libgit2/src/libgit2/transports/httpclient.c +14 -0
- data/vendor/libgit2/src/libgit2/transports/httpclient.h +10 -0
- data/vendor/libgit2/src/libgit2/transports/local.c +27 -4
- data/vendor/libgit2/src/libgit2/transports/smart.c +68 -27
- data/vendor/libgit2/src/libgit2/transports/smart.h +33 -9
- data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +281 -49
- data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +192 -55
- data/vendor/libgit2/src/libgit2/transports/ssh.c +334 -102
- data/vendor/libgit2/src/libgit2/transports/winhttp.c +22 -18
- data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
- data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
- data/vendor/libgit2/src/libgit2/tree.c +23 -17
- data/vendor/libgit2/src/libgit2/tree.h +2 -2
- data/vendor/libgit2/src/libgit2/worktree.c +30 -10
- data/vendor/libgit2/src/util/CMakeLists.txt +6 -1
- data/vendor/libgit2/src/util/alloc.c +65 -6
- data/vendor/libgit2/src/util/alloc.h +34 -9
- data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
- data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
- data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -105
- data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
- data/vendor/libgit2/src/util/array.h +6 -1
- data/vendor/libgit2/src/util/cc-compat.h +2 -0
- data/vendor/libgit2/src/util/filebuf.c +6 -1
- data/vendor/libgit2/src/util/filebuf.h +19 -6
- data/vendor/libgit2/src/util/fs_path.c +2 -2
- data/vendor/libgit2/src/util/futils.c +8 -8
- data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +9 -3
- data/vendor/libgit2/src/util/git2_util.h +2 -2
- data/vendor/libgit2/src/util/hash/openssl.c +4 -3
- data/vendor/libgit2/src/util/hash/rfc6234/sha.h +0 -112
- data/vendor/libgit2/src/util/hash.h +13 -0
- data/vendor/libgit2/src/util/net.c +492 -87
- data/vendor/libgit2/src/util/net.h +32 -0
- data/vendor/libgit2/src/util/posix.c +54 -0
- data/vendor/libgit2/src/util/posix.h +24 -0
- data/vendor/libgit2/src/util/rand.c +10 -4
- data/vendor/libgit2/src/util/regexp.c +3 -3
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/util/thread.h +20 -19
- data/vendor/libgit2/src/util/util.c +15 -10
- data/vendor/libgit2/src/util/util.h +25 -16
- data/vendor/libgit2/src/util/win32/error.c +1 -1
- data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
- data/vendor/libgit2/src/util/win32/posix_w32.c +1 -1
- data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
- data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
- data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
- metadata +34 -26
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
- data/vendor/libgit2/src/libgit2/netops.c +0 -124
- data/vendor/libgit2/src/libgit2/netops.h +0 -68
- data/vendor/libgit2/src/util/win32/findfile.c +0 -286
- data/vendor/libgit2/src/util/win32/findfile.h +0 -22
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -27,7 +27,7 @@ struct git_index {
|
|
27
27
|
|
28
28
|
char *index_file_path;
|
29
29
|
git_futils_filestamp stamp;
|
30
|
-
unsigned char checksum[
|
30
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
31
31
|
|
32
32
|
git_vector entries;
|
33
33
|
git_idxmap *entries_map;
|
@@ -35,6 +35,8 @@ struct git_index {
|
|
35
35
|
git_vector deleted; /* deleted entries if readers > 0 */
|
36
36
|
git_atomic32 readers; /* number of active iterators */
|
37
37
|
|
38
|
+
git_oid_t oid_type;
|
39
|
+
|
38
40
|
unsigned int on_disk:1;
|
39
41
|
unsigned int ignore_case:1;
|
40
42
|
unsigned int distrust_filemode:1;
|
@@ -141,6 +143,17 @@ GIT_INLINE(unsigned char *) git_index__checksum(git_index *index)
|
|
141
143
|
return index->checksum;
|
142
144
|
}
|
143
145
|
|
146
|
+
/* SHA256-aware internal functions */
|
147
|
+
|
148
|
+
extern int git_index__new(
|
149
|
+
git_index **index_out,
|
150
|
+
git_oid_t oid_type);
|
151
|
+
|
152
|
+
extern int git_index__open(
|
153
|
+
git_index **index_out,
|
154
|
+
const char *index_path,
|
155
|
+
git_oid_t oid_type);
|
156
|
+
|
144
157
|
/* Copy the current entries vector *and* increment the index refcount.
|
145
158
|
* Call `git_index__release_snapshot` when done.
|
146
159
|
*/
|
@@ -42,6 +42,7 @@ struct git_indexer {
|
|
42
42
|
have_delta :1,
|
43
43
|
do_fsync :1,
|
44
44
|
do_verify :1;
|
45
|
+
git_oid_t oid_type;
|
45
46
|
struct git_pack_header hdr;
|
46
47
|
struct git_pack_file *pack;
|
47
48
|
unsigned int mode;
|
@@ -55,8 +56,8 @@ struct git_indexer {
|
|
55
56
|
git_vector deltas;
|
56
57
|
unsigned int fanout[256];
|
57
58
|
git_hash_ctx hash_ctx;
|
58
|
-
unsigned char checksum[
|
59
|
-
char name[(
|
59
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
60
|
+
char name[(GIT_HASH_MAX_SIZE * 2) + 1];
|
60
61
|
git_indexer_progress_cb progress_cb;
|
61
62
|
void *progress_payload;
|
62
63
|
char objbuf[8*1024];
|
@@ -68,7 +69,7 @@ struct git_indexer {
|
|
68
69
|
git_odb *odb;
|
69
70
|
|
70
71
|
/* Fields for calculating the packfile trailer (hash of everything before it) */
|
71
|
-
char inbuf[
|
72
|
+
char inbuf[GIT_HASH_MAX_SIZE];
|
72
73
|
size_t inbuf_len;
|
73
74
|
git_hash_ctx trailer;
|
74
75
|
};
|
@@ -136,17 +137,33 @@ int git_indexer_init_options(git_indexer_options *opts, unsigned int version)
|
|
136
137
|
}
|
137
138
|
#endif
|
138
139
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
140
|
+
GIT_INLINE(git_hash_algorithm_t) indexer_hash_algorithm(git_indexer *idx)
|
141
|
+
{
|
142
|
+
switch (idx->oid_type) {
|
143
|
+
case GIT_OID_SHA1:
|
144
|
+
return GIT_HASH_ALGORITHM_SHA1;
|
145
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
146
|
+
case GIT_OID_SHA256:
|
147
|
+
return GIT_HASH_ALGORITHM_SHA256;
|
148
|
+
#endif
|
149
|
+
}
|
150
|
+
|
151
|
+
return GIT_HASH_ALGORITHM_NONE;
|
152
|
+
}
|
153
|
+
|
154
|
+
static int indexer_new(
|
155
|
+
git_indexer **out,
|
156
|
+
const char *prefix,
|
157
|
+
git_oid_t oid_type,
|
158
|
+
unsigned int mode,
|
159
|
+
git_odb *odb,
|
160
|
+
git_indexer_options *in_opts)
|
145
161
|
{
|
146
162
|
git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT;
|
147
163
|
git_indexer *idx;
|
148
164
|
git_str path = GIT_STR_INIT, tmp_path = GIT_STR_INIT;
|
149
165
|
static const char suff[] = "/pack";
|
166
|
+
git_hash_algorithm_t checksum_type;
|
150
167
|
int error, fd = -1;
|
151
168
|
|
152
169
|
if (in_opts)
|
@@ -154,14 +171,17 @@ int git_indexer_new(
|
|
154
171
|
|
155
172
|
idx = git__calloc(1, sizeof(git_indexer));
|
156
173
|
GIT_ERROR_CHECK_ALLOC(idx);
|
174
|
+
idx->oid_type = oid_type;
|
157
175
|
idx->odb = odb;
|
158
176
|
idx->progress_cb = opts.progress_cb;
|
159
177
|
idx->progress_payload = opts.progress_cb_payload;
|
160
178
|
idx->mode = mode ? mode : GIT_PACK_FILE_MODE;
|
161
179
|
git_str_init(&idx->entry_data, 0);
|
162
180
|
|
163
|
-
|
164
|
-
|
181
|
+
checksum_type = indexer_hash_algorithm(idx);
|
182
|
+
|
183
|
+
if ((error = git_hash_ctx_init(&idx->hash_ctx, checksum_type)) < 0 ||
|
184
|
+
(error = git_hash_ctx_init(&idx->trailer, checksum_type)) < 0 ||
|
165
185
|
(error = git_oidmap_new(&idx->expected_oids)) < 0)
|
166
186
|
goto cleanup;
|
167
187
|
|
@@ -179,7 +199,7 @@ int git_indexer_new(
|
|
179
199
|
if (fd < 0)
|
180
200
|
goto cleanup;
|
181
201
|
|
182
|
-
error = git_packfile_alloc(&idx->pack, git_str_cstr(&tmp_path));
|
202
|
+
error = git_packfile_alloc(&idx->pack, git_str_cstr(&tmp_path), oid_type);
|
183
203
|
git_str_dispose(&tmp_path);
|
184
204
|
|
185
205
|
if (error < 0)
|
@@ -208,6 +228,33 @@ cleanup:
|
|
208
228
|
return -1;
|
209
229
|
}
|
210
230
|
|
231
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
232
|
+
int git_indexer_new(
|
233
|
+
git_indexer **out,
|
234
|
+
const char *prefix,
|
235
|
+
git_oid_t oid_type,
|
236
|
+
git_indexer_options *opts)
|
237
|
+
{
|
238
|
+
return indexer_new(
|
239
|
+
out,
|
240
|
+
prefix,
|
241
|
+
oid_type,
|
242
|
+
opts ? opts->mode : 0,
|
243
|
+
opts ? opts->odb : NULL,
|
244
|
+
opts);
|
245
|
+
}
|
246
|
+
#else
|
247
|
+
int git_indexer_new(
|
248
|
+
git_indexer **out,
|
249
|
+
const char *prefix,
|
250
|
+
unsigned int mode,
|
251
|
+
git_odb *odb,
|
252
|
+
git_indexer_options *opts)
|
253
|
+
{
|
254
|
+
return indexer_new(out, prefix, GIT_OID_SHA1, mode, odb, opts);
|
255
|
+
}
|
256
|
+
#endif
|
257
|
+
|
211
258
|
void git_indexer__set_fsync(git_indexer *idx, int do_fsync)
|
212
259
|
{
|
213
260
|
idx->do_fsync = !!do_fsync;
|
@@ -272,7 +319,7 @@ static int advance_delta_offset(git_indexer *idx, git_object_t type)
|
|
272
319
|
GIT_ASSERT_ARG(type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA);
|
273
320
|
|
274
321
|
if (type == GIT_OBJECT_REF_DELTA) {
|
275
|
-
idx->off +=
|
322
|
+
idx->off += git_oid_size(idx->oid_type);
|
276
323
|
} else {
|
277
324
|
off64_t base_off;
|
278
325
|
int error = get_delta_base(&base_off, idx->pack, &w, &idx->off, type, idx->entry_start);
|
@@ -356,7 +403,7 @@ static int check_object_connectivity(git_indexer *idx, const git_rawobj *obj)
|
|
356
403
|
obj->type != GIT_OBJECT_TAG)
|
357
404
|
return 0;
|
358
405
|
|
359
|
-
if (git_object__from_raw(&object, obj->data, obj->len, obj->type) < 0) {
|
406
|
+
if (git_object__from_raw(&object, obj->data, obj->len, obj->type, idx->oid_type) < 0) {
|
360
407
|
/*
|
361
408
|
* parse_raw returns EINVALID on invalid data; downgrade
|
362
409
|
* that to a normal -1 error code.
|
@@ -444,6 +491,11 @@ static int store_object(git_indexer *idx)
|
|
444
491
|
git__free(pentry);
|
445
492
|
goto on_error;
|
446
493
|
}
|
494
|
+
|
495
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
496
|
+
oid.type = idx->oid_type;
|
497
|
+
#endif
|
498
|
+
|
447
499
|
entry_size = idx->off - entry_start;
|
448
500
|
if (entry_start > UINT31_MAX) {
|
449
501
|
entry->offset = UINT32_MAX;
|
@@ -463,16 +515,22 @@ static int store_object(git_indexer *idx)
|
|
463
515
|
goto on_error;
|
464
516
|
}
|
465
517
|
|
466
|
-
git_oid_cpy(&pentry->
|
518
|
+
git_oid_cpy(&pentry->id, &oid);
|
467
519
|
pentry->offset = entry_start;
|
468
520
|
|
469
|
-
if (git_oidmap_exists(idx->pack->idx_cache, &pentry->
|
470
|
-
|
521
|
+
if (git_oidmap_exists(idx->pack->idx_cache, &pentry->id)) {
|
522
|
+
const char *idstr = git_oid_tostr_s(&pentry->id);
|
523
|
+
|
524
|
+
if (!idstr)
|
525
|
+
git_error_set(GIT_ERROR_INDEXER, "failed to parse object id");
|
526
|
+
else
|
527
|
+
git_error_set(GIT_ERROR_INDEXER, "duplicate object %s found in pack", idstr);
|
528
|
+
|
471
529
|
git__free(pentry);
|
472
530
|
goto on_error;
|
473
531
|
}
|
474
532
|
|
475
|
-
if ((error = git_oidmap_set(idx->pack->idx_cache, &pentry->
|
533
|
+
if ((error = git_oidmap_set(idx->pack->idx_cache, &pentry->id, pentry)) < 0) {
|
476
534
|
git__free(pentry);
|
477
535
|
git_error_set_oom();
|
478
536
|
goto on_error;
|
@@ -517,8 +575,8 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
|
|
517
575
|
|
518
576
|
pentry->offset = entry_start;
|
519
577
|
|
520
|
-
if (git_oidmap_exists(idx->pack->idx_cache, &pentry->
|
521
|
-
git_oidmap_set(idx->pack->idx_cache, &pentry->
|
578
|
+
if (git_oidmap_exists(idx->pack->idx_cache, &pentry->id) ||
|
579
|
+
git_oidmap_set(idx->pack->idx_cache, &pentry->id, pentry) < 0) {
|
522
580
|
git_error_set(GIT_ERROR_INDEXER, "cannot insert object into pack");
|
523
581
|
return -1;
|
524
582
|
}
|
@@ -544,7 +602,7 @@ static int hash_and_save(git_indexer *idx, git_rawobj *obj, off64_t entry_start)
|
|
544
602
|
entry = git__calloc(1, sizeof(*entry));
|
545
603
|
GIT_ERROR_CHECK_ALLOC(entry);
|
546
604
|
|
547
|
-
if (git_odb__hashobj(&oid, obj) < 0) {
|
605
|
+
if (git_odb__hashobj(&oid, obj, idx->oid_type) < 0) {
|
548
606
|
git_error_set(GIT_ERROR_INDEXER, "failed to hash object");
|
549
607
|
goto on_error;
|
550
608
|
}
|
@@ -552,7 +610,7 @@ static int hash_and_save(git_indexer *idx, git_rawobj *obj, off64_t entry_start)
|
|
552
610
|
pentry = git__calloc(1, sizeof(struct git_pack_entry));
|
553
611
|
GIT_ERROR_CHECK_ALLOC(pentry);
|
554
612
|
|
555
|
-
git_oid_cpy(&pentry->
|
613
|
+
git_oid_cpy(&pentry->id, &oid);
|
556
614
|
git_oid_cpy(&entry->oid, &oid);
|
557
615
|
entry->crc = crc32(0L, Z_NULL, 0);
|
558
616
|
|
@@ -578,34 +636,38 @@ static int do_progress_callback(git_indexer *idx, git_indexer_progress *stats)
|
|
578
636
|
return 0;
|
579
637
|
}
|
580
638
|
|
581
|
-
/* Hash everything but the
|
639
|
+
/* Hash everything but the checksum trailer */
|
582
640
|
static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
|
583
641
|
{
|
584
642
|
size_t to_expell, to_keep;
|
643
|
+
size_t oid_size = git_oid_size(idx->oid_type);
|
585
644
|
|
586
645
|
if (size == 0)
|
587
646
|
return;
|
588
647
|
|
589
|
-
/*
|
590
|
-
|
648
|
+
/*
|
649
|
+
* Easy case, dump the buffer and the data minus the trailing
|
650
|
+
* checksum (SHA1 or SHA256).
|
651
|
+
*/
|
652
|
+
if (size >= oid_size) {
|
591
653
|
git_hash_update(&idx->trailer, idx->inbuf, idx->inbuf_len);
|
592
|
-
git_hash_update(&idx->trailer, data, size -
|
654
|
+
git_hash_update(&idx->trailer, data, size - oid_size);
|
593
655
|
|
594
|
-
data += size -
|
595
|
-
memcpy(idx->inbuf, data,
|
596
|
-
idx->inbuf_len =
|
656
|
+
data += size - oid_size;
|
657
|
+
memcpy(idx->inbuf, data, oid_size);
|
658
|
+
idx->inbuf_len = oid_size;
|
597
659
|
return;
|
598
660
|
}
|
599
661
|
|
600
662
|
/* We can just append */
|
601
|
-
if (idx->inbuf_len + size <=
|
663
|
+
if (idx->inbuf_len + size <= oid_size) {
|
602
664
|
memcpy(idx->inbuf + idx->inbuf_len, data, size);
|
603
665
|
idx->inbuf_len += size;
|
604
666
|
return;
|
605
667
|
}
|
606
668
|
|
607
669
|
/* We need to partially drain the buffer and then append */
|
608
|
-
to_keep =
|
670
|
+
to_keep = oid_size - size;
|
609
671
|
to_expell = idx->inbuf_len - to_keep;
|
610
672
|
|
611
673
|
git_hash_update(&idx->trailer, idx->inbuf, to_expell);
|
@@ -724,12 +786,14 @@ static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
|
|
724
786
|
{
|
725
787
|
git_packfile_stream *stream = &idx->stream;
|
726
788
|
off64_t entry_start = idx->off;
|
727
|
-
size_t entry_size;
|
789
|
+
size_t oid_size, entry_size;
|
728
790
|
git_object_t type;
|
729
791
|
git_mwindow *w = NULL;
|
730
792
|
int error;
|
731
793
|
|
732
|
-
|
794
|
+
oid_size = git_oid_size(idx->oid_type);
|
795
|
+
|
796
|
+
if (idx->pack->mwf.size <= idx->off + (long long)oid_size)
|
733
797
|
return GIT_EBUFS;
|
734
798
|
|
735
799
|
if (!idx->have_stream) {
|
@@ -900,7 +964,7 @@ static int index_path(git_str *path, git_indexer *idx, const char *suffix)
|
|
900
964
|
slash--;
|
901
965
|
|
902
966
|
if (git_str_grow(path, slash + 1 + strlen(prefix) +
|
903
|
-
|
967
|
+
git_oid_hexsize(idx->oid_type) + strlen(suffix) + 1) < 0)
|
904
968
|
return -1;
|
905
969
|
|
906
970
|
git_str_truncate(path, slash);
|
@@ -917,7 +981,7 @@ static int index_path(git_str *path, git_indexer *idx, const char *suffix)
|
|
917
981
|
*/
|
918
982
|
static int seek_back_trailer(git_indexer *idx)
|
919
983
|
{
|
920
|
-
idx->pack->mwf.size -=
|
984
|
+
idx->pack->mwf.size -= git_oid_size(idx->oid_type);
|
921
985
|
return git_mwindow_free_all(&idx->pack->mwf);
|
922
986
|
}
|
923
987
|
|
@@ -926,15 +990,17 @@ static int inject_object(git_indexer *idx, git_oid *id)
|
|
926
990
|
git_odb_object *obj = NULL;
|
927
991
|
struct entry *entry = NULL;
|
928
992
|
struct git_pack_entry *pentry = NULL;
|
929
|
-
unsigned char empty_checksum[
|
993
|
+
unsigned char empty_checksum[GIT_HASH_MAX_SIZE] = {0};
|
930
994
|
unsigned char hdr[64];
|
931
995
|
git_str buf = GIT_STR_INIT;
|
932
996
|
off64_t entry_start;
|
933
997
|
const void *data;
|
934
998
|
size_t len, hdr_len;
|
935
|
-
size_t checksum_size
|
999
|
+
size_t checksum_size;
|
936
1000
|
int error;
|
937
1001
|
|
1002
|
+
checksum_size = git_hash_size(indexer_hash_algorithm(idx));
|
1003
|
+
|
938
1004
|
if ((error = seek_back_trailer(idx)) < 0)
|
939
1005
|
goto cleanup;
|
940
1006
|
|
@@ -977,12 +1043,12 @@ static int inject_object(git_indexer *idx, git_oid *id)
|
|
977
1043
|
if ((error = append_to_pack(idx, empty_checksum, checksum_size)) < 0)
|
978
1044
|
goto cleanup;
|
979
1045
|
|
980
|
-
idx->pack->mwf.size +=
|
1046
|
+
idx->pack->mwf.size += git_oid_size(idx->oid_type);
|
981
1047
|
|
982
1048
|
pentry = git__calloc(1, sizeof(struct git_pack_entry));
|
983
1049
|
GIT_ERROR_CHECK_ALLOC(pentry);
|
984
1050
|
|
985
|
-
git_oid_cpy(&pentry->
|
1051
|
+
git_oid_cpy(&pentry->id, id);
|
986
1052
|
git_oid_cpy(&entry->oid, id);
|
987
1053
|
idx->off = entry_start + hdr_len + len;
|
988
1054
|
|
@@ -1040,13 +1106,13 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
|
|
1040
1106
|
}
|
1041
1107
|
|
1042
1108
|
/* curpos now points to the base information, which is an OID */
|
1043
|
-
base_info = git_mwindow_open(&idx->pack->mwf, &w, curpos,
|
1109
|
+
base_info = git_mwindow_open(&idx->pack->mwf, &w, curpos, git_oid_size(idx->oid_type), &left);
|
1044
1110
|
if (base_info == NULL) {
|
1045
1111
|
git_error_set(GIT_ERROR_INDEXER, "failed to map delta information");
|
1046
1112
|
return -1;
|
1047
1113
|
}
|
1048
1114
|
|
1049
|
-
|
1115
|
+
git_oid__fromraw(&base, base_info, idx->oid_type);
|
1050
1116
|
git_mwindow_close(&w);
|
1051
1117
|
|
1052
1118
|
if (has_entry(idx, &base))
|
@@ -1168,10 +1234,11 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
|
|
1168
1234
|
struct git_pack_idx_header hdr;
|
1169
1235
|
git_str filename = GIT_STR_INIT;
|
1170
1236
|
struct entry *entry;
|
1171
|
-
unsigned char checksum[
|
1237
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
1172
1238
|
git_filebuf index_file = {0};
|
1173
1239
|
void *packfile_trailer;
|
1174
|
-
size_t checksum_size
|
1240
|
+
size_t checksum_size;
|
1241
|
+
int filebuf_hash;
|
1175
1242
|
bool mismatch;
|
1176
1243
|
|
1177
1244
|
if (!idx->parsed_header) {
|
@@ -1179,6 +1246,10 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
|
|
1179
1246
|
return -1;
|
1180
1247
|
}
|
1181
1248
|
|
1249
|
+
checksum_size = git_hash_size(indexer_hash_algorithm(idx));
|
1250
|
+
filebuf_hash = git_filebuf_hash_flags(indexer_hash_algorithm(idx));
|
1251
|
+
GIT_ASSERT(checksum_size);
|
1252
|
+
|
1182
1253
|
/* Test for this before resolve_deltas(), as it plays with idx->off */
|
1183
1254
|
if (idx->off + (ssize_t)checksum_size < idx->pack->mwf.size) {
|
1184
1255
|
git_error_set(GIT_ERROR_INDEXER, "unexpected data at the end of the pack");
|
@@ -1251,8 +1322,7 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
|
|
1251
1322
|
return -1;
|
1252
1323
|
|
1253
1324
|
if (git_filebuf_open(&index_file, filename.ptr,
|
1254
|
-
|
1255
|
-
(idx->do_fsync ? GIT_FILEBUF_FSYNC : 0),
|
1325
|
+
filebuf_hash | (idx->do_fsync ? GIT_FILEBUF_FSYNC : 0),
|
1256
1326
|
idx->mode) < 0)
|
1257
1327
|
goto on_error;
|
1258
1328
|
|
@@ -1269,7 +1339,7 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
|
|
1269
1339
|
|
1270
1340
|
/* Write out the object names (SHA-1 hashes) */
|
1271
1341
|
git_vector_foreach(&idx->objects, i, entry) {
|
1272
|
-
git_filebuf_write(&index_file, &entry->oid.id,
|
1342
|
+
git_filebuf_write(&index_file, &entry->oid.id, git_oid_size(idx->oid_type));
|
1273
1343
|
}
|
1274
1344
|
|
1275
1345
|
/* Write out the CRC32 values */
|
@@ -1036,6 +1036,8 @@ typedef struct {
|
|
1036
1036
|
git_index *index;
|
1037
1037
|
git_vector index_snapshot;
|
1038
1038
|
|
1039
|
+
git_oid_t oid_type;
|
1040
|
+
|
1039
1041
|
git_array_t(filesystem_iterator_frame) frames;
|
1040
1042
|
git_ignores ignores;
|
1041
1043
|
|
@@ -1271,7 +1273,7 @@ static int filesystem_iterator_entry_hash(
|
|
1271
1273
|
int error;
|
1272
1274
|
|
1273
1275
|
if (S_ISDIR(entry->st.st_mode)) {
|
1274
|
-
memset(&entry->id, 0,
|
1276
|
+
memset(&entry->id, 0, git_oid_size(iter->oid_type));
|
1275
1277
|
return 0;
|
1276
1278
|
}
|
1277
1279
|
|
@@ -1281,7 +1283,7 @@ static int filesystem_iterator_entry_hash(
|
|
1281
1283
|
|
1282
1284
|
if (!(error = git_str_joinpath(&fullpath, iter->root, entry->path)) &&
|
1283
1285
|
!(error = git_path_validate_str_length(iter->base.repo, &fullpath)))
|
1284
|
-
error =
|
1286
|
+
error = git_odb__hashfile(&entry->id, fullpath.ptr, GIT_OBJECT_BLOB, iter->oid_type);
|
1285
1287
|
|
1286
1288
|
git_str_dispose(&fullpath);
|
1287
1289
|
return error;
|
@@ -1529,6 +1531,8 @@ static void filesystem_iterator_set_current(
|
|
1529
1531
|
|
1530
1532
|
if (iter->base.flags & GIT_ITERATOR_INCLUDE_HASH)
|
1531
1533
|
git_oid_cpy(&iter->entry.id, &entry->id);
|
1534
|
+
else
|
1535
|
+
git_oid_clear(&iter->entry.id, iter->oid_type);
|
1532
1536
|
|
1533
1537
|
iter->entry.path = entry->path;
|
1534
1538
|
|
@@ -1973,6 +1977,8 @@ static int iterator_for_filesystem(
|
|
1973
1977
|
(iterator__flag(&iter->base, PRECOMPOSE_UNICODE) ?
|
1974
1978
|
GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE : 0);
|
1975
1979
|
|
1980
|
+
iter->oid_type = options->oid_type;
|
1981
|
+
|
1976
1982
|
if ((error = filesystem_iterator_init(iter)) < 0)
|
1977
1983
|
goto on_error;
|
1978
1984
|
|
@@ -1987,10 +1993,15 @@ on_error:
|
|
1987
1993
|
int git_iterator_for_filesystem(
|
1988
1994
|
git_iterator **out,
|
1989
1995
|
const char *root,
|
1990
|
-
git_iterator_options *
|
1996
|
+
git_iterator_options *given_opts)
|
1991
1997
|
{
|
1998
|
+
git_iterator_options options = GIT_ITERATOR_OPTIONS_INIT;
|
1999
|
+
|
2000
|
+
if (given_opts)
|
2001
|
+
memcpy(&options, given_opts, sizeof(git_iterator_options));
|
2002
|
+
|
1992
2003
|
return iterator_for_filesystem(out,
|
1993
|
-
NULL, root, NULL, NULL, GIT_ITERATOR_FS, options);
|
2004
|
+
NULL, root, NULL, NULL, GIT_ITERATOR_FS, &options);
|
1994
2005
|
}
|
1995
2006
|
|
1996
2007
|
int git_iterator_for_workdir_ext(
|
@@ -2017,6 +2028,12 @@ int git_iterator_for_workdir_ext(
|
|
2017
2028
|
options.flags |= GIT_ITERATOR_HONOR_IGNORES |
|
2018
2029
|
GIT_ITERATOR_IGNORE_DOT_GIT;
|
2019
2030
|
|
2031
|
+
if (!options.oid_type)
|
2032
|
+
options.oid_type = repo->oid_type;
|
2033
|
+
else if (options.oid_type != repo->oid_type)
|
2034
|
+
git_error_set(GIT_ERROR_INVALID,
|
2035
|
+
"specified object ID type does not match repository object ID type");
|
2036
|
+
|
2020
2037
|
return iterator_for_filesystem(out,
|
2021
2038
|
repo, repo_workdir, index, tree, GIT_ITERATOR_WORKDIR, &options);
|
2022
2039
|
}
|
@@ -13,6 +13,7 @@
|
|
13
13
|
#include "cache.h"
|
14
14
|
#include "common.h"
|
15
15
|
#include "filter.h"
|
16
|
+
#include "grafts.h"
|
16
17
|
#include "hash.h"
|
17
18
|
#include "index.h"
|
18
19
|
#include "merge_driver.h"
|
@@ -30,6 +31,7 @@
|
|
30
31
|
#include "streams/registry.h"
|
31
32
|
#include "streams/mbedtls.h"
|
32
33
|
#include "streams/openssl.h"
|
34
|
+
#include "streams/socket.h"
|
33
35
|
#include "transports/smart.h"
|
34
36
|
#include "transports/http.h"
|
35
37
|
#include "transports/ssh.h"
|
@@ -46,6 +48,8 @@ extern size_t git_indexer__max_objects;
|
|
46
48
|
extern bool git_disable_pack_keep_file_checks;
|
47
49
|
extern int git_odb__packed_priority;
|
48
50
|
extern int git_odb__loose_priority;
|
51
|
+
extern int git_socket_stream__connect_timeout;
|
52
|
+
extern int git_socket_stream__timeout;
|
49
53
|
|
50
54
|
char *git__user_agent;
|
51
55
|
char *git__ssl_ciphers;
|
@@ -78,6 +82,7 @@ int git_libgit2_init(void)
|
|
78
82
|
git_merge_driver_global_init,
|
79
83
|
git_transport_ssh_global_init,
|
80
84
|
git_stream_registry_global_init,
|
85
|
+
git_socket_stream_global_init,
|
81
86
|
git_openssl_stream_global_init,
|
82
87
|
git_mbedtls_stream_global_init,
|
83
88
|
git_mwindow_global_init,
|
@@ -414,6 +419,59 @@ int git_libgit2_opts(int key, ...)
|
|
414
419
|
git_repository__validate_ownership = (va_arg(ap, int) != 0);
|
415
420
|
break;
|
416
421
|
|
422
|
+
case GIT_OPT_GET_HOMEDIR:
|
423
|
+
{
|
424
|
+
git_buf *out = va_arg(ap, git_buf *);
|
425
|
+
git_str str = GIT_STR_INIT;
|
426
|
+
const git_str *tmp;
|
427
|
+
|
428
|
+
if ((error = git_buf_tostr(&str, out)) < 0 ||
|
429
|
+
(error = git_sysdir_get(&tmp, GIT_SYSDIR_HOME)) < 0 ||
|
430
|
+
(error = git_str_put(&str, tmp->ptr, tmp->size)) < 0)
|
431
|
+
break;
|
432
|
+
|
433
|
+
error = git_buf_fromstr(out, &str);
|
434
|
+
}
|
435
|
+
break;
|
436
|
+
|
437
|
+
case GIT_OPT_SET_HOMEDIR:
|
438
|
+
error = git_sysdir_set(GIT_SYSDIR_HOME, va_arg(ap, const char *));
|
439
|
+
break;
|
440
|
+
|
441
|
+
case GIT_OPT_GET_SERVER_CONNECT_TIMEOUT:
|
442
|
+
*(va_arg(ap, int *)) = git_socket_stream__connect_timeout;
|
443
|
+
break;
|
444
|
+
|
445
|
+
case GIT_OPT_SET_SERVER_CONNECT_TIMEOUT:
|
446
|
+
{
|
447
|
+
int timeout = va_arg(ap, int);
|
448
|
+
|
449
|
+
if (timeout < 0) {
|
450
|
+
git_error_set(GIT_ERROR_INVALID, "invalid connect timeout");
|
451
|
+
error = -1;
|
452
|
+
} else {
|
453
|
+
git_socket_stream__connect_timeout = timeout;
|
454
|
+
}
|
455
|
+
}
|
456
|
+
break;
|
457
|
+
|
458
|
+
case GIT_OPT_GET_SERVER_TIMEOUT:
|
459
|
+
*(va_arg(ap, int *)) = git_socket_stream__timeout;
|
460
|
+
break;
|
461
|
+
|
462
|
+
case GIT_OPT_SET_SERVER_TIMEOUT:
|
463
|
+
{
|
464
|
+
int timeout = va_arg(ap, int);
|
465
|
+
|
466
|
+
if (timeout < 0) {
|
467
|
+
git_error_set(GIT_ERROR_INVALID, "invalid timeout");
|
468
|
+
error = -1;
|
469
|
+
} else {
|
470
|
+
git_socket_stream__timeout = timeout;
|
471
|
+
}
|
472
|
+
}
|
473
|
+
break;
|
474
|
+
|
417
475
|
default:
|
418
476
|
git_error_set(GIT_ERROR_INVALID, "invalid option key");
|
419
477
|
error = -1;
|
@@ -611,13 +611,13 @@ int git_repository_mergehead_foreach(
|
|
611
611
|
buffer = merge_head_file.ptr;
|
612
612
|
|
613
613
|
while ((line = git__strsep(&buffer, "\n")) != NULL) {
|
614
|
-
if (strlen(line) !=
|
614
|
+
if (strlen(line) != git_oid_hexsize(repo->oid_type)) {
|
615
615
|
git_error_set(GIT_ERROR_INVALID, "unable to parse OID - invalid length");
|
616
616
|
error = -1;
|
617
617
|
goto cleanup;
|
618
618
|
}
|
619
619
|
|
620
|
-
if ((error =
|
620
|
+
if ((error = git_oid__fromstr(&oid, line, repo->oid_type)) < 0)
|
621
621
|
goto cleanup;
|
622
622
|
|
623
623
|
if ((error = cb(&oid, payload)) != 0) {
|
@@ -1061,7 +1061,7 @@ static int index_entry_similarity_calc(
|
|
1061
1061
|
const git_merge_options *opts)
|
1062
1062
|
{
|
1063
1063
|
git_blob *blob;
|
1064
|
-
git_diff_file diff_file
|
1064
|
+
git_diff_file diff_file;
|
1065
1065
|
git_object_size_t blobsize;
|
1066
1066
|
int error;
|
1067
1067
|
|
@@ -1070,6 +1070,8 @@ static int index_entry_similarity_calc(
|
|
1070
1070
|
|
1071
1071
|
*out = NULL;
|
1072
1072
|
|
1073
|
+
git_oid_clear(&diff_file.id, repo->oid_type);
|
1074
|
+
|
1073
1075
|
if ((error = git_blob_lookup(&blob, repo, &entry->id)) < 0)
|
1074
1076
|
return error;
|
1075
1077
|
|
@@ -1997,8 +1999,11 @@ static int index_update_reuc(git_index *index, git_merge_diff_list *diff_list)
|
|
1997
1999
|
return 0;
|
1998
2000
|
}
|
1999
2001
|
|
2000
|
-
static int index_from_diff_list(
|
2001
|
-
|
2002
|
+
static int index_from_diff_list(
|
2003
|
+
git_index **out,
|
2004
|
+
git_merge_diff_list *diff_list,
|
2005
|
+
git_oid_t oid_type,
|
2006
|
+
bool skip_reuc)
|
2002
2007
|
{
|
2003
2008
|
git_index *index;
|
2004
2009
|
size_t i;
|
@@ -2007,7 +2012,7 @@ static int index_from_diff_list(git_index **out,
|
|
2007
2012
|
|
2008
2013
|
*out = NULL;
|
2009
2014
|
|
2010
|
-
if ((error =
|
2015
|
+
if ((error = git_index__new(&index, oid_type)) < 0)
|
2011
2016
|
return error;
|
2012
2017
|
|
2013
2018
|
if ((error = git_index__fill(index, &diff_list->staged)) < 0)
|
@@ -2157,7 +2162,7 @@ int git_merge__iterators(
|
|
2157
2162
|
}
|
2158
2163
|
}
|
2159
2164
|
|
2160
|
-
error = index_from_diff_list(out, diff_list,
|
2165
|
+
error = index_from_diff_list(out, diff_list, repo->oid_type,
|
2161
2166
|
(opts.flags & GIT_MERGE_SKIP_REUC));
|
2162
2167
|
|
2163
2168
|
done:
|
@@ -2200,8 +2205,8 @@ int git_merge_trees(
|
|
2200
2205
|
result = our_tree;
|
2201
2206
|
|
2202
2207
|
if (result) {
|
2203
|
-
if ((error =
|
2204
|
-
|
2208
|
+
if ((error = git_index__new(out, repo->oid_type)) == 0)
|
2209
|
+
error = git_index_read_tree(*out, result);
|
2205
2210
|
|
2206
2211
|
return error;
|
2207
2212
|
}
|