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,203 @@
|
|
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_cRuggedTag;
|
29
|
+
extern VALUE rb_cRuggedTree;
|
30
|
+
extern VALUE rb_cRuggedCommit;
|
31
|
+
extern VALUE rb_cRuggedBlob;
|
32
|
+
extern VALUE rb_cRuggedRepo;
|
33
|
+
|
34
|
+
VALUE rb_cRuggedObject;
|
35
|
+
|
36
|
+
git_object *rugged_object_load(git_repository *repo, VALUE object_value, git_otype type)
|
37
|
+
{
|
38
|
+
git_object *object = NULL;
|
39
|
+
|
40
|
+
if (TYPE(object_value) == T_STRING) {
|
41
|
+
git_oid oid;
|
42
|
+
int error;
|
43
|
+
|
44
|
+
error = git_oid_fromstr(&oid, StringValueCStr(object_value));
|
45
|
+
rugged_exception_check(error);
|
46
|
+
|
47
|
+
error = git_object_lookup(&object, repo, &oid, type);
|
48
|
+
rugged_exception_check(error);
|
49
|
+
|
50
|
+
} else if (rb_obj_is_kind_of(object_value, rb_cRuggedObject)) {
|
51
|
+
Data_Get_Struct(object_value, git_object, object);
|
52
|
+
|
53
|
+
if (type != GIT_OBJ_ANY && git_object_type(object) != type)
|
54
|
+
rb_raise(rb_eTypeError, "Object is not of the required type");
|
55
|
+
} else {
|
56
|
+
rb_raise(rb_eTypeError, "Invalid GIT object; an object reference must be a SHA1 id or an object itself");
|
57
|
+
}
|
58
|
+
|
59
|
+
assert(object);
|
60
|
+
return object;
|
61
|
+
}
|
62
|
+
|
63
|
+
static void rb_git_object__free(git_object *object)
|
64
|
+
{
|
65
|
+
git_object_free(object);
|
66
|
+
}
|
67
|
+
|
68
|
+
VALUE rugged_object_new(VALUE owner, git_object *object)
|
69
|
+
{
|
70
|
+
VALUE klass, rb_object;
|
71
|
+
|
72
|
+
switch (git_object_type(object))
|
73
|
+
{
|
74
|
+
case GIT_OBJ_COMMIT:
|
75
|
+
klass = rb_cRuggedCommit;
|
76
|
+
break;
|
77
|
+
|
78
|
+
case GIT_OBJ_TAG:
|
79
|
+
klass = rb_cRuggedTag;
|
80
|
+
break;
|
81
|
+
|
82
|
+
case GIT_OBJ_TREE:
|
83
|
+
klass = rb_cRuggedTree;
|
84
|
+
break;
|
85
|
+
|
86
|
+
case GIT_OBJ_BLOB:
|
87
|
+
klass = rb_cRuggedBlob;
|
88
|
+
break;
|
89
|
+
|
90
|
+
default:
|
91
|
+
rb_raise(rb_eTypeError, "Invalid type for Rugged::Object");
|
92
|
+
return Qnil; /* never reached */
|
93
|
+
}
|
94
|
+
|
95
|
+
rb_object = Data_Wrap_Struct(klass, NULL, &rb_git_object__free, object);
|
96
|
+
rugged_set_owner(rb_object, owner);
|
97
|
+
return rb_object;
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
static git_otype class2otype(VALUE klass)
|
102
|
+
{
|
103
|
+
if (klass == rb_cRuggedCommit)
|
104
|
+
return GIT_OBJ_COMMIT;
|
105
|
+
|
106
|
+
if (klass == rb_cRuggedTag)
|
107
|
+
return GIT_OBJ_TAG;
|
108
|
+
|
109
|
+
if (klass == rb_cRuggedBlob)
|
110
|
+
return GIT_OBJ_BLOB;
|
111
|
+
|
112
|
+
if (klass == rb_cRuggedTree)
|
113
|
+
return GIT_OBJ_TREE;
|
114
|
+
|
115
|
+
return GIT_OBJ_BAD;
|
116
|
+
}
|
117
|
+
|
118
|
+
VALUE rb_git_object_lookup(VALUE klass, VALUE rb_repo, VALUE rb_hex)
|
119
|
+
{
|
120
|
+
git_object *object;
|
121
|
+
git_otype type;
|
122
|
+
git_oid oid;
|
123
|
+
int error;
|
124
|
+
int oid_length;
|
125
|
+
|
126
|
+
git_repository *repo;
|
127
|
+
|
128
|
+
type = class2otype(rb_obj_class(klass));
|
129
|
+
|
130
|
+
if (type == GIT_OBJ_BAD)
|
131
|
+
type = GIT_OBJ_ANY;
|
132
|
+
|
133
|
+
Check_Type(rb_hex, T_STRING);
|
134
|
+
oid_length = (int)RSTRING_LEN(rb_hex);
|
135
|
+
|
136
|
+
if (!rb_obj_is_instance_of(rb_repo, rb_cRuggedRepo))
|
137
|
+
rb_raise(rb_eTypeError, "Expecting a Rugged Repository");
|
138
|
+
|
139
|
+
if (oid_length > GIT_OID_HEXSZ)
|
140
|
+
rb_raise(rb_eTypeError, "The given OID is too long");
|
141
|
+
|
142
|
+
Data_Get_Struct(rb_repo, git_repository, repo);
|
143
|
+
|
144
|
+
error = git_oid_fromstrn(&oid, RSTRING_PTR(rb_hex), oid_length);
|
145
|
+
rugged_exception_check(error);
|
146
|
+
|
147
|
+
if (oid_length < GIT_OID_HEXSZ)
|
148
|
+
error = git_object_lookup_prefix(&object, repo, &oid, oid_length, type);
|
149
|
+
else
|
150
|
+
error = git_object_lookup(&object, repo, &oid, type);
|
151
|
+
|
152
|
+
rugged_exception_check(error);
|
153
|
+
|
154
|
+
return rugged_object_new(rb_repo, object);
|
155
|
+
}
|
156
|
+
|
157
|
+
static VALUE rb_git_object_equal(VALUE self, VALUE other)
|
158
|
+
{
|
159
|
+
git_object *a, *b;
|
160
|
+
|
161
|
+
if (!rb_obj_is_kind_of(other, rb_cRuggedObject))
|
162
|
+
return Qfalse;
|
163
|
+
|
164
|
+
Data_Get_Struct(self, git_object, a);
|
165
|
+
Data_Get_Struct(other, git_object, b);
|
166
|
+
|
167
|
+
return git_oid_cmp(git_object_id(a), git_object_id(b)) == 0 ? Qtrue : Qfalse;
|
168
|
+
}
|
169
|
+
|
170
|
+
static VALUE rb_git_object_oid_GET(VALUE self)
|
171
|
+
{
|
172
|
+
git_object *object;
|
173
|
+
Data_Get_Struct(self, git_object, object);
|
174
|
+
return rugged_create_oid(git_object_id(object));
|
175
|
+
}
|
176
|
+
|
177
|
+
static VALUE rb_git_object_type_GET(VALUE self)
|
178
|
+
{
|
179
|
+
git_object *object;
|
180
|
+
Data_Get_Struct(self, git_object, object);
|
181
|
+
|
182
|
+
return rugged_str_new2(git_object_type2string(git_object_type(object)), NULL);
|
183
|
+
}
|
184
|
+
|
185
|
+
static VALUE rb_git_object_read_raw(VALUE self)
|
186
|
+
{
|
187
|
+
git_object *object;
|
188
|
+
Data_Get_Struct(self, git_object, object);
|
189
|
+
|
190
|
+
return rugged_raw_read(git_object_owner(object), git_object_id(object));
|
191
|
+
}
|
192
|
+
|
193
|
+
void Init_rugged_object()
|
194
|
+
{
|
195
|
+
rb_cRuggedObject = rb_define_class_under(rb_mRugged, "Object", rb_cObject);
|
196
|
+
rb_define_singleton_method(rb_cRuggedObject, "lookup", rb_git_object_lookup, 2);
|
197
|
+
rb_define_singleton_method(rb_cRuggedObject, "new", rb_git_object_lookup, 2);
|
198
|
+
|
199
|
+
rb_define_method(rb_cRuggedObject, "read_raw", rb_git_object_read_raw, 0);
|
200
|
+
rb_define_method(rb_cRuggedObject, "==", rb_git_object_equal, 1);
|
201
|
+
rb_define_method(rb_cRuggedObject, "oid", rb_git_object_oid_GET, 0);
|
202
|
+
rb_define_method(rb_cRuggedObject, "type", rb_git_object_type_GET, 0);
|
203
|
+
}
|
@@ -0,0 +1,401 @@
|
|
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
|
+
#define UNPACK_REFERENCE(_rb_obj, _rugged_obj) {\
|
28
|
+
if (DATA_PTR(_rb_obj) == NULL)\
|
29
|
+
rb_raise(rb_eRuntimeError,\
|
30
|
+
"This Git Reference has been deleted and no longer exists on the repository");\
|
31
|
+
Data_Get_Struct(_rb_obj, git_reference, _rugged_obj);\
|
32
|
+
}
|
33
|
+
|
34
|
+
extern VALUE rb_mRugged;
|
35
|
+
extern VALUE rb_cRuggedRepo;
|
36
|
+
VALUE rb_cRuggedReference;
|
37
|
+
|
38
|
+
void rb_git_ref__free(git_reference *ref)
|
39
|
+
{
|
40
|
+
git_reference_free(ref);
|
41
|
+
}
|
42
|
+
|
43
|
+
VALUE rugged_ref_new(VALUE klass, VALUE owner, git_reference *ref)
|
44
|
+
{
|
45
|
+
VALUE rb_ref = Data_Wrap_Struct(klass, NULL, &rb_git_ref__free, ref);
|
46
|
+
rugged_set_owner(rb_ref, owner);
|
47
|
+
return rb_ref;
|
48
|
+
}
|
49
|
+
|
50
|
+
static VALUE rb_git_ref_packall(VALUE klass, VALUE rb_repo)
|
51
|
+
{
|
52
|
+
git_repository *repo;
|
53
|
+
int error;
|
54
|
+
|
55
|
+
if (!rb_obj_is_kind_of(rb_repo, rb_cRuggedRepo))
|
56
|
+
rb_raise(rb_eTypeError, "Expecting a Rugged::Repository instance");
|
57
|
+
|
58
|
+
Data_Get_Struct(rb_repo, git_repository, repo);
|
59
|
+
|
60
|
+
error = git_reference_packall(repo);
|
61
|
+
rugged_exception_check(error);
|
62
|
+
|
63
|
+
return Qnil;
|
64
|
+
}
|
65
|
+
|
66
|
+
int ref_foreach__list(const char *ref_name, void *opaque)
|
67
|
+
{
|
68
|
+
rb_ary_push((VALUE)opaque, rugged_str_new2(ref_name, NULL));
|
69
|
+
return GIT_SUCCESS;
|
70
|
+
}
|
71
|
+
|
72
|
+
int ref_foreach__block(const char *ref_name, void *opaque)
|
73
|
+
{
|
74
|
+
rb_funcall((VALUE)opaque, rb_intern("call"), 1, rugged_str_new2(ref_name, NULL));
|
75
|
+
return GIT_SUCCESS;
|
76
|
+
}
|
77
|
+
|
78
|
+
static VALUE rb_git_ref_each(int argc, VALUE *argv, VALUE self)
|
79
|
+
{
|
80
|
+
git_repository *repo;
|
81
|
+
int error, flags = 0;
|
82
|
+
VALUE rb_repo, rb_list, rb_block;
|
83
|
+
|
84
|
+
rb_scan_args(argc, argv, "11&", &rb_repo, &rb_list, &rb_block);
|
85
|
+
|
86
|
+
if (!rb_block_given_p())
|
87
|
+
return rb_funcall(self, rb_intern("to_enum"), 3, CSTR2SYM("each"), rb_repo, rb_list);
|
88
|
+
|
89
|
+
if (!rb_obj_is_kind_of(rb_repo, rb_cRuggedRepo))
|
90
|
+
rb_raise(rb_eTypeError, "Expecting a Rugged::Repository instance");
|
91
|
+
|
92
|
+
Data_Get_Struct(rb_repo, git_repository, repo);
|
93
|
+
|
94
|
+
if (!NIL_P(rb_list)) {
|
95
|
+
ID list;
|
96
|
+
|
97
|
+
Check_Type(rb_list, T_SYMBOL);
|
98
|
+
list = SYM2ID(rb_list);
|
99
|
+
|
100
|
+
if (list == rb_intern("all"))
|
101
|
+
flags = GIT_REF_LISTALL;
|
102
|
+
else if (list == rb_intern("direct"))
|
103
|
+
flags = GIT_REF_OID|GIT_REF_PACKED;
|
104
|
+
else if (list == rb_intern("symbolic"))
|
105
|
+
flags = GIT_REF_SYMBOLIC|GIT_REF_PACKED;
|
106
|
+
} else {
|
107
|
+
flags = GIT_REF_LISTALL;
|
108
|
+
}
|
109
|
+
|
110
|
+
error = git_reference_foreach(repo, flags, &ref_foreach__block, (void *)rb_block);
|
111
|
+
rugged_exception_check(error);
|
112
|
+
return Qnil;
|
113
|
+
}
|
114
|
+
|
115
|
+
static VALUE rb_git_ref_lookup(VALUE klass, VALUE rb_repo, VALUE rb_name)
|
116
|
+
{
|
117
|
+
git_repository *repo;
|
118
|
+
git_reference *ref;
|
119
|
+
int error;
|
120
|
+
|
121
|
+
Data_Get_Struct(rb_repo, git_repository, repo);
|
122
|
+
Check_Type(rb_name, T_STRING);
|
123
|
+
|
124
|
+
error = git_reference_lookup(&ref, repo, StringValueCStr(rb_name));
|
125
|
+
rugged_exception_check(error);
|
126
|
+
|
127
|
+
return rugged_ref_new(klass, rb_repo, ref);
|
128
|
+
}
|
129
|
+
|
130
|
+
static VALUE rb_git_ref_create(int argc, VALUE *argv, VALUE klass)
|
131
|
+
{
|
132
|
+
VALUE rb_repo, rb_name, rb_target, rb_force;
|
133
|
+
git_repository *repo;
|
134
|
+
git_reference *ref;
|
135
|
+
git_oid oid;
|
136
|
+
int error, force = 0;
|
137
|
+
|
138
|
+
rb_scan_args(argc, argv, "31", &rb_repo, &rb_name, &rb_target, &rb_force);
|
139
|
+
|
140
|
+
Data_Get_Struct(rb_repo, git_repository, repo);
|
141
|
+
Check_Type(rb_name, T_STRING);
|
142
|
+
Check_Type(rb_target, T_STRING);
|
143
|
+
|
144
|
+
if (!NIL_P(rb_force))
|
145
|
+
force = rugged_parse_bool(rb_force);
|
146
|
+
|
147
|
+
if (git_oid_fromstr(&oid, StringValueCStr(rb_target)) == GIT_SUCCESS) {
|
148
|
+
error = git_reference_create_oid(
|
149
|
+
&ref, repo, StringValueCStr(rb_name), &oid, force);
|
150
|
+
} else {
|
151
|
+
error = git_reference_create_symbolic(
|
152
|
+
&ref, repo, StringValueCStr(rb_name), RSTRING_PTR(rb_target), force);
|
153
|
+
}
|
154
|
+
|
155
|
+
rugged_exception_check(error);
|
156
|
+
|
157
|
+
return rugged_ref_new(klass, rb_repo, ref);
|
158
|
+
}
|
159
|
+
|
160
|
+
static VALUE rb_git_ref_target(VALUE self)
|
161
|
+
{
|
162
|
+
git_reference *ref;
|
163
|
+
|
164
|
+
UNPACK_REFERENCE(self, ref);
|
165
|
+
|
166
|
+
if (git_reference_type(ref) == GIT_REF_OID) {
|
167
|
+
return rugged_create_oid(git_reference_oid(ref));
|
168
|
+
} else {
|
169
|
+
return rugged_str_new2(git_reference_target(ref), NULL);
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
static VALUE rb_git_ref_set_target(VALUE self, VALUE rb_target)
|
174
|
+
{
|
175
|
+
git_reference *ref;
|
176
|
+
int error;
|
177
|
+
|
178
|
+
UNPACK_REFERENCE(self, ref);
|
179
|
+
Check_Type(rb_target, T_STRING);
|
180
|
+
|
181
|
+
if (git_reference_type(ref) == GIT_REF_OID) {
|
182
|
+
git_oid target;
|
183
|
+
|
184
|
+
error = git_oid_fromstr(&target, StringValueCStr(rb_target));
|
185
|
+
rugged_exception_check(error);
|
186
|
+
|
187
|
+
error = git_reference_set_oid(ref, &target);
|
188
|
+
} else {
|
189
|
+
error = git_reference_set_target(ref, StringValueCStr(rb_target));
|
190
|
+
}
|
191
|
+
|
192
|
+
rugged_exception_check(error);
|
193
|
+
return Qnil;
|
194
|
+
}
|
195
|
+
|
196
|
+
static VALUE rb_git_ref_type(VALUE self)
|
197
|
+
{
|
198
|
+
git_reference *ref;
|
199
|
+
UNPACK_REFERENCE(self, ref);
|
200
|
+
return rugged_str_new2(git_object_type2string(git_reference_type(ref)), NULL);
|
201
|
+
}
|
202
|
+
|
203
|
+
static VALUE rb_git_ref_packed(VALUE self)
|
204
|
+
{
|
205
|
+
git_reference *ref;
|
206
|
+
UNPACK_REFERENCE(self, ref);
|
207
|
+
|
208
|
+
return git_reference_is_packed(ref) ? Qtrue : Qfalse;
|
209
|
+
}
|
210
|
+
|
211
|
+
static VALUE rb_git_ref_reload(VALUE self)
|
212
|
+
{
|
213
|
+
int error;
|
214
|
+
git_reference *ref;
|
215
|
+
UNPACK_REFERENCE(self, ref);
|
216
|
+
|
217
|
+
error = git_reference_reload(ref);
|
218
|
+
|
219
|
+
/* If reload fails, the reference is invalidated */
|
220
|
+
if (error < GIT_SUCCESS)
|
221
|
+
ref = NULL;
|
222
|
+
|
223
|
+
rugged_exception_check(error);
|
224
|
+
return Qnil;
|
225
|
+
}
|
226
|
+
|
227
|
+
static VALUE rb_git_ref_name(VALUE self)
|
228
|
+
{
|
229
|
+
git_reference *ref;
|
230
|
+
UNPACK_REFERENCE(self, ref);
|
231
|
+
return rugged_str_new2(git_reference_name(ref), NULL);
|
232
|
+
}
|
233
|
+
|
234
|
+
static VALUE rb_git_ref_resolve(VALUE self)
|
235
|
+
{
|
236
|
+
git_reference *ref;
|
237
|
+
git_reference *resolved;
|
238
|
+
int error;
|
239
|
+
|
240
|
+
UNPACK_REFERENCE(self, ref);
|
241
|
+
|
242
|
+
error = git_reference_resolve(&resolved, ref);
|
243
|
+
rugged_exception_check(error);
|
244
|
+
|
245
|
+
return rugged_ref_new(rb_cRuggedReference, rugged_owner(self), resolved);
|
246
|
+
}
|
247
|
+
|
248
|
+
static VALUE rb_git_ref_rename(int argc, VALUE *argv, VALUE self)
|
249
|
+
{
|
250
|
+
git_reference *ref;
|
251
|
+
VALUE rb_name, rb_force;
|
252
|
+
int error, force = 0;
|
253
|
+
|
254
|
+
UNPACK_REFERENCE(self, ref);
|
255
|
+
rb_scan_args(argc, argv, "11", &rb_name, &rb_force);
|
256
|
+
|
257
|
+
Check_Type(rb_name, T_STRING);
|
258
|
+
if (!NIL_P(rb_force))
|
259
|
+
force = rugged_parse_bool(rb_force);
|
260
|
+
|
261
|
+
error = git_reference_rename(ref, StringValueCStr(rb_name), force);
|
262
|
+
rugged_exception_check(error);
|
263
|
+
|
264
|
+
return Qnil;
|
265
|
+
}
|
266
|
+
|
267
|
+
static VALUE rb_git_ref_delete(VALUE self)
|
268
|
+
{
|
269
|
+
git_reference *ref;
|
270
|
+
int error;
|
271
|
+
|
272
|
+
UNPACK_REFERENCE(self, ref);
|
273
|
+
|
274
|
+
error = git_reference_delete(ref);
|
275
|
+
rugged_exception_check(error);
|
276
|
+
|
277
|
+
DATA_PTR(self) = NULL; /* this reference has been free'd */
|
278
|
+
rugged_set_owner(self, Qnil); /* and is no longer owned */
|
279
|
+
return Qnil;
|
280
|
+
}
|
281
|
+
|
282
|
+
static VALUE reflog_entry_new(const git_reflog_entry *entry)
|
283
|
+
{
|
284
|
+
VALUE rb_entry = rb_hash_new();
|
285
|
+
|
286
|
+
rb_hash_aset(rb_entry,
|
287
|
+
CSTR2SYM("oid_old"),
|
288
|
+
rugged_create_oid(git_reflog_entry_oidold(entry))
|
289
|
+
);
|
290
|
+
|
291
|
+
rb_hash_aset(rb_entry,
|
292
|
+
CSTR2SYM("oid_new"),
|
293
|
+
rugged_create_oid(git_reflog_entry_oidnew(entry))
|
294
|
+
);
|
295
|
+
|
296
|
+
rb_hash_aset(rb_entry,
|
297
|
+
CSTR2SYM("committer"),
|
298
|
+
rugged_signature_new(git_reflog_entry_committer(entry), NULL)
|
299
|
+
);
|
300
|
+
|
301
|
+
rb_hash_aset(rb_entry,
|
302
|
+
CSTR2SYM("message"),
|
303
|
+
rugged_str_new2(git_reflog_entry_msg(entry), NULL)
|
304
|
+
);
|
305
|
+
|
306
|
+
return rb_entry;
|
307
|
+
}
|
308
|
+
|
309
|
+
static VALUE rb_git_reflog(VALUE self)
|
310
|
+
{
|
311
|
+
git_reflog *reflog;
|
312
|
+
git_reference *ref;
|
313
|
+
int error;
|
314
|
+
VALUE rb_log;
|
315
|
+
unsigned int i, ref_count;
|
316
|
+
|
317
|
+
UNPACK_REFERENCE(self, ref);
|
318
|
+
|
319
|
+
error = git_reflog_read(&reflog, ref);
|
320
|
+
rugged_exception_check(error);
|
321
|
+
|
322
|
+
ref_count = git_reflog_entrycount(reflog);
|
323
|
+
rb_log = rb_ary_new2(ref_count);
|
324
|
+
|
325
|
+
for (i = 0; i < ref_count; ++i) {
|
326
|
+
const git_reflog_entry *entry =
|
327
|
+
git_reflog_entry_byindex(reflog, i);
|
328
|
+
|
329
|
+
rb_ary_push(rb_log, reflog_entry_new(entry));
|
330
|
+
}
|
331
|
+
|
332
|
+
git_reflog_free(reflog);
|
333
|
+
return rb_log;
|
334
|
+
}
|
335
|
+
|
336
|
+
static VALUE rb_git_reflog_write(
|
337
|
+
VALUE self,
|
338
|
+
VALUE rb_oid_old,
|
339
|
+
VALUE rb_committer,
|
340
|
+
VALUE rb_message)
|
341
|
+
{
|
342
|
+
git_reference *ref;
|
343
|
+
int error;
|
344
|
+
git_signature *committer;
|
345
|
+
const char *message = NULL;
|
346
|
+
git_oid oid_old;
|
347
|
+
|
348
|
+
UNPACK_REFERENCE(self, ref);
|
349
|
+
|
350
|
+
if (!NIL_P(rb_message)) {
|
351
|
+
Check_Type(rb_message, T_STRING);
|
352
|
+
message = StringValueCStr(rb_message);
|
353
|
+
}
|
354
|
+
|
355
|
+
if (!NIL_P(rb_oid_old)) {
|
356
|
+
Check_Type(rb_oid_old, T_STRING);
|
357
|
+
error = git_oid_fromstr(&oid_old, StringValueCStr(rb_oid_old));
|
358
|
+
rugged_exception_check(error);
|
359
|
+
}
|
360
|
+
|
361
|
+
committer = rugged_signature_get(rb_committer);
|
362
|
+
|
363
|
+
error = git_reflog_write(
|
364
|
+
ref,
|
365
|
+
NIL_P(rb_oid_old) ? NULL : &oid_old,
|
366
|
+
committer,
|
367
|
+
message
|
368
|
+
);
|
369
|
+
|
370
|
+
git_signature_free(committer);
|
371
|
+
|
372
|
+
rugged_exception_check(error);
|
373
|
+
return Qnil;
|
374
|
+
}
|
375
|
+
|
376
|
+
|
377
|
+
void Init_rugged_reference()
|
378
|
+
{
|
379
|
+
rb_cRuggedReference = rb_define_class_under(rb_mRugged, "Reference", rb_cObject);
|
380
|
+
|
381
|
+
rb_define_singleton_method(rb_cRuggedReference, "lookup", rb_git_ref_lookup, 2);
|
382
|
+
rb_define_singleton_method(rb_cRuggedReference, "create", rb_git_ref_create, -1);
|
383
|
+
rb_define_singleton_method(rb_cRuggedReference, "pack_all", rb_git_ref_packall, 1);
|
384
|
+
rb_define_singleton_method(rb_cRuggedReference, "each", rb_git_ref_each, -1);
|
385
|
+
|
386
|
+
rb_define_method(rb_cRuggedReference, "target", rb_git_ref_target, 0);
|
387
|
+
rb_define_method(rb_cRuggedReference, "target=", rb_git_ref_set_target, 1);
|
388
|
+
|
389
|
+
rb_define_method(rb_cRuggedReference, "type", rb_git_ref_type, 0);
|
390
|
+
|
391
|
+
rb_define_method(rb_cRuggedReference, "name", rb_git_ref_name, 0);
|
392
|
+
rb_define_method(rb_cRuggedReference, "rename", rb_git_ref_rename, -1);
|
393
|
+
|
394
|
+
rb_define_method(rb_cRuggedReference, "reload!", rb_git_ref_reload, 0);
|
395
|
+
rb_define_method(rb_cRuggedReference, "resolve", rb_git_ref_resolve, 0);
|
396
|
+
rb_define_method(rb_cRuggedReference, "delete!", rb_git_ref_delete, 0);
|
397
|
+
|
398
|
+
rb_define_method(rb_cRuggedReference, "packed?", rb_git_ref_packed, 0);
|
399
|
+
rb_define_method(rb_cRuggedReference, "log", rb_git_reflog, 0);
|
400
|
+
rb_define_method(rb_cRuggedReference, "log!", rb_git_reflog_write, 3);
|
401
|
+
}
|