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.
|
@@ -8,10 +8,21 @@
|
|
8
8
|
#include "common.h"
|
9
9
|
#include "commit.h"
|
10
10
|
#include "odb.h"
|
11
|
-
#include "hashtable.h"
|
12
11
|
#include "pqueue.h"
|
12
|
+
#include "pool.h"
|
13
|
+
#include "oidmap.h"
|
13
14
|
|
14
15
|
#include "git2/revwalk.h"
|
16
|
+
#include "git2/merge.h"
|
17
|
+
|
18
|
+
#include <regex.h>
|
19
|
+
|
20
|
+
GIT__USE_OIDMAP;
|
21
|
+
|
22
|
+
#define PARENT1 (1 << 0)
|
23
|
+
#define PARENT2 (1 << 1)
|
24
|
+
#define RESULT (1 << 2)
|
25
|
+
#define STALE (1 << 3)
|
15
26
|
|
16
27
|
typedef struct commit_object {
|
17
28
|
git_oid oid;
|
@@ -19,7 +30,8 @@ typedef struct commit_object {
|
|
19
30
|
unsigned int seen:1,
|
20
31
|
uninteresting:1,
|
21
32
|
topo_delay:1,
|
22
|
-
parsed:1
|
33
|
+
parsed:1,
|
34
|
+
flags : 4;
|
23
35
|
|
24
36
|
unsigned short in_degree;
|
25
37
|
unsigned short out_degree;
|
@@ -36,7 +48,8 @@ struct git_revwalk {
|
|
36
48
|
git_repository *repo;
|
37
49
|
git_odb *odb;
|
38
50
|
|
39
|
-
|
51
|
+
git_oidmap *commits;
|
52
|
+
git_pool commit_pool;
|
40
53
|
|
41
54
|
commit_list *iterator_topo;
|
42
55
|
commit_list *iterator_rand;
|
@@ -46,22 +59,47 @@ struct git_revwalk {
|
|
46
59
|
int (*get_next)(commit_object **, git_revwalk *);
|
47
60
|
int (*enqueue)(git_revwalk *, commit_object *);
|
48
61
|
|
49
|
-
git_vector memory_alloc;
|
50
|
-
size_t chunk_size;
|
51
|
-
|
52
62
|
unsigned walking:1;
|
53
63
|
unsigned int sorting;
|
64
|
+
|
65
|
+
/* merge base calculation */
|
66
|
+
commit_object *one;
|
67
|
+
git_vector twos;
|
54
68
|
};
|
55
69
|
|
70
|
+
static int commit_time_cmp(void *a, void *b)
|
71
|
+
{
|
72
|
+
commit_object *commit_a = (commit_object *)a;
|
73
|
+
commit_object *commit_b = (commit_object *)b;
|
74
|
+
|
75
|
+
return (commit_a->time < commit_b->time);
|
76
|
+
}
|
77
|
+
|
56
78
|
static commit_list *commit_list_insert(commit_object *item, commit_list **list_p)
|
57
79
|
{
|
58
80
|
commit_list *new_list = git__malloc(sizeof(commit_list));
|
59
|
-
new_list
|
60
|
-
|
81
|
+
if (new_list != NULL) {
|
82
|
+
new_list->item = item;
|
83
|
+
new_list->next = *list_p;
|
84
|
+
}
|
61
85
|
*list_p = new_list;
|
62
86
|
return new_list;
|
63
87
|
}
|
64
88
|
|
89
|
+
static commit_list *commit_list_insert_by_date(commit_object *item, commit_list **list_p)
|
90
|
+
{
|
91
|
+
commit_list **pp = list_p;
|
92
|
+
commit_list *p;
|
93
|
+
|
94
|
+
while ((p = *pp) != NULL) {
|
95
|
+
if (commit_time_cmp(p->item, item) < 0)
|
96
|
+
break;
|
97
|
+
|
98
|
+
pp = &p->next;
|
99
|
+
}
|
100
|
+
|
101
|
+
return commit_list_insert(item, pp);
|
102
|
+
}
|
65
103
|
static void commit_list_free(commit_list **list_p)
|
66
104
|
{
|
67
105
|
commit_list *list = *list_p;
|
@@ -87,68 +125,36 @@ static commit_object *commit_list_pop(commit_list **stack)
|
|
87
125
|
return item;
|
88
126
|
}
|
89
127
|
|
90
|
-
|
91
|
-
|
92
|
-
commit_object *
|
93
|
-
commit_object *commit_b = (commit_object *)b;
|
94
|
-
|
95
|
-
return (commit_a->time < commit_b->time);
|
96
|
-
}
|
97
|
-
|
98
|
-
static uint32_t object_table_hash(const void *key, int hash_id)
|
99
|
-
{
|
100
|
-
uint32_t r;
|
101
|
-
const git_oid *id = key;
|
102
|
-
|
103
|
-
memcpy(&r, id->id + (hash_id * sizeof(uint32_t)), sizeof(r));
|
104
|
-
return r;
|
105
|
-
}
|
106
|
-
|
107
|
-
#define COMMITS_PER_CHUNK 128
|
108
|
-
#define CHUNK_STEP 64
|
109
|
-
#define PARENTS_PER_COMMIT ((CHUNK_STEP - sizeof(commit_object)) / sizeof(commit_object *))
|
110
|
-
|
111
|
-
static int alloc_chunk(git_revwalk *walk)
|
112
|
-
{
|
113
|
-
void *chunk;
|
114
|
-
|
115
|
-
chunk = git__calloc(COMMITS_PER_CHUNK, CHUNK_STEP);
|
116
|
-
if (chunk == NULL)
|
117
|
-
return GIT_ENOMEM;
|
118
|
-
|
119
|
-
walk->chunk_size = 0;
|
120
|
-
return git_vector_insert(&walk->memory_alloc, chunk);
|
121
|
-
}
|
128
|
+
#define PARENTS_PER_COMMIT 2
|
129
|
+
#define COMMIT_ALLOC \
|
130
|
+
(sizeof(commit_object) + PARENTS_PER_COMMIT * sizeof(commit_object *))
|
122
131
|
|
123
132
|
static commit_object *alloc_commit(git_revwalk *walk)
|
124
133
|
{
|
125
|
-
|
126
|
-
|
127
|
-
if (walk->chunk_size == COMMITS_PER_CHUNK)
|
128
|
-
alloc_chunk(walk);
|
129
|
-
|
130
|
-
chunk = git_vector_get(&walk->memory_alloc, walk->memory_alloc.length - 1);
|
131
|
-
chunk += (walk->chunk_size * CHUNK_STEP);
|
132
|
-
walk->chunk_size++;
|
133
|
-
|
134
|
-
return (commit_object *)chunk;
|
134
|
+
return (commit_object *)git_pool_malloc(&walk->commit_pool, COMMIT_ALLOC);
|
135
135
|
}
|
136
136
|
|
137
|
-
static commit_object **alloc_parents(
|
137
|
+
static commit_object **alloc_parents(
|
138
|
+
git_revwalk *walk, commit_object *commit, size_t n_parents)
|
138
139
|
{
|
139
140
|
if (n_parents <= PARENTS_PER_COMMIT)
|
140
|
-
return (commit_object **)((
|
141
|
+
return (commit_object **)((char *)commit + sizeof(commit_object));
|
141
142
|
|
142
|
-
return
|
143
|
+
return (commit_object **)git_pool_malloc(
|
144
|
+
&walk->commit_pool, (uint32_t)(n_parents * sizeof(commit_object *)));
|
143
145
|
}
|
144
146
|
|
145
147
|
|
146
148
|
static commit_object *commit_lookup(git_revwalk *walk, const git_oid *oid)
|
147
149
|
{
|
148
150
|
commit_object *commit;
|
151
|
+
khiter_t pos;
|
152
|
+
int ret;
|
149
153
|
|
150
|
-
|
151
|
-
|
154
|
+
/* lookup and reserve space if not already present */
|
155
|
+
pos = kh_get(oid, walk->commits, oid);
|
156
|
+
if (pos != kh_end(walk->commits))
|
157
|
+
return kh_value(walk->commits, pos);
|
152
158
|
|
153
159
|
commit = alloc_commit(walk);
|
154
160
|
if (commit == NULL)
|
@@ -156,17 +162,16 @@ static commit_object *commit_lookup(git_revwalk *walk, const git_oid *oid)
|
|
156
162
|
|
157
163
|
git_oid_cpy(&commit->oid, oid);
|
158
164
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
}
|
165
|
+
pos = kh_put(oid, walk->commits, &commit->oid, &ret);
|
166
|
+
assert(ret != 0);
|
167
|
+
kh_value(walk->commits, pos) = commit;
|
163
168
|
|
164
169
|
return commit;
|
165
170
|
}
|
166
171
|
|
167
172
|
static int commit_quick_parse(git_revwalk *walk, commit_object *commit, git_rawobj *raw)
|
168
173
|
{
|
169
|
-
const
|
174
|
+
const size_t parent_len = strlen("parent ") + GIT_OID_HEXSZ + 1;
|
170
175
|
|
171
176
|
unsigned char *buffer = raw->data;
|
172
177
|
unsigned char *buffer_end = buffer + raw->len;
|
@@ -183,39 +188,44 @@ static int commit_quick_parse(git_revwalk *walk, commit_object *commit, git_rawo
|
|
183
188
|
buffer += parent_len;
|
184
189
|
}
|
185
190
|
|
186
|
-
commit->parents = alloc_parents(commit, parents);
|
187
|
-
|
188
|
-
return GIT_ENOMEM;
|
191
|
+
commit->parents = alloc_parents(walk, commit, parents);
|
192
|
+
GITERR_CHECK_ALLOC(commit->parents);
|
189
193
|
|
190
194
|
buffer = parents_start;
|
191
195
|
for (i = 0; i < parents; ++i) {
|
192
196
|
git_oid oid;
|
193
197
|
|
194
|
-
if (git_oid_fromstr(&oid, (char *)buffer + strlen("parent ")) <
|
195
|
-
return
|
198
|
+
if (git_oid_fromstr(&oid, (char *)buffer + strlen("parent ")) < 0)
|
199
|
+
return -1;
|
196
200
|
|
197
201
|
commit->parents[i] = commit_lookup(walk, &oid);
|
198
202
|
if (commit->parents[i] == NULL)
|
199
|
-
return
|
203
|
+
return -1;
|
200
204
|
|
201
205
|
buffer += parent_len;
|
202
206
|
}
|
203
207
|
|
204
208
|
commit->out_degree = (unsigned short)parents;
|
205
209
|
|
206
|
-
if ((buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL)
|
207
|
-
|
210
|
+
if ((buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL) {
|
211
|
+
giterr_set(GITERR_ODB, "Failed to parse commit. Object is corrupted");
|
212
|
+
return -1;
|
213
|
+
}
|
208
214
|
|
209
215
|
buffer = memchr(buffer, '>', buffer_end - buffer);
|
210
|
-
if (buffer == NULL)
|
211
|
-
|
216
|
+
if (buffer == NULL) {
|
217
|
+
giterr_set(GITERR_ODB, "Failed to parse commit. Can't find author");
|
218
|
+
return -1;
|
219
|
+
}
|
212
220
|
|
213
|
-
if (git__strtol32(&commit_time, (char *)buffer + 2, NULL, 10) <
|
214
|
-
|
221
|
+
if (git__strtol32(&commit_time, (char *)buffer + 2, NULL, 10) < 0) {
|
222
|
+
giterr_set(GITERR_ODB, "Failed to parse commit. Can't parse commit time");
|
223
|
+
return -1;
|
224
|
+
}
|
215
225
|
|
216
226
|
commit->time = (time_t)commit_time;
|
217
227
|
commit->parsed = 1;
|
218
|
-
return
|
228
|
+
return 0;
|
219
229
|
}
|
220
230
|
|
221
231
|
static int commit_parse(git_revwalk *walk, commit_object *commit)
|
@@ -224,19 +234,159 @@ static int commit_parse(git_revwalk *walk, commit_object *commit)
|
|
224
234
|
int error;
|
225
235
|
|
226
236
|
if (commit->parsed)
|
227
|
-
return
|
237
|
+
return 0;
|
228
238
|
|
229
|
-
if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) <
|
230
|
-
return
|
239
|
+
if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0)
|
240
|
+
return error;
|
231
241
|
|
232
242
|
if (obj->raw.type != GIT_OBJ_COMMIT) {
|
233
243
|
git_odb_object_free(obj);
|
234
|
-
|
244
|
+
giterr_set(GITERR_INVALID, "Failed to parse commit. Object is no commit object");
|
245
|
+
return -1;
|
235
246
|
}
|
236
247
|
|
237
248
|
error = commit_quick_parse(walk, commit, &obj->raw);
|
238
249
|
git_odb_object_free(obj);
|
239
|
-
return error
|
250
|
+
return error;
|
251
|
+
}
|
252
|
+
|
253
|
+
static int interesting(git_pqueue *list)
|
254
|
+
{
|
255
|
+
unsigned int i;
|
256
|
+
for (i = 1; i < git_pqueue_size(list); i++) {
|
257
|
+
commit_object *commit = list->d[i];
|
258
|
+
if ((commit->flags & STALE) == 0)
|
259
|
+
return 1;
|
260
|
+
}
|
261
|
+
|
262
|
+
return 0;
|
263
|
+
}
|
264
|
+
|
265
|
+
static int merge_bases_many(commit_list **out, git_revwalk *walk, commit_object *one, git_vector *twos)
|
266
|
+
{
|
267
|
+
int error;
|
268
|
+
unsigned int i;
|
269
|
+
commit_object *two;
|
270
|
+
commit_list *result = NULL, *tmp = NULL;
|
271
|
+
git_pqueue list;
|
272
|
+
|
273
|
+
/* if the commit is repeated, we have a our merge base already */
|
274
|
+
git_vector_foreach(twos, i, two) {
|
275
|
+
if (one == two)
|
276
|
+
return commit_list_insert(one, out) ? 0 : -1;
|
277
|
+
}
|
278
|
+
|
279
|
+
if (git_pqueue_init(&list, twos->length * 2, commit_time_cmp) < 0)
|
280
|
+
return -1;
|
281
|
+
|
282
|
+
if (commit_parse(walk, one) < 0)
|
283
|
+
return -1;
|
284
|
+
|
285
|
+
one->flags |= PARENT1;
|
286
|
+
if (git_pqueue_insert(&list, one) < 0)
|
287
|
+
return -1;
|
288
|
+
|
289
|
+
git_vector_foreach(twos, i, two) {
|
290
|
+
commit_parse(walk, two);
|
291
|
+
two->flags |= PARENT2;
|
292
|
+
if (git_pqueue_insert(&list, two) < 0)
|
293
|
+
return -1;
|
294
|
+
}
|
295
|
+
|
296
|
+
/* as long as there are non-STALE commits */
|
297
|
+
while (interesting(&list)) {
|
298
|
+
commit_object *commit;
|
299
|
+
int flags;
|
300
|
+
|
301
|
+
commit = git_pqueue_pop(&list);
|
302
|
+
|
303
|
+
flags = commit->flags & (PARENT1 | PARENT2 | STALE);
|
304
|
+
if (flags == (PARENT1 | PARENT2)) {
|
305
|
+
if (!(commit->flags & RESULT)) {
|
306
|
+
commit->flags |= RESULT;
|
307
|
+
if (commit_list_insert(commit, &result) == NULL)
|
308
|
+
return -1;
|
309
|
+
}
|
310
|
+
/* we mark the parents of a merge stale */
|
311
|
+
flags |= STALE;
|
312
|
+
}
|
313
|
+
|
314
|
+
for (i = 0; i < commit->out_degree; i++) {
|
315
|
+
commit_object *p = commit->parents[i];
|
316
|
+
if ((p->flags & flags) == flags)
|
317
|
+
continue;
|
318
|
+
|
319
|
+
if ((error = commit_parse(walk, p)) < 0)
|
320
|
+
return error;
|
321
|
+
|
322
|
+
p->flags |= flags;
|
323
|
+
if (git_pqueue_insert(&list, p) < 0)
|
324
|
+
return -1;
|
325
|
+
}
|
326
|
+
}
|
327
|
+
|
328
|
+
git_pqueue_free(&list);
|
329
|
+
|
330
|
+
/* filter out any stale commits in the results */
|
331
|
+
tmp = result;
|
332
|
+
result = NULL;
|
333
|
+
|
334
|
+
while (tmp) {
|
335
|
+
struct commit_list *next = tmp->next;
|
336
|
+
if (!(tmp->item->flags & STALE))
|
337
|
+
if (commit_list_insert_by_date(tmp->item, &result) == NULL)
|
338
|
+
return -1;
|
339
|
+
|
340
|
+
git__free(tmp);
|
341
|
+
tmp = next;
|
342
|
+
}
|
343
|
+
|
344
|
+
*out = result;
|
345
|
+
return 0;
|
346
|
+
}
|
347
|
+
|
348
|
+
int git_merge_base(git_oid *out, git_repository *repo, git_oid *one, git_oid *two)
|
349
|
+
{
|
350
|
+
git_revwalk *walk;
|
351
|
+
git_vector list;
|
352
|
+
commit_list *result = NULL;
|
353
|
+
commit_object *commit;
|
354
|
+
void *contents[1];
|
355
|
+
|
356
|
+
if (git_revwalk_new(&walk, repo) < 0)
|
357
|
+
return -1;
|
358
|
+
|
359
|
+
commit = commit_lookup(walk, two);
|
360
|
+
if (commit == NULL)
|
361
|
+
goto on_error;
|
362
|
+
|
363
|
+
/* This is just one value, so we can do it on the stack */
|
364
|
+
memset(&list, 0x0, sizeof(git_vector));
|
365
|
+
contents[0] = commit;
|
366
|
+
list.length = 1;
|
367
|
+
list.contents = contents;
|
368
|
+
|
369
|
+
commit = commit_lookup(walk, one);
|
370
|
+
if (commit == NULL)
|
371
|
+
goto on_error;
|
372
|
+
|
373
|
+
if (merge_bases_many(&result, walk, commit, &list) < 0)
|
374
|
+
goto on_error;
|
375
|
+
|
376
|
+
if (!result) {
|
377
|
+
git_revwalk_free(walk);
|
378
|
+
return GIT_ENOTFOUND;
|
379
|
+
}
|
380
|
+
|
381
|
+
git_oid_cpy(out, &result->item->oid);
|
382
|
+
commit_list_free(&result);
|
383
|
+
git_revwalk_free(walk);
|
384
|
+
|
385
|
+
return 0;
|
386
|
+
|
387
|
+
on_error:
|
388
|
+
git_revwalk_free(walk);
|
389
|
+
return -1;
|
240
390
|
}
|
241
391
|
|
242
392
|
static void mark_uninteresting(commit_object *commit)
|
@@ -246,6 +396,10 @@ static void mark_uninteresting(commit_object *commit)
|
|
246
396
|
|
247
397
|
commit->uninteresting = 1;
|
248
398
|
|
399
|
+
/* This means we've reached a merge base, so there's no need to walk any more */
|
400
|
+
if ((commit->flags & (RESULT | STALE)) == RESULT)
|
401
|
+
return;
|
402
|
+
|
249
403
|
for (i = 0; i < commit->out_degree; ++i)
|
250
404
|
if (!commit->parents[i]->uninteresting)
|
251
405
|
mark_uninteresting(commit->parents[i]);
|
@@ -259,12 +413,12 @@ static int process_commit(git_revwalk *walk, commit_object *commit, int hide)
|
|
259
413
|
mark_uninteresting(commit);
|
260
414
|
|
261
415
|
if (commit->seen)
|
262
|
-
return
|
416
|
+
return 0;
|
263
417
|
|
264
418
|
commit->seen = 1;
|
265
419
|
|
266
|
-
if ((error = commit_parse(walk, commit)) <
|
267
|
-
|
420
|
+
if ((error = commit_parse(walk, commit)) < 0)
|
421
|
+
return error;
|
268
422
|
|
269
423
|
return walk->enqueue(walk, commit);
|
270
424
|
}
|
@@ -272,13 +426,12 @@ static int process_commit(git_revwalk *walk, commit_object *commit, int hide)
|
|
272
426
|
static int process_commit_parents(git_revwalk *walk, commit_object *commit)
|
273
427
|
{
|
274
428
|
unsigned short i;
|
275
|
-
int error =
|
429
|
+
int error = 0;
|
276
430
|
|
277
|
-
for (i = 0; i < commit->out_degree && error
|
431
|
+
for (i = 0; i < commit->out_degree && !error; ++i)
|
278
432
|
error = process_commit(walk, commit->parents[i], commit->uninteresting);
|
279
|
-
}
|
280
433
|
|
281
|
-
return error
|
434
|
+
return error;
|
282
435
|
}
|
283
436
|
|
284
437
|
static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting)
|
@@ -287,9 +440,17 @@ static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting)
|
|
287
440
|
|
288
441
|
commit = commit_lookup(walk, oid);
|
289
442
|
if (commit == NULL)
|
290
|
-
return
|
443
|
+
return -1; /* error already reported by failed lookup */
|
291
444
|
|
292
|
-
|
445
|
+
commit->uninteresting = uninteresting;
|
446
|
+
if (walk->one == NULL && !uninteresting) {
|
447
|
+
walk->one = commit;
|
448
|
+
} else {
|
449
|
+
if (git_vector_insert(&walk->twos, commit) < 0)
|
450
|
+
return -1;
|
451
|
+
}
|
452
|
+
|
453
|
+
return 0;
|
293
454
|
}
|
294
455
|
|
295
456
|
int git_revwalk_push(git_revwalk *walk, const git_oid *oid)
|
@@ -298,12 +459,122 @@ int git_revwalk_push(git_revwalk *walk, const git_oid *oid)
|
|
298
459
|
return push_commit(walk, oid, 0);
|
299
460
|
}
|
300
461
|
|
462
|
+
|
301
463
|
int git_revwalk_hide(git_revwalk *walk, const git_oid *oid)
|
302
464
|
{
|
303
465
|
assert(walk && oid);
|
304
466
|
return push_commit(walk, oid, 1);
|
305
467
|
}
|
306
468
|
|
469
|
+
static int push_ref(git_revwalk *walk, const char *refname, int hide)
|
470
|
+
{
|
471
|
+
git_oid oid;
|
472
|
+
|
473
|
+
if (git_reference_name_to_oid(&oid, walk->repo, refname) < 0)
|
474
|
+
return -1;
|
475
|
+
|
476
|
+
return push_commit(walk, &oid, hide);
|
477
|
+
}
|
478
|
+
|
479
|
+
struct push_cb_data {
|
480
|
+
git_revwalk *walk;
|
481
|
+
const char *glob;
|
482
|
+
int hide;
|
483
|
+
};
|
484
|
+
|
485
|
+
static int push_glob_cb(const char *refname, void *data_)
|
486
|
+
{
|
487
|
+
struct push_cb_data *data = (struct push_cb_data *)data_;
|
488
|
+
|
489
|
+
if (!p_fnmatch(data->glob, refname, 0))
|
490
|
+
return push_ref(data->walk, refname, data->hide);
|
491
|
+
|
492
|
+
return 0;
|
493
|
+
}
|
494
|
+
|
495
|
+
static int push_glob(git_revwalk *walk, const char *glob, int hide)
|
496
|
+
{
|
497
|
+
git_buf buf = GIT_BUF_INIT;
|
498
|
+
struct push_cb_data data;
|
499
|
+
regex_t preg;
|
500
|
+
|
501
|
+
assert(walk && glob);
|
502
|
+
|
503
|
+
/* refs/ is implied if not given in the glob */
|
504
|
+
if (strncmp(glob, GIT_REFS_DIR, strlen(GIT_REFS_DIR))) {
|
505
|
+
git_buf_printf(&buf, GIT_REFS_DIR "%s", glob);
|
506
|
+
} else {
|
507
|
+
git_buf_puts(&buf, glob);
|
508
|
+
}
|
509
|
+
|
510
|
+
/* If no '?', '*' or '[' exist, we append '/ *' to the glob */
|
511
|
+
memset(&preg, 0x0, sizeof(regex_t));
|
512
|
+
if (regcomp(&preg, "[?*[]", REG_EXTENDED)) {
|
513
|
+
giterr_set(GITERR_OS, "Regex failed to compile");
|
514
|
+
git_buf_free(&buf);
|
515
|
+
return -1;
|
516
|
+
}
|
517
|
+
|
518
|
+
if (regexec(&preg, glob, 0, NULL, 0))
|
519
|
+
git_buf_puts(&buf, "/*");
|
520
|
+
|
521
|
+
if (git_buf_oom(&buf))
|
522
|
+
goto on_error;
|
523
|
+
|
524
|
+
data.walk = walk;
|
525
|
+
data.glob = git_buf_cstr(&buf);
|
526
|
+
data.hide = hide;
|
527
|
+
|
528
|
+
if (git_reference_foreach(
|
529
|
+
walk->repo, GIT_REF_LISTALL, push_glob_cb, &data) < 0)
|
530
|
+
goto on_error;
|
531
|
+
|
532
|
+
regfree(&preg);
|
533
|
+
git_buf_free(&buf);
|
534
|
+
return 0;
|
535
|
+
|
536
|
+
on_error:
|
537
|
+
regfree(&preg);
|
538
|
+
git_buf_free(&buf);
|
539
|
+
return -1;
|
540
|
+
}
|
541
|
+
|
542
|
+
int git_revwalk_push_glob(git_revwalk *walk, const char *glob)
|
543
|
+
{
|
544
|
+
assert(walk && glob);
|
545
|
+
return push_glob(walk, glob, 0);
|
546
|
+
}
|
547
|
+
|
548
|
+
int git_revwalk_hide_glob(git_revwalk *walk, const char *glob)
|
549
|
+
{
|
550
|
+
assert(walk && glob);
|
551
|
+
return push_glob(walk, glob, 1);
|
552
|
+
}
|
553
|
+
|
554
|
+
int git_revwalk_push_head(git_revwalk *walk)
|
555
|
+
{
|
556
|
+
assert(walk);
|
557
|
+
return push_ref(walk, GIT_HEAD_FILE, 0);
|
558
|
+
}
|
559
|
+
|
560
|
+
int git_revwalk_hide_head(git_revwalk *walk)
|
561
|
+
{
|
562
|
+
assert(walk);
|
563
|
+
return push_ref(walk, GIT_HEAD_FILE, 1);
|
564
|
+
}
|
565
|
+
|
566
|
+
int git_revwalk_push_ref(git_revwalk *walk, const char *refname)
|
567
|
+
{
|
568
|
+
assert(walk && refname);
|
569
|
+
return push_ref(walk, refname, 0);
|
570
|
+
}
|
571
|
+
|
572
|
+
int git_revwalk_hide_ref(git_revwalk *walk, const char *refname)
|
573
|
+
{
|
574
|
+
assert(walk && refname);
|
575
|
+
return push_ref(walk, refname, 1);
|
576
|
+
}
|
577
|
+
|
307
578
|
static int revwalk_enqueue_timesort(git_revwalk *walk, commit_object *commit)
|
308
579
|
{
|
309
580
|
return git_pqueue_insert(&walk->iterator_time, commit);
|
@@ -311,7 +582,7 @@ static int revwalk_enqueue_timesort(git_revwalk *walk, commit_object *commit)
|
|
311
582
|
|
312
583
|
static int revwalk_enqueue_unsorted(git_revwalk *walk, commit_object *commit)
|
313
584
|
{
|
314
|
-
return commit_list_insert(commit, &walk->iterator_rand) ?
|
585
|
+
return commit_list_insert(commit, &walk->iterator_rand) ? 0 : -1;
|
315
586
|
}
|
316
587
|
|
317
588
|
static int revwalk_next_timesort(commit_object **object_out, git_revwalk *walk)
|
@@ -320,16 +591,16 @@ static int revwalk_next_timesort(commit_object **object_out, git_revwalk *walk)
|
|
320
591
|
commit_object *next;
|
321
592
|
|
322
593
|
while ((next = git_pqueue_pop(&walk->iterator_time)) != NULL) {
|
323
|
-
if ((error = process_commit_parents(walk, next)) <
|
324
|
-
return
|
594
|
+
if ((error = process_commit_parents(walk, next)) < 0)
|
595
|
+
return error;
|
325
596
|
|
326
597
|
if (!next->uninteresting) {
|
327
598
|
*object_out = next;
|
328
|
-
return
|
599
|
+
return 0;
|
329
600
|
}
|
330
601
|
}
|
331
602
|
|
332
|
-
return
|
603
|
+
return GIT_REVWALKOVER;
|
333
604
|
}
|
334
605
|
|
335
606
|
static int revwalk_next_unsorted(commit_object **object_out, git_revwalk *walk)
|
@@ -338,16 +609,16 @@ static int revwalk_next_unsorted(commit_object **object_out, git_revwalk *walk)
|
|
338
609
|
commit_object *next;
|
339
610
|
|
340
611
|
while ((next = commit_list_pop(&walk->iterator_rand)) != NULL) {
|
341
|
-
if ((error = process_commit_parents(walk, next)) <
|
342
|
-
return
|
612
|
+
if ((error = process_commit_parents(walk, next)) < 0)
|
613
|
+
return error;
|
343
614
|
|
344
615
|
if (!next->uninteresting) {
|
345
616
|
*object_out = next;
|
346
|
-
return
|
617
|
+
return 0;
|
347
618
|
}
|
348
619
|
}
|
349
620
|
|
350
|
-
return
|
621
|
+
return GIT_REVWALKOVER;
|
351
622
|
}
|
352
623
|
|
353
624
|
static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
|
@@ -358,7 +629,7 @@ static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
|
|
358
629
|
for (;;) {
|
359
630
|
next = commit_list_pop(&walk->iterator_topo);
|
360
631
|
if (next == NULL)
|
361
|
-
return
|
632
|
+
return GIT_REVWALKOVER;
|
362
633
|
|
363
634
|
if (next->in_degree > 0) {
|
364
635
|
next->topo_delay = 1;
|
@@ -370,58 +641,83 @@ static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
|
|
370
641
|
|
371
642
|
if (--parent->in_degree == 0 && parent->topo_delay) {
|
372
643
|
parent->topo_delay = 0;
|
373
|
-
commit_list_insert(parent, &walk->iterator_topo)
|
644
|
+
if (commit_list_insert(parent, &walk->iterator_topo) == NULL)
|
645
|
+
return -1;
|
374
646
|
}
|
375
647
|
}
|
376
648
|
|
377
649
|
*object_out = next;
|
378
|
-
return
|
650
|
+
return 0;
|
379
651
|
}
|
380
652
|
}
|
381
653
|
|
382
654
|
static int revwalk_next_reverse(commit_object **object_out, git_revwalk *walk)
|
383
655
|
{
|
384
656
|
*object_out = commit_list_pop(&walk->iterator_reverse);
|
385
|
-
return *object_out ?
|
657
|
+
return *object_out ? 0 : GIT_REVWALKOVER;
|
386
658
|
}
|
387
659
|
|
388
660
|
|
389
661
|
static int prepare_walk(git_revwalk *walk)
|
390
662
|
{
|
391
663
|
int error;
|
392
|
-
|
664
|
+
unsigned int i;
|
665
|
+
commit_object *next, *two;
|
666
|
+
commit_list *bases = NULL;
|
667
|
+
|
668
|
+
/*
|
669
|
+
* If walk->one is NULL, there were no positive references,
|
670
|
+
* so we know that the walk is already over.
|
671
|
+
*/
|
672
|
+
if (walk->one == NULL)
|
673
|
+
return GIT_REVWALKOVER;
|
674
|
+
|
675
|
+
/* first figure out what the merge bases are */
|
676
|
+
if (merge_bases_many(&bases, walk, walk->one, &walk->twos) < 0)
|
677
|
+
return -1;
|
678
|
+
|
679
|
+
commit_list_free(&bases);
|
680
|
+
if (process_commit(walk, walk->one, walk->one->uninteresting) < 0)
|
681
|
+
return -1;
|
682
|
+
|
683
|
+
git_vector_foreach(&walk->twos, i, two) {
|
684
|
+
if (process_commit(walk, two, two->uninteresting) < 0)
|
685
|
+
return -1;
|
686
|
+
}
|
393
687
|
|
394
688
|
if (walk->sorting & GIT_SORT_TOPOLOGICAL) {
|
395
689
|
unsigned short i;
|
396
690
|
|
397
|
-
while ((error = walk->get_next(&next, walk)) ==
|
691
|
+
while ((error = walk->get_next(&next, walk)) == 0) {
|
398
692
|
for (i = 0; i < next->out_degree; ++i) {
|
399
693
|
commit_object *parent = next->parents[i];
|
400
694
|
parent->in_degree++;
|
401
695
|
}
|
402
696
|
|
403
|
-
commit_list_insert(next, &walk->iterator_topo)
|
697
|
+
if (commit_list_insert(next, &walk->iterator_topo) == NULL)
|
698
|
+
return -1;
|
404
699
|
}
|
405
700
|
|
406
|
-
if (error !=
|
407
|
-
return
|
701
|
+
if (error != GIT_REVWALKOVER)
|
702
|
+
return error;
|
408
703
|
|
409
704
|
walk->get_next = &revwalk_next_toposort;
|
410
705
|
}
|
411
706
|
|
412
707
|
if (walk->sorting & GIT_SORT_REVERSE) {
|
413
708
|
|
414
|
-
while ((error = walk->get_next(&next, walk)) ==
|
415
|
-
commit_list_insert(next, &walk->iterator_reverse)
|
709
|
+
while ((error = walk->get_next(&next, walk)) == 0)
|
710
|
+
if (commit_list_insert(next, &walk->iterator_reverse) == NULL)
|
711
|
+
return -1;
|
416
712
|
|
417
|
-
if (error !=
|
418
|
-
return
|
713
|
+
if (error != GIT_REVWALKOVER)
|
714
|
+
return error;
|
419
715
|
|
420
716
|
walk->get_next = &revwalk_next_reverse;
|
421
717
|
}
|
422
718
|
|
423
719
|
walk->walking = 1;
|
424
|
-
return
|
720
|
+
return 0;
|
425
721
|
}
|
426
722
|
|
427
723
|
|
@@ -430,70 +726,48 @@ static int prepare_walk(git_revwalk *walk)
|
|
430
726
|
|
431
727
|
int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
|
432
728
|
{
|
433
|
-
int error;
|
434
729
|
git_revwalk *walk;
|
435
730
|
|
436
731
|
walk = git__malloc(sizeof(git_revwalk));
|
437
|
-
|
438
|
-
return GIT_ENOMEM;
|
732
|
+
GITERR_CHECK_ALLOC(walk);
|
439
733
|
|
440
734
|
memset(walk, 0x0, sizeof(git_revwalk));
|
441
735
|
|
442
|
-
walk->commits =
|
443
|
-
|
444
|
-
(git_hash_keyeq_ptr)git_oid_cmp);
|
736
|
+
walk->commits = git_oidmap_alloc();
|
737
|
+
GITERR_CHECK_ALLOC(walk->commits);
|
445
738
|
|
446
|
-
if (walk->
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
git_pqueue_init(&walk->iterator_time, 8, commit_time_cmp);
|
452
|
-
git_vector_init(&walk->memory_alloc, 8, NULL);
|
453
|
-
alloc_chunk(walk);
|
739
|
+
if (git_pqueue_init(&walk->iterator_time, 8, commit_time_cmp) < 0 ||
|
740
|
+
git_vector_init(&walk->twos, 4, NULL) < 0 ||
|
741
|
+
git_pool_init(&walk->commit_pool, 1,
|
742
|
+
git_pool__suggest_items_per_page(COMMIT_ALLOC) * COMMIT_ALLOC) < 0)
|
743
|
+
return -1;
|
454
744
|
|
455
745
|
walk->get_next = &revwalk_next_unsorted;
|
456
746
|
walk->enqueue = &revwalk_enqueue_unsorted;
|
457
747
|
|
458
748
|
walk->repo = repo;
|
459
749
|
|
460
|
-
|
461
|
-
if (error < GIT_SUCCESS) {
|
750
|
+
if (git_repository_odb(&walk->odb, repo) < 0) {
|
462
751
|
git_revwalk_free(walk);
|
463
|
-
return
|
752
|
+
return -1;
|
464
753
|
}
|
465
754
|
|
466
755
|
*revwalk_out = walk;
|
467
|
-
return
|
756
|
+
return 0;
|
468
757
|
}
|
469
758
|
|
470
759
|
void git_revwalk_free(git_revwalk *walk)
|
471
760
|
{
|
472
|
-
unsigned int i;
|
473
|
-
const void *GIT_UNUSED(_unused);
|
474
|
-
commit_object *commit;
|
475
|
-
|
476
761
|
if (walk == NULL)
|
477
762
|
return;
|
478
763
|
|
479
764
|
git_revwalk_reset(walk);
|
480
765
|
git_odb_free(walk->odb);
|
481
766
|
|
482
|
-
|
483
|
-
|
484
|
-
* make sure it's being free'd */
|
485
|
-
GIT_HASHTABLE_FOREACH(walk->commits, _unused, commit, {
|
486
|
-
if (commit->out_degree > PARENTS_PER_COMMIT)
|
487
|
-
git__free(commit->parents);
|
488
|
-
});
|
489
|
-
|
490
|
-
git_hashtable_free(walk->commits);
|
767
|
+
git_oidmap_free(walk->commits);
|
768
|
+
git_pool_clear(&walk->commit_pool);
|
491
769
|
git_pqueue_free(&walk->iterator_time);
|
492
|
-
|
493
|
-
for (i = 0; i < walk->memory_alloc.length; ++i)
|
494
|
-
git__free(git_vector_get(&walk->memory_alloc, i));
|
495
|
-
|
496
|
-
git_vector_free(&walk->memory_alloc);
|
770
|
+
git_vector_free(&walk->twos);
|
497
771
|
git__free(walk);
|
498
772
|
}
|
499
773
|
|
@@ -529,41 +803,43 @@ int git_revwalk_next(git_oid *oid, git_revwalk *walk)
|
|
529
803
|
assert(walk && oid);
|
530
804
|
|
531
805
|
if (!walk->walking) {
|
532
|
-
if ((error = prepare_walk(walk)) <
|
533
|
-
return
|
806
|
+
if ((error = prepare_walk(walk)) < 0)
|
807
|
+
return error;
|
534
808
|
}
|
535
809
|
|
536
810
|
error = walk->get_next(&next, walk);
|
537
811
|
|
538
|
-
if (error ==
|
812
|
+
if (error == GIT_REVWALKOVER) {
|
539
813
|
git_revwalk_reset(walk);
|
540
|
-
return
|
814
|
+
return GIT_REVWALKOVER;
|
541
815
|
}
|
542
816
|
|
543
|
-
if (error
|
544
|
-
|
817
|
+
if (!error)
|
818
|
+
git_oid_cpy(oid, &next->oid);
|
545
819
|
|
546
|
-
|
547
|
-
return GIT_SUCCESS;
|
820
|
+
return error;
|
548
821
|
}
|
549
822
|
|
550
823
|
void git_revwalk_reset(git_revwalk *walk)
|
551
824
|
{
|
552
|
-
const void *GIT_UNUSED(_unused);
|
553
825
|
commit_object *commit;
|
554
826
|
|
555
827
|
assert(walk);
|
556
828
|
|
557
|
-
|
829
|
+
kh_foreach_value(walk->commits, commit, {
|
558
830
|
commit->seen = 0;
|
559
831
|
commit->in_degree = 0;
|
560
832
|
commit->topo_delay = 0;
|
561
|
-
|
833
|
+
commit->uninteresting = 0;
|
834
|
+
});
|
562
835
|
|
563
836
|
git_pqueue_clear(&walk->iterator_time);
|
564
837
|
commit_list_free(&walk->iterator_topo);
|
565
838
|
commit_list_free(&walk->iterator_rand);
|
566
839
|
commit_list_free(&walk->iterator_reverse);
|
567
840
|
walk->walking = 0;
|
841
|
+
|
842
|
+
walk->one = NULL;
|
843
|
+
git_vector_clear(&walk->twos);
|
568
844
|
}
|
569
845
|
|