rugged 0.16.0 → 0.17.0b1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +373 -243
- data/Rakefile +22 -0
- data/ext/rugged/extconf.rb +9 -6
- data/ext/rugged/rugged.c +123 -31
- data/ext/rugged/rugged.h +11 -10
- data/ext/rugged/rugged_blob.c +181 -18
- data/ext/rugged/rugged_commit.c +196 -18
- data/ext/rugged/rugged_config.c +94 -5
- data/ext/rugged/rugged_object.c +54 -1
- data/ext/rugged/rugged_reference.c +203 -15
- data/ext/rugged/{remote.c → rugged_remote.c} +35 -10
- data/ext/rugged/rugged_repo.c +323 -81
- data/ext/rugged/rugged_revwalk.c +57 -4
- data/ext/rugged/rugged_signature.c +3 -3
- data/ext/rugged/rugged_tag.c +72 -1
- data/ext/rugged/rugged_tree.c +70 -2
- data/ext/rugged/vendor/libgit2-dist/deps/regex/config.h +7 -0
- data/ext/rugged/vendor/libgit2-dist/deps/regex/regcomp.c +3856 -0
- data/ext/rugged/vendor/libgit2-dist/deps/regex/regex.c +85 -0
- data/ext/rugged/vendor/libgit2-dist/deps/regex/regex.h +582 -0
- data/ext/rugged/vendor/libgit2-dist/deps/regex/regex_internal.c +1744 -0
- data/ext/rugged/vendor/libgit2-dist/deps/regex/regex_internal.h +810 -0
- data/ext/rugged/vendor/libgit2-dist/deps/regex/regexec.c +4369 -0
- data/ext/rugged/vendor/libgit2-dist/examples/diff.c +238 -0
- data/ext/rugged/vendor/libgit2-dist/examples/general.c +4 -4
- data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +101 -85
- data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +7 -3
- data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +80 -25
- data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +6 -6
- data/ext/rugged/vendor/libgit2-dist/include/git2/attr.h +224 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/blob.h +59 -5
- data/ext/rugged/vendor/libgit2-dist/include/git2/branch.h +114 -7
- data/ext/rugged/vendor/libgit2-dist/include/git2/commit.h +14 -7
- data/ext/rugged/vendor/libgit2-dist/include/git2/common.h +4 -3
- data/ext/rugged/vendor/libgit2-dist/include/git2/config.h +105 -27
- data/ext/rugged/vendor/libgit2-dist/include/git2/diff.h +409 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/errors.h +47 -82
- data/ext/rugged/vendor/libgit2-dist/include/git2/index.h +25 -10
- data/ext/rugged/vendor/libgit2-dist/include/git2/indexer.h +46 -1
- data/ext/rugged/vendor/libgit2-dist/include/git2/merge.h +35 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/net.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/include/git2/notes.h +139 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/object.h +5 -5
- data/ext/rugged/vendor/libgit2-dist/include/git2/odb.h +13 -13
- data/ext/rugged/vendor/libgit2-dist/include/git2/odb_backend.h +8 -8
- data/ext/rugged/vendor/libgit2-dist/include/git2/oid.h +14 -9
- data/ext/rugged/vendor/libgit2-dist/include/git2/reflog.h +5 -5
- data/ext/rugged/vendor/libgit2-dist/include/git2/refs.h +37 -17
- data/ext/rugged/vendor/libgit2-dist/include/git2/refspec.h +17 -9
- data/ext/rugged/vendor/libgit2-dist/include/git2/remote.h +83 -16
- data/ext/rugged/vendor/libgit2-dist/include/git2/repository.h +24 -10
- data/ext/rugged/vendor/libgit2-dist/include/git2/reset.h +44 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/revparse.h +36 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/revwalk.h +74 -6
- data/ext/rugged/vendor/libgit2-dist/include/git2/signature.h +3 -3
- data/ext/rugged/vendor/libgit2-dist/include/git2/status.h +120 -19
- data/ext/rugged/vendor/libgit2-dist/include/git2/submodule.h +103 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/tag.h +28 -10
- data/ext/rugged/vendor/libgit2-dist/include/git2/threads.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/include/git2/tree.h +13 -13
- data/ext/rugged/vendor/libgit2-dist/include/git2/types.h +16 -2
- data/ext/rugged/vendor/libgit2-dist/include/git2/version.h +3 -3
- data/ext/rugged/vendor/libgit2-dist/include/git2/windows.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/include/git2.h +7 -2
- data/ext/rugged/vendor/libgit2-dist/src/attr.c +677 -0
- data/ext/rugged/vendor/libgit2-dist/src/attr.h +56 -0
- data/ext/rugged/vendor/libgit2-dist/src/attr_file.c +609 -0
- data/ext/rugged/vendor/libgit2-dist/src/attr_file.h +145 -0
- data/ext/rugged/vendor/libgit2-dist/src/blob.c +213 -60
- data/ext/rugged/vendor/libgit2-dist/src/blob.h +2 -1
- data/ext/rugged/vendor/libgit2-dist/src/branch.c +208 -0
- data/ext/rugged/vendor/libgit2-dist/src/branch.h +17 -0
- data/ext/rugged/vendor/libgit2-dist/src/bswap.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/buffer.c +395 -46
- data/ext/rugged/vendor/libgit2-dist/src/buffer.h +112 -9
- data/ext/rugged/vendor/libgit2-dist/src/cache.c +37 -49
- data/ext/rugged/vendor/libgit2-dist/src/cache.h +7 -17
- data/ext/rugged/vendor/libgit2-dist/src/cc-compat.h +18 -16
- data/ext/rugged/vendor/libgit2-dist/src/commit.c +56 -90
- data/ext/rugged/vendor/libgit2-dist/src/commit.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/common.h +12 -5
- data/ext/rugged/vendor/libgit2-dist/src/{win32 → compat}/fnmatch.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/{win32 → compat}/fnmatch.h +3 -3
- data/ext/rugged/vendor/libgit2-dist/src/config.c +247 -158
- data/ext/rugged/vendor/libgit2-dist/src/config.h +10 -1
- data/ext/rugged/vendor/libgit2-dist/src/config_cache.c +94 -0
- data/ext/rugged/vendor/libgit2-dist/src/config_file.c +606 -496
- data/ext/rugged/vendor/libgit2-dist/src/config_file.h +31 -0
- data/ext/rugged/vendor/libgit2-dist/src/crlf.c +228 -0
- data/ext/rugged/vendor/libgit2-dist/src/date.c +876 -0
- data/ext/rugged/vendor/libgit2-dist/src/delta-apply.c +15 -9
- data/ext/rugged/vendor/libgit2-dist/src/delta-apply.h +2 -2
- data/ext/rugged/vendor/libgit2-dist/src/diff.c +814 -0
- data/ext/rugged/vendor/libgit2-dist/src/diff.h +43 -0
- data/ext/rugged/vendor/libgit2-dist/src/diff_output.c +794 -0
- data/ext/rugged/vendor/libgit2-dist/src/errors.c +89 -74
- data/ext/rugged/vendor/libgit2-dist/src/fetch.c +94 -66
- data/ext/rugged/vendor/libgit2-dist/src/fetch.h +5 -4
- data/ext/rugged/vendor/libgit2-dist/src/filebuf.c +157 -100
- data/ext/rugged/vendor/libgit2-dist/src/filebuf.h +22 -8
- data/ext/rugged/vendor/libgit2-dist/src/fileops.c +330 -206
- data/ext/rugged/vendor/libgit2-dist/src/fileops.h +82 -51
- data/ext/rugged/vendor/libgit2-dist/src/filter.c +165 -0
- data/ext/rugged/vendor/libgit2-dist/src/filter.h +119 -0
- data/ext/rugged/vendor/libgit2-dist/src/global.c +4 -4
- data/ext/rugged/vendor/libgit2-dist/src/global.h +4 -1
- data/ext/rugged/vendor/libgit2-dist/src/hash.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/hash.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/ignore.c +203 -0
- data/ext/rugged/vendor/libgit2-dist/src/ignore.h +38 -0
- data/ext/rugged/vendor/libgit2-dist/src/index.c +220 -169
- data/ext/rugged/vendor/libgit2-dist/src/index.h +5 -1
- data/ext/rugged/vendor/libgit2-dist/src/indexer.c +601 -102
- data/ext/rugged/vendor/libgit2-dist/src/iterator.c +748 -0
- data/ext/rugged/vendor/libgit2-dist/src/iterator.h +151 -0
- data/ext/rugged/vendor/libgit2-dist/src/khash.h +608 -0
- data/ext/rugged/vendor/libgit2-dist/src/map.h +6 -1
- data/ext/rugged/vendor/libgit2-dist/src/message.c +61 -0
- data/ext/rugged/vendor/libgit2-dist/src/message.h +14 -0
- data/ext/rugged/vendor/libgit2-dist/src/mwindow.c +27 -29
- data/ext/rugged/vendor/libgit2-dist/src/mwindow.h +4 -4
- data/ext/rugged/vendor/libgit2-dist/src/netops.c +375 -56
- data/ext/rugged/vendor/libgit2-dist/src/netops.h +12 -9
- data/ext/rugged/vendor/libgit2-dist/src/notes.c +548 -0
- data/ext/rugged/vendor/libgit2-dist/src/notes.h +28 -0
- data/ext/rugged/vendor/libgit2-dist/src/object.c +59 -21
- data/ext/rugged/vendor/libgit2-dist/src/odb.c +212 -175
- data/ext/rugged/vendor/libgit2-dist/src/odb.h +39 -2
- data/ext/rugged/vendor/libgit2-dist/src/odb_loose.c +238 -241
- data/ext/rugged/vendor/libgit2-dist/src/odb_pack.c +94 -106
- data/ext/rugged/vendor/libgit2-dist/src/oid.c +59 -60
- data/ext/rugged/vendor/libgit2-dist/src/oidmap.h +42 -0
- data/ext/rugged/vendor/libgit2-dist/src/pack.c +198 -170
- data/ext/rugged/vendor/libgit2-dist/src/pack.h +16 -9
- data/ext/rugged/vendor/libgit2-dist/src/path.c +496 -106
- data/ext/rugged/vendor/libgit2-dist/src/path.h +214 -20
- data/ext/rugged/vendor/libgit2-dist/src/pkt.c +88 -159
- data/ext/rugged/vendor/libgit2-dist/src/pkt.h +9 -5
- data/ext/rugged/vendor/libgit2-dist/src/pool.c +294 -0
- data/ext/rugged/vendor/libgit2-dist/src/pool.h +125 -0
- data/ext/rugged/vendor/libgit2-dist/src/posix.c +38 -16
- data/ext/rugged/vendor/libgit2-dist/src/posix.h +20 -2
- data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/pqueue.c +7 -7
- data/ext/rugged/vendor/libgit2-dist/src/pqueue.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/protocol.c +21 -13
- data/ext/rugged/vendor/libgit2-dist/src/protocol.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/reflog.c +125 -103
- data/ext/rugged/vendor/libgit2-dist/src/reflog.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/refs.c +713 -640
- data/ext/rugged/vendor/libgit2-dist/src/refs.h +27 -3
- data/ext/rugged/vendor/libgit2-dist/src/refspec.c +51 -17
- data/ext/rugged/vendor/libgit2-dist/src/refspec.h +13 -1
- data/ext/rugged/vendor/libgit2-dist/src/remote.c +307 -119
- data/ext/rugged/vendor/libgit2-dist/src/remote.h +3 -2
- data/ext/rugged/vendor/libgit2-dist/src/repository.c +593 -442
- data/ext/rugged/vendor/libgit2-dist/src/repository.h +80 -2
- data/ext/rugged/vendor/libgit2-dist/src/reset.c +103 -0
- data/ext/rugged/vendor/libgit2-dist/src/revparse.c +753 -0
- data/ext/rugged/vendor/libgit2-dist/src/revwalk.c +434 -158
- data/ext/rugged/vendor/libgit2-dist/src/sha1.c +3 -3
- data/ext/rugged/vendor/libgit2-dist/src/sha1.h +2 -2
- data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.c +3 -2
- data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/signature.c +69 -80
- data/ext/rugged/vendor/libgit2-dist/src/signature.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/status.c +184 -638
- data/ext/rugged/vendor/libgit2-dist/src/strmap.h +64 -0
- data/ext/rugged/vendor/libgit2-dist/src/submodule.c +387 -0
- data/ext/rugged/vendor/libgit2-dist/src/tag.c +162 -137
- data/ext/rugged/vendor/libgit2-dist/src/tag.h +2 -1
- data/ext/rugged/vendor/libgit2-dist/src/thread-utils.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/thread-utils.h +8 -8
- data/ext/rugged/vendor/libgit2-dist/src/transport.c +31 -19
- data/ext/rugged/vendor/libgit2-dist/src/transport.h +31 -11
- data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +168 -193
- data/ext/rugged/vendor/libgit2-dist/src/transports/http.c +192 -241
- data/ext/rugged/vendor/libgit2-dist/src/transports/local.c +92 -86
- data/ext/rugged/vendor/libgit2-dist/src/tree-cache.c +32 -49
- data/ext/rugged/vendor/libgit2-dist/src/tree-cache.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/tree.c +172 -145
- data/ext/rugged/vendor/libgit2-dist/src/tree.h +16 -2
- data/ext/rugged/vendor/libgit2-dist/src/tsort.c +16 -14
- data/ext/rugged/vendor/libgit2-dist/src/unix/map.c +8 -24
- data/ext/rugged/vendor/libgit2-dist/src/unix/posix.h +9 -3
- data/ext/rugged/vendor/libgit2-dist/src/util.c +94 -38
- data/ext/rugged/vendor/libgit2-dist/src/util.h +119 -13
- data/ext/rugged/vendor/libgit2-dist/src/vector.c +84 -31
- data/ext/rugged/vendor/libgit2-dist/src/vector.h +37 -4
- data/ext/rugged/vendor/libgit2-dist/src/win32/dir.c +81 -41
- data/ext/rugged/vendor/libgit2-dist/src/{dir.h → win32/dir.h} +4 -9
- data/ext/rugged/vendor/libgit2-dist/src/win32/map.c +19 -35
- data/ext/rugged/vendor/libgit2-dist/src/win32/mingw-compat.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/win32/msvc-compat.h +5 -1
- data/ext/rugged/vendor/libgit2-dist/src/win32/posix.h +10 -8
- data/ext/rugged/vendor/libgit2-dist/src/win32/posix_w32.c +262 -118
- data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.c +12 -9
- data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.h +1 -1
- data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.c +30 -26
- data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.h +2 -1
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiff.h +135 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiffi.c +572 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiffi.h +63 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xemit.c +253 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xemit.h +36 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xhistogram.c +371 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xinclude.h +46 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xmacros.h +54 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xmerge.c +619 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xpatience.c +358 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xprepare.c +483 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xprepare.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xtypes.h +67 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xutils.c +419 -0
- data/ext/rugged/vendor/libgit2-dist/src/xdiff/xutils.h +49 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/attr_expect.h +43 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/file.c +226 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/flags.c +108 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/lookup.c +262 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/repo.c +273 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/buf/basic.c +5 -5
- data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_helpers.c +181 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_libgit2.h +55 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/commit.c +44 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/parse.c +350 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/signature.c +65 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/write.c +140 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/add.c +3 -3
- data/ext/rugged/vendor/libgit2-dist/tests-clar/config/multivar.c +151 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/new.c +5 -5
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/read.c +44 -32
- data/ext/rugged/vendor/libgit2-dist/tests-clar/config/stress.c +61 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/write.c +20 -5
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/buffer.c +613 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/dirent.c +39 -26
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/env.c +115 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/errors.c +60 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/filebuf.c +4 -18
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/hex.c +22 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/oid.c +6 -6
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/path.c +420 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/pool.c +85 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/rmdir.c +68 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/string.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/strmap.c +102 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/strtol.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/tests-clar/core/vector.c +191 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/date/date.c +15 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/blob.c +254 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.c +104 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.h +47 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/index.c +92 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/iterator.c +572 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/patch.c +99 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/tree.c +210 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/workdir.c +543 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/index/read_tree.c +46 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/index/rename.c +2 -12
- data/ext/rugged/vendor/libgit2-dist/tests-clar/index/tests.c +246 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/network/createremotethenload.c +33 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotelocal.c +137 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotes.c +183 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notes.c +133 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notesref.c +57 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/filter.c +125 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/fromchunks.c +87 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/write.c +69 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/commit/commitstagedfile.c +126 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/lookup.c +63 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/message.c +171 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/chars.c +3 -14
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/compare.c +4 -4
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/convert.c +10 -10
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/data.h +0 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/fromstr.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/hash.c +21 -17
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/short.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/size.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/type2string.c +14 -14
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/write.c +455 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/peel.c +56 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/read.c +130 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/write.c +192 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/tree/frompath.c +22 -16
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/read.c +75 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/write.c +84 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/loose.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/loose_data.h +0 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/mixed.c +24 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/pack_data.h +0 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/packed.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/sorting.c +1 -1
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/create.c +113 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/delete.c +91 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/listall.c +78 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/move.c +72 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/crashes.c +17 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/create.c +149 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/delete.c +85 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/list.c +53 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/listall.c +36 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/lookup.c +42 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/normalize.c +200 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/overwrite.c +136 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/pack.c +67 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/read.c +194 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/reflog.c +123 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/rename.c +339 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/revparse.c +174 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/unicode.c +42 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/discover.c +142 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/repo/getters.c +19 -1
- data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/init.c +235 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/open.c +282 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/setters.c +80 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/mixed.c +47 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.c +10 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.h +6 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/soft.c +102 -0
- data/ext/rugged/vendor/libgit2-dist/{tests/t05-revwalk.c → tests-clar/revwalk/basic.c} +85 -44
- data/ext/rugged/vendor/libgit2-dist/tests-clar/revwalk/mergebase.c +148 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/ignore.c +133 -0
- data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/status/single.c +2 -11
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_data.h +202 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.c +49 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.h +33 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/submodules.c +112 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/status/worktree.c +649 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clar/threads/basic.c +20 -0
- data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
- data/lib/rugged/commit.rb +35 -0
- data/lib/rugged/object.rb +7 -0
- data/lib/rugged/reference.rb +9 -0
- data/lib/rugged/repository.rb +99 -3
- data/lib/rugged/tag.rb +22 -0
- data/lib/rugged/tree.rb +8 -0
- data/lib/rugged/version.rb +1 -1
- data/lib/rugged.rb +4 -1
- data/test/blob_test.rb +2 -2
- data/test/commit_test.rb +27 -13
- data/test/config_test.rb +44 -0
- data/test/coverage/HEAD.json +1 -1
- data/test/fixtures/testrepo.git/config +2 -0
- data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
- data/test/lib_test.rb +7 -0
- data/test/object_test.rb +3 -3
- data/test/reference_test.rb +46 -8
- data/test/remote_test.rb +8 -2
- data/test/repo_pack_test.rb +3 -3
- data/test/repo_test.rb +79 -11
- data/test/tag_test.rb +9 -2
- data/test/test_helper.rb +21 -0
- data/test/tree_test.rb +18 -6
- metadata +205 -81
- data/ext/rugged/vendor/libgit2-dist/include/git2/zlib.h +0 -40
- data/ext/rugged/vendor/libgit2-dist/src/hashtable.c +0 -243
- data/ext/rugged/vendor/libgit2-dist/src/hashtable.h +0 -80
- data/ext/rugged/vendor/libgit2-dist/tests/t00-core.c +0 -628
- data/ext/rugged/vendor/libgit2-dist/tests/t01-data.h +0 -322
- data/ext/rugged/vendor/libgit2-dist/tests/t01-rawobj.c +0 -638
- data/ext/rugged/vendor/libgit2-dist/tests/t03-data.h +0 -344
- data/ext/rugged/vendor/libgit2-dist/tests/t03-objwrite.c +0 -255
- data/ext/rugged/vendor/libgit2-dist/tests/t04-commit.c +0 -788
- data/ext/rugged/vendor/libgit2-dist/tests/t06-index.c +0 -219
- data/ext/rugged/vendor/libgit2-dist/tests/t07-hashtable.c +0 -192
- data/ext/rugged/vendor/libgit2-dist/tests/t08-tag.c +0 -357
- data/ext/rugged/vendor/libgit2-dist/tests/t09-tree.c +0 -221
- data/ext/rugged/vendor/libgit2-dist/tests/t10-refs.c +0 -1294
- data/ext/rugged/vendor/libgit2-dist/tests/t12-repo.c +0 -174
- data/ext/rugged/vendor/libgit2-dist/tests/t13-threads.c +0 -41
- data/ext/rugged/vendor/libgit2-dist/tests/t17-bufs.c +0 -61
- data/ext/rugged/vendor/libgit2-dist/tests/t18-status.c +0 -448
- data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.c +0 -310
- data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.h +0 -83
- data/ext/rugged/vendor/libgit2-dist/tests/test_lib.c +0 -198
- data/ext/rugged/vendor/libgit2-dist/tests/test_lib.h +0 -54
- data/ext/rugged/vendor/libgit2-dist/tests/test_main.c +0 -89
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay.h +0 -187
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_libgit2.h +0 -28
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_main.c +0 -1073
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/stress.c +0 -39
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/path.c +0 -139
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/rmdir.c +0 -50
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/vector.c +0 -66
- data/ext/rugged/vendor/libgit2-dist/tests-clay/network/remotes.c +0 -50
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/init.c +0 -104
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/open.c +0 -54
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/status_data.h +0 -48
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/worktree.c +0 -124
- data/lib/rugged/objects.rb +0 -45
- data/test/fixtures/testrepo.git/refs/heads/new_name +0 -1
@@ -1,13 +1,14 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (C) 2009-
|
2
|
+
* Copyright (C) 2009-2012 the libgit2 contributors
|
3
3
|
*
|
4
4
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
6
6
|
*/
|
7
7
|
|
8
|
+
#include <zlib.h>
|
9
|
+
|
8
10
|
#include "git2/indexer.h"
|
9
11
|
#include "git2/object.h"
|
10
|
-
#include "git2/zlib.h"
|
11
12
|
#include "git2/oid.h"
|
12
13
|
|
13
14
|
#include "common.h"
|
@@ -29,8 +30,6 @@ struct entry {
|
|
29
30
|
|
30
31
|
struct git_indexer {
|
31
32
|
struct git_pack_file *pack;
|
32
|
-
struct stat st;
|
33
|
-
struct git_pack_header hdr;
|
34
33
|
size_t nr_objects;
|
35
34
|
git_vector objects;
|
36
35
|
git_filebuf file;
|
@@ -38,27 +37,89 @@ struct git_indexer {
|
|
38
37
|
git_oid hash;
|
39
38
|
};
|
40
39
|
|
40
|
+
struct git_indexer_stream {
|
41
|
+
unsigned int parsed_header :1,
|
42
|
+
opened_pack;
|
43
|
+
struct git_pack_file *pack;
|
44
|
+
git_filebuf pack_file;
|
45
|
+
git_filebuf index_file;
|
46
|
+
git_off_t off;
|
47
|
+
size_t nr_objects;
|
48
|
+
git_vector objects;
|
49
|
+
git_vector deltas;
|
50
|
+
unsigned int fanout[256];
|
51
|
+
git_oid hash;
|
52
|
+
};
|
53
|
+
|
54
|
+
struct delta_info {
|
55
|
+
git_off_t delta_off;
|
56
|
+
};
|
57
|
+
|
41
58
|
const git_oid *git_indexer_hash(git_indexer *idx)
|
42
59
|
{
|
43
60
|
return &idx->hash;
|
44
61
|
}
|
45
62
|
|
46
|
-
|
63
|
+
const git_oid *git_indexer_stream_hash(git_indexer_stream *idx)
|
64
|
+
{
|
65
|
+
return &idx->hash;
|
66
|
+
}
|
67
|
+
|
68
|
+
static int open_pack(struct git_pack_file **out, const char *filename)
|
69
|
+
{
|
70
|
+
size_t namelen;
|
71
|
+
struct git_pack_file *pack;
|
72
|
+
struct stat st;
|
73
|
+
int fd;
|
74
|
+
|
75
|
+
namelen = strlen(filename);
|
76
|
+
pack = git__calloc(1, sizeof(struct git_pack_file) + namelen + 1);
|
77
|
+
GITERR_CHECK_ALLOC(pack);
|
78
|
+
|
79
|
+
memcpy(pack->pack_name, filename, namelen + 1);
|
80
|
+
|
81
|
+
if (p_stat(filename, &st) < 0) {
|
82
|
+
giterr_set(GITERR_OS, "Failed to stat packfile.");
|
83
|
+
goto cleanup;
|
84
|
+
}
|
85
|
+
|
86
|
+
if ((fd = p_open(pack->pack_name, O_RDONLY)) < 0) {
|
87
|
+
giterr_set(GITERR_OS, "Failed to open packfile.");
|
88
|
+
goto cleanup;
|
89
|
+
}
|
90
|
+
|
91
|
+
pack->mwf.fd = fd;
|
92
|
+
pack->mwf.size = (git_off_t)st.st_size;
|
93
|
+
|
94
|
+
*out = pack;
|
95
|
+
return 0;
|
96
|
+
|
97
|
+
cleanup:
|
98
|
+
git__free(pack);
|
99
|
+
return -1;
|
100
|
+
}
|
101
|
+
|
102
|
+
static int parse_header(struct git_pack_header *hdr, struct git_pack_file *pack)
|
47
103
|
{
|
48
104
|
int error;
|
49
105
|
|
50
106
|
/* Verify we recognize this pack file format. */
|
51
|
-
if ((error = p_read(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
return git__throw(GIT_EOBJCORRUPTED, "Wrong pack signature");
|
107
|
+
if ((error = p_read(pack->mwf.fd, hdr, sizeof(*hdr))) < 0) {
|
108
|
+
giterr_set(GITERR_OS, "Failed to read in pack header");
|
109
|
+
return error;
|
110
|
+
}
|
56
111
|
|
57
|
-
if (
|
58
|
-
|
112
|
+
if (hdr->hdr_signature != ntohl(PACK_SIGNATURE)) {
|
113
|
+
giterr_set(GITERR_INDEXER, "Wrong pack signature");
|
114
|
+
return -1;
|
115
|
+
}
|
59
116
|
|
117
|
+
if (!pack_version_ok(hdr->hdr_version)) {
|
118
|
+
giterr_set(GITERR_INDEXER, "Wrong pack version");
|
119
|
+
return -1;
|
120
|
+
}
|
60
121
|
|
61
|
-
return
|
122
|
+
return 0;
|
62
123
|
}
|
63
124
|
|
64
125
|
static int objects_cmp(const void *a, const void *b)
|
@@ -77,102 +138,529 @@ static int cache_cmp(const void *a, const void *b)
|
|
77
138
|
return git_oid_cmp(&ea->sha1, &eb->sha1);
|
78
139
|
}
|
79
140
|
|
141
|
+
int git_indexer_stream_new(git_indexer_stream **out, const char *prefix)
|
142
|
+
{
|
143
|
+
git_indexer_stream *idx;
|
144
|
+
git_buf path = GIT_BUF_INIT;
|
145
|
+
static const char suff[] = "/objects/pack/pack-received";
|
146
|
+
int error;
|
80
147
|
|
81
|
-
|
148
|
+
idx = git__calloc(1, sizeof(git_indexer_stream));
|
149
|
+
GITERR_CHECK_ALLOC(idx);
|
150
|
+
|
151
|
+
error = git_buf_joinpath(&path, prefix, suff);
|
152
|
+
if (error < 0)
|
153
|
+
goto cleanup;
|
154
|
+
|
155
|
+
error = git_filebuf_open(&idx->pack_file, path.ptr,
|
156
|
+
GIT_FILEBUF_TEMPORARY | GIT_FILEBUF_DO_NOT_BUFFER);
|
157
|
+
git_buf_free(&path);
|
158
|
+
if (error < 0)
|
159
|
+
goto cleanup;
|
160
|
+
|
161
|
+
*out = idx;
|
162
|
+
return 0;
|
163
|
+
|
164
|
+
cleanup:
|
165
|
+
git_buf_free(&path);
|
166
|
+
git_filebuf_cleanup(&idx->pack_file);
|
167
|
+
git__free(idx);
|
168
|
+
return -1;
|
169
|
+
}
|
170
|
+
|
171
|
+
/* Try to store the delta so we can try to resolve it later */
|
172
|
+
static int store_delta(git_indexer_stream *idx)
|
82
173
|
{
|
83
|
-
|
84
|
-
|
85
|
-
|
174
|
+
git_otype type;
|
175
|
+
git_mwindow *w = NULL;
|
176
|
+
git_mwindow_file *mwf = &idx->pack->mwf;
|
177
|
+
git_off_t entry_start = idx->off;
|
178
|
+
struct delta_info *delta;
|
179
|
+
size_t entry_size;
|
180
|
+
git_rawobj obj;
|
181
|
+
int error;
|
86
182
|
|
87
|
-
|
183
|
+
/*
|
184
|
+
* ref-delta objects can refer to object that we haven't
|
185
|
+
* found yet, so give it another opportunity
|
186
|
+
*/
|
187
|
+
if (git_packfile_unpack_header(&entry_size, &type, mwf, &w, &idx->off) < 0)
|
188
|
+
return -1;
|
88
189
|
|
89
|
-
|
90
|
-
return git__throw(GIT_EINVALIDPATH, "Path is not absolute");
|
190
|
+
git_mwindow_close(&w);
|
91
191
|
|
92
|
-
|
93
|
-
if (
|
94
|
-
return
|
192
|
+
/* If it's not a delta, mark it as failure, we can't do anything with it */
|
193
|
+
if (type != GIT_OBJ_REF_DELTA && type != GIT_OBJ_OFS_DELTA)
|
194
|
+
return -1;
|
95
195
|
|
96
|
-
|
196
|
+
if (type == GIT_OBJ_REF_DELTA) {
|
197
|
+
idx->off += GIT_OID_RAWSZ;
|
198
|
+
} else {
|
199
|
+
git_off_t base_off;
|
97
200
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
201
|
+
base_off = get_delta_base(idx->pack, &w, &idx->off, type, entry_start);
|
202
|
+
git_mwindow_close(&w);
|
203
|
+
if (base_off < 0)
|
204
|
+
return (int)base_off;
|
205
|
+
}
|
206
|
+
|
207
|
+
error = packfile_unpack_compressed(&obj, idx->pack, &w, &idx->off, entry_size, type);
|
208
|
+
if (error == GIT_EBUFS) {
|
209
|
+
idx->off = entry_start;
|
210
|
+
return GIT_EBUFS;
|
211
|
+
} else if (error < 0){
|
212
|
+
return -1;
|
213
|
+
}
|
214
|
+
|
215
|
+
delta = git__calloc(1, sizeof(struct delta_info));
|
216
|
+
GITERR_CHECK_ALLOC(delta);
|
217
|
+
delta->delta_off = entry_start;
|
218
|
+
|
219
|
+
git__free(obj.data);
|
220
|
+
|
221
|
+
if (git_vector_insert(&idx->deltas, delta) < 0)
|
222
|
+
return -1;
|
223
|
+
|
224
|
+
return 0;
|
225
|
+
}
|
226
|
+
|
227
|
+
static int hash_and_save(git_indexer_stream *idx, git_rawobj *obj, git_off_t entry_start)
|
228
|
+
{
|
229
|
+
int i;
|
230
|
+
git_oid oid;
|
231
|
+
void *packed;
|
232
|
+
size_t entry_size;
|
233
|
+
unsigned int left;
|
234
|
+
struct entry *entry;
|
235
|
+
git_mwindow *w = NULL;
|
236
|
+
git_mwindow_file *mwf = &idx->pack->mwf;
|
237
|
+
struct git_pack_entry *pentry;
|
238
|
+
|
239
|
+
entry = git__calloc(1, sizeof(*entry));
|
240
|
+
GITERR_CHECK_ALLOC(entry);
|
241
|
+
|
242
|
+
if (entry_start > UINT31_MAX) {
|
243
|
+
entry->offset = UINT32_MAX;
|
244
|
+
entry->offset_long = entry_start;
|
245
|
+
} else {
|
246
|
+
entry->offset = (uint32_t)entry_start;
|
247
|
+
}
|
248
|
+
|
249
|
+
/* FIXME: Parse the object instead of hashing it */
|
250
|
+
if (git_odb__hashobj(&oid, obj) < 0) {
|
251
|
+
giterr_set(GITERR_INDEXER, "Failed to hash object");
|
252
|
+
return -1;
|
253
|
+
}
|
254
|
+
|
255
|
+
pentry = git__malloc(sizeof(struct git_pack_entry));
|
256
|
+
GITERR_CHECK_ALLOC(pentry);
|
257
|
+
|
258
|
+
git_oid_cpy(&pentry->sha1, &oid);
|
259
|
+
pentry->offset = entry_start;
|
260
|
+
if (git_vector_insert(&idx->pack->cache, pentry) < 0)
|
261
|
+
goto on_error;
|
262
|
+
|
263
|
+
git_oid_cpy(&entry->oid, &oid);
|
264
|
+
entry->crc = crc32(0L, Z_NULL, 0);
|
265
|
+
|
266
|
+
entry_size = (size_t)(idx->off - entry_start);
|
267
|
+
packed = git_mwindow_open(mwf, &w, entry_start, entry_size, &left);
|
268
|
+
if (packed == NULL)
|
269
|
+
goto on_error;
|
270
|
+
|
271
|
+
entry->crc = htonl(crc32(entry->crc, packed, (uInt)entry_size));
|
272
|
+
git_mwindow_close(&w);
|
273
|
+
|
274
|
+
/* Add the object to the list */
|
275
|
+
if (git_vector_insert(&idx->objects, entry) < 0)
|
276
|
+
goto on_error;
|
277
|
+
|
278
|
+
for (i = oid.id[0]; i < 256; ++i) {
|
279
|
+
idx->fanout[i]++;
|
280
|
+
}
|
281
|
+
|
282
|
+
return 0;
|
283
|
+
|
284
|
+
on_error:
|
285
|
+
git__free(entry);
|
286
|
+
git__free(pentry);
|
287
|
+
git__free(obj->data);
|
288
|
+
return -1;
|
289
|
+
}
|
290
|
+
|
291
|
+
int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_indexer_stats *stats)
|
292
|
+
{
|
293
|
+
int error;
|
294
|
+
struct git_pack_header hdr;
|
295
|
+
size_t processed;
|
296
|
+
git_mwindow_file *mwf = &idx->pack->mwf;
|
297
|
+
|
298
|
+
assert(idx && data && stats);
|
299
|
+
|
300
|
+
processed = stats->processed;
|
301
|
+
|
302
|
+
if (git_filebuf_write(&idx->pack_file, data, size) < 0)
|
303
|
+
return -1;
|
304
|
+
|
305
|
+
/* Make sure we set the new size of the pack */
|
306
|
+
if (idx->opened_pack) {
|
307
|
+
idx->pack->mwf.size += size;
|
308
|
+
//printf("\nadding %zu for %zu\n", size, idx->pack->mwf.size);
|
309
|
+
} else {
|
310
|
+
if (open_pack(&idx->pack, idx->pack_file.path_lock) < 0)
|
311
|
+
return -1;
|
312
|
+
idx->opened_pack = 1;
|
313
|
+
mwf = &idx->pack->mwf;
|
314
|
+
if (git_mwindow_file_register(&idx->pack->mwf) < 0)
|
315
|
+
return -1;
|
316
|
+
|
317
|
+
return 0;
|
318
|
+
}
|
319
|
+
|
320
|
+
if (!idx->parsed_header) {
|
321
|
+
if ((unsigned)idx->pack->mwf.size < sizeof(hdr))
|
322
|
+
return 0;
|
323
|
+
|
324
|
+
if (parse_header(&hdr, idx->pack) < 0)
|
325
|
+
return -1;
|
326
|
+
|
327
|
+
idx->parsed_header = 1;
|
328
|
+
idx->nr_objects = ntohl(hdr.hdr_entries);
|
329
|
+
idx->off = sizeof(struct git_pack_header);
|
330
|
+
|
331
|
+
/* for now, limit to 2^32 objects */
|
332
|
+
assert(idx->nr_objects == (size_t)((unsigned int)idx->nr_objects));
|
333
|
+
|
334
|
+
if (git_vector_init(&idx->pack->cache, (unsigned int)idx->nr_objects, cache_cmp) < 0)
|
335
|
+
return -1;
|
336
|
+
|
337
|
+
idx->pack->has_cache = 1;
|
338
|
+
if (git_vector_init(&idx->objects, (unsigned int)idx->nr_objects, objects_cmp) < 0)
|
339
|
+
return -1;
|
340
|
+
|
341
|
+
if (git_vector_init(&idx->deltas, (unsigned int)(idx->nr_objects / 2), NULL) < 0)
|
342
|
+
return -1;
|
343
|
+
|
344
|
+
stats->total = (unsigned int)idx->nr_objects;
|
345
|
+
stats->processed = 0;
|
346
|
+
}
|
347
|
+
|
348
|
+
/* Now that we have data in the pack, let's try to parse it */
|
349
|
+
|
350
|
+
/* As the file grows any windows we try to use will be out of date */
|
351
|
+
git_mwindow_free_all(mwf);
|
352
|
+
while (processed < idx->nr_objects) {
|
353
|
+
git_rawobj obj;
|
354
|
+
git_off_t entry_start = idx->off;
|
355
|
+
|
356
|
+
if (idx->pack->mwf.size <= idx->off + 20)
|
357
|
+
return 0;
|
358
|
+
|
359
|
+
error = git_packfile_unpack(&obj, idx->pack, &idx->off);
|
360
|
+
if (error == GIT_EBUFS) {
|
361
|
+
idx->off = entry_start;
|
362
|
+
return 0;
|
363
|
+
}
|
364
|
+
|
365
|
+
if (error < 0) {
|
366
|
+
idx->off = entry_start;
|
367
|
+
error = store_delta(idx);
|
368
|
+
if (error == GIT_EBUFS)
|
369
|
+
return 0;
|
370
|
+
if (error < 0)
|
371
|
+
return error;
|
372
|
+
|
373
|
+
continue;
|
374
|
+
}
|
375
|
+
|
376
|
+
if (hash_and_save(idx, &obj, entry_start) < 0)
|
377
|
+
goto on_error;
|
378
|
+
|
379
|
+
git__free(obj.data);
|
380
|
+
|
381
|
+
stats->processed = (unsigned int)++processed;
|
382
|
+
}
|
383
|
+
|
384
|
+
return 0;
|
385
|
+
|
386
|
+
on_error:
|
387
|
+
git_mwindow_free_all(mwf);
|
388
|
+
return -1;
|
389
|
+
}
|
390
|
+
|
391
|
+
static int index_path_stream(git_buf *path, git_indexer_stream *idx, const char *suffix)
|
392
|
+
{
|
393
|
+
const char prefix[] = "pack-";
|
394
|
+
size_t slash = (size_t)path->size;
|
395
|
+
|
396
|
+
/* search backwards for '/' */
|
397
|
+
while (slash > 0 && path->ptr[slash - 1] != '/')
|
398
|
+
slash--;
|
399
|
+
|
400
|
+
if (git_buf_grow(path, slash + 1 + strlen(prefix) +
|
401
|
+
GIT_OID_HEXSZ + strlen(suffix) + 1) < 0)
|
402
|
+
return -1;
|
403
|
+
|
404
|
+
git_buf_truncate(path, slash);
|
405
|
+
git_buf_puts(path, prefix);
|
406
|
+
git_oid_fmt(path->ptr + git_buf_len(path), &idx->hash);
|
407
|
+
path->size += GIT_OID_HEXSZ;
|
408
|
+
git_buf_puts(path, suffix);
|
409
|
+
|
410
|
+
return git_buf_oom(path) ? -1 : 0;
|
411
|
+
}
|
412
|
+
|
413
|
+
static int resolve_deltas(git_indexer_stream *idx, git_indexer_stats *stats)
|
414
|
+
{
|
415
|
+
unsigned int i;
|
416
|
+
struct delta_info *delta;
|
417
|
+
|
418
|
+
git_vector_foreach(&idx->deltas, i, delta) {
|
419
|
+
git_rawobj obj;
|
420
|
+
|
421
|
+
idx->off = delta->delta_off;
|
422
|
+
if (git_packfile_unpack(&obj, idx->pack, &idx->off) < 0)
|
423
|
+
return -1;
|
424
|
+
|
425
|
+
if (hash_and_save(idx, &obj, delta->delta_off) < 0)
|
426
|
+
return -1;
|
427
|
+
|
428
|
+
git__free(obj.data);
|
429
|
+
stats->processed++;
|
430
|
+
}
|
431
|
+
|
432
|
+
return 0;
|
433
|
+
}
|
434
|
+
|
435
|
+
int git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stats)
|
436
|
+
{
|
437
|
+
git_mwindow *w = NULL;
|
438
|
+
unsigned int i, long_offsets = 0, left;
|
439
|
+
struct git_pack_idx_header hdr;
|
440
|
+
git_buf filename = GIT_BUF_INIT;
|
441
|
+
struct entry *entry;
|
442
|
+
void *packfile_hash;
|
443
|
+
git_oid file_hash;
|
444
|
+
SHA_CTX ctx;
|
445
|
+
|
446
|
+
/* Test for this before resolve_deltas(), as it plays with idx->off */
|
447
|
+
if (idx->off < idx->pack->mwf.size - GIT_OID_RAWSZ) {
|
448
|
+
giterr_set(GITERR_INDEXER, "Indexing error: junk at the end of the pack");
|
449
|
+
return -1;
|
450
|
+
}
|
451
|
+
|
452
|
+
if (idx->deltas.length > 0)
|
453
|
+
if (resolve_deltas(idx, stats) < 0)
|
454
|
+
return -1;
|
455
|
+
|
456
|
+
if (stats->processed != stats->total) {
|
457
|
+
giterr_set(GITERR_INDEXER, "Indexing error: early EOF");
|
458
|
+
return -1;
|
459
|
+
}
|
460
|
+
|
461
|
+
git_vector_sort(&idx->objects);
|
462
|
+
|
463
|
+
git_buf_sets(&filename, idx->pack->pack_name);
|
464
|
+
git_buf_truncate(&filename, filename.size - strlen("pack"));
|
465
|
+
git_buf_puts(&filename, "idx");
|
466
|
+
if (git_buf_oom(&filename))
|
467
|
+
return -1;
|
468
|
+
|
469
|
+
if (git_filebuf_open(&idx->index_file, filename.ptr, GIT_FILEBUF_HASH_CONTENTS) < 0)
|
470
|
+
goto on_error;
|
471
|
+
|
472
|
+
/* Write out the header */
|
473
|
+
hdr.idx_signature = htonl(PACK_IDX_SIGNATURE);
|
474
|
+
hdr.idx_version = htonl(2);
|
475
|
+
git_filebuf_write(&idx->index_file, &hdr, sizeof(hdr));
|
476
|
+
|
477
|
+
/* Write out the fanout table */
|
478
|
+
for (i = 0; i < 256; ++i) {
|
479
|
+
uint32_t n = htonl(idx->fanout[i]);
|
480
|
+
git_filebuf_write(&idx->index_file, &n, sizeof(n));
|
481
|
+
}
|
482
|
+
|
483
|
+
/* Write out the object names (SHA-1 hashes) */
|
484
|
+
SHA1_Init(&ctx);
|
485
|
+
git_vector_foreach(&idx->objects, i, entry) {
|
486
|
+
git_filebuf_write(&idx->index_file, &entry->oid, sizeof(git_oid));
|
487
|
+
SHA1_Update(&ctx, &entry->oid, GIT_OID_RAWSZ);
|
488
|
+
}
|
489
|
+
SHA1_Final(idx->hash.id, &ctx);
|
490
|
+
|
491
|
+
/* Write out the CRC32 values */
|
492
|
+
git_vector_foreach(&idx->objects, i, entry) {
|
493
|
+
git_filebuf_write(&idx->index_file, &entry->crc, sizeof(uint32_t));
|
103
494
|
}
|
104
495
|
|
105
|
-
|
106
|
-
|
496
|
+
/* Write out the offsets */
|
497
|
+
git_vector_foreach(&idx->objects, i, entry) {
|
498
|
+
uint32_t n;
|
107
499
|
|
108
|
-
|
109
|
-
|
110
|
-
if (errno == ENOENT)
|
111
|
-
error = git__throw(GIT_ENOTFOUND, "Failed to stat packfile. File not found");
|
500
|
+
if (entry->offset == UINT32_MAX)
|
501
|
+
n = htonl(0x80000000 | long_offsets++);
|
112
502
|
else
|
113
|
-
|
503
|
+
n = htonl(entry->offset);
|
114
504
|
|
115
|
-
|
505
|
+
git_filebuf_write(&idx->index_file, &n, sizeof(uint32_t));
|
116
506
|
}
|
117
507
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
508
|
+
/* Write out the long offsets */
|
509
|
+
git_vector_foreach(&idx->objects, i, entry) {
|
510
|
+
uint32_t split[2];
|
511
|
+
|
512
|
+
if (entry->offset != UINT32_MAX)
|
513
|
+
continue;
|
514
|
+
|
515
|
+
split[0] = htonl(entry->offset_long >> 32);
|
516
|
+
split[1] = htonl(entry->offset_long & 0xffffffff);
|
517
|
+
|
518
|
+
git_filebuf_write(&idx->index_file, &split, sizeof(uint32_t) * 2);
|
122
519
|
}
|
123
520
|
|
124
|
-
|
125
|
-
idx->pack->mwf.size
|
521
|
+
/* Write out the packfile trailer */
|
522
|
+
packfile_hash = git_mwindow_open(&idx->pack->mwf, &w, idx->pack->mwf.size - GIT_OID_RAWSZ, GIT_OID_RAWSZ, &left);
|
523
|
+
if (packfile_hash == NULL) {
|
524
|
+
git_mwindow_close(&w);
|
525
|
+
goto on_error;
|
526
|
+
}
|
126
527
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
528
|
+
memcpy(&file_hash, packfile_hash, GIT_OID_RAWSZ);
|
529
|
+
git_mwindow_close(&w);
|
530
|
+
|
531
|
+
git_filebuf_write(&idx->index_file, &file_hash, sizeof(git_oid));
|
532
|
+
|
533
|
+
/* Write out the packfile trailer to the idx file as well */
|
534
|
+
if (git_filebuf_hash(&file_hash, &idx->index_file) < 0)
|
535
|
+
goto on_error;
|
536
|
+
|
537
|
+
git_filebuf_write(&idx->index_file, &file_hash, sizeof(git_oid));
|
538
|
+
|
539
|
+
/* Figure out what the final name should be */
|
540
|
+
if (index_path_stream(&filename, idx, ".idx") < 0)
|
541
|
+
goto on_error;
|
542
|
+
|
543
|
+
/* Commit file */
|
544
|
+
if (git_filebuf_commit_at(&idx->index_file, filename.ptr, GIT_PACK_FILE_MODE) < 0)
|
545
|
+
goto on_error;
|
546
|
+
|
547
|
+
git_mwindow_free_all(&idx->pack->mwf);
|
548
|
+
p_close(idx->pack->mwf.fd);
|
549
|
+
|
550
|
+
if (index_path_stream(&filename, idx, ".pack") < 0)
|
551
|
+
goto on_error;
|
552
|
+
/* And don't forget to rename the packfile to its new place. */
|
553
|
+
if (git_filebuf_commit_at(&idx->pack_file, filename.ptr, GIT_PACK_FILE_MODE) < 0)
|
554
|
+
return -1;
|
555
|
+
|
556
|
+
git_buf_free(&filename);
|
557
|
+
return 0;
|
558
|
+
|
559
|
+
on_error:
|
560
|
+
git_mwindow_free_all(&idx->pack->mwf);
|
561
|
+
p_close(idx->pack->mwf.fd);
|
562
|
+
git_filebuf_cleanup(&idx->index_file);
|
563
|
+
git_buf_free(&filename);
|
564
|
+
return -1;
|
565
|
+
}
|
566
|
+
|
567
|
+
void git_indexer_stream_free(git_indexer_stream *idx)
|
568
|
+
{
|
569
|
+
unsigned int i;
|
570
|
+
struct entry *e;
|
571
|
+
struct git_pack_entry *pe;
|
572
|
+
struct delta_info *delta;
|
573
|
+
|
574
|
+
if (idx == NULL)
|
575
|
+
return;
|
576
|
+
|
577
|
+
git_vector_foreach(&idx->objects, i, e)
|
578
|
+
git__free(e);
|
579
|
+
git_vector_free(&idx->objects);
|
580
|
+
git_vector_foreach(&idx->pack->cache, i, pe)
|
581
|
+
git__free(pe);
|
582
|
+
git_vector_free(&idx->pack->cache);
|
583
|
+
git_vector_foreach(&idx->deltas, i, delta)
|
584
|
+
git__free(delta);
|
585
|
+
git_vector_free(&idx->deltas);
|
586
|
+
git__free(idx->pack);
|
587
|
+
git__free(idx);
|
588
|
+
}
|
589
|
+
|
590
|
+
int git_indexer_new(git_indexer **out, const char *packname)
|
591
|
+
{
|
592
|
+
git_indexer *idx;
|
593
|
+
struct git_pack_header hdr;
|
594
|
+
int error;
|
595
|
+
|
596
|
+
assert(out && packname);
|
597
|
+
|
598
|
+
if (git_path_root(packname) < 0) {
|
599
|
+
giterr_set(GITERR_INDEXER, "Path is not absolute");
|
600
|
+
return -1;
|
131
601
|
}
|
132
602
|
|
133
|
-
idx
|
603
|
+
idx = git__calloc(1, sizeof(git_indexer));
|
604
|
+
GITERR_CHECK_ALLOC(idx);
|
134
605
|
|
135
|
-
|
136
|
-
|
606
|
+
open_pack(&idx->pack, packname);
|
607
|
+
|
608
|
+
if ((error = parse_header(&hdr, idx->pack)) < 0)
|
609
|
+
goto cleanup;
|
610
|
+
|
611
|
+
idx->nr_objects = ntohl(hdr.hdr_entries);
|
612
|
+
|
613
|
+
/* for now, limit to 2^32 objects */
|
614
|
+
assert(idx->nr_objects == (size_t)((unsigned int)idx->nr_objects));
|
615
|
+
|
616
|
+
error = git_vector_init(&idx->pack->cache, (unsigned int)idx->nr_objects, cache_cmp);
|
617
|
+
if (error < 0)
|
137
618
|
goto cleanup;
|
138
619
|
|
139
620
|
idx->pack->has_cache = 1;
|
140
|
-
error = git_vector_init(&idx->objects, idx->nr_objects, objects_cmp);
|
141
|
-
if (error <
|
621
|
+
error = git_vector_init(&idx->objects, (unsigned int)idx->nr_objects, objects_cmp);
|
622
|
+
if (error < 0)
|
142
623
|
goto cleanup;
|
143
624
|
|
144
625
|
*out = idx;
|
145
626
|
|
146
|
-
return
|
627
|
+
return 0;
|
147
628
|
|
148
629
|
cleanup:
|
149
630
|
git_indexer_free(idx);
|
150
631
|
|
151
|
-
return
|
632
|
+
return -1;
|
152
633
|
}
|
153
634
|
|
154
|
-
static
|
635
|
+
static int index_path(git_buf *path, git_indexer *idx)
|
155
636
|
{
|
156
|
-
char *ptr;
|
157
637
|
const char prefix[] = "pack-", suffix[] = ".idx";
|
638
|
+
size_t slash = (size_t)path->size;
|
639
|
+
|
640
|
+
/* search backwards for '/' */
|
641
|
+
while (slash > 0 && path->ptr[slash - 1] != '/')
|
642
|
+
slash--;
|
158
643
|
|
159
|
-
|
644
|
+
if (git_buf_grow(path, slash + 1 + strlen(prefix) +
|
645
|
+
GIT_OID_HEXSZ + strlen(suffix) + 1) < 0)
|
646
|
+
return -1;
|
160
647
|
|
161
|
-
|
162
|
-
|
163
|
-
git_oid_fmt(ptr, &idx->hash);
|
164
|
-
|
165
|
-
|
648
|
+
git_buf_truncate(path, slash);
|
649
|
+
git_buf_puts(path, prefix);
|
650
|
+
git_oid_fmt(path->ptr + git_buf_len(path), &idx->hash);
|
651
|
+
path->size += GIT_OID_HEXSZ;
|
652
|
+
git_buf_puts(path, suffix);
|
653
|
+
|
654
|
+
return git_buf_oom(path) ? -1 : 0;
|
166
655
|
}
|
167
656
|
|
168
657
|
int git_indexer_write(git_indexer *idx)
|
169
658
|
{
|
170
659
|
git_mwindow *w = NULL;
|
171
660
|
int error;
|
172
|
-
size_t namelen;
|
173
661
|
unsigned int i, long_offsets = 0, left;
|
174
662
|
struct git_pack_idx_header hdr;
|
175
|
-
|
663
|
+
git_buf filename = GIT_BUF_INIT;
|
176
664
|
struct entry *entry;
|
177
665
|
void *packfile_hash;
|
178
666
|
git_oid file_hash;
|
@@ -180,22 +668,28 @@ int git_indexer_write(git_indexer *idx)
|
|
180
668
|
|
181
669
|
git_vector_sort(&idx->objects);
|
182
670
|
|
183
|
-
|
184
|
-
|
185
|
-
|
671
|
+
git_buf_sets(&filename, idx->pack->pack_name);
|
672
|
+
git_buf_truncate(&filename, filename.size - strlen("pack"));
|
673
|
+
git_buf_puts(&filename, "idx");
|
674
|
+
if (git_buf_oom(&filename))
|
675
|
+
return -1;
|
186
676
|
|
187
|
-
error = git_filebuf_open(&idx->file, filename, GIT_FILEBUF_HASH_CONTENTS);
|
677
|
+
error = git_filebuf_open(&idx->file, filename.ptr, GIT_FILEBUF_HASH_CONTENTS);
|
678
|
+
if (error < 0)
|
679
|
+
goto cleanup;
|
188
680
|
|
189
681
|
/* Write out the header */
|
190
682
|
hdr.idx_signature = htonl(PACK_IDX_SIGNATURE);
|
191
683
|
hdr.idx_version = htonl(2);
|
192
684
|
error = git_filebuf_write(&idx->file, &hdr, sizeof(hdr));
|
685
|
+
if (error < 0)
|
686
|
+
goto cleanup;
|
193
687
|
|
194
688
|
/* Write out the fanout table */
|
195
689
|
for (i = 0; i < 256; ++i) {
|
196
690
|
uint32_t n = htonl(idx->fanout[i]);
|
197
691
|
error = git_filebuf_write(&idx->file, &n, sizeof(n));
|
198
|
-
if (error <
|
692
|
+
if (error < 0)
|
199
693
|
goto cleanup;
|
200
694
|
}
|
201
695
|
|
@@ -204,7 +698,7 @@ int git_indexer_write(git_indexer *idx)
|
|
204
698
|
git_vector_foreach(&idx->objects, i, entry) {
|
205
699
|
error = git_filebuf_write(&idx->file, &entry->oid, sizeof(git_oid));
|
206
700
|
SHA1_Update(&ctx, &entry->oid, GIT_OID_RAWSZ);
|
207
|
-
if (error <
|
701
|
+
if (error < 0)
|
208
702
|
goto cleanup;
|
209
703
|
}
|
210
704
|
SHA1_Final(idx->hash.id, &ctx);
|
@@ -212,7 +706,7 @@ int git_indexer_write(git_indexer *idx)
|
|
212
706
|
/* Write out the CRC32 values */
|
213
707
|
git_vector_foreach(&idx->objects, i, entry) {
|
214
708
|
error = git_filebuf_write(&idx->file, &entry->crc, sizeof(uint32_t));
|
215
|
-
if (error <
|
709
|
+
if (error < 0)
|
216
710
|
goto cleanup;
|
217
711
|
}
|
218
712
|
|
@@ -226,7 +720,7 @@ int git_indexer_write(git_indexer *idx)
|
|
226
720
|
n = htonl(entry->offset);
|
227
721
|
|
228
722
|
error = git_filebuf_write(&idx->file, &n, sizeof(uint32_t));
|
229
|
-
if (error <
|
723
|
+
if (error < 0)
|
230
724
|
goto cleanup;
|
231
725
|
}
|
232
726
|
|
@@ -241,16 +735,16 @@ int git_indexer_write(git_indexer *idx)
|
|
241
735
|
split[1] = htonl(entry->offset_long & 0xffffffff);
|
242
736
|
|
243
737
|
error = git_filebuf_write(&idx->file, &split, sizeof(uint32_t) * 2);
|
244
|
-
if (error <
|
738
|
+
if (error < 0)
|
245
739
|
goto cleanup;
|
246
740
|
}
|
247
741
|
|
248
742
|
/* Write out the packfile trailer */
|
249
743
|
|
250
|
-
packfile_hash = git_mwindow_open(&idx->pack->mwf, &w, idx->
|
744
|
+
packfile_hash = git_mwindow_open(&idx->pack->mwf, &w, idx->pack->mwf.size - GIT_OID_RAWSZ, GIT_OID_RAWSZ, &left);
|
251
745
|
git_mwindow_close(&w);
|
252
746
|
if (packfile_hash == NULL) {
|
253
|
-
error =
|
747
|
+
error = -1;
|
254
748
|
goto cleanup;
|
255
749
|
}
|
256
750
|
|
@@ -259,25 +753,31 @@ int git_indexer_write(git_indexer *idx)
|
|
259
753
|
git_mwindow_close(&w);
|
260
754
|
|
261
755
|
error = git_filebuf_write(&idx->file, &file_hash, sizeof(git_oid));
|
756
|
+
if (error < 0)
|
757
|
+
goto cleanup;
|
262
758
|
|
263
759
|
/* Write out the index sha */
|
264
760
|
error = git_filebuf_hash(&file_hash, &idx->file);
|
265
|
-
if (error <
|
761
|
+
if (error < 0)
|
266
762
|
goto cleanup;
|
267
763
|
|
268
764
|
error = git_filebuf_write(&idx->file, &file_hash, sizeof(git_oid));
|
269
|
-
if (error <
|
765
|
+
if (error < 0)
|
270
766
|
goto cleanup;
|
271
767
|
|
272
768
|
/* Figure out what the final name should be */
|
273
|
-
index_path(filename, idx);
|
769
|
+
error = index_path(&filename, idx);
|
770
|
+
if (error < 0)
|
771
|
+
goto cleanup;
|
772
|
+
|
274
773
|
/* Commit file */
|
275
|
-
error = git_filebuf_commit_at(&idx->file, filename, GIT_PACK_FILE_MODE);
|
774
|
+
error = git_filebuf_commit_at(&idx->file, filename.ptr, GIT_PACK_FILE_MODE);
|
276
775
|
|
277
776
|
cleanup:
|
278
777
|
git_mwindow_free_all(&idx->pack->mwf);
|
279
|
-
if (error <
|
778
|
+
if (error < 0)
|
280
779
|
git_filebuf_cleanup(&idx->file);
|
780
|
+
git_buf_free(&filename);
|
281
781
|
|
282
782
|
return error;
|
283
783
|
}
|
@@ -285,7 +785,7 @@ cleanup:
|
|
285
785
|
int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
|
286
786
|
{
|
287
787
|
git_mwindow_file *mwf;
|
288
|
-
|
788
|
+
git_off_t off = sizeof(struct git_pack_header);
|
289
789
|
int error;
|
290
790
|
struct entry *entry;
|
291
791
|
unsigned int left, processed;
|
@@ -294,10 +794,10 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
|
|
294
794
|
|
295
795
|
mwf = &idx->pack->mwf;
|
296
796
|
error = git_mwindow_file_register(mwf);
|
297
|
-
if (error <
|
298
|
-
return
|
797
|
+
if (error < 0)
|
798
|
+
return error;
|
299
799
|
|
300
|
-
stats->total = idx->nr_objects;
|
800
|
+
stats->total = (unsigned int)idx->nr_objects;
|
301
801
|
stats->processed = processed = 0;
|
302
802
|
|
303
803
|
while (processed < idx->nr_objects) {
|
@@ -306,62 +806,61 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
|
|
306
806
|
struct git_pack_entry *pentry;
|
307
807
|
git_mwindow *w = NULL;
|
308
808
|
int i;
|
309
|
-
|
809
|
+
git_off_t entry_start = off;
|
310
810
|
void *packed;
|
311
811
|
size_t entry_size;
|
812
|
+
char fmt[GIT_OID_HEXSZ] = {0};
|
312
813
|
|
313
|
-
entry =
|
314
|
-
|
814
|
+
entry = git__calloc(1, sizeof(*entry));
|
815
|
+
GITERR_CHECK_ALLOC(entry);
|
315
816
|
|
316
817
|
if (off > UINT31_MAX) {
|
317
818
|
entry->offset = UINT32_MAX;
|
318
819
|
entry->offset_long = off;
|
319
820
|
} else {
|
320
|
-
entry->offset = off;
|
821
|
+
entry->offset = (uint32_t)off;
|
321
822
|
}
|
322
823
|
|
323
824
|
error = git_packfile_unpack(&obj, idx->pack, &off);
|
324
|
-
if (error <
|
325
|
-
error = git__rethrow(error, "Failed to unpack object");
|
825
|
+
if (error < 0)
|
326
826
|
goto cleanup;
|
327
|
-
}
|
328
827
|
|
329
828
|
/* FIXME: Parse the object instead of hashing it */
|
330
|
-
error =
|
331
|
-
if (error <
|
332
|
-
|
829
|
+
error = git_odb__hashobj(&oid, &obj);
|
830
|
+
if (error < 0) {
|
831
|
+
giterr_set(GITERR_INDEXER, "Failed to hash object");
|
333
832
|
goto cleanup;
|
334
833
|
}
|
335
834
|
|
336
835
|
pentry = git__malloc(sizeof(struct git_pack_entry));
|
337
836
|
if (pentry == NULL) {
|
338
|
-
error =
|
837
|
+
error = -1;
|
339
838
|
goto cleanup;
|
340
839
|
}
|
840
|
+
|
341
841
|
git_oid_cpy(&pentry->sha1, &oid);
|
342
842
|
pentry->offset = entry_start;
|
843
|
+
git_oid_fmt(fmt, &oid);
|
343
844
|
error = git_vector_insert(&idx->pack->cache, pentry);
|
344
|
-
if (error <
|
845
|
+
if (error < 0)
|
345
846
|
goto cleanup;
|
346
847
|
|
347
848
|
git_oid_cpy(&entry->oid, &oid);
|
348
849
|
entry->crc = crc32(0L, Z_NULL, 0);
|
349
850
|
|
350
|
-
entry_size = off - entry_start;
|
851
|
+
entry_size = (size_t)(off - entry_start);
|
351
852
|
packed = git_mwindow_open(mwf, &w, entry_start, entry_size, &left);
|
352
853
|
if (packed == NULL) {
|
353
|
-
error =
|
854
|
+
error = -1;
|
354
855
|
goto cleanup;
|
355
856
|
}
|
356
|
-
entry->crc = htonl(crc32(entry->crc, packed, entry_size));
|
857
|
+
entry->crc = htonl(crc32(entry->crc, packed, (uInt)entry_size));
|
357
858
|
git_mwindow_close(&w);
|
358
859
|
|
359
860
|
/* Add the object to the list */
|
360
861
|
error = git_vector_insert(&idx->objects, entry);
|
361
|
-
if (error <
|
362
|
-
error = git__rethrow(error, "Failed to add entry to list");
|
862
|
+
if (error < 0)
|
363
863
|
goto cleanup;
|
364
|
-
}
|
365
864
|
|
366
865
|
for (i = oid.id[0]; i < 256; ++i) {
|
367
866
|
idx->fanout[i]++;
|