rugged 0.1.2 → 0.16.0b1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +25 -36
- data/Rakefile +20 -98
- data/ext/rugged/extconf.rb +44 -4
- data/ext/rugged/remote.c +215 -0
- data/ext/rugged/rugged.c +171 -0
- data/ext/rugged/rugged.h +126 -0
- data/ext/rugged/rugged_blob.c +99 -0
- data/ext/rugged/rugged_commit.c +224 -0
- data/ext/rugged/rugged_config.c +238 -0
- data/ext/rugged/rugged_index.c +440 -0
- data/ext/rugged/rugged_object.c +203 -0
- data/ext/rugged/rugged_reference.c +401 -0
- data/ext/rugged/rugged_repo.c +482 -0
- data/ext/rugged/rugged_revwalk.c +138 -0
- data/ext/rugged/rugged_signature.c +80 -0
- data/ext/rugged/rugged_tag.c +216 -0
- data/ext/rugged/rugged_tree.c +322 -0
- data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
- data/ext/rugged/vendor/libgit2-dist/deps/http-parser/http_parser.c +1778 -0
- data/ext/rugged/vendor/libgit2-dist/deps/http-parser/http_parser.h +267 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/adler32.c +169 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/crc32.c +442 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/crc32.h +441 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/deflate.c +1834 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/deflate.h +342 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffast.c +340 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffast.h +11 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffixed.h +94 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inflate.c +1480 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inflate.h +122 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inftrees.c +330 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inftrees.h +62 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/trees.c +1244 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/trees.h +128 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zconf.h +54 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zlib.h +1613 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zutil.c +318 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zutil.h +274 -0
- data/ext/rugged/vendor/libgit2-dist/examples/general.c +451 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/common.h +14 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +97 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +58 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +47 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +76 -0
- data/ext/rugged/vendor/libgit2-dist/examples/showindex.c +43 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2.h +44 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/blob.h +120 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/branch.h +15 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/commit.h +263 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/common.h +103 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/config.h +278 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/errors.h +144 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/index.h +306 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/indexer.h +76 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/inttypes.h +305 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/net.h +51 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/object.h +173 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/odb.h +331 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/odb_backend.h +100 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/oid.h +218 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/reflog.h +128 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/refs.h +309 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/refspec.h +60 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/remote.h +176 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/repository.h +290 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/revwalk.h +169 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/signature.h +65 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/status.h +63 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/stdint.h +247 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/tag.h +279 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/threads.h +48 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/tree.h +318 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/types.h +169 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/version.h +15 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/windows.h +59 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/zlib.h +40 -0
- data/ext/rugged/vendor/libgit2-dist/src/blob.c +135 -0
- data/ext/rugged/vendor/libgit2-dist/src/blob.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/bswap.h +97 -0
- data/ext/rugged/vendor/libgit2-dist/src/buffer.c +113 -0
- data/ext/rugged/vendor/libgit2-dist/src/buffer.h +32 -0
- data/ext/rugged/vendor/libgit2-dist/src/cache.c +111 -0
- data/ext/rugged/vendor/libgit2-dist/src/cache.h +64 -0
- data/ext/rugged/vendor/libgit2-dist/src/cc-compat.h +67 -0
- data/ext/rugged/vendor/libgit2-dist/src/commit.c +299 -0
- data/ext/rugged/vendor/libgit2-dist/src/commit.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/common.h +64 -0
- data/ext/rugged/vendor/libgit2-dist/src/config.c +418 -0
- data/ext/rugged/vendor/libgit2-dist/src/config.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/config_file.c +1210 -0
- data/ext/rugged/vendor/libgit2-dist/src/delta-apply.c +115 -0
- data/ext/rugged/vendor/libgit2-dist/src/delta-apply.h +33 -0
- data/ext/rugged/vendor/libgit2-dist/src/dir.h +47 -0
- data/ext/rugged/vendor/libgit2-dist/src/errors.c +104 -0
- data/ext/rugged/vendor/libgit2-dist/src/fetch.c +172 -0
- data/ext/rugged/vendor/libgit2-dist/src/fetch.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/filebuf.c +400 -0
- data/ext/rugged/vendor/libgit2-dist/src/filebuf.h +72 -0
- data/ext/rugged/vendor/libgit2-dist/src/fileops.c +358 -0
- data/ext/rugged/vendor/libgit2-dist/src/fileops.h +151 -0
- data/ext/rugged/vendor/libgit2-dist/src/global.c +134 -0
- data/ext/rugged/vendor/libgit2-dist/src/global.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/hash.c +74 -0
- data/ext/rugged/vendor/libgit2-dist/src/hash.h +29 -0
- data/ext/rugged/vendor/libgit2-dist/src/hashtable.c +243 -0
- data/ext/rugged/vendor/libgit2-dist/src/hashtable.h +80 -0
- data/ext/rugged/vendor/libgit2-dist/src/index.c +918 -0
- data/ext/rugged/vendor/libgit2-dist/src/index.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/indexer.c +401 -0
- data/ext/rugged/vendor/libgit2-dist/src/map.h +37 -0
- data/ext/rugged/vendor/libgit2-dist/src/mwindow.c +272 -0
- data/ext/rugged/vendor/libgit2-dist/src/mwindow.h +45 -0
- data/ext/rugged/vendor/libgit2-dist/src/netops.c +198 -0
- data/ext/rugged/vendor/libgit2-dist/src/netops.h +36 -0
- data/ext/rugged/vendor/libgit2-dist/src/object.c +295 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb.c +672 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb.h +43 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb_loose.c +855 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb_pack.c +485 -0
- data/ext/rugged/vendor/libgit2-dist/src/oid.c +388 -0
- data/ext/rugged/vendor/libgit2-dist/src/pack.c +788 -0
- data/ext/rugged/vendor/libgit2-dist/src/pack.h +99 -0
- data/ext/rugged/vendor/libgit2-dist/src/path.c +270 -0
- data/ext/rugged/vendor/libgit2-dist/src/path.h +84 -0
- data/ext/rugged/vendor/libgit2-dist/src/pkt.c +426 -0
- data/ext/rugged/vendor/libgit2-dist/src/pkt.h +77 -0
- data/ext/rugged/vendor/libgit2-dist/src/posix.c +94 -0
- data/ext/rugged/vendor/libgit2-dist/src/posix.h +69 -0
- data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.c +70 -0
- data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.h +26 -0
- data/ext/rugged/vendor/libgit2-dist/src/pqueue.c +141 -0
- data/ext/rugged/vendor/libgit2-dist/src/pqueue.h +81 -0
- data/ext/rugged/vendor/libgit2-dist/src/protocol.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/src/protocol.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/reflog.c +318 -0
- data/ext/rugged/vendor/libgit2-dist/src/reflog.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/refs.c +1693 -0
- data/ext/rugged/vendor/libgit2-dist/src/refs.h +58 -0
- data/ext/rugged/vendor/libgit2-dist/src/refspec.c +95 -0
- data/ext/rugged/vendor/libgit2-dist/src/refspec.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/remote.c +339 -0
- data/ext/rugged/vendor/libgit2-dist/src/remote.h +25 -0
- data/ext/rugged/vendor/libgit2-dist/src/repository.c +849 -0
- data/ext/rugged/vendor/libgit2-dist/src/repository.h +60 -0
- data/ext/rugged/vendor/libgit2-dist/src/revwalk.c +569 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1.c +280 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1.h +21 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.c +177 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/signature.c +335 -0
- data/ext/rugged/vendor/libgit2-dist/src/signature.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/status.c +696 -0
- data/ext/rugged/vendor/libgit2-dist/src/tag.c +446 -0
- data/ext/rugged/vendor/libgit2-dist/src/tag.h +28 -0
- data/ext/rugged/vendor/libgit2-dist/src/thread-utils.c +55 -0
- data/ext/rugged/vendor/libgit2-dist/src/thread-utils.h +108 -0
- data/ext/rugged/vendor/libgit2-dist/src/transport.c +85 -0
- data/ext/rugged/vendor/libgit2-dist/src/transport.h +110 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +502 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/http.c +756 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/local.c +235 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree-cache.c +201 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree-cache.h +31 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree.c +758 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree.h +37 -0
- data/ext/rugged/vendor/libgit2-dist/src/tsort.c +365 -0
- data/ext/rugged/vendor/libgit2-dist/src/unix/map.c +70 -0
- data/ext/rugged/vendor/libgit2-dist/src/unix/posix.h +25 -0
- data/ext/rugged/vendor/libgit2-dist/src/util.c +381 -0
- data/ext/rugged/vendor/libgit2-dist/src/util.h +137 -0
- data/ext/rugged/vendor/libgit2-dist/src/vector.c +174 -0
- data/ext/rugged/vendor/libgit2-dist/src/vector.h +45 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/dir.c +115 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/fnmatch.c +180 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/fnmatch.h +27 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/map.c +131 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/mingw-compat.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/msvc-compat.h +38 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/posix.h +53 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/posix_w32.c +404 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.c +65 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.h +40 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.c +88 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.h +17 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/buf/basic.c +29 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay.h +187 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_libgit2.h +28 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_main.c +1073 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/add.c +37 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/new.c +36 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/read.c +209 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/stress.c +39 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/write.c +77 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/dirent.c +222 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/filebuf.c +106 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/oid.c +18 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/path.c +139 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/rmdir.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/string.c +28 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/strtol.c +37 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/vector.c +66 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/index/rename.c +60 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/network/remotes.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/chars.c +52 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/compare.c +124 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/convert.c +75 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/data.h +323 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/fromstr.c +30 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/hash.c +162 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/short.c +94 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/size.c +13 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/type2string.c +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/tree/frompath.c +75 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/loose.c +84 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/loose_data.h +522 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/pack_data.h +151 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/packed.c +78 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/sorting.c +71 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/getters.c +68 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/init.c +104 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/open.c +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/single.c +38 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/status_data.h +48 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/worktree.c +124 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t00-core.c +628 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t01-data.h +322 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t01-rawobj.c +638 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t03-data.h +344 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t03-objwrite.c +255 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t04-commit.c +788 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t05-revwalk.c +140 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t06-index.c +219 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t07-hashtable.c +192 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t08-tag.c +357 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t09-tree.c +221 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t10-refs.c +1294 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t12-repo.c +174 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t13-threads.c +41 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t17-bufs.c +61 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t18-status.c +448 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.c +310 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.h +83 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_lib.c +198 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_lib.h +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_main.c +89 -0
- data/lib/rugged.rb +4 -3
- data/lib/rugged/index.rb +0 -8
- data/lib/rugged/objects.rb +45 -0
- data/lib/rugged/repository.rb +29 -0
- data/lib/rugged/tree.rb +16 -6
- data/lib/rugged/version.rb +1 -1
- data/lib/rugged/walker.rb +5 -0
- data/test/blob_test.rb +18 -14
- data/test/commit_test.rb +28 -26
- data/test/coverage/HEAD.json +1 -0
- data/test/coverage/cover.rb +106 -0
- data/test/fixtures/testrepo.git/refs/heads/new_name +1 -0
- data/test/index_test.rb +101 -78
- data/test/lib_test.rb +4 -4
- data/test/object_test.rb +3 -3
- data/test/reference_test.rb +75 -0
- data/test/remote_test.rb +19 -0
- data/test/repo_pack_test.rb +4 -4
- data/test/repo_test.rb +44 -15
- data/test/tag_test.rb +7 -17
- data/test/test_helper.rb +24 -5
- data/test/tree_test.rb +30 -12
- data/test/walker_test.rb +40 -31
- metadata +273 -50
- data/lib/rugged/person.rb +0 -20
- data/lib/rugged/tree_entry.rb +0 -9
- data/test/fixtures/testrepo.git/objects/1d/83f106355e4309a293e42ad2a2c4b8bdbe77ae +0 -0
- data/test/fixtures/testrepo.git/objects/2f/3321418db5b2a841375b8b70880a8ab5a4148f +0 -0
- data/test/fixtures/testrepo.git/objects/36/9b00a7700cca3a506d79e301d6ad8bf735d9ee +0 -3
- data/test/fixtures/testrepo.git/objects/3d/b1b5ceace59ff65279757003763046fd4cbbe6 +0 -0
- data/test/fixtures/testrepo.git/objects/4c/d1604907792e2c43e03dcec1216f99d63e68c4 +0 -3
- data/test/fixtures/testrepo.git/objects/e0/f46d77041c149296549b01ed4a18b02c4b7400 +0 -0
@@ -0,0 +1,446 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2011 the libgit2 contributors
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "common.h"
|
9
|
+
#include "commit.h"
|
10
|
+
#include "tag.h"
|
11
|
+
#include "signature.h"
|
12
|
+
#include "git2/object.h"
|
13
|
+
#include "git2/repository.h"
|
14
|
+
#include "git2/signature.h"
|
15
|
+
|
16
|
+
void git_tag__free(git_tag *tag)
|
17
|
+
{
|
18
|
+
git_signature_free(tag->tagger);
|
19
|
+
git__free(tag->message);
|
20
|
+
git__free(tag->tag_name);
|
21
|
+
git__free(tag);
|
22
|
+
}
|
23
|
+
|
24
|
+
const git_oid *git_tag_id(git_tag *c)
|
25
|
+
{
|
26
|
+
return git_object_id((git_object *)c);
|
27
|
+
}
|
28
|
+
|
29
|
+
int git_tag_target(git_object **target, git_tag *t)
|
30
|
+
{
|
31
|
+
assert(t);
|
32
|
+
return git_object_lookup(target, t->object.repo, &t->target, t->type);
|
33
|
+
}
|
34
|
+
|
35
|
+
const git_oid *git_tag_target_oid(git_tag *t)
|
36
|
+
{
|
37
|
+
assert(t);
|
38
|
+
return &t->target;
|
39
|
+
}
|
40
|
+
|
41
|
+
git_otype git_tag_type(git_tag *t)
|
42
|
+
{
|
43
|
+
assert(t);
|
44
|
+
return t->type;
|
45
|
+
}
|
46
|
+
|
47
|
+
const char *git_tag_name(git_tag *t)
|
48
|
+
{
|
49
|
+
assert(t);
|
50
|
+
return t->tag_name;
|
51
|
+
}
|
52
|
+
|
53
|
+
const git_signature *git_tag_tagger(git_tag *t)
|
54
|
+
{
|
55
|
+
return t->tagger;
|
56
|
+
}
|
57
|
+
|
58
|
+
const char *git_tag_message(git_tag *t)
|
59
|
+
{
|
60
|
+
assert(t);
|
61
|
+
return t->message;
|
62
|
+
}
|
63
|
+
|
64
|
+
static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer_end)
|
65
|
+
{
|
66
|
+
static const char *tag_types[] = {
|
67
|
+
NULL, "commit\n", "tree\n", "blob\n", "tag\n"
|
68
|
+
};
|
69
|
+
|
70
|
+
unsigned int i, text_len;
|
71
|
+
char *search;
|
72
|
+
int error;
|
73
|
+
|
74
|
+
if ((error = git_oid__parse(&tag->target, &buffer, buffer_end, "object ")) < 0)
|
75
|
+
return git__rethrow(error, "Failed to parse tag. Object field invalid");
|
76
|
+
|
77
|
+
if (buffer + 5 >= buffer_end)
|
78
|
+
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Object too short");
|
79
|
+
|
80
|
+
if (memcmp(buffer, "type ", 5) != 0)
|
81
|
+
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Type field not found");
|
82
|
+
buffer += 5;
|
83
|
+
|
84
|
+
tag->type = GIT_OBJ_BAD;
|
85
|
+
|
86
|
+
for (i = 1; i < ARRAY_SIZE(tag_types); ++i) {
|
87
|
+
size_t type_length = strlen(tag_types[i]);
|
88
|
+
|
89
|
+
if (buffer + type_length >= buffer_end)
|
90
|
+
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Object too short");
|
91
|
+
|
92
|
+
if (memcmp(buffer, tag_types[i], type_length) == 0) {
|
93
|
+
tag->type = i;
|
94
|
+
buffer += type_length;
|
95
|
+
break;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
if (tag->type == GIT_OBJ_BAD)
|
100
|
+
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Invalid object type");
|
101
|
+
|
102
|
+
if (buffer + 4 >= buffer_end)
|
103
|
+
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Object too short");
|
104
|
+
|
105
|
+
if (memcmp(buffer, "tag ", 4) != 0)
|
106
|
+
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Tag field not found");
|
107
|
+
|
108
|
+
buffer += 4;
|
109
|
+
|
110
|
+
search = memchr(buffer, '\n', buffer_end - buffer);
|
111
|
+
if (search == NULL)
|
112
|
+
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Object too short");
|
113
|
+
|
114
|
+
text_len = search - buffer;
|
115
|
+
|
116
|
+
tag->tag_name = git__malloc(text_len + 1);
|
117
|
+
if (tag->tag_name == NULL)
|
118
|
+
return GIT_ENOMEM;
|
119
|
+
|
120
|
+
memcpy(tag->tag_name, buffer, text_len);
|
121
|
+
tag->tag_name[text_len] = '\0';
|
122
|
+
|
123
|
+
buffer = search + 1;
|
124
|
+
|
125
|
+
tag->tagger = NULL;
|
126
|
+
if (*buffer != '\n') {
|
127
|
+
tag->tagger = git__malloc(sizeof(git_signature));
|
128
|
+
if (tag->tagger == NULL)
|
129
|
+
return GIT_ENOMEM;
|
130
|
+
|
131
|
+
if ((error = git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ", '\n') != 0)) {
|
132
|
+
return git__rethrow(error, "Failed to parse tag");
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
if( *buffer != '\n' )
|
137
|
+
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. No new line before message");
|
138
|
+
|
139
|
+
text_len = buffer_end - ++buffer;
|
140
|
+
|
141
|
+
tag->message = git__malloc(text_len + 1);
|
142
|
+
if (tag->message == NULL)
|
143
|
+
return GIT_ENOMEM;
|
144
|
+
|
145
|
+
memcpy(tag->message, buffer, text_len);
|
146
|
+
tag->message[text_len] = '\0';
|
147
|
+
|
148
|
+
return GIT_SUCCESS;
|
149
|
+
}
|
150
|
+
|
151
|
+
static int retrieve_tag_reference(git_reference **tag_reference_out, char *ref_name_out, git_repository *repo, const char *tag_name)
|
152
|
+
{
|
153
|
+
git_reference *tag_ref;
|
154
|
+
int error;
|
155
|
+
|
156
|
+
*tag_reference_out = NULL;
|
157
|
+
|
158
|
+
git_path_join(ref_name_out, GIT_REFS_TAGS_DIR, tag_name);
|
159
|
+
error = git_reference_lookup(&tag_ref, repo, ref_name_out);
|
160
|
+
if (error < GIT_SUCCESS)
|
161
|
+
return git__rethrow(error, "Failed to retrieve tag reference");
|
162
|
+
|
163
|
+
*tag_reference_out = tag_ref;
|
164
|
+
|
165
|
+
return GIT_SUCCESS;
|
166
|
+
}
|
167
|
+
|
168
|
+
static int write_tag_annotation(
|
169
|
+
git_oid *oid,
|
170
|
+
git_repository *repo,
|
171
|
+
const char *tag_name,
|
172
|
+
const git_object *target,
|
173
|
+
const git_signature *tagger,
|
174
|
+
const char *message)
|
175
|
+
{
|
176
|
+
int error = GIT_SUCCESS;
|
177
|
+
git_buf tag = GIT_BUF_INIT;
|
178
|
+
git_odb *odb;
|
179
|
+
|
180
|
+
git_oid__writebuf(&tag, "object ", git_object_id(target));
|
181
|
+
git_buf_printf(&tag, "type %s\n", git_object_type2string(git_object_type(target)));
|
182
|
+
git_buf_printf(&tag, "tag %s\n", tag_name);
|
183
|
+
git_signature__writebuf(&tag, "tagger ", tagger);
|
184
|
+
git_buf_putc(&tag, '\n');
|
185
|
+
git_buf_puts(&tag, message);
|
186
|
+
|
187
|
+
if (git_buf_oom(&tag)) {
|
188
|
+
git_buf_free(&tag);
|
189
|
+
return git__throw(GIT_ENOMEM, "Not enough memory to build the tag data");
|
190
|
+
}
|
191
|
+
|
192
|
+
error = git_repository_odb__weakptr(&odb, repo);
|
193
|
+
if (error < GIT_SUCCESS) {
|
194
|
+
git_buf_free(&tag);
|
195
|
+
return error;
|
196
|
+
}
|
197
|
+
|
198
|
+
error = git_odb_write(oid, odb, tag.ptr, tag.size, GIT_OBJ_TAG);
|
199
|
+
git_buf_free(&tag);
|
200
|
+
|
201
|
+
if (error < GIT_SUCCESS)
|
202
|
+
return git__rethrow(error, "Failed to create tag annotation");
|
203
|
+
|
204
|
+
return error;
|
205
|
+
}
|
206
|
+
|
207
|
+
static int git_tag_create__internal(
|
208
|
+
git_oid *oid,
|
209
|
+
git_repository *repo,
|
210
|
+
const char *tag_name,
|
211
|
+
const git_object *target,
|
212
|
+
const git_signature *tagger,
|
213
|
+
const char *message,
|
214
|
+
int allow_ref_overwrite,
|
215
|
+
int create_tag_annotation)
|
216
|
+
{
|
217
|
+
git_reference *new_ref = NULL;
|
218
|
+
char ref_name[GIT_REFNAME_MAX];
|
219
|
+
|
220
|
+
int error, should_update_ref = 0;
|
221
|
+
|
222
|
+
assert(repo && tag_name && target);
|
223
|
+
assert(!create_tag_annotation || (tagger && message));
|
224
|
+
|
225
|
+
if (git_object_owner(target) != repo)
|
226
|
+
return git__throw(GIT_EINVALIDARGS, "The given target does not belong to this repository");
|
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");
|
238
|
+
}
|
239
|
+
|
240
|
+
/** Ensure the tag name doesn't conflict with an already existing
|
241
|
+
* reference unless overwriting has explictly been requested **/
|
242
|
+
if (new_ref != NULL) {
|
243
|
+
if (!allow_ref_overwrite) {
|
244
|
+
git_oid_cpy(oid, git_reference_oid(new_ref));
|
245
|
+
git_reference_free(new_ref);
|
246
|
+
return git__throw(GIT_EEXISTS, "Tag already exists");
|
247
|
+
} else {
|
248
|
+
should_update_ref = 1;
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
if (create_tag_annotation) {
|
253
|
+
if ((error = write_tag_annotation(oid, repo, tag_name, target, tagger, message)) < GIT_SUCCESS) {
|
254
|
+
git_reference_free(new_ref);
|
255
|
+
return error;
|
256
|
+
}
|
257
|
+
} else
|
258
|
+
git_oid_cpy(oid, git_object_id(target));
|
259
|
+
|
260
|
+
if (!should_update_ref)
|
261
|
+
error = git_reference_create_oid(&new_ref, repo, ref_name, oid, 0);
|
262
|
+
else
|
263
|
+
error = git_reference_set_oid(new_ref, oid);
|
264
|
+
|
265
|
+
git_reference_free(new_ref);
|
266
|
+
|
267
|
+
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to create tag");
|
268
|
+
}
|
269
|
+
|
270
|
+
int git_tag_create(
|
271
|
+
git_oid *oid,
|
272
|
+
git_repository *repo,
|
273
|
+
const char *tag_name,
|
274
|
+
const git_object *target,
|
275
|
+
const git_signature *tagger,
|
276
|
+
const char *message,
|
277
|
+
int allow_ref_overwrite)
|
278
|
+
{
|
279
|
+
return git_tag_create__internal(oid, repo, tag_name, target, tagger, message, allow_ref_overwrite, 1);
|
280
|
+
}
|
281
|
+
|
282
|
+
int git_tag_create_lightweight(
|
283
|
+
git_oid *oid,
|
284
|
+
git_repository *repo,
|
285
|
+
const char *tag_name,
|
286
|
+
const git_object *target,
|
287
|
+
int allow_ref_overwrite)
|
288
|
+
{
|
289
|
+
return git_tag_create__internal(oid, repo, tag_name, target, NULL, NULL, allow_ref_overwrite, 0);
|
290
|
+
}
|
291
|
+
|
292
|
+
int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *buffer, int allow_ref_overwrite)
|
293
|
+
{
|
294
|
+
git_tag tag;
|
295
|
+
int error, should_update_ref = 0;
|
296
|
+
git_odb *odb;
|
297
|
+
git_odb_stream *stream;
|
298
|
+
git_odb_object *target_obj;
|
299
|
+
|
300
|
+
git_reference *new_ref = NULL;
|
301
|
+
char ref_name[GIT_REFNAME_MAX];
|
302
|
+
|
303
|
+
assert(oid && buffer);
|
304
|
+
|
305
|
+
memset(&tag, 0, sizeof(tag));
|
306
|
+
|
307
|
+
error = git_repository_odb__weakptr(&odb, repo);
|
308
|
+
if (error < GIT_SUCCESS)
|
309
|
+
return error;
|
310
|
+
|
311
|
+
/* validate the buffer */
|
312
|
+
if ((error = parse_tag_buffer(&tag, buffer, buffer + strlen(buffer))) < GIT_SUCCESS)
|
313
|
+
return git__rethrow(error, "Failed to create tag");
|
314
|
+
|
315
|
+
/* validate the target */
|
316
|
+
if ((error = git_odb_read(&target_obj, odb, &tag.target)) < GIT_SUCCESS)
|
317
|
+
return git__rethrow(error, "Failed to create tag");
|
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);
|
323
|
+
|
324
|
+
error = retrieve_tag_reference(&new_ref, ref_name, repo, tag.tag_name);
|
325
|
+
|
326
|
+
switch (error) {
|
327
|
+
case GIT_SUCCESS:
|
328
|
+
case GIT_ENOTFOUND:
|
329
|
+
break;
|
330
|
+
|
331
|
+
default:
|
332
|
+
git_reference_free(new_ref);
|
333
|
+
return git__rethrow(error, "Failed to create tag");
|
334
|
+
}
|
335
|
+
|
336
|
+
/** Ensure the tag name doesn't conflict with an already existing
|
337
|
+
* reference unless overwriting has explictly been requested **/
|
338
|
+
if (new_ref != NULL) {
|
339
|
+
if (!allow_ref_overwrite) {
|
340
|
+
git_oid_cpy(oid, git_reference_oid(new_ref));
|
341
|
+
git_reference_free(new_ref);
|
342
|
+
return git__throw(GIT_EEXISTS, "Tag already exists");
|
343
|
+
} else {
|
344
|
+
should_update_ref = 1;
|
345
|
+
}
|
346
|
+
}
|
347
|
+
|
348
|
+
/* write the buffer */
|
349
|
+
if ((error = git_odb_open_wstream(&stream, odb, strlen(buffer), GIT_OBJ_TAG)) < GIT_SUCCESS) {
|
350
|
+
git_reference_free(new_ref);
|
351
|
+
return git__rethrow(error, "Failed to create tag");
|
352
|
+
}
|
353
|
+
|
354
|
+
stream->write(stream, buffer, strlen(buffer));
|
355
|
+
|
356
|
+
error = stream->finalize_write(oid, stream);
|
357
|
+
stream->free(stream);
|
358
|
+
|
359
|
+
if (error < GIT_SUCCESS) {
|
360
|
+
git_reference_free(new_ref);
|
361
|
+
return git__rethrow(error, "Failed to create tag");
|
362
|
+
}
|
363
|
+
|
364
|
+
if (!should_update_ref)
|
365
|
+
error = git_reference_create_oid(&new_ref, repo, ref_name, oid, 0);
|
366
|
+
else
|
367
|
+
error = git_reference_set_oid(new_ref, oid);
|
368
|
+
|
369
|
+
git_reference_free(new_ref);
|
370
|
+
|
371
|
+
git_signature_free(tag.tagger);
|
372
|
+
git__free(tag.tag_name);
|
373
|
+
git__free(tag.message);
|
374
|
+
|
375
|
+
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to create tag");
|
376
|
+
}
|
377
|
+
|
378
|
+
int git_tag_delete(git_repository *repo, const char *tag_name)
|
379
|
+
{
|
380
|
+
int error;
|
381
|
+
git_reference *tag_ref;
|
382
|
+
char ref_name[GIT_REFNAME_MAX];
|
383
|
+
|
384
|
+
error = retrieve_tag_reference(&tag_ref, ref_name, repo, tag_name);
|
385
|
+
if (error < GIT_SUCCESS)
|
386
|
+
return git__rethrow(error, "Failed to delete tag");
|
387
|
+
|
388
|
+
return git_reference_delete(tag_ref);
|
389
|
+
}
|
390
|
+
|
391
|
+
int git_tag__parse(git_tag *tag, git_odb_object *obj)
|
392
|
+
{
|
393
|
+
assert(tag);
|
394
|
+
return parse_tag_buffer(tag, obj->raw.data, (char *)obj->raw.data + obj->raw.len);
|
395
|
+
}
|
396
|
+
|
397
|
+
typedef struct {
|
398
|
+
git_vector *taglist;
|
399
|
+
const char *pattern;
|
400
|
+
} tag_filter_data;
|
401
|
+
|
402
|
+
#define GIT_REFS_TAGS_DIR_LEN strlen(GIT_REFS_TAGS_DIR)
|
403
|
+
|
404
|
+
static int tag_list_cb(const char *tag_name, void *payload)
|
405
|
+
{
|
406
|
+
tag_filter_data *filter;
|
407
|
+
|
408
|
+
if (git__prefixcmp(tag_name, GIT_REFS_TAGS_DIR) != 0)
|
409
|
+
return GIT_SUCCESS;
|
410
|
+
|
411
|
+
filter = (tag_filter_data *)payload;
|
412
|
+
if (!*filter->pattern || p_fnmatch(filter->pattern, tag_name + GIT_REFS_TAGS_DIR_LEN, 0) == GIT_SUCCESS)
|
413
|
+
return git_vector_insert(filter->taglist, git__strdup(tag_name));
|
414
|
+
|
415
|
+
return GIT_SUCCESS;
|
416
|
+
}
|
417
|
+
|
418
|
+
int git_tag_list_match(git_strarray *tag_names, const char *pattern, git_repository *repo)
|
419
|
+
{
|
420
|
+
int error;
|
421
|
+
tag_filter_data filter;
|
422
|
+
git_vector taglist;
|
423
|
+
|
424
|
+
assert(tag_names && repo && pattern);
|
425
|
+
|
426
|
+
if (git_vector_init(&taglist, 8, NULL) < GIT_SUCCESS)
|
427
|
+
return GIT_ENOMEM;
|
428
|
+
|
429
|
+
filter.taglist = &taglist;
|
430
|
+
filter.pattern = pattern;
|
431
|
+
|
432
|
+
error = git_reference_foreach(repo, GIT_REF_OID|GIT_REF_PACKED, &tag_list_cb, (void *)&filter);
|
433
|
+
if (error < GIT_SUCCESS) {
|
434
|
+
git_vector_free(&taglist);
|
435
|
+
return git__rethrow(error, "Failed to list tags");
|
436
|
+
}
|
437
|
+
|
438
|
+
tag_names->strings = (char **)taglist.contents;
|
439
|
+
tag_names->count = taglist.length;
|
440
|
+
return GIT_SUCCESS;
|
441
|
+
}
|
442
|
+
|
443
|
+
int git_tag_list(git_strarray *tag_names, git_repository *repo)
|
444
|
+
{
|
445
|
+
return git_tag_list_match(tag_names, "", repo);
|
446
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2011 the libgit2 contributors
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
#ifndef INCLUDE_tag_h__
|
8
|
+
#define INCLUDE_tag_h__
|
9
|
+
|
10
|
+
#include "git2/tag.h"
|
11
|
+
#include "repository.h"
|
12
|
+
#include "odb.h"
|
13
|
+
|
14
|
+
struct git_tag {
|
15
|
+
git_object object;
|
16
|
+
|
17
|
+
git_oid target;
|
18
|
+
git_otype type;
|
19
|
+
|
20
|
+
char *tag_name;
|
21
|
+
git_signature *tagger;
|
22
|
+
char *message;
|
23
|
+
};
|
24
|
+
|
25
|
+
void git_tag__free(git_tag *tag);
|
26
|
+
int git_tag__parse(git_tag *tag, git_odb_object *obj);
|
27
|
+
|
28
|
+
#endif
|