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,482 @@
|
|
1
|
+
/*
|
2
|
+
* The MIT License
|
3
|
+
*
|
4
|
+
* Copyright (c) 2011 GitHub, Inc
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
14
|
+
* all copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
* THE SOFTWARE.
|
23
|
+
*/
|
24
|
+
|
25
|
+
#include "rugged.h"
|
26
|
+
|
27
|
+
extern VALUE rb_mRugged;
|
28
|
+
extern VALUE rb_cRuggedIndex;
|
29
|
+
extern VALUE rb_cRuggedConfig;
|
30
|
+
extern VALUE rb_cRuggedBackend;
|
31
|
+
|
32
|
+
VALUE rb_cRuggedRepo;
|
33
|
+
VALUE rb_cRuggedOdbObject;
|
34
|
+
|
35
|
+
git_otype rugged_get_otype(VALUE self)
|
36
|
+
{
|
37
|
+
git_otype type;
|
38
|
+
|
39
|
+
if (NIL_P(self))
|
40
|
+
return GIT_OBJ_ANY;
|
41
|
+
|
42
|
+
switch (TYPE(self)) {
|
43
|
+
case T_STRING:
|
44
|
+
type = git_object_string2type(StringValueCStr(self));
|
45
|
+
break;
|
46
|
+
|
47
|
+
case T_FIXNUM:
|
48
|
+
type = FIX2INT(self);
|
49
|
+
break;
|
50
|
+
|
51
|
+
default:
|
52
|
+
type = GIT_OBJ_BAD;
|
53
|
+
break;
|
54
|
+
}
|
55
|
+
|
56
|
+
if (!git_object_typeisloose(type))
|
57
|
+
rb_raise(rb_eTypeError, "Invalid Git object type specifier");
|
58
|
+
|
59
|
+
return type;
|
60
|
+
}
|
61
|
+
|
62
|
+
static VALUE rb_git_odbobj_hash(VALUE self)
|
63
|
+
{
|
64
|
+
git_odb_object *obj;
|
65
|
+
Data_Get_Struct(self, git_odb_object, obj);
|
66
|
+
return rugged_create_oid(git_odb_object_id(obj));
|
67
|
+
}
|
68
|
+
|
69
|
+
static VALUE rb_git_odbobj_data(VALUE self)
|
70
|
+
{
|
71
|
+
git_odb_object *obj;
|
72
|
+
Data_Get_Struct(self, git_odb_object, obj);
|
73
|
+
return rugged_str_ascii(git_odb_object_data(obj), git_odb_object_size(obj));
|
74
|
+
}
|
75
|
+
|
76
|
+
static VALUE rb_git_odbobj_size(VALUE self)
|
77
|
+
{
|
78
|
+
git_odb_object *obj;
|
79
|
+
Data_Get_Struct(self, git_odb_object, obj);
|
80
|
+
return INT2FIX(git_odb_object_size(obj));
|
81
|
+
}
|
82
|
+
|
83
|
+
static VALUE rb_git_odbobj_type(VALUE self)
|
84
|
+
{
|
85
|
+
git_odb_object *obj;
|
86
|
+
Data_Get_Struct(self, git_odb_object, obj);
|
87
|
+
return INT2FIX(git_odb_object_type(obj));
|
88
|
+
}
|
89
|
+
|
90
|
+
void rb_git__odbobj_free(void *obj)
|
91
|
+
{
|
92
|
+
git_odb_object_free((git_odb_object *)obj);
|
93
|
+
}
|
94
|
+
|
95
|
+
VALUE rugged_raw_read(git_repository *repo, const git_oid *oid)
|
96
|
+
{
|
97
|
+
git_odb *odb;
|
98
|
+
git_odb_object *obj;
|
99
|
+
|
100
|
+
int error;
|
101
|
+
|
102
|
+
error = git_repository_odb(&odb, repo);
|
103
|
+
rugged_exception_check(error);
|
104
|
+
|
105
|
+
error = git_odb_read(&obj, odb, oid);
|
106
|
+
rugged_exception_check(error);
|
107
|
+
|
108
|
+
git_odb_free(odb);
|
109
|
+
|
110
|
+
return Data_Wrap_Struct(rb_cRuggedOdbObject, NULL, rb_git__odbobj_free, obj);
|
111
|
+
}
|
112
|
+
|
113
|
+
void rb_git_repo__free(git_repository *repo)
|
114
|
+
{
|
115
|
+
git_repository_free(repo);
|
116
|
+
}
|
117
|
+
|
118
|
+
static VALUE rugged_repo_new(VALUE klass, git_repository *repo)
|
119
|
+
{
|
120
|
+
VALUE rb_repo = Data_Wrap_Struct(klass, NULL, &rb_git_repo__free, repo);
|
121
|
+
|
122
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
123
|
+
/* TODO: set this properly */
|
124
|
+
rb_iv_set(rb_repo, "@encoding",
|
125
|
+
rb_enc_from_encoding(rb_filesystem_encoding()));
|
126
|
+
#endif
|
127
|
+
|
128
|
+
return rb_repo;
|
129
|
+
}
|
130
|
+
|
131
|
+
static VALUE rb_git_repo_new(VALUE klass, VALUE rb_path)
|
132
|
+
{
|
133
|
+
git_repository *repo;
|
134
|
+
int error = 0;
|
135
|
+
|
136
|
+
Check_Type(rb_path, T_STRING);
|
137
|
+
|
138
|
+
error = git_repository_open(&repo, StringValueCStr(rb_path));
|
139
|
+
rugged_exception_check(error);
|
140
|
+
|
141
|
+
return rugged_repo_new(klass, repo);
|
142
|
+
}
|
143
|
+
|
144
|
+
static VALUE rb_git_repo_init_at(VALUE klass, VALUE path, VALUE rb_is_bare)
|
145
|
+
{
|
146
|
+
git_repository *repo;
|
147
|
+
int error, is_bare;
|
148
|
+
|
149
|
+
is_bare = rugged_parse_bool(rb_is_bare);
|
150
|
+
Check_Type(path, T_STRING);
|
151
|
+
|
152
|
+
error = git_repository_init(&repo, StringValueCStr(path), is_bare);
|
153
|
+
rugged_exception_check(error);
|
154
|
+
|
155
|
+
return rugged_repo_new(klass, repo);
|
156
|
+
}
|
157
|
+
|
158
|
+
#define RB_GIT_REPO_OWNED_ATTR(_klass, _object) \
|
159
|
+
static VALUE rb_git_repo_get_##_object(VALUE self) \
|
160
|
+
{ \
|
161
|
+
VALUE rb_data = rb_iv_get(self, "@" #_object); \
|
162
|
+
if (NIL_P(rb_data)) { \
|
163
|
+
git_repository *repo; \
|
164
|
+
git_##_object *data; \
|
165
|
+
int error; \
|
166
|
+
Data_Get_Struct(self, git_repository, repo); \
|
167
|
+
error = git_repository_##_object(&data, repo); \
|
168
|
+
rugged_exception_check(error); \
|
169
|
+
rb_data = rugged_##_object##_new(_klass, self, data); \
|
170
|
+
rb_iv_set(self, "@" #_object, rb_data); \
|
171
|
+
} \
|
172
|
+
return rb_data; \
|
173
|
+
}\
|
174
|
+
static VALUE rb_git_repo_set_##_object(VALUE self, VALUE rb_data) \
|
175
|
+
{ \
|
176
|
+
VALUE rb_old_data; \
|
177
|
+
git_repository *repo; \
|
178
|
+
git_##_object *data; \
|
179
|
+
if (!rb_obj_is_kind_of(rb_data, _klass))\
|
180
|
+
rb_raise(rb_eTypeError, \
|
181
|
+
"The given object is not a Rugged::" #_object); \
|
182
|
+
if (!NIL_P(rugged_owner(rb_data))) \
|
183
|
+
rb_raise(rb_eRuntimeError, \
|
184
|
+
"The given object is already owned by another repository"); \
|
185
|
+
Data_Get_Struct(self, git_repository, repo); \
|
186
|
+
Data_Get_Struct(rb_data, git_##_object, data); \
|
187
|
+
git_repository_set_##_object(repo, data); \
|
188
|
+
rb_old_data = rb_iv_get(self, "@" #_object); \
|
189
|
+
if (!NIL_P(rb_old_data)) rugged_set_owner(rb_old_data, Qnil); \
|
190
|
+
rugged_set_owner(rb_data, self); \
|
191
|
+
rb_iv_set(self, "@" #_object, rb_data); \
|
192
|
+
return Qnil; \
|
193
|
+
}
|
194
|
+
|
195
|
+
/* git_repository_index, git_repository_set_index */
|
196
|
+
RB_GIT_REPO_OWNED_ATTR(rb_cRuggedIndex, index);
|
197
|
+
|
198
|
+
/* git_repository_config, git_repository_set_config */
|
199
|
+
RB_GIT_REPO_OWNED_ATTR(rb_cRuggedConfig, config);
|
200
|
+
|
201
|
+
static VALUE rb_git_repo_exists(VALUE self, VALUE hex)
|
202
|
+
{
|
203
|
+
git_repository *repo;
|
204
|
+
git_odb *odb;
|
205
|
+
git_oid oid;
|
206
|
+
int error;
|
207
|
+
VALUE rb_result;
|
208
|
+
|
209
|
+
Data_Get_Struct(self, git_repository, repo);
|
210
|
+
Check_Type(hex, T_STRING);
|
211
|
+
|
212
|
+
error = git_repository_odb(&odb, repo);
|
213
|
+
rugged_exception_check(error);
|
214
|
+
|
215
|
+
error = git_oid_fromstr(&oid, StringValueCStr(hex));
|
216
|
+
rugged_exception_check(error);
|
217
|
+
|
218
|
+
rb_result = git_odb_exists(odb, &oid) ? Qtrue : Qfalse;
|
219
|
+
git_odb_free(odb);
|
220
|
+
|
221
|
+
return rb_result;
|
222
|
+
}
|
223
|
+
|
224
|
+
static VALUE rb_git_repo_read(VALUE self, VALUE hex)
|
225
|
+
{
|
226
|
+
git_repository *repo;
|
227
|
+
git_oid oid;
|
228
|
+
int error;
|
229
|
+
|
230
|
+
Data_Get_Struct(self, git_repository, repo);
|
231
|
+
Check_Type(hex, T_STRING);
|
232
|
+
|
233
|
+
error = git_oid_fromstr(&oid, StringValueCStr(hex));
|
234
|
+
rugged_exception_check(error);
|
235
|
+
|
236
|
+
return rugged_raw_read(repo, &oid);
|
237
|
+
}
|
238
|
+
|
239
|
+
static VALUE rb_git_repo_hash(VALUE self, VALUE rb_buffer, VALUE rb_type)
|
240
|
+
{
|
241
|
+
int error;
|
242
|
+
git_oid oid;
|
243
|
+
|
244
|
+
Check_Type(rb_buffer, T_STRING);
|
245
|
+
|
246
|
+
error = git_odb_hash(&oid,
|
247
|
+
RSTRING_PTR(rb_buffer),
|
248
|
+
RSTRING_LEN(rb_buffer),
|
249
|
+
rugged_get_otype(rb_type)
|
250
|
+
);
|
251
|
+
rugged_exception_check(error);
|
252
|
+
|
253
|
+
return rugged_create_oid(&oid);
|
254
|
+
}
|
255
|
+
|
256
|
+
static VALUE rb_git_repo_hashfile(VALUE self, VALUE rb_path, VALUE rb_type)
|
257
|
+
{
|
258
|
+
int error;
|
259
|
+
git_oid oid;
|
260
|
+
|
261
|
+
Check_Type(rb_path, T_STRING);
|
262
|
+
|
263
|
+
error = git_odb_hashfile(&oid,
|
264
|
+
StringValueCStr(rb_path),
|
265
|
+
rugged_get_otype(rb_type)
|
266
|
+
);
|
267
|
+
rugged_exception_check(error);
|
268
|
+
|
269
|
+
return rugged_create_oid(&oid);
|
270
|
+
}
|
271
|
+
|
272
|
+
static VALUE rb_git_repo_write(VALUE self, VALUE rb_buffer, VALUE rub_type)
|
273
|
+
{
|
274
|
+
git_repository *repo;
|
275
|
+
git_odb_stream *stream;
|
276
|
+
|
277
|
+
git_odb *odb;
|
278
|
+
git_oid oid;
|
279
|
+
int error;
|
280
|
+
|
281
|
+
git_otype type;
|
282
|
+
|
283
|
+
Data_Get_Struct(self, git_repository, repo);
|
284
|
+
|
285
|
+
error = git_repository_odb(&odb, repo);
|
286
|
+
rugged_exception_check(error);
|
287
|
+
|
288
|
+
type = rugged_get_otype(rub_type);
|
289
|
+
|
290
|
+
error = git_odb_open_wstream(&stream, odb, RSTRING_LEN(rb_buffer), type);
|
291
|
+
rugged_exception_check(error);
|
292
|
+
|
293
|
+
git_odb_free(odb);
|
294
|
+
|
295
|
+
error = stream->write(stream, RSTRING_PTR(rb_buffer), RSTRING_LEN(rb_buffer));
|
296
|
+
rugged_exception_check(error);
|
297
|
+
|
298
|
+
error = stream->finalize_write(&oid, stream);
|
299
|
+
rugged_exception_check(error);
|
300
|
+
|
301
|
+
return rugged_create_oid(&oid);
|
302
|
+
}
|
303
|
+
|
304
|
+
#define GIT_REPO_GETTER(method) \
|
305
|
+
static VALUE rb_git_repo_##method(VALUE self) \
|
306
|
+
{ \
|
307
|
+
git_repository *repo; \
|
308
|
+
int error; \
|
309
|
+
Data_Get_Struct(self, git_repository, repo); \
|
310
|
+
error = git_repository_##method(repo); \
|
311
|
+
rugged_exception_check(error); \
|
312
|
+
return error ? Qtrue : Qfalse; \
|
313
|
+
}
|
314
|
+
|
315
|
+
GIT_REPO_GETTER(is_bare); /* git_repository_is_bare */
|
316
|
+
GIT_REPO_GETTER(is_empty); /* git_repository_is_empty */
|
317
|
+
GIT_REPO_GETTER(head_detached); /* git_repository_head_detached */
|
318
|
+
GIT_REPO_GETTER(head_orphan); /* git_repository_head_orphan */
|
319
|
+
|
320
|
+
static VALUE rb_git_repo_path(VALUE self)
|
321
|
+
{
|
322
|
+
git_repository *repo;
|
323
|
+
Data_Get_Struct(self, git_repository, repo);
|
324
|
+
return rugged_str_new2(git_repository_path(repo), NULL);
|
325
|
+
}
|
326
|
+
|
327
|
+
static VALUE rb_git_repo_workdir(VALUE self)
|
328
|
+
{
|
329
|
+
git_repository *repo;
|
330
|
+
const char *workdir;
|
331
|
+
|
332
|
+
Data_Get_Struct(self, git_repository, repo);
|
333
|
+
workdir = git_repository_workdir(repo);
|
334
|
+
|
335
|
+
return workdir ? rugged_str_new2(workdir, NULL) : Qnil;
|
336
|
+
}
|
337
|
+
|
338
|
+
static VALUE rb_git_repo_set_workdir(VALUE self, VALUE rb_workdir)
|
339
|
+
{
|
340
|
+
git_repository *repo;
|
341
|
+
|
342
|
+
Data_Get_Struct(self, git_repository, repo);
|
343
|
+
Check_Type(rb_workdir, T_STRING);
|
344
|
+
|
345
|
+
rugged_exception_check(
|
346
|
+
git_repository_set_workdir(repo, StringValueCStr(rb_workdir))
|
347
|
+
);
|
348
|
+
|
349
|
+
return Qnil;
|
350
|
+
}
|
351
|
+
|
352
|
+
static VALUE rb_git_repo_discover(int argc, VALUE *argv, VALUE self)
|
353
|
+
{
|
354
|
+
VALUE rb_path, rb_across_fs;
|
355
|
+
char repository_path[GIT_PATH_MAX];
|
356
|
+
int error, across_fs = 0;
|
357
|
+
|
358
|
+
rb_scan_args(argc, argv, "02", &rb_path, &rb_across_fs);
|
359
|
+
|
360
|
+
if (NIL_P(rb_path)) {
|
361
|
+
VALUE rb_dir = rb_const_get(rb_cObject, rb_intern("Dir"));
|
362
|
+
rb_path = rb_funcall(rb_dir, rb_intern("pwd"), 0);
|
363
|
+
}
|
364
|
+
|
365
|
+
if (!NIL_P(rb_across_fs)) {
|
366
|
+
across_fs = rugged_parse_bool(rb_across_fs);
|
367
|
+
}
|
368
|
+
|
369
|
+
Check_Type(rb_path, T_STRING);
|
370
|
+
|
371
|
+
error = git_repository_discover(
|
372
|
+
repository_path, GIT_PATH_MAX,
|
373
|
+
StringValueCStr(rb_path),
|
374
|
+
across_fs,
|
375
|
+
NULL
|
376
|
+
);
|
377
|
+
|
378
|
+
rugged_exception_check(error);
|
379
|
+
return rugged_str_new2(repository_path, NULL);
|
380
|
+
}
|
381
|
+
|
382
|
+
static VALUE flags_to_rb(unsigned int flags)
|
383
|
+
{
|
384
|
+
VALUE rb_flags = rb_ary_new();
|
385
|
+
|
386
|
+
if (flags & GIT_STATUS_INDEX_NEW)
|
387
|
+
rb_ary_push(rb_flags, CSTR2SYM("index_new"));
|
388
|
+
|
389
|
+
if (flags & GIT_STATUS_INDEX_MODIFIED)
|
390
|
+
rb_ary_push(rb_flags, CSTR2SYM("index_modified"));
|
391
|
+
|
392
|
+
if (flags & GIT_STATUS_INDEX_DELETED)
|
393
|
+
rb_ary_push(rb_flags, CSTR2SYM("index_deleted"));
|
394
|
+
|
395
|
+
if (flags & GIT_STATUS_WT_NEW)
|
396
|
+
rb_ary_push(rb_flags, CSTR2SYM("worktree_new"));
|
397
|
+
|
398
|
+
if (flags & GIT_STATUS_WT_MODIFIED)
|
399
|
+
rb_ary_push(rb_flags, CSTR2SYM("worktree_modified"));
|
400
|
+
|
401
|
+
if (flags & GIT_STATUS_WT_DELETED)
|
402
|
+
rb_ary_push(rb_flags, CSTR2SYM("worktree_deleted"));
|
403
|
+
|
404
|
+
return rb_flags;
|
405
|
+
}
|
406
|
+
|
407
|
+
static int rugged__status_cb(const char *path, unsigned int flags, void *payload)
|
408
|
+
{
|
409
|
+
rb_funcall((VALUE)payload, rb_intern("call"), 2,
|
410
|
+
rugged_str_new2(path, NULL),
|
411
|
+
flags_to_rb(flags)
|
412
|
+
);
|
413
|
+
|
414
|
+
return GIT_SUCCESS;
|
415
|
+
}
|
416
|
+
|
417
|
+
static VALUE rb_git_repo_status(int argc, VALUE *argv, VALUE self)
|
418
|
+
{
|
419
|
+
int error;
|
420
|
+
VALUE rb_path;
|
421
|
+
git_repository *repo;
|
422
|
+
|
423
|
+
Data_Get_Struct(self, git_repository, repo);
|
424
|
+
|
425
|
+
if (rb_scan_args(argc, argv, "01", &rb_path) == 1) {
|
426
|
+
unsigned int flags;
|
427
|
+
Check_Type(rb_path, T_STRING);
|
428
|
+
error = git_status_file(&flags, repo, StringValueCStr(rb_path));
|
429
|
+
rugged_exception_check(error);
|
430
|
+
|
431
|
+
return flags_to_rb(flags);
|
432
|
+
}
|
433
|
+
|
434
|
+
if (!rb_block_given_p())
|
435
|
+
rb_raise(rb_eRuntimeError,
|
436
|
+
"A block was expected for iterating through "
|
437
|
+
"the repository contents.");
|
438
|
+
|
439
|
+
error = git_status_foreach(
|
440
|
+
repo,
|
441
|
+
&rugged__status_cb,
|
442
|
+
(void *)rb_block_proc()
|
443
|
+
);
|
444
|
+
|
445
|
+
rugged_exception_check(error);
|
446
|
+
return Qnil;
|
447
|
+
}
|
448
|
+
|
449
|
+
void Init_rugged_repo()
|
450
|
+
{
|
451
|
+
rb_cRuggedRepo = rb_define_class_under(rb_mRugged, "Repository", rb_cObject);
|
452
|
+
|
453
|
+
rb_define_singleton_method(rb_cRuggedRepo, "new", rb_git_repo_new, 1);
|
454
|
+
rb_define_singleton_method(rb_cRuggedRepo, "hash", rb_git_repo_hash, 2);
|
455
|
+
rb_define_singleton_method(rb_cRuggedRepo, "hash_file", rb_git_repo_hashfile, 2);
|
456
|
+
rb_define_singleton_method(rb_cRuggedRepo, "init_at", rb_git_repo_init_at, 2);
|
457
|
+
rb_define_singleton_method(rb_cRuggedRepo, "discover", rb_git_repo_discover, -1);
|
458
|
+
|
459
|
+
rb_define_method(rb_cRuggedRepo, "exists", rb_git_repo_exists, 1);
|
460
|
+
rb_define_method(rb_cRuggedRepo, "read", rb_git_repo_read, 1);
|
461
|
+
rb_define_method(rb_cRuggedRepo, "write", rb_git_repo_write, 2);
|
462
|
+
rb_define_method(rb_cRuggedRepo, "path", rb_git_repo_path, 0);
|
463
|
+
rb_define_method(rb_cRuggedRepo, "workdir", rb_git_repo_workdir, 0);
|
464
|
+
rb_define_method(rb_cRuggedRepo, "workdir=", rb_git_repo_set_workdir, 1);
|
465
|
+
rb_define_method(rb_cRuggedRepo, "status", rb_git_repo_status, -1);
|
466
|
+
|
467
|
+
rb_define_method(rb_cRuggedRepo, "index", rb_git_repo_get_index, 0);
|
468
|
+
rb_define_method(rb_cRuggedRepo, "index=", rb_git_repo_set_index, 1);
|
469
|
+
rb_define_method(rb_cRuggedRepo, "config", rb_git_repo_get_config, 0);
|
470
|
+
rb_define_method(rb_cRuggedRepo, "config=", rb_git_repo_set_config, 1);
|
471
|
+
|
472
|
+
rb_define_method(rb_cRuggedRepo, "bare?", rb_git_repo_is_bare, 0);
|
473
|
+
rb_define_method(rb_cRuggedRepo, "empty?", rb_git_repo_is_empty, 0);
|
474
|
+
rb_define_method(rb_cRuggedRepo, "head_detached?", rb_git_repo_head_detached, 0);
|
475
|
+
rb_define_method(rb_cRuggedRepo, "head_orphan?", rb_git_repo_head_orphan, 0);
|
476
|
+
|
477
|
+
rb_cRuggedOdbObject = rb_define_class_under(rb_mRugged, "OdbObject", rb_cObject);
|
478
|
+
rb_define_method(rb_cRuggedOdbObject, "data", rb_git_odbobj_data, 0);
|
479
|
+
rb_define_method(rb_cRuggedOdbObject, "len", rb_git_odbobj_size, 0);
|
480
|
+
rb_define_method(rb_cRuggedOdbObject, "type", rb_git_odbobj_type, 0);
|
481
|
+
rb_define_method(rb_cRuggedOdbObject, "hash", rb_git_odbobj_hash, 0);
|
482
|
+
}
|