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
@@ -0,0 +1,748 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2012 the libgit2 contributors
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "iterator.h"
|
9
|
+
#include "tree.h"
|
10
|
+
#include "ignore.h"
|
11
|
+
#include "buffer.h"
|
12
|
+
#include "git2/submodule.h"
|
13
|
+
|
14
|
+
#define ITERATOR_BASE_INIT(P,NAME_LC,NAME_UC) do { \
|
15
|
+
(P) = git__calloc(1, sizeof(NAME_LC ## _iterator)); \
|
16
|
+
GITERR_CHECK_ALLOC(P); \
|
17
|
+
(P)->base.type = GIT_ITERATOR_ ## NAME_UC; \
|
18
|
+
(P)->base.start = start ? git__strdup(start) : NULL; \
|
19
|
+
(P)->base.end = end ? git__strdup(end) : NULL; \
|
20
|
+
(P)->base.current = NAME_LC ## _iterator__current; \
|
21
|
+
(P)->base.at_end = NAME_LC ## _iterator__at_end; \
|
22
|
+
(P)->base.advance = NAME_LC ## _iterator__advance; \
|
23
|
+
(P)->base.seek = NAME_LC ## _iterator__seek; \
|
24
|
+
(P)->base.reset = NAME_LC ## _iterator__reset; \
|
25
|
+
(P)->base.free = NAME_LC ## _iterator__free; \
|
26
|
+
if ((start && !(P)->base.start) || (end && !(P)->base.end)) \
|
27
|
+
return -1; \
|
28
|
+
} while (0)
|
29
|
+
|
30
|
+
|
31
|
+
static int empty_iterator__no_item(
|
32
|
+
git_iterator *iter, const git_index_entry **entry)
|
33
|
+
{
|
34
|
+
GIT_UNUSED(iter);
|
35
|
+
*entry = NULL;
|
36
|
+
return 0;
|
37
|
+
}
|
38
|
+
|
39
|
+
static int empty_iterator__at_end(git_iterator *iter)
|
40
|
+
{
|
41
|
+
GIT_UNUSED(iter);
|
42
|
+
return 1;
|
43
|
+
}
|
44
|
+
|
45
|
+
static int empty_iterator__noop(git_iterator *iter)
|
46
|
+
{
|
47
|
+
GIT_UNUSED(iter);
|
48
|
+
return 0;
|
49
|
+
}
|
50
|
+
|
51
|
+
static int empty_iterator__seek(git_iterator *iter, const char *prefix)
|
52
|
+
{
|
53
|
+
GIT_UNUSED(iter);
|
54
|
+
GIT_UNUSED(prefix);
|
55
|
+
return -1;
|
56
|
+
}
|
57
|
+
|
58
|
+
static void empty_iterator__free(git_iterator *iter)
|
59
|
+
{
|
60
|
+
GIT_UNUSED(iter);
|
61
|
+
}
|
62
|
+
|
63
|
+
int git_iterator_for_nothing(git_iterator **iter)
|
64
|
+
{
|
65
|
+
git_iterator *i = git__calloc(1, sizeof(git_iterator));
|
66
|
+
GITERR_CHECK_ALLOC(i);
|
67
|
+
|
68
|
+
i->type = GIT_ITERATOR_EMPTY;
|
69
|
+
i->current = empty_iterator__no_item;
|
70
|
+
i->at_end = empty_iterator__at_end;
|
71
|
+
i->advance = empty_iterator__no_item;
|
72
|
+
i->seek = empty_iterator__seek;
|
73
|
+
i->reset = empty_iterator__noop;
|
74
|
+
i->free = empty_iterator__free;
|
75
|
+
|
76
|
+
*iter = i;
|
77
|
+
|
78
|
+
return 0;
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
typedef struct tree_iterator_frame tree_iterator_frame;
|
83
|
+
struct tree_iterator_frame {
|
84
|
+
tree_iterator_frame *next;
|
85
|
+
git_tree *tree;
|
86
|
+
char *start;
|
87
|
+
unsigned int index;
|
88
|
+
};
|
89
|
+
|
90
|
+
typedef struct {
|
91
|
+
git_iterator base;
|
92
|
+
git_repository *repo;
|
93
|
+
tree_iterator_frame *stack;
|
94
|
+
git_index_entry entry;
|
95
|
+
git_buf path;
|
96
|
+
bool path_has_filename;
|
97
|
+
} tree_iterator;
|
98
|
+
|
99
|
+
static const git_tree_entry *tree_iterator__tree_entry(tree_iterator *ti)
|
100
|
+
{
|
101
|
+
return (ti->stack == NULL) ? NULL :
|
102
|
+
git_tree_entry_byindex(ti->stack->tree, ti->stack->index);
|
103
|
+
}
|
104
|
+
|
105
|
+
static char *tree_iterator__current_filename(
|
106
|
+
tree_iterator *ti, const git_tree_entry *te)
|
107
|
+
{
|
108
|
+
if (!ti->path_has_filename) {
|
109
|
+
if (git_buf_joinpath(&ti->path, ti->path.ptr, te->filename) < 0)
|
110
|
+
return NULL;
|
111
|
+
ti->path_has_filename = true;
|
112
|
+
}
|
113
|
+
|
114
|
+
return ti->path.ptr;
|
115
|
+
}
|
116
|
+
|
117
|
+
static void tree_iterator__pop_frame(tree_iterator *ti)
|
118
|
+
{
|
119
|
+
tree_iterator_frame *tf = ti->stack;
|
120
|
+
ti->stack = tf->next;
|
121
|
+
if (ti->stack != NULL) /* don't free the initial tree */
|
122
|
+
git_tree_free(tf->tree);
|
123
|
+
git__free(tf);
|
124
|
+
}
|
125
|
+
|
126
|
+
static int tree_iterator__to_end(tree_iterator *ti)
|
127
|
+
{
|
128
|
+
while (ti->stack && ti->stack->next)
|
129
|
+
tree_iterator__pop_frame(ti);
|
130
|
+
|
131
|
+
if (ti->stack)
|
132
|
+
ti->stack->index = git_tree_entrycount(ti->stack->tree);
|
133
|
+
|
134
|
+
return 0;
|
135
|
+
}
|
136
|
+
|
137
|
+
static int tree_iterator__current(
|
138
|
+
git_iterator *self, const git_index_entry **entry)
|
139
|
+
{
|
140
|
+
tree_iterator *ti = (tree_iterator *)self;
|
141
|
+
const git_tree_entry *te = tree_iterator__tree_entry(ti);
|
142
|
+
|
143
|
+
if (entry)
|
144
|
+
*entry = NULL;
|
145
|
+
|
146
|
+
if (te == NULL)
|
147
|
+
return 0;
|
148
|
+
|
149
|
+
ti->entry.mode = te->attr;
|
150
|
+
git_oid_cpy(&ti->entry.oid, &te->oid);
|
151
|
+
|
152
|
+
ti->entry.path = tree_iterator__current_filename(ti, te);
|
153
|
+
if (ti->entry.path == NULL)
|
154
|
+
return -1;
|
155
|
+
|
156
|
+
if (ti->base.end && git__prefixcmp(ti->entry.path, ti->base.end) > 0)
|
157
|
+
return tree_iterator__to_end(ti);
|
158
|
+
|
159
|
+
if (entry)
|
160
|
+
*entry = &ti->entry;
|
161
|
+
|
162
|
+
return 0;
|
163
|
+
}
|
164
|
+
|
165
|
+
static int tree_iterator__at_end(git_iterator *self)
|
166
|
+
{
|
167
|
+
return (tree_iterator__tree_entry((tree_iterator *)self) == NULL);
|
168
|
+
}
|
169
|
+
|
170
|
+
static tree_iterator_frame *tree_iterator__alloc_frame(
|
171
|
+
git_tree *tree, char *start)
|
172
|
+
{
|
173
|
+
tree_iterator_frame *tf = git__calloc(1, sizeof(tree_iterator_frame));
|
174
|
+
if (!tf)
|
175
|
+
return NULL;
|
176
|
+
|
177
|
+
tf->tree = tree;
|
178
|
+
|
179
|
+
if (start && *start) {
|
180
|
+
tf->start = start;
|
181
|
+
tf->index = git_tree__prefix_position(tree, start);
|
182
|
+
}
|
183
|
+
|
184
|
+
return tf;
|
185
|
+
}
|
186
|
+
|
187
|
+
static int tree_iterator__expand_tree(tree_iterator *ti)
|
188
|
+
{
|
189
|
+
int error;
|
190
|
+
git_tree *subtree;
|
191
|
+
const git_tree_entry *te = tree_iterator__tree_entry(ti);
|
192
|
+
tree_iterator_frame *tf;
|
193
|
+
char *relpath;
|
194
|
+
|
195
|
+
while (te != NULL && git_tree_entry__is_tree(te)) {
|
196
|
+
if (git_buf_joinpath(&ti->path, ti->path.ptr, te->filename) < 0)
|
197
|
+
return -1;
|
198
|
+
|
199
|
+
/* check that we have not passed the range end */
|
200
|
+
if (ti->base.end != NULL &&
|
201
|
+
git__prefixcmp(ti->path.ptr, ti->base.end) > 0)
|
202
|
+
return tree_iterator__to_end(ti);
|
203
|
+
|
204
|
+
if ((error = git_tree_lookup(&subtree, ti->repo, &te->oid)) < 0)
|
205
|
+
return error;
|
206
|
+
|
207
|
+
relpath = NULL;
|
208
|
+
|
209
|
+
/* apply range start to new frame if relevant */
|
210
|
+
if (ti->stack->start &&
|
211
|
+
git__prefixcmp(ti->stack->start, te->filename) == 0)
|
212
|
+
{
|
213
|
+
size_t namelen = strlen(te->filename);
|
214
|
+
if (ti->stack->start[namelen] == '/')
|
215
|
+
relpath = ti->stack->start + namelen + 1;
|
216
|
+
}
|
217
|
+
|
218
|
+
if ((tf = tree_iterator__alloc_frame(subtree, relpath)) == NULL)
|
219
|
+
return -1;
|
220
|
+
|
221
|
+
tf->next = ti->stack;
|
222
|
+
ti->stack = tf;
|
223
|
+
|
224
|
+
te = tree_iterator__tree_entry(ti);
|
225
|
+
}
|
226
|
+
|
227
|
+
return 0;
|
228
|
+
}
|
229
|
+
|
230
|
+
static int tree_iterator__advance(
|
231
|
+
git_iterator *self, const git_index_entry **entry)
|
232
|
+
{
|
233
|
+
int error = 0;
|
234
|
+
tree_iterator *ti = (tree_iterator *)self;
|
235
|
+
const git_tree_entry *te = NULL;
|
236
|
+
|
237
|
+
if (entry != NULL)
|
238
|
+
*entry = NULL;
|
239
|
+
|
240
|
+
if (ti->path_has_filename) {
|
241
|
+
git_buf_rtruncate_at_char(&ti->path, '/');
|
242
|
+
ti->path_has_filename = false;
|
243
|
+
}
|
244
|
+
|
245
|
+
while (ti->stack != NULL) {
|
246
|
+
te = git_tree_entry_byindex(ti->stack->tree, ++ti->stack->index);
|
247
|
+
if (te != NULL)
|
248
|
+
break;
|
249
|
+
|
250
|
+
tree_iterator__pop_frame(ti);
|
251
|
+
|
252
|
+
git_buf_rtruncate_at_char(&ti->path, '/');
|
253
|
+
}
|
254
|
+
|
255
|
+
if (te && git_tree_entry__is_tree(te))
|
256
|
+
error = tree_iterator__expand_tree(ti);
|
257
|
+
|
258
|
+
if (!error)
|
259
|
+
error = tree_iterator__current(self, entry);
|
260
|
+
|
261
|
+
return error;
|
262
|
+
}
|
263
|
+
|
264
|
+
static int tree_iterator__seek(git_iterator *self, const char *prefix)
|
265
|
+
{
|
266
|
+
GIT_UNUSED(self);
|
267
|
+
GIT_UNUSED(prefix);
|
268
|
+
/* pop stack until matches prefix */
|
269
|
+
/* seek item in current frame matching prefix */
|
270
|
+
/* push stack which matches prefix */
|
271
|
+
return -1;
|
272
|
+
}
|
273
|
+
|
274
|
+
static void tree_iterator__free(git_iterator *self)
|
275
|
+
{
|
276
|
+
tree_iterator *ti = (tree_iterator *)self;
|
277
|
+
while (ti->stack != NULL)
|
278
|
+
tree_iterator__pop_frame(ti);
|
279
|
+
git_buf_free(&ti->path);
|
280
|
+
}
|
281
|
+
|
282
|
+
static int tree_iterator__reset(git_iterator *self)
|
283
|
+
{
|
284
|
+
tree_iterator *ti = (tree_iterator *)self;
|
285
|
+
|
286
|
+
while (ti->stack && ti->stack->next)
|
287
|
+
tree_iterator__pop_frame(ti);
|
288
|
+
|
289
|
+
if (ti->stack)
|
290
|
+
ti->stack->index =
|
291
|
+
git_tree__prefix_position(ti->stack->tree, ti->base.start);
|
292
|
+
|
293
|
+
git_buf_clear(&ti->path);
|
294
|
+
|
295
|
+
return tree_iterator__expand_tree(ti);
|
296
|
+
}
|
297
|
+
|
298
|
+
int git_iterator_for_tree_range(
|
299
|
+
git_iterator **iter,
|
300
|
+
git_repository *repo,
|
301
|
+
git_tree *tree,
|
302
|
+
const char *start,
|
303
|
+
const char *end)
|
304
|
+
{
|
305
|
+
int error;
|
306
|
+
tree_iterator *ti;
|
307
|
+
|
308
|
+
if (tree == NULL)
|
309
|
+
return git_iterator_for_nothing(iter);
|
310
|
+
|
311
|
+
ITERATOR_BASE_INIT(ti, tree, TREE);
|
312
|
+
|
313
|
+
ti->repo = repo;
|
314
|
+
ti->stack = tree_iterator__alloc_frame(tree, ti->base.start);
|
315
|
+
|
316
|
+
if ((error = tree_iterator__expand_tree(ti)) < 0)
|
317
|
+
git_iterator_free((git_iterator *)ti);
|
318
|
+
else
|
319
|
+
*iter = (git_iterator *)ti;
|
320
|
+
|
321
|
+
return error;
|
322
|
+
}
|
323
|
+
|
324
|
+
|
325
|
+
typedef struct {
|
326
|
+
git_iterator base;
|
327
|
+
git_index *index;
|
328
|
+
unsigned int current;
|
329
|
+
} index_iterator;
|
330
|
+
|
331
|
+
static int index_iterator__current(
|
332
|
+
git_iterator *self, const git_index_entry **entry)
|
333
|
+
{
|
334
|
+
index_iterator *ii = (index_iterator *)self;
|
335
|
+
git_index_entry *ie = git_index_get(ii->index, ii->current);
|
336
|
+
|
337
|
+
if (ie != NULL &&
|
338
|
+
ii->base.end != NULL &&
|
339
|
+
git__prefixcmp(ie->path, ii->base.end) > 0)
|
340
|
+
{
|
341
|
+
ii->current = git_index_entrycount(ii->index);
|
342
|
+
ie = NULL;
|
343
|
+
}
|
344
|
+
|
345
|
+
if (entry)
|
346
|
+
*entry = ie;
|
347
|
+
|
348
|
+
return 0;
|
349
|
+
}
|
350
|
+
|
351
|
+
static int index_iterator__at_end(git_iterator *self)
|
352
|
+
{
|
353
|
+
index_iterator *ii = (index_iterator *)self;
|
354
|
+
return (ii->current >= git_index_entrycount(ii->index));
|
355
|
+
}
|
356
|
+
|
357
|
+
static int index_iterator__advance(
|
358
|
+
git_iterator *self, const git_index_entry **entry)
|
359
|
+
{
|
360
|
+
index_iterator *ii = (index_iterator *)self;
|
361
|
+
|
362
|
+
if (ii->current < git_index_entrycount(ii->index))
|
363
|
+
ii->current++;
|
364
|
+
|
365
|
+
return index_iterator__current(self, entry);
|
366
|
+
}
|
367
|
+
|
368
|
+
static int index_iterator__seek(git_iterator *self, const char *prefix)
|
369
|
+
{
|
370
|
+
GIT_UNUSED(self);
|
371
|
+
GIT_UNUSED(prefix);
|
372
|
+
/* find last item before prefix */
|
373
|
+
return -1;
|
374
|
+
}
|
375
|
+
|
376
|
+
static int index_iterator__reset(git_iterator *self)
|
377
|
+
{
|
378
|
+
index_iterator *ii = (index_iterator *)self;
|
379
|
+
ii->current = 0;
|
380
|
+
return 0;
|
381
|
+
}
|
382
|
+
|
383
|
+
static void index_iterator__free(git_iterator *self)
|
384
|
+
{
|
385
|
+
index_iterator *ii = (index_iterator *)self;
|
386
|
+
git_index_free(ii->index);
|
387
|
+
ii->index = NULL;
|
388
|
+
}
|
389
|
+
|
390
|
+
int git_iterator_for_index_range(
|
391
|
+
git_iterator **iter,
|
392
|
+
git_repository *repo,
|
393
|
+
const char *start,
|
394
|
+
const char *end)
|
395
|
+
{
|
396
|
+
int error;
|
397
|
+
index_iterator *ii;
|
398
|
+
|
399
|
+
ITERATOR_BASE_INIT(ii, index, INDEX);
|
400
|
+
|
401
|
+
if ((error = git_repository_index(&ii->index, repo)) < 0)
|
402
|
+
git__free(ii);
|
403
|
+
else {
|
404
|
+
ii->current = start ? git_index__prefix_position(ii->index, start) : 0;
|
405
|
+
*iter = (git_iterator *)ii;
|
406
|
+
}
|
407
|
+
|
408
|
+
return error;
|
409
|
+
}
|
410
|
+
|
411
|
+
|
412
|
+
typedef struct workdir_iterator_frame workdir_iterator_frame;
|
413
|
+
struct workdir_iterator_frame {
|
414
|
+
workdir_iterator_frame *next;
|
415
|
+
git_vector entries;
|
416
|
+
unsigned int index;
|
417
|
+
char *start;
|
418
|
+
};
|
419
|
+
|
420
|
+
typedef struct {
|
421
|
+
git_iterator base;
|
422
|
+
git_repository *repo;
|
423
|
+
size_t root_len;
|
424
|
+
workdir_iterator_frame *stack;
|
425
|
+
git_ignores ignores;
|
426
|
+
git_index_entry entry;
|
427
|
+
git_buf path;
|
428
|
+
int is_ignored;
|
429
|
+
} workdir_iterator;
|
430
|
+
|
431
|
+
static workdir_iterator_frame *workdir_iterator__alloc_frame(void)
|
432
|
+
{
|
433
|
+
workdir_iterator_frame *wf = git__calloc(1, sizeof(workdir_iterator_frame));
|
434
|
+
if (wf == NULL)
|
435
|
+
return NULL;
|
436
|
+
if (git_vector_init(&wf->entries, 0, git_path_with_stat_cmp) != 0) {
|
437
|
+
git__free(wf);
|
438
|
+
return NULL;
|
439
|
+
}
|
440
|
+
return wf;
|
441
|
+
}
|
442
|
+
|
443
|
+
static void workdir_iterator__free_frame(workdir_iterator_frame *wf)
|
444
|
+
{
|
445
|
+
unsigned int i;
|
446
|
+
git_path_with_stat *path;
|
447
|
+
|
448
|
+
git_vector_foreach(&wf->entries, i, path)
|
449
|
+
git__free(path);
|
450
|
+
git_vector_free(&wf->entries);
|
451
|
+
git__free(wf);
|
452
|
+
}
|
453
|
+
|
454
|
+
static int workdir_iterator__update_entry(workdir_iterator *wi);
|
455
|
+
|
456
|
+
static int workdir_iterator__entry_cmp(const void *prefix, const void *item)
|
457
|
+
{
|
458
|
+
const git_path_with_stat *ps = item;
|
459
|
+
return git__prefixcmp((const char *)prefix, ps->path);
|
460
|
+
}
|
461
|
+
|
462
|
+
static int workdir_iterator__expand_dir(workdir_iterator *wi)
|
463
|
+
{
|
464
|
+
int error;
|
465
|
+
workdir_iterator_frame *wf = workdir_iterator__alloc_frame();
|
466
|
+
GITERR_CHECK_ALLOC(wf);
|
467
|
+
|
468
|
+
error = git_path_dirload_with_stat(wi->path.ptr, wi->root_len, &wf->entries);
|
469
|
+
if (error < 0 || wf->entries.length == 0) {
|
470
|
+
workdir_iterator__free_frame(wf);
|
471
|
+
return GIT_ENOTFOUND;
|
472
|
+
}
|
473
|
+
|
474
|
+
git_vector_sort(&wf->entries);
|
475
|
+
|
476
|
+
if (!wi->stack)
|
477
|
+
wf->start = wi->base.start;
|
478
|
+
else if (wi->stack->start &&
|
479
|
+
git__prefixcmp(wi->stack->start, wi->path.ptr + wi->root_len) == 0)
|
480
|
+
wf->start = wi->stack->start;
|
481
|
+
|
482
|
+
if (wf->start)
|
483
|
+
git_vector_bsearch3(
|
484
|
+
&wf->index, &wf->entries, workdir_iterator__entry_cmp, wf->start);
|
485
|
+
|
486
|
+
wf->next = wi->stack;
|
487
|
+
wi->stack = wf;
|
488
|
+
|
489
|
+
/* only push new ignores if this is not top level directory */
|
490
|
+
if (wi->stack->next != NULL) {
|
491
|
+
ssize_t slash_pos = git_buf_rfind_next(&wi->path, '/');
|
492
|
+
(void)git_ignore__push_dir(&wi->ignores, &wi->path.ptr[slash_pos + 1]);
|
493
|
+
}
|
494
|
+
|
495
|
+
return workdir_iterator__update_entry(wi);
|
496
|
+
}
|
497
|
+
|
498
|
+
static int workdir_iterator__current(
|
499
|
+
git_iterator *self, const git_index_entry **entry)
|
500
|
+
{
|
501
|
+
workdir_iterator *wi = (workdir_iterator *)self;
|
502
|
+
*entry = (wi->entry.path == NULL) ? NULL : &wi->entry;
|
503
|
+
return 0;
|
504
|
+
}
|
505
|
+
|
506
|
+
static int workdir_iterator__at_end(git_iterator *self)
|
507
|
+
{
|
508
|
+
return (((workdir_iterator *)self)->entry.path == NULL);
|
509
|
+
}
|
510
|
+
|
511
|
+
static int workdir_iterator__advance(
|
512
|
+
git_iterator *self, const git_index_entry **entry)
|
513
|
+
{
|
514
|
+
int error;
|
515
|
+
workdir_iterator *wi = (workdir_iterator *)self;
|
516
|
+
workdir_iterator_frame *wf;
|
517
|
+
git_path_with_stat *next;
|
518
|
+
|
519
|
+
if (entry != NULL)
|
520
|
+
*entry = NULL;
|
521
|
+
|
522
|
+
if (wi->entry.path == NULL)
|
523
|
+
return 0;
|
524
|
+
|
525
|
+
while ((wf = wi->stack) != NULL) {
|
526
|
+
next = git_vector_get(&wf->entries, ++wf->index);
|
527
|
+
if (next != NULL) {
|
528
|
+
if (strcmp(next->path, DOT_GIT "/") == 0)
|
529
|
+
continue;
|
530
|
+
/* else found a good entry */
|
531
|
+
break;
|
532
|
+
}
|
533
|
+
|
534
|
+
/* pop workdir directory stack */
|
535
|
+
wi->stack = wf->next;
|
536
|
+
workdir_iterator__free_frame(wf);
|
537
|
+
git_ignore__pop_dir(&wi->ignores);
|
538
|
+
|
539
|
+
if (wi->stack == NULL) {
|
540
|
+
memset(&wi->entry, 0, sizeof(wi->entry));
|
541
|
+
return 0;
|
542
|
+
}
|
543
|
+
}
|
544
|
+
|
545
|
+
error = workdir_iterator__update_entry(wi);
|
546
|
+
|
547
|
+
if (!error && entry != NULL)
|
548
|
+
error = workdir_iterator__current(self, entry);
|
549
|
+
|
550
|
+
return error;
|
551
|
+
}
|
552
|
+
|
553
|
+
static int workdir_iterator__seek(git_iterator *self, const char *prefix)
|
554
|
+
{
|
555
|
+
GIT_UNUSED(self);
|
556
|
+
GIT_UNUSED(prefix);
|
557
|
+
/* pop stack until matching prefix */
|
558
|
+
/* find prefix item in current frame */
|
559
|
+
/* push subdirectories as deep as possible while matching */
|
560
|
+
return 0;
|
561
|
+
}
|
562
|
+
|
563
|
+
static int workdir_iterator__reset(git_iterator *self)
|
564
|
+
{
|
565
|
+
workdir_iterator *wi = (workdir_iterator *)self;
|
566
|
+
while (wi->stack != NULL && wi->stack->next != NULL) {
|
567
|
+
workdir_iterator_frame *wf = wi->stack;
|
568
|
+
wi->stack = wf->next;
|
569
|
+
workdir_iterator__free_frame(wf);
|
570
|
+
git_ignore__pop_dir(&wi->ignores);
|
571
|
+
}
|
572
|
+
if (wi->stack)
|
573
|
+
wi->stack->index = 0;
|
574
|
+
return 0;
|
575
|
+
}
|
576
|
+
|
577
|
+
static void workdir_iterator__free(git_iterator *self)
|
578
|
+
{
|
579
|
+
workdir_iterator *wi = (workdir_iterator *)self;
|
580
|
+
|
581
|
+
while (wi->stack != NULL) {
|
582
|
+
workdir_iterator_frame *wf = wi->stack;
|
583
|
+
wi->stack = wf->next;
|
584
|
+
workdir_iterator__free_frame(wf);
|
585
|
+
}
|
586
|
+
|
587
|
+
git_ignore__free(&wi->ignores);
|
588
|
+
git_buf_free(&wi->path);
|
589
|
+
}
|
590
|
+
|
591
|
+
static int workdir_iterator__update_entry(workdir_iterator *wi)
|
592
|
+
{
|
593
|
+
git_path_with_stat *ps = git_vector_get(&wi->stack->entries, wi->stack->index);
|
594
|
+
|
595
|
+
git_buf_truncate(&wi->path, wi->root_len);
|
596
|
+
memset(&wi->entry, 0, sizeof(wi->entry));
|
597
|
+
|
598
|
+
if (!ps)
|
599
|
+
return 0;
|
600
|
+
|
601
|
+
if (git_buf_put(&wi->path, ps->path, ps->path_len) < 0)
|
602
|
+
return -1;
|
603
|
+
|
604
|
+
if (wi->base.end &&
|
605
|
+
git__prefixcmp(wi->path.ptr + wi->root_len, wi->base.end) > 0)
|
606
|
+
return 0;
|
607
|
+
|
608
|
+
wi->entry.path = ps->path;
|
609
|
+
|
610
|
+
/* skip over .git directory */
|
611
|
+
if (strcmp(ps->path, DOT_GIT "/") == 0)
|
612
|
+
return workdir_iterator__advance((git_iterator *)wi, NULL);
|
613
|
+
|
614
|
+
/* if there is an error processing the entry, treat as ignored */
|
615
|
+
wi->is_ignored = 1;
|
616
|
+
|
617
|
+
git_index__init_entry_from_stat(&ps->st, &wi->entry);
|
618
|
+
|
619
|
+
/* need different mode here to keep directories during iteration */
|
620
|
+
wi->entry.mode = git_futils_canonical_mode(ps->st.st_mode);
|
621
|
+
|
622
|
+
/* if this is a file type we don't handle, treat as ignored */
|
623
|
+
if (wi->entry.mode == 0)
|
624
|
+
return 0;
|
625
|
+
|
626
|
+
/* okay, we are far enough along to look up real ignore rule */
|
627
|
+
if (git_ignore__lookup(&wi->ignores, wi->entry.path, &wi->is_ignored) < 0)
|
628
|
+
return 0; /* if error, ignore it and ignore file */
|
629
|
+
|
630
|
+
/* detect submodules */
|
631
|
+
if (S_ISDIR(wi->entry.mode)) {
|
632
|
+
bool is_submodule = git_path_contains(&wi->path, DOT_GIT);
|
633
|
+
|
634
|
+
/* if there is no .git, still check submodules data */
|
635
|
+
if (!is_submodule) {
|
636
|
+
int res = git_submodule_lookup(NULL, wi->repo, wi->entry.path);
|
637
|
+
is_submodule = (res == 0);
|
638
|
+
if (res == GIT_ENOTFOUND)
|
639
|
+
giterr_clear();
|
640
|
+
}
|
641
|
+
|
642
|
+
/* if submodule, mark as GITLINK and remove trailing slash */
|
643
|
+
if (is_submodule) {
|
644
|
+
size_t len = strlen(wi->entry.path);
|
645
|
+
assert(wi->entry.path[len - 1] == '/');
|
646
|
+
wi->entry.path[len - 1] = '\0';
|
647
|
+
wi->entry.mode = S_IFGITLINK;
|
648
|
+
}
|
649
|
+
}
|
650
|
+
|
651
|
+
return 0;
|
652
|
+
}
|
653
|
+
|
654
|
+
int git_iterator_for_workdir_range(
|
655
|
+
git_iterator **iter,
|
656
|
+
git_repository *repo,
|
657
|
+
const char *start,
|
658
|
+
const char *end)
|
659
|
+
{
|
660
|
+
int error;
|
661
|
+
workdir_iterator *wi;
|
662
|
+
|
663
|
+
assert(iter && repo);
|
664
|
+
|
665
|
+
if (git_repository_is_bare(repo)) {
|
666
|
+
giterr_set(GITERR_INVALID,
|
667
|
+
"Cannot scan working directory for bare repo");
|
668
|
+
return -1;
|
669
|
+
}
|
670
|
+
|
671
|
+
ITERATOR_BASE_INIT(wi, workdir, WORKDIR);
|
672
|
+
|
673
|
+
wi->repo = repo;
|
674
|
+
|
675
|
+
if (git_buf_sets(&wi->path, git_repository_workdir(repo)) < 0 ||
|
676
|
+
git_path_to_dir(&wi->path) < 0 ||
|
677
|
+
git_ignore__for_path(repo, "", &wi->ignores) < 0)
|
678
|
+
{
|
679
|
+
git__free(wi);
|
680
|
+
return -1;
|
681
|
+
}
|
682
|
+
|
683
|
+
wi->root_len = wi->path.size;
|
684
|
+
|
685
|
+
if ((error = workdir_iterator__expand_dir(wi)) < 0) {
|
686
|
+
if (error == GIT_ENOTFOUND)
|
687
|
+
error = 0;
|
688
|
+
else {
|
689
|
+
git_iterator_free((git_iterator *)wi);
|
690
|
+
wi = NULL;
|
691
|
+
}
|
692
|
+
}
|
693
|
+
|
694
|
+
*iter = (git_iterator *)wi;
|
695
|
+
|
696
|
+
return error;
|
697
|
+
}
|
698
|
+
|
699
|
+
|
700
|
+
int git_iterator_current_tree_entry(
|
701
|
+
git_iterator *iter, const git_tree_entry **tree_entry)
|
702
|
+
{
|
703
|
+
*tree_entry = (iter->type != GIT_ITERATOR_TREE) ? NULL :
|
704
|
+
tree_iterator__tree_entry((tree_iterator *)iter);
|
705
|
+
return 0;
|
706
|
+
}
|
707
|
+
|
708
|
+
int git_iterator_current_is_ignored(git_iterator *iter)
|
709
|
+
{
|
710
|
+
return (iter->type != GIT_ITERATOR_WORKDIR) ? 0 :
|
711
|
+
((workdir_iterator *)iter)->is_ignored;
|
712
|
+
}
|
713
|
+
|
714
|
+
int git_iterator_advance_into_directory(
|
715
|
+
git_iterator *iter, const git_index_entry **entry)
|
716
|
+
{
|
717
|
+
workdir_iterator *wi = (workdir_iterator *)iter;
|
718
|
+
|
719
|
+
if (iter->type == GIT_ITERATOR_WORKDIR &&
|
720
|
+
wi->entry.path &&
|
721
|
+
S_ISDIR(wi->entry.mode) &&
|
722
|
+
!S_ISGITLINK(wi->entry.mode))
|
723
|
+
{
|
724
|
+
if (workdir_iterator__expand_dir(wi) < 0)
|
725
|
+
/* if error loading or if empty, skip the directory. */
|
726
|
+
return workdir_iterator__advance(iter, entry);
|
727
|
+
}
|
728
|
+
|
729
|
+
return entry ? git_iterator_current(iter, entry) : 0;
|
730
|
+
}
|
731
|
+
|
732
|
+
int git_iterator_cmp(
|
733
|
+
git_iterator *iter, const char *path_prefix)
|
734
|
+
{
|
735
|
+
const git_index_entry *entry;
|
736
|
+
|
737
|
+
/* a "done" iterator is after every prefix */
|
738
|
+
if (git_iterator_current(iter, &entry) < 0 ||
|
739
|
+
entry == NULL)
|
740
|
+
return 1;
|
741
|
+
|
742
|
+
/* a NULL prefix is after any valid iterator */
|
743
|
+
if (!path_prefix)
|
744
|
+
return -1;
|
745
|
+
|
746
|
+
return git__prefixcmp(entry->path, path_prefix);
|
747
|
+
}
|
748
|
+
|