rugged 1.6.5 → 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/rugged_allocator.c +0 -54
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +3 -8
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -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/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 +26 -1
- data/vendor/libgit2/include/git2/diff.h +41 -3
- data/vendor/libgit2/include/git2/errors.h +4 -2
- data/vendor/libgit2/include/git2/index.h +9 -0
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/remote.h +18 -0
- data/vendor/libgit2/include/git2/repository.h +12 -2
- 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/stream.h +16 -2
- data/vendor/libgit2/include/git2/sys/transport.h +20 -2
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +3 -1
- data/vendor/libgit2/src/CMakeLists.txt +34 -11
- data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
- 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 +1 -19
- 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/blame.c +23 -16
- data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
- 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 +3 -1
- data/vendor/libgit2/src/libgit2/commit.c +31 -9
- data/vendor/libgit2/src/libgit2/commit_graph.c +110 -43
- data/vendor/libgit2/src/libgit2/commit_graph.h +20 -4
- data/vendor/libgit2/src/libgit2/commit_list.c +12 -5
- data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
- data/vendor/libgit2/src/libgit2/config_file.c +14 -8
- data/vendor/libgit2/src/libgit2/describe.c +10 -7
- data/vendor/libgit2/src/libgit2/diff.c +16 -7
- data/vendor/libgit2/src/libgit2/diff.h +6 -6
- data/vendor/libgit2/src/libgit2/diff_file.c +7 -7
- data/vendor/libgit2/src/libgit2/diff_generate.c +36 -15
- 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 -4
- 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/fetch.c +37 -9
- 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 +325 -125
- data/vendor/libgit2/src/libgit2/index.h +14 -1
- data/vendor/libgit2/src/libgit2/indexer.c +10 -3
- data/vendor/libgit2/src/libgit2/iterator.c +20 -5
- data/vendor/libgit2/src/libgit2/iterator.h +3 -0
- data/vendor/libgit2/src/libgit2/libgit2.c +39 -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 +66 -37
- data/vendor/libgit2/src/libgit2/midx.h +13 -3
- data/vendor/libgit2/src/libgit2/notes.c +9 -8
- data/vendor/libgit2/src/libgit2/object.c +40 -15
- data/vendor/libgit2/src/libgit2/object.h +6 -0
- data/vendor/libgit2/src/libgit2/odb.c +11 -5
- data/vendor/libgit2/src/libgit2/odb_pack.c +16 -3
- data/vendor/libgit2/src/libgit2/oid.c +7 -1
- 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 +19 -12
- data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
- data/vendor/libgit2/src/libgit2/pack.c +3 -3
- data/vendor/libgit2/src/libgit2/parse.c +7 -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 +2 -2
- data/vendor/libgit2/src/libgit2/reader.c +1 -1
- data/vendor/libgit2/src/libgit2/rebase.c +72 -84
- data/vendor/libgit2/src/libgit2/refdb_fs.c +22 -13
- data/vendor/libgit2/src/libgit2/refs.c +8 -1
- data/vendor/libgit2/src/libgit2/remote.c +15 -6
- data/vendor/libgit2/src/libgit2/remote.h +1 -0
- data/vendor/libgit2/src/libgit2/repository.c +580 -301
- data/vendor/libgit2/src/libgit2/repository.h +17 -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 +1 -4
- data/vendor/libgit2/src/libgit2/revwalk.c +26 -4
- data/vendor/libgit2/src/libgit2/stash.c +9 -8
- data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
- data/vendor/libgit2/src/libgit2/streams/openssl.c +8 -16
- 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 +237 -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.h +3 -3
- 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 +7 -2
- data/vendor/libgit2/src/libgit2/transports/httpclient.c +5 -0
- data/vendor/libgit2/src/libgit2/transports/local.c +13 -4
- data/vendor/libgit2/src/libgit2/transports/smart.c +33 -27
- data/vendor/libgit2/src/libgit2/transports/smart.h +23 -8
- data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +136 -17
- data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +154 -47
- data/vendor/libgit2/src/libgit2/transports/ssh.c +3 -3
- data/vendor/libgit2/src/libgit2/transports/winhttp.c +14 -15
- 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 +1 -1
- data/vendor/libgit2/src/libgit2/worktree.c +25 -10
- 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 +1 -1
- data/vendor/libgit2/src/util/futils.c +8 -5
- data/vendor/libgit2/src/util/git2_features.h.in +9 -3
- data/vendor/libgit2/src/util/net.c +308 -157
- data/vendor/libgit2/src/util/net.h +25 -0
- data/vendor/libgit2/src/util/posix.c +54 -0
- data/vendor/libgit2/src/util/posix.h +22 -0
- data/vendor/libgit2/src/util/rand.c +6 -4
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/util/util.c +15 -10
- data/vendor/libgit2/src/util/util.h +24 -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 +29 -23
- 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/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
|
*/
|
@@ -519,7 +519,13 @@ static int store_object(git_indexer *idx)
|
|
519
519
|
pentry->offset = entry_start;
|
520
520
|
|
521
521
|
if (git_oidmap_exists(idx->pack->idx_cache, &pentry->id)) {
|
522
|
-
|
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
|
+
|
523
529
|
git__free(pentry);
|
524
530
|
goto on_error;
|
525
531
|
}
|
@@ -1232,6 +1238,7 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
|
|
1232
1238
|
git_filebuf index_file = {0};
|
1233
1239
|
void *packfile_trailer;
|
1234
1240
|
size_t checksum_size;
|
1241
|
+
int filebuf_hash;
|
1235
1242
|
bool mismatch;
|
1236
1243
|
|
1237
1244
|
if (!idx->parsed_header) {
|
@@ -1240,6 +1247,7 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
|
|
1240
1247
|
}
|
1241
1248
|
|
1242
1249
|
checksum_size = git_hash_size(indexer_hash_algorithm(idx));
|
1250
|
+
filebuf_hash = git_filebuf_hash_flags(indexer_hash_algorithm(idx));
|
1243
1251
|
GIT_ASSERT(checksum_size);
|
1244
1252
|
|
1245
1253
|
/* Test for this before resolve_deltas(), as it plays with idx->off */
|
@@ -1314,8 +1322,7 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
|
|
1314
1322
|
return -1;
|
1315
1323
|
|
1316
1324
|
if (git_filebuf_open(&index_file, filename.ptr,
|
1317
|
-
|
1318
|
-
(idx->do_fsync ? GIT_FILEBUF_FSYNC : 0),
|
1325
|
+
filebuf_hash | (idx->do_fsync ? GIT_FILEBUF_FSYNC : 0),
|
1319
1326
|
idx->mode) < 0)
|
1320
1327
|
goto on_error;
|
1321
1328
|
|
@@ -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 = git_odb__hashfile(&entry->id, fullpath.ptr, GIT_OBJECT_BLOB,
|
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;
|
@@ -1530,7 +1532,7 @@ static void filesystem_iterator_set_current(
|
|
1530
1532
|
if (iter->base.flags & GIT_ITERATOR_INCLUDE_HASH)
|
1531
1533
|
git_oid_cpy(&iter->entry.id, &entry->id);
|
1532
1534
|
else
|
1533
|
-
git_oid_clear(&iter->entry.id,
|
1535
|
+
git_oid_clear(&iter->entry.id, iter->oid_type);
|
1534
1536
|
|
1535
1537
|
iter->entry.path = entry->path;
|
1536
1538
|
|
@@ -1975,6 +1977,8 @@ static int iterator_for_filesystem(
|
|
1975
1977
|
(iterator__flag(&iter->base, PRECOMPOSE_UNICODE) ?
|
1976
1978
|
GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE : 0);
|
1977
1979
|
|
1980
|
+
iter->oid_type = options->oid_type;
|
1981
|
+
|
1978
1982
|
if ((error = filesystem_iterator_init(iter)) < 0)
|
1979
1983
|
goto on_error;
|
1980
1984
|
|
@@ -1989,10 +1993,15 @@ on_error:
|
|
1989
1993
|
int git_iterator_for_filesystem(
|
1990
1994
|
git_iterator **out,
|
1991
1995
|
const char *root,
|
1992
|
-
git_iterator_options *
|
1996
|
+
git_iterator_options *given_opts)
|
1993
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
|
+
|
1994
2003
|
return iterator_for_filesystem(out,
|
1995
|
-
NULL, root, NULL, NULL, GIT_ITERATOR_FS, options);
|
2004
|
+
NULL, root, NULL, NULL, GIT_ITERATOR_FS, &options);
|
1996
2005
|
}
|
1997
2006
|
|
1998
2007
|
int git_iterator_for_workdir_ext(
|
@@ -2019,6 +2028,12 @@ int git_iterator_for_workdir_ext(
|
|
2019
2028
|
options.flags |= GIT_ITERATOR_HONOR_IGNORES |
|
2020
2029
|
GIT_ITERATOR_IGNORE_DOT_GIT;
|
2021
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
|
+
|
2022
2037
|
return iterator_for_filesystem(out,
|
2023
2038
|
repo, repo_workdir, index, tree, GIT_ITERATOR_WORKDIR, &options);
|
2024
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,
|
@@ -433,6 +438,40 @@ int git_libgit2_opts(int key, ...)
|
|
433
438
|
error = git_sysdir_set(GIT_SYSDIR_HOME, va_arg(ap, const char *));
|
434
439
|
break;
|
435
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
|
+
|
436
475
|
default:
|
437
476
|
git_error_set(GIT_ERROR_INVALID, "invalid option key");
|
438
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 = git_oid__fromstr(&oid, line,
|
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
|
}
|
@@ -114,23 +114,16 @@ static int midx_parse_oid_lookup(
|
|
114
114
|
const unsigned char *data,
|
115
115
|
struct git_midx_chunk *chunk_oid_lookup)
|
116
116
|
{
|
117
|
-
|
118
|
-
unsigned char *oid, *prev_oid, zero_oid[GIT_OID_SHA1_SIZE] = {0};
|
117
|
+
size_t oid_size = git_oid_size(idx->oid_type);
|
119
118
|
|
120
119
|
if (chunk_oid_lookup->offset == 0)
|
121
120
|
return midx_error("missing OID Lookup chunk");
|
122
121
|
if (chunk_oid_lookup->length == 0)
|
123
122
|
return midx_error("empty OID Lookup chunk");
|
124
|
-
if (chunk_oid_lookup->length != idx->num_objects *
|
123
|
+
if (chunk_oid_lookup->length != idx->num_objects * oid_size)
|
125
124
|
return midx_error("OID Lookup chunk has wrong length");
|
126
125
|
|
127
|
-
idx->oid_lookup =
|
128
|
-
prev_oid = zero_oid;
|
129
|
-
for (i = 0; i < idx->num_objects; ++i, oid += GIT_OID_SHA1_SIZE) {
|
130
|
-
if (git_oid_raw_cmp(prev_oid, oid, GIT_OID_SHA1_SIZE) >= 0)
|
131
|
-
return midx_error("OID Lookup index is non-monotonic");
|
132
|
-
prev_oid = oid;
|
133
|
-
}
|
126
|
+
idx->oid_lookup = (unsigned char *)(data + chunk_oid_lookup->offset);
|
134
127
|
|
135
128
|
return 0;
|
136
129
|
}
|
@@ -178,17 +171,20 @@ int git_midx_parse(
|
|
178
171
|
struct git_midx_chunk *last_chunk;
|
179
172
|
uint32_t i;
|
180
173
|
off64_t last_chunk_offset, chunk_offset, trailer_offset;
|
181
|
-
size_t checksum_size;
|
174
|
+
size_t checksum_size, oid_size;
|
182
175
|
int error;
|
183
176
|
struct git_midx_chunk chunk_packfile_names = {0},
|
184
177
|
chunk_oid_fanout = {0},
|
185
178
|
chunk_oid_lookup = {0},
|
186
179
|
chunk_object_offsets = {0},
|
187
|
-
chunk_object_large_offsets = {0}
|
180
|
+
chunk_object_large_offsets = {0},
|
181
|
+
chunk_unknown = {0};
|
188
182
|
|
189
183
|
GIT_ASSERT_ARG(idx);
|
190
184
|
|
191
|
-
|
185
|
+
oid_size = git_oid_size(idx->oid_type);
|
186
|
+
|
187
|
+
if (size < sizeof(struct git_midx_header) + oid_size)
|
192
188
|
return midx_error("multi-pack index is too short");
|
193
189
|
|
194
190
|
hdr = ((struct git_midx_header *)data);
|
@@ -209,7 +205,7 @@ int git_midx_parse(
|
|
209
205
|
sizeof(struct git_midx_header) +
|
210
206
|
(1 + hdr->chunks) * 12;
|
211
207
|
|
212
|
-
checksum_size =
|
208
|
+
checksum_size = oid_size;
|
213
209
|
trailer_offset = size - checksum_size;
|
214
210
|
|
215
211
|
if (trailer_offset < last_chunk_offset)
|
@@ -261,7 +257,9 @@ int git_midx_parse(
|
|
261
257
|
break;
|
262
258
|
|
263
259
|
default:
|
264
|
-
|
260
|
+
chunk_unknown.offset = last_chunk_offset;
|
261
|
+
last_chunk = &chunk_unknown;
|
262
|
+
break;
|
265
263
|
}
|
266
264
|
}
|
267
265
|
last_chunk->length = (size_t)(trailer_offset - last_chunk_offset);
|
@@ -287,8 +285,9 @@ int git_midx_parse(
|
|
287
285
|
}
|
288
286
|
|
289
287
|
int git_midx_open(
|
290
|
-
|
291
|
-
|
288
|
+
git_midx_file **idx_out,
|
289
|
+
const char *path,
|
290
|
+
git_oid_t oid_type)
|
292
291
|
{
|
293
292
|
git_midx_file *idx;
|
294
293
|
git_file fd = -1;
|
@@ -296,6 +295,8 @@ int git_midx_open(
|
|
296
295
|
struct stat st;
|
297
296
|
int error;
|
298
297
|
|
298
|
+
GIT_ASSERT_ARG(idx_out && path && oid_type);
|
299
|
+
|
299
300
|
/* TODO: properly open the file without access time using O_NOATIME */
|
300
301
|
fd = git_futils_open_ro(path);
|
301
302
|
if (fd < 0)
|
@@ -317,6 +318,8 @@ int git_midx_open(
|
|
317
318
|
idx = git__calloc(1, sizeof(git_midx_file));
|
318
319
|
GIT_ERROR_CHECK_ALLOC(idx);
|
319
320
|
|
321
|
+
idx->oid_type = oid_type;
|
322
|
+
|
320
323
|
error = git_str_sets(&idx->filename, path);
|
321
324
|
if (error < 0)
|
322
325
|
return error;
|
@@ -344,7 +347,7 @@ bool git_midx_needs_refresh(
|
|
344
347
|
git_file fd = -1;
|
345
348
|
struct stat st;
|
346
349
|
ssize_t bytes_read;
|
347
|
-
unsigned char checksum[
|
350
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
348
351
|
size_t checksum_size;
|
349
352
|
|
350
353
|
/* TODO: properly open the file without access time using O_NOATIME */
|
@@ -364,8 +367,8 @@ bool git_midx_needs_refresh(
|
|
364
367
|
return true;
|
365
368
|
}
|
366
369
|
|
367
|
-
checksum_size =
|
368
|
-
bytes_read = p_pread(fd, checksum, checksum_size, st.st_size -
|
370
|
+
checksum_size = git_oid_size(idx->oid_type);
|
371
|
+
bytes_read = p_pread(fd, checksum, checksum_size, st.st_size - checksum_size);
|
369
372
|
p_close(fd);
|
370
373
|
|
371
374
|
if (bytes_read != (ssize_t)checksum_size)
|
@@ -381,7 +384,7 @@ int git_midx_entry_find(
|
|
381
384
|
size_t len)
|
382
385
|
{
|
383
386
|
int pos, found = 0;
|
384
|
-
size_t pack_index;
|
387
|
+
size_t pack_index, oid_size, oid_hexsize;
|
385
388
|
uint32_t hi, lo;
|
386
389
|
unsigned char *current = NULL;
|
387
390
|
const unsigned char *object_offset;
|
@@ -389,30 +392,33 @@ int git_midx_entry_find(
|
|
389
392
|
|
390
393
|
GIT_ASSERT_ARG(idx);
|
391
394
|
|
395
|
+
oid_size = git_oid_size(idx->oid_type);
|
396
|
+
oid_hexsize = git_oid_hexsize(idx->oid_type);
|
397
|
+
|
392
398
|
hi = ntohl(idx->oid_fanout[(int)short_oid->id[0]]);
|
393
399
|
lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(idx->oid_fanout[(int)short_oid->id[0] - 1]));
|
394
400
|
|
395
|
-
pos = git_pack__lookup_id(idx->oid_lookup,
|
401
|
+
pos = git_pack__lookup_id(idx->oid_lookup, oid_size, lo, hi, short_oid->id, idx->oid_type);
|
396
402
|
|
397
403
|
if (pos >= 0) {
|
398
404
|
/* An object matching exactly the oid was found */
|
399
405
|
found = 1;
|
400
|
-
current = idx->oid_lookup + (pos *
|
406
|
+
current = idx->oid_lookup + (pos * oid_size);
|
401
407
|
} else {
|
402
408
|
/* No object was found */
|
403
409
|
/* pos refers to the object with the "closest" oid to short_oid */
|
404
410
|
pos = -1 - pos;
|
405
411
|
if (pos < (int)idx->num_objects) {
|
406
|
-
current = idx->oid_lookup + (pos *
|
412
|
+
current = idx->oid_lookup + (pos * oid_size);
|
407
413
|
|
408
414
|
if (!git_oid_raw_ncmp(short_oid->id, current, len))
|
409
415
|
found = 1;
|
410
416
|
}
|
411
417
|
}
|
412
418
|
|
413
|
-
if (found && len !=
|
419
|
+
if (found && len != oid_hexsize && pos + 1 < (int)idx->num_objects) {
|
414
420
|
/* Check for ambiguousity */
|
415
|
-
const unsigned char *next = current +
|
421
|
+
const unsigned char *next = current + oid_size;
|
416
422
|
|
417
423
|
if (!git_oid_raw_ncmp(short_oid->id, next, len))
|
418
424
|
found = 2;
|
@@ -443,7 +449,7 @@ int git_midx_entry_find(
|
|
443
449
|
return midx_error("invalid index into the packfile names table");
|
444
450
|
e->pack_index = pack_index;
|
445
451
|
e->offset = offset;
|
446
|
-
git_oid__fromraw(&e->sha1, current,
|
452
|
+
git_oid__fromraw(&e->sha1, current, idx->oid_type);
|
447
453
|
return 0;
|
448
454
|
}
|
449
455
|
|
@@ -453,13 +459,15 @@ int git_midx_foreach_entry(
|
|
453
459
|
void *data)
|
454
460
|
{
|
455
461
|
git_oid oid;
|
456
|
-
size_t i;
|
462
|
+
size_t oid_size, i;
|
457
463
|
int error;
|
458
464
|
|
459
465
|
GIT_ASSERT_ARG(idx);
|
460
466
|
|
467
|
+
oid_size = git_oid_size(idx->oid_type);
|
468
|
+
|
461
469
|
for (i = 0; i < idx->num_objects; ++i) {
|
462
|
-
if ((error = git_oid__fromraw(&oid, &idx->oid_lookup[i *
|
470
|
+
if ((error = git_oid__fromraw(&oid, &idx->oid_lookup[i * oid_size], idx->oid_type)) < 0)
|
463
471
|
return error;
|
464
472
|
|
465
473
|
if ((error = cb(&oid, data)) != 0)
|
@@ -501,9 +509,21 @@ static int packfile__cmp(const void *a_, const void *b_)
|
|
501
509
|
|
502
510
|
int git_midx_writer_new(
|
503
511
|
git_midx_writer **out,
|
504
|
-
const char *pack_dir
|
512
|
+
const char *pack_dir
|
513
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
514
|
+
, git_oid_t oid_type
|
515
|
+
#endif
|
516
|
+
)
|
505
517
|
{
|
506
|
-
git_midx_writer *w
|
518
|
+
git_midx_writer *w;
|
519
|
+
|
520
|
+
#ifndef GIT_EXPERIMENTAL_SHA256
|
521
|
+
git_oid_t oid_type = GIT_OID_SHA1;
|
522
|
+
#endif
|
523
|
+
|
524
|
+
GIT_ASSERT_ARG(out && pack_dir && oid_type);
|
525
|
+
|
526
|
+
w = git__calloc(1, sizeof(git_midx_writer));
|
507
527
|
GIT_ERROR_CHECK_ALLOC(w);
|
508
528
|
|
509
529
|
if (git_str_sets(&w->pack_dir, pack_dir) < 0) {
|
@@ -518,6 +538,8 @@ int git_midx_writer_new(
|
|
518
538
|
return -1;
|
519
539
|
}
|
520
540
|
|
541
|
+
w->oid_type = oid_type;
|
542
|
+
|
521
543
|
*out = w;
|
522
544
|
return 0;
|
523
545
|
}
|
@@ -662,12 +684,13 @@ static int midx_write(
|
|
662
684
|
oid_lookup = GIT_STR_INIT,
|
663
685
|
object_offsets = GIT_STR_INIT,
|
664
686
|
object_large_offsets = GIT_STR_INIT;
|
665
|
-
unsigned char checksum[
|
666
|
-
size_t checksum_size;
|
687
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
688
|
+
size_t checksum_size, oid_size;
|
667
689
|
git_midx_entry *entry;
|
668
690
|
object_entry_array_t object_entries_array = GIT_ARRAY_INIT;
|
669
691
|
git_vector object_entries = GIT_VECTOR_INIT;
|
670
692
|
git_hash_ctx ctx;
|
693
|
+
git_hash_algorithm_t checksum_type;
|
671
694
|
struct midx_write_hash_context hash_cb_data = {0};
|
672
695
|
|
673
696
|
hdr.signature = htonl(MIDX_SIGNATURE);
|
@@ -679,10 +702,14 @@ static int midx_write(
|
|
679
702
|
hash_cb_data.cb_data = cb_data;
|
680
703
|
hash_cb_data.ctx = &ctx;
|
681
704
|
|
682
|
-
|
683
|
-
|
684
|
-
|
705
|
+
oid_size = git_oid_size(w->oid_type);
|
706
|
+
|
707
|
+
GIT_ASSERT((checksum_type = git_oid_algorithm(w->oid_type)));
|
708
|
+
checksum_size = git_hash_size(checksum_type);
|
709
|
+
|
710
|
+
if ((error = git_hash_ctx_init(&ctx, checksum_type)) < 0)
|
685
711
|
return error;
|
712
|
+
|
686
713
|
cb_data = &hash_cb_data;
|
687
714
|
write_cb = midx_write_hash;
|
688
715
|
|
@@ -749,7 +776,9 @@ static int midx_write(
|
|
749
776
|
|
750
777
|
/* Fill the OID Lookup table. */
|
751
778
|
git_vector_foreach (&object_entries, i, entry) {
|
752
|
-
error = git_str_put(&oid_lookup,
|
779
|
+
error = git_str_put(&oid_lookup,
|
780
|
+
(char *)&entry->sha1.id, oid_size);
|
781
|
+
|
753
782
|
if (error < 0)
|
754
783
|
goto cleanup;
|
755
784
|
}
|
@@ -51,8 +51,14 @@ typedef struct git_midx_file {
|
|
51
51
|
/* The number of entries in the Object Large Offsets table. Each entry has an 8-byte with an offset */
|
52
52
|
size_t num_object_large_offsets;
|
53
53
|
|
54
|
-
/*
|
55
|
-
|
54
|
+
/*
|
55
|
+
* The trailer of the file. Contains the checksum of the whole
|
56
|
+
* file, in the repository's object format hash.
|
57
|
+
*/
|
58
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
59
|
+
|
60
|
+
/* The type of object IDs in the midx. */
|
61
|
+
git_oid_t oid_type;
|
56
62
|
|
57
63
|
/* something like ".git/objects/pack/multi-pack-index". */
|
58
64
|
git_str filename;
|
@@ -82,11 +88,15 @@ struct git_midx_writer {
|
|
82
88
|
|
83
89
|
/* The list of `git_pack_file`s. */
|
84
90
|
git_vector packs;
|
91
|
+
|
92
|
+
/* The object ID type of the writer. */
|
93
|
+
git_oid_t oid_type;
|
85
94
|
};
|
86
95
|
|
87
96
|
int git_midx_open(
|
88
97
|
git_midx_file **idx_out,
|
89
|
-
const char *path
|
98
|
+
const char *path,
|
99
|
+
git_oid_t oid_type);
|
90
100
|
bool git_midx_needs_refresh(
|
91
101
|
const git_midx_file *idx,
|
92
102
|
const char *path);
|
@@ -460,7 +460,7 @@ int git_note_commit_read(
|
|
460
460
|
{
|
461
461
|
int error;
|
462
462
|
git_tree *tree = NULL;
|
463
|
-
char target[
|
463
|
+
char target[GIT_OID_MAX_HEXSIZE + 1];
|
464
464
|
|
465
465
|
git_oid_tostr(target, sizeof(target), oid);
|
466
466
|
|
@@ -507,7 +507,7 @@ int git_note_commit_create(
|
|
507
507
|
{
|
508
508
|
int error;
|
509
509
|
git_tree *tree = NULL;
|
510
|
-
char target[
|
510
|
+
char target[GIT_OID_MAX_HEXSIZE + 1];
|
511
511
|
|
512
512
|
git_oid_tostr(target, sizeof(target), oid);
|
513
513
|
|
@@ -578,7 +578,7 @@ int git_note_commit_remove(
|
|
578
578
|
{
|
579
579
|
int error;
|
580
580
|
git_tree *tree = NULL;
|
581
|
-
char target[
|
581
|
+
char target[GIT_OID_MAX_HEXSIZE + 1];
|
582
582
|
|
583
583
|
git_oid_tostr(target, sizeof(target), oid);
|
584
584
|
|
@@ -665,8 +665,9 @@ void git_note_free(git_note *note)
|
|
665
665
|
}
|
666
666
|
|
667
667
|
static int process_entry_path(
|
668
|
-
|
669
|
-
|
668
|
+
git_oid *annotated_object_id,
|
669
|
+
git_note_iterator *it,
|
670
|
+
const char *entry_path)
|
670
671
|
{
|
671
672
|
int error = 0;
|
672
673
|
size_t i = 0, j = 0, len;
|
@@ -698,12 +699,12 @@ static int process_entry_path(
|
|
698
699
|
buf.ptr[j] = '\0';
|
699
700
|
buf.size = j;
|
700
701
|
|
701
|
-
if (j !=
|
702
|
+
if (j != git_oid_hexsize(it->repo->oid_type)) {
|
702
703
|
/* This is not a note entry */
|
703
704
|
goto cleanup;
|
704
705
|
}
|
705
706
|
|
706
|
-
error = git_oid__fromstr(annotated_object_id, buf.ptr,
|
707
|
+
error = git_oid__fromstr(annotated_object_id, buf.ptr, it->repo->oid_type);
|
707
708
|
|
708
709
|
cleanup:
|
709
710
|
git_str_dispose(&buf);
|
@@ -799,7 +800,7 @@ int git_note_next(
|
|
799
800
|
|
800
801
|
git_oid_cpy(note_id, &item->id);
|
801
802
|
|
802
|
-
if ((error = process_entry_path(item->path
|
803
|
+
if ((error = process_entry_path(annotated_id, it, item->path)) < 0)
|
803
804
|
return error;
|
804
805
|
|
805
806
|
if ((error = git_iterator_advance(NULL, it)) < 0 && error != GIT_ITEROVER)
|