rugged 1.3.2.3 → 1.4.2
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 +1 -1
- data/ext/rugged/rugged_config.c +7 -2
- data/ext/rugged/rugged_remote.c +17 -0
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +103 -276
- data/vendor/libgit2/COPYING +36 -19
- data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
- data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
- data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
- data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
- data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
- data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
- data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
- data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
- data/vendor/libgit2/cmake/FindLibSSH2.cmake +5 -5
- data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
- data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
- data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
- data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
- data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
- data/vendor/libgit2/cmake/Findfutimens.cmake +8 -8
- data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
- data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
- data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
- data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
- data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -100
- data/vendor/libgit2/cmake/SelectHashes.cmake +39 -49
- data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
- data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
- data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +31 -31
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +1 -1
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
- data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
- data/vendor/libgit2/deps/zlib/adler32.c +0 -7
- data/vendor/libgit2/deps/zlib/crc32.c +288 -975
- data/vendor/libgit2/deps/zlib/crc32.h +436 -9441
- data/vendor/libgit2/deps/zlib/deflate.c +31 -83
- data/vendor/libgit2/deps/zlib/deflate.h +15 -12
- data/vendor/libgit2/deps/zlib/gzguts.h +2 -3
- data/vendor/libgit2/deps/zlib/infback.c +1 -2
- data/vendor/libgit2/deps/zlib/inffast.c +14 -14
- data/vendor/libgit2/deps/zlib/inflate.c +8 -39
- data/vendor/libgit2/deps/zlib/inflate.h +2 -3
- data/vendor/libgit2/deps/zlib/inftrees.c +3 -3
- data/vendor/libgit2/deps/zlib/trees.c +48 -27
- data/vendor/libgit2/deps/zlib/zlib.h +100 -126
- data/vendor/libgit2/deps/zlib/zutil.c +2 -2
- data/vendor/libgit2/deps/zlib/zutil.h +9 -12
- data/vendor/libgit2/include/git2/apply.h +16 -2
- data/vendor/libgit2/include/git2/attr.h +11 -2
- data/vendor/libgit2/include/git2/blame.h +4 -1
- data/vendor/libgit2/include/git2/blob.h +14 -1
- data/vendor/libgit2/include/git2/branch.h +2 -0
- data/vendor/libgit2/include/git2/buffer.h +18 -78
- data/vendor/libgit2/include/git2/cert.h +2 -2
- data/vendor/libgit2/include/git2/checkout.h +5 -2
- data/vendor/libgit2/include/git2/clone.h +3 -3
- data/vendor/libgit2/include/git2/commit.h +2 -0
- data/vendor/libgit2/include/git2/common.h +5 -12
- data/vendor/libgit2/include/git2/config.h +19 -3
- data/vendor/libgit2/include/git2/credential.h +2 -1
- data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
- data/vendor/libgit2/include/git2/deprecated.h +1 -1
- data/vendor/libgit2/include/git2/describe.h +7 -2
- data/vendor/libgit2/include/git2/diff.h +17 -9
- data/vendor/libgit2/include/git2/email.h +1 -1
- data/vendor/libgit2/include/git2/errors.h +1 -2
- data/vendor/libgit2/include/git2/filter.h +7 -2
- data/vendor/libgit2/include/git2/graph.h +1 -0
- data/vendor/libgit2/include/git2/ignore.h +1 -1
- data/vendor/libgit2/include/git2/index.h +11 -5
- data/vendor/libgit2/include/git2/indexer.h +19 -0
- data/vendor/libgit2/include/git2/merge.h +23 -3
- data/vendor/libgit2/include/git2/message.h +2 -0
- data/vendor/libgit2/include/git2/object.h +23 -0
- data/vendor/libgit2/include/git2/odb.h +37 -7
- data/vendor/libgit2/include/git2/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +24 -8
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/pathspec.h +1 -1
- data/vendor/libgit2/include/git2/proxy.h +1 -1
- data/vendor/libgit2/include/git2/rebase.h +9 -1
- data/vendor/libgit2/include/git2/refdb.h +3 -0
- data/vendor/libgit2/include/git2/reflog.h +1 -1
- data/vendor/libgit2/include/git2/refs.h +2 -2
- data/vendor/libgit2/include/git2/remote.h +184 -37
- data/vendor/libgit2/include/git2/repository.h +14 -9
- data/vendor/libgit2/include/git2/reset.h +2 -2
- data/vendor/libgit2/include/git2/revparse.h +1 -1
- data/vendor/libgit2/include/git2/revwalk.h +4 -1
- data/vendor/libgit2/include/git2/signature.h +1 -1
- data/vendor/libgit2/include/git2/stash.h +3 -3
- data/vendor/libgit2/include/git2/status.h +9 -3
- data/vendor/libgit2/include/git2/submodule.h +7 -2
- data/vendor/libgit2/include/git2/sys/commit_graph.h +1 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +2 -5
- data/vendor/libgit2/include/git2/sys/remote.h +31 -0
- data/vendor/libgit2/include/git2/sys/stream.h +1 -1
- data/vendor/libgit2/include/git2/sys/transport.h +25 -34
- data/vendor/libgit2/include/git2/tag.h +1 -0
- data/vendor/libgit2/include/git2/tree.h +4 -3
- data/vendor/libgit2/include/git2/types.h +7 -7
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/include/git2/worktree.h +12 -2
- data/vendor/libgit2/src/CMakeLists.txt +189 -315
- data/vendor/libgit2/src/annotated_commit.h +1 -1
- data/vendor/libgit2/src/apply.c +18 -18
- data/vendor/libgit2/src/apply.h +2 -2
- data/vendor/libgit2/src/attr.c +18 -18
- data/vendor/libgit2/src/attr_file.c +17 -17
- data/vendor/libgit2/src/attr_file.h +4 -4
- data/vendor/libgit2/src/attrcache.c +17 -12
- data/vendor/libgit2/src/blame_git.c +1 -1
- data/vendor/libgit2/src/blob.c +33 -26
- data/vendor/libgit2/src/blob.h +1 -1
- data/vendor/libgit2/src/branch.c +150 -109
- data/vendor/libgit2/src/branch.h +15 -3
- data/vendor/libgit2/src/buf.c +126 -0
- data/vendor/libgit2/src/buf.h +50 -0
- data/vendor/libgit2/src/cc-compat.h +1 -1
- data/vendor/libgit2/src/checkout.c +74 -68
- data/vendor/libgit2/src/cherrypick.c +10 -10
- data/vendor/libgit2/src/clone.c +66 -66
- data/vendor/libgit2/src/commit.c +128 -58
- data/vendor/libgit2/src/commit.h +24 -1
- data/vendor/libgit2/src/commit_graph.c +68 -53
- data/vendor/libgit2/src/commit_graph.h +10 -3
- data/vendor/libgit2/src/commit_list.c +2 -3
- data/vendor/libgit2/src/common.h +10 -3
- data/vendor/libgit2/src/config.c +99 -77
- data/vendor/libgit2/src/config.h +15 -2
- data/vendor/libgit2/src/config_file.c +103 -91
- data/vendor/libgit2/src/config_mem.c +9 -9
- data/vendor/libgit2/src/config_parse.c +27 -23
- data/vendor/libgit2/src/crlf.c +24 -21
- data/vendor/libgit2/src/date.c +10 -17
- data/vendor/libgit2/src/date.h +33 -0
- data/vendor/libgit2/src/describe.c +27 -19
- data/vendor/libgit2/src/diff.c +25 -8
- data/vendor/libgit2/src/diff.h +2 -4
- data/vendor/libgit2/src/diff_driver.c +34 -36
- data/vendor/libgit2/src/diff_driver.h +3 -3
- data/vendor/libgit2/src/diff_file.c +29 -20
- data/vendor/libgit2/src/diff_generate.c +30 -6
- data/vendor/libgit2/src/diff_generate.h +5 -3
- data/vendor/libgit2/src/diff_print.c +102 -95
- data/vendor/libgit2/src/diff_stats.c +40 -29
- data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
- data/vendor/libgit2/src/diff_tform.c +9 -8
- data/vendor/libgit2/src/diff_xdiff.c +3 -8
- data/vendor/libgit2/src/email.c +54 -38
- data/vendor/libgit2/src/email.h +1 -1
- data/vendor/libgit2/src/errors.c +18 -18
- data/vendor/libgit2/src/features.h.in +6 -1
- data/vendor/libgit2/src/fetch.c +69 -24
- data/vendor/libgit2/src/fetch.h +1 -1
- data/vendor/libgit2/src/fetchhead.c +19 -19
- data/vendor/libgit2/src/filebuf.c +28 -28
- data/vendor/libgit2/src/filebuf.h +1 -1
- data/vendor/libgit2/src/filter.c +96 -52
- data/vendor/libgit2/src/filter.h +26 -5
- data/vendor/libgit2/src/fs_path.c +1912 -0
- data/vendor/libgit2/src/fs_path.h +752 -0
- data/vendor/libgit2/src/futils.c +91 -85
- data/vendor/libgit2/src/futils.h +26 -14
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +2 -2
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +2 -2
- data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +2 -2
- data/vendor/libgit2/src/hash/sha1/openssl.c +2 -2
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +1 -1
- data/vendor/libgit2/src/hash/sha1/win32.c +6 -6
- data/vendor/libgit2/src/hash/sha1.h +3 -1
- data/vendor/libgit2/src/hash.c +67 -35
- data/vendor/libgit2/src/hash.h +12 -12
- data/vendor/libgit2/src/ident.c +18 -18
- data/vendor/libgit2/src/ignore.c +35 -34
- data/vendor/libgit2/src/ignore.h +2 -2
- data/vendor/libgit2/src/index.c +79 -80
- data/vendor/libgit2/src/index.h +6 -3
- data/vendor/libgit2/src/indexer.c +75 -57
- data/vendor/libgit2/src/iterator.c +64 -56
- data/vendor/libgit2/src/iterator.h +5 -5
- data/vendor/libgit2/src/khash.h +1 -1
- data/vendor/libgit2/src/libgit2.c +22 -19
- data/vendor/libgit2/src/mailmap.c +38 -36
- data/vendor/libgit2/src/merge.c +27 -27
- data/vendor/libgit2/src/merge.h +1 -14
- data/vendor/libgit2/src/merge_driver.c +2 -2
- data/vendor/libgit2/src/merge_file.c +13 -3
- data/vendor/libgit2/src/message.c +21 -10
- data/vendor/libgit2/src/midx.c +83 -66
- data/vendor/libgit2/src/midx.h +3 -3
- data/vendor/libgit2/src/mwindow.c +1 -1
- data/vendor/libgit2/src/net.c +278 -68
- data/vendor/libgit2/src/net.h +10 -3
- data/vendor/libgit2/src/netops.c +1 -1
- data/vendor/libgit2/src/netops.h +1 -1
- data/vendor/libgit2/src/notes.c +20 -29
- data/vendor/libgit2/src/object.c +49 -9
- data/vendor/libgit2/src/object.h +1 -1
- data/vendor/libgit2/src/odb.c +35 -32
- data/vendor/libgit2/src/odb.h +1 -1
- data/vendor/libgit2/src/odb_loose.c +68 -68
- data/vendor/libgit2/src/odb_mempack.c +18 -5
- data/vendor/libgit2/src/odb_pack.c +43 -43
- data/vendor/libgit2/src/oid.c +11 -4
- data/vendor/libgit2/src/oid.h +15 -0
- data/vendor/libgit2/src/pack-objects.c +41 -26
- data/vendor/libgit2/src/pack-objects.h +11 -6
- data/vendor/libgit2/src/pack.c +10 -10
- data/vendor/libgit2/src/patch.c +3 -3
- data/vendor/libgit2/src/patch.h +1 -0
- data/vendor/libgit2/src/patch_generate.c +27 -11
- data/vendor/libgit2/src/patch_generate.h +5 -5
- data/vendor/libgit2/src/patch_parse.c +24 -24
- data/vendor/libgit2/src/path.c +76 -1951
- data/vendor/libgit2/src/path.h +34 -741
- data/vendor/libgit2/src/pathspec.c +6 -6
- data/vendor/libgit2/src/pathspec.h +2 -2
- data/vendor/libgit2/src/posix.c +3 -3
- data/vendor/libgit2/src/posix.h +1 -0
- data/vendor/libgit2/src/pqueue.h +1 -1
- data/vendor/libgit2/src/proxy.c +4 -1
- data/vendor/libgit2/src/proxy.h +1 -1
- data/vendor/libgit2/src/push.c +30 -35
- data/vendor/libgit2/src/push.h +4 -16
- data/vendor/libgit2/src/rand.c +226 -0
- data/vendor/libgit2/src/rand.h +37 -0
- data/vendor/libgit2/src/reader.c +8 -8
- data/vendor/libgit2/src/reader.h +2 -2
- data/vendor/libgit2/src/rebase.c +89 -88
- data/vendor/libgit2/src/refdb_fs.c +447 -173
- data/vendor/libgit2/src/refs.c +32 -32
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +32 -37
- data/vendor/libgit2/src/refspec.h +5 -2
- data/vendor/libgit2/src/regexp.c +1 -1
- data/vendor/libgit2/src/remote.c +713 -419
- data/vendor/libgit2/src/remote.h +15 -10
- data/vendor/libgit2/src/repository.c +350 -467
- data/vendor/libgit2/src/repository.h +11 -10
- data/vendor/libgit2/src/reset.c +8 -5
- data/vendor/libgit2/src/revert.c +10 -10
- data/vendor/libgit2/src/revparse.c +48 -35
- data/vendor/libgit2/src/revwalk.c +7 -7
- data/vendor/libgit2/src/signature.c +12 -6
- data/vendor/libgit2/src/signature.h +1 -1
- data/vendor/libgit2/src/sortedcache.c +1 -1
- data/vendor/libgit2/src/sortedcache.h +1 -1
- data/vendor/libgit2/src/stash.c +36 -37
- data/vendor/libgit2/src/status.c +4 -1
- data/vendor/libgit2/src/{buffer.c → str.c} +157 -151
- data/vendor/libgit2/src/str.h +357 -0
- data/vendor/libgit2/src/streams/mbedtls.c +8 -6
- data/vendor/libgit2/src/streams/openssl_dynamic.h +3 -3
- data/vendor/libgit2/src/submodule.c +171 -159
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/sysdir.c +68 -52
- data/vendor/libgit2/src/sysdir.h +15 -10
- data/vendor/libgit2/src/tag.c +29 -27
- data/vendor/libgit2/src/thread.h +3 -3
- data/vendor/libgit2/src/threadstate.c +3 -3
- data/vendor/libgit2/src/threadstate.h +1 -1
- data/vendor/libgit2/src/trace.c +1 -14
- data/vendor/libgit2/src/trace.h +5 -22
- data/vendor/libgit2/src/trailer.c +1 -1
- data/vendor/libgit2/src/transaction.c +1 -1
- data/vendor/libgit2/src/transport.c +10 -10
- data/vendor/libgit2/src/transports/auth.c +7 -9
- data/vendor/libgit2/src/transports/auth.h +2 -3
- data/vendor/libgit2/src/transports/auth_negotiate.c +12 -13
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -10
- data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
- data/vendor/libgit2/src/transports/git.c +9 -11
- data/vendor/libgit2/src/transports/http.c +37 -17
- data/vendor/libgit2/src/transports/http.h +2 -3
- data/vendor/libgit2/src/transports/httpclient.c +65 -65
- data/vendor/libgit2/src/transports/local.c +124 -116
- data/vendor/libgit2/src/transports/smart.c +51 -139
- data/vendor/libgit2/src/transports/smart.h +25 -31
- data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
- data/vendor/libgit2/src/transports/smart_protocol.c +57 -39
- data/vendor/libgit2/src/transports/ssh.c +47 -112
- data/vendor/libgit2/src/transports/winhttp.c +50 -56
- data/vendor/libgit2/src/tree-cache.c +5 -5
- data/vendor/libgit2/src/tree-cache.h +2 -2
- data/vendor/libgit2/src/tree.c +59 -48
- data/vendor/libgit2/src/tree.h +1 -1
- data/vendor/libgit2/src/unix/map.c +0 -2
- data/vendor/libgit2/src/unix/posix.h +1 -4
- data/vendor/libgit2/src/unix/realpath.c +0 -2
- data/vendor/libgit2/src/util.c +14 -14
- data/vendor/libgit2/src/util.h +2 -28
- data/vendor/libgit2/src/vector.h +1 -1
- data/vendor/libgit2/src/win32/findfile.c +172 -116
- data/vendor/libgit2/src/win32/findfile.h +7 -4
- data/vendor/libgit2/src/win32/path_w32.c +140 -9
- data/vendor/libgit2/src/win32/path_w32.h +2 -0
- data/vendor/libgit2/src/win32/posix.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +11 -27
- data/vendor/libgit2/src/win32/w32_buffer.c +2 -3
- data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
- data/vendor/libgit2/src/win32/w32_leakcheck.c +1 -1
- data/vendor/libgit2/src/worktree.c +116 -94
- data/vendor/libgit2/src/worktree.h +1 -1
- data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
- data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
- data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
- data/vendor/libgit2/src/xdiff/xemit.c +23 -7
- data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
- data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
- data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
- data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
- data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
- data/vendor/libgit2/src/xdiff/xutils.c +18 -7
- data/vendor/libgit2/src/zstream.c +5 -5
- data/vendor/libgit2/src/zstream.h +4 -4
- metadata +25 -10
- data/vendor/libgit2/src/buffer.h +0 -374
data/vendor/libgit2/src/midx.c
CHANGED
@@ -8,14 +8,15 @@
|
|
8
8
|
#include "midx.h"
|
9
9
|
|
10
10
|
#include "array.h"
|
11
|
-
#include "
|
11
|
+
#include "buf.h"
|
12
12
|
#include "filebuf.h"
|
13
13
|
#include "futils.h"
|
14
14
|
#include "hash.h"
|
15
15
|
#include "odb.h"
|
16
16
|
#include "pack.h"
|
17
|
-
#include "
|
17
|
+
#include "fs_path.h"
|
18
18
|
#include "repository.h"
|
19
|
+
#include "str.h"
|
19
20
|
|
20
21
|
#define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */
|
21
22
|
#define MIDX_VERSION 1
|
@@ -177,7 +178,8 @@ int git_midx_parse(
|
|
177
178
|
struct git_midx_chunk *last_chunk;
|
178
179
|
uint32_t i;
|
179
180
|
off64_t last_chunk_offset, chunk_offset, trailer_offset;
|
180
|
-
|
181
|
+
size_t checksum_size;
|
182
|
+
unsigned char checksum[GIT_HASH_SHA1_SIZE];
|
181
183
|
int error;
|
182
184
|
struct git_midx_chunk chunk_packfile_names = {0},
|
183
185
|
chunk_oid_fanout = {0},
|
@@ -207,14 +209,17 @@ int git_midx_parse(
|
|
207
209
|
last_chunk_offset =
|
208
210
|
sizeof(struct git_midx_header) +
|
209
211
|
(1 + hdr->chunks) * 12;
|
210
|
-
|
212
|
+
|
213
|
+
checksum_size = GIT_HASH_SHA1_SIZE;
|
214
|
+
trailer_offset = size - checksum_size;
|
215
|
+
|
211
216
|
if (trailer_offset < last_chunk_offset)
|
212
217
|
return midx_error("wrong index size");
|
213
|
-
|
218
|
+
memcpy(idx->checksum, data + trailer_offset, checksum_size);
|
214
219
|
|
215
|
-
if (git_hash_buf(
|
220
|
+
if (git_hash_buf(checksum, data, (size_t)trailer_offset, GIT_HASH_ALGORITHM_SHA1) < 0)
|
216
221
|
return midx_error("could not calculate signature");
|
217
|
-
if (
|
222
|
+
if (memcmp(checksum, idx->checksum, checksum_size) != 0)
|
218
223
|
return midx_error("index signature mismatch");
|
219
224
|
|
220
225
|
chunk_hdr = data + sizeof(struct git_midx_header);
|
@@ -313,7 +318,7 @@ int git_midx_open(
|
|
313
318
|
idx = git__calloc(1, sizeof(git_midx_file));
|
314
319
|
GIT_ERROR_CHECK_ALLOC(idx);
|
315
320
|
|
316
|
-
error =
|
321
|
+
error = git_str_sets(&idx->filename, path);
|
317
322
|
if (error < 0)
|
318
323
|
return error;
|
319
324
|
|
@@ -340,7 +345,8 @@ bool git_midx_needs_refresh(
|
|
340
345
|
git_file fd = -1;
|
341
346
|
struct stat st;
|
342
347
|
ssize_t bytes_read;
|
343
|
-
|
348
|
+
unsigned char checksum[GIT_HASH_SHA1_SIZE];
|
349
|
+
size_t checksum_size;
|
344
350
|
|
345
351
|
/* TODO: properly open the file without access time using O_NOATIME */
|
346
352
|
fd = git_futils_open_ro(path);
|
@@ -359,13 +365,14 @@ bool git_midx_needs_refresh(
|
|
359
365
|
return true;
|
360
366
|
}
|
361
367
|
|
362
|
-
|
368
|
+
checksum_size = GIT_HASH_SHA1_SIZE;
|
369
|
+
bytes_read = p_pread(fd, checksum, checksum_size, st.st_size - GIT_OID_RAWSZ);
|
363
370
|
p_close(fd);
|
364
371
|
|
365
|
-
if (bytes_read !=
|
372
|
+
if (bytes_read != (ssize_t)checksum_size)
|
366
373
|
return true;
|
367
374
|
|
368
|
-
return
|
375
|
+
return (memcmp(checksum, idx->checksum, checksum_size) != 0);
|
369
376
|
}
|
370
377
|
|
371
378
|
int git_midx_entry_find(
|
@@ -477,7 +484,7 @@ void git_midx_free(git_midx_file *idx)
|
|
477
484
|
if (!idx)
|
478
485
|
return;
|
479
486
|
|
480
|
-
|
487
|
+
git_str_dispose(&idx->filename);
|
481
488
|
git_midx_close(idx);
|
482
489
|
git__free(idx);
|
483
490
|
}
|
@@ -497,14 +504,14 @@ int git_midx_writer_new(
|
|
497
504
|
git_midx_writer *w = git__calloc(1, sizeof(git_midx_writer));
|
498
505
|
GIT_ERROR_CHECK_ALLOC(w);
|
499
506
|
|
500
|
-
if (
|
507
|
+
if (git_str_sets(&w->pack_dir, pack_dir) < 0) {
|
501
508
|
git__free(w);
|
502
509
|
return -1;
|
503
510
|
}
|
504
|
-
|
511
|
+
git_fs_path_squash_slashes(&w->pack_dir);
|
505
512
|
|
506
513
|
if (git_vector_init(&w->packs, 0, packfile__cmp) < 0) {
|
507
|
-
|
514
|
+
git_str_dispose(&w->pack_dir);
|
508
515
|
git__free(w);
|
509
516
|
return -1;
|
510
517
|
}
|
@@ -524,7 +531,7 @@ void git_midx_writer_free(git_midx_writer *w)
|
|
524
531
|
git_vector_foreach (&w->packs, i, p)
|
525
532
|
git_mwindow_put_pack(p);
|
526
533
|
git_vector_free(&w->packs);
|
527
|
-
|
534
|
+
git_str_dispose(&w->pack_dir);
|
528
535
|
git__free(w);
|
529
536
|
}
|
530
537
|
|
@@ -532,16 +539,16 @@ int git_midx_writer_add(
|
|
532
539
|
git_midx_writer *w,
|
533
540
|
const char *idx_path)
|
534
541
|
{
|
535
|
-
|
542
|
+
git_str idx_path_buf = GIT_STR_INIT;
|
536
543
|
int error;
|
537
544
|
struct git_pack_file *p;
|
538
545
|
|
539
|
-
error =
|
546
|
+
error = git_fs_path_prettify(&idx_path_buf, idx_path, git_str_cstr(&w->pack_dir));
|
540
547
|
if (error < 0)
|
541
548
|
return error;
|
542
549
|
|
543
|
-
error = git_mwindow_get_pack(&p,
|
544
|
-
|
550
|
+
error = git_mwindow_get_pack(&p, git_str_cstr(&idx_path_buf));
|
551
|
+
git_str_dispose(&idx_path_buf);
|
545
552
|
if (error < 0)
|
546
553
|
return error;
|
547
554
|
|
@@ -613,8 +620,8 @@ static int write_chunk_header(int chunk_id, off64_t offset, midx_write_cb write_
|
|
613
620
|
|
614
621
|
static int midx_write_buf(const char *buf, size_t size, void *data)
|
615
622
|
{
|
616
|
-
|
617
|
-
return
|
623
|
+
git_str *b = (git_str *)data;
|
624
|
+
return git_str_put(b, buf, size);
|
618
625
|
}
|
619
626
|
|
620
627
|
struct midx_write_hash_context {
|
@@ -648,11 +655,12 @@ static int midx_write(
|
|
648
655
|
uint32_t object_large_offsets_count;
|
649
656
|
uint32_t oid_fanout[256];
|
650
657
|
off64_t offset;
|
651
|
-
|
652
|
-
oid_lookup =
|
653
|
-
object_offsets =
|
654
|
-
object_large_offsets =
|
655
|
-
|
658
|
+
git_str packfile_names = GIT_STR_INIT,
|
659
|
+
oid_lookup = GIT_STR_INIT,
|
660
|
+
object_offsets = GIT_STR_INIT,
|
661
|
+
object_large_offsets = GIT_STR_INIT;
|
662
|
+
unsigned char checksum[GIT_HASH_SHA1_SIZE];
|
663
|
+
size_t checksum_size;
|
656
664
|
git_midx_entry *entry;
|
657
665
|
object_entry_array_t object_entries_array = GIT_ARRAY_INIT;
|
658
666
|
git_vector object_entries = GIT_VECTOR_INIT;
|
@@ -668,7 +676,8 @@ static int midx_write(
|
|
668
676
|
hash_cb_data.cb_data = cb_data;
|
669
677
|
hash_cb_data.ctx = &ctx;
|
670
678
|
|
671
|
-
|
679
|
+
checksum_size = GIT_HASH_SHA1_SIZE;
|
680
|
+
error = git_hash_ctx_init(&ctx, GIT_HASH_ALGORITHM_SHA1);
|
672
681
|
if (error < 0)
|
673
682
|
return error;
|
674
683
|
cb_data = &hash_cb_data;
|
@@ -676,34 +685,34 @@ static int midx_write(
|
|
676
685
|
|
677
686
|
git_vector_sort(&w->packs);
|
678
687
|
git_vector_foreach (&w->packs, i, p) {
|
679
|
-
|
688
|
+
git_str relative_index = GIT_STR_INIT;
|
680
689
|
struct object_entry_cb_state state = {0};
|
681
690
|
size_t path_len;
|
682
691
|
|
683
692
|
state.pack_index = (uint32_t)i;
|
684
693
|
state.object_entries_array = &object_entries_array;
|
685
694
|
|
686
|
-
error =
|
695
|
+
error = git_str_sets(&relative_index, p->pack_name);
|
687
696
|
if (error < 0)
|
688
697
|
goto cleanup;
|
689
|
-
error =
|
698
|
+
error = git_fs_path_make_relative(&relative_index, git_str_cstr(&w->pack_dir));
|
690
699
|
if (error < 0) {
|
691
|
-
|
700
|
+
git_str_dispose(&relative_index);
|
692
701
|
goto cleanup;
|
693
702
|
}
|
694
|
-
path_len =
|
695
|
-
if (path_len <= strlen(".pack") || git__suffixcmp(
|
696
|
-
|
703
|
+
path_len = git_str_len(&relative_index);
|
704
|
+
if (path_len <= strlen(".pack") || git__suffixcmp(git_str_cstr(&relative_index), ".pack") != 0) {
|
705
|
+
git_str_dispose(&relative_index);
|
697
706
|
git_error_set(GIT_ERROR_INVALID, "invalid packfile name: '%s'", p->pack_name);
|
698
707
|
error = -1;
|
699
708
|
goto cleanup;
|
700
709
|
}
|
701
710
|
path_len -= strlen(".pack");
|
702
711
|
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
712
|
+
git_str_put(&packfile_names, git_str_cstr(&relative_index), path_len);
|
713
|
+
git_str_puts(&packfile_names, ".idx");
|
714
|
+
git_str_putc(&packfile_names, '\0');
|
715
|
+
git_str_dispose(&relative_index);
|
707
716
|
|
708
717
|
error = git_pack_foreach_entry_offset(p, object_entry__cb, &state);
|
709
718
|
if (error < 0)
|
@@ -723,8 +732,8 @@ static int midx_write(
|
|
723
732
|
git_vector_uniq(&object_entries, NULL);
|
724
733
|
|
725
734
|
/* Pad the packfile names so it is a multiple of four. */
|
726
|
-
while (
|
727
|
-
|
735
|
+
while (git_str_len(&packfile_names) & 3)
|
736
|
+
git_str_putc(&packfile_names, '\0');
|
728
737
|
|
729
738
|
/* Fill the OID Fanout table. */
|
730
739
|
oid_fanout_count = 0;
|
@@ -737,7 +746,7 @@ static int midx_write(
|
|
737
746
|
|
738
747
|
/* Fill the OID Lookup table. */
|
739
748
|
git_vector_foreach (&object_entries, i, entry) {
|
740
|
-
error =
|
749
|
+
error = git_str_put(&oid_lookup, (const char *)&entry->sha1, sizeof(entry->sha1));
|
741
750
|
if (error < 0)
|
742
751
|
goto cleanup;
|
743
752
|
}
|
@@ -748,7 +757,7 @@ static int midx_write(
|
|
748
757
|
uint32_t word;
|
749
758
|
|
750
759
|
word = htonl((uint32_t)entry->pack_index);
|
751
|
-
error =
|
760
|
+
error = git_str_put(&object_offsets, (const char *)&word, sizeof(word));
|
752
761
|
if (error < 0)
|
753
762
|
goto cleanup;
|
754
763
|
if (entry->offset >= 0x80000000l) {
|
@@ -759,7 +768,7 @@ static int midx_write(
|
|
759
768
|
word = htonl((uint32_t)entry->offset & 0x7fffffffu);
|
760
769
|
}
|
761
770
|
|
762
|
-
error =
|
771
|
+
error = git_str_put(&object_offsets, (const char *)&word, sizeof(word));
|
763
772
|
if (error < 0)
|
764
773
|
goto cleanup;
|
765
774
|
}
|
@@ -767,7 +776,7 @@ static int midx_write(
|
|
767
776
|
/* Write the header. */
|
768
777
|
hdr.packfiles = htonl((uint32_t)git_vector_length(&w->packs));
|
769
778
|
hdr.chunks = 4;
|
770
|
-
if (
|
779
|
+
if (git_str_len(&object_large_offsets) > 0)
|
771
780
|
hdr.chunks++;
|
772
781
|
error = write_cb((const char *)&hdr, sizeof(hdr), cb_data);
|
773
782
|
if (error < 0)
|
@@ -778,7 +787,7 @@ static int midx_write(
|
|
778
787
|
error = write_chunk_header(MIDX_PACKFILE_NAMES_ID, offset, write_cb, cb_data);
|
779
788
|
if (error < 0)
|
780
789
|
goto cleanup;
|
781
|
-
offset +=
|
790
|
+
offset += git_str_len(&packfile_names);
|
782
791
|
error = write_chunk_header(MIDX_OID_FANOUT_ID, offset, write_cb, cb_data);
|
783
792
|
if (error < 0)
|
784
793
|
goto cleanup;
|
@@ -786,53 +795,53 @@ static int midx_write(
|
|
786
795
|
error = write_chunk_header(MIDX_OID_LOOKUP_ID, offset, write_cb, cb_data);
|
787
796
|
if (error < 0)
|
788
797
|
goto cleanup;
|
789
|
-
offset +=
|
798
|
+
offset += git_str_len(&oid_lookup);
|
790
799
|
error = write_chunk_header(MIDX_OBJECT_OFFSETS_ID, offset, write_cb, cb_data);
|
791
800
|
if (error < 0)
|
792
801
|
goto cleanup;
|
793
|
-
offset +=
|
794
|
-
if (
|
802
|
+
offset += git_str_len(&object_offsets);
|
803
|
+
if (git_str_len(&object_large_offsets) > 0) {
|
795
804
|
error = write_chunk_header(MIDX_OBJECT_LARGE_OFFSETS_ID, offset, write_cb, cb_data);
|
796
805
|
if (error < 0)
|
797
806
|
goto cleanup;
|
798
|
-
offset +=
|
807
|
+
offset += git_str_len(&object_large_offsets);
|
799
808
|
}
|
800
809
|
error = write_chunk_header(0, offset, write_cb, cb_data);
|
801
810
|
if (error < 0)
|
802
811
|
goto cleanup;
|
803
812
|
|
804
813
|
/* Write all the chunks. */
|
805
|
-
error = write_cb(
|
814
|
+
error = write_cb(git_str_cstr(&packfile_names), git_str_len(&packfile_names), cb_data);
|
806
815
|
if (error < 0)
|
807
816
|
goto cleanup;
|
808
817
|
error = write_cb((const char *)oid_fanout, sizeof(oid_fanout), cb_data);
|
809
818
|
if (error < 0)
|
810
819
|
goto cleanup;
|
811
|
-
error = write_cb(
|
820
|
+
error = write_cb(git_str_cstr(&oid_lookup), git_str_len(&oid_lookup), cb_data);
|
812
821
|
if (error < 0)
|
813
822
|
goto cleanup;
|
814
|
-
error = write_cb(
|
823
|
+
error = write_cb(git_str_cstr(&object_offsets), git_str_len(&object_offsets), cb_data);
|
815
824
|
if (error < 0)
|
816
825
|
goto cleanup;
|
817
|
-
error = write_cb(
|
826
|
+
error = write_cb(git_str_cstr(&object_large_offsets), git_str_len(&object_large_offsets), cb_data);
|
818
827
|
if (error < 0)
|
819
828
|
goto cleanup;
|
820
829
|
|
821
830
|
/* Finalize the checksum and write the trailer. */
|
822
|
-
error = git_hash_final(
|
831
|
+
error = git_hash_final(checksum, &ctx);
|
823
832
|
if (error < 0)
|
824
833
|
goto cleanup;
|
825
|
-
error = write_cb((
|
834
|
+
error = write_cb((char *)checksum, checksum_size, cb_data);
|
826
835
|
if (error < 0)
|
827
836
|
goto cleanup;
|
828
837
|
|
829
838
|
cleanup:
|
830
839
|
git_array_clear(object_entries_array);
|
831
840
|
git_vector_free(&object_entries);
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
841
|
+
git_str_dispose(&packfile_names);
|
842
|
+
git_str_dispose(&oid_lookup);
|
843
|
+
git_str_dispose(&object_offsets);
|
844
|
+
git_str_dispose(&object_large_offsets);
|
836
845
|
git_hash_ctx_cleanup(&ctx);
|
837
846
|
return error;
|
838
847
|
}
|
@@ -848,17 +857,17 @@ int git_midx_writer_commit(
|
|
848
857
|
{
|
849
858
|
int error;
|
850
859
|
int filebuf_flags = GIT_FILEBUF_DO_NOT_BUFFER;
|
851
|
-
|
860
|
+
git_str midx_path = GIT_STR_INIT;
|
852
861
|
git_filebuf output = GIT_FILEBUF_INIT;
|
853
862
|
|
854
|
-
error =
|
863
|
+
error = git_str_joinpath(&midx_path, git_str_cstr(&w->pack_dir), "multi-pack-index");
|
855
864
|
if (error < 0)
|
856
865
|
return error;
|
857
866
|
|
858
867
|
if (git_repository__fsync_gitdir)
|
859
868
|
filebuf_flags |= GIT_FILEBUF_FSYNC;
|
860
|
-
error = git_filebuf_open(&output,
|
861
|
-
|
869
|
+
error = git_filebuf_open(&output, git_str_cstr(&midx_path), filebuf_flags, 0644);
|
870
|
+
git_str_dispose(&midx_path);
|
862
871
|
if (error < 0)
|
863
872
|
return error;
|
864
873
|
|
@@ -875,5 +884,13 @@ int git_midx_writer_dump(
|
|
875
884
|
git_buf *midx,
|
876
885
|
git_midx_writer *w)
|
877
886
|
{
|
878
|
-
|
887
|
+
git_str str = GIT_STR_INIT;
|
888
|
+
int error;
|
889
|
+
|
890
|
+
if ((error = git_buf_tostr(&str, midx)) < 0 ||
|
891
|
+
(error = midx_write(w, midx_write_buf, &str)) == 0)
|
892
|
+
error = git_buf_fromstr(midx, &str);
|
893
|
+
|
894
|
+
git_str_dispose(&str);
|
895
|
+
return error;
|
879
896
|
}
|
data/vendor/libgit2/src/midx.h
CHANGED
@@ -51,10 +51,10 @@ typedef struct git_midx_file {
|
|
51
51
|
size_t num_object_large_offsets;
|
52
52
|
|
53
53
|
/* The trailer of the file. Contains the SHA1-checksum of the whole file. */
|
54
|
-
|
54
|
+
unsigned char checksum[GIT_HASH_SHA1_SIZE];
|
55
55
|
|
56
56
|
/* something like ".git/objects/pack/multi-pack-index". */
|
57
|
-
|
57
|
+
git_str filename;
|
58
58
|
} git_midx_file;
|
59
59
|
|
60
60
|
/*
|
@@ -77,7 +77,7 @@ struct git_midx_writer {
|
|
77
77
|
* The path of the directory where the .pack/.idx files are stored. The
|
78
78
|
* `multi-pack-index` file will be written to the same directory.
|
79
79
|
*/
|
80
|
-
|
80
|
+
git_str pack_dir;
|
81
81
|
|
82
82
|
/* The list of `git_pack_file`s. */
|
83
83
|
git_vector packs;
|
@@ -473,7 +473,7 @@ int git_mwindow_file_register(git_mwindow_file *mwf)
|
|
473
473
|
git_mwindow_find_lru_file_locked(&lru_file) == 0) {
|
474
474
|
if ((error = git_vector_insert(&closed_files, lru_file)) < 0) {
|
475
475
|
/*
|
476
|
-
* Exceeding the file limit seems
|
476
|
+
* Exceeding the file limit seems preferable to being open to
|
477
477
|
* data races that can end up corrupting the heap.
|
478
478
|
*/
|
479
479
|
break;
|