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,5 +1,5 @@
|
|
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.
|
@@ -10,6 +10,7 @@
|
|
10
10
|
#include "common.h"
|
11
11
|
#include "repository.h"
|
12
12
|
#include "index.h"
|
13
|
+
#include "tree.h"
|
13
14
|
#include "tree-cache.h"
|
14
15
|
#include "hash.h"
|
15
16
|
#include "git2/odb.h"
|
@@ -87,6 +88,8 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
87
88
|
static int is_index_extended(git_index *index);
|
88
89
|
static int write_index(git_index *index, git_filebuf *file);
|
89
90
|
|
91
|
+
static void index_entry_free(git_index_entry *entry);
|
92
|
+
|
90
93
|
static int index_srch(const void *key, const void *array_member)
|
91
94
|
{
|
92
95
|
const git_index_entry *entry = array_member;
|
@@ -132,22 +135,17 @@ int git_index_open(git_index **index_out, const char *index_path)
|
|
132
135
|
|
133
136
|
assert(index_out && index_path);
|
134
137
|
|
135
|
-
index =
|
136
|
-
|
137
|
-
return GIT_ENOMEM;
|
138
|
-
|
139
|
-
memset(index, 0x0, sizeof(git_index));
|
138
|
+
index = git__calloc(1, sizeof(git_index));
|
139
|
+
GITERR_CHECK_ALLOC(index);
|
140
140
|
|
141
141
|
index->index_file_path = git__strdup(index_path);
|
142
|
-
|
143
|
-
git__free(index);
|
144
|
-
return GIT_ENOMEM;
|
145
|
-
}
|
142
|
+
GITERR_CHECK_ALLOC(index->index_file_path);
|
146
143
|
|
147
|
-
git_vector_init(&index->entries, 32, index_cmp)
|
144
|
+
if (git_vector_init(&index->entries, 32, index_cmp) < 0)
|
145
|
+
return -1;
|
148
146
|
|
149
147
|
/* Check if index file is stored on disk already */
|
150
|
-
if (
|
148
|
+
if (git_path_exists(index->index_file_path) == true)
|
151
149
|
index->on_disk = 1;
|
152
150
|
|
153
151
|
*index_out = index;
|
@@ -157,8 +155,17 @@ int git_index_open(git_index **index_out, const char *index_path)
|
|
157
155
|
|
158
156
|
static void index_free(git_index *index)
|
159
157
|
{
|
158
|
+
git_index_entry *e;
|
159
|
+
unsigned int i;
|
160
|
+
|
160
161
|
git_index_clear(index);
|
162
|
+
git_vector_foreach(&index->entries, i, e) {
|
163
|
+
index_entry_free(e);
|
164
|
+
}
|
161
165
|
git_vector_free(&index->entries);
|
166
|
+
git_vector_foreach(&index->unmerged, i, e) {
|
167
|
+
index_entry_free(e);
|
168
|
+
}
|
162
169
|
git_vector_free(&index->unmerged);
|
163
170
|
|
164
171
|
git__free(index->index_file_path);
|
@@ -203,36 +210,35 @@ void git_index_clear(git_index *index)
|
|
203
210
|
|
204
211
|
int git_index_read(git_index *index)
|
205
212
|
{
|
206
|
-
int error
|
207
|
-
|
213
|
+
int error, updated;
|
214
|
+
git_buf buffer = GIT_BUF_INIT;
|
208
215
|
time_t mtime;
|
209
216
|
|
210
217
|
assert(index->index_file_path);
|
211
218
|
|
212
|
-
if (!index->on_disk ||
|
219
|
+
if (!index->on_disk || git_path_exists(index->index_file_path) == false) {
|
213
220
|
git_index_clear(index);
|
214
221
|
index->on_disk = 0;
|
215
|
-
return
|
222
|
+
return 0;
|
216
223
|
}
|
217
224
|
|
218
225
|
/* We don't want to update the mtime if we fail to parse the index */
|
219
226
|
mtime = index->last_modified;
|
220
|
-
error = git_futils_readbuffer_updated(
|
221
|
-
|
222
|
-
|
227
|
+
error = git_futils_readbuffer_updated(
|
228
|
+
&buffer, index->index_file_path, &mtime, &updated);
|
229
|
+
if (error < 0)
|
230
|
+
return error;
|
223
231
|
|
224
232
|
if (updated) {
|
225
233
|
git_index_clear(index);
|
226
|
-
error = parse_index(index, buffer.
|
234
|
+
error = parse_index(index, buffer.ptr, buffer.size);
|
227
235
|
|
228
|
-
if (error
|
236
|
+
if (!error)
|
229
237
|
index->last_modified = mtime;
|
230
238
|
|
231
|
-
|
239
|
+
git_buf_free(&buffer);
|
232
240
|
}
|
233
241
|
|
234
|
-
if (error < GIT_SUCCESS)
|
235
|
-
return git__rethrow(error, "Failed to parse index");
|
236
242
|
return error;
|
237
243
|
}
|
238
244
|
|
@@ -244,23 +250,24 @@ int git_index_write(git_index *index)
|
|
244
250
|
|
245
251
|
git_vector_sort(&index->entries);
|
246
252
|
|
247
|
-
if ((error = git_filebuf_open(
|
248
|
-
|
253
|
+
if ((error = git_filebuf_open(
|
254
|
+
&file, index->index_file_path, GIT_FILEBUF_HASH_CONTENTS)) < 0)
|
255
|
+
return error;
|
249
256
|
|
250
|
-
if ((error = write_index(index, &file)) <
|
257
|
+
if ((error = write_index(index, &file)) < 0) {
|
251
258
|
git_filebuf_cleanup(&file);
|
252
|
-
return
|
259
|
+
return error;
|
253
260
|
}
|
254
261
|
|
255
|
-
if ((error = git_filebuf_commit(&file, GIT_INDEX_FILE_MODE)) <
|
256
|
-
return
|
262
|
+
if ((error = git_filebuf_commit(&file, GIT_INDEX_FILE_MODE)) < 0)
|
263
|
+
return error;
|
257
264
|
|
258
265
|
if (p_stat(index->index_file_path, &indexst) == 0) {
|
259
266
|
index->last_modified = indexst.st_mtime;
|
260
267
|
index->on_disk = 1;
|
261
268
|
}
|
262
269
|
|
263
|
-
return
|
270
|
+
return 0;
|
264
271
|
}
|
265
272
|
|
266
273
|
unsigned int git_index_entrycount(git_index *index)
|
@@ -281,64 +288,69 @@ git_index_entry *git_index_get(git_index *index, unsigned int n)
|
|
281
288
|
return git_vector_get(&index->entries, n);
|
282
289
|
}
|
283
290
|
|
291
|
+
void git_index__init_entry_from_stat(struct stat *st, git_index_entry *entry)
|
292
|
+
{
|
293
|
+
entry->ctime.seconds = (git_time_t)st->st_ctime;
|
294
|
+
entry->mtime.seconds = (git_time_t)st->st_mtime;
|
295
|
+
/* entry->mtime.nanoseconds = st->st_mtimensec; */
|
296
|
+
/* entry->ctime.nanoseconds = st->st_ctimensec; */
|
297
|
+
entry->dev = st->st_rdev;
|
298
|
+
entry->ino = st->st_ino;
|
299
|
+
entry->mode = index_create_mode(st->st_mode);
|
300
|
+
entry->uid = st->st_uid;
|
301
|
+
entry->gid = st->st_gid;
|
302
|
+
entry->file_size = st->st_size;
|
303
|
+
}
|
304
|
+
|
284
305
|
static int index_entry_init(git_index_entry **entry_out, git_index *index, const char *rel_path, int stage)
|
285
306
|
{
|
286
|
-
git_index_entry *entry;
|
287
|
-
char full_path[GIT_PATH_MAX];
|
307
|
+
git_index_entry *entry = NULL;
|
288
308
|
struct stat st;
|
289
309
|
git_oid oid;
|
290
|
-
int error;
|
291
310
|
const char *workdir;
|
311
|
+
git_buf full_path = GIT_BUF_INIT;
|
312
|
+
int error;
|
313
|
+
|
314
|
+
assert(stage >= 0 && stage <= 3);
|
292
315
|
|
293
|
-
if (INDEX_OWNER(index) == NULL
|
294
|
-
|
295
|
-
|
316
|
+
if (INDEX_OWNER(index) == NULL ||
|
317
|
+
(workdir = git_repository_workdir(INDEX_OWNER(index))) == NULL)
|
318
|
+
{
|
319
|
+
giterr_set(GITERR_INDEX,
|
320
|
+
"Could not initialize index entry. Repository is bare");
|
321
|
+
return -1;
|
322
|
+
}
|
296
323
|
|
297
|
-
|
298
|
-
|
299
|
-
return git__throw(GIT_EBAREINDEX,
|
300
|
-
"Failed to initialize entry. Cannot resolved workdir");
|
324
|
+
if ((error = git_buf_joinpath(&full_path, workdir, rel_path)) < 0)
|
325
|
+
return error;
|
301
326
|
|
302
|
-
|
327
|
+
if ((error = git_path_lstat(full_path.ptr, &st)) < 0) {
|
328
|
+
git_buf_free(&full_path);
|
329
|
+
return error;
|
330
|
+
}
|
303
331
|
|
304
|
-
|
305
|
-
return git__throw(GIT_ENOTFOUND,
|
306
|
-
"Failed to initialize entry. '%s' cannot be opened", full_path);
|
332
|
+
git_buf_free(&full_path); /* done with full path */
|
307
333
|
|
308
|
-
|
309
|
-
|
310
|
-
|
334
|
+
/* There is no need to validate the rel_path here, since it will be
|
335
|
+
* immediately validated by the call to git_blob_create_fromfile.
|
336
|
+
*/
|
311
337
|
|
312
338
|
/* write the blob to disk and get the oid */
|
313
|
-
if ((error = git_blob_create_fromfile(&oid, INDEX_OWNER(index), rel_path)) <
|
314
|
-
return
|
339
|
+
if ((error = git_blob_create_fromfile(&oid, INDEX_OWNER(index), rel_path)) < 0)
|
340
|
+
return error;
|
315
341
|
|
316
|
-
entry =
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
entry->ctime.seconds = (git_time_t)st.st_ctime;
|
322
|
-
entry->mtime.seconds = (git_time_t)st.st_mtime;
|
323
|
-
/* entry.mtime.nanoseconds = st.st_mtimensec; */
|
324
|
-
/* entry.ctime.nanoseconds = st.st_ctimensec; */
|
325
|
-
entry->dev= st.st_rdev;
|
326
|
-
entry->ino = st.st_ino;
|
327
|
-
entry->mode = index_create_mode(st.st_mode);
|
328
|
-
entry->uid = st.st_uid;
|
329
|
-
entry->gid = st.st_gid;
|
330
|
-
entry->file_size = st.st_size;
|
331
|
-
entry->oid = oid;
|
342
|
+
entry = git__calloc(1, sizeof(git_index_entry));
|
343
|
+
GITERR_CHECK_ALLOC(entry);
|
344
|
+
|
345
|
+
git_index__init_entry_from_stat(&st, entry);
|
332
346
|
|
347
|
+
entry->oid = oid;
|
333
348
|
entry->flags |= (stage << GIT_IDXENTRY_STAGESHIFT);
|
334
349
|
entry->path = git__strdup(rel_path);
|
335
|
-
|
336
|
-
git__free(entry);
|
337
|
-
return GIT_ENOMEM;
|
338
|
-
}
|
350
|
+
GITERR_CHECK_ALLOC(entry->path);
|
339
351
|
|
340
352
|
*entry_out = entry;
|
341
|
-
return
|
353
|
+
return 0;
|
342
354
|
}
|
343
355
|
|
344
356
|
static git_index_entry *index_entry_dup(const git_index_entry *source_entry)
|
@@ -373,10 +385,7 @@ static int index_insert(git_index *index, git_index_entry *entry, int replace)
|
|
373
385
|
int position;
|
374
386
|
git_index_entry **entry_array;
|
375
387
|
|
376
|
-
assert(index && entry);
|
377
|
-
|
378
|
-
if (entry->path == NULL)
|
379
|
-
return git__throw(GIT_EMISSINGOBJDATA, "Failed to insert into index. Entry has no path");
|
388
|
+
assert(index && entry && entry->path != NULL);
|
380
389
|
|
381
390
|
/* make sure that the path length flag is correct */
|
382
391
|
path_length = strlen(entry->path);
|
@@ -392,12 +401,8 @@ static int index_insert(git_index *index, git_index_entry *entry, int replace)
|
|
392
401
|
* replacing is not requested: just insert entry at the end;
|
393
402
|
* the index is no longer sorted
|
394
403
|
*/
|
395
|
-
if (!replace)
|
396
|
-
|
397
|
-
return GIT_ENOMEM;
|
398
|
-
|
399
|
-
return GIT_SUCCESS;
|
400
|
-
}
|
404
|
+
if (!replace)
|
405
|
+
return git_vector_insert(&index->entries, entry);
|
401
406
|
|
402
407
|
/* look if an entry with this path already exists */
|
403
408
|
position = git_index_find(index, entry->path);
|
@@ -406,12 +411,8 @@ static int index_insert(git_index *index, git_index_entry *entry, int replace)
|
|
406
411
|
* if no entry exists add the entry at the end;
|
407
412
|
* the index is no longer sorted
|
408
413
|
*/
|
409
|
-
if (position == GIT_ENOTFOUND)
|
410
|
-
|
411
|
-
return GIT_ENOMEM;
|
412
|
-
|
413
|
-
return GIT_SUCCESS;
|
414
|
-
}
|
414
|
+
if (position == GIT_ENOTFOUND)
|
415
|
+
return git_vector_insert(&index->entries, entry);
|
415
416
|
|
416
417
|
/* exists, replace it */
|
417
418
|
entry_array = (git_index_entry **) index->entries.contents;
|
@@ -419,7 +420,7 @@ static int index_insert(git_index *index, git_index_entry *entry, int replace)
|
|
419
420
|
git__free(entry_array[position]);
|
420
421
|
entry_array[position] = entry;
|
421
422
|
|
422
|
-
return
|
423
|
+
return 0;
|
423
424
|
}
|
424
425
|
|
425
426
|
static int index_add(git_index *index, const char *path, int stage, int replace)
|
@@ -427,20 +428,15 @@ static int index_add(git_index *index, const char *path, int stage, int replace)
|
|
427
428
|
git_index_entry *entry = NULL;
|
428
429
|
int ret;
|
429
430
|
|
430
|
-
ret = index_entry_init(&entry, index, path, stage)
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
goto err;
|
431
|
+
if ((ret = index_entry_init(&entry, index, path, stage)) < 0 ||
|
432
|
+
(ret = index_insert(index, entry, replace)) < 0)
|
433
|
+
{
|
434
|
+
index_entry_free(entry);
|
435
|
+
return ret;
|
436
|
+
}
|
437
437
|
|
438
438
|
git_tree_cache_invalidate_path(index->tree, entry->path);
|
439
|
-
|
440
|
-
return ret;
|
441
|
-
err:
|
442
|
-
index_entry_free(entry);
|
443
|
-
return git__rethrow(ret, "Failed to append to index");
|
439
|
+
return 0;
|
444
440
|
}
|
445
441
|
|
446
442
|
int git_index_add(git_index *index, const char *path, int stage)
|
@@ -453,28 +449,23 @@ int git_index_append(git_index *index, const char *path, int stage)
|
|
453
449
|
return index_add(index, path, stage, 0);
|
454
450
|
}
|
455
451
|
|
456
|
-
static int index_add2(
|
457
|
-
|
452
|
+
static int index_add2(
|
453
|
+
git_index *index, const git_index_entry *source_entry, int replace)
|
458
454
|
{
|
459
455
|
git_index_entry *entry = NULL;
|
460
456
|
int ret;
|
461
457
|
|
462
458
|
entry = index_entry_dup(source_entry);
|
463
|
-
if (entry == NULL)
|
464
|
-
|
465
|
-
goto err;
|
466
|
-
}
|
459
|
+
if (entry == NULL)
|
460
|
+
return -1;
|
467
461
|
|
468
|
-
ret = index_insert(index, entry, replace)
|
469
|
-
|
470
|
-
|
462
|
+
if ((ret = index_insert(index, entry, replace)) < 0) {
|
463
|
+
index_entry_free(entry);
|
464
|
+
return ret;
|
465
|
+
}
|
471
466
|
|
472
467
|
git_tree_cache_invalidate_path(index->tree, entry->path);
|
473
|
-
|
474
|
-
return ret;
|
475
|
-
err:
|
476
|
-
index_entry_free(entry);
|
477
|
-
return git__rethrow(ret, "Failed to append to index");
|
468
|
+
return 0;
|
478
469
|
}
|
479
470
|
|
480
471
|
int git_index_add2(git_index *index, const git_index_entry *source_entry)
|
@@ -489,14 +480,21 @@ int git_index_append2(git_index *index, const git_index_entry *source_entry)
|
|
489
480
|
|
490
481
|
int git_index_remove(git_index *index, int position)
|
491
482
|
{
|
483
|
+
int error;
|
492
484
|
git_index_entry *entry;
|
493
485
|
|
494
486
|
git_vector_sort(&index->entries);
|
487
|
+
|
495
488
|
entry = git_vector_get(&index->entries, position);
|
496
489
|
if (entry != NULL)
|
497
490
|
git_tree_cache_invalidate_path(index->tree, entry->path);
|
498
491
|
|
499
|
-
|
492
|
+
error = git_vector_remove(&index->entries, (unsigned int)position);
|
493
|
+
|
494
|
+
if (!error)
|
495
|
+
index_entry_free(entry);
|
496
|
+
|
497
|
+
return error;
|
500
498
|
}
|
501
499
|
|
502
500
|
int git_index_find(git_index *index, const char *path)
|
@@ -504,12 +502,22 @@ int git_index_find(git_index *index, const char *path)
|
|
504
502
|
return git_vector_bsearch2(&index->entries, index_srch, path);
|
505
503
|
}
|
506
504
|
|
505
|
+
unsigned int git_index__prefix_position(git_index *index, const char *path)
|
506
|
+
{
|
507
|
+
unsigned int pos;
|
508
|
+
|
509
|
+
git_vector_bsearch3(&pos, &index->entries, index_srch, path);
|
510
|
+
|
511
|
+
return pos;
|
512
|
+
}
|
513
|
+
|
507
514
|
void git_index_uniq(git_index *index)
|
508
515
|
{
|
509
516
|
git_vector_uniq(&index->entries);
|
510
517
|
}
|
511
518
|
|
512
|
-
const git_index_entry_unmerged *git_index_get_unmerged_bypath(
|
519
|
+
const git_index_entry_unmerged *git_index_get_unmerged_bypath(
|
520
|
+
git_index *index, const char *path)
|
513
521
|
{
|
514
522
|
int pos;
|
515
523
|
assert(index && path);
|
@@ -517,75 +525,87 @@ const git_index_entry_unmerged *git_index_get_unmerged_bypath(git_index *index,
|
|
517
525
|
if (!index->unmerged.length)
|
518
526
|
return NULL;
|
519
527
|
|
520
|
-
if ((pos = git_vector_bsearch2(&index->unmerged, unmerged_srch, path)) <
|
528
|
+
if ((pos = git_vector_bsearch2(&index->unmerged, unmerged_srch, path)) < 0)
|
521
529
|
return NULL;
|
522
530
|
|
523
531
|
return git_vector_get(&index->unmerged, pos);
|
524
532
|
}
|
525
533
|
|
526
|
-
const git_index_entry_unmerged *git_index_get_unmerged_byindex(
|
534
|
+
const git_index_entry_unmerged *git_index_get_unmerged_byindex(
|
535
|
+
git_index *index, unsigned int n)
|
527
536
|
{
|
528
537
|
assert(index);
|
529
538
|
return git_vector_get(&index->unmerged, n);
|
530
539
|
}
|
531
540
|
|
541
|
+
static int index_error_invalid(const char *message)
|
542
|
+
{
|
543
|
+
giterr_set(GITERR_INDEX, "Invalid data in index - %s", message);
|
544
|
+
return -1;
|
545
|
+
}
|
546
|
+
|
532
547
|
static int read_unmerged(git_index *index, const char *buffer, size_t size)
|
533
548
|
{
|
534
549
|
const char *endptr;
|
535
550
|
size_t len;
|
536
551
|
int i;
|
537
552
|
|
538
|
-
git_vector_init(&index->unmerged, 16, unmerged_cmp)
|
553
|
+
if (git_vector_init(&index->unmerged, 16, unmerged_cmp) < 0)
|
554
|
+
return -1;
|
539
555
|
|
540
556
|
while (size) {
|
541
557
|
git_index_entry_unmerged *lost;
|
542
558
|
|
543
559
|
len = strlen(buffer) + 1;
|
544
560
|
if (size <= len)
|
545
|
-
return
|
561
|
+
return index_error_invalid("reading unmerged entries");
|
546
562
|
|
547
|
-
|
548
|
-
|
563
|
+
lost = git__malloc(sizeof(git_index_entry_unmerged));
|
564
|
+
GITERR_CHECK_ALLOC(lost);
|
549
565
|
|
550
|
-
if (git_vector_insert(&index->unmerged, lost) <
|
551
|
-
return
|
566
|
+
if (git_vector_insert(&index->unmerged, lost) < 0)
|
567
|
+
return -1;
|
552
568
|
|
569
|
+
/* read NUL-terminated pathname for entry */
|
553
570
|
lost->path = git__strdup(buffer);
|
554
|
-
|
555
|
-
return GIT_ENOMEM;
|
571
|
+
GITERR_CHECK_ALLOC(lost->path);
|
556
572
|
|
557
573
|
size -= len;
|
558
574
|
buffer += len;
|
559
575
|
|
576
|
+
/* read 3 ASCII octal numbers for stage entries */
|
560
577
|
for (i = 0; i < 3; i++) {
|
561
578
|
int tmp;
|
562
579
|
|
563
|
-
if (git__strtol32(&tmp, buffer, &endptr, 8) <
|
564
|
-
!endptr || endptr == buffer || *endptr ||
|
565
|
-
|
580
|
+
if (git__strtol32(&tmp, buffer, &endptr, 8) < 0 ||
|
581
|
+
!endptr || endptr == buffer || *endptr ||
|
582
|
+
(unsigned)tmp > UINT_MAX)
|
583
|
+
return index_error_invalid("reading unmerged entry stage");
|
566
584
|
|
567
585
|
lost->mode[i] = tmp;
|
568
586
|
|
569
587
|
len = (endptr + 1) - buffer;
|
570
588
|
if (size <= len)
|
571
|
-
return
|
589
|
+
return index_error_invalid("reading unmerged entry stage");
|
572
590
|
|
573
591
|
size -= len;
|
574
592
|
buffer += len;
|
575
593
|
}
|
576
594
|
|
595
|
+
/* read up to 3 OIDs for stage entries */
|
577
596
|
for (i = 0; i < 3; i++) {
|
578
597
|
if (!lost->mode[i])
|
579
598
|
continue;
|
580
599
|
if (size < 20)
|
581
|
-
return
|
600
|
+
return index_error_invalid("reading unmerged entry oid");
|
601
|
+
|
582
602
|
git_oid_fromraw(&lost->oid[i], (const unsigned char *) buffer);
|
583
603
|
size -= 20;
|
584
604
|
buffer += 20;
|
585
605
|
}
|
586
606
|
}
|
587
607
|
|
588
|
-
return
|
608
|
+
return 0;
|
589
609
|
}
|
590
610
|
|
591
611
|
static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffer_size)
|
@@ -631,7 +651,7 @@ static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffe
|
|
631
651
|
|
632
652
|
path_end = memchr(path_ptr, '\0', buffer_size);
|
633
653
|
if (path_end == NULL)
|
634
|
-
|
654
|
+
return 0;
|
635
655
|
|
636
656
|
path_length = path_end - path_ptr;
|
637
657
|
}
|
@@ -656,15 +676,15 @@ static int read_header(struct index_header *dest, const void *buffer)
|
|
656
676
|
|
657
677
|
dest->signature = ntohl(source->signature);
|
658
678
|
if (dest->signature != INDEX_HEADER_SIG)
|
659
|
-
return
|
679
|
+
return index_error_invalid("incorrect header signature");
|
660
680
|
|
661
681
|
dest->version = ntohl(source->version);
|
662
682
|
if (dest->version != INDEX_VERSION_NUMBER_EXT &&
|
663
683
|
dest->version != INDEX_VERSION_NUMBER)
|
664
|
-
return
|
684
|
+
return index_error_invalid("incorrect header version");
|
665
685
|
|
666
686
|
dest->entry_count = ntohl(source->entry_count);
|
667
|
-
return
|
687
|
+
return 0;
|
668
688
|
}
|
669
689
|
|
670
690
|
static size_t read_extension(git_index *index, const char *buffer, size_t buffer_size)
|
@@ -687,10 +707,10 @@ static size_t read_extension(git_index *index, const char *buffer, size_t buffer
|
|
687
707
|
if (dest.signature[0] >= 'A' && dest.signature[0] <= 'Z') {
|
688
708
|
/* tree cache */
|
689
709
|
if (memcmp(dest.signature, INDEX_EXT_TREECACHE_SIG, 4) == 0) {
|
690
|
-
if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size) <
|
710
|
+
if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size) < 0)
|
691
711
|
return 0;
|
692
712
|
} else if (memcmp(dest.signature, INDEX_EXT_UNMERGED_SIG, 4) == 0) {
|
693
|
-
if (read_unmerged(index, buffer + 8, dest.extension_size) <
|
713
|
+
if (read_unmerged(index, buffer + 8, dest.extension_size) < 0)
|
694
714
|
return 0;
|
695
715
|
}
|
696
716
|
/* else, unsupported extension. We cannot parse this, but we can skip
|
@@ -712,21 +732,21 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
712
732
|
|
713
733
|
#define seek_forward(_increase) { \
|
714
734
|
if (_increase >= buffer_size) \
|
715
|
-
return
|
735
|
+
return index_error_invalid("ran out of data while parsing"); \
|
716
736
|
buffer += _increase; \
|
717
737
|
buffer_size -= _increase;\
|
718
738
|
}
|
719
739
|
|
720
740
|
if (buffer_size < INDEX_HEADER_SIZE + INDEX_FOOTER_SIZE)
|
721
|
-
return
|
741
|
+
return index_error_invalid("insufficient buffer space");
|
722
742
|
|
723
743
|
/* Precalculate the SHA1 of the files's contents -- we'll match it to
|
724
744
|
* the provided SHA1 in the footer */
|
725
745
|
git_hash_buf(&checksum_calculated, buffer, buffer_size - INDEX_FOOTER_SIZE);
|
726
746
|
|
727
747
|
/* Parse header */
|
728
|
-
if (read_header(&header, buffer) <
|
729
|
-
return
|
748
|
+
if (read_header(&header, buffer) < 0)
|
749
|
+
return -1;
|
730
750
|
|
731
751
|
seek_forward(INDEX_HEADER_SIZE);
|
732
752
|
|
@@ -738,23 +758,22 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
738
758
|
git_index_entry *entry;
|
739
759
|
|
740
760
|
entry = git__malloc(sizeof(git_index_entry));
|
741
|
-
|
742
|
-
return GIT_ENOMEM;
|
761
|
+
GITERR_CHECK_ALLOC(entry);
|
743
762
|
|
744
763
|
entry_size = read_entry(entry, buffer, buffer_size);
|
745
764
|
|
746
765
|
/* 0 bytes read means an object corruption */
|
747
766
|
if (entry_size == 0)
|
748
|
-
return
|
767
|
+
return index_error_invalid("invalid entry");
|
749
768
|
|
750
|
-
if (git_vector_insert(&index->entries, entry) <
|
751
|
-
return
|
769
|
+
if (git_vector_insert(&index->entries, entry) < 0)
|
770
|
+
return -1;
|
752
771
|
|
753
772
|
seek_forward(entry_size);
|
754
773
|
}
|
755
774
|
|
756
775
|
if (i != header.entry_count)
|
757
|
-
return
|
776
|
+
return index_error_invalid("header entries changed while parsing");
|
758
777
|
|
759
778
|
/* There's still space for some extensions! */
|
760
779
|
while (buffer_size > INDEX_FOOTER_SIZE) {
|
@@ -764,43 +783,43 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
764
783
|
|
765
784
|
/* see if we have read any bytes from the extension */
|
766
785
|
if (extension_size == 0)
|
767
|
-
return
|
786
|
+
return index_error_invalid("extension size is zero");
|
768
787
|
|
769
788
|
seek_forward(extension_size);
|
770
789
|
}
|
771
790
|
|
772
791
|
if (buffer_size != INDEX_FOOTER_SIZE)
|
773
|
-
return
|
792
|
+
return index_error_invalid("buffer size does not match index footer size");
|
774
793
|
|
775
794
|
/* 160-bit SHA-1 over the content of the index file before this checksum. */
|
776
795
|
git_oid_fromraw(&checksum_expected, (const unsigned char *)buffer);
|
777
796
|
|
778
797
|
if (git_oid_cmp(&checksum_calculated, &checksum_expected) != 0)
|
779
|
-
return
|
798
|
+
return index_error_invalid("calculated checksum does not match expected");
|
780
799
|
|
781
800
|
#undef seek_forward
|
782
801
|
|
783
802
|
/* force sorting in the vector: the entries are
|
784
803
|
* assured to be sorted on the index */
|
785
804
|
index->entries.sorted = 1;
|
786
|
-
return
|
805
|
+
return 0;
|
787
806
|
}
|
788
807
|
|
789
808
|
static int is_index_extended(git_index *index)
|
790
809
|
{
|
791
810
|
unsigned int i, extended;
|
811
|
+
git_index_entry *entry;
|
792
812
|
|
793
813
|
extended = 0;
|
794
814
|
|
795
|
-
|
796
|
-
git_index_entry *entry;
|
797
|
-
entry = git_vector_get(&index->entries, i);
|
815
|
+
git_vector_foreach(&index->entries, i, entry) {
|
798
816
|
entry->flags &= ~GIT_IDXENTRY_EXTENDED;
|
799
817
|
if (entry->flags_extended & GIT_IDXENTRY_EXTENDED_FLAGS) {
|
800
818
|
extended++;
|
801
819
|
entry->flags |= GIT_IDXENTRY_EXTENDED;
|
802
820
|
}
|
803
821
|
}
|
822
|
+
|
804
823
|
return extended;
|
805
824
|
}
|
806
825
|
|
@@ -818,8 +837,8 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry)
|
|
818
837
|
else
|
819
838
|
disk_size = short_entry_size(path_len);
|
820
839
|
|
821
|
-
if (git_filebuf_reserve(file, &mem, disk_size) <
|
822
|
-
return
|
840
|
+
if (git_filebuf_reserve(file, &mem, disk_size) < 0)
|
841
|
+
return -1;
|
823
842
|
|
824
843
|
ondisk = (struct entry_short *)mem;
|
825
844
|
|
@@ -861,7 +880,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry)
|
|
861
880
|
|
862
881
|
memcpy(path, entry->path, path_len);
|
863
882
|
|
864
|
-
return
|
883
|
+
return 0;
|
865
884
|
}
|
866
885
|
|
867
886
|
static int write_entries(git_index *index, git_filebuf *file)
|
@@ -871,16 +890,15 @@ static int write_entries(git_index *index, git_filebuf *file)
|
|
871
890
|
for (i = 0; i < index->entries.length; ++i) {
|
872
891
|
git_index_entry *entry;
|
873
892
|
entry = git_vector_get(&index->entries, i);
|
874
|
-
if (write_disk_entry(file, entry) <
|
875
|
-
return
|
893
|
+
if (write_disk_entry(file, entry) < 0)
|
894
|
+
return -1;
|
876
895
|
}
|
877
896
|
|
878
|
-
return
|
897
|
+
return 0;
|
879
898
|
}
|
880
899
|
|
881
900
|
static int write_index(git_index *index, git_filebuf *file)
|
882
901
|
{
|
883
|
-
int error = GIT_SUCCESS;
|
884
902
|
git_oid hash_final;
|
885
903
|
|
886
904
|
struct index_header header;
|
@@ -895,11 +913,11 @@ static int write_index(git_index *index, git_filebuf *file)
|
|
895
913
|
header.version = htonl(is_extended ? INDEX_VERSION_NUMBER_EXT : INDEX_VERSION_NUMBER);
|
896
914
|
header.entry_count = htonl(index->entries.length);
|
897
915
|
|
898
|
-
git_filebuf_write(file, &header, sizeof(struct index_header))
|
916
|
+
if (git_filebuf_write(file, &header, sizeof(struct index_header)) < 0)
|
917
|
+
return -1;
|
899
918
|
|
900
|
-
|
901
|
-
|
902
|
-
return git__rethrow(error, "Failed to write index");
|
919
|
+
if (write_entries(index, file) < 0)
|
920
|
+
return -1;
|
903
921
|
|
904
922
|
/* TODO: write extensions (tree cache) */
|
905
923
|
|
@@ -907,12 +925,45 @@ static int write_index(git_index *index, git_filebuf *file)
|
|
907
925
|
git_filebuf_hash(&hash_final, file);
|
908
926
|
|
909
927
|
/* write it at the end of the file */
|
910
|
-
git_filebuf_write(file, hash_final.id, GIT_OID_RAWSZ);
|
911
|
-
|
912
|
-
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to write index");
|
928
|
+
return git_filebuf_write(file, hash_final.id, GIT_OID_RAWSZ);
|
913
929
|
}
|
914
930
|
|
915
931
|
int git_index_entry_stage(const git_index_entry *entry)
|
916
932
|
{
|
917
933
|
return (entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT;
|
918
934
|
}
|
935
|
+
|
936
|
+
static int read_tree_cb(const char *root, git_tree_entry *tentry, void *data)
|
937
|
+
{
|
938
|
+
git_index *index = data;
|
939
|
+
git_index_entry *entry = NULL;
|
940
|
+
git_buf path = GIT_BUF_INIT;
|
941
|
+
|
942
|
+
if (git_tree_entry__is_tree(tentry))
|
943
|
+
return 0;
|
944
|
+
|
945
|
+
if (git_buf_joinpath(&path, root, tentry->filename) < 0)
|
946
|
+
return -1;
|
947
|
+
|
948
|
+
entry = git__calloc(1, sizeof(git_index_entry));
|
949
|
+
GITERR_CHECK_ALLOC(entry);
|
950
|
+
|
951
|
+
entry->mode = tentry->attr;
|
952
|
+
entry->oid = tentry->oid;
|
953
|
+
entry->path = git_buf_detach(&path);
|
954
|
+
git_buf_free(&path);
|
955
|
+
|
956
|
+
if (index_insert(index, entry, 0) < 0) {
|
957
|
+
index_entry_free(entry);
|
958
|
+
return -1;
|
959
|
+
}
|
960
|
+
|
961
|
+
return 0;
|
962
|
+
}
|
963
|
+
|
964
|
+
int git_index_read_tree(git_index *index, git_tree *tree)
|
965
|
+
{
|
966
|
+
git_index_clear(index);
|
967
|
+
|
968
|
+
return git_tree_walk(tree, read_tree_cb, GIT_TREEWALK_POST, index);
|
969
|
+
}
|