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,58 @@
|
|
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_refs_h__
|
8
|
+
#define INCLUDE_refs_h__
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
#include "git2/oid.h"
|
12
|
+
#include "git2/refs.h"
|
13
|
+
#include "hashtable.h"
|
14
|
+
|
15
|
+
#define GIT_REFS_DIR "refs/"
|
16
|
+
#define GIT_REFS_HEADS_DIR GIT_REFS_DIR "heads/"
|
17
|
+
#define GIT_REFS_TAGS_DIR GIT_REFS_DIR "tags/"
|
18
|
+
#define GIT_REFS_REMOTES_DIR GIT_REFS_DIR "remotes/"
|
19
|
+
#define GIT_REFS_DIR_MODE 0777
|
20
|
+
#define GIT_REFS_FILE_MODE 0666
|
21
|
+
|
22
|
+
#define GIT_RENAMED_REF_FILE GIT_REFS_DIR "RENAMED-REF"
|
23
|
+
|
24
|
+
#define GIT_SYMREF "ref: "
|
25
|
+
#define GIT_PACKEDREFS_FILE "packed-refs"
|
26
|
+
#define GIT_PACKEDREFS_HEADER "# pack-refs with: peeled "
|
27
|
+
#define GIT_PACKEDREFS_FILE_MODE 0666
|
28
|
+
|
29
|
+
#define GIT_HEAD_FILE "HEAD"
|
30
|
+
#define GIT_FETCH_HEAD_FILE "FETCH_HEAD"
|
31
|
+
#define GIT_MERGE_HEAD_FILE "MERGE_HEAD"
|
32
|
+
#define GIT_REFS_HEADS_MASTER_FILE GIT_REFS_HEADS_DIR "master"
|
33
|
+
|
34
|
+
#define GIT_REFNAME_MAX 1024
|
35
|
+
|
36
|
+
struct git_reference {
|
37
|
+
unsigned int flags;
|
38
|
+
git_repository *owner;
|
39
|
+
char *name;
|
40
|
+
time_t mtime;
|
41
|
+
|
42
|
+
union {
|
43
|
+
git_oid oid;
|
44
|
+
char *symbolic;
|
45
|
+
} target;
|
46
|
+
};
|
47
|
+
|
48
|
+
typedef struct {
|
49
|
+
git_hashtable *packfile;
|
50
|
+
time_t packfile_time;
|
51
|
+
} git_refcache;
|
52
|
+
|
53
|
+
void git_repository__refcache_free(git_refcache *refs);
|
54
|
+
|
55
|
+
int git_reference__normalize_name(char *buffer_out, size_t out_size, const char *name);
|
56
|
+
int git_reference__normalize_name_oid(char *buffer_out, size_t out_size, const char *name);
|
57
|
+
|
58
|
+
#endif
|
@@ -0,0 +1,95 @@
|
|
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 "git2/errors.h"
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
#include "refspec.h"
|
12
|
+
#include "util.h"
|
13
|
+
|
14
|
+
int git_refspec_parse(git_refspec *refspec, const char *str)
|
15
|
+
{
|
16
|
+
char *delim;
|
17
|
+
|
18
|
+
memset(refspec, 0x0, sizeof(git_refspec));
|
19
|
+
|
20
|
+
if (*str == '+') {
|
21
|
+
refspec->force = 1;
|
22
|
+
str++;
|
23
|
+
}
|
24
|
+
|
25
|
+
delim = strchr(str, ':');
|
26
|
+
if (delim == NULL) {
|
27
|
+
refspec->src = git__strdup(str);
|
28
|
+
if (refspec->src == NULL)
|
29
|
+
return GIT_ENOMEM;
|
30
|
+
|
31
|
+
return GIT_SUCCESS;
|
32
|
+
}
|
33
|
+
|
34
|
+
refspec->src = git__strndup(str, delim - str);
|
35
|
+
if (refspec->src == NULL)
|
36
|
+
return GIT_ENOMEM;
|
37
|
+
|
38
|
+
refspec->dst = git__strdup(delim + 1);
|
39
|
+
if (refspec->dst == NULL) {
|
40
|
+
git__free(refspec->src);
|
41
|
+
refspec->src = NULL;
|
42
|
+
return GIT_ENOMEM;
|
43
|
+
}
|
44
|
+
|
45
|
+
return GIT_SUCCESS;
|
46
|
+
}
|
47
|
+
|
48
|
+
const char *git_refspec_src(const git_refspec *refspec)
|
49
|
+
{
|
50
|
+
return refspec == NULL ? NULL : refspec->src;
|
51
|
+
}
|
52
|
+
|
53
|
+
const char *git_refspec_dst(const git_refspec *refspec)
|
54
|
+
{
|
55
|
+
return refspec == NULL ? NULL : refspec->dst;
|
56
|
+
}
|
57
|
+
|
58
|
+
int git_refspec_src_match(const git_refspec *refspec, const char *refname)
|
59
|
+
{
|
60
|
+
return refspec == NULL ? GIT_ENOMATCH : git__fnmatch(refspec->src, refname, 0);
|
61
|
+
}
|
62
|
+
|
63
|
+
int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, const char *name)
|
64
|
+
{
|
65
|
+
size_t baselen, namelen;
|
66
|
+
|
67
|
+
baselen = strlen(spec->dst);
|
68
|
+
if (outlen <= baselen)
|
69
|
+
return git__throw(GIT_EINVALIDREFNAME, "Reference name too long");
|
70
|
+
|
71
|
+
/*
|
72
|
+
* No '*' at the end means that it's mapped to one specific local
|
73
|
+
* branch, so no actual transformation is needed.
|
74
|
+
*/
|
75
|
+
if (spec->dst[baselen - 1] != '*') {
|
76
|
+
memcpy(out, spec->dst, baselen + 1); /* include '\0' */
|
77
|
+
return GIT_SUCCESS;
|
78
|
+
}
|
79
|
+
|
80
|
+
/* There's a '*' at the end, so remove its length */
|
81
|
+
baselen--;
|
82
|
+
|
83
|
+
/* skip the prefix, -1 is for the '*' */
|
84
|
+
name += strlen(spec->src) - 1;
|
85
|
+
|
86
|
+
namelen = strlen(name);
|
87
|
+
|
88
|
+
if (outlen <= baselen + namelen)
|
89
|
+
return git__throw(GIT_EINVALIDREFNAME, "Reference name too long");
|
90
|
+
|
91
|
+
memcpy(out, spec->dst, baselen);
|
92
|
+
memcpy(out + baselen, name, namelen + 1);
|
93
|
+
|
94
|
+
return GIT_SUCCESS;
|
95
|
+
}
|
@@ -0,0 +1,23 @@
|
|
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_refspec_h__
|
8
|
+
#define INCLUDE_refspec_h__
|
9
|
+
|
10
|
+
#include "git2/refspec.h"
|
11
|
+
|
12
|
+
struct git_refspec {
|
13
|
+
struct git_refspec *next;
|
14
|
+
char *src;
|
15
|
+
char *dst;
|
16
|
+
unsigned int force :1,
|
17
|
+
pattern :1,
|
18
|
+
matching :1;
|
19
|
+
};
|
20
|
+
|
21
|
+
int git_refspec_parse(struct git_refspec *refspec, const char *str);
|
22
|
+
|
23
|
+
#endif
|
@@ -0,0 +1,339 @@
|
|
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 "git2/remote.h"
|
9
|
+
#include "git2/config.h"
|
10
|
+
#include "git2/types.h"
|
11
|
+
|
12
|
+
#include "config.h"
|
13
|
+
#include "repository.h"
|
14
|
+
#include "remote.h"
|
15
|
+
#include "fetch.h"
|
16
|
+
#include "refs.h"
|
17
|
+
|
18
|
+
static int refspec_parse(git_refspec *refspec, const char *str)
|
19
|
+
{
|
20
|
+
char *delim;
|
21
|
+
|
22
|
+
memset(refspec, 0x0, sizeof(git_refspec));
|
23
|
+
|
24
|
+
if (*str == '+') {
|
25
|
+
refspec->force = 1;
|
26
|
+
str++;
|
27
|
+
}
|
28
|
+
|
29
|
+
delim = strchr(str, ':');
|
30
|
+
if (delim == NULL)
|
31
|
+
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse refspec. No ':'");
|
32
|
+
|
33
|
+
refspec->src = git__strndup(str, delim - str);
|
34
|
+
if (refspec->src == NULL)
|
35
|
+
return GIT_ENOMEM;
|
36
|
+
|
37
|
+
refspec->dst = git__strdup(delim + 1);
|
38
|
+
if (refspec->dst == NULL) {
|
39
|
+
git__free(refspec->src);
|
40
|
+
refspec->src = NULL;
|
41
|
+
return GIT_ENOMEM;
|
42
|
+
}
|
43
|
+
|
44
|
+
return GIT_SUCCESS;
|
45
|
+
}
|
46
|
+
|
47
|
+
static int parse_remote_refspec(git_config *cfg, git_refspec *refspec, const char *var)
|
48
|
+
{
|
49
|
+
const char *val;
|
50
|
+
int error;
|
51
|
+
|
52
|
+
error = git_config_get_string(cfg, var, &val);
|
53
|
+
if (error < GIT_SUCCESS)
|
54
|
+
return error;
|
55
|
+
|
56
|
+
return refspec_parse(refspec, val);
|
57
|
+
}
|
58
|
+
|
59
|
+
int git_remote_new(git_remote **out, git_repository *repo, const char *url, const char *name)
|
60
|
+
{
|
61
|
+
git_remote *remote;
|
62
|
+
|
63
|
+
/* name is optional */
|
64
|
+
assert(out && repo && url);
|
65
|
+
|
66
|
+
remote = git__malloc(sizeof(git_remote));
|
67
|
+
if (remote == NULL)
|
68
|
+
return GIT_ENOMEM;
|
69
|
+
|
70
|
+
memset(remote, 0x0, sizeof(git_remote));
|
71
|
+
remote->repo = repo;
|
72
|
+
|
73
|
+
if (git_vector_init(&remote->refs, 32, NULL) < 0) {
|
74
|
+
git_remote_free(remote);
|
75
|
+
return GIT_ENOMEM;
|
76
|
+
}
|
77
|
+
|
78
|
+
remote->url = git__strdup(url);
|
79
|
+
if (remote->url == NULL) {
|
80
|
+
git_remote_free(remote);
|
81
|
+
return GIT_ENOMEM;
|
82
|
+
}
|
83
|
+
|
84
|
+
if (name != NULL) {
|
85
|
+
remote->name = git__strdup(name);
|
86
|
+
if (remote->name == NULL) {
|
87
|
+
git_remote_free(remote);
|
88
|
+
return GIT_ENOMEM;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
*out = remote;
|
93
|
+
return GIT_SUCCESS;
|
94
|
+
}
|
95
|
+
|
96
|
+
int git_remote_load(git_remote **out, git_repository *repo, const char *name)
|
97
|
+
{
|
98
|
+
git_remote *remote;
|
99
|
+
char *buf = NULL;
|
100
|
+
const char *val;
|
101
|
+
int ret, error, buf_len;
|
102
|
+
git_config *config;
|
103
|
+
|
104
|
+
assert(out && repo && name);
|
105
|
+
|
106
|
+
error = git_repository_config__weakptr(&config, repo);
|
107
|
+
if (error < GIT_SUCCESS)
|
108
|
+
return error;
|
109
|
+
|
110
|
+
remote = git__malloc(sizeof(git_remote));
|
111
|
+
if (remote == NULL)
|
112
|
+
return GIT_ENOMEM;
|
113
|
+
|
114
|
+
memset(remote, 0x0, sizeof(git_remote));
|
115
|
+
remote->name = git__strdup(name);
|
116
|
+
if (remote->name == NULL) {
|
117
|
+
error = GIT_ENOMEM;
|
118
|
+
goto cleanup;
|
119
|
+
}
|
120
|
+
|
121
|
+
if (git_vector_init(&remote->refs, 32, NULL) < 0) {
|
122
|
+
error = GIT_ENOMEM;
|
123
|
+
goto cleanup;
|
124
|
+
}
|
125
|
+
|
126
|
+
/* "fetch" is the longest var name we're interested in */
|
127
|
+
buf_len = strlen("remote.") + strlen(".fetch") + strlen(name) + 1;
|
128
|
+
buf = git__malloc(buf_len);
|
129
|
+
if (buf == NULL) {
|
130
|
+
error = GIT_ENOMEM;
|
131
|
+
goto cleanup;
|
132
|
+
}
|
133
|
+
|
134
|
+
ret = p_snprintf(buf, buf_len, "%s.%s.%s", "remote", name, "url");
|
135
|
+
if (ret < 0) {
|
136
|
+
error = git__throw(GIT_EOSERR, "Failed to build config var name");
|
137
|
+
goto cleanup;
|
138
|
+
}
|
139
|
+
|
140
|
+
error = git_config_get_string(config, buf, &val);
|
141
|
+
if (error < GIT_SUCCESS) {
|
142
|
+
error = git__rethrow(error, "Remote's url doesn't exist");
|
143
|
+
goto cleanup;
|
144
|
+
}
|
145
|
+
|
146
|
+
remote->repo = repo;
|
147
|
+
remote->url = git__strdup(val);
|
148
|
+
if (remote->url == NULL) {
|
149
|
+
error = GIT_ENOMEM;
|
150
|
+
goto cleanup;
|
151
|
+
}
|
152
|
+
|
153
|
+
ret = p_snprintf(buf, buf_len, "%s.%s.%s", "remote", name, "fetch");
|
154
|
+
if (ret < 0) {
|
155
|
+
error = git__throw(GIT_EOSERR, "Failed to build config var name");
|
156
|
+
goto cleanup;
|
157
|
+
}
|
158
|
+
|
159
|
+
error = parse_remote_refspec(config, &remote->fetch, buf);
|
160
|
+
if (error < GIT_SUCCESS) {
|
161
|
+
error = git__rethrow(error, "Failed to get fetch refspec");
|
162
|
+
goto cleanup;
|
163
|
+
}
|
164
|
+
|
165
|
+
ret = p_snprintf(buf, buf_len, "%s.%s.%s", "remote", name, "push");
|
166
|
+
if (ret < 0) {
|
167
|
+
error = git__throw(GIT_EOSERR, "Failed to build config var name");
|
168
|
+
goto cleanup;
|
169
|
+
}
|
170
|
+
|
171
|
+
error = parse_remote_refspec(config, &remote->push, buf);
|
172
|
+
/* Not finding push is fine */
|
173
|
+
if (error == GIT_ENOTFOUND)
|
174
|
+
error = GIT_SUCCESS;
|
175
|
+
|
176
|
+
if (error < GIT_SUCCESS)
|
177
|
+
goto cleanup;
|
178
|
+
|
179
|
+
*out = remote;
|
180
|
+
|
181
|
+
cleanup:
|
182
|
+
git__free(buf);
|
183
|
+
|
184
|
+
if (error < GIT_SUCCESS)
|
185
|
+
git_remote_free(remote);
|
186
|
+
|
187
|
+
return error;
|
188
|
+
}
|
189
|
+
|
190
|
+
const char *git_remote_name(git_remote *remote)
|
191
|
+
{
|
192
|
+
assert(remote);
|
193
|
+
return remote->name;
|
194
|
+
}
|
195
|
+
|
196
|
+
const char *git_remote_url(git_remote *remote)
|
197
|
+
{
|
198
|
+
assert(remote);
|
199
|
+
return remote->url;
|
200
|
+
}
|
201
|
+
|
202
|
+
const git_refspec *git_remote_fetchspec(git_remote *remote)
|
203
|
+
{
|
204
|
+
assert(remote);
|
205
|
+
return &remote->fetch;
|
206
|
+
}
|
207
|
+
|
208
|
+
const git_refspec *git_remote_pushspec(git_remote *remote)
|
209
|
+
{
|
210
|
+
assert(remote);
|
211
|
+
return &remote->push;
|
212
|
+
}
|
213
|
+
|
214
|
+
int git_remote_connect(git_remote *remote, int direction)
|
215
|
+
{
|
216
|
+
int error;
|
217
|
+
git_transport *t;
|
218
|
+
|
219
|
+
assert(remote);
|
220
|
+
|
221
|
+
error = git_transport_new(&t, remote->url);
|
222
|
+
if (error < GIT_SUCCESS)
|
223
|
+
return git__rethrow(error, "Failed to create transport");
|
224
|
+
|
225
|
+
error = t->connect(t, direction);
|
226
|
+
if (error < GIT_SUCCESS) {
|
227
|
+
error = git__rethrow(error, "Failed to connect the transport");
|
228
|
+
goto cleanup;
|
229
|
+
}
|
230
|
+
|
231
|
+
remote->transport = t;
|
232
|
+
|
233
|
+
cleanup:
|
234
|
+
if (error < GIT_SUCCESS)
|
235
|
+
t->free(t);
|
236
|
+
|
237
|
+
return error;
|
238
|
+
}
|
239
|
+
|
240
|
+
int git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload)
|
241
|
+
{
|
242
|
+
assert(remote);
|
243
|
+
|
244
|
+
if (!remote->transport || !remote->transport->connected)
|
245
|
+
return git__throw(GIT_ERROR, "The remote is not connected");
|
246
|
+
|
247
|
+
return remote->transport->ls(remote->transport, list_cb, payload);
|
248
|
+
}
|
249
|
+
|
250
|
+
int git_remote_download(char **filename, git_remote *remote)
|
251
|
+
{
|
252
|
+
int error;
|
253
|
+
|
254
|
+
assert(filename && remote);
|
255
|
+
|
256
|
+
if ((error = git_fetch_negotiate(remote)) < 0)
|
257
|
+
return git__rethrow(error, "Error negotiating");
|
258
|
+
|
259
|
+
return git_fetch_download_pack(filename, remote);
|
260
|
+
}
|
261
|
+
|
262
|
+
int git_remote_update_tips(git_remote *remote)
|
263
|
+
{
|
264
|
+
int error = GIT_SUCCESS;
|
265
|
+
unsigned int i = 0;
|
266
|
+
char refname[GIT_PATH_MAX];
|
267
|
+
git_vector *refs = &remote->refs;
|
268
|
+
git_remote_head *head;
|
269
|
+
git_reference *ref;
|
270
|
+
struct git_refspec *spec = &remote->fetch;
|
271
|
+
|
272
|
+
assert(remote);
|
273
|
+
|
274
|
+
memset(refname, 0x0, sizeof(refname));
|
275
|
+
|
276
|
+
if (refs->length == 0)
|
277
|
+
return GIT_SUCCESS;
|
278
|
+
|
279
|
+
/* HEAD is only allowed to be the first in the list */
|
280
|
+
head = refs->contents[0];
|
281
|
+
if (!strcmp(head->name, GIT_HEAD_FILE)) {
|
282
|
+
error = git_reference_create_oid(&ref, remote->repo, GIT_FETCH_HEAD_FILE, &head->oid, 1);
|
283
|
+
i = 1;
|
284
|
+
git_reference_free(ref);
|
285
|
+
if (error < GIT_SUCCESS)
|
286
|
+
return git__rethrow(error, "Failed to update FETCH_HEAD");
|
287
|
+
}
|
288
|
+
|
289
|
+
for (; i < refs->length; ++i) {
|
290
|
+
head = refs->contents[i];
|
291
|
+
|
292
|
+
error = git_refspec_transform(refname, sizeof(refname), spec, head->name);
|
293
|
+
if (error < GIT_SUCCESS)
|
294
|
+
return error;
|
295
|
+
|
296
|
+
error = git_reference_create_oid(&ref, remote->repo, refname, &head->oid, 1);
|
297
|
+
if (error < GIT_SUCCESS)
|
298
|
+
return error;
|
299
|
+
|
300
|
+
git_reference_free(ref);
|
301
|
+
}
|
302
|
+
|
303
|
+
return GIT_SUCCESS;
|
304
|
+
}
|
305
|
+
|
306
|
+
int git_remote_connected(git_remote *remote)
|
307
|
+
{
|
308
|
+
assert(remote);
|
309
|
+
return remote->transport == NULL ? 0 : remote->transport->connected;
|
310
|
+
}
|
311
|
+
|
312
|
+
void git_remote_disconnect(git_remote *remote)
|
313
|
+
{
|
314
|
+
assert(remote);
|
315
|
+
|
316
|
+
if (remote->transport != NULL) {
|
317
|
+
if (remote->transport->connected)
|
318
|
+
remote->transport->close(remote->transport);
|
319
|
+
|
320
|
+
remote->transport->free(remote->transport);
|
321
|
+
remote->transport = NULL;
|
322
|
+
}
|
323
|
+
}
|
324
|
+
|
325
|
+
void git_remote_free(git_remote *remote)
|
326
|
+
{
|
327
|
+
if (remote == NULL)
|
328
|
+
return;
|
329
|
+
|
330
|
+
git__free(remote->fetch.src);
|
331
|
+
git__free(remote->fetch.dst);
|
332
|
+
git__free(remote->push.src);
|
333
|
+
git__free(remote->push.dst);
|
334
|
+
git__free(remote->url);
|
335
|
+
git__free(remote->name);
|
336
|
+
git_vector_free(&remote->refs);
|
337
|
+
git_remote_disconnect(remote);
|
338
|
+
git__free(remote);
|
339
|
+
}
|