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,115 @@
|
|
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
|
+
#include "common.h"
|
8
|
+
#include "git2/odb.h"
|
9
|
+
#include "delta-apply.h"
|
10
|
+
|
11
|
+
/*
|
12
|
+
* This file was heavily cribbed from BinaryDelta.java in JGit, which
|
13
|
+
* itself was heavily cribbed from <code>patch-delta.c</code> in the
|
14
|
+
* GIT project. The original delta patching code was written by
|
15
|
+
* Nicolas Pitre <nico@cam.org>.
|
16
|
+
*/
|
17
|
+
|
18
|
+
static int hdr_sz(
|
19
|
+
size_t *size,
|
20
|
+
const unsigned char **delta,
|
21
|
+
const unsigned char *end)
|
22
|
+
{
|
23
|
+
const unsigned char *d = *delta;
|
24
|
+
size_t r = 0;
|
25
|
+
unsigned int c, shift = 0;
|
26
|
+
|
27
|
+
do {
|
28
|
+
if (d == end)
|
29
|
+
return -1;
|
30
|
+
c = *d++;
|
31
|
+
r |= (c & 0x7f) << shift;
|
32
|
+
shift += 7;
|
33
|
+
} while (c & 0x80);
|
34
|
+
*delta = d;
|
35
|
+
*size = r;
|
36
|
+
return 0;
|
37
|
+
}
|
38
|
+
|
39
|
+
int git__delta_apply(
|
40
|
+
git_rawobj *out,
|
41
|
+
const unsigned char *base,
|
42
|
+
size_t base_len,
|
43
|
+
const unsigned char *delta,
|
44
|
+
size_t delta_len)
|
45
|
+
{
|
46
|
+
const unsigned char *delta_end = delta + delta_len;
|
47
|
+
size_t base_sz, res_sz;
|
48
|
+
unsigned char *res_dp;
|
49
|
+
|
50
|
+
/* Check that the base size matches the data we were given;
|
51
|
+
* if not we would underflow while accessing data from the
|
52
|
+
* base object, resulting in data corruption or segfault.
|
53
|
+
*/
|
54
|
+
if ((hdr_sz(&base_sz, &delta, delta_end) < 0) || (base_sz != base_len))
|
55
|
+
return git__throw(GIT_ERROR, "Failed to apply delta. Base size does not match given data");
|
56
|
+
|
57
|
+
if (hdr_sz(&res_sz, &delta, delta_end) < 0)
|
58
|
+
return git__throw(GIT_ERROR, "Failed to apply delta. Base size does not match given data");
|
59
|
+
|
60
|
+
if ((res_dp = git__malloc(res_sz + 1)) == NULL)
|
61
|
+
return GIT_ENOMEM;
|
62
|
+
res_dp[res_sz] = '\0';
|
63
|
+
out->data = res_dp;
|
64
|
+
out->len = res_sz;
|
65
|
+
|
66
|
+
while (delta < delta_end) {
|
67
|
+
unsigned char cmd = *delta++;
|
68
|
+
if (cmd & 0x80) {
|
69
|
+
/* cmd is a copy instruction; copy from the base.
|
70
|
+
*/
|
71
|
+
size_t off = 0, len = 0;
|
72
|
+
|
73
|
+
if (cmd & 0x01) off = *delta++;
|
74
|
+
if (cmd & 0x02) off |= *delta++ << 8;
|
75
|
+
if (cmd & 0x04) off |= *delta++ << 16;
|
76
|
+
if (cmd & 0x08) off |= *delta++ << 24;
|
77
|
+
|
78
|
+
if (cmd & 0x10) len = *delta++;
|
79
|
+
if (cmd & 0x20) len |= *delta++ << 8;
|
80
|
+
if (cmd & 0x40) len |= *delta++ << 16;
|
81
|
+
if (!len) len = 0x10000;
|
82
|
+
|
83
|
+
if (base_len < off + len || res_sz < len)
|
84
|
+
goto fail;
|
85
|
+
memcpy(res_dp, base + off, len);
|
86
|
+
res_dp += len;
|
87
|
+
res_sz -= len;
|
88
|
+
|
89
|
+
} else if (cmd) {
|
90
|
+
/* cmd is a literal insert instruction; copy from
|
91
|
+
* the delta stream itself.
|
92
|
+
*/
|
93
|
+
if (delta_end - delta < cmd || res_sz < cmd)
|
94
|
+
goto fail;
|
95
|
+
memcpy(res_dp, delta, cmd);
|
96
|
+
delta += cmd;
|
97
|
+
res_dp += cmd;
|
98
|
+
res_sz -= cmd;
|
99
|
+
|
100
|
+
} else {
|
101
|
+
/* cmd == 0 is reserved for future encodings.
|
102
|
+
*/
|
103
|
+
goto fail;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
if (delta != delta_end || res_sz)
|
108
|
+
goto fail;
|
109
|
+
return GIT_SUCCESS;
|
110
|
+
|
111
|
+
fail:
|
112
|
+
git__free(out->data);
|
113
|
+
out->data = NULL;
|
114
|
+
return git__throw(GIT_ERROR, "Failed to apply delta");
|
115
|
+
}
|
@@ -0,0 +1,33 @@
|
|
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_delta_apply_h__
|
8
|
+
#define INCLUDE_delta_apply_h__
|
9
|
+
|
10
|
+
#include "odb.h"
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Apply a git binary delta to recover the original content.
|
14
|
+
*
|
15
|
+
* @param out the output buffer to receive the original data.
|
16
|
+
* Only out->data and out->len are populated, as this is
|
17
|
+
* the only information available in the delta.
|
18
|
+
* @param base the base to copy from during copy instructions.
|
19
|
+
* @param base_len number of bytes available at base.
|
20
|
+
* @param delta the delta to execute copy/insert instructions from.
|
21
|
+
* @param delta_len total number of bytes in the delta.
|
22
|
+
* @return
|
23
|
+
* - GIT_SUCCESS on a successful delta unpack.
|
24
|
+
* - GIT_ERROR if the delta is corrupt or doesn't match the base.
|
25
|
+
*/
|
26
|
+
extern int git__delta_apply(
|
27
|
+
git_rawobj *out,
|
28
|
+
const unsigned char *base,
|
29
|
+
size_t base_len,
|
30
|
+
const unsigned char *delta,
|
31
|
+
size_t delta_len);
|
32
|
+
|
33
|
+
#endif
|
@@ -0,0 +1,47 @@
|
|
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_dir_h__
|
8
|
+
#define INCLUDE_dir_h__
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
|
12
|
+
#ifndef GIT_WIN32
|
13
|
+
# include <dirent.h>
|
14
|
+
#endif
|
15
|
+
|
16
|
+
#ifdef GIT_WIN32
|
17
|
+
|
18
|
+
struct git__dirent {
|
19
|
+
int d_ino;
|
20
|
+
char d_name[261];
|
21
|
+
};
|
22
|
+
|
23
|
+
typedef struct {
|
24
|
+
HANDLE h;
|
25
|
+
WIN32_FIND_DATAW f;
|
26
|
+
struct git__dirent entry;
|
27
|
+
char *dir;
|
28
|
+
int first;
|
29
|
+
} git__DIR;
|
30
|
+
|
31
|
+
extern git__DIR *git__opendir(const char *);
|
32
|
+
extern struct git__dirent *git__readdir(git__DIR *);
|
33
|
+
extern void git__rewinddir(git__DIR *);
|
34
|
+
extern int git__closedir(git__DIR *);
|
35
|
+
|
36
|
+
# ifndef GIT__WIN32_NO_WRAP_DIR
|
37
|
+
# define dirent git__dirent
|
38
|
+
# define DIR git__DIR
|
39
|
+
# define opendir git__opendir
|
40
|
+
# define readdir git__readdir
|
41
|
+
# define rewinddir git__rewinddir
|
42
|
+
# define closedir git__closedir
|
43
|
+
# endif
|
44
|
+
|
45
|
+
#endif
|
46
|
+
|
47
|
+
#endif /* INCLUDE_dir_h__ */
|
@@ -0,0 +1,104 @@
|
|
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
|
+
#include "common.h"
|
8
|
+
#include "global.h"
|
9
|
+
#include <stdarg.h>
|
10
|
+
|
11
|
+
static struct {
|
12
|
+
int num;
|
13
|
+
const char *str;
|
14
|
+
} error_codes[] = {
|
15
|
+
{GIT_ERROR, "Unspecified error"},
|
16
|
+
{GIT_ENOTOID, "Input was not a properly formatted Git object id."},
|
17
|
+
{GIT_ENOTFOUND, "Object does not exist in the scope searched."},
|
18
|
+
{GIT_ENOMEM, "Not enough space available."},
|
19
|
+
{GIT_EOSERR, "Consult the OS error information."},
|
20
|
+
{GIT_EOBJTYPE, "The specified object is of invalid type"},
|
21
|
+
{GIT_EOBJCORRUPTED, "The specified object has its data corrupted"},
|
22
|
+
{GIT_ENOTAREPO, "The specified repository is invalid"},
|
23
|
+
{GIT_EINVALIDTYPE, "The object or config variable type is invalid or doesn't match"},
|
24
|
+
{GIT_EMISSINGOBJDATA, "The object cannot be written that because it's missing internal data"},
|
25
|
+
{GIT_EPACKCORRUPTED, "The packfile for the ODB is corrupted"},
|
26
|
+
{GIT_EFLOCKFAIL, "Failed to adquire or release a file lock"},
|
27
|
+
{GIT_EZLIB, "The Z library failed to inflate/deflate an object's data"},
|
28
|
+
{GIT_EBUSY, "The queried object is currently busy"},
|
29
|
+
{GIT_EINVALIDPATH, "The path is invalid"},
|
30
|
+
{GIT_EBAREINDEX, "The index file is not backed up by an existing repository"},
|
31
|
+
{GIT_EINVALIDREFNAME, "The name of the reference is not valid"},
|
32
|
+
{GIT_EREFCORRUPTED, "The specified reference has its data corrupted"},
|
33
|
+
{GIT_ETOONESTEDSYMREF, "The specified symbolic reference is too deeply nested"},
|
34
|
+
{GIT_EPACKEDREFSCORRUPTED, "The pack-refs file is either corrupted of its format is not currently supported"},
|
35
|
+
{GIT_EINVALIDPATH, "The path is invalid" },
|
36
|
+
{GIT_EREVWALKOVER, "The revision walker is empty; there are no more commits left to iterate"},
|
37
|
+
{GIT_EINVALIDREFSTATE, "The state of the reference is not valid"},
|
38
|
+
{GIT_ENOTIMPLEMENTED, "This feature has not been implemented yet"},
|
39
|
+
{GIT_EEXISTS, "A reference with this name already exists"},
|
40
|
+
{GIT_EOVERFLOW, "The given integer literal is too large to be parsed"},
|
41
|
+
{GIT_ENOTNUM, "The given literal is not a valid number"},
|
42
|
+
{GIT_EAMBIGUOUSOIDPREFIX, "The given oid prefix is ambiguous"},
|
43
|
+
};
|
44
|
+
|
45
|
+
const char *git_strerror(int num)
|
46
|
+
{
|
47
|
+
size_t i;
|
48
|
+
|
49
|
+
if (num == GIT_EOSERR)
|
50
|
+
return strerror(errno);
|
51
|
+
for (i = 0; i < ARRAY_SIZE(error_codes); i++)
|
52
|
+
if (num == error_codes[i].num)
|
53
|
+
return error_codes[i].str;
|
54
|
+
|
55
|
+
return "Unknown error";
|
56
|
+
}
|
57
|
+
|
58
|
+
#define ERROR_MAX_LEN 1024
|
59
|
+
|
60
|
+
void git___rethrow(const char *msg, ...)
|
61
|
+
{
|
62
|
+
char new_error[ERROR_MAX_LEN];
|
63
|
+
char *last_error;
|
64
|
+
char *old_error = NULL;
|
65
|
+
|
66
|
+
va_list va;
|
67
|
+
|
68
|
+
last_error = GIT_GLOBAL->error.last;
|
69
|
+
|
70
|
+
va_start(va, msg);
|
71
|
+
vsnprintf(new_error, ERROR_MAX_LEN, msg, va);
|
72
|
+
va_end(va);
|
73
|
+
|
74
|
+
old_error = git__strdup(last_error);
|
75
|
+
|
76
|
+
snprintf(last_error, ERROR_MAX_LEN, "%s \n - %s", new_error, old_error);
|
77
|
+
|
78
|
+
git__free(old_error);
|
79
|
+
}
|
80
|
+
|
81
|
+
void git___throw(const char *msg, ...)
|
82
|
+
{
|
83
|
+
va_list va;
|
84
|
+
|
85
|
+
va_start(va, msg);
|
86
|
+
vsnprintf(GIT_GLOBAL->error.last, ERROR_MAX_LEN, msg, va);
|
87
|
+
va_end(va);
|
88
|
+
}
|
89
|
+
|
90
|
+
const char *git_lasterror(void)
|
91
|
+
{
|
92
|
+
char *last_error = GIT_GLOBAL->error.last;
|
93
|
+
|
94
|
+
if (!last_error[0])
|
95
|
+
return NULL;
|
96
|
+
|
97
|
+
return last_error;
|
98
|
+
}
|
99
|
+
|
100
|
+
void git_clearerror(void)
|
101
|
+
{
|
102
|
+
char *last_error = GIT_GLOBAL->error.last;
|
103
|
+
last_error[0] = '\0';
|
104
|
+
}
|
@@ -0,0 +1,172 @@
|
|
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/oid.h"
|
10
|
+
#include "git2/refs.h"
|
11
|
+
#include "git2/revwalk.h"
|
12
|
+
|
13
|
+
#include "common.h"
|
14
|
+
#include "transport.h"
|
15
|
+
#include "remote.h"
|
16
|
+
#include "refspec.h"
|
17
|
+
#include "pack.h"
|
18
|
+
#include "fetch.h"
|
19
|
+
#include "netops.h"
|
20
|
+
|
21
|
+
struct filter_payload {
|
22
|
+
git_remote *remote;
|
23
|
+
const git_refspec *spec;
|
24
|
+
git_odb *odb;
|
25
|
+
int found_head;
|
26
|
+
};
|
27
|
+
|
28
|
+
static int filter_ref__cb(git_remote_head *head, void *payload)
|
29
|
+
{
|
30
|
+
struct filter_payload *p = payload;
|
31
|
+
int error;
|
32
|
+
|
33
|
+
if (!p->found_head && strcmp(head->name, GIT_HEAD_FILE) == 0) {
|
34
|
+
p->found_head = 1;
|
35
|
+
} else {
|
36
|
+
/* If it doesn't match the refpec, we don't want it */
|
37
|
+
error = git_refspec_src_match(p->spec, head->name);
|
38
|
+
|
39
|
+
if (error == GIT_ENOMATCH)
|
40
|
+
return GIT_SUCCESS;
|
41
|
+
|
42
|
+
if (error < GIT_SUCCESS)
|
43
|
+
return git__rethrow(error, "Error matching remote ref name");
|
44
|
+
}
|
45
|
+
|
46
|
+
/* If we have the object, mark it so we don't ask for it */
|
47
|
+
if (git_odb_exists(p->odb, &head->oid))
|
48
|
+
head->local = 1;
|
49
|
+
else
|
50
|
+
p->remote->need_pack = 1;
|
51
|
+
|
52
|
+
return git_vector_insert(&p->remote->refs, head);
|
53
|
+
}
|
54
|
+
|
55
|
+
static int filter_wants(git_remote *remote)
|
56
|
+
{
|
57
|
+
int error;
|
58
|
+
struct filter_payload p;
|
59
|
+
|
60
|
+
git_vector_clear(&remote->refs);
|
61
|
+
|
62
|
+
/*
|
63
|
+
* The fetch refspec can be NULL, and what this means is that the
|
64
|
+
* user didn't specify one. This is fine, as it means that we're
|
65
|
+
* not interested in any particular branch but just the remote's
|
66
|
+
* HEAD, which will be stored in FETCH_HEAD after the fetch.
|
67
|
+
*/
|
68
|
+
p.spec = git_remote_fetchspec(remote);
|
69
|
+
p.found_head = 0;
|
70
|
+
p.remote = remote;
|
71
|
+
|
72
|
+
error = git_repository_odb__weakptr(&p.odb, remote->repo);
|
73
|
+
if (error < GIT_SUCCESS)
|
74
|
+
return error;
|
75
|
+
|
76
|
+
return remote->transport->ls(remote->transport, &filter_ref__cb, &p);
|
77
|
+
}
|
78
|
+
|
79
|
+
/*
|
80
|
+
* In this first version, we push all our refs in and start sending
|
81
|
+
* them out. When we get an ACK we hide that commit and continue
|
82
|
+
* traversing until we're done
|
83
|
+
*/
|
84
|
+
int git_fetch_negotiate(git_remote *remote)
|
85
|
+
{
|
86
|
+
int error;
|
87
|
+
git_transport *t = remote->transport;
|
88
|
+
|
89
|
+
error = filter_wants(remote);
|
90
|
+
if (error < GIT_SUCCESS)
|
91
|
+
return git__rethrow(error, "Failed to filter the reference list for wants");
|
92
|
+
|
93
|
+
/* Don't try to negotiate when we don't want anything */
|
94
|
+
if (remote->refs.length == 0)
|
95
|
+
return GIT_SUCCESS;
|
96
|
+
|
97
|
+
if (!remote->need_pack)
|
98
|
+
return GIT_SUCCESS;
|
99
|
+
|
100
|
+
/*
|
101
|
+
* Now we have everything set up so we can start tell the server
|
102
|
+
* what we want and what we have.
|
103
|
+
*/
|
104
|
+
return t->negotiate_fetch(t, remote->repo, &remote->refs);
|
105
|
+
}
|
106
|
+
|
107
|
+
int git_fetch_download_pack(char **out, git_remote *remote)
|
108
|
+
{
|
109
|
+
if(!remote->need_pack) {
|
110
|
+
*out = NULL;
|
111
|
+
return GIT_SUCCESS;
|
112
|
+
}
|
113
|
+
|
114
|
+
return remote->transport->download_pack(out, remote->transport, remote->repo);
|
115
|
+
}
|
116
|
+
|
117
|
+
/* Receiving data from a socket and storing it is pretty much the same for git and HTTP */
|
118
|
+
int git_fetch__download_pack(char **out, const char *buffered, size_t buffered_size,
|
119
|
+
GIT_SOCKET fd, git_repository *repo)
|
120
|
+
{
|
121
|
+
git_filebuf file = GIT_FILEBUF_INIT;
|
122
|
+
int error;
|
123
|
+
char buff[1024], path[GIT_PATH_MAX];
|
124
|
+
static const char suff[] = "/objects/pack/pack-received";
|
125
|
+
gitno_buffer buf;
|
126
|
+
|
127
|
+
|
128
|
+
git_path_join(path, repo->path_repository, suff);
|
129
|
+
|
130
|
+
gitno_buffer_setup(&buf, buff, sizeof(buff), fd);
|
131
|
+
|
132
|
+
if (memcmp(buffered, "PACK", strlen("PACK"))) {
|
133
|
+
return git__throw(GIT_ERROR, "The pack doesn't start with the signature");
|
134
|
+
}
|
135
|
+
|
136
|
+
error = git_filebuf_open(&file, path, GIT_FILEBUF_TEMPORARY);
|
137
|
+
if (error < GIT_SUCCESS)
|
138
|
+
goto cleanup;
|
139
|
+
|
140
|
+
/* Part of the packfile has been received, don't loose it */
|
141
|
+
error = git_filebuf_write(&file, buffered, buffered_size);
|
142
|
+
if (error < GIT_SUCCESS)
|
143
|
+
goto cleanup;
|
144
|
+
|
145
|
+
while (1) {
|
146
|
+
error = git_filebuf_write(&file, buf.data, buf.offset);
|
147
|
+
if (error < GIT_SUCCESS)
|
148
|
+
goto cleanup;
|
149
|
+
|
150
|
+
gitno_consume_n(&buf, buf.offset);
|
151
|
+
error = gitno_recv(&buf);
|
152
|
+
if (error < GIT_SUCCESS)
|
153
|
+
goto cleanup;
|
154
|
+
if (error == 0) /* Orderly shutdown */
|
155
|
+
break;
|
156
|
+
}
|
157
|
+
|
158
|
+
*out = git__strdup(file.path_lock);
|
159
|
+
if (*out == NULL) {
|
160
|
+
error = GIT_ENOMEM;
|
161
|
+
goto cleanup;
|
162
|
+
}
|
163
|
+
|
164
|
+
/* A bit dodgy, but we need to keep the pack at the temporary path */
|
165
|
+
error = git_filebuf_commit_at(&file, file.path_lock, GIT_PACK_FILE_MODE);
|
166
|
+
cleanup:
|
167
|
+
if (error < GIT_SUCCESS)
|
168
|
+
git_filebuf_cleanup(&file);
|
169
|
+
|
170
|
+
return error;
|
171
|
+
|
172
|
+
}
|