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.
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#include "commit.h"
|
10
10
|
#include "tag.h"
|
11
11
|
#include "signature.h"
|
12
|
+
#include "message.h"
|
12
13
|
#include "git2/object.h"
|
13
14
|
#include "git2/repository.h"
|
14
15
|
#include "git2/signature.h"
|
@@ -61,24 +62,32 @@ const char *git_tag_message(git_tag *t)
|
|
61
62
|
return t->message;
|
62
63
|
}
|
63
64
|
|
64
|
-
static int
|
65
|
+
static int tag_error(const char *str)
|
66
|
+
{
|
67
|
+
giterr_set(GITERR_TAG, "Failed to parse tag. %s", str);
|
68
|
+
return -1;
|
69
|
+
}
|
70
|
+
|
71
|
+
int git_tag__parse_buffer(git_tag *tag, const char *buffer, size_t length)
|
65
72
|
{
|
66
73
|
static const char *tag_types[] = {
|
67
74
|
NULL, "commit\n", "tree\n", "blob\n", "tag\n"
|
68
75
|
};
|
69
76
|
|
70
|
-
unsigned int i
|
77
|
+
unsigned int i;
|
78
|
+
size_t text_len;
|
71
79
|
char *search;
|
72
|
-
int error;
|
73
80
|
|
74
|
-
|
75
|
-
|
81
|
+
const char *buffer_end = buffer + length;
|
82
|
+
|
83
|
+
if (git_oid__parse(&tag->target, &buffer, buffer_end, "object ") < 0)
|
84
|
+
return tag_error("Object field invalid");
|
76
85
|
|
77
86
|
if (buffer + 5 >= buffer_end)
|
78
|
-
return
|
87
|
+
return tag_error("Object too short");
|
79
88
|
|
80
89
|
if (memcmp(buffer, "type ", 5) != 0)
|
81
|
-
return
|
90
|
+
return tag_error("Type field not found");
|
82
91
|
buffer += 5;
|
83
92
|
|
84
93
|
tag->type = GIT_OBJ_BAD;
|
@@ -87,7 +96,7 @@ static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer
|
|
87
96
|
size_t type_length = strlen(tag_types[i]);
|
88
97
|
|
89
98
|
if (buffer + type_length >= buffer_end)
|
90
|
-
return
|
99
|
+
return tag_error("Object too short");
|
91
100
|
|
92
101
|
if (memcmp(buffer, tag_types[i], type_length) == 0) {
|
93
102
|
tag->type = i;
|
@@ -97,25 +106,24 @@ static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer
|
|
97
106
|
}
|
98
107
|
|
99
108
|
if (tag->type == GIT_OBJ_BAD)
|
100
|
-
return
|
109
|
+
return tag_error("Invalid object type");
|
101
110
|
|
102
111
|
if (buffer + 4 >= buffer_end)
|
103
|
-
return
|
112
|
+
return tag_error("Object too short");
|
104
113
|
|
105
114
|
if (memcmp(buffer, "tag ", 4) != 0)
|
106
|
-
return
|
115
|
+
return tag_error("Tag field not found");
|
107
116
|
|
108
117
|
buffer += 4;
|
109
118
|
|
110
119
|
search = memchr(buffer, '\n', buffer_end - buffer);
|
111
120
|
if (search == NULL)
|
112
|
-
return
|
121
|
+
return tag_error("Object too short");
|
113
122
|
|
114
123
|
text_len = search - buffer;
|
115
124
|
|
116
125
|
tag->tag_name = git__malloc(text_len + 1);
|
117
|
-
|
118
|
-
return GIT_ENOMEM;
|
126
|
+
GITERR_CHECK_ALLOC(tag->tag_name);
|
119
127
|
|
120
128
|
memcpy(tag->tag_name, buffer, text_len);
|
121
129
|
tag->tag_name[text_len] = '\0';
|
@@ -125,44 +133,59 @@ static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer
|
|
125
133
|
tag->tagger = NULL;
|
126
134
|
if (*buffer != '\n') {
|
127
135
|
tag->tagger = git__malloc(sizeof(git_signature));
|
128
|
-
|
129
|
-
return GIT_ENOMEM;
|
136
|
+
GITERR_CHECK_ALLOC(tag->tagger);
|
130
137
|
|
131
|
-
if (
|
132
|
-
return
|
133
|
-
}
|
138
|
+
if (git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ", '\n') < 0)
|
139
|
+
return -1;
|
134
140
|
}
|
135
141
|
|
136
142
|
if( *buffer != '\n' )
|
137
|
-
return
|
143
|
+
return tag_error("No new line before message");
|
138
144
|
|
139
145
|
text_len = buffer_end - ++buffer;
|
140
146
|
|
141
147
|
tag->message = git__malloc(text_len + 1);
|
142
|
-
|
143
|
-
return GIT_ENOMEM;
|
148
|
+
GITERR_CHECK_ALLOC(tag->message);
|
144
149
|
|
145
150
|
memcpy(tag->message, buffer, text_len);
|
146
151
|
tag->message[text_len] = '\0';
|
147
152
|
|
148
|
-
return
|
153
|
+
return 0;
|
149
154
|
}
|
150
155
|
|
151
|
-
static int retrieve_tag_reference(
|
156
|
+
static int retrieve_tag_reference(
|
157
|
+
git_reference **tag_reference_out,
|
158
|
+
git_buf *ref_name_out,
|
159
|
+
git_repository *repo,
|
160
|
+
const char *tag_name)
|
152
161
|
{
|
153
162
|
git_reference *tag_ref;
|
154
163
|
int error;
|
155
164
|
|
156
165
|
*tag_reference_out = NULL;
|
157
166
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
167
|
+
if (git_buf_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0)
|
168
|
+
return -1;
|
169
|
+
|
170
|
+
error = git_reference_lookup(&tag_ref, repo, ref_name_out->ptr);
|
171
|
+
if (error < 0)
|
172
|
+
return error; /* Be it not foundo or corrupted */
|
162
173
|
|
163
174
|
*tag_reference_out = tag_ref;
|
164
175
|
|
165
|
-
return
|
176
|
+
return 0;
|
177
|
+
}
|
178
|
+
|
179
|
+
static int retrieve_tag_reference_oid(
|
180
|
+
git_oid *oid,
|
181
|
+
git_buf *ref_name_out,
|
182
|
+
git_repository *repo,
|
183
|
+
const char *tag_name)
|
184
|
+
{
|
185
|
+
if (git_buf_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0)
|
186
|
+
return -1;
|
187
|
+
|
188
|
+
return git_reference_name_to_oid(oid, repo, ref_name_out->ptr);
|
166
189
|
}
|
167
190
|
|
168
191
|
static int write_tag_annotation(
|
@@ -173,8 +196,7 @@ static int write_tag_annotation(
|
|
173
196
|
const git_signature *tagger,
|
174
197
|
const char *message)
|
175
198
|
{
|
176
|
-
|
177
|
-
git_buf tag = GIT_BUF_INIT;
|
199
|
+
git_buf tag = GIT_BUF_INIT, cleaned_message = GIT_BUF_INIT;
|
178
200
|
git_odb *odb;
|
179
201
|
|
180
202
|
git_oid__writebuf(&tag, "object ", git_object_id(target));
|
@@ -182,26 +204,30 @@ static int write_tag_annotation(
|
|
182
204
|
git_buf_printf(&tag, "tag %s\n", tag_name);
|
183
205
|
git_signature__writebuf(&tag, "tagger ", tagger);
|
184
206
|
git_buf_putc(&tag, '\n');
|
185
|
-
git_buf_puts(&tag, message);
|
186
207
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
}
|
208
|
+
/* Remove comments by default */
|
209
|
+
if (git_message_prettify(&cleaned_message, message, 1) < 0)
|
210
|
+
goto on_error;
|
191
211
|
|
192
|
-
|
193
|
-
|
194
|
-
git_buf_free(&tag);
|
195
|
-
return error;
|
196
|
-
}
|
212
|
+
if (git_buf_puts(&tag, git_buf_cstr(&cleaned_message)) < 0)
|
213
|
+
goto on_error;
|
197
214
|
|
198
|
-
|
199
|
-
git_buf_free(&tag);
|
215
|
+
git_buf_free(&cleaned_message);
|
200
216
|
|
201
|
-
if (
|
202
|
-
|
217
|
+
if (git_repository_odb__weakptr(&odb, repo) < 0)
|
218
|
+
goto on_error;
|
203
219
|
|
204
|
-
|
220
|
+
if (git_odb_write(oid, odb, tag.ptr, tag.size, GIT_OBJ_TAG) < 0)
|
221
|
+
goto on_error;
|
222
|
+
|
223
|
+
git_buf_free(&tag);
|
224
|
+
return 0;
|
225
|
+
|
226
|
+
on_error:
|
227
|
+
git_buf_free(&tag);
|
228
|
+
git_buf_free(&cleaned_message);
|
229
|
+
giterr_set(GITERR_OBJECT, "Failed to create tag annotation.");
|
230
|
+
return -1;
|
205
231
|
}
|
206
232
|
|
207
233
|
static int git_tag_create__internal(
|
@@ -215,56 +241,41 @@ static int git_tag_create__internal(
|
|
215
241
|
int create_tag_annotation)
|
216
242
|
{
|
217
243
|
git_reference *new_ref = NULL;
|
218
|
-
|
244
|
+
git_buf ref_name = GIT_BUF_INIT;
|
219
245
|
|
220
|
-
int error
|
246
|
+
int error;
|
221
247
|
|
222
248
|
assert(repo && tag_name && target);
|
223
249
|
assert(!create_tag_annotation || (tagger && message));
|
224
250
|
|
225
|
-
if (git_object_owner(target) != repo)
|
226
|
-
|
227
|
-
|
228
|
-
error = retrieve_tag_reference(&new_ref, ref_name, repo, tag_name);
|
229
|
-
|
230
|
-
switch (error) {
|
231
|
-
case GIT_SUCCESS:
|
232
|
-
case GIT_ENOTFOUND:
|
233
|
-
break;
|
234
|
-
|
235
|
-
default:
|
236
|
-
git_reference_free(new_ref);
|
237
|
-
return git__rethrow(error, "Failed to create tag");
|
251
|
+
if (git_object_owner(target) != repo) {
|
252
|
+
giterr_set(GITERR_INVALID, "The given target does not belong to this repository");
|
253
|
+
return -1;
|
238
254
|
}
|
239
255
|
|
256
|
+
error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag_name);
|
257
|
+
if (error < 0 && error != GIT_ENOTFOUND)
|
258
|
+
return -1;
|
259
|
+
|
240
260
|
/** Ensure the tag name doesn't conflict with an already existing
|
241
261
|
* reference unless overwriting has explictly been requested **/
|
242
|
-
if (
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
return git__throw(GIT_EEXISTS, "Tag already exists");
|
247
|
-
} else {
|
248
|
-
should_update_ref = 1;
|
249
|
-
}
|
262
|
+
if (error == 0 && !allow_ref_overwrite) {
|
263
|
+
git_buf_free(&ref_name);
|
264
|
+
giterr_set(GITERR_TAG, "Tag already exists");
|
265
|
+
return GIT_EEXISTS;
|
250
266
|
}
|
251
267
|
|
252
268
|
if (create_tag_annotation) {
|
253
|
-
if (
|
254
|
-
|
255
|
-
return error;
|
256
|
-
}
|
269
|
+
if (write_tag_annotation(oid, repo, tag_name, target, tagger, message) < 0)
|
270
|
+
return -1;
|
257
271
|
} else
|
258
272
|
git_oid_cpy(oid, git_object_id(target));
|
259
273
|
|
260
|
-
|
261
|
-
error = git_reference_create_oid(&new_ref, repo, ref_name, oid, 0);
|
262
|
-
else
|
263
|
-
error = git_reference_set_oid(new_ref, oid);
|
274
|
+
error = git_reference_create_oid(&new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite);
|
264
275
|
|
265
276
|
git_reference_free(new_ref);
|
266
|
-
|
267
|
-
return error
|
277
|
+
git_buf_free(&ref_name);
|
278
|
+
return error;
|
268
279
|
}
|
269
280
|
|
270
281
|
int git_tag_create(
|
@@ -292,98 +303,92 @@ int git_tag_create_lightweight(
|
|
292
303
|
int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *buffer, int allow_ref_overwrite)
|
293
304
|
{
|
294
305
|
git_tag tag;
|
295
|
-
int error
|
306
|
+
int error;
|
296
307
|
git_odb *odb;
|
297
308
|
git_odb_stream *stream;
|
298
309
|
git_odb_object *target_obj;
|
299
310
|
|
300
311
|
git_reference *new_ref = NULL;
|
301
|
-
|
312
|
+
git_buf ref_name = GIT_BUF_INIT;
|
302
313
|
|
303
314
|
assert(oid && buffer);
|
304
315
|
|
305
316
|
memset(&tag, 0, sizeof(tag));
|
306
317
|
|
307
|
-
|
308
|
-
|
309
|
-
return error;
|
318
|
+
if (git_repository_odb__weakptr(&odb, repo) < 0)
|
319
|
+
return -1;
|
310
320
|
|
311
321
|
/* validate the buffer */
|
312
|
-
if ((
|
313
|
-
return
|
322
|
+
if (git_tag__parse_buffer(&tag, buffer, strlen(buffer)) < 0)
|
323
|
+
return -1;
|
314
324
|
|
315
325
|
/* validate the target */
|
316
|
-
if (
|
317
|
-
|
318
|
-
|
319
|
-
if (tag.type != target_obj->raw.type)
|
320
|
-
return git__throw(error, "The type for the given target is invalid");
|
321
|
-
|
322
|
-
git_odb_object_free(target_obj);
|
326
|
+
if (git_odb_read(&target_obj, odb, &tag.target) < 0)
|
327
|
+
goto on_error;
|
323
328
|
|
324
|
-
|
329
|
+
if (tag.type != target_obj->raw.type) {
|
330
|
+
giterr_set(GITERR_TAG, "The type for the given target is invalid");
|
331
|
+
goto on_error;
|
332
|
+
}
|
325
333
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
break;
|
334
|
+
error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag.tag_name);
|
335
|
+
if (error < 0 && error != GIT_ENOTFOUND)
|
336
|
+
goto on_error;
|
330
337
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
338
|
+
/* We don't need these objects after this */
|
339
|
+
git_signature_free(tag.tagger);
|
340
|
+
git__free(tag.tag_name);
|
341
|
+
git__free(tag.message);
|
342
|
+
git_odb_object_free(target_obj);
|
335
343
|
|
336
344
|
/** Ensure the tag name doesn't conflict with an already existing
|
337
345
|
* reference unless overwriting has explictly been requested **/
|
338
|
-
if (
|
339
|
-
|
340
|
-
|
341
|
-
git_reference_free(new_ref);
|
342
|
-
return git__throw(GIT_EEXISTS, "Tag already exists");
|
343
|
-
} else {
|
344
|
-
should_update_ref = 1;
|
345
|
-
}
|
346
|
+
if (error == 0 && !allow_ref_overwrite) {
|
347
|
+
giterr_set(GITERR_TAG, "Tag already exists");
|
348
|
+
return GIT_EEXISTS;
|
346
349
|
}
|
347
350
|
|
348
351
|
/* write the buffer */
|
349
|
-
if (
|
350
|
-
|
351
|
-
return git__rethrow(error, "Failed to create tag");
|
352
|
-
}
|
352
|
+
if (git_odb_open_wstream(&stream, odb, strlen(buffer), GIT_OBJ_TAG) < 0)
|
353
|
+
return -1;
|
353
354
|
|
354
355
|
stream->write(stream, buffer, strlen(buffer));
|
355
356
|
|
356
357
|
error = stream->finalize_write(oid, stream);
|
357
358
|
stream->free(stream);
|
358
359
|
|
359
|
-
if (error <
|
360
|
-
|
361
|
-
return
|
360
|
+
if (error < 0) {
|
361
|
+
git_buf_free(&ref_name);
|
362
|
+
return -1;
|
362
363
|
}
|
363
364
|
|
364
|
-
|
365
|
-
error = git_reference_create_oid(&new_ref, repo, ref_name, oid, 0);
|
366
|
-
else
|
367
|
-
error = git_reference_set_oid(new_ref, oid);
|
365
|
+
error = git_reference_create_oid(&new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite);
|
368
366
|
|
369
367
|
git_reference_free(new_ref);
|
368
|
+
git_buf_free(&ref_name);
|
369
|
+
|
370
|
+
return error;
|
370
371
|
|
372
|
+
on_error:
|
371
373
|
git_signature_free(tag.tagger);
|
372
374
|
git__free(tag.tag_name);
|
373
375
|
git__free(tag.message);
|
374
|
-
|
375
|
-
return
|
376
|
+
git_odb_object_free(target_obj);
|
377
|
+
return -1;
|
376
378
|
}
|
377
379
|
|
378
380
|
int git_tag_delete(git_repository *repo, const char *tag_name)
|
379
381
|
{
|
380
382
|
int error;
|
381
383
|
git_reference *tag_ref;
|
382
|
-
|
384
|
+
git_buf ref_name = GIT_BUF_INIT;
|
385
|
+
|
386
|
+
error = retrieve_tag_reference(&tag_ref, &ref_name, repo, tag_name);
|
383
387
|
|
384
|
-
|
385
|
-
|
386
|
-
|
388
|
+
git_buf_free(&ref_name);
|
389
|
+
|
390
|
+
if (error < 0)
|
391
|
+
return -1;
|
387
392
|
|
388
393
|
return git_reference_delete(tag_ref);
|
389
394
|
}
|
@@ -391,7 +396,7 @@ int git_tag_delete(git_repository *repo, const char *tag_name)
|
|
391
396
|
int git_tag__parse(git_tag *tag, git_odb_object *obj)
|
392
397
|
{
|
393
398
|
assert(tag);
|
394
|
-
return
|
399
|
+
return git_tag__parse_buffer(tag, obj->raw.data, obj->raw.len);
|
395
400
|
}
|
396
401
|
|
397
402
|
typedef struct {
|
@@ -406,13 +411,13 @@ static int tag_list_cb(const char *tag_name, void *payload)
|
|
406
411
|
tag_filter_data *filter;
|
407
412
|
|
408
413
|
if (git__prefixcmp(tag_name, GIT_REFS_TAGS_DIR) != 0)
|
409
|
-
return
|
414
|
+
return 0;
|
410
415
|
|
411
416
|
filter = (tag_filter_data *)payload;
|
412
|
-
if (!*filter->pattern || p_fnmatch(filter->pattern, tag_name + GIT_REFS_TAGS_DIR_LEN, 0) ==
|
417
|
+
if (!*filter->pattern || p_fnmatch(filter->pattern, tag_name + GIT_REFS_TAGS_DIR_LEN, 0) == 0)
|
413
418
|
return git_vector_insert(filter->taglist, git__strdup(tag_name));
|
414
419
|
|
415
|
-
return
|
420
|
+
return 0;
|
416
421
|
}
|
417
422
|
|
418
423
|
int git_tag_list_match(git_strarray *tag_names, const char *pattern, git_repository *repo)
|
@@ -423,24 +428,44 @@ int git_tag_list_match(git_strarray *tag_names, const char *pattern, git_reposit
|
|
423
428
|
|
424
429
|
assert(tag_names && repo && pattern);
|
425
430
|
|
426
|
-
if (git_vector_init(&taglist, 8, NULL) <
|
427
|
-
return
|
431
|
+
if (git_vector_init(&taglist, 8, NULL) < 0)
|
432
|
+
return -1;
|
428
433
|
|
429
434
|
filter.taglist = &taglist;
|
430
435
|
filter.pattern = pattern;
|
431
436
|
|
432
437
|
error = git_reference_foreach(repo, GIT_REF_OID|GIT_REF_PACKED, &tag_list_cb, (void *)&filter);
|
433
|
-
if (error <
|
438
|
+
if (error < 0) {
|
434
439
|
git_vector_free(&taglist);
|
435
|
-
return
|
440
|
+
return -1;
|
436
441
|
}
|
437
442
|
|
438
443
|
tag_names->strings = (char **)taglist.contents;
|
439
444
|
tag_names->count = taglist.length;
|
440
|
-
return
|
445
|
+
return 0;
|
441
446
|
}
|
442
447
|
|
443
448
|
int git_tag_list(git_strarray *tag_names, git_repository *repo)
|
444
449
|
{
|
445
450
|
return git_tag_list_match(tag_names, "", repo);
|
446
451
|
}
|
452
|
+
|
453
|
+
int git_tag_peel(git_object **tag_target, git_tag *tag)
|
454
|
+
{
|
455
|
+
int error;
|
456
|
+
git_object *target;
|
457
|
+
|
458
|
+
assert(tag_target && tag);
|
459
|
+
|
460
|
+
if (git_tag_target(&target, tag) < 0)
|
461
|
+
return -1;
|
462
|
+
|
463
|
+
if (git_object_type(target) == GIT_OBJ_TAG) {
|
464
|
+
error = git_tag_peel(tag_target, (git_tag *)target);
|
465
|
+
git_object_free(target);
|
466
|
+
return error;
|
467
|
+
}
|
468
|
+
|
469
|
+
*tag_target = target;
|
470
|
+
return 0;
|
471
|
+
}
|
@@ -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.
|
@@ -24,5 +24,6 @@ struct git_tag {
|
|
24
24
|
|
25
25
|
void git_tag__free(git_tag *tag);
|
26
26
|
int git_tag__parse(git_tag *tag, git_odb_object *obj);
|
27
|
+
int git_tag__parse_buffer(git_tag *tag, const char *data, size_t len);
|
27
28
|
|
28
29
|
#endif
|
@@ -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.
|
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
/* Common operations even if threading has been disabled */
|
13
13
|
typedef struct {
|
14
|
-
#if defined(
|
14
|
+
#if defined(GIT_WIN32)
|
15
15
|
volatile long val;
|
16
16
|
#else
|
17
17
|
volatile int val;
|
@@ -48,10 +48,10 @@ GIT_INLINE(void) git_atomic_set(git_atomic *a, int val)
|
|
48
48
|
|
49
49
|
GIT_INLINE(int) git_atomic_inc(git_atomic *a)
|
50
50
|
{
|
51
|
-
#
|
52
|
-
return __sync_add_and_fetch(&a->val, 1);
|
53
|
-
#elif defined(_MSC_VER)
|
51
|
+
#if defined(GIT_WIN32)
|
54
52
|
return InterlockedIncrement(&a->val);
|
53
|
+
#elif defined(__GNUC__)
|
54
|
+
return __sync_add_and_fetch(&a->val, 1);
|
55
55
|
#else
|
56
56
|
# error "Unsupported architecture for atomic operations"
|
57
57
|
#endif
|
@@ -59,10 +59,10 @@ GIT_INLINE(int) git_atomic_inc(git_atomic *a)
|
|
59
59
|
|
60
60
|
GIT_INLINE(int) git_atomic_dec(git_atomic *a)
|
61
61
|
{
|
62
|
-
#
|
63
|
-
return __sync_sub_and_fetch(&a->val, 1);
|
64
|
-
#elif defined(_MSC_VER)
|
62
|
+
#if defined(GIT_WIN32)
|
65
63
|
return InterlockedDecrement(&a->val);
|
64
|
+
#elif defined(__GNUC__)
|
65
|
+
return __sync_sub_and_fetch(&a->val, 1);
|
66
66
|
#else
|
67
67
|
# error "Unsupported architecture for atomic operations"
|
68
68
|
#endif
|
@@ -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.
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#include "git2/remote.h"
|
10
10
|
#include "git2/net.h"
|
11
11
|
#include "transport.h"
|
12
|
+
#include "path.h"
|
12
13
|
|
13
14
|
static struct {
|
14
15
|
char *prefix;
|
@@ -16,26 +17,33 @@ static struct {
|
|
16
17
|
} transports[] = {
|
17
18
|
{"git://", git_transport_git},
|
18
19
|
{"http://", git_transport_http},
|
19
|
-
{"https://",
|
20
|
+
{"https://", git_transport_https},
|
20
21
|
{"file://", git_transport_local},
|
21
22
|
{"git+ssh://", git_transport_dummy},
|
22
23
|
{"ssh+git://", git_transport_dummy},
|
23
24
|
{NULL, 0}
|
24
25
|
};
|
25
26
|
|
26
|
-
#define GIT_TRANSPORT_COUNT (sizeof(transports)/sizeof(transports[0]))
|
27
|
+
#define GIT_TRANSPORT_COUNT (sizeof(transports)/sizeof(transports[0])) - 1
|
27
28
|
|
28
29
|
static git_transport_cb transport_find_fn(const char *url)
|
29
30
|
{
|
30
31
|
size_t i = 0;
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
// First, check to see if it's an obvious URL, which a URL scheme
|
34
34
|
for (i = 0; i < GIT_TRANSPORT_COUNT; ++i) {
|
35
35
|
if (!strncasecmp(url, transports[i].prefix, strlen(transports[i].prefix)))
|
36
36
|
return transports[i].fn;
|
37
37
|
}
|
38
38
|
|
39
|
+
/* still here? Check to see if the path points to a file on the local file system */
|
40
|
+
if ((git_path_exists(url) == 0) && git_path_isdir(url))
|
41
|
+
return &git_transport_local;
|
42
|
+
|
43
|
+
/* It could be a SSH remote path. Check to see if there's a : */
|
44
|
+
if (strrchr(url, ':'))
|
45
|
+
return &git_transport_dummy; /* SSH is an unsupported transport mechanism in this version of libgit2 */
|
46
|
+
|
39
47
|
return NULL;
|
40
48
|
}
|
41
49
|
|
@@ -43,10 +51,11 @@ static git_transport_cb transport_find_fn(const char *url)
|
|
43
51
|
* Public API *
|
44
52
|
**************/
|
45
53
|
|
46
|
-
int git_transport_dummy(git_transport **
|
54
|
+
int git_transport_dummy(git_transport **transport)
|
47
55
|
{
|
48
|
-
|
49
|
-
|
56
|
+
GIT_UNUSED(transport);
|
57
|
+
giterr_set(GITERR_NET, "This transport isn't implemented. Sorry");
|
58
|
+
return -1;
|
50
59
|
}
|
51
60
|
|
52
61
|
int git_transport_new(git_transport **out, const char *url)
|
@@ -57,24 +66,21 @@ int git_transport_new(git_transport **out, const char *url)
|
|
57
66
|
|
58
67
|
fn = transport_find_fn(url);
|
59
68
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
if (fn == NULL)
|
65
|
-
fn = &git_transport_local;
|
69
|
+
if (fn == NULL) {
|
70
|
+
giterr_set(GITERR_NET, "Unsupported URL protocol");
|
71
|
+
return -1;
|
72
|
+
}
|
66
73
|
|
67
74
|
error = fn(&transport);
|
68
|
-
if (error <
|
69
|
-
return
|
75
|
+
if (error < 0)
|
76
|
+
return error;
|
70
77
|
|
71
78
|
transport->url = git__strdup(url);
|
72
|
-
|
73
|
-
return GIT_ENOMEM;
|
79
|
+
GITERR_CHECK_ALLOC(transport->url);
|
74
80
|
|
75
81
|
*out = transport;
|
76
82
|
|
77
|
-
return
|
83
|
+
return 0;
|
78
84
|
}
|
79
85
|
|
80
86
|
/* from remote.h */
|
@@ -83,3 +89,9 @@ int git_remote_valid_url(const char *url)
|
|
83
89
|
return transport_find_fn(url) != NULL;
|
84
90
|
}
|
85
91
|
|
92
|
+
int git_remote_supported_url(const char* url)
|
93
|
+
{
|
94
|
+
git_transport_cb transport_fn = transport_find_fn(url);
|
95
|
+
|
96
|
+
return ((transport_fn != NULL) && (transport_fn != &git_transport_dummy));
|
97
|
+
}
|