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,12 +1,12 @@
|
|
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
8
|
#include "common.h"
|
9
|
-
#include
|
9
|
+
#include <zlib.h>
|
10
10
|
#include "git2/object.h"
|
11
11
|
#include "git2/oid.h"
|
12
12
|
#include "fileops.h"
|
@@ -26,7 +26,6 @@ typedef struct { /* object header data */
|
|
26
26
|
typedef struct {
|
27
27
|
git_odb_stream stream;
|
28
28
|
git_filebuf fbuf;
|
29
|
-
int finished;
|
30
29
|
} loose_writestream;
|
31
30
|
|
32
31
|
typedef struct loose_backend {
|
@@ -51,41 +50,38 @@ typedef struct {
|
|
51
50
|
} loose_locate_object_state;
|
52
51
|
|
53
52
|
|
54
|
-
|
55
53
|
/***********************************************************
|
56
54
|
*
|
57
55
|
* MISCELANEOUS HELPER FUNCTIONS
|
58
56
|
*
|
59
57
|
***********************************************************/
|
60
58
|
|
61
|
-
static
|
59
|
+
static int object_file_name(git_buf *name, const char *dir, const git_oid *id)
|
62
60
|
{
|
63
|
-
|
61
|
+
git_buf_sets(name, dir);
|
64
62
|
|
65
|
-
/*
|
66
|
-
if (
|
67
|
-
return
|
63
|
+
/* expand length for 40 hex sha1 chars + 2 * '/' + '\0' */
|
64
|
+
if (git_buf_grow(name, git_buf_len(name) + GIT_OID_HEXSZ + 3) < 0)
|
65
|
+
return -1;
|
68
66
|
|
69
|
-
|
70
|
-
strcpy(name, dir);
|
71
|
-
if (name[len-1] != '/')
|
72
|
-
name[len++] = '/';
|
67
|
+
git_path_to_dir(name);
|
73
68
|
|
74
69
|
/* loose object filename: aa/aaa... (41 bytes) */
|
75
|
-
git_oid_pathfmt(
|
76
|
-
name
|
70
|
+
git_oid_pathfmt(name->ptr + git_buf_len(name), id);
|
71
|
+
name->size += GIT_OID_HEXSZ + 1;
|
72
|
+
name->ptr[name->size] = '\0';
|
77
73
|
|
78
74
|
return 0;
|
79
75
|
}
|
80
76
|
|
81
77
|
|
82
|
-
static size_t get_binary_object_header(obj_hdr *hdr,
|
78
|
+
static size_t get_binary_object_header(obj_hdr *hdr, git_buf *obj)
|
83
79
|
{
|
84
80
|
unsigned char c;
|
85
|
-
unsigned char *data = obj->
|
81
|
+
unsigned char *data = (unsigned char *)obj->ptr;
|
86
82
|
size_t shift, size, used = 0;
|
87
83
|
|
88
|
-
if (obj
|
84
|
+
if (git_buf_len(obj) == 0)
|
89
85
|
return 0;
|
90
86
|
|
91
87
|
c = data[used++];
|
@@ -94,7 +90,7 @@ static size_t get_binary_object_header(obj_hdr *hdr, git_fbuffer *obj)
|
|
94
90
|
size = c & 15;
|
95
91
|
shift = 4;
|
96
92
|
while (c & 0x80) {
|
97
|
-
if (obj
|
93
|
+
if (git_buf_len(obj) <= used)
|
98
94
|
return 0;
|
99
95
|
if (sizeof(size_t) * 8 <= shift)
|
100
96
|
return 0;
|
@@ -181,12 +177,12 @@ static void set_stream_output(z_stream *s, void *out, size_t len)
|
|
181
177
|
}
|
182
178
|
|
183
179
|
|
184
|
-
static int start_inflate(z_stream *s,
|
180
|
+
static int start_inflate(z_stream *s, git_buf *obj, void *out, size_t len)
|
185
181
|
{
|
186
182
|
int status;
|
187
183
|
|
188
184
|
init_stream(s, out, len);
|
189
|
-
set_stream_input(s, obj->
|
185
|
+
set_stream_input(s, obj->ptr, git_buf_len(obj));
|
190
186
|
|
191
187
|
if ((status = inflateInit(s)) < Z_OK)
|
192
188
|
return status;
|
@@ -203,10 +199,12 @@ static int finish_inflate(z_stream *s)
|
|
203
199
|
|
204
200
|
inflateEnd(s);
|
205
201
|
|
206
|
-
if ((status != Z_STREAM_END) || (s->avail_in != 0))
|
207
|
-
|
202
|
+
if ((status != Z_STREAM_END) || (s->avail_in != 0)) {
|
203
|
+
giterr_set(GITERR_ZLIB, "Failed to finish ZLib inflation. Stream aborted prematurely");
|
204
|
+
return -1;
|
205
|
+
}
|
208
206
|
|
209
|
-
return
|
207
|
+
return 0;
|
210
208
|
}
|
211
209
|
|
212
210
|
static int is_zlib_compressed_data(unsigned char *data)
|
@@ -230,21 +228,24 @@ static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen)
|
|
230
228
|
zs.next_in = in;
|
231
229
|
zs.avail_in = (uInt)inlen;
|
232
230
|
|
233
|
-
if (inflateInit(&zs) < Z_OK)
|
234
|
-
|
231
|
+
if (inflateInit(&zs) < Z_OK) {
|
232
|
+
giterr_set(GITERR_ZLIB, "Failed to inflate buffer");
|
233
|
+
return -1;
|
234
|
+
}
|
235
235
|
|
236
236
|
while (status == Z_OK)
|
237
237
|
status = inflate(&zs, Z_FINISH);
|
238
238
|
|
239
239
|
inflateEnd(&zs);
|
240
240
|
|
241
|
-
if (
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
return
|
241
|
+
if (status != Z_STREAM_END /* || zs.avail_in != 0 */ ||
|
242
|
+
zs.total_out != outlen)
|
243
|
+
{
|
244
|
+
giterr_set(GITERR_ZLIB, "Failed to inflate buffer. Stream aborted prematurely");
|
245
|
+
return -1;
|
246
|
+
}
|
246
247
|
|
247
|
-
return
|
248
|
+
return 0;
|
248
249
|
}
|
249
250
|
|
250
251
|
static void *inflate_tail(z_stream *s, void *hb, size_t used, obj_hdr *hdr)
|
@@ -291,7 +292,7 @@ static void *inflate_tail(z_stream *s, void *hb, size_t used, obj_hdr *hdr)
|
|
291
292
|
* of loose object data into packs. This format is no longer used, but
|
292
293
|
* we must still read it.
|
293
294
|
*/
|
294
|
-
static int inflate_packlike_loose_disk_obj(git_rawobj *out,
|
295
|
+
static int inflate_packlike_loose_disk_obj(git_rawobj *out, git_buf *obj)
|
295
296
|
{
|
296
297
|
unsigned char *in, *buf;
|
297
298
|
obj_hdr hdr;
|
@@ -301,24 +302,23 @@ static int inflate_packlike_loose_disk_obj(git_rawobj *out, git_fbuffer *obj)
|
|
301
302
|
* read the object header, which is an (uncompressed)
|
302
303
|
* binary encoding of the object type and size.
|
303
304
|
*/
|
304
|
-
if ((used = get_binary_object_header(&hdr, obj)) == 0
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
305
|
+
if ((used = get_binary_object_header(&hdr, obj)) == 0 ||
|
306
|
+
!git_object_typeisloose(hdr.type)) {
|
307
|
+
giterr_set(GITERR_ODB, "Failed to inflate loose object.");
|
308
|
+
return -1;
|
309
|
+
}
|
309
310
|
|
310
311
|
/*
|
311
312
|
* allocate a buffer and inflate the data into it
|
312
313
|
*/
|
313
314
|
buf = git__malloc(hdr.size + 1);
|
314
|
-
|
315
|
-
return GIT_ENOMEM;
|
315
|
+
GITERR_CHECK_ALLOC(buf);
|
316
316
|
|
317
|
-
in = ((unsigned char *)obj->
|
318
|
-
len = obj->
|
319
|
-
if (inflate_buffer(in, len, buf, hdr.size)) {
|
317
|
+
in = ((unsigned char *)obj->ptr) + used;
|
318
|
+
len = obj->size - used;
|
319
|
+
if (inflate_buffer(in, len, buf, hdr.size) < 0) {
|
320
320
|
git__free(buf);
|
321
|
-
return
|
321
|
+
return -1;
|
322
322
|
}
|
323
323
|
buf[hdr.size] = '\0';
|
324
324
|
|
@@ -326,10 +326,10 @@ static int inflate_packlike_loose_disk_obj(git_rawobj *out, git_fbuffer *obj)
|
|
326
326
|
out->len = hdr.size;
|
327
327
|
out->type = hdr.type;
|
328
328
|
|
329
|
-
return
|
329
|
+
return 0;
|
330
330
|
}
|
331
331
|
|
332
|
-
static int inflate_disk_obj(git_rawobj *out,
|
332
|
+
static int inflate_disk_obj(git_rawobj *out, git_buf *obj)
|
333
333
|
{
|
334
334
|
unsigned char head[64], *buf;
|
335
335
|
z_stream zs;
|
@@ -339,35 +339,34 @@ static int inflate_disk_obj(git_rawobj *out, git_fbuffer *obj)
|
|
339
339
|
/*
|
340
340
|
* check for a pack-like loose object
|
341
341
|
*/
|
342
|
-
if (!is_zlib_compressed_data(obj->
|
342
|
+
if (!is_zlib_compressed_data((unsigned char *)obj->ptr))
|
343
343
|
return inflate_packlike_loose_disk_obj(out, obj);
|
344
344
|
|
345
345
|
/*
|
346
346
|
* inflate the initial part of the io buffer in order
|
347
347
|
* to parse the object header (type and size).
|
348
348
|
*/
|
349
|
-
if (start_inflate(&zs, obj, head, sizeof(head)) < Z_OK
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
return git__throw(GIT_ERROR, "Failed to inflate disk object. Wrong object type");
|
349
|
+
if (start_inflate(&zs, obj, head, sizeof(head)) < Z_OK ||
|
350
|
+
(used = get_object_header(&hdr, head)) == 0 ||
|
351
|
+
!git_object_typeisloose(hdr.type))
|
352
|
+
{
|
353
|
+
giterr_set(GITERR_ODB, "Failed to inflate disk object.");
|
354
|
+
return -1;
|
355
|
+
}
|
357
356
|
|
358
357
|
/*
|
359
358
|
* allocate a buffer and inflate the object data into it
|
360
359
|
* (including the initial sequence in the head buffer).
|
361
360
|
*/
|
362
361
|
if ((buf = inflate_tail(&zs, head, used, &hdr)) == NULL)
|
363
|
-
return
|
362
|
+
return -1;
|
364
363
|
buf[hdr.size] = '\0';
|
365
364
|
|
366
365
|
out->data = buf;
|
367
366
|
out->len = hdr.size;
|
368
367
|
out->type = hdr.type;
|
369
368
|
|
370
|
-
return
|
369
|
+
return 0;
|
371
370
|
}
|
372
371
|
|
373
372
|
|
@@ -384,29 +383,31 @@ static int inflate_disk_obj(git_rawobj *out, git_fbuffer *obj)
|
|
384
383
|
*
|
385
384
|
***********************************************************/
|
386
385
|
|
387
|
-
static int read_loose(git_rawobj *out,
|
386
|
+
static int read_loose(git_rawobj *out, git_buf *loc)
|
388
387
|
{
|
389
388
|
int error;
|
390
|
-
|
389
|
+
git_buf obj = GIT_BUF_INIT;
|
391
390
|
|
392
391
|
assert(out && loc);
|
393
392
|
|
393
|
+
if (git_buf_oom(loc))
|
394
|
+
return -1;
|
395
|
+
|
394
396
|
out->data = NULL;
|
395
397
|
out->len = 0;
|
396
398
|
out->type = GIT_OBJ_BAD;
|
397
399
|
|
398
|
-
if (git_futils_readbuffer(&obj, loc)
|
399
|
-
|
400
|
+
if (!(error = git_futils_readbuffer(&obj, loc->ptr)))
|
401
|
+
error = inflate_disk_obj(out, &obj);
|
400
402
|
|
401
|
-
|
402
|
-
git_futils_freebuffer(&obj);
|
403
|
+
git_buf_free(&obj);
|
403
404
|
|
404
|
-
return error
|
405
|
+
return error;
|
405
406
|
}
|
406
407
|
|
407
|
-
static int read_header_loose(git_rawobj *out,
|
408
|
+
static int read_header_loose(git_rawobj *out, git_buf *loc)
|
408
409
|
{
|
409
|
-
int error =
|
410
|
+
int error = 0, z_return = Z_ERRNO, read_bytes;
|
410
411
|
git_file fd;
|
411
412
|
z_stream zs;
|
412
413
|
obj_hdr header_obj;
|
@@ -414,133 +415,151 @@ static int read_header_loose(git_rawobj *out, const char *loc)
|
|
414
415
|
|
415
416
|
assert(out && loc);
|
416
417
|
|
418
|
+
if (git_buf_oom(loc))
|
419
|
+
return -1;
|
420
|
+
|
417
421
|
out->data = NULL;
|
418
422
|
|
419
|
-
if ((fd =
|
420
|
-
return
|
423
|
+
if ((fd = git_futils_open_ro(loc->ptr)) < 0)
|
424
|
+
return fd;
|
421
425
|
|
422
426
|
init_stream(&zs, inflated_buffer, sizeof(inflated_buffer));
|
423
427
|
|
424
|
-
|
425
|
-
error = GIT_EZLIB;
|
426
|
-
goto cleanup;
|
427
|
-
}
|
428
|
+
z_return = inflateInit(&zs);
|
428
429
|
|
429
|
-
|
430
|
-
if ((read_bytes =
|
430
|
+
while (z_return == Z_OK) {
|
431
|
+
if ((read_bytes = p_read(fd, raw_buffer, sizeof(raw_buffer))) > 0) {
|
431
432
|
set_stream_input(&zs, raw_buffer, read_bytes);
|
432
433
|
z_return = inflate(&zs, 0);
|
433
|
-
} else
|
434
|
+
} else
|
434
435
|
z_return = Z_STREAM_END;
|
435
|
-
|
436
|
-
}
|
437
|
-
} while (z_return == Z_OK);
|
436
|
+
}
|
438
437
|
|
439
438
|
if ((z_return != Z_STREAM_END && z_return != Z_BUF_ERROR)
|
440
439
|
|| get_object_header(&header_obj, inflated_buffer) == 0
|
441
|
-
|| git_object_typeisloose(header_obj.type) == 0)
|
442
|
-
|
443
|
-
|
440
|
+
|| git_object_typeisloose(header_obj.type) == 0)
|
441
|
+
{
|
442
|
+
giterr_set(GITERR_ZLIB, "Failed to read loose object header");
|
443
|
+
error = -1;
|
444
|
+
} else {
|
445
|
+
out->len = header_obj.size;
|
446
|
+
out->type = header_obj.type;
|
444
447
|
}
|
445
448
|
|
446
|
-
out->len = header_obj.size;
|
447
|
-
out->type = header_obj.type;
|
448
|
-
|
449
|
-
cleanup:
|
450
449
|
finish_inflate(&zs);
|
451
450
|
p_close(fd);
|
452
451
|
|
453
|
-
|
454
|
-
return git__throw(error, "Failed to read loose object header. Header is corrupted");
|
455
|
-
|
456
|
-
return GIT_SUCCESS;
|
452
|
+
return error;
|
457
453
|
}
|
458
454
|
|
459
|
-
static int locate_object(
|
455
|
+
static int locate_object(
|
456
|
+
git_buf *object_location,
|
457
|
+
loose_backend *backend,
|
458
|
+
const git_oid *oid)
|
460
459
|
{
|
461
|
-
object_file_name(object_location,
|
462
|
-
|
460
|
+
int error = object_file_name(object_location, backend->objects_dir, oid);
|
461
|
+
|
462
|
+
if (!error && !git_path_exists(object_location->ptr))
|
463
|
+
return GIT_ENOTFOUND;
|
464
|
+
|
465
|
+
return error;
|
463
466
|
}
|
464
467
|
|
465
468
|
/* Explore an entry of a directory and see if it matches a short oid */
|
466
|
-
static int fn_locate_object_short_oid(void *state,
|
469
|
+
static int fn_locate_object_short_oid(void *state, git_buf *pathbuf) {
|
467
470
|
loose_locate_object_state *sstate = (loose_locate_object_state *)state;
|
468
471
|
|
469
|
-
|
470
|
-
if (pathbuf_len - sstate->dir_len != GIT_OID_HEXSZ - 2) {
|
472
|
+
if (git_buf_len(pathbuf) - sstate->dir_len != GIT_OID_HEXSZ - 2) {
|
471
473
|
/* Entry cannot be an object. Continue to next entry */
|
472
|
-
return
|
474
|
+
return 0;
|
473
475
|
}
|
474
476
|
|
475
|
-
if (
|
477
|
+
if (git_path_isdir(pathbuf->ptr) == false) {
|
476
478
|
/* We are already in the directory matching the 2 first hex characters,
|
477
479
|
* compare the first ncmp characters of the oids */
|
478
480
|
if (!memcmp(sstate->short_oid + 2,
|
479
|
-
(unsigned char *)pathbuf + sstate->dir_len,
|
481
|
+
(unsigned char *)pathbuf->ptr + sstate->dir_len,
|
480
482
|
sstate->short_oid_len - 2)) {
|
481
483
|
|
482
484
|
if (!sstate->found) {
|
483
485
|
sstate->res_oid[0] = sstate->short_oid[0];
|
484
486
|
sstate->res_oid[1] = sstate->short_oid[1];
|
485
|
-
memcpy(sstate->res_oid+2, pathbuf+sstate->dir_len, GIT_OID_HEXSZ-2);
|
487
|
+
memcpy(sstate->res_oid+2, pathbuf->ptr+sstate->dir_len, GIT_OID_HEXSZ-2);
|
486
488
|
}
|
487
489
|
sstate->found++;
|
488
490
|
}
|
489
491
|
}
|
492
|
+
|
490
493
|
if (sstate->found > 1)
|
491
|
-
return
|
494
|
+
return git_odb__error_ambiguous("multiple matches in loose objects");
|
492
495
|
|
493
|
-
return
|
496
|
+
return 0;
|
494
497
|
}
|
495
498
|
|
496
499
|
/* Locate an object matching a given short oid */
|
497
|
-
static int locate_object_short_oid(
|
500
|
+
static int locate_object_short_oid(
|
501
|
+
git_buf *object_location,
|
502
|
+
git_oid *res_oid,
|
503
|
+
loose_backend *backend,
|
504
|
+
const git_oid *short_oid,
|
505
|
+
unsigned int len)
|
498
506
|
{
|
499
507
|
char *objects_dir = backend->objects_dir;
|
500
508
|
size_t dir_len = strlen(objects_dir);
|
501
509
|
loose_locate_object_state state;
|
502
510
|
int error;
|
503
511
|
|
504
|
-
|
505
|
-
|
512
|
+
/* prealloc memory for OBJ_DIR/xx/ */
|
513
|
+
if (git_buf_grow(object_location, dir_len + 5) < 0)
|
514
|
+
return -1;
|
506
515
|
|
507
|
-
|
516
|
+
git_buf_sets(object_location, objects_dir);
|
517
|
+
git_path_to_dir(object_location);
|
508
518
|
|
509
|
-
/*
|
510
|
-
|
511
|
-
object_location[dir_len++] = '/';
|
519
|
+
/* save adjusted position at end of dir so it can be restored later */
|
520
|
+
dir_len = git_buf_len(object_location);
|
512
521
|
|
513
522
|
/* Convert raw oid to hex formatted oid */
|
514
523
|
git_oid_fmt((char *)state.short_oid, short_oid);
|
524
|
+
|
515
525
|
/* Explore OBJ_DIR/xx/ where xx is the beginning of hex formatted short oid */
|
516
|
-
|
526
|
+
if (git_buf_printf(object_location, "%.2s/", state.short_oid) < 0)
|
527
|
+
return -1;
|
517
528
|
|
518
529
|
/* Check that directory exists */
|
519
|
-
if (
|
520
|
-
return
|
530
|
+
if (git_path_isdir(object_location->ptr) == false)
|
531
|
+
return git_odb__error_notfound("no matching loose object for prefix", short_oid);
|
521
532
|
|
522
|
-
state.dir_len =
|
533
|
+
state.dir_len = git_buf_len(object_location);
|
523
534
|
state.short_oid_len = len;
|
524
535
|
state.found = 0;
|
536
|
+
|
525
537
|
/* Explore directory to find a unique object matching short_oid */
|
526
|
-
error =
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
538
|
+
error = git_path_direach(
|
539
|
+
object_location, fn_locate_object_short_oid, &state);
|
540
|
+
if (error)
|
541
|
+
return error;
|
542
|
+
|
543
|
+
if (!state.found)
|
544
|
+
return git_odb__error_notfound("no matching loose object for prefix", short_oid);
|
533
545
|
|
534
546
|
/* Convert obtained hex formatted oid to raw */
|
535
547
|
error = git_oid_fromstr(res_oid, (char *)state.res_oid);
|
536
|
-
if (error)
|
537
|
-
return
|
538
|
-
}
|
548
|
+
if (error)
|
549
|
+
return error;
|
539
550
|
|
540
551
|
/* Update the location according to the oid obtained */
|
541
|
-
git_oid_pathfmt(object_location+dir_len, res_oid);
|
542
552
|
|
543
|
-
|
553
|
+
git_buf_truncate(object_location, dir_len);
|
554
|
+
if (git_buf_grow(object_location, dir_len + GIT_OID_HEXSZ + 2) < 0)
|
555
|
+
return -1;
|
556
|
+
|
557
|
+
git_oid_pathfmt(object_location->ptr + dir_len, res_oid);
|
558
|
+
|
559
|
+
object_location->size += GIT_OID_HEXSZ + 1;
|
560
|
+
object_location->ptr[object_location->size] = '\0';
|
561
|
+
|
562
|
+
return 0;
|
544
563
|
}
|
545
564
|
|
546
565
|
|
@@ -561,7 +580,7 @@ static int locate_object_short_oid(char *object_location, git_oid *res_oid, loos
|
|
561
580
|
|
562
581
|
static int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
|
563
582
|
{
|
564
|
-
|
583
|
+
git_buf object_path = GIT_BUF_INIT;
|
565
584
|
git_rawobj raw;
|
566
585
|
int error;
|
567
586
|
|
@@ -570,36 +589,37 @@ static int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_
|
|
570
589
|
raw.len = 0;
|
571
590
|
raw.type = GIT_OBJ_BAD;
|
572
591
|
|
573
|
-
if (locate_object(object_path, (loose_backend *)backend, oid) < 0)
|
574
|
-
|
592
|
+
if (locate_object(&object_path, (loose_backend *)backend, oid) < 0)
|
593
|
+
error = git_odb__error_notfound("no matching loose object", oid);
|
594
|
+
else if ((error = read_header_loose(&raw, &object_path)) == 0) {
|
595
|
+
*len_p = raw.len;
|
596
|
+
*type_p = raw.type;
|
597
|
+
}
|
575
598
|
|
576
|
-
|
577
|
-
return error;
|
599
|
+
git_buf_free(&object_path);
|
578
600
|
|
579
|
-
|
580
|
-
*type_p = raw.type;
|
581
|
-
return GIT_SUCCESS;
|
601
|
+
return error;
|
582
602
|
}
|
583
603
|
|
584
604
|
static int loose_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
|
585
605
|
{
|
586
|
-
|
606
|
+
git_buf object_path = GIT_BUF_INIT;
|
587
607
|
git_rawobj raw;
|
588
|
-
int error;
|
608
|
+
int error = 0;
|
589
609
|
|
590
610
|
assert(backend && oid);
|
591
611
|
|
592
|
-
if (locate_object(object_path, (loose_backend *)backend, oid) < 0)
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
612
|
+
if (locate_object(&object_path, (loose_backend *)backend, oid) < 0)
|
613
|
+
error = git_odb__error_notfound("no matching loose object", oid);
|
614
|
+
else if ((error = read_loose(&raw, &object_path)) == 0) {
|
615
|
+
*buffer_p = raw.data;
|
616
|
+
*len_p = raw.len;
|
617
|
+
*type_p = raw.type;
|
618
|
+
}
|
597
619
|
|
598
|
-
|
599
|
-
*len_p = raw.len;
|
600
|
-
*type_p = raw.type;
|
620
|
+
git_buf_free(&object_path);
|
601
621
|
|
602
|
-
return
|
622
|
+
return error;
|
603
623
|
}
|
604
624
|
|
605
625
|
static int loose_backend__read_prefix(
|
@@ -611,77 +631,76 @@ static int loose_backend__read_prefix(
|
|
611
631
|
const git_oid *short_oid,
|
612
632
|
unsigned int len)
|
613
633
|
{
|
634
|
+
int error = 0;
|
635
|
+
|
614
636
|
if (len < GIT_OID_MINPREFIXLEN)
|
615
|
-
|
637
|
+
error = git_odb__error_ambiguous("prefix length too short");
|
616
638
|
|
617
|
-
if (len >= GIT_OID_HEXSZ) {
|
639
|
+
else if (len >= GIT_OID_HEXSZ) {
|
618
640
|
/* We can fall back to regular read method */
|
619
|
-
|
620
|
-
if (error
|
641
|
+
error = loose_backend__read(buffer_p, len_p, type_p, backend, short_oid);
|
642
|
+
if (!error)
|
621
643
|
git_oid_cpy(out_oid, short_oid);
|
622
|
-
|
623
|
-
return error;
|
624
644
|
} else {
|
625
|
-
|
645
|
+
git_buf object_path = GIT_BUF_INIT;
|
626
646
|
git_rawobj raw;
|
627
|
-
int error;
|
628
647
|
|
629
648
|
assert(backend && short_oid);
|
630
649
|
|
631
|
-
if ((error = locate_object_short_oid(object_path, out_oid,
|
632
|
-
|
650
|
+
if ((error = locate_object_short_oid(&object_path, out_oid,
|
651
|
+
(loose_backend *)backend, short_oid, len)) == 0 &&
|
652
|
+
(error = read_loose(&raw, &object_path)) == 0)
|
653
|
+
{
|
654
|
+
*buffer_p = raw.data;
|
655
|
+
*len_p = raw.len;
|
656
|
+
*type_p = raw.type;
|
633
657
|
}
|
634
658
|
|
635
|
-
|
636
|
-
return git__rethrow(error, "Failed to read loose backend");
|
637
|
-
|
638
|
-
*buffer_p = raw.data;
|
639
|
-
*len_p = raw.len;
|
640
|
-
*type_p = raw.type;
|
659
|
+
git_buf_free(&object_path);
|
641
660
|
}
|
642
661
|
|
643
|
-
return
|
662
|
+
return error;
|
644
663
|
}
|
645
664
|
|
646
665
|
static int loose_backend__exists(git_odb_backend *backend, const git_oid *oid)
|
647
666
|
{
|
648
|
-
|
667
|
+
git_buf object_path = GIT_BUF_INIT;
|
668
|
+
int error;
|
649
669
|
|
650
670
|
assert(backend && oid);
|
651
671
|
|
652
|
-
|
672
|
+
error = locate_object(&object_path, (loose_backend *)backend, oid);
|
673
|
+
|
674
|
+
git_buf_free(&object_path);
|
675
|
+
|
676
|
+
return !error;
|
653
677
|
}
|
654
678
|
|
655
679
|
static int loose_backend__stream_fwrite(git_oid *oid, git_odb_stream *_stream)
|
656
680
|
{
|
657
681
|
loose_writestream *stream = (loose_writestream *)_stream;
|
658
682
|
loose_backend *backend = (loose_backend *)_stream->backend;
|
683
|
+
git_buf final_path = GIT_BUF_INIT;
|
684
|
+
int error = 0;
|
659
685
|
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
return git__rethrow(error, "Failed to write loose backend");
|
665
|
-
|
666
|
-
if (object_file_name(final_path, sizeof(final_path), backend->objects_dir, oid))
|
667
|
-
return GIT_ENOMEM;
|
668
|
-
|
669
|
-
if ((error = git_futils_mkpath2file(final_path, GIT_OBJECT_DIR_MODE)) < GIT_SUCCESS)
|
670
|
-
return git__rethrow(error, "Failed to write loose backend");
|
671
|
-
|
672
|
-
stream->finished = 1;
|
673
|
-
|
686
|
+
if (git_filebuf_hash(oid, &stream->fbuf) < 0 ||
|
687
|
+
object_file_name(&final_path, backend->objects_dir, oid) < 0 ||
|
688
|
+
git_futils_mkpath2file(final_path.ptr, GIT_OBJECT_DIR_MODE) < 0)
|
689
|
+
error = -1;
|
674
690
|
/*
|
675
691
|
* Don't try to add an existing object to the repository. This
|
676
692
|
* is what git does and allows us to sidestep the fact that
|
677
693
|
* we're not allowed to overwrite a read-only file on Windows.
|
678
694
|
*/
|
679
|
-
if (
|
695
|
+
else if (git_path_exists(final_path.ptr) == true)
|
680
696
|
git_filebuf_cleanup(&stream->fbuf);
|
681
|
-
|
682
|
-
|
697
|
+
else
|
698
|
+
error = git_filebuf_commit_at(
|
699
|
+
&stream->fbuf, final_path.ptr, GIT_OBJECT_FILE_MODE);
|
700
|
+
|
701
|
+
git_buf_free(&final_path);
|
683
702
|
|
684
|
-
return
|
703
|
+
return error;
|
685
704
|
}
|
686
705
|
|
687
706
|
static int loose_backend__stream_write(git_odb_stream *_stream, const char *data, size_t len)
|
@@ -694,9 +713,7 @@ static void loose_backend__stream_free(git_odb_stream *_stream)
|
|
694
713
|
{
|
695
714
|
loose_writestream *stream = (loose_writestream *)_stream;
|
696
715
|
|
697
|
-
|
698
|
-
git_filebuf_cleanup(&stream->fbuf);
|
699
|
-
|
716
|
+
git_filebuf_cleanup(&stream->fbuf);
|
700
717
|
git__free(stream);
|
701
718
|
}
|
702
719
|
|
@@ -706,21 +723,18 @@ static int format_object_header(char *hdr, size_t n, size_t obj_len, git_otype o
|
|
706
723
|
int len = snprintf(hdr, n, "%s %"PRIuZ, type_str, obj_len);
|
707
724
|
|
708
725
|
assert(len > 0); /* otherwise snprintf() is broken */
|
709
|
-
assert(((size_t)
|
726
|
+
assert(((size_t)len) < n); /* otherwise the caller is broken! */
|
710
727
|
|
711
|
-
if (len < 0 || ((size_t) len) >= n)
|
712
|
-
return git__throw(GIT_ERROR, "Failed to format object header. Length is out of bounds");
|
713
728
|
return len+1;
|
714
729
|
}
|
715
730
|
|
716
731
|
static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend, size_t length, git_otype type)
|
717
732
|
{
|
718
733
|
loose_backend *backend;
|
719
|
-
loose_writestream *stream;
|
720
|
-
|
721
|
-
|
734
|
+
loose_writestream *stream = NULL;
|
735
|
+
char hdr[64];
|
736
|
+
git_buf tmp_path = GIT_BUF_INIT;
|
722
737
|
int hdrlen;
|
723
|
-
int error;
|
724
738
|
|
725
739
|
assert(_backend);
|
726
740
|
|
@@ -728,12 +742,9 @@ static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_
|
|
728
742
|
*stream_out = NULL;
|
729
743
|
|
730
744
|
hdrlen = format_object_header(hdr, sizeof(hdr), length, type);
|
731
|
-
if (hdrlen < GIT_SUCCESS)
|
732
|
-
return git__throw(GIT_EOBJCORRUPTED, "Failed to create loose backend stream. Object is corrupted");
|
733
745
|
|
734
746
|
stream = git__calloc(1, sizeof(loose_writestream));
|
735
|
-
|
736
|
-
return GIT_ENOMEM;
|
747
|
+
GITERR_CHECK_ALLOC(stream);
|
737
748
|
|
738
749
|
stream->stream.backend = _backend;
|
739
750
|
stream->stream.read = NULL; /* read only */
|
@@ -742,69 +753,59 @@ static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_
|
|
742
753
|
stream->stream.free = &loose_backend__stream_free;
|
743
754
|
stream->stream.mode = GIT_STREAM_WRONLY;
|
744
755
|
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
(
|
751
|
-
|
752
|
-
if (error < GIT_SUCCESS) {
|
753
|
-
git__free(stream);
|
754
|
-
return git__rethrow(error, "Failed to create loose backend stream");
|
755
|
-
}
|
756
|
-
|
757
|
-
error = stream->stream.write((git_odb_stream *)stream, hdr, hdrlen);
|
758
|
-
if (error < GIT_SUCCESS) {
|
756
|
+
if (git_buf_joinpath(&tmp_path, backend->objects_dir, "tmp_object") < 0 ||
|
757
|
+
git_filebuf_open(&stream->fbuf, tmp_path.ptr,
|
758
|
+
GIT_FILEBUF_HASH_CONTENTS |
|
759
|
+
GIT_FILEBUF_TEMPORARY |
|
760
|
+
(backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT)) < 0 ||
|
761
|
+
stream->stream.write((git_odb_stream *)stream, hdr, hdrlen) < 0)
|
762
|
+
{
|
759
763
|
git_filebuf_cleanup(&stream->fbuf);
|
760
764
|
git__free(stream);
|
761
|
-
|
765
|
+
stream = NULL;
|
762
766
|
}
|
763
|
-
|
767
|
+
git_buf_free(&tmp_path);
|
764
768
|
*stream_out = (git_odb_stream *)stream;
|
765
|
-
|
769
|
+
|
770
|
+
return !stream ? -1 : 0;
|
766
771
|
}
|
767
772
|
|
768
773
|
static int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const void *data, size_t len, git_otype type)
|
769
774
|
{
|
770
|
-
int error, header_len;
|
771
|
-
|
775
|
+
int error = 0, header_len;
|
776
|
+
git_buf final_path = GIT_BUF_INIT;
|
777
|
+
char header[64];
|
772
778
|
git_filebuf fbuf = GIT_FILEBUF_INIT;
|
773
779
|
loose_backend *backend;
|
774
780
|
|
775
781
|
backend = (loose_backend *)_backend;
|
776
782
|
|
777
783
|
/* prepare the header for the file */
|
784
|
+
header_len = format_object_header(header, sizeof(header), len, type);
|
785
|
+
|
786
|
+
if (git_buf_joinpath(&final_path, backend->objects_dir, "tmp_object") < 0 ||
|
787
|
+
git_filebuf_open(&fbuf, final_path.ptr,
|
788
|
+
GIT_FILEBUF_HASH_CONTENTS |
|
789
|
+
GIT_FILEBUF_TEMPORARY |
|
790
|
+
(backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT)) < 0)
|
778
791
|
{
|
779
|
-
|
780
|
-
|
781
|
-
return GIT_EOBJCORRUPTED;
|
792
|
+
error = -1;
|
793
|
+
goto cleanup;
|
782
794
|
}
|
783
795
|
|
784
|
-
git_path_join(final_path, backend->objects_dir, "tmp_object");
|
785
|
-
|
786
|
-
error = git_filebuf_open(&fbuf, final_path,
|
787
|
-
GIT_FILEBUF_HASH_CONTENTS |
|
788
|
-
GIT_FILEBUF_TEMPORARY |
|
789
|
-
(backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT));
|
790
|
-
|
791
|
-
if (error < GIT_SUCCESS)
|
792
|
-
return error;
|
793
|
-
|
794
796
|
git_filebuf_write(&fbuf, header, header_len);
|
795
797
|
git_filebuf_write(&fbuf, data, len);
|
796
798
|
git_filebuf_hash(oid, &fbuf);
|
797
799
|
|
798
|
-
if (
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
goto cleanup;
|
803
|
-
|
804
|
-
return git_filebuf_commit_at(&fbuf, final_path, GIT_OBJECT_FILE_MODE);
|
800
|
+
if (object_file_name(&final_path, backend->objects_dir, oid) < 0 ||
|
801
|
+
git_futils_mkpath2file(final_path.ptr, GIT_OBJECT_DIR_MODE) < 0 ||
|
802
|
+
git_filebuf_commit_at(&fbuf, final_path.ptr, GIT_OBJECT_FILE_MODE) < 0)
|
803
|
+
error = -1;
|
805
804
|
|
806
805
|
cleanup:
|
807
|
-
|
806
|
+
if (error < 0)
|
807
|
+
git_filebuf_cleanup(&fbuf);
|
808
|
+
git_buf_free(&final_path);
|
808
809
|
return error;
|
809
810
|
}
|
810
811
|
|
@@ -827,14 +828,10 @@ int git_odb_backend_loose(
|
|
827
828
|
loose_backend *backend;
|
828
829
|
|
829
830
|
backend = git__calloc(1, sizeof(loose_backend));
|
830
|
-
|
831
|
-
return GIT_ENOMEM;
|
831
|
+
GITERR_CHECK_ALLOC(backend);
|
832
832
|
|
833
833
|
backend->objects_dir = git__strdup(objects_dir);
|
834
|
-
|
835
|
-
git__free(backend);
|
836
|
-
return GIT_ENOMEM;
|
837
|
-
}
|
834
|
+
GITERR_CHECK_ALLOC(backend->objects_dir);
|
838
835
|
|
839
836
|
if (compression_level < 0)
|
840
837
|
compression_level = Z_BEST_SPEED;
|
@@ -851,5 +848,5 @@ int git_odb_backend_loose(
|
|
851
848
|
backend->parent.free = &loose_backend__free;
|
852
849
|
|
853
850
|
*backend_out = (git_odb_backend *)backend;
|
854
|
-
return
|
851
|
+
return 0;
|
855
852
|
}
|