rugged 0.19.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/README.md +151 -25
- data/ext/rugged/extconf.rb +48 -27
- data/ext/rugged/rugged.c +107 -35
- data/ext/rugged/rugged.h +44 -8
- data/ext/rugged/rugged_blame.c +292 -0
- data/ext/rugged/rugged_blob.c +84 -31
- data/ext/rugged/rugged_branch.c +90 -223
- data/ext/rugged/rugged_branch_collection.c +445 -0
- data/ext/rugged/rugged_commit.c +190 -9
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_cred.c +125 -0
- data/ext/rugged/rugged_diff.c +267 -94
- data/ext/rugged/rugged_diff_delta.c +14 -3
- data/ext/rugged/rugged_diff_hunk.c +31 -28
- data/ext/rugged/rugged_diff_line.c +21 -17
- data/ext/rugged/rugged_index.c +326 -6
- data/ext/rugged/rugged_note.c +39 -34
- data/ext/rugged/rugged_object.c +9 -9
- data/ext/rugged/rugged_patch.c +245 -0
- data/ext/rugged/rugged_reference.c +67 -332
- data/ext/rugged/rugged_reference_collection.c +490 -0
- data/ext/rugged/rugged_remote.c +447 -351
- data/ext/rugged/rugged_remote_collection.c +285 -0
- data/ext/rugged/rugged_repo.c +752 -203
- data/ext/rugged/rugged_revwalk.c +119 -27
- data/ext/rugged/rugged_settings.c +48 -1
- data/ext/rugged/rugged_signature.c +30 -16
- data/ext/rugged/rugged_tag.c +86 -191
- data/ext/rugged/rugged_tag_collection.c +279 -0
- data/ext/rugged/rugged_tree.c +159 -22
- data/lib/rugged/branch.rb +8 -17
- data/lib/rugged/credentials.rb +43 -0
- data/lib/rugged/diff/delta.rb +1 -2
- data/lib/rugged/diff/hunk.rb +4 -9
- data/lib/rugged/diff/line.rb +23 -3
- data/lib/rugged/diff.rb +3 -1
- data/lib/rugged/patch.rb +26 -0
- data/lib/rugged/reference.rb +1 -3
- data/lib/rugged/remote.rb +0 -9
- data/lib/rugged/repository.rb +70 -13
- data/lib/rugged/tag.rb +23 -18
- data/lib/rugged/tree.rb +7 -0
- data/lib/rugged/version.rb +1 -1
- data/lib/rugged.rb +8 -1
- data/vendor/libgit2/AUTHORS +75 -0
- data/vendor/libgit2/CMakeLists.txt +490 -0
- data/vendor/libgit2/COPYING +920 -0
- data/vendor/libgit2/Makefile.embed +25 -7
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +16 -0
- data/vendor/libgit2/cmake/Modules/FindHTTP_Parser.cmake +39 -0
- data/vendor/libgit2/cmake/Modules/FindIconv.cmake +43 -0
- data/vendor/libgit2/cmake/Modules/FindLIBSSH2.cmake +44 -0
- data/vendor/libgit2/deps/http-parser/LICENSE-MIT +23 -0
- data/vendor/libgit2/deps/regex/regex.c +10 -3
- data/vendor/libgit2/include/git2/attr.h +2 -1
- data/vendor/libgit2/include/git2/blame.h +213 -0
- data/vendor/libgit2/include/git2/blob.h +57 -29
- data/vendor/libgit2/include/git2/branch.h +56 -44
- data/vendor/libgit2/include/git2/buffer.h +112 -0
- data/vendor/libgit2/include/git2/checkout.h +72 -37
- data/vendor/libgit2/include/git2/cherrypick.h +87 -0
- data/vendor/libgit2/include/git2/clone.h +153 -56
- data/vendor/libgit2/include/git2/commit.h +82 -12
- data/vendor/libgit2/include/git2/common.h +31 -19
- data/vendor/libgit2/include/git2/config.h +124 -19
- data/vendor/libgit2/include/git2/cred_helpers.h +1 -1
- data/vendor/libgit2/include/git2/diff.h +636 -494
- data/vendor/libgit2/include/git2/errors.h +48 -15
- data/vendor/libgit2/include/git2/filter.h +149 -0
- data/vendor/libgit2/include/git2/graph.h +14 -0
- data/vendor/libgit2/include/git2/index.h +95 -54
- data/vendor/libgit2/include/git2/indexer.h +15 -9
- data/vendor/libgit2/include/git2/merge.h +402 -39
- data/vendor/libgit2/include/git2/message.h +9 -14
- data/vendor/libgit2/include/git2/net.h +5 -0
- data/vendor/libgit2/include/git2/notes.h +6 -6
- data/vendor/libgit2/include/git2/object.h +34 -2
- data/vendor/libgit2/include/git2/odb.h +77 -14
- data/vendor/libgit2/include/git2/odb_backend.h +50 -6
- data/vendor/libgit2/include/git2/oid.h +4 -8
- data/vendor/libgit2/include/git2/pack.h +58 -4
- data/vendor/libgit2/include/git2/patch.h +277 -0
- data/vendor/libgit2/include/git2/pathspec.h +263 -0
- data/vendor/libgit2/include/git2/push.h +55 -5
- data/vendor/libgit2/include/git2/reflog.h +11 -8
- data/vendor/libgit2/include/git2/refs.h +219 -33
- data/vendor/libgit2/include/git2/refspec.h +3 -4
- data/vendor/libgit2/include/git2/remote.h +216 -76
- data/vendor/libgit2/include/git2/repository.h +85 -40
- data/vendor/libgit2/include/git2/reset.h +15 -4
- data/vendor/libgit2/include/git2/revert.h +86 -0
- data/vendor/libgit2/include/git2/revparse.h +27 -16
- data/vendor/libgit2/include/git2/revwalk.h +44 -6
- data/vendor/libgit2/include/git2/signature.h +17 -3
- data/vendor/libgit2/include/git2/stash.h +8 -12
- data/vendor/libgit2/include/git2/status.h +67 -18
- data/vendor/libgit2/include/git2/submodule.h +100 -85
- data/vendor/libgit2/include/git2/sys/commit.h +38 -4
- data/vendor/libgit2/include/git2/sys/config.h +44 -3
- data/vendor/libgit2/include/git2/sys/diff.h +91 -0
- data/vendor/libgit2/include/git2/sys/filter.h +301 -0
- data/vendor/libgit2/include/git2/sys/index.h +0 -2
- data/vendor/libgit2/include/git2/sys/mempack.h +85 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +33 -11
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +51 -5
- data/vendor/libgit2/include/git2/sys/reflog.h +21 -0
- data/vendor/libgit2/include/git2/sys/refs.h +2 -2
- data/vendor/libgit2/include/git2/sys/repository.h +19 -1
- data/vendor/libgit2/include/git2/transport.h +216 -75
- data/vendor/libgit2/include/git2/tree.h +32 -11
- data/vendor/libgit2/include/git2/types.h +124 -10
- data/vendor/libgit2/include/git2/version.h +4 -2
- data/vendor/libgit2/include/git2.h +41 -40
- data/vendor/libgit2/libgit2.pc.in +10 -0
- data/vendor/libgit2/src/array.h +16 -8
- data/vendor/libgit2/src/attr.c +140 -402
- data/vendor/libgit2/src/attr.h +1 -33
- data/vendor/libgit2/src/attr_file.c +298 -135
- data/vendor/libgit2/src/attr_file.h +61 -22
- data/vendor/libgit2/src/attrcache.c +449 -0
- data/vendor/libgit2/src/attrcache.h +38 -6
- data/vendor/libgit2/src/bitvec.h +75 -0
- data/vendor/libgit2/src/blame.c +488 -0
- data/vendor/libgit2/src/blame.h +93 -0
- data/vendor/libgit2/src/blame_git.c +624 -0
- data/vendor/libgit2/src/blame_git.h +20 -0
- data/vendor/libgit2/src/blob.c +137 -92
- data/vendor/libgit2/src/blob.h +9 -0
- data/vendor/libgit2/src/branch.c +175 -156
- data/vendor/libgit2/src/buf_text.c +29 -14
- data/vendor/libgit2/src/buf_text.h +5 -4
- data/vendor/libgit2/src/buffer.c +158 -15
- data/vendor/libgit2/src/buffer.h +33 -20
- data/vendor/libgit2/src/cc-compat.h +8 -2
- data/vendor/libgit2/src/checkout.c +1081 -287
- data/vendor/libgit2/src/checkout.h +1 -1
- data/vendor/libgit2/src/cherrypick.c +226 -0
- data/vendor/libgit2/src/clone.c +297 -245
- data/vendor/libgit2/src/{compress.h → clone.h} +4 -8
- data/vendor/libgit2/src/commit.c +313 -101
- data/vendor/libgit2/src/commit.h +6 -3
- data/vendor/libgit2/src/commit_list.c +3 -3
- data/vendor/libgit2/src/commit_list.h +1 -1
- data/vendor/libgit2/src/common.h +74 -1
- data/vendor/libgit2/src/config.c +570 -145
- data/vendor/libgit2/src/config.h +39 -6
- data/vendor/libgit2/src/config_cache.c +32 -18
- data/vendor/libgit2/src/config_file.c +711 -424
- data/vendor/libgit2/src/config_file.h +4 -3
- data/vendor/libgit2/src/crlf.c +149 -109
- data/vendor/libgit2/src/date.c +35 -7
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/diff.c +719 -414
- data/vendor/libgit2/src/diff.h +52 -7
- data/vendor/libgit2/src/diff_driver.c +183 -85
- data/vendor/libgit2/src/diff_driver.h +1 -1
- data/vendor/libgit2/src/diff_file.c +65 -84
- data/vendor/libgit2/src/diff_file.h +12 -10
- data/vendor/libgit2/src/diff_patch.c +274 -333
- data/vendor/libgit2/src/diff_patch.h +10 -9
- data/vendor/libgit2/src/diff_print.c +381 -179
- data/vendor/libgit2/src/diff_stats.c +336 -0
- data/vendor/libgit2/src/diff_tform.c +393 -215
- data/vendor/libgit2/src/diff_xdiff.c +117 -42
- data/vendor/libgit2/src/errors.c +59 -4
- data/vendor/libgit2/src/fetch.c +40 -34
- data/vendor/libgit2/src/fetch.h +2 -5
- data/vendor/libgit2/src/fetchhead.c +14 -7
- data/vendor/libgit2/src/filebuf.c +13 -24
- data/vendor/libgit2/src/filebuf.h +3 -3
- data/vendor/libgit2/src/fileops.c +104 -296
- data/vendor/libgit2/src/fileops.h +23 -94
- data/vendor/libgit2/src/filter.c +642 -43
- data/vendor/libgit2/src/filter.h +7 -66
- data/vendor/libgit2/src/fnmatch.c +46 -3
- data/vendor/libgit2/src/fnmatch.h +24 -3
- data/vendor/libgit2/src/global.c +158 -42
- data/vendor/libgit2/src/global.h +9 -0
- data/vendor/libgit2/src/graph.c +34 -20
- data/vendor/libgit2/src/hash/hash_generic.h +0 -1
- data/vendor/libgit2/src/hash/hash_openssl.h +0 -1
- data/vendor/libgit2/src/hash/hash_win32.c +14 -29
- data/vendor/libgit2/src/hash.h +0 -2
- data/vendor/libgit2/src/hashsig.c +97 -117
- data/vendor/libgit2/src/ident.c +125 -0
- data/vendor/libgit2/src/ignore.c +159 -110
- data/vendor/libgit2/src/ignore.h +13 -3
- data/vendor/libgit2/src/index.c +803 -445
- data/vendor/libgit2/src/index.h +43 -6
- data/vendor/libgit2/src/indexer.c +475 -157
- data/vendor/libgit2/src/iterator.c +198 -55
- data/vendor/libgit2/src/iterator.h +28 -4
- data/vendor/libgit2/src/map.h +1 -0
- data/vendor/libgit2/src/merge.c +849 -142
- data/vendor/libgit2/src/merge.h +11 -4
- data/vendor/libgit2/src/merge_file.c +183 -78
- data/vendor/libgit2/src/merge_file.h +0 -57
- data/vendor/libgit2/src/message.c +4 -28
- data/vendor/libgit2/src/mwindow.c +117 -8
- data/vendor/libgit2/src/mwindow.h +9 -1
- data/vendor/libgit2/src/netops.c +164 -59
- data/vendor/libgit2/src/netops.h +37 -1
- data/vendor/libgit2/src/notes.c +9 -18
- data/vendor/libgit2/src/notes.h +1 -1
- data/vendor/libgit2/src/object.c +78 -2
- data/vendor/libgit2/src/odb.c +191 -59
- data/vendor/libgit2/src/odb.h +2 -1
- data/vendor/libgit2/src/odb_loose.c +66 -51
- data/vendor/libgit2/src/odb_mempack.c +182 -0
- data/vendor/libgit2/src/odb_pack.c +151 -61
- data/vendor/libgit2/src/oid.c +30 -19
- data/vendor/libgit2/src/oid.h +13 -10
- data/vendor/libgit2/src/pack-objects.c +198 -147
- data/vendor/libgit2/src/pack-objects.h +7 -0
- data/vendor/libgit2/src/pack.c +272 -101
- data/vendor/libgit2/src/pack.h +15 -1
- data/vendor/libgit2/src/path.c +359 -117
- data/vendor/libgit2/src/path.h +110 -20
- data/vendor/libgit2/src/pathspec.c +583 -57
- data/vendor/libgit2/src/pathspec.h +36 -15
- data/vendor/libgit2/src/pool.c +4 -5
- data/vendor/libgit2/src/posix.c +45 -2
- data/vendor/libgit2/src/posix.h +13 -5
- data/vendor/libgit2/src/pqueue.c +73 -119
- data/vendor/libgit2/src/pqueue.h +35 -82
- data/vendor/libgit2/src/push.c +116 -48
- data/vendor/libgit2/src/push.h +5 -0
- data/vendor/libgit2/src/refdb.c +45 -6
- data/vendor/libgit2/src/refdb.h +13 -3
- data/vendor/libgit2/src/refdb_fs.c +1130 -551
- data/vendor/libgit2/src/reflog.c +36 -327
- data/vendor/libgit2/src/reflog.h +6 -1
- data/vendor/libgit2/src/refs.c +345 -142
- data/vendor/libgit2/src/refs.h +9 -2
- data/vendor/libgit2/src/refspec.c +90 -62
- data/vendor/libgit2/src/refspec.h +7 -24
- data/vendor/libgit2/src/remote.c +815 -415
- data/vendor/libgit2/src/remote.h +3 -4
- data/vendor/libgit2/src/repository.c +360 -207
- data/vendor/libgit2/src/repository.h +16 -10
- data/vendor/libgit2/src/reset.c +28 -13
- data/vendor/libgit2/src/revert.c +228 -0
- data/vendor/libgit2/src/revparse.c +29 -30
- data/vendor/libgit2/src/revwalk.c +141 -96
- data/vendor/libgit2/src/revwalk.h +6 -1
- data/vendor/libgit2/src/settings.c +140 -0
- data/vendor/libgit2/src/sha1_lookup.c +71 -0
- data/vendor/libgit2/src/sha1_lookup.h +5 -0
- data/vendor/libgit2/src/signature.c +38 -10
- data/vendor/libgit2/src/sortedcache.c +378 -0
- data/vendor/libgit2/src/sortedcache.h +178 -0
- data/vendor/libgit2/src/stash.c +98 -116
- data/vendor/libgit2/src/status.c +88 -60
- data/vendor/libgit2/src/status.h +2 -2
- data/vendor/libgit2/src/strmap.c +32 -0
- data/vendor/libgit2/src/strmap.h +14 -1
- data/vendor/libgit2/src/strnlen.h +23 -0
- data/vendor/libgit2/src/submodule.c +1073 -615
- data/vendor/libgit2/src/submodule.h +89 -21
- data/vendor/libgit2/src/sysdir.c +252 -0
- data/vendor/libgit2/src/sysdir.h +101 -0
- data/vendor/libgit2/src/tag.c +31 -20
- data/vendor/libgit2/src/thread-utils.h +98 -17
- data/vendor/libgit2/src/trace.h +0 -2
- data/vendor/libgit2/src/transport.c +76 -6
- data/vendor/libgit2/src/transports/cred.c +164 -61
- data/vendor/libgit2/src/transports/git.c +41 -48
- data/vendor/libgit2/src/transports/http.c +65 -109
- data/vendor/libgit2/src/transports/local.c +88 -65
- data/vendor/libgit2/src/transports/smart.c +91 -19
- data/vendor/libgit2/src/transports/smart.h +13 -5
- data/vendor/libgit2/src/transports/smart_pkt.c +24 -14
- data/vendor/libgit2/src/transports/smart_protocol.c +268 -113
- data/vendor/libgit2/src/transports/ssh.c +284 -186
- data/vendor/libgit2/src/transports/winhttp.c +279 -198
- data/vendor/libgit2/src/tree-cache.c +21 -23
- data/vendor/libgit2/src/tree-cache.h +1 -0
- data/vendor/libgit2/src/tree.c +109 -92
- data/vendor/libgit2/src/tree.h +2 -3
- data/vendor/libgit2/src/unix/map.c +7 -1
- data/vendor/libgit2/src/unix/posix.h +0 -1
- data/vendor/libgit2/src/userdiff.h +208 -0
- data/vendor/libgit2/src/util.c +16 -112
- data/vendor/libgit2/src/util.h +107 -3
- data/vendor/libgit2/src/vector.c +72 -17
- data/vendor/libgit2/src/vector.h +32 -5
- data/vendor/libgit2/src/win32/dir.c +15 -40
- data/vendor/libgit2/src/win32/dir.h +3 -2
- data/vendor/libgit2/src/win32/error.c +5 -31
- data/vendor/libgit2/src/win32/findfile.c +47 -66
- data/vendor/libgit2/src/win32/findfile.h +1 -12
- data/vendor/libgit2/src/win32/git2.rc +40 -0
- data/vendor/libgit2/src/win32/map.c +7 -1
- data/vendor/libgit2/src/win32/mingw-compat.h +3 -0
- data/vendor/libgit2/src/win32/posix.h +17 -11
- data/vendor/libgit2/src/win32/posix_w32.c +424 -292
- data/vendor/libgit2/src/win32/precompiled.h +6 -2
- data/vendor/libgit2/src/win32/pthread.c +141 -18
- data/vendor/libgit2/src/win32/pthread.h +50 -8
- data/vendor/libgit2/src/win32/reparse.h +57 -0
- data/vendor/libgit2/src/win32/utf-conv.c +117 -60
- data/vendor/libgit2/src/win32/utf-conv.h +81 -6
- data/vendor/libgit2/src/win32/version.h +21 -4
- data/vendor/libgit2/src/win32/w32_util.c +139 -0
- data/vendor/libgit2/src/win32/w32_util.h +54 -0
- data/vendor/libgit2/src/zstream.c +156 -0
- data/vendor/libgit2/src/zstream.h +39 -0
- metadata +84 -167
- data/Rakefile +0 -61
- data/ext/rugged/rugged_diff_patch.c +0 -169
- data/lib/rugged/diff/patch.rb +0 -28
- data/test/blob_test.rb +0 -341
- data/test/branch_test.rb +0 -199
- data/test/commit_test.rb +0 -104
- data/test/config_test.rb +0 -45
- data/test/coverage/cover.rb +0 -133
- data/test/diff_test.rb +0 -777
- data/test/errors_test.rb +0 -34
- data/test/fixtures/alternate/objects/14/6ae76773c91e3b1d00cf7a338ec55ae58297e2 +0 -0
- data/test/fixtures/alternate/objects/14/9c32d47e99d0a3572ff1e70a2e0051bbf347a9 +0 -0
- data/test/fixtures/alternate/objects/14/fb3108588f9421bf764041e5e3ac305eb6277f +0 -0
- data/test/fixtures/archive.tar.gz +0 -0
- data/test/fixtures/attr/attr0 +0 -1
- data/test/fixtures/attr/attr1 +0 -29
- data/test/fixtures/attr/attr2 +0 -21
- data/test/fixtures/attr/attr3 +0 -4
- data/test/fixtures/attr/binfile +0 -1
- data/test/fixtures/attr/dir/file +0 -0
- data/test/fixtures/attr/file +0 -1
- data/test/fixtures/attr/gitattributes +0 -29
- data/test/fixtures/attr/gitignore +0 -2
- data/test/fixtures/attr/ign +0 -1
- data/test/fixtures/attr/macro_bad +0 -1
- data/test/fixtures/attr/macro_test +0 -1
- data/test/fixtures/attr/root_test1 +0 -1
- data/test/fixtures/attr/root_test2 +0 -6
- data/test/fixtures/attr/root_test3 +0 -19
- data/test/fixtures/attr/root_test4.txt +0 -14
- data/test/fixtures/attr/sub/abc +0 -37
- data/test/fixtures/attr/sub/dir/file +0 -0
- data/test/fixtures/attr/sub/file +0 -1
- data/test/fixtures/attr/sub/ign/file +0 -1
- data/test/fixtures/attr/sub/ign/sub/file +0 -1
- data/test/fixtures/attr/sub/sub/dir +0 -0
- data/test/fixtures/attr/sub/sub/file +0 -1
- data/test/fixtures/attr/sub/sub/subsub.txt +0 -1
- data/test/fixtures/attr/sub/subdir_test1 +0 -2
- data/test/fixtures/attr/sub/subdir_test2.txt +0 -1
- data/test/fixtures/diff/another.txt +0 -38
- data/test/fixtures/diff/readme.txt +0 -36
- data/test/fixtures/mergedrepo/conflicts-one.txt +0 -5
- data/test/fixtures/mergedrepo/conflicts-two.txt +0 -5
- data/test/fixtures/mergedrepo/one.txt +0 -10
- data/test/fixtures/mergedrepo/two.txt +0 -12
- data/test/fixtures/status/current_file +0 -1
- data/test/fixtures/status/ignored_file +0 -1
- data/test/fixtures/status/modified_file +0 -2
- data/test/fixtures/status/new_file +0 -1
- data/test/fixtures/status/staged_changes +0 -2
- data/test/fixtures/status/staged_changes_modified_file +0 -3
- data/test/fixtures/status/staged_delete_modified_file +0 -1
- data/test/fixtures/status/staged_new_file +0 -1
- data/test/fixtures/status/staged_new_file_modified_file +0 -2
- data/test/fixtures/status/subdir/current_file +0 -1
- data/test/fixtures/status/subdir/modified_file +0 -2
- data/test/fixtures/status/subdir/new_file +0 -1
- data/test/fixtures/status/subdir.txt +0 -2
- data/test/fixtures/status//350/277/231 +0 -1
- data/test/fixtures/testrepo.git/HEAD +0 -1
- data/test/fixtures/testrepo.git/config +0 -13
- data/test/fixtures/testrepo.git/description +0 -1
- data/test/fixtures/testrepo.git/index +0 -0
- data/test/fixtures/testrepo.git/info/exclude +0 -6
- data/test/fixtures/testrepo.git/logs/HEAD +0 -3
- data/test/fixtures/testrepo.git/logs/refs/heads/master +0 -3
- data/test/fixtures/testrepo.git/logs/refs/notes/commits +0 -1
- data/test/fixtures/testrepo.git/objects/0c/37a5391bbff43c37f0d0371823a5509eed5b1d +0 -0
- data/test/fixtures/testrepo.git/objects/13/85f264afb75a56a5bec74243be9b367ba4ca08 +0 -0
- data/test/fixtures/testrepo.git/objects/18/1037049a54a1eb5fab404658a3a250b44335d7 +0 -0
- data/test/fixtures/testrepo.git/objects/18/10dff58d8a660512d4832e740f692884338ccd +0 -0
- data/test/fixtures/testrepo.git/objects/2d/2eff63372b08adf0a9eb84109ccf7d19e2f3a2 +0 -0
- data/test/fixtures/testrepo.git/objects/36/060c58702ed4c2a40832c51758d5344201d89a +0 -2
- data/test/fixtures/testrepo.git/objects/44/1034f860c1d5d90e4188d11ae0d325176869a8 +0 -1
- data/test/fixtures/testrepo.git/objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057 +0 -0
- data/test/fixtures/testrepo.git/objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045 +0 -2
- data/test/fixtures/testrepo.git/objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644 +0 -2
- data/test/fixtures/testrepo.git/objects/60/d415052a33de2150bf68757f6461df4f563ae4 +0 -0
- data/test/fixtures/testrepo.git/objects/61/9f9935957e010c419cb9d15621916ddfcc0b96 +0 -0
- data/test/fixtures/testrepo.git/objects/68/8a8f4ef7496901d15322972f96e212a9e466cc +0 -1
- data/test/fixtures/testrepo.git/objects/75/057dd4114e74cca1d750d0aee1647c903cb60a +0 -0
- data/test/fixtures/testrepo.git/objects/77/71329dfa3002caf8c61a0ceb62a31d09023f37 +0 -0
- data/test/fixtures/testrepo.git/objects/81/4889a078c031f61ed08ab5fa863aea9314344d +0 -0
- data/test/fixtures/testrepo.git/objects/84/96071c1b46c854b31185ea97743be6a8774479 +0 -0
- data/test/fixtures/testrepo.git/objects/94/eca2de348d5f672faf56b0decafa5937e3235e +0 -0
- data/test/fixtures/testrepo.git/objects/9b/7384fe1676186192842f5d3e129457b62db9e3 +0 -0
- data/test/fixtures/testrepo.git/objects/9f/d738e8f7967c078dceed8190330fc8648ee56a +0 -3
- data/test/fixtures/testrepo.git/objects/a4/a7dce85cf63874e984719f4fdd239f5145052f +0 -2
- data/test/fixtures/testrepo.git/objects/a7/1586c1dfe8a71c6cbf6c129f404c5642ff31bd +0 -0
- data/test/fixtures/testrepo.git/objects/a8/233120f6ad708f843d861ce2b7228ec4e3dec6 +0 -0
- data/test/fixtures/testrepo.git/objects/b7/4713326bc972cc15751ed504dca6f6f3b91f7a +0 -3
- data/test/fixtures/testrepo.git/objects/be/3563ae3f795b2b4353bcce3a527ad0a4f7f644 +0 -3
- data/test/fixtures/testrepo.git/objects/c4/7800c7266a2be04c571c04d5a6614691ea99bd +0 -3
- data/test/fixtures/testrepo.git/objects/c4/dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b +0 -0
- data/test/fixtures/testrepo.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/test/fixtures/testrepo.git/objects/f6/0079018b664e4e79329a7ef9559c8d9e0378d1 +0 -0
- data/test/fixtures/testrepo.git/objects/fa/49b077972391ad58037050f2a75f74e3671e92 +0 -0
- data/test/fixtures/testrepo.git/objects/fd/093bff70906175335656e6ce6ae05783708765 +0 -0
- data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx +0 -0
- data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.pack +0 -0
- data/test/fixtures/testrepo.git/packed-refs +0 -2
- data/test/fixtures/testrepo.git/refs/heads/master +0 -1
- data/test/fixtures/testrepo.git/refs/notes/commits +0 -1
- data/test/fixtures/testrepo.git/refs/tags/v0.9 +0 -1
- data/test/fixtures/testrepo.git/refs/tags/v1.0 +0 -1
- data/test/fixtures/text_file.md +0 -464
- data/test/fixtures/unsymlinked.git/HEAD +0 -1
- data/test/fixtures/unsymlinked.git/config +0 -6
- data/test/fixtures/unsymlinked.git/description +0 -1
- data/test/fixtures/unsymlinked.git/info/exclude +0 -2
- data/test/fixtures/unsymlinked.git/objects/08/8b64704e0d6b8bd061dea879418cb5442a3fbf +0 -0
- data/test/fixtures/unsymlinked.git/objects/13/a5e939bca25940c069fd2169d993dba328e30b +0 -0
- data/test/fixtures/unsymlinked.git/objects/19/bf568e59e3a0b363cafb4106226e62d4a4c41c +0 -0
- data/test/fixtures/unsymlinked.git/objects/58/1fadd35b4cf320d102a152f918729011604773 +0 -0
- data/test/fixtures/unsymlinked.git/objects/5c/87b6791e8b13da658a14d1ef7e09b5dc3bac8c +0 -0
- data/test/fixtures/unsymlinked.git/objects/6f/e5f5398af85fb3de8a6aba0339b6d3bfa26a27 +0 -0
- data/test/fixtures/unsymlinked.git/objects/7f/ccd75616ec188b8f1b23d67506a334cc34a49d +0 -0
- data/test/fixtures/unsymlinked.git/objects/80/6999882bf91d24241e4077906b9017605eb1f3 +0 -0
- data/test/fixtures/unsymlinked.git/objects/83/7d176303c5005505ec1e4a30231c40930c0230 +0 -0
- data/test/fixtures/unsymlinked.git/objects/a8/595ccca04f40818ae0155c8f9c77a230e597b6 +0 -2
- data/test/fixtures/unsymlinked.git/objects/cf/8f1cf5cce859c438d6cc067284cb5e161206e7 +0 -0
- data/test/fixtures/unsymlinked.git/objects/d5/278d05c8607ec420bfee4cf219fbc0eeebfd6a +0 -0
- data/test/fixtures/unsymlinked.git/objects/f4/e16fb76536591a41454194058d048d8e4dd2e9 +0 -0
- data/test/fixtures/unsymlinked.git/objects/f9/e65619d93fdf2673882e0a261c5e93b1a84006 +0 -0
- data/test/fixtures/unsymlinked.git/refs/heads/exe-file +0 -1
- data/test/fixtures/unsymlinked.git/refs/heads/master +0 -1
- data/test/fixtures/unsymlinked.git/refs/heads/reg-file +0 -1
- data/test/index_test.rb +0 -333
- data/test/lib_test.rb +0 -127
- data/test/note_test.rb +0 -158
- data/test/object_test.rb +0 -43
- data/test/reference_test.rb +0 -207
- data/test/remote_test.rb +0 -324
- data/test/repo_pack_test.rb +0 -24
- data/test/repo_reset_test.rb +0 -82
- data/test/repo_test.rb +0 -402
- data/test/tag_test.rb +0 -68
- data/test/test_helper.rb +0 -92
- data/test/tree_test.rb +0 -91
- data/test/walker_test.rb +0 -88
- data/vendor/libgit2/src/amiga/map.c +0 -48
- data/vendor/libgit2/src/compress.c +0 -53
data/ext/rugged/rugged_remote.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* The MIT License
|
3
3
|
*
|
4
|
-
* Copyright (c)
|
4
|
+
* Copyright (c) 2014 GitHub, Inc
|
5
5
|
*
|
6
6
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
* of this software and associated documentation files (the "Software"), to deal
|
@@ -26,198 +26,165 @@
|
|
26
26
|
|
27
27
|
extern VALUE rb_mRugged;
|
28
28
|
extern VALUE rb_cRuggedRepo;
|
29
|
+
extern VALUE rb_eRuggedError;
|
29
30
|
VALUE rb_cRuggedRemote;
|
30
31
|
|
31
|
-
|
32
|
-
{
|
33
|
-
git_remote_free(remote);
|
34
|
-
}
|
32
|
+
#define RUGGED_REMOTE_CALLBACKS_INIT {1, progress_cb, NULL, credentials_cb, transfer_progress_cb, update_tips_cb, NULL}
|
35
33
|
|
36
|
-
|
34
|
+
static int progress_cb(const char *str, int len, void *data)
|
37
35
|
{
|
38
|
-
|
36
|
+
struct rugged_remote_cb_payload *payload = data;
|
37
|
+
VALUE args = rb_ary_new2(2);
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
return rb_remote;
|
43
|
-
}
|
39
|
+
if (NIL_P(payload->progress))
|
40
|
+
return 0;
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
rb_ary_push(args, payload->progress);
|
43
|
+
rb_ary_push(args, rb_str_new(str, len));
|
44
|
+
|
45
|
+
rb_protect(rugged__block_yield_splat, args, &payload->exception);
|
46
|
+
|
47
|
+
return payload->exception ? GIT_ERROR : GIT_OK;
|
50
48
|
}
|
51
49
|
|
52
|
-
|
53
|
-
* call-seq:
|
54
|
-
* Remote.new(repository, url) -> remote
|
55
|
-
*
|
56
|
-
* Return a new remote with +url+ in +repository+ , the remote is not persisted:
|
57
|
-
* - +url+: a valid remote url
|
58
|
-
*
|
59
|
-
* Returns a new Rugged::Remote object
|
60
|
-
*
|
61
|
-
* Rugged::Remote.new(@repo, 'git://github.com/libgit2/libgit2.git') #=> #<Rugged::Remote:0x00000001fbfa80>
|
62
|
-
*/
|
63
|
-
static VALUE rb_git_remote_new(VALUE klass, VALUE rb_repo, VALUE rb_url)
|
50
|
+
static int transfer_progress_cb(const git_transfer_progress *stats, void *data)
|
64
51
|
{
|
65
|
-
|
66
|
-
|
67
|
-
int error;
|
68
|
-
|
69
|
-
rugged_check_repo(rb_repo);
|
70
|
-
rugged_validate_remote_url(rb_url);
|
52
|
+
struct rugged_remote_cb_payload *payload = data;
|
53
|
+
VALUE args = rb_ary_new2(5);
|
71
54
|
|
72
|
-
|
55
|
+
if (NIL_P(payload->transfer_progress))
|
56
|
+
return 0;
|
73
57
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
58
|
+
rb_ary_push(args, payload->transfer_progress);
|
59
|
+
rb_ary_push(args, UINT2NUM(stats->total_objects));
|
60
|
+
rb_ary_push(args, UINT2NUM(stats->indexed_objects));
|
61
|
+
rb_ary_push(args, UINT2NUM(stats->received_objects));
|
62
|
+
rb_ary_push(args, UINT2NUM(stats->local_objects));
|
63
|
+
rb_ary_push(args, UINT2NUM(stats->total_deltas));
|
64
|
+
rb_ary_push(args, UINT2NUM(stats->indexed_deltas));
|
65
|
+
rb_ary_push(args, INT2FIX(stats->received_bytes));
|
79
66
|
|
80
|
-
|
67
|
+
rb_protect(rugged__block_yield_splat, args, &payload->exception);
|
81
68
|
|
82
|
-
return
|
69
|
+
return payload->exception ? GIT_ERROR : GIT_OK;
|
83
70
|
}
|
84
71
|
|
85
|
-
|
86
|
-
* call-seq:
|
87
|
-
* Remote.add(repository, name, url) -> remote
|
88
|
-
*
|
89
|
-
* Add a new remote with +name+ and +url+ to +repository+
|
90
|
-
* - +url+: a valid remote url
|
91
|
-
* - +name+: a valid remote name
|
92
|
-
*
|
93
|
-
* Returns a new Rugged::Remote object
|
94
|
-
*
|
95
|
-
* Rugged::Remote.add(@repo, 'origin', 'git://github.com/libgit2/rugged.git') #=> #<Rugged::Remote:0x00000001fbfa80>
|
96
|
-
*/
|
97
|
-
static VALUE rb_git_remote_add(VALUE klass, VALUE rb_repo,VALUE rb_name, VALUE rb_url)
|
72
|
+
static int update_tips_cb(const char *refname, const git_oid *src, const git_oid *dest, void *data)
|
98
73
|
{
|
99
|
-
|
100
|
-
|
101
|
-
int error;
|
102
|
-
|
103
|
-
Check_Type(rb_name, T_STRING);
|
104
|
-
rugged_validate_remote_url(rb_url);
|
105
|
-
rugged_check_repo(rb_repo);
|
74
|
+
struct rugged_remote_cb_payload *payload = data;
|
75
|
+
VALUE args = rb_ary_new2(4);
|
106
76
|
|
107
|
-
|
77
|
+
if (NIL_P(payload->update_tips))
|
78
|
+
return 0;
|
108
79
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
StringValueCStr(rb_url));
|
80
|
+
rb_ary_push(args, payload->update_tips);
|
81
|
+
rb_ary_push(args, rb_str_new_utf8(refname));
|
82
|
+
rb_ary_push(args, git_oid_iszero(src) ? Qnil : rugged_create_oid(src));
|
83
|
+
rb_ary_push(args, git_oid_iszero(dest) ? Qnil : rugged_create_oid(dest));
|
114
84
|
|
115
|
-
|
85
|
+
rb_protect(rugged__block_yield_splat, args, &payload->exception);
|
116
86
|
|
117
|
-
return
|
87
|
+
return payload->exception ? GIT_ERROR : GIT_OK;
|
118
88
|
}
|
119
89
|
|
120
|
-
|
121
|
-
* call-seq:
|
122
|
-
* Remote.lookup(repository, name) -> remote or nil
|
123
|
-
*
|
124
|
-
* Return an existing remote with +name+ in +repository+:
|
125
|
-
* - +name+: a valid remote name
|
126
|
-
*
|
127
|
-
* Returns a new Rugged::Remote object or +nil+ if the
|
128
|
-
* remote doesn't exist
|
129
|
-
*
|
130
|
-
* Rugged::Remote.lookup(@repo, 'origin') #=> #<Rugged::Remote:0x00000001fbfa80>
|
131
|
-
*/
|
132
|
-
static VALUE rb_git_remote_lookup(VALUE klass, VALUE rb_repo, VALUE rb_name)
|
90
|
+
struct extract_cred_args
|
133
91
|
{
|
134
|
-
|
135
|
-
|
136
|
-
|
92
|
+
VALUE rb_callback;
|
93
|
+
git_cred **cred;
|
94
|
+
const char *url;
|
95
|
+
const char *username_from_url;
|
96
|
+
unsigned int allowed_types;
|
97
|
+
};
|
137
98
|
|
138
|
-
|
139
|
-
|
140
|
-
Data_Get_Struct(rb_repo, git_repository, repo);
|
99
|
+
static VALUE allowed_types_to_rb_ary(int allowed_types) {
|
100
|
+
VALUE rb_allowed_types = rb_ary_new();
|
141
101
|
|
142
|
-
|
102
|
+
if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT)
|
103
|
+
rb_ary_push(rb_allowed_types, CSTR2SYM("plaintext"));
|
143
104
|
|
144
|
-
if (
|
145
|
-
|
105
|
+
if (allowed_types & GIT_CREDTYPE_SSH_KEY)
|
106
|
+
rb_ary_push(rb_allowed_types, CSTR2SYM("ssh_key"));
|
146
107
|
|
147
|
-
|
108
|
+
if (allowed_types & GIT_CREDTYPE_DEFAULT)
|
109
|
+
rb_ary_push(rb_allowed_types, CSTR2SYM("default"));
|
148
110
|
|
149
|
-
return
|
111
|
+
return rb_allowed_types;
|
150
112
|
}
|
151
113
|
|
152
|
-
|
153
|
-
*
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
114
|
+
static VALUE extract_cred(VALUE data) {
|
115
|
+
struct extract_cred_args *args = (struct extract_cred_args*)data;
|
116
|
+
VALUE rb_url, rb_username_from_url, rb_cred;
|
117
|
+
|
118
|
+
rb_url = args->url ? rb_str_new2(args->url) : Qnil;
|
119
|
+
rb_username_from_url = args->username_from_url ? rb_str_new2(args->username_from_url) : Qnil;
|
120
|
+
|
121
|
+
rb_cred = rb_funcall(args->rb_callback, rb_intern("call"), 3,
|
122
|
+
rb_url, rb_username_from_url, allowed_types_to_rb_ary(args->allowed_types));
|
123
|
+
|
124
|
+
rugged_cred_extract(args->cred, args->allowed_types, rb_cred);
|
162
125
|
|
163
|
-
git_remote_disconnect(remote);
|
164
126
|
return Qnil;
|
165
127
|
}
|
166
128
|
|
167
|
-
|
168
|
-
|
169
|
-
*
|
170
|
-
*
|
171
|
-
|
172
|
-
*
|
173
|
-
* - +direction+: +:fetch+ or +:pull+
|
174
|
-
*
|
175
|
-
* If a block is given it will be passed the connected remote as argument
|
176
|
-
* and the remote will be disconnected when the block terminates.
|
177
|
-
*
|
178
|
-
* The transport is selected based on the URL.
|
179
|
-
*
|
180
|
-
* remote.connect(:fetch) #=> nil
|
181
|
-
*
|
182
|
-
* remote.connect(:fetch) do |r|
|
183
|
-
* r.connected? #=> true
|
184
|
-
* end
|
185
|
-
*
|
186
|
-
*/
|
187
|
-
static VALUE rb_git_remote_connect(VALUE self, VALUE rb_direction)
|
129
|
+
static int credentials_cb(
|
130
|
+
git_cred **cred,
|
131
|
+
const char *url,
|
132
|
+
const char *username_from_url,
|
133
|
+
unsigned int allowed_types,
|
134
|
+
void *data)
|
188
135
|
{
|
189
|
-
|
190
|
-
|
191
|
-
|
136
|
+
struct rugged_remote_cb_payload *payload = data;
|
137
|
+
struct extract_cred_args args = {
|
138
|
+
payload->credentials, cred, url, username_from_url, allowed_types
|
139
|
+
};
|
192
140
|
|
193
|
-
|
141
|
+
if (NIL_P(payload->credentials))
|
142
|
+
return GIT_PASSTHROUGH;
|
194
143
|
|
195
|
-
|
196
|
-
id_direction = SYM2ID(rb_direction);
|
144
|
+
rb_protect(extract_cred, (VALUE)&args, &payload->exception);
|
197
145
|
|
198
|
-
|
199
|
-
|
200
|
-
else if (id_direction == rb_intern("push"))
|
201
|
-
direction = GIT_DIRECTION_PUSH;
|
202
|
-
else
|
203
|
-
rb_raise(rb_eTypeError,
|
204
|
-
"Invalid remote direction. Expected `:fetch` or `:push`");
|
146
|
+
return payload->exception ? GIT_ERROR : GIT_OK;
|
147
|
+
}
|
205
148
|
|
206
|
-
|
207
|
-
|
149
|
+
#define CALLABLE_OR_RAISE(ret, rb_options, name) \
|
150
|
+
do { \
|
151
|
+
ret = rb_hash_aref(rb_options, CSTR2SYM(name)); \
|
152
|
+
\
|
153
|
+
if (!NIL_P(ret) && !rb_respond_to(ret, rb_intern("call"))) \
|
154
|
+
rb_raise(rb_eArgError, "Expected a Proc or an object that responds to #call (:" name " )."); \
|
155
|
+
} while (0);
|
156
|
+
|
157
|
+
void rugged_remote_init_callbacks_and_payload_from_options(
|
158
|
+
VALUE rb_options,
|
159
|
+
git_remote_callbacks *callbacks,
|
160
|
+
struct rugged_remote_cb_payload *payload)
|
161
|
+
{
|
162
|
+
git_remote_callbacks prefilled = RUGGED_REMOTE_CALLBACKS_INIT;
|
208
163
|
|
209
|
-
|
210
|
-
|
211
|
-
git_remote_disconnect(remote);
|
164
|
+
prefilled.payload = payload;
|
165
|
+
memcpy(callbacks, &prefilled, sizeof(git_remote_callbacks));
|
212
166
|
|
213
|
-
|
214
|
-
|
215
|
-
|
167
|
+
CALLABLE_OR_RAISE(payload->update_tips, rb_options, "update_tips");
|
168
|
+
CALLABLE_OR_RAISE(payload->progress, rb_options, "progress");
|
169
|
+
CALLABLE_OR_RAISE(payload->transfer_progress, rb_options, "transfer_progress");
|
170
|
+
CALLABLE_OR_RAISE(payload->credentials, rb_options, "credentials");
|
171
|
+
}
|
216
172
|
|
217
|
-
|
173
|
+
static void rb_git_remote__free(git_remote *remote)
|
174
|
+
{
|
175
|
+
git_remote_free(remote);
|
176
|
+
}
|
177
|
+
|
178
|
+
VALUE rugged_remote_new(VALUE owner, git_remote *remote)
|
179
|
+
{
|
180
|
+
VALUE rb_remote;
|
181
|
+
|
182
|
+
rb_remote = Data_Wrap_Struct(rb_cRuggedRemote, NULL, &rb_git_remote__free, remote);
|
183
|
+
rugged_set_owner(rb_remote, owner);
|
184
|
+
return rb_remote;
|
218
185
|
}
|
219
186
|
|
220
|
-
static VALUE rugged_rhead_new(git_remote_head *head)
|
187
|
+
static VALUE rugged_rhead_new(const git_remote_head *head)
|
221
188
|
{
|
222
189
|
VALUE rb_head = rb_hash_new();
|
223
190
|
|
@@ -230,48 +197,78 @@ static VALUE rugged_rhead_new(git_remote_head *head)
|
|
230
197
|
return rb_head;
|
231
198
|
}
|
232
199
|
|
233
|
-
static int cb_remote__ls(git_remote_head *head, void *payload)
|
234
|
-
{
|
235
|
-
int *exception = (int *)payload;
|
236
|
-
rb_protect(rb_yield, rugged_rhead_new(head), exception);
|
237
|
-
return *exception ? GIT_ERROR : GIT_OK;
|
238
|
-
}
|
239
|
-
|
240
200
|
/*
|
241
201
|
* call-seq:
|
242
|
-
* remote.ls() -> an_enumerator
|
243
|
-
* remote.ls() { |remote_head_hash| block }
|
202
|
+
* remote.ls(options = {}) -> an_enumerator
|
203
|
+
* remote.ls(options = {}) { |remote_head_hash| block }
|
204
|
+
*
|
205
|
+
* Connects +remote+ to list all references available along with their
|
206
|
+
* associated commit ids.
|
207
|
+
*
|
208
|
+
* The given block is called once for each remote head with a Hash containing the
|
209
|
+
* following keys:
|
210
|
+
*
|
211
|
+
* :local? ::
|
212
|
+
* +true+ if the remote head is available locally, +false+ otherwise.
|
244
213
|
*
|
245
|
-
*
|
246
|
-
*
|
214
|
+
* :oid ::
|
215
|
+
* The id of the object the remote head is currently pointing to.
|
247
216
|
*
|
248
|
-
*
|
249
|
-
*
|
250
|
-
*
|
217
|
+
* :loid ::
|
218
|
+
* The id of the object the local copy of the remote head is currently
|
219
|
+
* pointing to. Set to +nil+ if there is no local copy of the remote head.
|
251
220
|
*
|
252
|
-
*
|
253
|
-
*
|
254
|
-
* end
|
221
|
+
* :name ::
|
222
|
+
* The fully qualified reference name of the remote head.
|
255
223
|
*
|
256
|
-
*
|
257
|
-
* [:oid] oid of the remote head
|
258
|
-
* [:name] name of the remote head
|
224
|
+
* If no block is given, an enumerator will be returned.
|
259
225
|
*
|
226
|
+
* The following options can be passed in the +options+ Hash:
|
260
227
|
*
|
228
|
+
* :credentials ::
|
229
|
+
* The credentials to use for the ls operation. Can be either an instance of one
|
230
|
+
* of the Rugged::Credentials types, or a proc returning one of the former.
|
231
|
+
* The proc will be called with the +url+, the +username+ from the url (if applicable) and
|
232
|
+
* a list of applicable credential types.
|
261
233
|
*/
|
262
|
-
static VALUE rb_git_remote_ls(VALUE self)
|
234
|
+
static VALUE rb_git_remote_ls(int argc, VALUE *argv, VALUE self)
|
263
235
|
{
|
264
|
-
int error, exception = 0;
|
265
236
|
git_remote *remote;
|
237
|
+
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
238
|
+
const git_remote_head **heads;
|
239
|
+
|
240
|
+
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
|
241
|
+
|
242
|
+
VALUE rb_options;
|
243
|
+
|
244
|
+
int error;
|
245
|
+
size_t heads_len, i;
|
246
|
+
|
266
247
|
Data_Get_Struct(self, git_remote, remote);
|
267
248
|
|
249
|
+
rb_scan_args(argc, argv, ":", &rb_options);
|
250
|
+
|
268
251
|
if (!rb_block_given_p())
|
269
|
-
return rb_funcall(self, rb_intern("to_enum"),
|
252
|
+
return rb_funcall(self, rb_intern("to_enum"), 2, CSTR2SYM("ls"), rb_options);
|
253
|
+
|
254
|
+
if (!NIL_P(rb_options))
|
255
|
+
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
|
256
|
+
|
257
|
+
if ((error = git_remote_set_callbacks(remote, &callbacks)) ||
|
258
|
+
(error = git_remote_connect(remote, GIT_DIRECTION_FETCH)) ||
|
259
|
+
(error = git_remote_ls(&heads, &heads_len, remote)))
|
260
|
+
goto cleanup;
|
270
261
|
|
271
|
-
|
262
|
+
for (i = 0; i < heads_len && !payload.exception; i++)
|
263
|
+
rb_protect(rb_yield, rugged_rhead_new(heads[i]), &payload.exception);
|
264
|
+
|
265
|
+
cleanup:
|
266
|
+
|
267
|
+
git_remote_disconnect(remote);
|
268
|
+
|
269
|
+
if (payload.exception)
|
270
|
+
rb_jump_tag(payload.exception);
|
272
271
|
|
273
|
-
if (exception)
|
274
|
-
rb_jump_tag(exception);
|
275
272
|
rugged_exception_check(error);
|
276
273
|
|
277
274
|
return Qnil;
|
@@ -281,7 +278,8 @@ static VALUE rb_git_remote_ls(VALUE self)
|
|
281
278
|
* call-seq:
|
282
279
|
* remote.name() -> string
|
283
280
|
*
|
284
|
-
* Returns the remote's name
|
281
|
+
* Returns the remote's name.
|
282
|
+
*
|
285
283
|
* remote.name #=> "origin"
|
286
284
|
*/
|
287
285
|
static VALUE rb_git_remote_name(VALUE self)
|
@@ -300,6 +298,7 @@ static VALUE rb_git_remote_name(VALUE self)
|
|
300
298
|
* remote.url() -> string
|
301
299
|
*
|
302
300
|
* Returns the remote's url
|
301
|
+
*
|
303
302
|
* remote.url #=> "git://github.com/libgit2/rugged.git"
|
304
303
|
*/
|
305
304
|
static VALUE rb_git_remote_url(VALUE self)
|
@@ -316,6 +315,7 @@ static VALUE rb_git_remote_url(VALUE self)
|
|
316
315
|
*
|
317
316
|
* Sets the remote's url without persisting it in the config.
|
318
317
|
* Existing connections will not be updated.
|
318
|
+
*
|
319
319
|
* remote.url = 'git://github.com/libgit2/rugged.git' #=> "git://github.com/libgit2/rugged.git"
|
320
320
|
*/
|
321
321
|
static VALUE rb_git_remote_set_url(VALUE self, VALUE rb_url)
|
@@ -337,6 +337,7 @@ static VALUE rb_git_remote_set_url(VALUE self, VALUE rb_url)
|
|
337
337
|
*
|
338
338
|
* Returns the remote's url for pushing or nil if no special url for
|
339
339
|
* pushing is set.
|
340
|
+
*
|
340
341
|
* remote.push_url #=> "git://github.com/libgit2/rugged.git"
|
341
342
|
*/
|
342
343
|
static VALUE rb_git_remote_push_url(VALUE self)
|
@@ -356,6 +357,7 @@ static VALUE rb_git_remote_push_url(VALUE self)
|
|
356
357
|
*
|
357
358
|
* Sets the remote's url for pushing without persisting it in the config.
|
358
359
|
* Existing connections will not be updated.
|
360
|
+
*
|
359
361
|
* remote.push_url = 'git@github.com/libgit2/rugged.git' #=> "git@github.com/libgit2/rugged.git"
|
360
362
|
*/
|
361
363
|
static VALUE rb_git_remote_set_push_url(VALUE self, VALUE rb_url)
|
@@ -397,7 +399,7 @@ static VALUE rb_git_remote_refspecs(VALUE self, git_direction direction)
|
|
397
399
|
* call-seq:
|
398
400
|
* remote.fetch_refspecs -> array
|
399
401
|
*
|
400
|
-
* Get the remote's list of fetch refspecs as +array
|
402
|
+
* Get the remote's list of fetch refspecs as +array+.
|
401
403
|
*/
|
402
404
|
static VALUE rb_git_remote_fetch_refspecs(VALUE self)
|
403
405
|
{
|
@@ -408,7 +410,7 @@ static VALUE rb_git_remote_fetch_refspecs(VALUE self)
|
|
408
410
|
* call-seq:
|
409
411
|
* remote.push_refspecs -> array
|
410
412
|
*
|
411
|
-
* Get the remote's list of push refspecs as +array
|
413
|
+
* Get the remote's list of push refspecs as +array+.
|
412
414
|
*/
|
413
415
|
static VALUE rb_git_remote_push_refspecs(VALUE self)
|
414
416
|
{
|
@@ -438,7 +440,7 @@ static VALUE rb_git_remote_add_refspec(VALUE self, VALUE rb_refspec, git_directi
|
|
438
440
|
* call-seq:
|
439
441
|
* remote.add_fetch(refspec) -> nil
|
440
442
|
*
|
441
|
-
* Add a fetch refspec to the remote
|
443
|
+
* Add a fetch refspec to the remote.
|
442
444
|
*/
|
443
445
|
static VALUE rb_git_remote_add_fetch(VALUE self, VALUE rb_refspec)
|
444
446
|
{
|
@@ -449,7 +451,7 @@ static VALUE rb_git_remote_add_fetch(VALUE self, VALUE rb_refspec)
|
|
449
451
|
* call-seq:
|
450
452
|
* remote.add_push(refspec) -> nil
|
451
453
|
*
|
452
|
-
* Add a push refspec to the remote
|
454
|
+
* Add a push refspec to the remote.
|
453
455
|
*/
|
454
456
|
static VALUE rb_git_remote_add_push(VALUE self, VALUE rb_refspec)
|
455
457
|
{
|
@@ -475,251 +477,346 @@ static VALUE rb_git_remote_clear_refspecs(VALUE self)
|
|
475
477
|
|
476
478
|
/*
|
477
479
|
* call-seq:
|
478
|
-
* remote.
|
480
|
+
* remote.save -> true
|
479
481
|
*
|
480
|
-
*
|
482
|
+
* Saves the remote data (url, fetchspecs, ...) to the config.
|
481
483
|
*
|
482
|
-
*
|
483
|
-
*
|
484
|
-
*
|
484
|
+
* Anonymous, in-memory remotes created through
|
485
|
+
* +ReferenceCollection#create_anonymous+ can not be saved.
|
486
|
+
* Doing so will result in an exception being raised.
|
485
487
|
*/
|
486
|
-
static VALUE
|
488
|
+
static VALUE rb_git_remote_save(VALUE self)
|
487
489
|
{
|
488
490
|
git_remote *remote;
|
491
|
+
|
489
492
|
Data_Get_Struct(self, git_remote, remote);
|
490
493
|
|
491
|
-
|
494
|
+
rugged_exception_check(
|
495
|
+
git_remote_save(remote)
|
496
|
+
);
|
497
|
+
return Qtrue;
|
492
498
|
}
|
493
499
|
|
494
500
|
/*
|
495
501
|
* call-seq:
|
496
|
-
* remote.
|
502
|
+
* remote.rename!(new_name) -> array or nil
|
497
503
|
*
|
498
|
-
*
|
504
|
+
* Renames a remote.
|
505
|
+
*
|
506
|
+
* All remote-tracking branches and configuration settings
|
507
|
+
* for the remote are updated.
|
499
508
|
*
|
500
|
-
*
|
501
|
-
*
|
509
|
+
* Returns +nil+ if everything was updated or array of fetch refspecs
|
510
|
+
* that haven't been automatically updated and need potential manual
|
511
|
+
* tweaking.
|
502
512
|
*
|
503
|
-
*
|
504
|
-
*
|
505
|
-
*
|
513
|
+
* Anonymous, in-memory remotes created through
|
514
|
+
* +ReferenceCollection#create_anonymous+ can not be given a name through
|
515
|
+
* this method.
|
516
|
+
*
|
517
|
+
* remote = Rugged::Remote.lookup(@repo, 'origin')
|
518
|
+
* remote.rename!('upstream') #=> nil
|
506
519
|
*/
|
507
|
-
static VALUE
|
520
|
+
static VALUE rb_git_remote_rename(VALUE self, VALUE rb_new_name)
|
508
521
|
{
|
509
|
-
int error;
|
510
522
|
git_remote *remote;
|
523
|
+
git_strarray problems = {0};
|
524
|
+
VALUE rb_result;
|
511
525
|
|
526
|
+
Check_Type(rb_new_name, T_STRING);
|
512
527
|
Data_Get_Struct(self, git_remote, remote);
|
528
|
+
|
529
|
+
rugged_exception_check(
|
530
|
+
git_remote_rename(&problems, remote, StringValueCStr(rb_new_name))
|
531
|
+
);
|
513
532
|
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
return Qnil;
|
518
|
-
}
|
519
|
-
|
520
|
-
static int cb_remote__update_tips(const char *refname, const git_oid *src, const git_oid *dest, void *payload)
|
521
|
-
{
|
522
|
-
VALUE rb_args = rb_ary_new2(3);
|
523
|
-
int *exception = (int *)payload;
|
524
|
-
rb_ary_push(rb_args, rb_str_new_utf8(refname));
|
525
|
-
rb_ary_push(rb_args, git_oid_iszero(src) ? Qnil : rugged_create_oid(src));
|
526
|
-
rb_ary_push(rb_args, git_oid_iszero(dest) ? Qnil : rugged_create_oid(dest));
|
527
|
-
|
528
|
-
rb_protect(rb_yield_splat, rb_args, exception);
|
529
|
-
|
530
|
-
return *exception ? GIT_ERROR : GIT_OK;
|
533
|
+
rb_result = problems.count == 0 ? Qnil : rugged_strarray_to_rb_ary(&problems);
|
534
|
+
git_strarray_free(&problems);
|
535
|
+
return rb_result;
|
531
536
|
}
|
532
537
|
|
533
538
|
/*
|
534
539
|
* call-seq:
|
535
|
-
* remote.
|
536
|
-
* remote.update_tips! { |reference, source, destination| block }
|
540
|
+
* remote.fetch(refspecs = nil, options = {}) -> hash
|
537
541
|
*
|
538
|
-
*
|
539
|
-
* objects must be downloaded before the tips are updated.
|
542
|
+
* Downloads new data from the remote for the given +refspecs+ and updates tips.
|
540
543
|
*
|
541
|
-
*
|
542
|
-
*
|
543
|
-
*
|
544
|
+
* You can optionally pass in an alternative list of +refspecs+ to use instead of the fetch
|
545
|
+
* refspecs already configured for +remote+.
|
546
|
+
*
|
547
|
+
* Returns a hash containing statistics for the fetch operation.
|
548
|
+
*
|
549
|
+
* The following options can be passed in the +options+ Hash:
|
550
|
+
*
|
551
|
+
* :credentials ::
|
552
|
+
* The credentials to use for the fetch operation. Can be either an instance of one
|
553
|
+
* of the Rugged::Credentials types, or a proc returning one of the former.
|
554
|
+
* The proc will be called with the +url+, the +username+ from the url (if applicable) and
|
555
|
+
* a list of applicable credential types.
|
556
|
+
*
|
557
|
+
* :progress ::
|
558
|
+
* A callback that will be executed with the textual progress received from the remote.
|
559
|
+
* This is the text send over the progress side-band (ie. the "counting objects" output).
|
560
|
+
*
|
561
|
+
* :transfer_progress ::
|
562
|
+
* A callback that will be executed to report clone progress information. It will be passed
|
563
|
+
* the amount of +total_objects+, +indexed_objects+, +received_objects+, +local_objects+,
|
564
|
+
* +total_deltas+, +indexed_deltas+ and +received_bytes+.
|
565
|
+
*
|
566
|
+
* :update_tips ::
|
567
|
+
* A callback that will be executed each time a reference is updated locally. It will be
|
568
|
+
* passed the +refname+, +old_oid+ and +new_oid+.
|
569
|
+
*
|
570
|
+
* :message ::
|
571
|
+
* The message to insert into the reflogs. Defaults to "fetch".
|
572
|
+
*
|
573
|
+
* :signature ::
|
574
|
+
* The signature to be used for updating the reflogs.
|
575
|
+
*
|
576
|
+
* Example:
|
577
|
+
*
|
578
|
+
* remote = Rugged::Remote.lookup(@repo, 'origin')
|
579
|
+
* remote.fetch({
|
580
|
+
* transfer_progress: lambda { |total_objects, indexed_objects, received_objects, local_objects, total_deltas, indexed_deltas, received_bytes|
|
581
|
+
* # ...
|
582
|
+
* }
|
583
|
+
* })
|
544
584
|
*/
|
545
|
-
static VALUE
|
585
|
+
static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
|
546
586
|
{
|
547
|
-
git_remote *remote;
|
587
|
+
git_remote *remote, *tmp_remote = NULL;
|
588
|
+
git_repository *repo;
|
589
|
+
git_signature *signature = NULL;
|
590
|
+
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
591
|
+
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
|
592
|
+
|
593
|
+
char *log_message = NULL;
|
594
|
+
int error, i;
|
595
|
+
|
596
|
+
VALUE rb_options, rb_refspecs, rb_result = Qnil, rb_repo = rugged_owner(self);
|
597
|
+
|
598
|
+
rb_scan_args(argc, argv, "01:", &rb_refspecs, &rb_options);
|
599
|
+
|
600
|
+
if (!NIL_P(rb_refspecs)) {
|
601
|
+
Check_Type(rb_refspecs, T_ARRAY);
|
602
|
+
for (i = 0; i < RARRAY_LEN(rb_refspecs); ++i) {
|
603
|
+
VALUE rb_refspec = rb_ary_entry(rb_refspecs, i);
|
604
|
+
Check_Type(rb_refspec, T_STRING);
|
605
|
+
}
|
606
|
+
}
|
548
607
|
|
549
608
|
Data_Get_Struct(self, git_remote, remote);
|
609
|
+
rugged_check_repo(rb_repo);
|
610
|
+
Data_Get_Struct(rb_repo, git_repository, repo);
|
550
611
|
|
551
|
-
if (
|
552
|
-
|
553
|
-
|
612
|
+
if (!NIL_P(rb_options)) {
|
613
|
+
VALUE rb_val = rb_hash_aref(rb_options, CSTR2SYM("signature"));
|
614
|
+
if (!NIL_P(rb_val))
|
615
|
+
signature = rugged_signature_get(rb_val, repo);
|
554
616
|
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
git_remote_set_callbacks(remote, &callbacks)
|
559
|
-
);
|
617
|
+
rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
|
618
|
+
if (!NIL_P(rb_val))
|
619
|
+
log_message = StringValueCStr(rb_val);
|
560
620
|
|
561
|
-
|
621
|
+
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
|
622
|
+
}
|
562
623
|
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
else git_remote_set_callbacks(remote, &callbacks);
|
624
|
+
if ((error = git_remote_dup(&tmp_remote, remote)) ||
|
625
|
+
(error = git_remote_set_callbacks(tmp_remote, &callbacks)))
|
626
|
+
goto cleanup;
|
567
627
|
|
568
|
-
|
569
|
-
|
628
|
+
if (!NIL_P(rb_refspecs)) {
|
629
|
+
git_remote_clear_refspecs(tmp_remote);
|
630
|
+
for (i = 0; !error && i < RARRAY_LEN(rb_refspecs); ++i) {
|
631
|
+
VALUE rb_refspec = rb_ary_entry(rb_refspecs, i);
|
570
632
|
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
git_remote_update_tips(remote)
|
575
|
-
);
|
633
|
+
if ((error = git_remote_add_fetch(tmp_remote, StringValueCStr(rb_refspec))))
|
634
|
+
goto cleanup;
|
635
|
+
}
|
576
636
|
}
|
577
637
|
|
578
|
-
|
638
|
+
if ((error = git_remote_fetch(tmp_remote, signature, log_message)) == GIT_OK) {
|
639
|
+
const git_transfer_progress *stats = git_remote_stats(tmp_remote);
|
640
|
+
|
641
|
+
rb_result = rb_hash_new();
|
642
|
+
rb_hash_aset(rb_result, CSTR2SYM("total_objects"), UINT2NUM(stats->total_objects));
|
643
|
+
rb_hash_aset(rb_result, CSTR2SYM("indexed_objects"), UINT2NUM(stats->indexed_objects));
|
644
|
+
rb_hash_aset(rb_result, CSTR2SYM("received_objects"), UINT2NUM(stats->received_objects));
|
645
|
+
rb_hash_aset(rb_result, CSTR2SYM("local_objects"), UINT2NUM(stats->local_objects));
|
646
|
+
rb_hash_aset(rb_result, CSTR2SYM("total_deltas"), UINT2NUM(stats->total_deltas));
|
647
|
+
rb_hash_aset(rb_result, CSTR2SYM("indexed_deltas"), UINT2NUM(stats->indexed_deltas));
|
648
|
+
rb_hash_aset(rb_result, CSTR2SYM("received_bytes"), INT2FIX(stats->received_bytes));
|
649
|
+
}
|
650
|
+
|
651
|
+
cleanup:
|
652
|
+
|
653
|
+
git_signature_free(signature);
|
654
|
+
git_remote_free(tmp_remote);
|
655
|
+
|
656
|
+
if (payload.exception)
|
657
|
+
rb_jump_tag(payload.exception);
|
658
|
+
|
659
|
+
rugged_exception_check(error);
|
660
|
+
|
661
|
+
return rb_result;
|
662
|
+
}
|
663
|
+
|
664
|
+
static int push_status_cb(const char *ref, const char *msg, void *payload)
|
665
|
+
{
|
666
|
+
VALUE rb_result_hash = (VALUE)payload;
|
667
|
+
if (msg != NULL)
|
668
|
+
rb_hash_aset(rb_result_hash, rb_str_new_utf8(ref), rb_str_new_utf8(msg));
|
669
|
+
|
670
|
+
return GIT_OK;
|
579
671
|
}
|
580
672
|
|
581
673
|
/*
|
582
674
|
* call-seq:
|
583
|
-
*
|
675
|
+
* remote.push(refspecs = nil, options = {}) -> hash
|
676
|
+
*
|
677
|
+
* Pushes the given +refspecs+ to the given +remote+. Returns a hash that contains
|
678
|
+
* key-value pairs that reflect pushed refs and error messages, if applicable.
|
679
|
+
*
|
680
|
+
* You can optionally pass in an alternative list of +refspecs+ to use instead of the push
|
681
|
+
* refspecs already configured for +remote+.
|
682
|
+
*
|
683
|
+
* The following options can be passed in the +options+ Hash:
|
684
|
+
*
|
685
|
+
* :credentials ::
|
686
|
+
* The credentials to use for the push operation. Can be either an instance of one
|
687
|
+
* of the Rugged::Credentials types, or a proc returning one of the former.
|
688
|
+
* The proc will be called with the +url+, the +username+ from the url (if applicable) and
|
689
|
+
* a list of applicable credential types.
|
690
|
+
*
|
691
|
+
* :update_tips ::
|
692
|
+
* A callback that will be executed each time a reference is updated remotely. It will be
|
693
|
+
* passed the +refname+, +old_oid+ and +new_oid+.
|
584
694
|
*
|
585
|
-
*
|
695
|
+
* :message ::
|
696
|
+
* A single line log message to be appended to the reflog of each local remote-tracking
|
697
|
+
* branch that gets updated. Defaults to: "fetch".
|
586
698
|
*
|
587
|
-
*
|
699
|
+
* :signature ::
|
700
|
+
* The signature to be used for populating the reflog entries.
|
701
|
+
*
|
702
|
+
* Example:
|
703
|
+
*
|
704
|
+
* remote = Rugged::Remote.lookup(@repo, 'origin')
|
705
|
+
* remote.push(["refs/heads/master", ":refs/heads/to_be_deleted"])
|
588
706
|
*/
|
589
|
-
|
590
|
-
static VALUE rb_git_remote_names(VALUE klass, VALUE rb_repo)
|
707
|
+
static VALUE rb_git_remote_push(int argc, VALUE *argv, VALUE self)
|
591
708
|
{
|
592
|
-
|
593
|
-
|
594
|
-
VALUE
|
595
|
-
int error;
|
596
|
-
|
597
|
-
rugged_check_repo(rb_repo);
|
709
|
+
VALUE rb_refspecs, rb_options, rb_val;
|
710
|
+
VALUE rb_repo = rugged_owner(self);
|
711
|
+
VALUE rb_exception = Qnil, rb_result = rb_hash_new();
|
598
712
|
|
599
|
-
|
713
|
+
git_repository *repo;
|
714
|
+
git_remote *remote, *tmp_remote = NULL;
|
715
|
+
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
716
|
+
git_push *push = NULL;
|
717
|
+
git_signature *signature = NULL;
|
600
718
|
|
601
|
-
error =
|
602
|
-
|
719
|
+
int error = 0, i = 0;
|
720
|
+
char *log_message = NULL;
|
603
721
|
|
604
|
-
|
605
|
-
git_strarray_free(&remotes);
|
606
|
-
return rb_remote_names;
|
607
|
-
}
|
722
|
+
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, 0 };
|
608
723
|
|
609
|
-
|
610
|
-
static VALUE rb_git_remote_each(VALUE klass, VALUE rb_repo)
|
611
|
-
{
|
612
|
-
git_repository *repo;
|
613
|
-
git_strarray remotes;
|
614
|
-
size_t i;
|
615
|
-
int error = 0;
|
616
|
-
int exception = 0;
|
724
|
+
rb_scan_args(argc, argv, "01:", &rb_refspecs, &rb_options);
|
617
725
|
|
618
|
-
if (!
|
619
|
-
|
726
|
+
if (!NIL_P(rb_refspecs)) {
|
727
|
+
Check_Type(rb_refspecs, T_ARRAY);
|
728
|
+
for (i = 0; i < RARRAY_LEN(rb_refspecs); ++i) {
|
729
|
+
VALUE rb_refspec = rb_ary_entry(rb_refspecs, i);
|
730
|
+
Check_Type(rb_refspec, T_STRING);
|
731
|
+
}
|
732
|
+
}
|
620
733
|
|
621
734
|
rugged_check_repo(rb_repo);
|
622
735
|
Data_Get_Struct(rb_repo, git_repository, repo);
|
736
|
+
Data_Get_Struct(self, git_remote, remote);
|
623
737
|
|
624
|
-
|
625
|
-
|
738
|
+
if (!NIL_P(rb_options)) {
|
739
|
+
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
|
740
|
+
|
741
|
+
rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
|
742
|
+
if (!NIL_P(rb_val))
|
743
|
+
log_message = StringValueCStr(rb_val);
|
744
|
+
|
745
|
+
rb_val = rb_hash_aref(rb_options, CSTR2SYM("signature"));
|
746
|
+
if (!NIL_P(rb_val))
|
747
|
+
signature = rugged_signature_get(rb_val, repo);
|
748
|
+
}
|
749
|
+
|
750
|
+
// Create a temporary remote that we use for pushing
|
751
|
+
if ((error = git_remote_dup(&tmp_remote, remote)) ||
|
752
|
+
(error = git_remote_set_callbacks(tmp_remote, &callbacks)))
|
753
|
+
goto cleanup;
|
626
754
|
|
627
|
-
|
628
|
-
|
629
|
-
error = git_remote_load(&remote, repo, remotes.strings[i]);
|
755
|
+
if (!NIL_P(rb_refspecs)) {
|
756
|
+
git_remote_clear_refspecs(tmp_remote);
|
630
757
|
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
758
|
+
for (i = 0; !error && i < RARRAY_LEN(rb_refspecs); ++i) {
|
759
|
+
VALUE rb_refspec = rb_ary_entry(rb_refspecs, i);
|
760
|
+
|
761
|
+
if ((error = git_remote_add_push(tmp_remote, StringValueCStr(rb_refspec))))
|
762
|
+
goto cleanup;
|
635
763
|
}
|
636
764
|
}
|
637
765
|
|
638
|
-
|
766
|
+
if ((error = git_push_new(&push, tmp_remote)))
|
767
|
+
goto cleanup;
|
639
768
|
|
640
|
-
|
641
|
-
|
769
|
+
// TODO: Get rid of this once git_remote_push lands in libgit2.
|
770
|
+
{
|
771
|
+
git_strarray push_refspecs;
|
772
|
+
size_t i;
|
642
773
|
|
643
|
-
|
644
|
-
|
645
|
-
}
|
774
|
+
if ((error = git_remote_get_push_refspecs(&push_refspecs, tmp_remote)))
|
775
|
+
goto cleanup;
|
646
776
|
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
* Saves the remote data ( url, fetchspecs, ...) to the config
|
652
|
-
*
|
653
|
-
* One can't save a in-memory remote created with Remote.new.
|
654
|
-
* Doing so will result in an exception being raised.
|
655
|
-
*/
|
656
|
-
static VALUE rb_git_remote_save(VALUE self)
|
657
|
-
{
|
658
|
-
git_remote *remote;
|
777
|
+
if (push_refspecs.count == 0) {
|
778
|
+
rb_exception = rb_exc_new2(rb_eRuggedError, "no pushspecs are configured for the given remote");
|
779
|
+
goto cleanup;
|
780
|
+
}
|
659
781
|
|
660
|
-
|
782
|
+
for (i = 0; !error && i < push_refspecs.count; ++i) {
|
783
|
+
error = git_push_add_refspec(push, push_refspecs.strings[i]);
|
784
|
+
}
|
661
785
|
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
return Qtrue;
|
666
|
-
}
|
786
|
+
git_strarray_free(&push_refspecs);
|
787
|
+
if (error) goto cleanup;
|
788
|
+
}
|
667
789
|
|
668
|
-
|
669
|
-
|
670
|
-
rb_ary_push((VALUE) payload, rb_str_new_utf8(refspec_name));
|
671
|
-
return 0;
|
672
|
-
}
|
790
|
+
if ((error = git_push_finish(push)))
|
791
|
+
goto cleanup;
|
673
792
|
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
* Renames a remote
|
679
|
-
*
|
680
|
-
* All remote-tracking branches and configuration settings
|
681
|
-
* for the remote are updated.
|
682
|
-
*
|
683
|
-
* Returns +nil+ if everything was updated or array of fetch refspecs
|
684
|
-
* that haven't been automatically updated and need potential manual
|
685
|
-
* tweaking.
|
686
|
-
*
|
687
|
-
* A temporary in-memory remote, created with Remote.new
|
688
|
-
* cannot be given a name with this method.
|
689
|
-
* remote = Rugged::Remote.lookup(@repo, 'origin')
|
690
|
-
* remote.rename!('upstream') #=> nil
|
691
|
-
*
|
692
|
-
*/
|
693
|
-
static VALUE rb_git_remote_rename(VALUE self, VALUE rb_new_name)
|
694
|
-
{
|
695
|
-
git_remote *remote;
|
696
|
-
int error = 0;
|
697
|
-
VALUE rb_refspec_ary = rb_ary_new();
|
793
|
+
if (!git_push_unpack_ok(push)) {
|
794
|
+
rb_exception = rb_exc_new2(rb_eRuggedError, "the remote side did not unpack successfully");
|
795
|
+
goto cleanup;
|
796
|
+
}
|
698
797
|
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
798
|
+
if ((error = git_push_status_foreach(push, &push_status_cb, (void *)rb_result)) ||
|
799
|
+
(error = git_push_update_tips(push, signature, log_message)))
|
800
|
+
goto cleanup;
|
801
|
+
|
802
|
+
cleanup:
|
803
|
+
git_push_free(push);
|
804
|
+
git_remote_free(tmp_remote);
|
805
|
+
git_signature_free(signature);
|
806
|
+
|
807
|
+
if (!NIL_P(rb_exception))
|
808
|
+
rb_exc_raise(rb_exception);
|
705
809
|
|
706
810
|
rugged_exception_check(error);
|
707
811
|
|
708
|
-
return
|
812
|
+
return rb_result;
|
709
813
|
}
|
710
814
|
|
711
815
|
void Init_rugged_remote(void)
|
712
816
|
{
|
713
817
|
rb_cRuggedRemote = rb_define_class_under(rb_mRugged, "Remote", rb_cObject);
|
714
818
|
|
715
|
-
rb_define_singleton_method(rb_cRuggedRemote, "new", rb_git_remote_new, 2);
|
716
|
-
rb_define_singleton_method(rb_cRuggedRemote, "add", rb_git_remote_add, 3);
|
717
|
-
rb_define_singleton_method(rb_cRuggedRemote, "lookup", rb_git_remote_lookup, 2);
|
718
|
-
rb_define_singleton_method(rb_cRuggedRemote, "names", rb_git_remote_names, 1);
|
719
|
-
rb_define_singleton_method(rb_cRuggedRemote, "each", rb_git_remote_each, 1);
|
720
819
|
|
721
|
-
rb_define_method(rb_cRuggedRemote, "connect", rb_git_remote_connect, 1);
|
722
|
-
rb_define_method(rb_cRuggedRemote, "disconnect", rb_git_remote_disconnect, 0);
|
723
820
|
rb_define_method(rb_cRuggedRemote, "name", rb_git_remote_name, 0);
|
724
821
|
rb_define_method(rb_cRuggedRemote, "url", rb_git_remote_url, 0);
|
725
822
|
rb_define_method(rb_cRuggedRemote, "url=", rb_git_remote_set_url, 1);
|
@@ -729,10 +826,9 @@ void Init_rugged_remote(void)
|
|
729
826
|
rb_define_method(rb_cRuggedRemote, "push_refspecs", rb_git_remote_push_refspecs, 0);
|
730
827
|
rb_define_method(rb_cRuggedRemote, "add_fetch", rb_git_remote_add_fetch, 1);
|
731
828
|
rb_define_method(rb_cRuggedRemote, "add_push", rb_git_remote_add_push, 1);
|
732
|
-
rb_define_method(rb_cRuggedRemote, "
|
733
|
-
rb_define_method(rb_cRuggedRemote, "
|
734
|
-
rb_define_method(rb_cRuggedRemote, "
|
735
|
-
rb_define_method(rb_cRuggedRemote, "update_tips!", rb_git_remote_update_tips, 0);
|
829
|
+
rb_define_method(rb_cRuggedRemote, "ls", rb_git_remote_ls, -1);
|
830
|
+
rb_define_method(rb_cRuggedRemote, "fetch", rb_git_remote_fetch, -1);
|
831
|
+
rb_define_method(rb_cRuggedRemote, "push", rb_git_remote_push, -1);
|
736
832
|
rb_define_method(rb_cRuggedRemote, "clear_refspecs", rb_git_remote_clear_refspecs, 0);
|
737
833
|
rb_define_method(rb_cRuggedRemote, "save", rb_git_remote_save, 0);
|
738
834
|
rb_define_method(rb_cRuggedRemote, "rename!", rb_git_remote_rename, 1);
|