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,322 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Raw data
|
4
|
+
*/
|
5
|
+
static unsigned char commit_data[] = {
|
6
|
+
0x74, 0x72, 0x65, 0x65, 0x20, 0x64, 0x66, 0x66,
|
7
|
+
0x32, 0x64, 0x61, 0x39, 0x30, 0x62, 0x32, 0x35,
|
8
|
+
0x34, 0x65, 0x31, 0x62, 0x65, 0x62, 0x38, 0x38,
|
9
|
+
0x39, 0x64, 0x31, 0x66, 0x31, 0x66, 0x31, 0x32,
|
10
|
+
0x38, 0x38, 0x62, 0x65, 0x31, 0x38, 0x30, 0x33,
|
11
|
+
0x37, 0x38, 0x32, 0x64, 0x66, 0x0a, 0x61, 0x75,
|
12
|
+
0x74, 0x68, 0x6f, 0x72, 0x20, 0x41, 0x20, 0x55,
|
13
|
+
0x20, 0x54, 0x68, 0x6f, 0x72, 0x20, 0x3c, 0x61,
|
14
|
+
0x75, 0x74, 0x68, 0x6f, 0x72, 0x40, 0x65, 0x78,
|
15
|
+
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f,
|
16
|
+
0x6d, 0x3e, 0x20, 0x31, 0x32, 0x32, 0x37, 0x38,
|
17
|
+
0x31, 0x34, 0x32, 0x39, 0x37, 0x20, 0x2b, 0x30,
|
18
|
+
0x30, 0x30, 0x30, 0x0a, 0x63, 0x6f, 0x6d, 0x6d,
|
19
|
+
0x69, 0x74, 0x74, 0x65, 0x72, 0x20, 0x43, 0x20,
|
20
|
+
0x4f, 0x20, 0x4d, 0x69, 0x74, 0x74, 0x65, 0x72,
|
21
|
+
0x20, 0x3c, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
|
22
|
+
0x74, 0x65, 0x72, 0x40, 0x65, 0x78, 0x61, 0x6d,
|
23
|
+
0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x3e,
|
24
|
+
0x20, 0x31, 0x32, 0x32, 0x37, 0x38, 0x31, 0x34,
|
25
|
+
0x32, 0x39, 0x37, 0x20, 0x2b, 0x30, 0x30, 0x30,
|
26
|
+
0x30, 0x0a, 0x0a, 0x41, 0x20, 0x6f, 0x6e, 0x65,
|
27
|
+
0x2d, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x63, 0x6f,
|
28
|
+
0x6d, 0x6d, 0x69, 0x74, 0x20, 0x73, 0x75, 0x6d,
|
29
|
+
0x6d, 0x61, 0x72, 0x79, 0x0a, 0x0a, 0x54, 0x68,
|
30
|
+
0x65, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x6f,
|
31
|
+
0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f,
|
32
|
+
0x6d, 0x6d, 0x69, 0x74, 0x20, 0x6d, 0x65, 0x73,
|
33
|
+
0x73, 0x61, 0x67, 0x65, 0x2c, 0x20, 0x63, 0x6f,
|
34
|
+
0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67,
|
35
|
+
0x20, 0x66, 0x75, 0x72, 0x74, 0x68, 0x65, 0x72,
|
36
|
+
0x20, 0x65, 0x78, 0x70, 0x6c, 0x61, 0x6e, 0x61,
|
37
|
+
0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x6f, 0x66, 0x20,
|
38
|
+
0x74, 0x68, 0x65, 0x20, 0x70, 0x75, 0x72, 0x70,
|
39
|
+
0x6f, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74,
|
40
|
+
0x68, 0x65, 0x20, 0x63, 0x68, 0x61, 0x6e, 0x67,
|
41
|
+
0x65, 0x73, 0x20, 0x69, 0x6e, 0x74, 0x72, 0x6f,
|
42
|
+
0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x62, 0x79,
|
43
|
+
0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6d,
|
44
|
+
0x6d, 0x69, 0x74, 0x2e, 0x0a, 0x0a, 0x53, 0x69,
|
45
|
+
0x67, 0x6e, 0x65, 0x64, 0x2d, 0x6f, 0x66, 0x2d,
|
46
|
+
0x62, 0x79, 0x3a, 0x20, 0x41, 0x20, 0x55, 0x20,
|
47
|
+
0x54, 0x68, 0x6f, 0x72, 0x20, 0x3c, 0x61, 0x75,
|
48
|
+
0x74, 0x68, 0x6f, 0x72, 0x40, 0x65, 0x78, 0x61,
|
49
|
+
0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d,
|
50
|
+
0x3e, 0x0a,
|
51
|
+
};
|
52
|
+
|
53
|
+
|
54
|
+
static unsigned char tree_data[] = {
|
55
|
+
0x31, 0x30, 0x30, 0x36, 0x34, 0x34, 0x20, 0x6f,
|
56
|
+
0x6e, 0x65, 0x00, 0x8b, 0x13, 0x78, 0x91, 0x79,
|
57
|
+
0x1f, 0xe9, 0x69, 0x27, 0xad, 0x78, 0xe6, 0x4b,
|
58
|
+
0x0a, 0xad, 0x7b, 0xde, 0xd0, 0x8b, 0xdc, 0x31,
|
59
|
+
0x30, 0x30, 0x36, 0x34, 0x34, 0x20, 0x73, 0x6f,
|
60
|
+
0x6d, 0x65, 0x00, 0xfd, 0x84, 0x30, 0xbc, 0x86,
|
61
|
+
0x4c, 0xfc, 0xd5, 0xf1, 0x0e, 0x55, 0x90, 0xf8,
|
62
|
+
0xa4, 0x47, 0xe0, 0x1b, 0x94, 0x2b, 0xfe, 0x31,
|
63
|
+
0x30, 0x30, 0x36, 0x34, 0x34, 0x20, 0x74, 0x77,
|
64
|
+
0x6f, 0x00, 0x78, 0x98, 0x19, 0x22, 0x61, 0x3b,
|
65
|
+
0x2a, 0xfb, 0x60, 0x25, 0x04, 0x2f, 0xf6, 0xbd,
|
66
|
+
0x87, 0x8a, 0xc1, 0x99, 0x4e, 0x85, 0x31, 0x30,
|
67
|
+
0x30, 0x36, 0x34, 0x34, 0x20, 0x7a, 0x65, 0x72,
|
68
|
+
0x6f, 0x00, 0xe6, 0x9d, 0xe2, 0x9b, 0xb2, 0xd1,
|
69
|
+
0xd6, 0x43, 0x4b, 0x8b, 0x29, 0xae, 0x77, 0x5a,
|
70
|
+
0xd8, 0xc2, 0xe4, 0x8c, 0x53, 0x91,
|
71
|
+
};
|
72
|
+
|
73
|
+
static unsigned char tag_data[] = {
|
74
|
+
0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x33,
|
75
|
+
0x64, 0x37, 0x66, 0x38, 0x61, 0x36, 0x61, 0x66,
|
76
|
+
0x30, 0x37, 0x36, 0x63, 0x38, 0x63, 0x33, 0x66,
|
77
|
+
0x32, 0x30, 0x30, 0x37, 0x31, 0x61, 0x38, 0x39,
|
78
|
+
0x33, 0x35, 0x63, 0x64, 0x62, 0x65, 0x38, 0x32,
|
79
|
+
0x32, 0x38, 0x35, 0x39, 0x34, 0x64, 0x31, 0x0a,
|
80
|
+
0x74, 0x79, 0x70, 0x65, 0x20, 0x63, 0x6f, 0x6d,
|
81
|
+
0x6d, 0x69, 0x74, 0x0a, 0x74, 0x61, 0x67, 0x20,
|
82
|
+
0x76, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x0a, 0x74,
|
83
|
+
0x61, 0x67, 0x67, 0x65, 0x72, 0x20, 0x43, 0x20,
|
84
|
+
0x4f, 0x20, 0x4d, 0x69, 0x74, 0x74, 0x65, 0x72,
|
85
|
+
0x20, 0x3c, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
|
86
|
+
0x74, 0x65, 0x72, 0x40, 0x65, 0x78, 0x61, 0x6d,
|
87
|
+
0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x3e,
|
88
|
+
0x20, 0x31, 0x32, 0x32, 0x37, 0x38, 0x31, 0x34,
|
89
|
+
0x32, 0x39, 0x37, 0x20, 0x2b, 0x30, 0x30, 0x30,
|
90
|
+
0x30, 0x0a, 0x0a, 0x54, 0x68, 0x69, 0x73, 0x20,
|
91
|
+
0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x74,
|
92
|
+
0x61, 0x67, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
|
93
|
+
0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x72, 0x65,
|
94
|
+
0x6c, 0x65, 0x61, 0x73, 0x65, 0x20, 0x76, 0x30,
|
95
|
+
0x2e, 0x30, 0x2e, 0x31, 0x0a,
|
96
|
+
};
|
97
|
+
|
98
|
+
static unsigned char zero_data[] = {
|
99
|
+
0x00 /* dummy data */
|
100
|
+
};
|
101
|
+
|
102
|
+
static unsigned char one_data[] = {
|
103
|
+
0x0a,
|
104
|
+
};
|
105
|
+
|
106
|
+
static unsigned char two_data[] = {
|
107
|
+
0x61, 0x0a,
|
108
|
+
};
|
109
|
+
|
110
|
+
static unsigned char some_data[] = {
|
111
|
+
0x2f, 0x2a, 0x0a, 0x20, 0x2a, 0x20, 0x54, 0x68,
|
112
|
+
0x69, 0x73, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20,
|
113
|
+
0x69, 0x73, 0x20, 0x66, 0x72, 0x65, 0x65, 0x20,
|
114
|
+
0x73, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
|
115
|
+
0x3b, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x63, 0x61,
|
116
|
+
0x6e, 0x20, 0x72, 0x65, 0x64, 0x69, 0x73, 0x74,
|
117
|
+
0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x69,
|
118
|
+
0x74, 0x20, 0x61, 0x6e, 0x64, 0x2f, 0x6f, 0x72,
|
119
|
+
0x20, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0a,
|
120
|
+
0x20, 0x2a, 0x20, 0x69, 0x74, 0x20, 0x75, 0x6e,
|
121
|
+
0x64, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20,
|
122
|
+
0x74, 0x65, 0x72, 0x6d, 0x73, 0x20, 0x6f, 0x66,
|
123
|
+
0x20, 0x74, 0x68, 0x65, 0x20, 0x47, 0x4e, 0x55,
|
124
|
+
0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c,
|
125
|
+
0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20,
|
126
|
+
0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x2c,
|
127
|
+
0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
128
|
+
0x20, 0x32, 0x2c, 0x0a, 0x20, 0x2a, 0x20, 0x61,
|
129
|
+
0x73, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73,
|
130
|
+
0x68, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74,
|
131
|
+
0x68, 0x65, 0x20, 0x46, 0x72, 0x65, 0x65, 0x20,
|
132
|
+
0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
|
133
|
+
0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74,
|
134
|
+
0x69, 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x2a, 0x0a,
|
135
|
+
0x20, 0x2a, 0x20, 0x49, 0x6e, 0x20, 0x61, 0x64,
|
136
|
+
0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74,
|
137
|
+
0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x65,
|
138
|
+
0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e,
|
139
|
+
0x73, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65,
|
140
|
+
0x20, 0x47, 0x4e, 0x55, 0x20, 0x47, 0x65, 0x6e,
|
141
|
+
0x65, 0x72, 0x61, 0x6c, 0x20, 0x50, 0x75, 0x62,
|
142
|
+
0x6c, 0x69, 0x63, 0x20, 0x4c, 0x69, 0x63, 0x65,
|
143
|
+
0x6e, 0x73, 0x65, 0x2c, 0x0a, 0x20, 0x2a, 0x20,
|
144
|
+
0x74, 0x68, 0x65, 0x20, 0x61, 0x75, 0x74, 0x68,
|
145
|
+
0x6f, 0x72, 0x73, 0x20, 0x67, 0x69, 0x76, 0x65,
|
146
|
+
0x20, 0x79, 0x6f, 0x75, 0x20, 0x75, 0x6e, 0x6c,
|
147
|
+
0x69, 0x6d, 0x69, 0x74, 0x65, 0x64, 0x20, 0x70,
|
148
|
+
0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f,
|
149
|
+
0x6e, 0x20, 0x74, 0x6f, 0x20, 0x6c, 0x69, 0x6e,
|
150
|
+
0x6b, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f,
|
151
|
+
0x6d, 0x70, 0x69, 0x6c, 0x65, 0x64, 0x0a, 0x20,
|
152
|
+
0x2a, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f,
|
153
|
+
0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x69,
|
154
|
+
0x73, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x69,
|
155
|
+
0x6e, 0x74, 0x6f, 0x20, 0x63, 0x6f, 0x6d, 0x62,
|
156
|
+
0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
157
|
+
0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x6f, 0x74,
|
158
|
+
0x68, 0x65, 0x72, 0x20, 0x70, 0x72, 0x6f, 0x67,
|
159
|
+
0x72, 0x61, 0x6d, 0x73, 0x2c, 0x0a, 0x20, 0x2a,
|
160
|
+
0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x6f, 0x20,
|
161
|
+
0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75,
|
162
|
+
0x74, 0x65, 0x20, 0x74, 0x68, 0x6f, 0x73, 0x65,
|
163
|
+
0x20, 0x63, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x61,
|
164
|
+
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x77, 0x69,
|
165
|
+
0x74, 0x68, 0x6f, 0x75, 0x74, 0x20, 0x61, 0x6e,
|
166
|
+
0x79, 0x20, 0x72, 0x65, 0x73, 0x74, 0x72, 0x69,
|
167
|
+
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x2a,
|
168
|
+
0x20, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x20,
|
169
|
+
0x66, 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68, 0x65,
|
170
|
+
0x20, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20,
|
171
|
+
0x74, 0x68, 0x69, 0x73, 0x20, 0x66, 0x69, 0x6c,
|
172
|
+
0x65, 0x2e, 0x20, 0x20, 0x28, 0x54, 0x68, 0x65,
|
173
|
+
0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c,
|
174
|
+
0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20,
|
175
|
+
0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x0a,
|
176
|
+
0x20, 0x2a, 0x20, 0x72, 0x65, 0x73, 0x74, 0x72,
|
177
|
+
0x69, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20,
|
178
|
+
0x64, 0x6f, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x79,
|
179
|
+
0x20, 0x69, 0x6e, 0x20, 0x6f, 0x74, 0x68, 0x65,
|
180
|
+
0x72, 0x20, 0x72, 0x65, 0x73, 0x70, 0x65, 0x63,
|
181
|
+
0x74, 0x73, 0x3b, 0x20, 0x66, 0x6f, 0x72, 0x20,
|
182
|
+
0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2c,
|
183
|
+
0x20, 0x74, 0x68, 0x65, 0x79, 0x20, 0x63, 0x6f,
|
184
|
+
0x76, 0x65, 0x72, 0x0a, 0x20, 0x2a, 0x20, 0x6d,
|
185
|
+
0x6f, 0x64, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74,
|
186
|
+
0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74,
|
187
|
+
0x68, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2c,
|
188
|
+
0x20, 0x61, 0x6e, 0x64, 0x20, 0x64, 0x69, 0x73,
|
189
|
+
0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f,
|
190
|
+
0x6e, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x6e,
|
191
|
+
0x6f, 0x74, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0x65,
|
192
|
+
0x64, 0x20, 0x69, 0x6e, 0x74, 0x6f, 0x0a, 0x20,
|
193
|
+
0x2a, 0x20, 0x61, 0x20, 0x63, 0x6f, 0x6d, 0x62,
|
194
|
+
0x69, 0x6e, 0x65, 0x64, 0x20, 0x65, 0x78, 0x65,
|
195
|
+
0x63, 0x75, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e,
|
196
|
+
0x29, 0x0a, 0x20, 0x2a, 0x0a, 0x20, 0x2a, 0x20,
|
197
|
+
0x54, 0x68, 0x69, 0x73, 0x20, 0x66, 0x69, 0x6c,
|
198
|
+
0x65, 0x20, 0x69, 0x73, 0x20, 0x64, 0x69, 0x73,
|
199
|
+
0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64,
|
200
|
+
0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20,
|
201
|
+
0x68, 0x6f, 0x70, 0x65, 0x20, 0x74, 0x68, 0x61,
|
202
|
+
0x74, 0x20, 0x69, 0x74, 0x20, 0x77, 0x69, 0x6c,
|
203
|
+
0x6c, 0x20, 0x62, 0x65, 0x20, 0x75, 0x73, 0x65,
|
204
|
+
0x66, 0x75, 0x6c, 0x2c, 0x20, 0x62, 0x75, 0x74,
|
205
|
+
0x0a, 0x20, 0x2a, 0x20, 0x57, 0x49, 0x54, 0x48,
|
206
|
+
0x4f, 0x55, 0x54, 0x20, 0x41, 0x4e, 0x59, 0x20,
|
207
|
+
0x57, 0x41, 0x52, 0x52, 0x41, 0x4e, 0x54, 0x59,
|
208
|
+
0x3b, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75,
|
209
|
+
0x74, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x20, 0x74,
|
210
|
+
0x68, 0x65, 0x20, 0x69, 0x6d, 0x70, 0x6c, 0x69,
|
211
|
+
0x65, 0x64, 0x20, 0x77, 0x61, 0x72, 0x72, 0x61,
|
212
|
+
0x6e, 0x74, 0x79, 0x20, 0x6f, 0x66, 0x0a, 0x20,
|
213
|
+
0x2a, 0x20, 0x4d, 0x45, 0x52, 0x43, 0x48, 0x41,
|
214
|
+
0x4e, 0x54, 0x41, 0x42, 0x49, 0x4c, 0x49, 0x54,
|
215
|
+
0x59, 0x20, 0x6f, 0x72, 0x20, 0x46, 0x49, 0x54,
|
216
|
+
0x4e, 0x45, 0x53, 0x53, 0x20, 0x46, 0x4f, 0x52,
|
217
|
+
0x20, 0x41, 0x20, 0x50, 0x41, 0x52, 0x54, 0x49,
|
218
|
+
0x43, 0x55, 0x4c, 0x41, 0x52, 0x20, 0x50, 0x55,
|
219
|
+
0x52, 0x50, 0x4f, 0x53, 0x45, 0x2e, 0x20, 0x20,
|
220
|
+
0x53, 0x65, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20,
|
221
|
+
0x47, 0x4e, 0x55, 0x0a, 0x20, 0x2a, 0x20, 0x47,
|
222
|
+
0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x20, 0x50,
|
223
|
+
0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x4c, 0x69,
|
224
|
+
0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x66, 0x6f,
|
225
|
+
0x72, 0x20, 0x6d, 0x6f, 0x72, 0x65, 0x20, 0x64,
|
226
|
+
0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x0a,
|
227
|
+
0x20, 0x2a, 0x0a, 0x20, 0x2a, 0x20, 0x59, 0x6f,
|
228
|
+
0x75, 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64,
|
229
|
+
0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x72, 0x65,
|
230
|
+
0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x20, 0x61,
|
231
|
+
0x20, 0x63, 0x6f, 0x70, 0x79, 0x20, 0x6f, 0x66,
|
232
|
+
0x20, 0x74, 0x68, 0x65, 0x20, 0x47, 0x4e, 0x55,
|
233
|
+
0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c,
|
234
|
+
0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20,
|
235
|
+
0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x0a,
|
236
|
+
0x20, 0x2a, 0x20, 0x61, 0x6c, 0x6f, 0x6e, 0x67,
|
237
|
+
0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74, 0x68,
|
238
|
+
0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72,
|
239
|
+
0x61, 0x6d, 0x3b, 0x20, 0x73, 0x65, 0x65, 0x20,
|
240
|
+
0x74, 0x68, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x65,
|
241
|
+
0x20, 0x43, 0x4f, 0x50, 0x59, 0x49, 0x4e, 0x47,
|
242
|
+
0x2e, 0x20, 0x20, 0x49, 0x66, 0x20, 0x6e, 0x6f,
|
243
|
+
0x74, 0x2c, 0x20, 0x77, 0x72, 0x69, 0x74, 0x65,
|
244
|
+
0x20, 0x74, 0x6f, 0x0a, 0x20, 0x2a, 0x20, 0x74,
|
245
|
+
0x68, 0x65, 0x20, 0x46, 0x72, 0x65, 0x65, 0x20,
|
246
|
+
0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65,
|
247
|
+
0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x74,
|
248
|
+
0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x35, 0x31, 0x20,
|
249
|
+
0x46, 0x72, 0x61, 0x6e, 0x6b, 0x6c, 0x69, 0x6e,
|
250
|
+
0x20, 0x53, 0x74, 0x72, 0x65, 0x65, 0x74, 0x2c,
|
251
|
+
0x20, 0x46, 0x69, 0x66, 0x74, 0x68, 0x20, 0x46,
|
252
|
+
0x6c, 0x6f, 0x6f, 0x72, 0x2c, 0x0a, 0x20, 0x2a,
|
253
|
+
0x20, 0x42, 0x6f, 0x73, 0x74, 0x6f, 0x6e, 0x2c,
|
254
|
+
0x20, 0x4d, 0x41, 0x20, 0x30, 0x32, 0x31, 0x31,
|
255
|
+
0x30, 0x2d, 0x31, 0x33, 0x30, 0x31, 0x2c, 0x20,
|
256
|
+
0x55, 0x53, 0x41, 0x2e, 0x0a, 0x20, 0x2a, 0x2f,
|
257
|
+
0x0a,
|
258
|
+
};
|
259
|
+
|
260
|
+
/*
|
261
|
+
* Sha1 IDS
|
262
|
+
*/
|
263
|
+
static char *commit_id = "3d7f8a6af076c8c3f20071a8935cdbe8228594d1";
|
264
|
+
static char *tree_id = "dff2da90b254e1beb889d1f1f1288be1803782df";
|
265
|
+
static char *tag_id = "09d373e1dfdc16b129ceec6dd649739911541e05";
|
266
|
+
static char *zero_id = "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391";
|
267
|
+
static char *one_id = "8b137891791fe96927ad78e64b0aad7bded08bdc";
|
268
|
+
static char *two_id = "78981922613b2afb6025042ff6bd878ac1994e85";
|
269
|
+
static char *some_id = "fd8430bc864cfcd5f10e5590f8a447e01b942bfe";
|
270
|
+
|
271
|
+
/*
|
272
|
+
* In memory objects
|
273
|
+
*/
|
274
|
+
static git_rawobj tree_obj = {
|
275
|
+
tree_data,
|
276
|
+
sizeof(tree_data),
|
277
|
+
GIT_OBJ_TREE
|
278
|
+
};
|
279
|
+
|
280
|
+
static git_rawobj tag_obj = {
|
281
|
+
tag_data,
|
282
|
+
sizeof(tag_data),
|
283
|
+
GIT_OBJ_TAG
|
284
|
+
};
|
285
|
+
|
286
|
+
static git_rawobj zero_obj = {
|
287
|
+
zero_data,
|
288
|
+
0,
|
289
|
+
GIT_OBJ_BLOB
|
290
|
+
};
|
291
|
+
|
292
|
+
static git_rawobj one_obj = {
|
293
|
+
one_data,
|
294
|
+
sizeof(one_data),
|
295
|
+
GIT_OBJ_BLOB
|
296
|
+
};
|
297
|
+
|
298
|
+
static git_rawobj two_obj = {
|
299
|
+
two_data,
|
300
|
+
sizeof(two_data),
|
301
|
+
GIT_OBJ_BLOB
|
302
|
+
};
|
303
|
+
|
304
|
+
static git_rawobj commit_obj = {
|
305
|
+
commit_data,
|
306
|
+
sizeof(commit_data),
|
307
|
+
GIT_OBJ_COMMIT
|
308
|
+
};
|
309
|
+
|
310
|
+
static git_rawobj some_obj = {
|
311
|
+
some_data,
|
312
|
+
sizeof(some_data),
|
313
|
+
GIT_OBJ_BLOB
|
314
|
+
};
|
315
|
+
|
316
|
+
static git_rawobj junk_obj = {
|
317
|
+
NULL,
|
318
|
+
0,
|
319
|
+
GIT_OBJ_BAD
|
320
|
+
};
|
321
|
+
|
322
|
+
|
@@ -0,0 +1,638 @@
|
|
1
|
+
/*
|
2
|
+
* This file is free software; you can redistribute it and/or modify
|
3
|
+
* it under the terms of the GNU General Public License, version 2,
|
4
|
+
* as published by the Free Software Foundation.
|
5
|
+
*
|
6
|
+
* In addition to the permissions in the GNU General Public License,
|
7
|
+
* the authors give you unlimited permission to link the compiled
|
8
|
+
* version of this file into combinations with other programs,
|
9
|
+
* and to distribute those combinations without any restriction
|
10
|
+
* coming from the use of this file. (The General Public License
|
11
|
+
* restrictions do apply in other respects; for example, they cover
|
12
|
+
* modification of the file, and distribution when not linked into
|
13
|
+
* a combined executable.)
|
14
|
+
*
|
15
|
+
* This file is distributed in the hope that it will be useful, but
|
16
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18
|
+
* General Public License for more details.
|
19
|
+
*
|
20
|
+
* You should have received a copy of the GNU General Public License
|
21
|
+
* along with this program; see the file COPYING. If not, write to
|
22
|
+
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
23
|
+
* Boston, MA 02110-1301, USA.
|
24
|
+
*/
|
25
|
+
#include "test_lib.h"
|
26
|
+
|
27
|
+
#include "odb.h"
|
28
|
+
#include "hash.h"
|
29
|
+
|
30
|
+
#include "t01-data.h"
|
31
|
+
|
32
|
+
static int hash_object(git_oid *oid, git_rawobj *obj)
|
33
|
+
{
|
34
|
+
return git_odb_hash(oid, obj->data, obj->len, obj->type);
|
35
|
+
}
|
36
|
+
|
37
|
+
BEGIN_TEST(oid0, "validate size of oid objects")
|
38
|
+
git_oid out;
|
39
|
+
must_be_true(20 == GIT_OID_RAWSZ);
|
40
|
+
must_be_true(40 == GIT_OID_HEXSZ);
|
41
|
+
must_be_true(sizeof(out) == GIT_OID_RAWSZ);
|
42
|
+
must_be_true(sizeof(out.id) == GIT_OID_RAWSZ);
|
43
|
+
END_TEST
|
44
|
+
|
45
|
+
BEGIN_TEST(oid1, "fail when parsing an empty string as oid")
|
46
|
+
git_oid out;
|
47
|
+
must_fail(git_oid_fromstr(&out, ""));
|
48
|
+
END_TEST
|
49
|
+
|
50
|
+
BEGIN_TEST(oid2, "fail when parsing an invalid string as oid")
|
51
|
+
git_oid out;
|
52
|
+
must_fail(git_oid_fromstr(&out, "moo"));
|
53
|
+
END_TEST
|
54
|
+
|
55
|
+
static int from_hex(unsigned int i)
|
56
|
+
{
|
57
|
+
if (i >= '0' && i <= '9')
|
58
|
+
return i - '0';
|
59
|
+
if (i >= 'a' && i <= 'f')
|
60
|
+
return 10 + (i - 'a');
|
61
|
+
if (i >= 'A' && i <= 'F')
|
62
|
+
return 10 + (i - 'A');
|
63
|
+
return -1;
|
64
|
+
}
|
65
|
+
|
66
|
+
BEGIN_TEST(oid3, "find all invalid characters when parsing an oid")
|
67
|
+
git_oid out;
|
68
|
+
unsigned char exp[] = {
|
69
|
+
0x16, 0xa6, 0x77, 0x70, 0xb7,
|
70
|
+
0xd8, 0xd7, 0x23, 0x17, 0xc4,
|
71
|
+
0xb7, 0x75, 0x21, 0x3c, 0x23,
|
72
|
+
0xa8, 0xbd, 0x74, 0xf5, 0xe0,
|
73
|
+
};
|
74
|
+
char in[41] = "16a67770b7d8d72317c4b775213c23a8bd74f5e0";
|
75
|
+
unsigned int i;
|
76
|
+
|
77
|
+
for (i = 0; i < 256; i++) {
|
78
|
+
in[38] = (char)i;
|
79
|
+
|
80
|
+
if (from_hex(i) >= 0) {
|
81
|
+
exp[19] = (unsigned char)(from_hex(i) << 4);
|
82
|
+
must_pass(git_oid_fromstr(&out, in));
|
83
|
+
must_be_true(memcmp(out.id, exp, sizeof(out.id)) == 0);
|
84
|
+
} else {
|
85
|
+
must_fail(git_oid_fromstr(&out, in));
|
86
|
+
}
|
87
|
+
}
|
88
|
+
END_TEST
|
89
|
+
|
90
|
+
BEGIN_TEST(oid4, "fail when parsing an invalid oid string")
|
91
|
+
git_oid out;
|
92
|
+
must_fail(git_oid_fromstr(&out, "16a67770b7d8d72317c4b775213c23a8bd74f5ez"));
|
93
|
+
END_TEST
|
94
|
+
|
95
|
+
BEGIN_TEST(oid5, "succeed when parsing a valid oid string")
|
96
|
+
git_oid out;
|
97
|
+
unsigned char exp[] = {
|
98
|
+
0x16, 0xa6, 0x77, 0x70, 0xb7,
|
99
|
+
0xd8, 0xd7, 0x23, 0x17, 0xc4,
|
100
|
+
0xb7, 0x75, 0x21, 0x3c, 0x23,
|
101
|
+
0xa8, 0xbd, 0x74, 0xf5, 0xe0,
|
102
|
+
};
|
103
|
+
|
104
|
+
must_pass(git_oid_fromstr(&out, "16a67770b7d8d72317c4b775213c23a8bd74f5e0"));
|
105
|
+
must_pass(memcmp(out.id, exp, sizeof(out.id)));
|
106
|
+
|
107
|
+
must_pass(git_oid_fromstr(&out, "16A67770B7D8D72317C4b775213C23A8BD74F5E0"));
|
108
|
+
must_pass(memcmp(out.id, exp, sizeof(out.id)));
|
109
|
+
END_TEST
|
110
|
+
|
111
|
+
BEGIN_TEST(oid6, "build a valid oid from raw bytes")
|
112
|
+
git_oid out;
|
113
|
+
unsigned char exp[] = {
|
114
|
+
0x16, 0xa6, 0x77, 0x70, 0xb7,
|
115
|
+
0xd8, 0xd7, 0x23, 0x17, 0xc4,
|
116
|
+
0xb7, 0x75, 0x21, 0x3c, 0x23,
|
117
|
+
0xa8, 0xbd, 0x74, 0xf5, 0xe0,
|
118
|
+
};
|
119
|
+
|
120
|
+
git_oid_fromraw(&out, exp);
|
121
|
+
must_pass(memcmp(out.id, exp, sizeof(out.id)));
|
122
|
+
END_TEST
|
123
|
+
|
124
|
+
BEGIN_TEST(oid7, "properly copy an oid to another")
|
125
|
+
git_oid a, b;
|
126
|
+
unsigned char exp[] = {
|
127
|
+
0x16, 0xa6, 0x77, 0x70, 0xb7,
|
128
|
+
0xd8, 0xd7, 0x23, 0x17, 0xc4,
|
129
|
+
0xb7, 0x75, 0x21, 0x3c, 0x23,
|
130
|
+
0xa8, 0xbd, 0x74, 0xf5, 0xe0,
|
131
|
+
};
|
132
|
+
|
133
|
+
memset(&b, 0, sizeof(b));
|
134
|
+
git_oid_fromraw(&a, exp);
|
135
|
+
git_oid_cpy(&b, &a);
|
136
|
+
must_pass(memcmp(a.id, exp, sizeof(a.id)));
|
137
|
+
END_TEST
|
138
|
+
|
139
|
+
BEGIN_TEST(oid8, "compare two oids (lesser than)")
|
140
|
+
git_oid a, b;
|
141
|
+
unsigned char a_in[] = {
|
142
|
+
0x16, 0xa6, 0x77, 0x70, 0xb7,
|
143
|
+
0xd8, 0xd7, 0x23, 0x17, 0xc4,
|
144
|
+
0xb7, 0x75, 0x21, 0x3c, 0x23,
|
145
|
+
0xa8, 0xbd, 0x74, 0xf5, 0xe0,
|
146
|
+
};
|
147
|
+
unsigned char b_in[] = {
|
148
|
+
0x16, 0xa6, 0x77, 0x70, 0xb7,
|
149
|
+
0xd8, 0xd7, 0x23, 0x17, 0xc4,
|
150
|
+
0xb7, 0x75, 0x21, 0x3c, 0x23,
|
151
|
+
0xa8, 0xbd, 0x74, 0xf5, 0xf0,
|
152
|
+
};
|
153
|
+
|
154
|
+
git_oid_fromraw(&a, a_in);
|
155
|
+
git_oid_fromraw(&b, b_in);
|
156
|
+
must_be_true(git_oid_cmp(&a, &b) < 0);
|
157
|
+
END_TEST
|
158
|
+
|
159
|
+
BEGIN_TEST(oid9, "compare two oids (equal)")
|
160
|
+
git_oid a, b;
|
161
|
+
unsigned char a_in[] = {
|
162
|
+
0x16, 0xa6, 0x77, 0x70, 0xb7,
|
163
|
+
0xd8, 0xd7, 0x23, 0x17, 0xc4,
|
164
|
+
0xb7, 0x75, 0x21, 0x3c, 0x23,
|
165
|
+
0xa8, 0xbd, 0x74, 0xf5, 0xe0,
|
166
|
+
};
|
167
|
+
|
168
|
+
git_oid_fromraw(&a, a_in);
|
169
|
+
git_oid_fromraw(&b, a_in);
|
170
|
+
must_be_true(git_oid_cmp(&a, &b) == 0);
|
171
|
+
END_TEST
|
172
|
+
|
173
|
+
BEGIN_TEST(oid10, "compare two oids (greater than)")
|
174
|
+
git_oid a, b;
|
175
|
+
unsigned char a_in[] = {
|
176
|
+
0x16, 0xa6, 0x77, 0x70, 0xb7,
|
177
|
+
0xd8, 0xd7, 0x23, 0x17, 0xc4,
|
178
|
+
0xb7, 0x75, 0x21, 0x3c, 0x23,
|
179
|
+
0xa8, 0xbd, 0x74, 0xf5, 0xe0,
|
180
|
+
};
|
181
|
+
unsigned char b_in[] = {
|
182
|
+
0x16, 0xa6, 0x77, 0x70, 0xb7,
|
183
|
+
0xd8, 0xd7, 0x23, 0x17, 0xc4,
|
184
|
+
0xb7, 0x75, 0x21, 0x3c, 0x23,
|
185
|
+
0xa8, 0xbd, 0x74, 0xf5, 0xd0,
|
186
|
+
};
|
187
|
+
|
188
|
+
git_oid_fromraw(&a, a_in);
|
189
|
+
git_oid_fromraw(&b, b_in);
|
190
|
+
must_be_true(git_oid_cmp(&a, &b) > 0);
|
191
|
+
END_TEST
|
192
|
+
|
193
|
+
BEGIN_TEST(oid11, "compare formated oids")
|
194
|
+
const char *exp = "16a0123456789abcdef4b775213c23a8bd74f5e0";
|
195
|
+
git_oid in;
|
196
|
+
char out[GIT_OID_HEXSZ + 1];
|
197
|
+
|
198
|
+
must_pass(git_oid_fromstr(&in, exp));
|
199
|
+
|
200
|
+
/* Format doesn't touch the last byte */
|
201
|
+
out[GIT_OID_HEXSZ] = 'Z';
|
202
|
+
git_oid_fmt(out, &in);
|
203
|
+
must_be_true(out[GIT_OID_HEXSZ] == 'Z');
|
204
|
+
|
205
|
+
/* Format produced the right result */
|
206
|
+
out[GIT_OID_HEXSZ] = '\0';
|
207
|
+
must_be_true(strcmp(exp, out) == 0);
|
208
|
+
END_TEST
|
209
|
+
|
210
|
+
BEGIN_TEST(oid12, "compare oids (allocate + format)")
|
211
|
+
const char *exp = "16a0123456789abcdef4b775213c23a8bd74f5e0";
|
212
|
+
git_oid in;
|
213
|
+
char *out;
|
214
|
+
|
215
|
+
must_pass(git_oid_fromstr(&in, exp));
|
216
|
+
|
217
|
+
out = git_oid_allocfmt(&in);
|
218
|
+
must_be_true(out);
|
219
|
+
must_be_true(strcmp(exp, out) == 0);
|
220
|
+
git__free(out);
|
221
|
+
END_TEST
|
222
|
+
|
223
|
+
BEGIN_TEST(oid13, "compare oids (path format)")
|
224
|
+
const char *exp1 = "16a0123456789abcdef4b775213c23a8bd74f5e0";
|
225
|
+
const char *exp2 = "16/a0123456789abcdef4b775213c23a8bd74f5e0";
|
226
|
+
git_oid in;
|
227
|
+
char out[GIT_OID_HEXSZ + 2];
|
228
|
+
|
229
|
+
must_pass(git_oid_fromstr(&in, exp1));
|
230
|
+
|
231
|
+
/* Format doesn't touch the last byte */
|
232
|
+
out[GIT_OID_HEXSZ + 1] = 'Z';
|
233
|
+
git_oid_pathfmt(out, &in);
|
234
|
+
must_be_true(out[GIT_OID_HEXSZ + 1] == 'Z');
|
235
|
+
|
236
|
+
/* Format produced the right result */
|
237
|
+
out[GIT_OID_HEXSZ + 1] = '\0';
|
238
|
+
must_be_true(strcmp(exp2, out) == 0);
|
239
|
+
END_TEST
|
240
|
+
|
241
|
+
BEGIN_TEST(oid14, "convert raw oid to string")
|
242
|
+
const char *exp = "16a0123456789abcdef4b775213c23a8bd74f5e0";
|
243
|
+
git_oid in;
|
244
|
+
char out[GIT_OID_HEXSZ + 1];
|
245
|
+
char *str;
|
246
|
+
int i;
|
247
|
+
|
248
|
+
must_pass(git_oid_fromstr(&in, exp));
|
249
|
+
|
250
|
+
/* NULL buffer pointer, returns static empty string */
|
251
|
+
str = git_oid_to_string(NULL, sizeof(out), &in);
|
252
|
+
must_be_true(str && *str == '\0' && str != out);
|
253
|
+
|
254
|
+
/* zero buffer size, returns static empty string */
|
255
|
+
str = git_oid_to_string(out, 0, &in);
|
256
|
+
must_be_true(str && *str == '\0' && str != out);
|
257
|
+
|
258
|
+
/* NULL oid pointer, returns static empty string */
|
259
|
+
str = git_oid_to_string(out, sizeof(out), NULL);
|
260
|
+
must_be_true(str && *str == '\0' && str != out);
|
261
|
+
|
262
|
+
/* n == 1, returns out as an empty string */
|
263
|
+
str = git_oid_to_string(out, 1, &in);
|
264
|
+
must_be_true(str && *str == '\0' && str == out);
|
265
|
+
|
266
|
+
for (i = 1; i < GIT_OID_HEXSZ; i++) {
|
267
|
+
out[i+1] = 'Z';
|
268
|
+
str = git_oid_to_string(out, i+1, &in);
|
269
|
+
/* returns out containing c-string */
|
270
|
+
must_be_true(str && str == out);
|
271
|
+
/* must be '\0' terminated */
|
272
|
+
must_be_true(*(str+i) == '\0');
|
273
|
+
/* must not touch bytes past end of string */
|
274
|
+
must_be_true(*(str+(i+1)) == 'Z');
|
275
|
+
/* i == n-1 charaters of string */
|
276
|
+
must_pass(strncmp(exp, out, i));
|
277
|
+
}
|
278
|
+
|
279
|
+
/* returns out as hex formatted c-string */
|
280
|
+
str = git_oid_to_string(out, sizeof(out), &in);
|
281
|
+
must_be_true(str && str == out && *(str+GIT_OID_HEXSZ) == '\0');
|
282
|
+
must_be_true(strcmp(exp, out) == 0);
|
283
|
+
END_TEST
|
284
|
+
|
285
|
+
BEGIN_TEST(oid15, "convert raw oid to string (big)")
|
286
|
+
const char *exp = "16a0123456789abcdef4b775213c23a8bd74f5e0";
|
287
|
+
git_oid in;
|
288
|
+
char big[GIT_OID_HEXSZ + 1 + 3]; /* note + 4 => big buffer */
|
289
|
+
char *str;
|
290
|
+
|
291
|
+
must_pass(git_oid_fromstr(&in, exp));
|
292
|
+
|
293
|
+
/* place some tail material */
|
294
|
+
big[GIT_OID_HEXSZ+0] = 'W'; /* should be '\0' afterwards */
|
295
|
+
big[GIT_OID_HEXSZ+1] = 'X'; /* should remain untouched */
|
296
|
+
big[GIT_OID_HEXSZ+2] = 'Y'; /* ditto */
|
297
|
+
big[GIT_OID_HEXSZ+3] = 'Z'; /* ditto */
|
298
|
+
|
299
|
+
/* returns big as hex formatted c-string */
|
300
|
+
str = git_oid_to_string(big, sizeof(big), &in);
|
301
|
+
must_be_true(str && str == big && *(str+GIT_OID_HEXSZ) == '\0');
|
302
|
+
must_be_true(strcmp(exp, big) == 0);
|
303
|
+
|
304
|
+
/* check tail material is untouched */
|
305
|
+
must_be_true(str && str == big && *(str+GIT_OID_HEXSZ+1) == 'X');
|
306
|
+
must_be_true(str && str == big && *(str+GIT_OID_HEXSZ+2) == 'Y');
|
307
|
+
must_be_true(str && str == big && *(str+GIT_OID_HEXSZ+3) == 'Z');
|
308
|
+
END_TEST
|
309
|
+
|
310
|
+
|
311
|
+
BEGIN_TEST(oid16, "make sure the OID shortener doesn't choke on duplicate sha1s")
|
312
|
+
|
313
|
+
git_oid_shorten *os;
|
314
|
+
int min_len;
|
315
|
+
|
316
|
+
os = git_oid_shorten_new(0);
|
317
|
+
must_be_true(os != NULL);
|
318
|
+
|
319
|
+
git_oid_shorten_add(os, "22596363b3de40b06f981fb85d82312e8c0ed511");
|
320
|
+
git_oid_shorten_add(os, "ce08fe4884650f067bd5703b6a59a8b3b3c99a09");
|
321
|
+
git_oid_shorten_add(os, "16a0123456789abcdef4b775213c23a8bd74f5e0");
|
322
|
+
min_len = git_oid_shorten_add(os, "ce08fe4884650f067bd5703b6a59a8b3b3c99a09");
|
323
|
+
|
324
|
+
must_be_true(min_len == GIT_OID_HEXSZ + 1);
|
325
|
+
|
326
|
+
git_oid_shorten_free(os);
|
327
|
+
END_TEST
|
328
|
+
|
329
|
+
BEGIN_TEST(oid17, "stress test for the git_oid_shorten object")
|
330
|
+
|
331
|
+
#define MAX_OIDS 1000
|
332
|
+
|
333
|
+
git_oid_shorten *os;
|
334
|
+
char *oids[MAX_OIDS];
|
335
|
+
char number_buffer[16];
|
336
|
+
git_oid oid;
|
337
|
+
size_t i, j;
|
338
|
+
|
339
|
+
int min_len = 0, found_collision;
|
340
|
+
|
341
|
+
os = git_oid_shorten_new(0);
|
342
|
+
must_be_true(os != NULL);
|
343
|
+
|
344
|
+
/*
|
345
|
+
* Insert in the shortener 1000 unique SHA1 ids
|
346
|
+
*/
|
347
|
+
for (i = 0; i < MAX_OIDS; ++i) {
|
348
|
+
char *oid_text;
|
349
|
+
|
350
|
+
sprintf(number_buffer, "%u", (unsigned int)i);
|
351
|
+
git_hash_buf(&oid, number_buffer, strlen(number_buffer));
|
352
|
+
|
353
|
+
oid_text = git__malloc(GIT_OID_HEXSZ + 1);
|
354
|
+
git_oid_fmt(oid_text, &oid);
|
355
|
+
oid_text[GIT_OID_HEXSZ] = 0;
|
356
|
+
|
357
|
+
min_len = git_oid_shorten_add(os, oid_text);
|
358
|
+
must_be_true(min_len >= 0);
|
359
|
+
|
360
|
+
oids[i] = oid_text;
|
361
|
+
}
|
362
|
+
|
363
|
+
/*
|
364
|
+
* Compare the first `min_char - 1` characters of each
|
365
|
+
* SHA1 OID. If the minimizer worked, we should find at
|
366
|
+
* least one collision
|
367
|
+
*/
|
368
|
+
found_collision = 0;
|
369
|
+
for (i = 0; i < MAX_OIDS; ++i) {
|
370
|
+
for (j = 0; j < MAX_OIDS; ++j) {
|
371
|
+
if (i != j && memcmp(oids[i], oids[j], min_len - 1) == 0)
|
372
|
+
found_collision = 1;
|
373
|
+
}
|
374
|
+
}
|
375
|
+
must_be_true(found_collision == 1);
|
376
|
+
|
377
|
+
/*
|
378
|
+
* Compare the first `min_char` characters of each
|
379
|
+
* SHA1 OID. If the minimizer worked, every single preffix
|
380
|
+
* should be unique.
|
381
|
+
*/
|
382
|
+
found_collision = 0;
|
383
|
+
for (i = 0; i < MAX_OIDS; ++i) {
|
384
|
+
for (j = 0; j < MAX_OIDS; ++j) {
|
385
|
+
if (i != j && memcmp(oids[i], oids[j], min_len) == 0)
|
386
|
+
found_collision = 1;
|
387
|
+
}
|
388
|
+
}
|
389
|
+
must_be_true(found_collision == 0);
|
390
|
+
|
391
|
+
/* cleanup */
|
392
|
+
for (i = 0; i < MAX_OIDS; ++i)
|
393
|
+
git__free(oids[i]);
|
394
|
+
|
395
|
+
git_oid_shorten_free(os);
|
396
|
+
|
397
|
+
#undef MAX_OIDS
|
398
|
+
END_TEST
|
399
|
+
|
400
|
+
static char *hello_id = "22596363b3de40b06f981fb85d82312e8c0ed511";
|
401
|
+
static char *hello_text = "hello world\n";
|
402
|
+
|
403
|
+
static char *bye_id = "ce08fe4884650f067bd5703b6a59a8b3b3c99a09";
|
404
|
+
static char *bye_text = "bye world\n";
|
405
|
+
|
406
|
+
BEGIN_TEST(hash0, "normal hash by blocks")
|
407
|
+
git_hash_ctx *ctx;
|
408
|
+
git_oid id1, id2;
|
409
|
+
|
410
|
+
must_be_true((ctx = git_hash_new_ctx()) != NULL);
|
411
|
+
|
412
|
+
/* should already be init'd */
|
413
|
+
git_hash_update(ctx, hello_text, strlen(hello_text));
|
414
|
+
git_hash_final(&id2, ctx);
|
415
|
+
must_pass(git_oid_fromstr(&id1, hello_id));
|
416
|
+
must_be_true(git_oid_cmp(&id1, &id2) == 0);
|
417
|
+
|
418
|
+
/* reinit should permit reuse */
|
419
|
+
git_hash_init(ctx);
|
420
|
+
git_hash_update(ctx, bye_text, strlen(bye_text));
|
421
|
+
git_hash_final(&id2, ctx);
|
422
|
+
must_pass(git_oid_fromstr(&id1, bye_id));
|
423
|
+
must_be_true(git_oid_cmp(&id1, &id2) == 0);
|
424
|
+
|
425
|
+
git_hash_free_ctx(ctx);
|
426
|
+
END_TEST
|
427
|
+
|
428
|
+
BEGIN_TEST(hash1, "hash whole buffer in a single call")
|
429
|
+
git_oid id1, id2;
|
430
|
+
|
431
|
+
must_pass(git_oid_fromstr(&id1, hello_id));
|
432
|
+
|
433
|
+
git_hash_buf(&id2, hello_text, strlen(hello_text));
|
434
|
+
|
435
|
+
must_be_true(git_oid_cmp(&id1, &id2) == 0);
|
436
|
+
END_TEST
|
437
|
+
|
438
|
+
BEGIN_TEST(hash2, "hash a vector")
|
439
|
+
git_oid id1, id2;
|
440
|
+
git_buf_vec vec[2];
|
441
|
+
|
442
|
+
must_pass(git_oid_fromstr(&id1, hello_id));
|
443
|
+
|
444
|
+
vec[0].data = hello_text;
|
445
|
+
vec[0].len = 4;
|
446
|
+
vec[1].data = hello_text+4;
|
447
|
+
vec[1].len = strlen(hello_text)-4;
|
448
|
+
|
449
|
+
git_hash_vec(&id2, vec, 2);
|
450
|
+
|
451
|
+
must_be_true(git_oid_cmp(&id1, &id2) == 0);
|
452
|
+
END_TEST
|
453
|
+
|
454
|
+
BEGIN_TEST(objtype0, "convert type to string")
|
455
|
+
must_be_true(!strcmp(git_object_type2string(GIT_OBJ_BAD), ""));
|
456
|
+
must_be_true(!strcmp(git_object_type2string(GIT_OBJ__EXT1), ""));
|
457
|
+
must_be_true(!strcmp(git_object_type2string(GIT_OBJ_COMMIT), "commit"));
|
458
|
+
must_be_true(!strcmp(git_object_type2string(GIT_OBJ_TREE), "tree"));
|
459
|
+
must_be_true(!strcmp(git_object_type2string(GIT_OBJ_BLOB), "blob"));
|
460
|
+
must_be_true(!strcmp(git_object_type2string(GIT_OBJ_TAG), "tag"));
|
461
|
+
must_be_true(!strcmp(git_object_type2string(GIT_OBJ__EXT2), ""));
|
462
|
+
must_be_true(!strcmp(git_object_type2string(GIT_OBJ_OFS_DELTA), "OFS_DELTA"));
|
463
|
+
must_be_true(!strcmp(git_object_type2string(GIT_OBJ_REF_DELTA), "REF_DELTA"));
|
464
|
+
|
465
|
+
must_be_true(!strcmp(git_object_type2string(-2), ""));
|
466
|
+
must_be_true(!strcmp(git_object_type2string(8), ""));
|
467
|
+
must_be_true(!strcmp(git_object_type2string(1234), ""));
|
468
|
+
END_TEST
|
469
|
+
|
470
|
+
BEGIN_TEST(objtype1, "convert string to type")
|
471
|
+
must_be_true(git_object_string2type(NULL) == GIT_OBJ_BAD);
|
472
|
+
must_be_true(git_object_string2type("") == GIT_OBJ_BAD);
|
473
|
+
must_be_true(git_object_string2type("commit") == GIT_OBJ_COMMIT);
|
474
|
+
must_be_true(git_object_string2type("tree") == GIT_OBJ_TREE);
|
475
|
+
must_be_true(git_object_string2type("blob") == GIT_OBJ_BLOB);
|
476
|
+
must_be_true(git_object_string2type("tag") == GIT_OBJ_TAG);
|
477
|
+
must_be_true(git_object_string2type("OFS_DELTA") == GIT_OBJ_OFS_DELTA);
|
478
|
+
must_be_true(git_object_string2type("REF_DELTA") == GIT_OBJ_REF_DELTA);
|
479
|
+
|
480
|
+
must_be_true(git_object_string2type("CoMmIt") == GIT_OBJ_BAD);
|
481
|
+
must_be_true(git_object_string2type("hohoho") == GIT_OBJ_BAD);
|
482
|
+
END_TEST
|
483
|
+
|
484
|
+
BEGIN_TEST(objtype2, "check if an object type is loose")
|
485
|
+
must_be_true(git_object_typeisloose(GIT_OBJ_BAD) == 0);
|
486
|
+
must_be_true(git_object_typeisloose(GIT_OBJ__EXT1) == 0);
|
487
|
+
must_be_true(git_object_typeisloose(GIT_OBJ_COMMIT) == 1);
|
488
|
+
must_be_true(git_object_typeisloose(GIT_OBJ_TREE) == 1);
|
489
|
+
must_be_true(git_object_typeisloose(GIT_OBJ_BLOB) == 1);
|
490
|
+
must_be_true(git_object_typeisloose(GIT_OBJ_TAG) == 1);
|
491
|
+
must_be_true(git_object_typeisloose(GIT_OBJ__EXT2) == 0);
|
492
|
+
must_be_true(git_object_typeisloose(GIT_OBJ_OFS_DELTA) == 0);
|
493
|
+
must_be_true(git_object_typeisloose(GIT_OBJ_REF_DELTA) == 0);
|
494
|
+
|
495
|
+
must_be_true(git_object_typeisloose(-2) == 0);
|
496
|
+
must_be_true(git_object_typeisloose(8) == 0);
|
497
|
+
must_be_true(git_object_typeisloose(1234) == 0);
|
498
|
+
END_TEST
|
499
|
+
|
500
|
+
BEGIN_TEST(objhash0, "hash junk data")
|
501
|
+
git_oid id, id_zero;
|
502
|
+
|
503
|
+
must_pass(git_oid_fromstr(&id_zero, zero_id));
|
504
|
+
|
505
|
+
/* invalid types: */
|
506
|
+
junk_obj.data = some_data;
|
507
|
+
must_fail(hash_object(&id, &junk_obj));
|
508
|
+
|
509
|
+
junk_obj.type = GIT_OBJ__EXT1;
|
510
|
+
must_fail(hash_object(&id, &junk_obj));
|
511
|
+
|
512
|
+
junk_obj.type = GIT_OBJ__EXT2;
|
513
|
+
must_fail(hash_object(&id, &junk_obj));
|
514
|
+
|
515
|
+
junk_obj.type = GIT_OBJ_OFS_DELTA;
|
516
|
+
must_fail(hash_object(&id, &junk_obj));
|
517
|
+
|
518
|
+
junk_obj.type = GIT_OBJ_REF_DELTA;
|
519
|
+
must_fail(hash_object(&id, &junk_obj));
|
520
|
+
|
521
|
+
/* data can be NULL only if len is zero: */
|
522
|
+
junk_obj.type = GIT_OBJ_BLOB;
|
523
|
+
junk_obj.data = NULL;
|
524
|
+
must_pass(hash_object(&id, &junk_obj));
|
525
|
+
must_be_true(git_oid_cmp(&id, &id_zero) == 0);
|
526
|
+
|
527
|
+
junk_obj.len = 1;
|
528
|
+
must_fail(hash_object(&id, &junk_obj));
|
529
|
+
END_TEST
|
530
|
+
|
531
|
+
BEGIN_TEST(objhash1, "hash a commit object")
|
532
|
+
git_oid id1, id2;
|
533
|
+
|
534
|
+
must_pass(git_oid_fromstr(&id1, commit_id));
|
535
|
+
|
536
|
+
must_pass(hash_object(&id2, &commit_obj));
|
537
|
+
|
538
|
+
must_be_true(git_oid_cmp(&id1, &id2) == 0);
|
539
|
+
END_TEST
|
540
|
+
|
541
|
+
BEGIN_TEST(objhash2, "hash a tree object")
|
542
|
+
git_oid id1, id2;
|
543
|
+
|
544
|
+
must_pass(git_oid_fromstr(&id1, tree_id));
|
545
|
+
|
546
|
+
must_pass(hash_object(&id2, &tree_obj));
|
547
|
+
|
548
|
+
must_be_true(git_oid_cmp(&id1, &id2) == 0);
|
549
|
+
END_TEST
|
550
|
+
|
551
|
+
BEGIN_TEST(objhash3, "hash a tag object")
|
552
|
+
git_oid id1, id2;
|
553
|
+
|
554
|
+
must_pass(git_oid_fromstr(&id1, tag_id));
|
555
|
+
|
556
|
+
must_pass(hash_object(&id2, &tag_obj));
|
557
|
+
|
558
|
+
must_be_true(git_oid_cmp(&id1, &id2) == 0);
|
559
|
+
END_TEST
|
560
|
+
|
561
|
+
BEGIN_TEST(objhash4, "hash a zero-length object")
|
562
|
+
git_oid id1, id2;
|
563
|
+
|
564
|
+
must_pass(git_oid_fromstr(&id1, zero_id));
|
565
|
+
|
566
|
+
must_pass(hash_object(&id2, &zero_obj));
|
567
|
+
|
568
|
+
must_be_true(git_oid_cmp(&id1, &id2) == 0);
|
569
|
+
END_TEST
|
570
|
+
|
571
|
+
BEGIN_TEST(objhash5, "hash an one-byte long object")
|
572
|
+
git_oid id1, id2;
|
573
|
+
|
574
|
+
must_pass(git_oid_fromstr(&id1, one_id));
|
575
|
+
|
576
|
+
must_pass(hash_object(&id2, &one_obj));
|
577
|
+
|
578
|
+
must_be_true(git_oid_cmp(&id1, &id2) == 0);
|
579
|
+
END_TEST
|
580
|
+
|
581
|
+
BEGIN_TEST(objhash6, "hash a two-byte long object")
|
582
|
+
git_oid id1, id2;
|
583
|
+
|
584
|
+
must_pass(git_oid_fromstr(&id1, two_id));
|
585
|
+
|
586
|
+
must_pass(hash_object(&id2, &two_obj));
|
587
|
+
|
588
|
+
must_be_true(git_oid_cmp(&id1, &id2) == 0);
|
589
|
+
END_TEST
|
590
|
+
|
591
|
+
BEGIN_TEST(objhash7, "hash an object several bytes long")
|
592
|
+
git_oid id1, id2;
|
593
|
+
|
594
|
+
must_pass(git_oid_fromstr(&id1, some_id));
|
595
|
+
|
596
|
+
must_pass(hash_object(&id2, &some_obj));
|
597
|
+
|
598
|
+
must_be_true(git_oid_cmp(&id1, &id2) == 0);
|
599
|
+
END_TEST
|
600
|
+
|
601
|
+
BEGIN_SUITE(rawobjects)
|
602
|
+
ADD_TEST(oid0);
|
603
|
+
ADD_TEST(oid1);
|
604
|
+
ADD_TEST(oid2);
|
605
|
+
ADD_TEST(oid3);
|
606
|
+
ADD_TEST(oid4);
|
607
|
+
ADD_TEST(oid5);
|
608
|
+
ADD_TEST(oid6);
|
609
|
+
ADD_TEST(oid7);
|
610
|
+
ADD_TEST(oid8);
|
611
|
+
ADD_TEST(oid9);
|
612
|
+
ADD_TEST(oid10);
|
613
|
+
ADD_TEST(oid11);
|
614
|
+
ADD_TEST(oid12);
|
615
|
+
ADD_TEST(oid13);
|
616
|
+
ADD_TEST(oid14);
|
617
|
+
ADD_TEST(oid15);
|
618
|
+
ADD_TEST(oid16);
|
619
|
+
ADD_TEST(oid17);
|
620
|
+
|
621
|
+
ADD_TEST(hash0);
|
622
|
+
ADD_TEST(hash1);
|
623
|
+
ADD_TEST(hash2);
|
624
|
+
|
625
|
+
ADD_TEST(objtype0);
|
626
|
+
ADD_TEST(objtype1);
|
627
|
+
ADD_TEST(objtype2);
|
628
|
+
|
629
|
+
ADD_TEST(objhash0);
|
630
|
+
ADD_TEST(objhash1);
|
631
|
+
ADD_TEST(objhash2);
|
632
|
+
ADD_TEST(objhash3);
|
633
|
+
ADD_TEST(objhash4);
|
634
|
+
ADD_TEST(objhash5);
|
635
|
+
ADD_TEST(objhash6);
|
636
|
+
ADD_TEST(objhash7);
|
637
|
+
END_SUITE
|
638
|
+
|