rugged 0.21.1b2 → 0.21.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -12
- data/ext/rugged/extconf.rb +8 -8
- data/ext/rugged/rugged.h +1 -1
- data/ext/rugged/rugged_blob.c +0 -57
- data/ext/rugged/rugged_cred.c +0 -23
- data/ext/rugged/rugged_index.c +2 -6
- data/ext/rugged/rugged_remote.c +1 -69
- data/ext/rugged/rugged_repo.c +5 -287
- data/ext/rugged/rugged_tag_collection.c +2 -70
- data/ext/rugged/rugged_tree.c +10 -29
- data/lib/rugged.rb +0 -2
- data/lib/rugged/diff.rb +1 -0
- data/lib/rugged/diff/line.rb +3 -1
- data/lib/rugged/patch.rb +2 -12
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +0 -11
- data/vendor/libgit2/deps/http-parser/http_parser.h +0 -2
- data/vendor/libgit2/deps/zlib/adler32.c +29 -39
- data/vendor/libgit2/deps/zlib/crc32.c +50 -33
- data/vendor/libgit2/deps/zlib/crc32.h +1 -1
- data/vendor/libgit2/deps/zlib/deflate.c +65 -198
- data/vendor/libgit2/deps/zlib/deflate.h +4 -8
- data/vendor/libgit2/deps/zlib/inffast.c +3 -3
- data/vendor/libgit2/deps/zlib/inffixed.h +3 -3
- data/vendor/libgit2/deps/zlib/inflate.c +52 -84
- data/vendor/libgit2/deps/zlib/inftrees.c +39 -15
- data/vendor/libgit2/deps/zlib/trees.c +36 -18
- data/vendor/libgit2/deps/zlib/zconf.h +0 -4
- data/vendor/libgit2/deps/zlib/zlib.h +95 -250
- data/vendor/libgit2/deps/zlib/zutil.c +10 -13
- data/vendor/libgit2/deps/zlib/zutil.h +62 -41
- data/vendor/libgit2/include/git2/attr.h +13 -16
- data/vendor/libgit2/include/git2/buffer.h +0 -16
- data/vendor/libgit2/include/git2/checkout.h +12 -12
- data/vendor/libgit2/include/git2/cherrypick.h +15 -15
- data/vendor/libgit2/include/git2/clone.h +69 -77
- data/vendor/libgit2/include/git2/diff.h +0 -7
- data/vendor/libgit2/include/git2/errors.h +0 -2
- data/vendor/libgit2/include/git2/merge.h +0 -16
- data/vendor/libgit2/include/git2/oid.h +4 -8
- data/vendor/libgit2/include/git2/remote.h +32 -13
- data/vendor/libgit2/include/git2/repository.h +1 -4
- data/vendor/libgit2/include/git2/reset.h +0 -4
- data/vendor/libgit2/include/git2/revert.h +1 -1
- data/vendor/libgit2/include/git2/status.h +14 -17
- data/vendor/libgit2/include/git2/submodule.h +0 -18
- data/vendor/libgit2/include/git2/sys/repository.h +0 -13
- data/vendor/libgit2/include/git2/transport.h +313 -79
- data/vendor/libgit2/include/git2/tree.h +2 -4
- data/vendor/libgit2/include/git2/types.h +6 -54
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/attr.c +4 -8
- data/vendor/libgit2/src/attr_file.c +1 -14
- data/vendor/libgit2/src/blame.c +1 -0
- data/vendor/libgit2/src/buf_text.c +5 -9
- data/vendor/libgit2/src/buf_text.h +2 -3
- data/vendor/libgit2/src/buffer.c +10 -67
- data/vendor/libgit2/src/buffer.h +2 -4
- data/vendor/libgit2/src/cache.c +9 -9
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/checkout.c +44 -121
- data/vendor/libgit2/src/cherrypick.c +44 -41
- data/vendor/libgit2/src/clone.c +56 -94
- data/vendor/libgit2/src/config_file.c +7 -2
- data/vendor/libgit2/src/crlf.c +1 -2
- data/vendor/libgit2/src/diff.c +0 -21
- data/vendor/libgit2/src/diff_file.c +0 -1
- data/vendor/libgit2/src/diff_print.c +9 -11
- data/vendor/libgit2/src/diff_tform.c +2 -4
- data/vendor/libgit2/src/errors.c +7 -9
- data/vendor/libgit2/src/filebuf.c +2 -0
- data/vendor/libgit2/src/fileops.c +7 -9
- data/vendor/libgit2/src/filter.c +11 -2
- data/vendor/libgit2/src/global.c +20 -3
- data/vendor/libgit2/src/global.h +0 -2
- data/vendor/libgit2/src/graph.c +2 -2
- data/vendor/libgit2/src/hashsig.c +1 -1
- data/vendor/libgit2/{include/git2/sys → src}/hashsig.h +7 -11
- data/vendor/libgit2/src/ignore.c +2 -2
- data/vendor/libgit2/src/indexer.c +1 -13
- data/vendor/libgit2/src/merge.c +145 -99
- data/vendor/libgit2/src/merge.h +1 -1
- data/vendor/libgit2/src/mwindow.c +8 -117
- data/vendor/libgit2/src/mwindow.h +1 -9
- data/vendor/libgit2/src/netops.c +7 -6
- data/vendor/libgit2/src/netops.h +4 -0
- data/vendor/libgit2/src/odb_loose.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +3 -6
- data/vendor/libgit2/src/oid.c +0 -8
- data/vendor/libgit2/src/oid.h +0 -11
- data/vendor/libgit2/src/pack.c +6 -20
- data/vendor/libgit2/src/pack.h +0 -3
- data/vendor/libgit2/src/path.c +64 -134
- data/vendor/libgit2/src/path.h +1 -22
- data/vendor/libgit2/src/posix.h +28 -46
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +2 -14
- data/vendor/libgit2/src/remote.c +26 -29
- data/vendor/libgit2/src/remote.h +1 -3
- data/vendor/libgit2/src/repository.c +14 -54
- data/vendor/libgit2/src/revert.c +6 -4
- data/vendor/libgit2/src/revparse.c +18 -15
- data/vendor/libgit2/src/signature.c +2 -2
- data/vendor/libgit2/src/stash.c +1 -2
- data/vendor/libgit2/src/status.c +2 -11
- data/vendor/libgit2/src/strnlen.h +1 -2
- data/vendor/libgit2/src/submodule.c +33 -73
- data/vendor/libgit2/src/tag.c +3 -2
- data/vendor/libgit2/src/thread-utils.h +7 -0
- data/vendor/libgit2/src/trace.h +1 -9
- data/vendor/libgit2/src/transport.c +90 -93
- data/vendor/libgit2/src/transports/cred.c +0 -58
- data/vendor/libgit2/src/transports/cred_helpers.c +0 -3
- data/vendor/libgit2/src/transports/git.c +0 -1
- data/vendor/libgit2/src/transports/http.c +82 -205
- data/vendor/libgit2/src/transports/smart.c +0 -2
- data/vendor/libgit2/src/transports/smart.h +0 -2
- data/vendor/libgit2/src/transports/smart_protocol.c +5 -7
- data/vendor/libgit2/src/transports/ssh.c +35 -224
- data/vendor/libgit2/src/transports/winhttp.c +34 -140
- data/vendor/libgit2/src/tree.c +60 -64
- data/vendor/libgit2/src/tree.h +3 -2
- data/vendor/libgit2/src/unix/posix.h +9 -23
- data/vendor/libgit2/src/unix/realpath.c +7 -8
- data/vendor/libgit2/src/util.c +1 -2
- data/vendor/libgit2/src/util.h +3 -3
- data/vendor/libgit2/src/win32/mingw-compat.h +12 -5
- data/vendor/libgit2/src/win32/msvc-compat.h +32 -3
- data/vendor/libgit2/src/win32/posix.h +31 -20
- data/vendor/libgit2/src/win32/posix_w32.c +18 -62
- metadata +5 -18
- data/lib/rugged/attributes.rb +0 -41
- data/lib/rugged/blob.rb +0 -28
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +0 -324
- data/vendor/libgit2/deps/zlib/infback.c +0 -640
- data/vendor/libgit2/include/git2/oidarray.h +0 -40
- data/vendor/libgit2/include/git2/sys/transport.h +0 -352
- data/vendor/libgit2/src/oidarray.c +0 -21
- data/vendor/libgit2/src/oidarray.h +0 -18
- data/vendor/libgit2/src/transports/auth.c +0 -71
- data/vendor/libgit2/src/transports/auth.h +0 -63
- data/vendor/libgit2/src/transports/auth_negotiate.c +0 -275
- data/vendor/libgit2/src/transports/auth_negotiate.h +0 -27
- data/vendor/libgit2/src/transports/cred.h +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fd19143d7ae79c19dcc780edd7399e0b96c677b
|
4
|
+
data.tar.gz: c2e501d2d3525acc5a3a2297bc3726fc0c3465f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b6f3fb73a8d64f10b2dcac66dc7bc6a27c8257bf72f9d2d02b7d3179bb24a096a36593c87b420cfd31e889425c72b725d81f551907115ef717101716bb4f390
|
7
|
+
data.tar.gz: 991a7b7aaa258c7fe858dedde2694493ce4af466e61ea42935fac3afe3ceaa1b80298f345f83cb82ee237256968ffe45faabfc182402d349ded4665bcf794424
|
data/README.md
CHANGED
@@ -17,12 +17,7 @@ Rugged is a self-contained gem. You can install it by running:
|
|
17
17
|
|
18
18
|
$ gem install rugged
|
19
19
|
|
20
|
-
You need to have CMake
|
21
|
-
```bash
|
22
|
-
$ brew install cmake
|
23
|
-
```
|
24
|
-
|
25
|
-
If you want to build Rugged with HTTPS and SSH support, check out the list of optional [libgit2 dependencies](https://github.com/libgit2/libgit2#optional-dependencies).
|
20
|
+
You need to have CMake installed on your system to be able to build the included version of `libgit2`. If you want to build Rugged with HTTPS and SSH support, check out the list of optional [libgit2 dependencies](https://github.com/libgit2/libgit2#optional-dependencies).
|
26
21
|
|
27
22
|
If you're using bundler and want to bundle `libgit2` with Rugged, you can use the `:submodules` option:
|
28
23
|
|
@@ -101,7 +96,7 @@ repo.bare?
|
|
101
96
|
# => false
|
102
97
|
repo.empty?
|
103
98
|
# => true
|
104
|
-
repo.
|
99
|
+
repo.head_orphan?
|
105
100
|
# => false
|
106
101
|
repo.head_detached?
|
107
102
|
# => false
|
@@ -114,15 +109,13 @@ repo.workdir
|
|
114
109
|
|
115
110
|
# The HEAD of the repository.
|
116
111
|
ref = repo.head
|
117
|
-
# => #<Rugged::Reference:2228467240 {name: "refs/heads/master", target:
|
112
|
+
# => #<Rugged::Reference:2228467240 {name: "refs/heads/master", target: "07b44cbda23b726e5d54e2ef383495922c024202"}>
|
118
113
|
|
119
|
-
# From the returned ref, you can also access the `name
|
114
|
+
# From the returned ref, you can also access the `name` and `target`:
|
120
115
|
ref.name
|
121
116
|
# => "refs/heads/master"
|
122
117
|
ref.target
|
123
|
-
# =>
|
124
|
-
ref.target_id
|
125
|
-
# => "2bc6a70483369f33f641ca44873497f13a15cde5"
|
118
|
+
# => "07b44cbda23b726e5d54e2ef383495922c024202"
|
126
119
|
|
127
120
|
# Reading an object
|
128
121
|
object = repo.read('a0ae5566e3c8a3bddffab21022056f0b5e03ef07')
|
data/ext/rugged/extconf.rb
CHANGED
@@ -15,10 +15,18 @@ def sys(cmd)
|
|
15
15
|
ret
|
16
16
|
end
|
17
17
|
|
18
|
+
if !find_executable('cmake')
|
19
|
+
abort "ERROR: CMake is required to build Rugged."
|
20
|
+
end
|
21
|
+
|
18
22
|
if !(MAKE = find_executable('gmake') || find_executable('make'))
|
19
23
|
abort "ERROR: GNU make is required to build Rugged."
|
20
24
|
end
|
21
25
|
|
26
|
+
if !find_executable('pkg-config')
|
27
|
+
abort "ERROR: pkg-config is required to build Rugged."
|
28
|
+
end
|
29
|
+
|
22
30
|
if arg_config("--use-system-libraries", !!ENV['RUGGED_USE_SYSTEM_LIBRARIES'])
|
23
31
|
puts "Building Rugged using system libraries.\n"
|
24
32
|
|
@@ -32,14 +40,6 @@ if arg_config("--use-system-libraries", !!ENV['RUGGED_USE_SYSTEM_LIBRARIES'])
|
|
32
40
|
#endif
|
33
41
|
SRC
|
34
42
|
else
|
35
|
-
if !find_executable('cmake')
|
36
|
-
abort "ERROR: CMake is required to build Rugged."
|
37
|
-
end
|
38
|
-
|
39
|
-
if !find_executable('pkg-config')
|
40
|
-
abort "ERROR: pkg-config is required to build Rugged."
|
41
|
-
end
|
42
|
-
|
43
43
|
CWD = File.expand_path(File.dirname(__FILE__))
|
44
44
|
LIBGIT2_DIR = File.join(CWD, '..', '..', 'vendor', 'libgit2')
|
45
45
|
|
data/ext/rugged/rugged.h
CHANGED
@@ -120,7 +120,7 @@ static inline VALUE rugged_owner(VALUE object)
|
|
120
120
|
static inline void rugged_validate_remote_url(VALUE rb_url)
|
121
121
|
{
|
122
122
|
Check_Type(rb_url, T_STRING);
|
123
|
-
if (!
|
123
|
+
if (!git_remote_valid_url(StringValueCStr(rb_url)))
|
124
124
|
rb_raise(rb_eArgError, "Invalid URL format");
|
125
125
|
}
|
126
126
|
|
data/ext/rugged/rugged_blob.c
CHANGED
@@ -24,7 +24,6 @@
|
|
24
24
|
|
25
25
|
#include "rugged.h"
|
26
26
|
#include <ctype.h>
|
27
|
-
#include <git2/sys/hashsig.h>
|
28
27
|
|
29
28
|
extern VALUE rb_mRugged;
|
30
29
|
extern VALUE rb_cRuggedObject;
|
@@ -32,7 +31,6 @@ extern VALUE rb_cRuggedRepo;
|
|
32
31
|
static ID id_read;
|
33
32
|
|
34
33
|
VALUE rb_cRuggedBlob;
|
35
|
-
VALUE rb_cRuggedBlobSig;
|
36
34
|
|
37
35
|
/*
|
38
36
|
* call-seq:
|
@@ -522,57 +520,6 @@ static VALUE rb_git_blob_to_buffer(int argc, VALUE *argv, VALUE self)
|
|
522
520
|
return rb_ret;
|
523
521
|
}
|
524
522
|
|
525
|
-
static VALUE rb_git_blob_sig_new(int argc, VALUE *argv, VALUE klass)
|
526
|
-
{
|
527
|
-
int error, opts = 0;
|
528
|
-
git_hashsig *sig;
|
529
|
-
VALUE rb_blob, rb_options;
|
530
|
-
|
531
|
-
if (rb_scan_args(argc, argv, "11", &rb_blob, &rb_options) == 2) {
|
532
|
-
Check_Type(rb_options, T_FIXNUM);
|
533
|
-
opts = FIX2INT(rb_options);
|
534
|
-
}
|
535
|
-
|
536
|
-
if (rb_obj_is_kind_of(rb_blob, rb_cRuggedBlob)) {
|
537
|
-
git_blob *blob;
|
538
|
-
Data_Get_Struct(rb_blob, git_blob, blob);
|
539
|
-
|
540
|
-
error = git_hashsig_create(&sig,
|
541
|
-
git_blob_rawcontent(blob),
|
542
|
-
git_blob_rawsize(blob),
|
543
|
-
opts);
|
544
|
-
} else {
|
545
|
-
Check_Type(rb_blob, T_STRING);
|
546
|
-
error = git_hashsig_create(&sig, RSTRING_PTR(rb_blob), RSTRING_LEN(rb_blob), opts);
|
547
|
-
}
|
548
|
-
|
549
|
-
rugged_exception_check(error);
|
550
|
-
|
551
|
-
return Data_Wrap_Struct(klass, NULL, &git_hashsig_free, sig);
|
552
|
-
}
|
553
|
-
|
554
|
-
static VALUE rb_git_blob_sig_compare(VALUE self, VALUE rb_sig_a, VALUE rb_sig_b)
|
555
|
-
{
|
556
|
-
git_hashsig *sig_a;
|
557
|
-
git_hashsig *sig_b;
|
558
|
-
int result;
|
559
|
-
|
560
|
-
if (!rb_obj_is_kind_of(rb_sig_a, rb_cRuggedBlobSig) ||
|
561
|
-
!rb_obj_is_kind_of(rb_sig_b, rb_cRuggedBlobSig)) {
|
562
|
-
rb_raise(rb_eTypeError, "Expected Rugged::Blob::HashSignature");
|
563
|
-
}
|
564
|
-
|
565
|
-
Data_Get_Struct(rb_sig_a, git_hashsig, sig_a);
|
566
|
-
Data_Get_Struct(rb_sig_b, git_hashsig, sig_b);
|
567
|
-
|
568
|
-
result = git_hashsig_compare(sig_a, sig_b);
|
569
|
-
|
570
|
-
if (result < 0)
|
571
|
-
rugged_exception_check(result);
|
572
|
-
|
573
|
-
return INT2FIX(result);
|
574
|
-
}
|
575
|
-
|
576
523
|
void Init_rugged_blob(void)
|
577
524
|
{
|
578
525
|
id_read = rb_intern("read");
|
@@ -592,8 +539,4 @@ void Init_rugged_blob(void)
|
|
592
539
|
rb_define_singleton_method(rb_cRuggedBlob, "from_io", rb_git_blob_from_io, -1);
|
593
540
|
|
594
541
|
rb_define_singleton_method(rb_cRuggedBlob, "to_buffer", rb_git_blob_to_buffer, -1);
|
595
|
-
|
596
|
-
rb_cRuggedBlobSig = rb_define_class_under(rb_cRuggedBlob, "HashSignature", rb_cObject);
|
597
|
-
rb_define_singleton_method(rb_cRuggedBlobSig, "new", rb_git_blob_sig_new, -1);
|
598
|
-
rb_define_singleton_method(rb_cRuggedBlobSig, "compare", rb_git_blob_sig_compare, 2);
|
599
542
|
}
|
data/ext/rugged/rugged_cred.c
CHANGED
@@ -88,42 +88,19 @@ static void rugged_cred_extract_default(git_cred **cred, VALUE rb_credential)
|
|
88
88
|
rugged_exception_check(git_cred_default_new(cred));
|
89
89
|
}
|
90
90
|
|
91
|
-
static void rugged_cred_extract_username(git_cred **cred, VALUE rb_credential)
|
92
|
-
{
|
93
|
-
VALUE rb_username = rb_iv_get(rb_credential, "@username");
|
94
|
-
Check_Type(rb_username, T_STRING);
|
95
|
-
|
96
|
-
rugged_exception_check(git_cred_username_new(cred, StringValueCStr(rb_username)));
|
97
|
-
}
|
98
|
-
|
99
91
|
void rugged_cred_extract(git_cred **cred, int allowed_types, VALUE rb_credential)
|
100
92
|
{
|
101
93
|
if (rb_obj_is_kind_of(rb_credential, rb_cRuggedCredUserPassword)) {
|
102
|
-
if (allowed_types & GIT_CREDTYPE_USERNAME) {
|
103
|
-
rugged_cred_extract_username(cred, rb_credential);
|
104
|
-
return;
|
105
|
-
}
|
106
|
-
|
107
94
|
if (!(allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT))
|
108
95
|
rb_raise(rb_eArgError, "Invalid credential type");
|
109
96
|
|
110
97
|
rugged_cred_extract_userpass(cred, rb_credential);
|
111
98
|
} else if (rb_obj_is_kind_of(rb_credential, rb_cRuggedCredSshKey)) {
|
112
|
-
if (allowed_types & GIT_CREDTYPE_USERNAME) {
|
113
|
-
rugged_cred_extract_username(cred, rb_credential);
|
114
|
-
return;
|
115
|
-
}
|
116
|
-
|
117
99
|
if (!(allowed_types & GIT_CREDTYPE_SSH_KEY))
|
118
100
|
rb_raise(rb_eArgError, "Invalid credential type");
|
119
101
|
|
120
102
|
rugged_cred_extract_ssh_key(cred, rb_credential);
|
121
103
|
} else if (rb_obj_is_kind_of(rb_credential, rb_cRuggedCredSshKeyFromAgent)) {
|
122
|
-
if (allowed_types & GIT_CREDTYPE_USERNAME) {
|
123
|
-
rugged_cred_extract_username(cred, rb_credential);
|
124
|
-
return;
|
125
|
-
}
|
126
|
-
|
127
104
|
if (!(allowed_types & GIT_CREDTYPE_SSH_KEY))
|
128
105
|
rb_raise(rb_eArgError, "Invalid credential type");
|
129
106
|
|
data/ext/rugged/rugged_index.c
CHANGED
@@ -681,10 +681,6 @@ static VALUE rb_git_index_readtree(VALUE self, VALUE rb_tree)
|
|
681
681
|
Data_Get_Struct(self, git_index, index);
|
682
682
|
Data_Get_Struct(rb_tree, git_tree, tree);
|
683
683
|
|
684
|
-
if (!rb_obj_is_kind_of(rb_tree, rb_cRuggedTree)) {
|
685
|
-
rb_raise(rb_eTypeError, "A Rugged::Tree instance is required");
|
686
|
-
}
|
687
|
-
|
688
684
|
error = git_index_read_tree(index, tree);
|
689
685
|
rugged_exception_check(error);
|
690
686
|
|
@@ -756,7 +752,7 @@ static VALUE rb_git_index_readtree(VALUE self, VALUE rb_tree)
|
|
756
752
|
* :recurse_untracked_dirs ::
|
757
753
|
* Even if +:include_untracked+ is true, untracked directories will only be
|
758
754
|
* marked with a single entry in the diff. If this flag is set to true,
|
759
|
-
* all files under ignored directories will be included in the
|
755
|
+
* all files under ignored directories will be included in the di ff, too.
|
760
756
|
*
|
761
757
|
* :disable_pathspec_match ::
|
762
758
|
* If true, the given +:paths+ will be applied as exact matches, instead of
|
@@ -835,7 +831,7 @@ static VALUE rb_git_index_diff(int argc, VALUE *argv, VALUE self)
|
|
835
831
|
xfree(opts.pathspec.strings);
|
836
832
|
rugged_exception_check(error);
|
837
833
|
|
838
|
-
return rugged_diff_new(rb_cRuggedDiff,
|
834
|
+
return rugged_diff_new(rb_cRuggedDiff, self, diff);
|
839
835
|
}
|
840
836
|
|
841
837
|
/*
|
data/ext/rugged/rugged_remote.c
CHANGED
@@ -29,7 +29,7 @@ extern VALUE rb_cRuggedRepo;
|
|
29
29
|
extern VALUE rb_eRuggedError;
|
30
30
|
VALUE rb_cRuggedRemote;
|
31
31
|
|
32
|
-
#define RUGGED_REMOTE_CALLBACKS_INIT {1, progress_cb, NULL, credentials_cb,
|
32
|
+
#define RUGGED_REMOTE_CALLBACKS_INIT {1, progress_cb, NULL, credentials_cb, transfer_progress_cb, update_tips_cb, NULL}
|
33
33
|
|
34
34
|
static int progress_cb(const char *str, int len, void *data)
|
35
35
|
{
|
@@ -535,73 +535,6 @@ static VALUE rb_git_remote_rename(VALUE self, VALUE rb_new_name)
|
|
535
535
|
return rb_result;
|
536
536
|
}
|
537
537
|
|
538
|
-
/*
|
539
|
-
* call-seq:
|
540
|
-
* remote.check_connection(direction, options = {}) -> boolean
|
541
|
-
*
|
542
|
-
* Try to connect to the +remote+. Useful to simulate
|
543
|
-
* <tt>git fetch --dry-run</tt> and <tt>git push --dry-run</tt>.
|
544
|
-
*
|
545
|
-
* Returns +true+ if connection is successful, +false+ otherwise.
|
546
|
-
*
|
547
|
-
* +direction+ must be either +:fetch+ or +:push+.
|
548
|
-
*
|
549
|
-
* The following options can be passed in the +options+ Hash:
|
550
|
-
*
|
551
|
-
* +credentials+ ::
|
552
|
-
* The credentials to use for the connection. Can be either an instance of
|
553
|
-
* one of the Rugged::Credentials types, or a proc returning one of the
|
554
|
-
* former.
|
555
|
-
* The proc will be called with the +url+, the +username+ from the url (if
|
556
|
-
* applicable) and a list of applicable credential types.
|
557
|
-
*
|
558
|
-
* Example:
|
559
|
-
*
|
560
|
-
* remote = repo.remotes["origin"]
|
561
|
-
* success = remote.check_connection(:fetch)
|
562
|
-
* raise Error("Unable to pull without credentials") unless success
|
563
|
-
*/
|
564
|
-
static VALUE rb_git_remote_check_connection(int argc, VALUE *argv, VALUE self)
|
565
|
-
{
|
566
|
-
git_remote *remote;
|
567
|
-
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
568
|
-
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
|
569
|
-
VALUE rb_direction, rb_options;
|
570
|
-
ID id_direction;
|
571
|
-
int error, direction;
|
572
|
-
|
573
|
-
Data_Get_Struct(self, git_remote, remote);
|
574
|
-
rb_scan_args(argc, argv, "01:", &rb_direction, &rb_options);
|
575
|
-
|
576
|
-
Check_Type(rb_direction, T_SYMBOL);
|
577
|
-
id_direction = SYM2ID(rb_direction);
|
578
|
-
if (id_direction == rb_intern("fetch"))
|
579
|
-
direction = GIT_DIRECTION_FETCH;
|
580
|
-
else if (id_direction == rb_intern("push"))
|
581
|
-
direction = GIT_DIRECTION_PUSH;
|
582
|
-
else
|
583
|
-
rb_raise(rb_eTypeError, "Invalid direction. Expected :fetch or :push");
|
584
|
-
|
585
|
-
if (!NIL_P(rb_options))
|
586
|
-
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
|
587
|
-
|
588
|
-
if ((error = git_remote_set_callbacks(remote, &callbacks)) < 0)
|
589
|
-
goto cleanup;
|
590
|
-
|
591
|
-
if (git_remote_connect(remote, direction))
|
592
|
-
return Qfalse;
|
593
|
-
else {
|
594
|
-
git_remote_disconnect(remote);
|
595
|
-
return Qtrue;
|
596
|
-
}
|
597
|
-
|
598
|
-
cleanup:
|
599
|
-
if (payload.exception)
|
600
|
-
rb_jump_tag(payload.exception);
|
601
|
-
rugged_exception_check(error);
|
602
|
-
return Qfalse;
|
603
|
-
}
|
604
|
-
|
605
538
|
/*
|
606
539
|
* call-seq:
|
607
540
|
* remote.fetch(refspecs = nil, options = {}) -> hash
|
@@ -894,7 +827,6 @@ void Init_rugged_remote(void)
|
|
894
827
|
rb_define_method(rb_cRuggedRemote, "add_fetch", rb_git_remote_add_fetch, 1);
|
895
828
|
rb_define_method(rb_cRuggedRemote, "add_push", rb_git_remote_add_push, 1);
|
896
829
|
rb_define_method(rb_cRuggedRemote, "ls", rb_git_remote_ls, -1);
|
897
|
-
rb_define_method(rb_cRuggedRemote, "check_connection", rb_git_remote_check_connection, -1);
|
898
830
|
rb_define_method(rb_cRuggedRemote, "fetch", rb_git_remote_fetch, -1);
|
899
831
|
rb_define_method(rb_cRuggedRemote, "push", rb_git_remote_push, -1);
|
900
832
|
rb_define_method(rb_cRuggedRemote, "clear_refspecs", rb_git_remote_clear_refspecs, 0);
|
data/ext/rugged/rugged_repo.c
CHANGED
@@ -643,10 +643,9 @@ static VALUE rb_git_repo_merge_commits(int argc, VALUE *argv, VALUE self)
|
|
643
643
|
* repo.exists?(oid) -> true or false
|
644
644
|
*
|
645
645
|
* Return whether an object with the given SHA1 OID (represented as
|
646
|
-
* a
|
646
|
+
* a 40-character string) exists in the repository.
|
647
647
|
*
|
648
648
|
* repo.include?("d8786bfc97485e8d7b19b21fb88c8ef1f199fc3f") #=> true
|
649
|
-
* repo.include?("d8786bfc") #=> true
|
650
649
|
*/
|
651
650
|
static VALUE rb_git_repo_exists(VALUE self, VALUE hex)
|
652
651
|
{
|
@@ -654,23 +653,21 @@ static VALUE rb_git_repo_exists(VALUE self, VALUE hex)
|
|
654
653
|
git_odb *odb;
|
655
654
|
git_oid oid;
|
656
655
|
int error;
|
656
|
+
VALUE rb_result;
|
657
657
|
|
658
658
|
Data_Get_Struct(self, git_repository, repo);
|
659
659
|
Check_Type(hex, T_STRING);
|
660
660
|
|
661
|
-
error =
|
661
|
+
error = git_oid_fromstr(&oid, StringValueCStr(hex));
|
662
662
|
rugged_exception_check(error);
|
663
663
|
|
664
664
|
error = git_repository_odb(&odb, repo);
|
665
665
|
rugged_exception_check(error);
|
666
666
|
|
667
|
-
|
667
|
+
rb_result = git_odb_exists(odb, &oid) ? Qtrue : Qfalse;
|
668
668
|
git_odb_free(odb);
|
669
669
|
|
670
|
-
|
671
|
-
return Qtrue;
|
672
|
-
|
673
|
-
return Qfalse;
|
670
|
+
return rb_result;
|
674
671
|
}
|
675
672
|
|
676
673
|
/*
|
@@ -739,107 +736,6 @@ static VALUE rb_git_repo_read_header(VALUE self, VALUE hex)
|
|
739
736
|
return rb_hash;
|
740
737
|
}
|
741
738
|
|
742
|
-
/**
|
743
|
-
* call-seq:
|
744
|
-
* repo.expand_oids([oid..], object_type = :any) -> hash
|
745
|
-
*
|
746
|
-
* Expand a list of short oids to their full value, assuming they exist
|
747
|
-
* in the repository. If `object_type` is passed, OIDs are expected to be
|
748
|
-
* of the given type.
|
749
|
-
*
|
750
|
-
* Returns a hash of `{ short_oid => full_oid }` for the short OIDs which
|
751
|
-
* exist in the repository and match the expected object type. Missing OIDs
|
752
|
-
* will not appear in the resulting hash.
|
753
|
-
*/
|
754
|
-
static VALUE rb_git_repo_expand_oids(int argc, VALUE *argv, VALUE self)
|
755
|
-
{
|
756
|
-
VALUE rb_result, rb_oids, rb_expected_type;
|
757
|
-
|
758
|
-
git_otype expected_type = GIT_OBJ_ANY;
|
759
|
-
|
760
|
-
git_repository *repo;
|
761
|
-
git_oid oid;
|
762
|
-
git_odb *odb;
|
763
|
-
int i, error;
|
764
|
-
|
765
|
-
Data_Get_Struct(self, git_repository, repo);
|
766
|
-
|
767
|
-
rb_scan_args(argc, argv, "11", &rb_oids, &rb_expected_type);
|
768
|
-
|
769
|
-
Check_Type(rb_oids, T_ARRAY);
|
770
|
-
expected_type = rugged_otype_get(rb_expected_type);
|
771
|
-
|
772
|
-
error = git_repository_odb(&odb, repo);
|
773
|
-
rugged_exception_check(error);
|
774
|
-
|
775
|
-
rb_result = rb_hash_new();
|
776
|
-
|
777
|
-
for (i = 0; i < RARRAY_LEN(rb_oids); ++i) {
|
778
|
-
VALUE hex_oid = rb_ary_entry(rb_oids, i);
|
779
|
-
git_oid found_oid;
|
780
|
-
|
781
|
-
if (TYPE(hex_oid) != T_STRING) {
|
782
|
-
git_odb_free(odb);
|
783
|
-
rb_raise(rb_eTypeError, "Expected a SHA1 OID");
|
784
|
-
}
|
785
|
-
|
786
|
-
error = git_oid_fromstrn(&oid, RSTRING_PTR(hex_oid), RSTRING_LEN(hex_oid));
|
787
|
-
if (error < 0) {
|
788
|
-
git_odb_free(odb);
|
789
|
-
rugged_exception_check(error);
|
790
|
-
}
|
791
|
-
|
792
|
-
error = git_odb_exists_prefix(&found_oid, odb, &oid, RSTRING_LEN(hex_oid));
|
793
|
-
|
794
|
-
if (!error) {
|
795
|
-
if (expected_type != GIT_OBJ_ANY) {
|
796
|
-
size_t found_size;
|
797
|
-
git_otype found_type;
|
798
|
-
|
799
|
-
if (git_odb_read_header(&found_size, &found_type, odb, &found_oid) < 0)
|
800
|
-
continue;
|
801
|
-
|
802
|
-
if (found_type != expected_type)
|
803
|
-
continue;
|
804
|
-
}
|
805
|
-
|
806
|
-
rb_hash_aset(rb_result, hex_oid, rugged_create_oid(&found_oid));
|
807
|
-
}
|
808
|
-
}
|
809
|
-
|
810
|
-
git_odb_free(odb);
|
811
|
-
return rb_result;
|
812
|
-
}
|
813
|
-
|
814
|
-
/*
|
815
|
-
* call-seq:
|
816
|
-
* repo.descendant_of?(commit, ancestor) -> true or false
|
817
|
-
*
|
818
|
-
* +commit+ and +ancestor+ must be String commit OIDs or instances of Rugged::Commit.
|
819
|
-
*
|
820
|
-
* Returns true if +commit+ is a descendant of +ancestor+, or false if not.
|
821
|
-
*/
|
822
|
-
static VALUE rb_git_repo_descendant_of(VALUE self, VALUE rb_commit, VALUE rb_ancestor)
|
823
|
-
{
|
824
|
-
int result;
|
825
|
-
int error;
|
826
|
-
git_repository *repo;
|
827
|
-
git_oid commit, ancestor;
|
828
|
-
|
829
|
-
Data_Get_Struct(self, git_repository, repo);
|
830
|
-
|
831
|
-
error = rugged_oid_get(&commit, repo, rb_commit);
|
832
|
-
rugged_exception_check(error);
|
833
|
-
|
834
|
-
error = rugged_oid_get(&ancestor, repo, rb_ancestor);
|
835
|
-
rugged_exception_check(error);
|
836
|
-
|
837
|
-
result = git_graph_descendant_of(repo, &commit, &ancestor);
|
838
|
-
rugged_exception_check(result);
|
839
|
-
|
840
|
-
return result ? Qtrue : Qfalse;
|
841
|
-
}
|
842
|
-
|
843
739
|
/*
|
844
740
|
* call-seq:
|
845
741
|
* Repository.hash_data(str, type) -> oid
|
@@ -2028,179 +1924,6 @@ static VALUE rb_git_repo_is_path_ignored(VALUE self, VALUE rb_path) {
|
|
2028
1924
|
return ignored ? Qtrue : Qfalse;
|
2029
1925
|
}
|
2030
1926
|
|
2031
|
-
static void rugged_parse_cherrypick_options(git_cherrypick_options *opts, VALUE rb_options)
|
2032
|
-
{
|
2033
|
-
VALUE rb_value;
|
2034
|
-
|
2035
|
-
if (NIL_P(rb_options))
|
2036
|
-
return;
|
2037
|
-
|
2038
|
-
Check_Type(rb_options, T_HASH);
|
2039
|
-
|
2040
|
-
rb_value = rb_hash_aref(rb_options, CSTR2SYM("mainline"));
|
2041
|
-
if (!NIL_P(rb_value)) {
|
2042
|
-
opts->mainline = FIX2UINT(rb_value);
|
2043
|
-
}
|
2044
|
-
}
|
2045
|
-
|
2046
|
-
static VALUE rugged_create_attr(const char *attr)
|
2047
|
-
{
|
2048
|
-
switch (git_attr_value(attr)) {
|
2049
|
-
case GIT_ATTR_TRUE_T:
|
2050
|
-
return Qtrue;
|
2051
|
-
|
2052
|
-
case GIT_ATTR_FALSE_T:
|
2053
|
-
return Qfalse;
|
2054
|
-
|
2055
|
-
case GIT_ATTR_VALUE_T:
|
2056
|
-
return rb_str_new2(attr);
|
2057
|
-
|
2058
|
-
case GIT_ATTR_UNSPECIFIED_T:
|
2059
|
-
default:
|
2060
|
-
return Qnil;
|
2061
|
-
}
|
2062
|
-
}
|
2063
|
-
|
2064
|
-
static int foreach_attr_hash(const char *name, const char *value, void *payload)
|
2065
|
-
{
|
2066
|
-
VALUE rb_hash = (VALUE)payload;
|
2067
|
-
rb_hash_aset(rb_hash, rb_str_new2(name), rugged_create_attr(value));
|
2068
|
-
return 0;
|
2069
|
-
}
|
2070
|
-
|
2071
|
-
static VALUE rb_git_repo_attributes(int argc, VALUE *argv, VALUE self)
|
2072
|
-
{
|
2073
|
-
VALUE rb_path, rb_names, rb_options;
|
2074
|
-
|
2075
|
-
git_repository *repo;
|
2076
|
-
int error, options = 0;
|
2077
|
-
|
2078
|
-
rb_scan_args(argc, argv, "12", &rb_path, &rb_names, &rb_options);
|
2079
|
-
|
2080
|
-
Data_Get_Struct(self, git_repository, repo);
|
2081
|
-
Check_Type(rb_path, T_STRING);
|
2082
|
-
|
2083
|
-
if (!NIL_P(rb_options)) {
|
2084
|
-
Check_Type(rb_options, T_FIXNUM);
|
2085
|
-
options = FIX2INT(rb_options);
|
2086
|
-
}
|
2087
|
-
|
2088
|
-
switch (TYPE(rb_names)) {
|
2089
|
-
case T_ARRAY:
|
2090
|
-
{
|
2091
|
-
VALUE rb_result;
|
2092
|
-
const char **values;
|
2093
|
-
const char **names;
|
2094
|
-
int i, num_attr = RARRAY_LEN(rb_names);
|
2095
|
-
|
2096
|
-
if (num_attr > 32)
|
2097
|
-
rb_raise(rb_eRuntimeError, "Too many attributes requested");
|
2098
|
-
|
2099
|
-
values = alloca(num_attr * sizeof(const char *));
|
2100
|
-
names = alloca(num_attr * sizeof(const char *));
|
2101
|
-
|
2102
|
-
for (i = 0; i < num_attr; ++i) {
|
2103
|
-
VALUE attr = rb_ary_entry(rb_names, i);
|
2104
|
-
Check_Type(attr, T_STRING);
|
2105
|
-
names[i] = StringValueCStr(attr);
|
2106
|
-
}
|
2107
|
-
|
2108
|
-
error = git_attr_get_many(
|
2109
|
-
values, repo, options,
|
2110
|
-
StringValueCStr(rb_path),
|
2111
|
-
(size_t)num_attr, names);
|
2112
|
-
|
2113
|
-
rugged_exception_check(error);
|
2114
|
-
|
2115
|
-
rb_result = rb_hash_new();
|
2116
|
-
for (i = 0; i < num_attr; ++i) {
|
2117
|
-
VALUE attr = rb_ary_entry(rb_names, i);
|
2118
|
-
rb_hash_aset(rb_result, attr, rugged_create_attr(values[i]));
|
2119
|
-
}
|
2120
|
-
return rb_result;
|
2121
|
-
}
|
2122
|
-
|
2123
|
-
case T_STRING:
|
2124
|
-
{
|
2125
|
-
const char *value;
|
2126
|
-
|
2127
|
-
error = git_attr_get(
|
2128
|
-
&value, repo, options,
|
2129
|
-
StringValueCStr(rb_path),
|
2130
|
-
StringValueCStr(rb_names));
|
2131
|
-
|
2132
|
-
rugged_exception_check(error);
|
2133
|
-
|
2134
|
-
return rugged_create_attr(value);
|
2135
|
-
}
|
2136
|
-
|
2137
|
-
case T_NIL:
|
2138
|
-
{
|
2139
|
-
VALUE rb_result = rb_hash_new();
|
2140
|
-
|
2141
|
-
error = git_attr_foreach(
|
2142
|
-
repo, options,
|
2143
|
-
StringValueCStr(rb_path),
|
2144
|
-
&foreach_attr_hash,
|
2145
|
-
(void *)rb_result);
|
2146
|
-
|
2147
|
-
rugged_exception_check(error);
|
2148
|
-
return rb_result;
|
2149
|
-
}
|
2150
|
-
|
2151
|
-
default:
|
2152
|
-
rb_raise(rb_eTypeError,
|
2153
|
-
"Invalid attribute name (expected String or Array)");
|
2154
|
-
}
|
2155
|
-
}
|
2156
|
-
|
2157
|
-
/*
|
2158
|
-
* call-seq:
|
2159
|
-
* repo.cherrypick(commit[, options]) -> nil
|
2160
|
-
*
|
2161
|
-
* Cherry-pick the given commit and update the index and working
|
2162
|
-
* directory accordingly.
|
2163
|
-
*
|
2164
|
-
* `commit` can be either a string containing a commit id or a
|
2165
|
-
* `Rugged::Commit` object.
|
2166
|
-
*
|
2167
|
-
* The following options can be passed in the +options+ Hash:
|
2168
|
-
*
|
2169
|
-
* :mainline ::
|
2170
|
-
* When cherry-picking a merge, you need to specify the parent number
|
2171
|
-
* (starting from 1) which should be considered the mainline.
|
2172
|
-
*/
|
2173
|
-
static VALUE rb_git_repo_cherrypick(int argc, VALUE *argv, VALUE self)
|
2174
|
-
{
|
2175
|
-
VALUE rb_options, rb_commit;
|
2176
|
-
|
2177
|
-
git_repository *repo;
|
2178
|
-
git_commit *commit;
|
2179
|
-
git_cherrypick_options opts = GIT_CHERRYPICK_OPTIONS_INIT;
|
2180
|
-
|
2181
|
-
int error;
|
2182
|
-
|
2183
|
-
rb_scan_args(argc, argv, "10:", &rb_commit, &rb_options);
|
2184
|
-
|
2185
|
-
if (TYPE(rb_commit) == T_STRING) {
|
2186
|
-
rb_commit = rugged_object_rev_parse(self, rb_commit, 1);
|
2187
|
-
}
|
2188
|
-
|
2189
|
-
if (!rb_obj_is_kind_of(rb_commit, rb_cRuggedCommit)) {
|
2190
|
-
rb_raise(rb_eArgError, "Expected a Rugged::Commit.");
|
2191
|
-
}
|
2192
|
-
|
2193
|
-
Data_Get_Struct(self, git_repository, repo);
|
2194
|
-
Data_Get_Struct(rb_commit, git_commit, commit);
|
2195
|
-
|
2196
|
-
rugged_parse_cherrypick_options(&opts, rb_options);
|
2197
|
-
|
2198
|
-
error = git_cherrypick(repo, commit, &opts);
|
2199
|
-
rugged_exception_check(error);
|
2200
|
-
|
2201
|
-
return Qnil;
|
2202
|
-
}
|
2203
|
-
|
2204
1927
|
void Init_rugged_repo(void)
|
2205
1928
|
{
|
2206
1929
|
id_call = rb_intern("call");
|
@@ -2219,8 +1942,6 @@ void Init_rugged_repo(void)
|
|
2219
1942
|
|
2220
1943
|
rb_define_method(rb_cRuggedRepo, "exists?", rb_git_repo_exists, 1);
|
2221
1944
|
rb_define_method(rb_cRuggedRepo, "include?", rb_git_repo_exists, 1);
|
2222
|
-
rb_define_method(rb_cRuggedRepo, "expand_oids", rb_git_repo_expand_oids, -1);
|
2223
|
-
rb_define_method(rb_cRuggedRepo, "descendant_of?", rb_git_repo_descendant_of, 2);
|
2224
1945
|
|
2225
1946
|
rb_define_method(rb_cRuggedRepo, "read", rb_git_repo_read, 1);
|
2226
1947
|
rb_define_method(rb_cRuggedRepo, "read_header", rb_git_repo_read_header, 1);
|
@@ -2265,9 +1986,6 @@ void Init_rugged_repo(void)
|
|
2265
1986
|
rb_define_method(rb_cRuggedRepo, "checkout_tree", rb_git_checkout_tree, -1);
|
2266
1987
|
rb_define_method(rb_cRuggedRepo, "checkout_head", rb_git_checkout_head, -1);
|
2267
1988
|
|
2268
|
-
rb_define_method(rb_cRuggedRepo, "cherrypick", rb_git_repo_cherrypick, -1);
|
2269
|
-
rb_define_method(rb_cRuggedRepo, "fetch_attributes", rb_git_repo_attributes, -1);
|
2270
|
-
|
2271
1989
|
rb_cRuggedOdbObject = rb_define_class_under(rb_mRugged, "OdbObject", rb_cObject);
|
2272
1990
|
rb_define_method(rb_cRuggedOdbObject, "data", rb_git_odbobj_data, 0);
|
2273
1991
|
rb_define_method(rb_cRuggedOdbObject, "len", rb_git_odbobj_size, 0);
|