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,134 @@
|
|
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 "git2/threads.h"
|
10
|
+
#include "thread-utils.h"
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Handle the global state with TLS
|
14
|
+
*
|
15
|
+
* If libgit2 is built with GIT_THREADS enabled,
|
16
|
+
* the `git_threads_init()` function must be called
|
17
|
+
* before calling any other function of the library.
|
18
|
+
*
|
19
|
+
* This function allocates a TLS index (using pthreads
|
20
|
+
* or the native Win32 API) to store the global state
|
21
|
+
* on a per-thread basis.
|
22
|
+
*
|
23
|
+
* Any internal method that requires global state will
|
24
|
+
* then call `git__global_state()` which returns a pointer
|
25
|
+
* to the global state structure; this pointer is lazily
|
26
|
+
* allocated on each thread.
|
27
|
+
*
|
28
|
+
* Before shutting down the library, the
|
29
|
+
* `git_threads_shutdown` method must be called to free
|
30
|
+
* the previously reserved TLS index.
|
31
|
+
*
|
32
|
+
* If libgit2 is built without threading support, the
|
33
|
+
* `git__global_statestate()` call returns a pointer to a single,
|
34
|
+
* statically allocated global state. The `git_thread_`
|
35
|
+
* functions are not available in that case.
|
36
|
+
*/
|
37
|
+
|
38
|
+
#if defined(GIT_THREADS) && defined(GIT_WIN32)
|
39
|
+
|
40
|
+
static DWORD _tls_index;
|
41
|
+
static int _tls_init = 0;
|
42
|
+
|
43
|
+
void git_threads_init(void)
|
44
|
+
{
|
45
|
+
if (_tls_init)
|
46
|
+
return;
|
47
|
+
|
48
|
+
_tls_index = TlsAlloc();
|
49
|
+
_tls_init = 1;
|
50
|
+
}
|
51
|
+
|
52
|
+
void git_threads_shutdown(void)
|
53
|
+
{
|
54
|
+
TlsFree(_tls_index);
|
55
|
+
_tls_init = 0;
|
56
|
+
}
|
57
|
+
|
58
|
+
git_global_st *git__global_state(void)
|
59
|
+
{
|
60
|
+
void *ptr;
|
61
|
+
|
62
|
+
if ((ptr = TlsGetValue(_tls_index)) != NULL)
|
63
|
+
return ptr;
|
64
|
+
|
65
|
+
ptr = malloc(sizeof(git_global_st));
|
66
|
+
if (!ptr)
|
67
|
+
return NULL;
|
68
|
+
|
69
|
+
memset(ptr, 0x0, sizeof(git_global_st));
|
70
|
+
TlsSetValue(_tls_index, ptr);
|
71
|
+
return ptr;
|
72
|
+
}
|
73
|
+
|
74
|
+
#elif defined(GIT_THREADS) && defined(_POSIX_THREADS)
|
75
|
+
|
76
|
+
static pthread_key_t _tls_key;
|
77
|
+
static int _tls_init = 0;
|
78
|
+
|
79
|
+
static void cb__free_status(void *st)
|
80
|
+
{
|
81
|
+
free(st);
|
82
|
+
}
|
83
|
+
|
84
|
+
void git_threads_init(void)
|
85
|
+
{
|
86
|
+
if (_tls_init)
|
87
|
+
return;
|
88
|
+
|
89
|
+
pthread_key_create(&_tls_key, &cb__free_status);
|
90
|
+
_tls_init = 1;
|
91
|
+
}
|
92
|
+
|
93
|
+
void git_threads_shutdown(void)
|
94
|
+
{
|
95
|
+
pthread_key_delete(_tls_key);
|
96
|
+
_tls_init = 0;
|
97
|
+
}
|
98
|
+
|
99
|
+
git_global_st *git__global_state(void)
|
100
|
+
{
|
101
|
+
void *ptr;
|
102
|
+
|
103
|
+
if ((ptr = pthread_getspecific(_tls_key)) != NULL)
|
104
|
+
return ptr;
|
105
|
+
|
106
|
+
ptr = malloc(sizeof(git_global_st));
|
107
|
+
if (!ptr)
|
108
|
+
return NULL;
|
109
|
+
|
110
|
+
memset(ptr, 0x0, sizeof(git_global_st));
|
111
|
+
pthread_setspecific(_tls_key, ptr);
|
112
|
+
return ptr;
|
113
|
+
}
|
114
|
+
|
115
|
+
#else
|
116
|
+
|
117
|
+
static git_global_st __state;
|
118
|
+
|
119
|
+
void git_threads_init(void)
|
120
|
+
{
|
121
|
+
/* noop */
|
122
|
+
}
|
123
|
+
|
124
|
+
void git_threads_shutdown(void)
|
125
|
+
{
|
126
|
+
/* noop */
|
127
|
+
}
|
128
|
+
|
129
|
+
git_global_st *git__global_state(void)
|
130
|
+
{
|
131
|
+
return &__state;
|
132
|
+
}
|
133
|
+
|
134
|
+
#endif /* GIT_THREADS */
|
@@ -0,0 +1,24 @@
|
|
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_global_h__
|
8
|
+
#define INCLUDE_global_h__
|
9
|
+
|
10
|
+
#include "mwindow.h"
|
11
|
+
|
12
|
+
typedef struct {
|
13
|
+
struct {
|
14
|
+
char last[1024];
|
15
|
+
} error;
|
16
|
+
|
17
|
+
git_mwindow_ctl mem_ctl;
|
18
|
+
} git_global_st;
|
19
|
+
|
20
|
+
git_global_st *git__global_state(void);
|
21
|
+
|
22
|
+
#define GIT_GLOBAL (git__global_state())
|
23
|
+
|
24
|
+
#endif
|
@@ -0,0 +1,74 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2011 the libgit2 contributors
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "common.h"
|
9
|
+
#include "hash.h"
|
10
|
+
|
11
|
+
#if defined(PPC_SHA1)
|
12
|
+
# include "ppc/sha1.h"
|
13
|
+
#else
|
14
|
+
# include "sha1.h"
|
15
|
+
#endif
|
16
|
+
|
17
|
+
struct git_hash_ctx {
|
18
|
+
SHA_CTX c;
|
19
|
+
};
|
20
|
+
|
21
|
+
git_hash_ctx *git_hash_new_ctx(void)
|
22
|
+
{
|
23
|
+
git_hash_ctx *ctx = git__malloc(sizeof(*ctx));
|
24
|
+
|
25
|
+
if (!ctx)
|
26
|
+
return NULL;
|
27
|
+
|
28
|
+
SHA1_Init(&ctx->c);
|
29
|
+
|
30
|
+
return ctx;
|
31
|
+
}
|
32
|
+
|
33
|
+
void git_hash_free_ctx(git_hash_ctx *ctx)
|
34
|
+
{
|
35
|
+
git__free(ctx);
|
36
|
+
}
|
37
|
+
|
38
|
+
void git_hash_init(git_hash_ctx *ctx)
|
39
|
+
{
|
40
|
+
assert(ctx);
|
41
|
+
SHA1_Init(&ctx->c);
|
42
|
+
}
|
43
|
+
|
44
|
+
void git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
|
45
|
+
{
|
46
|
+
assert(ctx);
|
47
|
+
SHA1_Update(&ctx->c, data, len);
|
48
|
+
}
|
49
|
+
|
50
|
+
void git_hash_final(git_oid *out, git_hash_ctx *ctx)
|
51
|
+
{
|
52
|
+
assert(ctx);
|
53
|
+
SHA1_Final(out->id, &ctx->c);
|
54
|
+
}
|
55
|
+
|
56
|
+
void git_hash_buf(git_oid *out, const void *data, size_t len)
|
57
|
+
{
|
58
|
+
SHA_CTX c;
|
59
|
+
|
60
|
+
SHA1_Init(&c);
|
61
|
+
SHA1_Update(&c, data, len);
|
62
|
+
SHA1_Final(out->id, &c);
|
63
|
+
}
|
64
|
+
|
65
|
+
void git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n)
|
66
|
+
{
|
67
|
+
SHA_CTX c;
|
68
|
+
size_t i;
|
69
|
+
|
70
|
+
SHA1_Init(&c);
|
71
|
+
for (i = 0; i < n; i++)
|
72
|
+
SHA1_Update(&c, vec[i].data, vec[i].len);
|
73
|
+
SHA1_Final(out->id, &c);
|
74
|
+
}
|
@@ -0,0 +1,29 @@
|
|
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_hash_h__
|
8
|
+
#define INCLUDE_hash_h__
|
9
|
+
|
10
|
+
#include "git2/oid.h"
|
11
|
+
|
12
|
+
typedef struct git_hash_ctx git_hash_ctx;
|
13
|
+
|
14
|
+
typedef struct {
|
15
|
+
void *data;
|
16
|
+
size_t len;
|
17
|
+
} git_buf_vec;
|
18
|
+
|
19
|
+
git_hash_ctx *git_hash_new_ctx(void);
|
20
|
+
void git_hash_free_ctx(git_hash_ctx *ctx);
|
21
|
+
|
22
|
+
void git_hash_init(git_hash_ctx *c);
|
23
|
+
void git_hash_update(git_hash_ctx *c, const void *data, size_t len);
|
24
|
+
void git_hash_final(git_oid *out, git_hash_ctx *c);
|
25
|
+
|
26
|
+
void git_hash_buf(git_oid *out, const void *data, size_t len);
|
27
|
+
void git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n);
|
28
|
+
|
29
|
+
#endif /* INCLUDE_hash_h__ */
|
@@ -0,0 +1,243 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2011 the libgit2 contributors
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "common.h"
|
9
|
+
#include "repository.h"
|
10
|
+
#include "commit.h"
|
11
|
+
|
12
|
+
#define MAX_LOOPS 5
|
13
|
+
static const double max_load_factor = 0.65;
|
14
|
+
|
15
|
+
static int resize_to(git_hashtable *self, size_t new_size);
|
16
|
+
static int set_size(git_hashtable *self, size_t new_size);
|
17
|
+
static git_hashtable_node *node_with_hash(git_hashtable *self, const void *key, int hash_id);
|
18
|
+
static void node_swap_with(git_hashtable_node *self, git_hashtable_node *other);
|
19
|
+
static int node_insert(git_hashtable *self, git_hashtable_node *new_node);
|
20
|
+
static int insert_nodes(git_hashtable *self, git_hashtable_node *old_nodes, size_t old_size);
|
21
|
+
|
22
|
+
static int resize_to(git_hashtable *self, size_t new_size)
|
23
|
+
{
|
24
|
+
git_hashtable_node *old_nodes = self->nodes;
|
25
|
+
size_t old_size = self->size;
|
26
|
+
|
27
|
+
self->is_resizing = 1;
|
28
|
+
|
29
|
+
do {
|
30
|
+
self->size = new_size;
|
31
|
+
self->size_mask = new_size - 1;
|
32
|
+
self->key_count = 0;
|
33
|
+
self->nodes = git__calloc(1, sizeof(git_hashtable_node) * self->size);
|
34
|
+
|
35
|
+
if (self->nodes == NULL)
|
36
|
+
return GIT_ENOMEM;
|
37
|
+
|
38
|
+
if (insert_nodes(self, old_nodes, old_size) == 0)
|
39
|
+
self->is_resizing = 0;
|
40
|
+
else {
|
41
|
+
new_size *= 2;
|
42
|
+
git__free(self->nodes);
|
43
|
+
}
|
44
|
+
} while(self->is_resizing);
|
45
|
+
|
46
|
+
git__free(old_nodes);
|
47
|
+
return GIT_SUCCESS;
|
48
|
+
}
|
49
|
+
|
50
|
+
static int set_size(git_hashtable *self, size_t new_size)
|
51
|
+
{
|
52
|
+
self->nodes = git__realloc(self->nodes, new_size * sizeof(git_hashtable_node));
|
53
|
+
if (self->nodes == NULL)
|
54
|
+
return GIT_ENOMEM;
|
55
|
+
|
56
|
+
if (new_size > self->size) {
|
57
|
+
memset(&self->nodes[self->size], 0x0, (new_size - self->size) * sizeof(git_hashtable_node));
|
58
|
+
}
|
59
|
+
|
60
|
+
self->size = new_size;
|
61
|
+
self->size_mask = new_size - 1;
|
62
|
+
return GIT_SUCCESS;
|
63
|
+
}
|
64
|
+
|
65
|
+
static git_hashtable_node *node_with_hash(git_hashtable *self, const void *key, int hash_id)
|
66
|
+
{
|
67
|
+
size_t pos = self->hash(key, hash_id) & self->size_mask;
|
68
|
+
return git_hashtable_node_at(self->nodes, pos);
|
69
|
+
}
|
70
|
+
|
71
|
+
static void node_swap_with(git_hashtable_node *self, git_hashtable_node *other)
|
72
|
+
{
|
73
|
+
git_hashtable_node tmp = *self;
|
74
|
+
*self = *other;
|
75
|
+
*other = tmp;
|
76
|
+
}
|
77
|
+
|
78
|
+
static int node_insert(git_hashtable *self, git_hashtable_node *new_node)
|
79
|
+
{
|
80
|
+
int iteration, hash_id;
|
81
|
+
|
82
|
+
for (iteration = 0; iteration < MAX_LOOPS; iteration++) {
|
83
|
+
for (hash_id = 0; hash_id < GIT_HASHTABLE_HASHES; ++hash_id) {
|
84
|
+
git_hashtable_node *node;
|
85
|
+
node = node_with_hash(self, new_node->key, hash_id);
|
86
|
+
node_swap_with(new_node, node);
|
87
|
+
if(new_node->key == 0x0){
|
88
|
+
self->key_count++;
|
89
|
+
return GIT_SUCCESS;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
if (self->is_resizing)
|
95
|
+
return git__throw(GIT_EBUSY, "Failed to insert node. Hashtable is currently resizing");
|
96
|
+
|
97
|
+
resize_to(self, self->size * 2);
|
98
|
+
git_hashtable_insert(self, new_node->key, new_node->value);
|
99
|
+
return GIT_SUCCESS;
|
100
|
+
}
|
101
|
+
|
102
|
+
static int insert_nodes(git_hashtable *self, git_hashtable_node *old_nodes, size_t old_size)
|
103
|
+
{
|
104
|
+
size_t i;
|
105
|
+
|
106
|
+
for (i = 0; i < old_size; ++i) {
|
107
|
+
git_hashtable_node *node = git_hashtable_node_at(old_nodes, i);
|
108
|
+
if (node->key && git_hashtable_insert(self, node->key, node->value) < GIT_SUCCESS)
|
109
|
+
return GIT_ENOMEM;
|
110
|
+
}
|
111
|
+
|
112
|
+
return GIT_SUCCESS;
|
113
|
+
}
|
114
|
+
|
115
|
+
git_hashtable *git_hashtable_alloc(size_t min_size,
|
116
|
+
git_hash_ptr hash,
|
117
|
+
git_hash_keyeq_ptr key_eq)
|
118
|
+
{
|
119
|
+
git_hashtable *table;
|
120
|
+
|
121
|
+
assert(hash && key_eq);
|
122
|
+
|
123
|
+
if ((table = git__malloc(sizeof(git_hashtable))) == NULL)
|
124
|
+
return NULL;
|
125
|
+
|
126
|
+
memset(table, 0x0, sizeof(git_hashtable));
|
127
|
+
|
128
|
+
if (min_size < 8)
|
129
|
+
min_size = 8;
|
130
|
+
|
131
|
+
/* round up size to closest power of 2 */
|
132
|
+
min_size--;
|
133
|
+
min_size |= min_size >> 1;
|
134
|
+
min_size |= min_size >> 2;
|
135
|
+
min_size |= min_size >> 4;
|
136
|
+
min_size |= min_size >> 8;
|
137
|
+
min_size |= min_size >> 16;
|
138
|
+
|
139
|
+
table->hash = hash;
|
140
|
+
table->key_equal = key_eq;
|
141
|
+
|
142
|
+
set_size(table, min_size + 1);
|
143
|
+
|
144
|
+
return table;
|
145
|
+
}
|
146
|
+
|
147
|
+
void git_hashtable_clear(git_hashtable *self)
|
148
|
+
{
|
149
|
+
assert(self);
|
150
|
+
|
151
|
+
memset(self->nodes, 0x0, sizeof(git_hashtable_node) * self->size);
|
152
|
+
self->key_count = 0;
|
153
|
+
}
|
154
|
+
|
155
|
+
void git_hashtable_free(git_hashtable *self)
|
156
|
+
{
|
157
|
+
assert(self);
|
158
|
+
|
159
|
+
git__free(self->nodes);
|
160
|
+
git__free(self);
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
int git_hashtable_insert2(git_hashtable *self, const void *key, void *value, void **old_value)
|
165
|
+
{
|
166
|
+
int hash_id;
|
167
|
+
git_hashtable_node *node;
|
168
|
+
|
169
|
+
assert(self && self->nodes);
|
170
|
+
|
171
|
+
*old_value = NULL;
|
172
|
+
|
173
|
+
for (hash_id = 0; hash_id < GIT_HASHTABLE_HASHES; ++hash_id) {
|
174
|
+
node = node_with_hash(self, key, hash_id);
|
175
|
+
|
176
|
+
if (!node->key) {
|
177
|
+
node->key = key;
|
178
|
+
node->value = value;
|
179
|
+
self->key_count++;
|
180
|
+
return GIT_SUCCESS;
|
181
|
+
}
|
182
|
+
|
183
|
+
if (key == node->key || self->key_equal(key, node->key) == 0) {
|
184
|
+
*old_value = node->value;
|
185
|
+
node->key = key;
|
186
|
+
node->value = value;
|
187
|
+
return GIT_SUCCESS;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
/* no space in table; must do cuckoo dance */
|
192
|
+
{
|
193
|
+
git_hashtable_node x;
|
194
|
+
x.key = key;
|
195
|
+
x.value = value;
|
196
|
+
return node_insert(self, &x);
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
void *git_hashtable_lookup(git_hashtable *self, const void *key)
|
201
|
+
{
|
202
|
+
int hash_id;
|
203
|
+
git_hashtable_node *node;
|
204
|
+
|
205
|
+
assert(self && self->nodes);
|
206
|
+
|
207
|
+
for (hash_id = 0; hash_id < GIT_HASHTABLE_HASHES; ++hash_id) {
|
208
|
+
node = node_with_hash(self, key, hash_id);
|
209
|
+
if (node->key && self->key_equal(key, node->key) == 0)
|
210
|
+
return node->value;
|
211
|
+
}
|
212
|
+
|
213
|
+
return NULL;
|
214
|
+
}
|
215
|
+
|
216
|
+
int git_hashtable_remove(git_hashtable *self, const void *key)
|
217
|
+
{
|
218
|
+
int hash_id;
|
219
|
+
git_hashtable_node *node;
|
220
|
+
|
221
|
+
assert(self && self->nodes);
|
222
|
+
|
223
|
+
for (hash_id = 0; hash_id < GIT_HASHTABLE_HASHES; ++hash_id) {
|
224
|
+
node = node_with_hash(self, key, hash_id);
|
225
|
+
if (node->key && self->key_equal(key, node->key) == 0) {
|
226
|
+
node->key = NULL;
|
227
|
+
node->value = NULL;
|
228
|
+
self->key_count--;
|
229
|
+
return GIT_SUCCESS;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
return git__throw(GIT_ENOTFOUND, "Entry not found in hash table");
|
234
|
+
}
|
235
|
+
|
236
|
+
int git_hashtable_merge(git_hashtable *self, git_hashtable *other)
|
237
|
+
{
|
238
|
+
if (resize_to(self, (self->size + other->size) * 2) < GIT_SUCCESS)
|
239
|
+
return GIT_ENOMEM;
|
240
|
+
|
241
|
+
return insert_nodes(self, other->nodes, other->key_count);
|
242
|
+
}
|
243
|
+
|