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,25 @@
|
|
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_posix__w32_h__
|
8
|
+
#define INCLUDE_posix__w32_h__
|
9
|
+
|
10
|
+
#include <fnmatch.h>
|
11
|
+
|
12
|
+
#define p_lstat(p,b) lstat(p,b)
|
13
|
+
#define p_readlink(a, b, c) readlink(a, b, c)
|
14
|
+
#define p_link(o,n) link(o, n)
|
15
|
+
#define p_unlink(p) unlink(p)
|
16
|
+
#define p_mkdir(p,m) mkdir(p, m)
|
17
|
+
#define p_fsync(fd) fsync(fd)
|
18
|
+
#define p_realpath(p, po) realpath(p, po)
|
19
|
+
#define p_fnmatch(p, s, f) fnmatch(p, s, f)
|
20
|
+
#define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a)
|
21
|
+
#define p_snprintf(b, c, f, ...) snprintf(b, c, f, __VA_ARGS__)
|
22
|
+
#define p_mkstemp(p) mkstemp(p)
|
23
|
+
#define p_setenv(n,v,o) setenv(n,v,o)
|
24
|
+
|
25
|
+
#endif
|
@@ -0,0 +1,381 @@
|
|
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 <git2.h>
|
8
|
+
#include "common.h"
|
9
|
+
#include <stdarg.h>
|
10
|
+
#include <stdio.h>
|
11
|
+
#include <ctype.h>
|
12
|
+
#include "posix.h"
|
13
|
+
|
14
|
+
#ifdef _MSC_VER
|
15
|
+
# include <Shlwapi.h>
|
16
|
+
#endif
|
17
|
+
|
18
|
+
void git_libgit2_version(int *major, int *minor, int *rev)
|
19
|
+
{
|
20
|
+
*major = LIBGIT2_VER_MAJOR;
|
21
|
+
*minor = LIBGIT2_VER_MINOR;
|
22
|
+
*rev = LIBGIT2_VER_REVISION;
|
23
|
+
}
|
24
|
+
|
25
|
+
void git_strarray_free(git_strarray *array)
|
26
|
+
{
|
27
|
+
size_t i;
|
28
|
+
for (i = 0; i < array->count; ++i)
|
29
|
+
git__free(array->strings[i]);
|
30
|
+
|
31
|
+
git__free(array->strings);
|
32
|
+
}
|
33
|
+
|
34
|
+
int git__fnmatch(const char *pattern, const char *name, int flags)
|
35
|
+
{
|
36
|
+
int ret;
|
37
|
+
|
38
|
+
ret = p_fnmatch(pattern, name, flags);
|
39
|
+
switch (ret) {
|
40
|
+
case 0:
|
41
|
+
return GIT_SUCCESS;
|
42
|
+
case FNM_NOMATCH:
|
43
|
+
return GIT_ENOMATCH;
|
44
|
+
default:
|
45
|
+
return git__throw(GIT_EOSERR, "Error trying to match path");
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
int git__strtol64(int64_t *result, const char *nptr, const char **endptr, int base)
|
50
|
+
{
|
51
|
+
const char *p;
|
52
|
+
int64_t n, nn;
|
53
|
+
int c, ovfl, v, neg, ndig;
|
54
|
+
|
55
|
+
p = nptr;
|
56
|
+
neg = 0;
|
57
|
+
n = 0;
|
58
|
+
ndig = 0;
|
59
|
+
ovfl = 0;
|
60
|
+
|
61
|
+
/*
|
62
|
+
* White space
|
63
|
+
*/
|
64
|
+
while (isspace(*p))
|
65
|
+
p++;
|
66
|
+
|
67
|
+
/*
|
68
|
+
* Sign
|
69
|
+
*/
|
70
|
+
if (*p == '-' || *p == '+')
|
71
|
+
if (*p++ == '-')
|
72
|
+
neg = 1;
|
73
|
+
|
74
|
+
/*
|
75
|
+
* Base
|
76
|
+
*/
|
77
|
+
if (base == 0) {
|
78
|
+
if (*p != '0')
|
79
|
+
base = 10;
|
80
|
+
else {
|
81
|
+
base = 8;
|
82
|
+
if (p[1] == 'x' || p[1] == 'X') {
|
83
|
+
p += 2;
|
84
|
+
base = 16;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
} else if (base == 16 && *p == '0') {
|
88
|
+
if (p[1] == 'x' || p[1] == 'X')
|
89
|
+
p += 2;
|
90
|
+
} else if (base < 0 || 36 < base)
|
91
|
+
goto Return;
|
92
|
+
|
93
|
+
/*
|
94
|
+
* Non-empty sequence of digits
|
95
|
+
*/
|
96
|
+
for (;; p++,ndig++) {
|
97
|
+
c = *p;
|
98
|
+
v = base;
|
99
|
+
if ('0'<=c && c<='9')
|
100
|
+
v = c - '0';
|
101
|
+
else if ('a'<=c && c<='z')
|
102
|
+
v = c - 'a' + 10;
|
103
|
+
else if ('A'<=c && c<='Z')
|
104
|
+
v = c - 'A' + 10;
|
105
|
+
if (v >= base)
|
106
|
+
break;
|
107
|
+
nn = n*base + v;
|
108
|
+
if (nn < n)
|
109
|
+
ovfl = 1;
|
110
|
+
n = nn;
|
111
|
+
}
|
112
|
+
|
113
|
+
Return:
|
114
|
+
if (ndig == 0)
|
115
|
+
return git__throw(GIT_ENOTNUM, "Failed to convert string to long. Not a number");
|
116
|
+
|
117
|
+
if (endptr)
|
118
|
+
*endptr = p;
|
119
|
+
|
120
|
+
if (ovfl)
|
121
|
+
return git__throw(GIT_EOVERFLOW, "Failed to convert string to long. Overflow error");
|
122
|
+
|
123
|
+
*result = neg ? -n : n;
|
124
|
+
return GIT_SUCCESS;
|
125
|
+
}
|
126
|
+
|
127
|
+
int git__strtol32(int32_t *result, const char *nptr, const char **endptr, int base)
|
128
|
+
{
|
129
|
+
int error = GIT_SUCCESS;
|
130
|
+
int32_t tmp_int;
|
131
|
+
int64_t tmp_long;
|
132
|
+
|
133
|
+
if ((error = git__strtol64(&tmp_long, nptr, endptr, base)) < GIT_SUCCESS)
|
134
|
+
return error;
|
135
|
+
|
136
|
+
tmp_int = tmp_long & 0xFFFFFFFF;
|
137
|
+
if (tmp_int != tmp_long)
|
138
|
+
return git__throw(GIT_EOVERFLOW, "Failed to convert. '%s' is too large", nptr);
|
139
|
+
|
140
|
+
*result = tmp_int;
|
141
|
+
|
142
|
+
return error;
|
143
|
+
}
|
144
|
+
|
145
|
+
void git__strntolower(char *str, size_t len)
|
146
|
+
{
|
147
|
+
size_t i;
|
148
|
+
|
149
|
+
for (i = 0; i < len; ++i) {
|
150
|
+
str[i] = (char) tolower(str[i]);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
void git__strtolower(char *str)
|
155
|
+
{
|
156
|
+
git__strntolower(str, strlen(str));
|
157
|
+
}
|
158
|
+
|
159
|
+
int git__prefixcmp(const char *str, const char *prefix)
|
160
|
+
{
|
161
|
+
for (;;) {
|
162
|
+
char p = *(prefix++), s;
|
163
|
+
if (!p)
|
164
|
+
return 0;
|
165
|
+
if ((s = *(str++)) != p)
|
166
|
+
return s - p;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
int git__suffixcmp(const char *str, const char *suffix)
|
171
|
+
{
|
172
|
+
size_t a = strlen(str);
|
173
|
+
size_t b = strlen(suffix);
|
174
|
+
if (a < b)
|
175
|
+
return -1;
|
176
|
+
return strcmp(str + (a - b), suffix);
|
177
|
+
}
|
178
|
+
|
179
|
+
char *git__strtok(char **end, const char *sep)
|
180
|
+
{
|
181
|
+
char *ptr = *end;
|
182
|
+
|
183
|
+
while (*ptr && strchr(sep, *ptr))
|
184
|
+
++ptr;
|
185
|
+
|
186
|
+
if (*ptr) {
|
187
|
+
char *start = ptr;
|
188
|
+
*end = start + 1;
|
189
|
+
|
190
|
+
while (**end && !strchr(sep, **end))
|
191
|
+
++*end;
|
192
|
+
|
193
|
+
if (**end) {
|
194
|
+
**end = '\0';
|
195
|
+
++*end;
|
196
|
+
}
|
197
|
+
|
198
|
+
return start;
|
199
|
+
}
|
200
|
+
|
201
|
+
return NULL;
|
202
|
+
}
|
203
|
+
|
204
|
+
void git__hexdump(const char *buffer, size_t len)
|
205
|
+
{
|
206
|
+
static const size_t LINE_WIDTH = 16;
|
207
|
+
|
208
|
+
size_t line_count, last_line, i, j;
|
209
|
+
const char *line;
|
210
|
+
|
211
|
+
line_count = (len / LINE_WIDTH);
|
212
|
+
last_line = (len % LINE_WIDTH);
|
213
|
+
|
214
|
+
for (i = 0; i < line_count; ++i) {
|
215
|
+
line = buffer + (i * LINE_WIDTH);
|
216
|
+
for (j = 0; j < LINE_WIDTH; ++j, ++line)
|
217
|
+
printf("%02X ", (unsigned char)*line & 0xFF);
|
218
|
+
|
219
|
+
printf("| ");
|
220
|
+
|
221
|
+
line = buffer + (i * LINE_WIDTH);
|
222
|
+
for (j = 0; j < LINE_WIDTH; ++j, ++line)
|
223
|
+
printf("%c", (*line >= 32 && *line <= 126) ? *line : '.');
|
224
|
+
|
225
|
+
printf("\n");
|
226
|
+
}
|
227
|
+
|
228
|
+
if (last_line > 0) {
|
229
|
+
|
230
|
+
line = buffer + (line_count * LINE_WIDTH);
|
231
|
+
for (j = 0; j < last_line; ++j, ++line)
|
232
|
+
printf("%02X ", (unsigned char)*line & 0xFF);
|
233
|
+
|
234
|
+
for (j = 0; j < (LINE_WIDTH - last_line); ++j)
|
235
|
+
printf(" ");
|
236
|
+
|
237
|
+
printf("| ");
|
238
|
+
|
239
|
+
line = buffer + (line_count * LINE_WIDTH);
|
240
|
+
for (j = 0; j < last_line; ++j, ++line)
|
241
|
+
printf("%c", (*line >= 32 && *line <= 126) ? *line : '.');
|
242
|
+
|
243
|
+
printf("\n");
|
244
|
+
}
|
245
|
+
|
246
|
+
printf("\n");
|
247
|
+
}
|
248
|
+
|
249
|
+
#ifdef GIT_LEGACY_HASH
|
250
|
+
uint32_t git__hash(const void *key, int len, unsigned int seed)
|
251
|
+
{
|
252
|
+
const uint32_t m = 0x5bd1e995;
|
253
|
+
const int r = 24;
|
254
|
+
uint32_t h = seed ^ len;
|
255
|
+
|
256
|
+
const unsigned char *data = (const unsigned char *)key;
|
257
|
+
|
258
|
+
while(len >= 4) {
|
259
|
+
uint32_t k = *(uint32_t *)data;
|
260
|
+
|
261
|
+
k *= m;
|
262
|
+
k ^= k >> r;
|
263
|
+
k *= m;
|
264
|
+
|
265
|
+
h *= m;
|
266
|
+
h ^= k;
|
267
|
+
|
268
|
+
data += 4;
|
269
|
+
len -= 4;
|
270
|
+
}
|
271
|
+
|
272
|
+
switch(len) {
|
273
|
+
case 3: h ^= data[2] << 16;
|
274
|
+
case 2: h ^= data[1] << 8;
|
275
|
+
case 1: h ^= data[0];
|
276
|
+
h *= m;
|
277
|
+
};
|
278
|
+
|
279
|
+
h ^= h >> 13;
|
280
|
+
h *= m;
|
281
|
+
h ^= h >> 15;
|
282
|
+
|
283
|
+
return h;
|
284
|
+
}
|
285
|
+
#else
|
286
|
+
/*
|
287
|
+
Cross-platform version of Murmurhash3
|
288
|
+
http://code.google.com/p/smhasher/wiki/MurmurHash3
|
289
|
+
by Austin Appleby (aappleby@gmail.com)
|
290
|
+
|
291
|
+
This code is on the public domain.
|
292
|
+
*/
|
293
|
+
uint32_t git__hash(const void *key, int len, uint32_t seed)
|
294
|
+
{
|
295
|
+
|
296
|
+
#define MURMUR_BLOCK() {\
|
297
|
+
k1 *= c1; \
|
298
|
+
k1 = git__rotl(k1,11);\
|
299
|
+
k1 *= c2;\
|
300
|
+
h1 ^= k1;\
|
301
|
+
h1 = h1*3 + 0x52dce729;\
|
302
|
+
c1 = c1*5 + 0x7b7d159c;\
|
303
|
+
c2 = c2*5 + 0x6bce6396;\
|
304
|
+
}
|
305
|
+
|
306
|
+
const uint8_t *data = (const uint8_t*)key;
|
307
|
+
const int nblocks = len / 4;
|
308
|
+
|
309
|
+
const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4);
|
310
|
+
const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
|
311
|
+
|
312
|
+
uint32_t h1 = 0x971e137b ^ seed;
|
313
|
+
uint32_t k1;
|
314
|
+
|
315
|
+
uint32_t c1 = 0x95543787;
|
316
|
+
uint32_t c2 = 0x2ad7eb25;
|
317
|
+
|
318
|
+
int i;
|
319
|
+
|
320
|
+
for (i = -nblocks; i; i++) {
|
321
|
+
k1 = blocks[i];
|
322
|
+
MURMUR_BLOCK();
|
323
|
+
}
|
324
|
+
|
325
|
+
k1 = 0;
|
326
|
+
|
327
|
+
switch(len & 3) {
|
328
|
+
case 3: k1 ^= tail[2] << 16;
|
329
|
+
case 2: k1 ^= tail[1] << 8;
|
330
|
+
case 1: k1 ^= tail[0];
|
331
|
+
MURMUR_BLOCK();
|
332
|
+
}
|
333
|
+
|
334
|
+
h1 ^= len;
|
335
|
+
h1 ^= h1 >> 16;
|
336
|
+
h1 *= 0x85ebca6b;
|
337
|
+
h1 ^= h1 >> 13;
|
338
|
+
h1 *= 0xc2b2ae35;
|
339
|
+
h1 ^= h1 >> 16;
|
340
|
+
|
341
|
+
return h1;
|
342
|
+
}
|
343
|
+
#endif
|
344
|
+
|
345
|
+
/**
|
346
|
+
* A modified `bsearch` from the BSD glibc.
|
347
|
+
*
|
348
|
+
* Copyright (c) 1990 Regents of the University of California.
|
349
|
+
* All rights reserved.
|
350
|
+
*/
|
351
|
+
void **git__bsearch(const void *key, void **base, size_t nmemb, int (*compar)(const void *, const void *))
|
352
|
+
{
|
353
|
+
int lim, cmp;
|
354
|
+
void **p;
|
355
|
+
|
356
|
+
for (lim = nmemb; lim != 0; lim >>= 1) {
|
357
|
+
p = base + (lim >> 1);
|
358
|
+
cmp = (*compar)(key, *p);
|
359
|
+
if (cmp > 0) { /* key > p: move right */
|
360
|
+
base = p + 1;
|
361
|
+
lim--;
|
362
|
+
} else if (cmp == 0) {
|
363
|
+
return (void **)p;
|
364
|
+
} /* else move left */
|
365
|
+
}
|
366
|
+
return NULL;
|
367
|
+
}
|
368
|
+
|
369
|
+
/**
|
370
|
+
* A strcmp wrapper
|
371
|
+
*
|
372
|
+
* We don't want direct pointers to the CRT on Windows, we may
|
373
|
+
* get stdcall conflicts.
|
374
|
+
*/
|
375
|
+
int git__strcmp_cb(const void *a, const void *b)
|
376
|
+
{
|
377
|
+
const char *stra = (const char *)a;
|
378
|
+
const char *strb = (const char *)b;
|
379
|
+
|
380
|
+
return strcmp(stra, strb);
|
381
|
+
}
|
@@ -0,0 +1,137 @@
|
|
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_util_h__
|
8
|
+
#define INCLUDE_util_h__
|
9
|
+
|
10
|
+
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
11
|
+
#define bitsizeof(x) (CHAR_BIT * sizeof(x))
|
12
|
+
#define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits))))
|
13
|
+
#ifndef min
|
14
|
+
# define min(a,b) ((a) < (b) ? (a) : (b))
|
15
|
+
#endif
|
16
|
+
|
17
|
+
/*
|
18
|
+
* Custom memory allocation wrappers
|
19
|
+
* that set error code and error message
|
20
|
+
* on allocation failure
|
21
|
+
*/
|
22
|
+
GIT_INLINE(void *) git__malloc(size_t len)
|
23
|
+
{
|
24
|
+
void *ptr = malloc(len);
|
25
|
+
if (!ptr)
|
26
|
+
git__throw(GIT_ENOMEM, "Out of memory. Failed to allocate %d bytes.", (int)len);
|
27
|
+
return ptr;
|
28
|
+
}
|
29
|
+
|
30
|
+
GIT_INLINE(void *) git__calloc(size_t nelem, size_t elsize)
|
31
|
+
{
|
32
|
+
void *ptr = calloc(nelem, elsize);
|
33
|
+
if (!ptr)
|
34
|
+
git__throw(GIT_ENOMEM, "Out of memory. Failed to allocate %d bytes.", (int)elsize);
|
35
|
+
return ptr;
|
36
|
+
}
|
37
|
+
|
38
|
+
GIT_INLINE(char *) git__strdup(const char *str)
|
39
|
+
{
|
40
|
+
char *ptr = strdup(str);
|
41
|
+
if (!ptr)
|
42
|
+
git__throw(GIT_ENOMEM, "Out of memory. Failed to duplicate string");
|
43
|
+
return ptr;
|
44
|
+
}
|
45
|
+
|
46
|
+
GIT_INLINE(char *) git__strndup(const char *str, size_t n)
|
47
|
+
{
|
48
|
+
size_t length;
|
49
|
+
char *ptr;
|
50
|
+
|
51
|
+
length = strlen(str);
|
52
|
+
if (n < length)
|
53
|
+
length = n;
|
54
|
+
|
55
|
+
ptr = (char*)malloc(length + 1);
|
56
|
+
if (!ptr) {
|
57
|
+
git__throw(GIT_ENOMEM, "Out of memory. Failed to duplicate string");
|
58
|
+
return NULL;
|
59
|
+
}
|
60
|
+
|
61
|
+
memcpy(ptr, str, length);
|
62
|
+
ptr[length] = '\0';
|
63
|
+
|
64
|
+
return ptr;
|
65
|
+
}
|
66
|
+
|
67
|
+
GIT_INLINE(void *) git__realloc(void *ptr, size_t size)
|
68
|
+
{
|
69
|
+
void *new_ptr = realloc(ptr, size);
|
70
|
+
if (!new_ptr)
|
71
|
+
git__throw(GIT_ENOMEM, "Out of memory. Failed to allocate %d bytes.", (int)size);
|
72
|
+
return new_ptr;
|
73
|
+
}
|
74
|
+
|
75
|
+
#define git__free(ptr) free(ptr)
|
76
|
+
|
77
|
+
extern int git__prefixcmp(const char *str, const char *prefix);
|
78
|
+
extern int git__suffixcmp(const char *str, const char *suffix);
|
79
|
+
|
80
|
+
extern int git__strtol32(int32_t *n, const char *buff, const char **end_buf, int base);
|
81
|
+
extern int git__strtol64(int64_t *n, const char *buff, const char **end_buf, int base);
|
82
|
+
|
83
|
+
extern void git__hexdump(const char *buffer, size_t n);
|
84
|
+
extern uint32_t git__hash(const void *key, int len, uint32_t seed);
|
85
|
+
|
86
|
+
/** @return true if p fits into the range of a size_t */
|
87
|
+
GIT_INLINE(int) git__is_sizet(git_off_t p)
|
88
|
+
{
|
89
|
+
size_t r = (size_t)p;
|
90
|
+
return p == (git_off_t)r;
|
91
|
+
}
|
92
|
+
|
93
|
+
/* 32-bit cross-platform rotl */
|
94
|
+
#ifdef _MSC_VER /* use built-in method in MSVC */
|
95
|
+
# define git__rotl(v, s) (uint32_t)_rotl(v, s)
|
96
|
+
#else /* use bitops in GCC; with o2 this gets optimized to a rotl instruction */
|
97
|
+
# define git__rotl(v, s) (uint32_t)(((uint32_t)(v) << (s)) | ((uint32_t)(v) >> (32 - (s))))
|
98
|
+
#endif
|
99
|
+
|
100
|
+
extern char *git__strtok(char **end, const char *sep);
|
101
|
+
|
102
|
+
extern void git__strntolower(char *str, size_t len);
|
103
|
+
extern void git__strtolower(char *str);
|
104
|
+
|
105
|
+
extern int git__fnmatch(const char *pattern, const char *name, int flags);
|
106
|
+
|
107
|
+
extern void git__tsort(void **dst, size_t size, int (*cmp)(const void *, const void *));
|
108
|
+
extern void **git__bsearch(const void *key, void **base, size_t nmemb,
|
109
|
+
int (*compar)(const void *, const void *));
|
110
|
+
|
111
|
+
extern int git__strcmp_cb(const void *a, const void *b);
|
112
|
+
|
113
|
+
typedef struct {
|
114
|
+
short refcount;
|
115
|
+
void *owner;
|
116
|
+
} git_refcount;
|
117
|
+
|
118
|
+
typedef void (*git_refcount_freeptr)(void *r);
|
119
|
+
|
120
|
+
#define GIT_REFCOUNT_INC(r) { \
|
121
|
+
((git_refcount *)(r))->refcount++; \
|
122
|
+
}
|
123
|
+
|
124
|
+
#define GIT_REFCOUNT_DEC(_r, do_free) { \
|
125
|
+
git_refcount *r = (git_refcount *)(_r); \
|
126
|
+
r->refcount--; \
|
127
|
+
if (r->refcount <= 0 && r->owner == NULL) { do_free(_r); } \
|
128
|
+
}
|
129
|
+
|
130
|
+
#define GIT_REFCOUNT_OWN(r, o) { \
|
131
|
+
((git_refcount *)(r))->owner = o; \
|
132
|
+
}
|
133
|
+
|
134
|
+
#define GIT_REFCOUNT_OWNER(r) (((git_refcount *)(r))->owner)
|
135
|
+
|
136
|
+
|
137
|
+
#endif /* INCLUDE_util_h__ */
|