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.
|
@@ -13,684 +13,230 @@
|
|
13
13
|
#include "tree.h"
|
14
14
|
#include "git2/status.h"
|
15
15
|
#include "repository.h"
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
if (
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
else if (git_oid_cmp(&e->index_oid, &e->wt_oid) != 0)
|
117
|
-
e->status_flags |= GIT_STATUS_WT_MODIFIED;
|
118
|
-
|
119
|
-
return GIT_SUCCESS;
|
120
|
-
}
|
121
|
-
|
122
|
-
struct status_st {
|
123
|
-
git_vector *vector;
|
124
|
-
git_index *index;
|
125
|
-
git_tree *tree;
|
126
|
-
|
127
|
-
int workdir_path_len;
|
128
|
-
char* head_tree_relative_path;
|
129
|
-
int head_tree_relative_path_len;
|
130
|
-
unsigned int tree_position;
|
131
|
-
unsigned int index_position;
|
132
|
-
int is_dir:1;
|
133
|
-
};
|
134
|
-
|
135
|
-
static int retrieve_head_tree(git_tree **tree_out, git_repository *repo)
|
136
|
-
{
|
137
|
-
git_reference *resolved_head_ref;
|
138
|
-
git_commit *head_commit = NULL;
|
139
|
-
git_tree *tree;
|
140
|
-
int error = GIT_SUCCESS;
|
141
|
-
|
142
|
-
*tree_out = NULL;
|
143
|
-
|
144
|
-
error = git_repository_head(&resolved_head_ref, repo);
|
145
|
-
/*
|
146
|
-
* We assume that a situation where HEAD exists but can not be resolved is valid.
|
147
|
-
* A new repository fits this description for instance.
|
148
|
-
*/
|
149
|
-
if (error == GIT_ENOTFOUND)
|
150
|
-
return GIT_SUCCESS;
|
151
|
-
if (error < GIT_SUCCESS)
|
152
|
-
return git__rethrow(error, "HEAD can't be resolved");
|
153
|
-
|
154
|
-
if ((error = git_commit_lookup(&head_commit, repo, git_reference_oid(resolved_head_ref))) < GIT_SUCCESS)
|
155
|
-
return git__rethrow(error, "The tip of HEAD can't be retrieved");
|
156
|
-
|
157
|
-
if ((error = git_commit_tree(&tree, head_commit)) < GIT_SUCCESS) {
|
158
|
-
error = git__rethrow(error, "The tree of HEAD can't be retrieved");
|
159
|
-
goto exit;
|
160
|
-
}
|
161
|
-
|
162
|
-
*tree_out = tree;
|
163
|
-
|
164
|
-
exit:
|
165
|
-
git_commit_free(head_commit);
|
166
|
-
return error;
|
167
|
-
}
|
168
|
-
|
169
|
-
enum path_type {
|
170
|
-
GIT_STATUS_PATH_NULL,
|
171
|
-
GIT_STATUS_PATH_IGNORE,
|
172
|
-
GIT_STATUS_PATH_FILE,
|
173
|
-
GIT_STATUS_PATH_FOLDER,
|
174
|
-
};
|
175
|
-
|
176
|
-
static int dirent_cb(void *state, char *full_path);
|
177
|
-
static int alphasorted_futils_direach(
|
178
|
-
char *path, size_t path_sz,
|
179
|
-
int (*fn)(void *, char *), void *arg);
|
180
|
-
|
181
|
-
static int process_folder(struct status_st *st, const git_tree_entry *tree_entry, char *full_path, enum path_type path_type)
|
182
|
-
{
|
183
|
-
git_object *subtree = NULL;
|
184
|
-
git_tree *pushed_tree = NULL;
|
185
|
-
int error, pushed_tree_position = 0;
|
186
|
-
git_otype tree_entry_type = GIT_OBJ_BAD;
|
187
|
-
|
188
|
-
if (tree_entry != NULL) {
|
189
|
-
tree_entry_type = git_tree_entry_type(tree_entry);
|
190
|
-
|
191
|
-
switch (tree_entry_type) {
|
192
|
-
case GIT_OBJ_TREE:
|
193
|
-
error = git_tree_entry_2object(&subtree, ((git_object *)(st->tree))->repo, tree_entry);
|
194
|
-
pushed_tree = st->tree;
|
195
|
-
pushed_tree_position = st->tree_position;
|
196
|
-
st->tree = (git_tree *)subtree;
|
197
|
-
st->tree_position = 0;
|
198
|
-
st->head_tree_relative_path_len += 1 + tree_entry->filename_len; /* path + '/' + name */
|
199
|
-
break;
|
200
|
-
|
201
|
-
case GIT_OBJ_BLOB:
|
202
|
-
/* No op */
|
203
|
-
break;
|
204
|
-
|
205
|
-
default:
|
206
|
-
error = git__throw(GIT_EINVALIDTYPE, "Unexpected tree entry type"); /* TODO: How should we deal with submodules? */
|
16
|
+
#include "ignore.h"
|
17
|
+
|
18
|
+
#include "git2/diff.h"
|
19
|
+
#include "diff.h"
|
20
|
+
|
21
|
+
static unsigned int index_delta2status(git_delta_t index_status)
|
22
|
+
{
|
23
|
+
unsigned int st = GIT_STATUS_CURRENT;
|
24
|
+
|
25
|
+
switch (index_status) {
|
26
|
+
case GIT_DELTA_ADDED:
|
27
|
+
case GIT_DELTA_COPIED:
|
28
|
+
case GIT_DELTA_RENAMED:
|
29
|
+
st = GIT_STATUS_INDEX_NEW;
|
30
|
+
break;
|
31
|
+
case GIT_DELTA_DELETED:
|
32
|
+
st = GIT_STATUS_INDEX_DELETED;
|
33
|
+
break;
|
34
|
+
case GIT_DELTA_MODIFIED:
|
35
|
+
st = GIT_STATUS_INDEX_MODIFIED;
|
36
|
+
break;
|
37
|
+
default:
|
38
|
+
break;
|
39
|
+
}
|
40
|
+
|
41
|
+
return st;
|
42
|
+
}
|
43
|
+
|
44
|
+
static unsigned int workdir_delta2status(git_delta_t workdir_status)
|
45
|
+
{
|
46
|
+
unsigned int st = GIT_STATUS_CURRENT;
|
47
|
+
|
48
|
+
switch (workdir_status) {
|
49
|
+
case GIT_DELTA_ADDED:
|
50
|
+
case GIT_DELTA_COPIED:
|
51
|
+
case GIT_DELTA_RENAMED:
|
52
|
+
case GIT_DELTA_UNTRACKED:
|
53
|
+
st = GIT_STATUS_WT_NEW;
|
54
|
+
break;
|
55
|
+
case GIT_DELTA_DELETED:
|
56
|
+
st = GIT_STATUS_WT_DELETED;
|
57
|
+
break;
|
58
|
+
case GIT_DELTA_MODIFIED:
|
59
|
+
st = GIT_STATUS_WT_MODIFIED;
|
60
|
+
break;
|
61
|
+
case GIT_DELTA_IGNORED:
|
62
|
+
st = GIT_STATUS_IGNORED;
|
63
|
+
break;
|
64
|
+
default:
|
65
|
+
break;
|
66
|
+
}
|
67
|
+
|
68
|
+
return st;
|
69
|
+
}
|
70
|
+
|
71
|
+
int git_status_foreach_ext(
|
72
|
+
git_repository *repo,
|
73
|
+
const git_status_options *opts,
|
74
|
+
int (*cb)(const char *, unsigned int, void *),
|
75
|
+
void *cbdata)
|
76
|
+
{
|
77
|
+
int err = 0, cmp;
|
78
|
+
git_diff_options diffopt;
|
79
|
+
git_diff_list *idx2head = NULL, *wd2idx = NULL;
|
80
|
+
git_tree *head = NULL;
|
81
|
+
git_status_show_t show =
|
82
|
+
opts ? opts->show : GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
|
83
|
+
git_diff_delta *i2h, *w2i;
|
84
|
+
unsigned int i, j, i_max, j_max;
|
85
|
+
|
86
|
+
assert(show <= GIT_STATUS_SHOW_INDEX_THEN_WORKDIR);
|
87
|
+
|
88
|
+
if ((err = git_repository_head_tree(&head, repo)) < 0)
|
89
|
+
return err;
|
90
|
+
|
91
|
+
memset(&diffopt, 0, sizeof(diffopt));
|
92
|
+
memcpy(&diffopt.pathspec, &opts->pathspec, sizeof(diffopt.pathspec));
|
93
|
+
|
94
|
+
if ((opts->flags & GIT_STATUS_OPT_INCLUDE_UNTRACKED) != 0)
|
95
|
+
diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNTRACKED;
|
96
|
+
if ((opts->flags & GIT_STATUS_OPT_INCLUDE_IGNORED) != 0)
|
97
|
+
diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_IGNORED;
|
98
|
+
if ((opts->flags & GIT_STATUS_OPT_INCLUDE_UNMODIFIED) != 0)
|
99
|
+
diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNMODIFIED;
|
100
|
+
if ((opts->flags & GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS) != 0)
|
101
|
+
diffopt.flags = diffopt.flags | GIT_DIFF_RECURSE_UNTRACKED_DIRS;
|
102
|
+
/* TODO: support EXCLUDE_SUBMODULES flag */
|
103
|
+
|
104
|
+
if (show != GIT_STATUS_SHOW_WORKDIR_ONLY &&
|
105
|
+
(err = git_diff_index_to_tree(repo, &diffopt, head, &idx2head)) < 0)
|
106
|
+
goto cleanup;
|
107
|
+
|
108
|
+
if (show != GIT_STATUS_SHOW_INDEX_ONLY &&
|
109
|
+
(err = git_diff_workdir_to_index(repo, &diffopt, &wd2idx)) < 0)
|
110
|
+
goto cleanup;
|
111
|
+
|
112
|
+
if (show == GIT_STATUS_SHOW_INDEX_THEN_WORKDIR) {
|
113
|
+
for (i = 0; !err && i < idx2head->deltas.length; i++) {
|
114
|
+
i2h = GIT_VECTOR_GET(&idx2head->deltas, i);
|
115
|
+
err = cb(i2h->old_file.path, index_delta2status(i2h->status), cbdata);
|
207
116
|
}
|
117
|
+
git_diff_list_free(idx2head);
|
118
|
+
idx2head = NULL;
|
208
119
|
}
|
209
120
|
|
210
|
-
|
211
|
-
|
212
|
-
else {
|
213
|
-
error = dirent_cb(st, NULL);
|
214
|
-
}
|
121
|
+
i_max = idx2head ? idx2head->deltas.length : 0;
|
122
|
+
j_max = wd2idx ? wd2idx->deltas.length : 0;
|
215
123
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
st->tree = pushed_tree;
|
220
|
-
st->tree_position = pushed_tree_position;
|
221
|
-
st->tree_position++;
|
222
|
-
}
|
124
|
+
for (i = 0, j = 0; !err && (i < i_max || j < j_max); ) {
|
125
|
+
i2h = idx2head ? GIT_VECTOR_GET(&idx2head->deltas,i) : NULL;
|
126
|
+
w2i = wd2idx ? GIT_VECTOR_GET(&wd2idx->deltas,j) : NULL;
|
223
127
|
|
224
|
-
|
225
|
-
}
|
226
|
-
|
227
|
-
static int store_if_changed(struct status_st *st, struct status_entry *e)
|
228
|
-
{
|
229
|
-
int error;
|
230
|
-
if ((error = status_entry_update_flags(e)) < GIT_SUCCESS)
|
231
|
-
return git__throw(error, "Failed to process the file '%s'. It doesn't exist in the workdir, in the HEAD nor in the index", e->path);
|
232
|
-
|
233
|
-
if (e->status_flags == GIT_STATUS_CURRENT) {
|
234
|
-
git__free(e);
|
235
|
-
return GIT_SUCCESS;
|
236
|
-
}
|
237
|
-
|
238
|
-
return git_vector_insert(st->vector, e);
|
239
|
-
}
|
240
|
-
|
241
|
-
static int determine_status(struct status_st *st,
|
242
|
-
int in_head, int in_index, int in_workdir,
|
243
|
-
const git_tree_entry *tree_entry,
|
244
|
-
const git_index_entry *index_entry,
|
245
|
-
char *full_path,
|
246
|
-
const char *status_path,
|
247
|
-
enum path_type path_type)
|
248
|
-
{
|
249
|
-
struct status_entry *e;
|
250
|
-
int error = GIT_SUCCESS;
|
251
|
-
git_otype tree_entry_type = GIT_OBJ_BAD;
|
128
|
+
cmp = !w2i ? -1 : !i2h ? 1 : strcmp(i2h->old_file.path, w2i->old_file.path);
|
252
129
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
if (in_head && tree_entry_type == GIT_OBJ_BLOB) {
|
265
|
-
status_entry_update_from_tree_entry(e, tree_entry);
|
266
|
-
st->tree_position++;
|
130
|
+
if (cmp < 0) {
|
131
|
+
err = cb(i2h->old_file.path, index_delta2status(i2h->status), cbdata);
|
132
|
+
i++;
|
133
|
+
} else if (cmp > 0) {
|
134
|
+
err = cb(w2i->old_file.path, workdir_delta2status(w2i->status), cbdata);
|
135
|
+
j++;
|
136
|
+
} else {
|
137
|
+
err = cb(i2h->old_file.path, index_delta2status(i2h->status) |
|
138
|
+
workdir_delta2status(w2i->status), cbdata);
|
139
|
+
i++; j++;
|
267
140
|
}
|
268
|
-
|
269
|
-
if (in_index) {
|
270
|
-
status_entry_update_from_index_entry(e, index_entry);
|
271
|
-
st->index_position++;
|
272
|
-
}
|
273
|
-
|
274
|
-
if (in_workdir)
|
275
|
-
if ((error = status_entry_update_from_workdir(e, full_path)) < GIT_SUCCESS)
|
276
|
-
return error; /* The callee has already set the error message */
|
277
|
-
|
278
|
-
return store_if_changed(st, e);
|
279
141
|
}
|
280
142
|
|
281
|
-
|
282
|
-
|
283
|
-
|
143
|
+
cleanup:
|
144
|
+
git_tree_free(head);
|
145
|
+
git_diff_list_free(idx2head);
|
146
|
+
git_diff_list_free(wd2idx);
|
147
|
+
return err;
|
284
148
|
}
|
285
149
|
|
286
|
-
|
150
|
+
int git_status_foreach(
|
151
|
+
git_repository *repo,
|
152
|
+
int (*callback)(const char *, unsigned int, void *),
|
153
|
+
void *payload)
|
287
154
|
{
|
288
|
-
|
289
|
-
return GIT_STATUS_PATH_NULL;
|
290
|
-
|
291
|
-
if (!is_dir)
|
292
|
-
return GIT_STATUS_PATH_FILE;
|
155
|
+
git_status_options opts;
|
293
156
|
|
294
|
-
|
295
|
-
|
157
|
+
memset(&opts, 0, sizeof(opts));
|
158
|
+
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
|
159
|
+
opts.flags = GIT_STATUS_OPT_INCLUDE_IGNORED |
|
160
|
+
GIT_STATUS_OPT_INCLUDE_UNTRACKED |
|
161
|
+
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS;
|
296
162
|
|
297
|
-
return
|
163
|
+
return git_status_foreach_ext(repo, &opts, callback, payload);
|
298
164
|
}
|
299
165
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
/* TODO: Fixme. Ensure that when non null, they're all equal */
|
306
|
-
if (first != NULL)
|
307
|
-
return first;
|
308
|
-
|
309
|
-
if (second != NULL)
|
310
|
-
return second;
|
311
|
-
|
312
|
-
return third;
|
313
|
-
}
|
166
|
+
struct status_file_info {
|
167
|
+
unsigned int count;
|
168
|
+
unsigned int status;
|
169
|
+
char *expected;
|
170
|
+
};
|
314
171
|
|
315
|
-
static int
|
172
|
+
static int get_one_status(const char *path, unsigned int status, void *data)
|
316
173
|
{
|
317
|
-
|
318
|
-
return 0;
|
174
|
+
struct status_file_info *sfi = data;
|
319
175
|
|
320
|
-
|
321
|
-
|
176
|
+
sfi->count++;
|
177
|
+
sfi->status = status;
|
322
178
|
|
323
|
-
if (
|
179
|
+
if (sfi->count > 1 || strcmp(sfi->expected, path) != 0) {
|
180
|
+
giterr_set(GITERR_INVALID,
|
181
|
+
"Ambiguous path '%s' given to git_status_file", sfi->expected);
|
324
182
|
return -1;
|
325
|
-
|
326
|
-
return strcmp(left, right);
|
327
|
-
}
|
328
|
-
|
329
|
-
/* Greatly inspired from JGit IndexTreeWalker */
|
330
|
-
/* https://github.com/spearce/jgit/blob/ed47e29c777accfa78c6f50685a5df2b8f5b8ff5/org.spearce.jgit/src/org/spearce/jgit/lib/IndexTreeWalker.java#L88 */
|
331
|
-
|
332
|
-
static int dirent_cb(void *state, char *a)
|
333
|
-
{
|
334
|
-
const git_tree_entry *m;
|
335
|
-
const git_index_entry *entry;
|
336
|
-
enum path_type path_type;
|
337
|
-
int cmpma, cmpmi, cmpai, error;
|
338
|
-
const char *pm, *pa, *pi;
|
339
|
-
const char *m_name, *i_name, *a_name;
|
340
|
-
|
341
|
-
struct status_st *st = (struct status_st *)state;
|
342
|
-
|
343
|
-
path_type = path_type_from(a, st->is_dir);
|
344
|
-
|
345
|
-
if (path_type == GIT_STATUS_PATH_IGNORE)
|
346
|
-
return GIT_SUCCESS; /* Let's skip the ".git" directory */
|
347
|
-
|
348
|
-
a_name = (path_type != GIT_STATUS_PATH_NULL) ? a + st->workdir_path_len : NULL;
|
349
|
-
|
350
|
-
while (1) {
|
351
|
-
if (st->tree == NULL)
|
352
|
-
m = NULL;
|
353
|
-
else
|
354
|
-
m = git_tree_entry_byindex(st->tree, st->tree_position);
|
355
|
-
|
356
|
-
entry = git_index_get(st->index, st->index_position);
|
357
|
-
|
358
|
-
if ((m == NULL) && (a == NULL) && (entry == NULL))
|
359
|
-
return GIT_SUCCESS;
|
360
|
-
|
361
|
-
if (m != NULL) {
|
362
|
-
st->head_tree_relative_path[st->head_tree_relative_path_len] = '\0';
|
363
|
-
|
364
|
-
/* When the tree entry is a folder, append a forward slash to its name */
|
365
|
-
if (git_tree_entry_type(m) == GIT_OBJ_TREE)
|
366
|
-
git_path_join_n(st->head_tree_relative_path, 3, st->head_tree_relative_path, m->filename, "");
|
367
|
-
else
|
368
|
-
git_path_join(st->head_tree_relative_path, st->head_tree_relative_path, m->filename);
|
369
|
-
|
370
|
-
m_name = st->head_tree_relative_path;
|
371
|
-
} else
|
372
|
-
m_name = NULL;
|
373
|
-
|
374
|
-
i_name = (entry != NULL) ? entry->path : NULL;
|
375
|
-
|
376
|
-
cmpma = compare(m_name, a_name);
|
377
|
-
cmpmi = compare(m_name, i_name);
|
378
|
-
cmpai = compare(a_name, i_name);
|
379
|
-
|
380
|
-
pm = ((cmpma <= 0) && (cmpmi <= 0)) ? m_name : NULL;
|
381
|
-
pa = ((cmpma >= 0) && (cmpai <= 0)) ? a_name : NULL;
|
382
|
-
pi = ((cmpmi >= 0) && (cmpai >= 0)) ? i_name : NULL;
|
383
|
-
|
384
|
-
if((error = determine_status(st, pm != NULL, pi != NULL, pa != NULL, m, entry, a, status_path(pm, pi, pa), path_type)) < GIT_SUCCESS)
|
385
|
-
return git__rethrow(error, "An error occured while determining the status of '%s'", a);
|
386
|
-
|
387
|
-
if ((pa != NULL) || (path_type == GIT_STATUS_PATH_FOLDER))
|
388
|
-
return GIT_SUCCESS;
|
389
|
-
}
|
390
|
-
}
|
391
|
-
|
392
|
-
static int status_cmp(const void *a, const void *b)
|
393
|
-
{
|
394
|
-
const struct status_entry *entry_a = (const struct status_entry *)(a);
|
395
|
-
const struct status_entry *entry_b = (const struct status_entry *)(b);
|
396
|
-
|
397
|
-
return strcmp(entry_a->path, entry_b->path);
|
398
|
-
}
|
399
|
-
|
400
|
-
#define DEFAULT_SIZE 16
|
401
|
-
|
402
|
-
int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsigned int, void *), void *payload)
|
403
|
-
{
|
404
|
-
git_vector entries;
|
405
|
-
git_index *index = NULL;
|
406
|
-
char temp_path[GIT_PATH_MAX];
|
407
|
-
char tree_path[GIT_PATH_MAX] = "";
|
408
|
-
struct status_st dirent_st;
|
409
|
-
int error = GIT_SUCCESS;
|
410
|
-
unsigned int i;
|
411
|
-
git_tree *tree;
|
412
|
-
struct status_entry *e;
|
413
|
-
const char *workdir;
|
414
|
-
|
415
|
-
if ((workdir = git_repository_workdir(repo)) == NULL)
|
416
|
-
return git__throw(GIT_ERROR,
|
417
|
-
"Cannot retrieve status on a bare repository");
|
418
|
-
|
419
|
-
if ((error = git_repository_index__weakptr(&index, repo)) < GIT_SUCCESS) {
|
420
|
-
return git__rethrow(error,
|
421
|
-
"Failed to determine statuses. Index can't be opened");
|
422
|
-
}
|
423
|
-
|
424
|
-
if ((error = retrieve_head_tree(&tree, repo)) < GIT_SUCCESS) {
|
425
|
-
error = git__rethrow(error, "Failed to determine statuses");
|
426
|
-
goto exit;
|
427
|
-
}
|
428
|
-
|
429
|
-
git_vector_init(&entries, DEFAULT_SIZE, status_cmp);
|
430
|
-
|
431
|
-
dirent_st.workdir_path_len = strlen(workdir);
|
432
|
-
dirent_st.tree_position = 0;
|
433
|
-
dirent_st.index_position = 0;
|
434
|
-
dirent_st.tree = tree;
|
435
|
-
dirent_st.index = index;
|
436
|
-
dirent_st.vector = &entries;
|
437
|
-
dirent_st.head_tree_relative_path = tree_path;
|
438
|
-
dirent_st.head_tree_relative_path_len = 0;
|
439
|
-
dirent_st.is_dir = 1;
|
440
|
-
|
441
|
-
strcpy(temp_path, workdir);
|
442
|
-
|
443
|
-
if (git_futils_isdir(temp_path)) {
|
444
|
-
error = git__throw(GIT_EINVALIDPATH,
|
445
|
-
"Failed to determine status of file '%s'. "
|
446
|
-
"The given path doesn't lead to a folder", temp_path);
|
447
|
-
goto exit;
|
448
|
-
}
|
449
|
-
|
450
|
-
error = alphasorted_futils_direach(
|
451
|
-
temp_path, sizeof(temp_path),
|
452
|
-
dirent_cb, &dirent_st
|
453
|
-
);
|
454
|
-
|
455
|
-
if (error < GIT_SUCCESS)
|
456
|
-
error = git__rethrow(error,
|
457
|
-
"Failed to determine statuses. "
|
458
|
-
"An error occured while processing the working directory");
|
459
|
-
|
460
|
-
if ((error == GIT_SUCCESS) && ((error = dirent_cb(&dirent_st, NULL)) < GIT_SUCCESS))
|
461
|
-
error = git__rethrow(error,
|
462
|
-
"Failed to determine statuses. "
|
463
|
-
"An error occured while post-processing the HEAD tree and the index");
|
464
|
-
|
465
|
-
for (i = 0; i < entries.length; ++i) {
|
466
|
-
e = (struct status_entry *)git_vector_get(&entries, i);
|
467
|
-
|
468
|
-
if (error == GIT_SUCCESS) {
|
469
|
-
error = callback(e->path, e->status_flags, payload);
|
470
|
-
if (error < GIT_SUCCESS)
|
471
|
-
error = git__rethrow(error,
|
472
|
-
"Failed to determine statuses. User callback failed");
|
473
|
-
}
|
474
|
-
|
475
|
-
git__free(e);
|
476
183
|
}
|
477
184
|
|
478
|
-
|
479
|
-
git_vector_free(&entries);
|
480
|
-
git_tree_free(tree);
|
481
|
-
return error;
|
185
|
+
return 0;
|
482
186
|
}
|
483
187
|
|
484
|
-
|
188
|
+
int git_status_file(
|
189
|
+
unsigned int *status_flags,
|
190
|
+
git_repository *repo,
|
191
|
+
const char *path)
|
485
192
|
{
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
int error = GIT_SUCCESS;
|
490
|
-
|
491
|
-
dir_sep = strchr(path, '/');
|
492
|
-
if (!dir_sep) {
|
493
|
-
tree_entry = git_tree_entry_byname(tree, path);
|
494
|
-
if (tree_entry == NULL)
|
495
|
-
return GIT_SUCCESS; /* The leaf doesn't exist in the tree*/
|
496
|
-
|
497
|
-
status_entry_update_from_tree_entry(e, tree_entry);
|
498
|
-
return GIT_SUCCESS;
|
499
|
-
}
|
500
|
-
|
501
|
-
/* Retrieve subtree name */
|
502
|
-
*dir_sep = '\0';
|
503
|
-
|
504
|
-
tree_entry = git_tree_entry_byname(tree, path);
|
505
|
-
if (tree_entry == NULL)
|
506
|
-
return GIT_SUCCESS; /* The subtree doesn't exist in the tree*/
|
507
|
-
|
508
|
-
*dir_sep = '/';
|
509
|
-
|
510
|
-
/* Retreive subtree */
|
511
|
-
if ((error = git_tree_lookup(&subtree, tree->object.repo, &tree_entry->oid)) < GIT_SUCCESS)
|
512
|
-
return git__throw(GIT_EOBJCORRUPTED, "Can't find tree object '%s'", tree_entry->filename);
|
513
|
-
|
514
|
-
error = recurse_tree_entry(subtree, e, dir_sep+1);
|
515
|
-
git_tree_free(subtree);
|
516
|
-
return error;
|
517
|
-
}
|
518
|
-
|
519
|
-
int git_status_file(unsigned int *status_flags, git_repository *repo, const char *path)
|
520
|
-
{
|
521
|
-
struct status_entry *e;
|
522
|
-
git_index *index = NULL;
|
523
|
-
char temp_path[GIT_PATH_MAX];
|
524
|
-
int error = GIT_SUCCESS;
|
525
|
-
git_tree *tree = NULL;
|
526
|
-
const char *workdir;
|
193
|
+
int error;
|
194
|
+
git_status_options opts;
|
195
|
+
struct status_file_info sfi;
|
527
196
|
|
528
197
|
assert(status_flags && repo && path);
|
529
198
|
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
git_path_join(temp_path, workdir, path);
|
535
|
-
if (git_futils_isdir(temp_path) == GIT_SUCCESS)
|
536
|
-
return git__throw(GIT_EINVALIDPATH,
|
537
|
-
"Failed to determine status of file '%s'. "
|
538
|
-
"Given path leads to a folder, not a file", path);
|
539
|
-
|
540
|
-
e = status_entry_new(NULL, path);
|
541
|
-
if (e == NULL)
|
542
|
-
return GIT_ENOMEM;
|
543
|
-
|
544
|
-
/* Find file in Workdir */
|
545
|
-
if (git_futils_exists(temp_path) == GIT_SUCCESS) {
|
546
|
-
if ((error = status_entry_update_from_workdir(e, temp_path)) < GIT_SUCCESS)
|
547
|
-
goto exit; /* The callee has already set the error message */
|
548
|
-
}
|
549
|
-
|
550
|
-
/* Find file in Index */
|
551
|
-
if ((error = git_repository_index__weakptr(&index, repo)) < GIT_SUCCESS) {
|
552
|
-
error = git__rethrow(error,
|
553
|
-
"Failed to determine status of file '%s'."
|
554
|
-
"Index can't be opened", path);
|
555
|
-
goto exit;
|
556
|
-
}
|
557
|
-
|
558
|
-
status_entry_update_from_index(e, index);
|
199
|
+
memset(&sfi, 0, sizeof(sfi));
|
200
|
+
if ((sfi.expected = git__strdup(path)) == NULL)
|
201
|
+
return -1;
|
559
202
|
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
203
|
+
memset(&opts, 0, sizeof(opts));
|
204
|
+
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
|
205
|
+
opts.flags = GIT_STATUS_OPT_INCLUDE_IGNORED |
|
206
|
+
GIT_STATUS_OPT_INCLUDE_UNTRACKED |
|
207
|
+
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS |
|
208
|
+
GIT_STATUS_OPT_INCLUDE_UNMODIFIED;
|
209
|
+
opts.pathspec.count = 1;
|
210
|
+
opts.pathspec.strings = &sfi.expected;
|
565
211
|
|
566
|
-
|
567
|
-
if (tree != NULL) {
|
568
|
-
strcpy(temp_path, path);
|
212
|
+
error = git_status_foreach_ext(repo, &opts, get_one_status, &sfi);
|
569
213
|
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
"An error occured while processing the tree", path);
|
575
|
-
goto exit;
|
576
|
-
}
|
214
|
+
if (!error && !sfi.count) {
|
215
|
+
giterr_set(GITERR_INVALID,
|
216
|
+
"Attempt to get status of nonexistent file '%s'", path);
|
217
|
+
error = GIT_ENOTFOUND;
|
577
218
|
}
|
578
219
|
|
579
|
-
|
580
|
-
if ((error = status_entry_update_flags(e)) < GIT_SUCCESS) {
|
581
|
-
error = git__throw(error, "Nonexistent file");
|
582
|
-
goto exit;
|
583
|
-
}
|
220
|
+
*status_flags = sfi.status;
|
584
221
|
|
585
|
-
|
222
|
+
git__free(sfi.expected);
|
586
223
|
|
587
|
-
exit:
|
588
|
-
git_tree_free(tree);
|
589
|
-
git__free(e);
|
590
224
|
return error;
|
591
225
|
}
|
592
226
|
|
593
|
-
|
594
|
-
*
|
595
|
-
*
|
596
|
-
*
|
597
|
-
*
|
598
|
-
*/
|
599
|
-
|
600
|
-
struct alphasorted_dirent_info {
|
601
|
-
int is_dir;
|
602
|
-
|
603
|
-
char path[GIT_FLEX_ARRAY]; /* more */
|
604
|
-
};
|
605
|
-
|
606
|
-
static struct alphasorted_dirent_info *alphasorted_dirent_info_new(const char *path)
|
607
|
-
{
|
608
|
-
int is_dir, size;
|
609
|
-
struct alphasorted_dirent_info *di;
|
610
|
-
|
611
|
-
is_dir = git_futils_isdir(path) == GIT_SUCCESS ? 1 : 0;
|
612
|
-
size = sizeof(*di) + (is_dir ? GIT_PATH_MAX : strlen(path)) + 2;
|
613
|
-
|
614
|
-
di = git__malloc(size);
|
615
|
-
if (di == NULL)
|
616
|
-
return NULL;
|
617
|
-
|
618
|
-
memset(di, 0x0, size);
|
619
|
-
|
620
|
-
strcpy(di->path, path);
|
621
|
-
|
622
|
-
if (is_dir) {
|
623
|
-
di->is_dir = 1;
|
624
|
-
|
625
|
-
/*
|
626
|
-
* Append a forward slash to the name to force folders
|
627
|
-
* to be ordered in a similar way than in a tree
|
628
|
-
*
|
629
|
-
* The file "subdir" should appear before the file "subdir.txt"
|
630
|
-
* The folder "subdir" should appear after the file "subdir.txt"
|
631
|
-
*/
|
632
|
-
di->path[strlen(path)] = '/';
|
633
|
-
}
|
634
|
-
|
635
|
-
return di;
|
636
|
-
}
|
637
|
-
|
638
|
-
static int alphasorted_dirent_info_cmp(const void *a, const void *b)
|
227
|
+
int git_status_should_ignore(
|
228
|
+
int *ignored,
|
229
|
+
git_repository *repo,
|
230
|
+
const char *path)
|
639
231
|
{
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
return strcmp(stra->path, strb->path);
|
644
|
-
}
|
645
|
-
|
646
|
-
static int alphasorted_dirent_cb(void *state, char *full_path)
|
647
|
-
{
|
648
|
-
struct alphasorted_dirent_info *entry;
|
649
|
-
git_vector *entry_names;
|
650
|
-
|
651
|
-
entry_names = (git_vector *)state;
|
652
|
-
entry = alphasorted_dirent_info_new(full_path);
|
653
|
-
|
654
|
-
if (entry == NULL)
|
655
|
-
return GIT_ENOMEM;
|
656
|
-
|
657
|
-
if (git_vector_insert(entry_names, entry) < GIT_SUCCESS) {
|
658
|
-
git__free(entry);
|
659
|
-
return GIT_ENOMEM;
|
660
|
-
}
|
661
|
-
|
662
|
-
return GIT_SUCCESS;
|
663
|
-
}
|
664
|
-
|
665
|
-
static int alphasorted_futils_direach(
|
666
|
-
char *path,
|
667
|
-
size_t path_sz,
|
668
|
-
int (*fn)(void *, char *),
|
669
|
-
void *arg)
|
670
|
-
{
|
671
|
-
struct alphasorted_dirent_info *entry;
|
672
|
-
git_vector entry_names;
|
673
|
-
unsigned int idx;
|
674
|
-
int error = GIT_SUCCESS;
|
675
|
-
|
676
|
-
if (git_vector_init(&entry_names, 16, alphasorted_dirent_info_cmp) < GIT_SUCCESS)
|
677
|
-
return GIT_ENOMEM;
|
678
|
-
|
679
|
-
error = git_futils_direach(path, path_sz, alphasorted_dirent_cb, &entry_names);
|
680
|
-
|
681
|
-
git_vector_sort(&entry_names);
|
682
|
-
|
683
|
-
for (idx = 0; idx < entry_names.length; ++idx) {
|
684
|
-
entry = (struct alphasorted_dirent_info *)git_vector_get(&entry_names, idx);
|
685
|
-
|
686
|
-
if (error == GIT_SUCCESS) {
|
687
|
-
((struct status_st *)arg)->is_dir = entry->is_dir;
|
688
|
-
error = fn(arg, entry->path);
|
689
|
-
}
|
232
|
+
int error;
|
233
|
+
git_ignores ignores;
|
690
234
|
|
691
|
-
|
692
|
-
|
235
|
+
if (git_ignore__for_path(repo, path, &ignores) < 0)
|
236
|
+
return -1;
|
693
237
|
|
694
|
-
|
238
|
+
error = git_ignore__lookup(&ignores, path, ignored);
|
239
|
+
git_ignore__free(&ignores);
|
695
240
|
return error;
|
696
241
|
}
|
242
|
+
|