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,94 @@
|
|
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 "posix.h"
|
9
|
+
#include "path.h"
|
10
|
+
#include <stdio.h>
|
11
|
+
#include <ctype.h>
|
12
|
+
|
13
|
+
#ifndef GIT_WIN32
|
14
|
+
|
15
|
+
int p_open(const char *path, int flags)
|
16
|
+
{
|
17
|
+
return open(path, flags | O_BINARY);
|
18
|
+
}
|
19
|
+
|
20
|
+
int p_creat(const char *path, mode_t mode)
|
21
|
+
{
|
22
|
+
return open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode);
|
23
|
+
}
|
24
|
+
|
25
|
+
int p_getcwd(char *buffer_out, size_t size)
|
26
|
+
{
|
27
|
+
char *cwd_buffer;
|
28
|
+
|
29
|
+
assert(buffer_out && size > 0);
|
30
|
+
|
31
|
+
cwd_buffer = getcwd(buffer_out, size);
|
32
|
+
|
33
|
+
if (cwd_buffer == NULL)
|
34
|
+
return git__throw(GIT_EOSERR, "Failed to retrieve current working directory");
|
35
|
+
|
36
|
+
git_path_mkposix(buffer_out);
|
37
|
+
|
38
|
+
git_path_join(buffer_out, buffer_out, ""); //Ensure the path ends with a trailing slash
|
39
|
+
return GIT_SUCCESS;
|
40
|
+
}
|
41
|
+
|
42
|
+
int p_rename(const char *from, const char *to)
|
43
|
+
{
|
44
|
+
if (!link(from, to)) {
|
45
|
+
p_unlink(from);
|
46
|
+
return GIT_SUCCESS;
|
47
|
+
}
|
48
|
+
|
49
|
+
if (!rename(from, to))
|
50
|
+
return GIT_SUCCESS;
|
51
|
+
|
52
|
+
return GIT_ERROR;
|
53
|
+
|
54
|
+
}
|
55
|
+
|
56
|
+
#endif
|
57
|
+
|
58
|
+
int p_read(git_file fd, void *buf, size_t cnt)
|
59
|
+
{
|
60
|
+
char *b = buf;
|
61
|
+
while (cnt) {
|
62
|
+
ssize_t r = read(fd, b, cnt);
|
63
|
+
if (r < 0) {
|
64
|
+
if (errno == EINTR || errno == EAGAIN)
|
65
|
+
continue;
|
66
|
+
return GIT_EOSERR;
|
67
|
+
}
|
68
|
+
if (!r)
|
69
|
+
break;
|
70
|
+
cnt -= r;
|
71
|
+
b += r;
|
72
|
+
}
|
73
|
+
return (int)(b - (char *)buf);
|
74
|
+
}
|
75
|
+
|
76
|
+
int p_write(git_file fd, const void *buf, size_t cnt)
|
77
|
+
{
|
78
|
+
const char *b = buf;
|
79
|
+
while (cnt) {
|
80
|
+
ssize_t r = write(fd, b, cnt);
|
81
|
+
if (r < 0) {
|
82
|
+
if (errno == EINTR || errno == EAGAIN)
|
83
|
+
continue;
|
84
|
+
return GIT_EOSERR;
|
85
|
+
}
|
86
|
+
if (!r) {
|
87
|
+
errno = EPIPE;
|
88
|
+
return GIT_EOSERR;
|
89
|
+
}
|
90
|
+
cnt -= r;
|
91
|
+
b += r;
|
92
|
+
}
|
93
|
+
return GIT_SUCCESS;
|
94
|
+
}
|
@@ -0,0 +1,69 @@
|
|
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_h__
|
8
|
+
#define INCLUDE_posix_h__
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
#include <fcntl.h>
|
12
|
+
#include <time.h>
|
13
|
+
|
14
|
+
#define S_IFGITLINK 0160000
|
15
|
+
#define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK)
|
16
|
+
|
17
|
+
#if !defined(O_BINARY)
|
18
|
+
#define O_BINARY 0
|
19
|
+
#endif
|
20
|
+
|
21
|
+
typedef int git_file;
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Standard POSIX Methods
|
25
|
+
*
|
26
|
+
* All the methods starting with the `p_` prefix are
|
27
|
+
* direct ports of the standard POSIX methods.
|
28
|
+
*
|
29
|
+
* Some of the methods are slightly wrapped to provide
|
30
|
+
* saner defaults. Some of these methods are emulated
|
31
|
+
* in Windows platforns.
|
32
|
+
*
|
33
|
+
* Use your manpages to check the docs on these.
|
34
|
+
* Straightforward
|
35
|
+
*/
|
36
|
+
|
37
|
+
extern int p_read(git_file fd, void *buf, size_t cnt);
|
38
|
+
extern int p_write(git_file fd, const void *buf, size_t cnt);
|
39
|
+
|
40
|
+
#define p_fstat(f,b) fstat(f, b)
|
41
|
+
#define p_lseek(f,n,w) lseek(f, n, w)
|
42
|
+
#define p_close(fd) close(fd)
|
43
|
+
#define p_umask(m) umask(m)
|
44
|
+
|
45
|
+
extern int p_open(const char *path, int flags);
|
46
|
+
extern int p_creat(const char *path, mode_t mode);
|
47
|
+
extern int p_getcwd(char *buffer_out, size_t size);
|
48
|
+
extern int p_rename(const char *from, const char *to);
|
49
|
+
|
50
|
+
#ifndef GIT_WIN32
|
51
|
+
|
52
|
+
#define p_stat(p,b) stat(p, b)
|
53
|
+
#define p_chdir(p) chdir(p)
|
54
|
+
#define p_rmdir(p) rmdir(p)
|
55
|
+
#define p_chmod(p,m) chmod(p, m)
|
56
|
+
#define p_access(p,m) access(p,m)
|
57
|
+
|
58
|
+
#endif
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Platform-dependent methods
|
62
|
+
*/
|
63
|
+
#ifdef GIT_WIN32
|
64
|
+
# include "win32/posix.h"
|
65
|
+
#else
|
66
|
+
# include "unix/posix.h"
|
67
|
+
#endif
|
68
|
+
|
69
|
+
#endif
|
@@ -0,0 +1,70 @@
|
|
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 <stdio.h>
|
8
|
+
#include <string.h>
|
9
|
+
#include "sha1.h"
|
10
|
+
|
11
|
+
extern void ppc_sha1_core(uint32_t *hash, const unsigned char *p,
|
12
|
+
unsigned int nblocks);
|
13
|
+
|
14
|
+
int ppc_SHA1_Init(ppc_SHA_CTX *c)
|
15
|
+
{
|
16
|
+
c->hash[0] = 0x67452301;
|
17
|
+
c->hash[1] = 0xEFCDAB89;
|
18
|
+
c->hash[2] = 0x98BADCFE;
|
19
|
+
c->hash[3] = 0x10325476;
|
20
|
+
c->hash[4] = 0xC3D2E1F0;
|
21
|
+
c->len = 0;
|
22
|
+
c->cnt = 0;
|
23
|
+
return 0;
|
24
|
+
}
|
25
|
+
|
26
|
+
int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *ptr, unsigned long n)
|
27
|
+
{
|
28
|
+
unsigned long nb;
|
29
|
+
const unsigned char *p = ptr;
|
30
|
+
|
31
|
+
c->len += (uint64_t) n << 3;
|
32
|
+
while (n != 0) {
|
33
|
+
if (c->cnt || n < 64) {
|
34
|
+
nb = 64 - c->cnt;
|
35
|
+
if (nb > n)
|
36
|
+
nb = n;
|
37
|
+
memcpy(&c->buf.b[c->cnt], p, nb);
|
38
|
+
if ((c->cnt += nb) == 64) {
|
39
|
+
ppc_sha1_core(c->hash, c->buf.b, 1);
|
40
|
+
c->cnt = 0;
|
41
|
+
}
|
42
|
+
} else {
|
43
|
+
nb = n >> 6;
|
44
|
+
ppc_sha1_core(c->hash, p, nb);
|
45
|
+
nb <<= 6;
|
46
|
+
}
|
47
|
+
n -= nb;
|
48
|
+
p += nb;
|
49
|
+
}
|
50
|
+
return 0;
|
51
|
+
}
|
52
|
+
|
53
|
+
int ppc_SHA1_Final(unsigned char *hash, ppc_SHA_CTX *c)
|
54
|
+
{
|
55
|
+
unsigned int cnt = c->cnt;
|
56
|
+
|
57
|
+
c->buf.b[cnt++] = 0x80;
|
58
|
+
if (cnt > 56) {
|
59
|
+
if (cnt < 64)
|
60
|
+
memset(&c->buf.b[cnt], 0, 64 - cnt);
|
61
|
+
ppc_sha1_core(c->hash, c->buf.b, 1);
|
62
|
+
cnt = 0;
|
63
|
+
}
|
64
|
+
if (cnt < 56)
|
65
|
+
memset(&c->buf.b[cnt], 0, 56 - cnt);
|
66
|
+
c->buf.l[7] = c->len;
|
67
|
+
ppc_sha1_core(c->hash, c->buf.b, 1);
|
68
|
+
memcpy(hash, c->hash, 20);
|
69
|
+
return 0;
|
70
|
+
}
|
@@ -0,0 +1,26 @@
|
|
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 <stdint.h>
|
8
|
+
|
9
|
+
typedef struct {
|
10
|
+
uint32_t hash[5];
|
11
|
+
uint32_t cnt;
|
12
|
+
uint64_t len;
|
13
|
+
union {
|
14
|
+
unsigned char b[64];
|
15
|
+
uint64_t l[8];
|
16
|
+
} buf;
|
17
|
+
} ppc_SHA_CTX;
|
18
|
+
|
19
|
+
int ppc_SHA1_Init(ppc_SHA_CTX *c);
|
20
|
+
int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *p, unsigned long n);
|
21
|
+
int ppc_SHA1_Final(unsigned char *hash, ppc_SHA_CTX *c);
|
22
|
+
|
23
|
+
#define SHA_CTX ppc_SHA_CTX
|
24
|
+
#define SHA1_Init ppc_SHA1_Init
|
25
|
+
#define SHA1_Update ppc_SHA1_Update
|
26
|
+
#define SHA1_Final ppc_SHA1_Final
|
@@ -0,0 +1,141 @@
|
|
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 "pqueue.h"
|
10
|
+
|
11
|
+
#define left(i) ((i) << 1)
|
12
|
+
#define right(i) (((i) << 1) + 1)
|
13
|
+
#define parent(i) ((i) >> 1)
|
14
|
+
|
15
|
+
int git_pqueue_init(git_pqueue *q, size_t n, git_pqueue_cmp cmppri)
|
16
|
+
{
|
17
|
+
assert(q);
|
18
|
+
|
19
|
+
/* Need to allocate n+1 elements since element 0 isn't used. */
|
20
|
+
if ((q->d = git__malloc((n + 1) * sizeof(void *))) == NULL)
|
21
|
+
return GIT_ENOMEM;
|
22
|
+
|
23
|
+
q->size = 1;
|
24
|
+
q->avail = q->step = (n + 1); /* see comment above about n+1 */
|
25
|
+
q->cmppri = cmppri;
|
26
|
+
|
27
|
+
return GIT_SUCCESS;
|
28
|
+
}
|
29
|
+
|
30
|
+
|
31
|
+
void git_pqueue_free(git_pqueue *q)
|
32
|
+
{
|
33
|
+
git__free(q->d);
|
34
|
+
q->d = NULL;
|
35
|
+
}
|
36
|
+
|
37
|
+
void git_pqueue_clear(git_pqueue *q)
|
38
|
+
{
|
39
|
+
q->size = 1;
|
40
|
+
}
|
41
|
+
|
42
|
+
size_t git_pqueue_size(git_pqueue *q)
|
43
|
+
{
|
44
|
+
/* queue element 0 exists but doesn't count since it isn't used. */
|
45
|
+
return (q->size - 1);
|
46
|
+
}
|
47
|
+
|
48
|
+
|
49
|
+
static void bubble_up(git_pqueue *q, size_t i)
|
50
|
+
{
|
51
|
+
size_t parent_node;
|
52
|
+
void *moving_node = q->d[i];
|
53
|
+
|
54
|
+
for (parent_node = parent(i);
|
55
|
+
((i > 1) && q->cmppri(q->d[parent_node], moving_node));
|
56
|
+
i = parent_node, parent_node = parent(i)) {
|
57
|
+
q->d[i] = q->d[parent_node];
|
58
|
+
}
|
59
|
+
|
60
|
+
q->d[i] = moving_node;
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
static size_t maxchild(git_pqueue *q, size_t i)
|
65
|
+
{
|
66
|
+
size_t child_node = left(i);
|
67
|
+
|
68
|
+
if (child_node >= q->size)
|
69
|
+
return 0;
|
70
|
+
|
71
|
+
if ((child_node + 1) < q->size &&
|
72
|
+
q->cmppri(q->d[child_node], q->d[child_node + 1]))
|
73
|
+
child_node++; /* use right child instead of left */
|
74
|
+
|
75
|
+
return child_node;
|
76
|
+
}
|
77
|
+
|
78
|
+
|
79
|
+
static void percolate_down(git_pqueue *q, size_t i)
|
80
|
+
{
|
81
|
+
size_t child_node;
|
82
|
+
void *moving_node = q->d[i];
|
83
|
+
|
84
|
+
while ((child_node = maxchild(q, i)) != 0 &&
|
85
|
+
q->cmppri(moving_node, q->d[child_node])) {
|
86
|
+
q->d[i] = q->d[child_node];
|
87
|
+
i = child_node;
|
88
|
+
}
|
89
|
+
|
90
|
+
q->d[i] = moving_node;
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
int git_pqueue_insert(git_pqueue *q, void *d)
|
95
|
+
{
|
96
|
+
void *tmp;
|
97
|
+
size_t i;
|
98
|
+
size_t newsize;
|
99
|
+
|
100
|
+
if (!q) return 1;
|
101
|
+
|
102
|
+
/* allocate more memory if necessary */
|
103
|
+
if (q->size >= q->avail) {
|
104
|
+
newsize = q->size + q->step;
|
105
|
+
if ((tmp = git__realloc(q->d, sizeof(void *) * newsize)) == NULL)
|
106
|
+
return GIT_ENOMEM;
|
107
|
+
|
108
|
+
q->d = tmp;
|
109
|
+
q->avail = newsize;
|
110
|
+
}
|
111
|
+
|
112
|
+
/* insert item */
|
113
|
+
i = q->size++;
|
114
|
+
q->d[i] = d;
|
115
|
+
bubble_up(q, i);
|
116
|
+
|
117
|
+
return GIT_SUCCESS;
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
void *git_pqueue_pop(git_pqueue *q)
|
122
|
+
{
|
123
|
+
void *head;
|
124
|
+
|
125
|
+
if (!q || q->size == 1)
|
126
|
+
return NULL;
|
127
|
+
|
128
|
+
head = q->d[1];
|
129
|
+
q->d[1] = q->d[--q->size];
|
130
|
+
percolate_down(q, 1);
|
131
|
+
|
132
|
+
return head;
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
void *git_pqueue_peek(git_pqueue *q)
|
137
|
+
{
|
138
|
+
if (!q || q->size == 1)
|
139
|
+
return NULL;
|
140
|
+
return q->d[1];
|
141
|
+
}
|
@@ -0,0 +1,81 @@
|
|
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
|
+
#ifndef INCLUDE_pqueue_h__
|
9
|
+
#define INCLUDE_pqueue_h__
|
10
|
+
|
11
|
+
/** callback functions to get/set/compare the priority of an element */
|
12
|
+
typedef int (*git_pqueue_cmp)(void *a, void *b);
|
13
|
+
|
14
|
+
/** the priority queue handle */
|
15
|
+
typedef struct {
|
16
|
+
size_t size, avail, step;
|
17
|
+
git_pqueue_cmp cmppri;
|
18
|
+
void **d;
|
19
|
+
} git_pqueue;
|
20
|
+
|
21
|
+
|
22
|
+
/**
|
23
|
+
* initialize the queue
|
24
|
+
*
|
25
|
+
* @param n the initial estimate of the number of queue items for which memory
|
26
|
+
* should be preallocated
|
27
|
+
* @param cmppri the callback function to compare two nodes of the queue
|
28
|
+
*
|
29
|
+
* @Return the handle or NULL for insufficent memory
|
30
|
+
*/
|
31
|
+
int git_pqueue_init(git_pqueue *q, size_t n, git_pqueue_cmp cmppri);
|
32
|
+
|
33
|
+
|
34
|
+
/**
|
35
|
+
* free all memory used by the queue
|
36
|
+
* @param q the queue
|
37
|
+
*/
|
38
|
+
void git_pqueue_free(git_pqueue *q);
|
39
|
+
|
40
|
+
/**
|
41
|
+
* clear all the elements in the queue
|
42
|
+
* @param q the queue
|
43
|
+
*/
|
44
|
+
void git_pqueue_clear(git_pqueue *q);
|
45
|
+
|
46
|
+
/**
|
47
|
+
* return the size of the queue.
|
48
|
+
* @param q the queue
|
49
|
+
*/
|
50
|
+
size_t git_pqueue_size(git_pqueue *q);
|
51
|
+
|
52
|
+
|
53
|
+
/**
|
54
|
+
* insert an item into the queue.
|
55
|
+
* @param q the queue
|
56
|
+
* @param d the item
|
57
|
+
* @return 0 on success
|
58
|
+
*/
|
59
|
+
int git_pqueue_insert(git_pqueue *q, void *d);
|
60
|
+
|
61
|
+
|
62
|
+
/**
|
63
|
+
* pop the highest-ranking item from the queue.
|
64
|
+
* @param p the queue
|
65
|
+
* @param d where to copy the entry to
|
66
|
+
* @return NULL on error, otherwise the entry
|
67
|
+
*/
|
68
|
+
void *git_pqueue_pop(git_pqueue *q);
|
69
|
+
|
70
|
+
|
71
|
+
/**
|
72
|
+
* access highest-ranking item without removing it.
|
73
|
+
* @param q the queue
|
74
|
+
* @param d the entry
|
75
|
+
* @return NULL on error, otherwise the entry
|
76
|
+
*/
|
77
|
+
void *git_pqueue_peek(git_pqueue *q);
|
78
|
+
|
79
|
+
#endif /* PQUEUE_H */
|
80
|
+
/** @} */
|
81
|
+
|