rugged 0.21.4 → 0.22.0b1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -5
- data/ext/rugged/extconf.rb +9 -9
- data/ext/rugged/rugged.c +4 -2
- data/ext/rugged/rugged.h +3 -7
- data/ext/rugged/rugged_blob.c +57 -0
- data/ext/rugged/rugged_cred.c +23 -0
- data/ext/rugged/rugged_index.c +6 -2
- data/ext/rugged/rugged_remote.c +65 -52
- data/ext/rugged/rugged_remote_collection.c +59 -10
- data/ext/rugged/rugged_repo.c +345 -11
- data/ext/rugged/rugged_revwalk.c +10 -0
- data/ext/rugged/rugged_submodule.c +1042 -0
- data/ext/rugged/rugged_submodule_collection.c +236 -0
- data/ext/rugged/rugged_tag_collection.c +70 -2
- data/ext/rugged/rugged_tree.c +29 -10
- data/lib/rugged.rb +3 -0
- data/lib/rugged/attributes.rb +41 -0
- data/lib/rugged/blob.rb +28 -0
- data/lib/rugged/diff.rb +0 -1
- data/lib/rugged/diff/line.rb +1 -3
- data/lib/rugged/patch.rb +12 -2
- data/lib/rugged/repository.rb +7 -0
- data/lib/rugged/submodule_collection.rb +48 -0
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +27 -3
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +324 -0
- data/vendor/libgit2/deps/http-parser/http_parser.h +2 -0
- data/vendor/libgit2/deps/zlib/adler32.c +39 -29
- data/vendor/libgit2/deps/zlib/crc32.c +33 -50
- data/vendor/libgit2/deps/zlib/crc32.h +1 -1
- data/vendor/libgit2/deps/zlib/deflate.c +198 -65
- data/vendor/libgit2/deps/zlib/deflate.h +8 -4
- data/vendor/libgit2/deps/zlib/infback.c +640 -0
- 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 +84 -52
- data/vendor/libgit2/deps/zlib/inftrees.c +15 -39
- data/vendor/libgit2/deps/zlib/trees.c +18 -36
- data/vendor/libgit2/deps/zlib/zconf.h +4 -0
- data/vendor/libgit2/deps/zlib/zlib.h +250 -95
- data/vendor/libgit2/deps/zlib/zutil.c +13 -10
- data/vendor/libgit2/deps/zlib/zutil.h +41 -62
- data/vendor/libgit2/include/git2.h +4 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +99 -0
- data/vendor/libgit2/include/git2/attr.h +16 -13
- data/vendor/libgit2/include/git2/branch.h +11 -0
- data/vendor/libgit2/include/git2/buffer.h +16 -0
- 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 +77 -69
- data/vendor/libgit2/include/git2/common.h +13 -1
- data/vendor/libgit2/include/git2/config.h +0 -14
- data/vendor/libgit2/include/git2/describe.h +162 -0
- data/vendor/libgit2/include/git2/diff.h +13 -8
- data/vendor/libgit2/include/git2/errors.h +5 -0
- data/vendor/libgit2/include/git2/global.h +38 -0
- data/vendor/libgit2/include/git2/merge.h +38 -64
- data/vendor/libgit2/include/git2/net.h +2 -2
- data/vendor/libgit2/include/git2/notes.h +17 -0
- data/vendor/libgit2/include/git2/oid.h +8 -4
- data/vendor/libgit2/include/git2/oidarray.h +40 -0
- data/vendor/libgit2/include/git2/rebase.h +261 -0
- data/vendor/libgit2/include/git2/reflog.h +1 -1
- data/vendor/libgit2/include/git2/remote.h +25 -47
- data/vendor/libgit2/include/git2/repository.h +4 -1
- data/vendor/libgit2/include/git2/reset.h +10 -1
- data/vendor/libgit2/include/git2/revert.h +1 -1
- data/vendor/libgit2/include/git2/revwalk.h +28 -23
- data/vendor/libgit2/include/git2/status.h +19 -15
- data/vendor/libgit2/include/git2/submodule.h +18 -0
- data/vendor/libgit2/include/git2/sys/config.h +0 -1
- data/vendor/libgit2/{src → include/git2/sys}/hashsig.h +11 -7
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +13 -0
- data/vendor/libgit2/include/git2/sys/refs.h +0 -11
- data/vendor/libgit2/include/git2/sys/repository.h +13 -0
- data/vendor/libgit2/include/git2/sys/transport.h +352 -0
- data/vendor/libgit2/include/git2/threads.h +10 -20
- data/vendor/libgit2/include/git2/transaction.h +111 -0
- data/vendor/libgit2/include/git2/transport.h +79 -313
- data/vendor/libgit2/include/git2/tree.h +4 -2
- data/vendor/libgit2/include/git2/types.h +77 -8
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/annotated_commit.c +121 -0
- data/vendor/libgit2/src/annotated_commit.h +22 -0
- data/vendor/libgit2/src/attr.c +8 -4
- data/vendor/libgit2/src/attr_file.c +24 -2
- data/vendor/libgit2/src/blame.c +0 -1
- data/vendor/libgit2/src/branch.c +32 -3
- data/vendor/libgit2/src/buf_text.c +9 -5
- data/vendor/libgit2/src/buf_text.h +3 -2
- data/vendor/libgit2/src/buffer.c +67 -10
- data/vendor/libgit2/src/buffer.h +4 -2
- data/vendor/libgit2/src/cache.c +9 -9
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +2 -0
- data/vendor/libgit2/src/checkout.c +263 -82
- data/vendor/libgit2/src/checkout.h +1 -0
- data/vendor/libgit2/src/cherrypick.c +41 -44
- data/vendor/libgit2/src/clone.c +96 -58
- data/vendor/libgit2/src/commit.c +5 -31
- data/vendor/libgit2/src/commit_list.h +3 -1
- data/vendor/libgit2/src/config.c +0 -17
- data/vendor/libgit2/src/config_cache.c +0 -2
- data/vendor/libgit2/src/config_file.c +12 -15
- data/vendor/libgit2/src/crlf.c +2 -1
- data/vendor/libgit2/src/describe.c +886 -0
- data/vendor/libgit2/src/diff.c +29 -3
- data/vendor/libgit2/src/diff_file.c +1 -0
- data/vendor/libgit2/src/diff_patch.c +2 -3
- data/vendor/libgit2/src/diff_print.c +11 -9
- data/vendor/libgit2/src/diff_tform.c +4 -4
- data/vendor/libgit2/src/errors.c +9 -7
- data/vendor/libgit2/src/fetch.c +6 -6
- data/vendor/libgit2/src/fetchhead.h +2 -4
- data/vendor/libgit2/src/filebuf.c +0 -2
- data/vendor/libgit2/src/filebuf.h +2 -3
- data/vendor/libgit2/src/fileops.c +9 -7
- data/vendor/libgit2/src/global.c +44 -35
- data/vendor/libgit2/src/global.h +2 -0
- data/vendor/libgit2/src/graph.c +2 -2
- data/vendor/libgit2/src/hash.h +3 -1
- data/vendor/libgit2/src/hash/hash_common_crypto.h +44 -0
- data/vendor/libgit2/src/hash/hash_win32.c +1 -1
- data/vendor/libgit2/src/hashsig.c +1 -1
- data/vendor/libgit2/src/ignore.c +5 -88
- data/vendor/libgit2/src/index.c +70 -57
- data/vendor/libgit2/src/index.h +1 -0
- data/vendor/libgit2/src/indexer.c +16 -5
- data/vendor/libgit2/src/iterator.c +70 -1
- data/vendor/libgit2/src/iterator.h +5 -1
- data/vendor/libgit2/src/map.h +0 -1
- data/vendor/libgit2/src/merge.c +203 -327
- data/vendor/libgit2/src/merge.h +3 -13
- data/vendor/libgit2/src/mwindow.c +119 -8
- data/vendor/libgit2/src/mwindow.h +9 -1
- data/vendor/libgit2/src/netops.c +7 -8
- data/vendor/libgit2/src/netops.h +6 -16
- data/vendor/libgit2/src/notes.c +31 -4
- data/vendor/libgit2/src/notes.h +3 -0
- data/vendor/libgit2/src/odb.c +23 -1
- data/vendor/libgit2/src/odb_loose.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +6 -3
- data/vendor/libgit2/src/oid.c +9 -1
- data/vendor/libgit2/src/oid.h +11 -0
- data/vendor/libgit2/src/oidarray.c +21 -0
- data/vendor/libgit2/src/oidarray.h +18 -0
- data/vendor/libgit2/src/oidmap.h +16 -0
- data/vendor/libgit2/src/pack.c +20 -7
- data/vendor/libgit2/src/pack.h +3 -0
- data/vendor/libgit2/src/path.c +120 -293
- data/vendor/libgit2/src/path.h +21 -44
- data/vendor/libgit2/src/pathspec.c +1 -1
- data/vendor/libgit2/src/pool.c +5 -11
- data/vendor/libgit2/src/pool.h +0 -2
- data/vendor/libgit2/src/posix.c +6 -6
- data/vendor/libgit2/src/posix.h +48 -28
- data/vendor/libgit2/src/push.c +19 -48
- data/vendor/libgit2/src/push.h +2 -4
- data/vendor/libgit2/src/rebase.c +1125 -0
- data/vendor/libgit2/src/refdb.c +19 -0
- data/vendor/libgit2/src/refdb.h +2 -1
- data/vendor/libgit2/src/refdb_fs.c +101 -29
- data/vendor/libgit2/src/reflog.c +1 -1
- data/vendor/libgit2/src/refs.c +38 -3
- data/vendor/libgit2/src/refs.h +13 -2
- data/vendor/libgit2/src/refspec.c +20 -2
- data/vendor/libgit2/src/remote.c +288 -154
- data/vendor/libgit2/src/remote.h +5 -1
- data/vendor/libgit2/src/repository.c +75 -36
- data/vendor/libgit2/src/repository.h +3 -25
- data/vendor/libgit2/src/reset.c +5 -1
- data/vendor/libgit2/src/revert.c +4 -6
- data/vendor/libgit2/src/revparse.c +15 -18
- data/vendor/libgit2/src/revwalk.c +96 -22
- data/vendor/libgit2/src/revwalk.h +5 -4
- data/vendor/libgit2/src/settings.c +22 -0
- data/vendor/libgit2/src/signature.c +37 -2
- data/vendor/libgit2/src/signature.h +3 -0
- data/vendor/libgit2/src/stash.c +17 -12
- data/vendor/libgit2/src/status.c +13 -3
- data/vendor/libgit2/src/strnlen.h +2 -1
- data/vendor/libgit2/src/submodule.c +75 -35
- data/vendor/libgit2/src/thread-utils.h +4 -9
- data/vendor/libgit2/src/trace.h +9 -1
- data/vendor/libgit2/src/transaction.c +352 -0
- data/vendor/libgit2/src/transport.c +91 -97
- data/vendor/libgit2/src/transports/auth.c +71 -0
- data/vendor/libgit2/src/transports/auth.h +63 -0
- data/vendor/libgit2/src/transports/auth_negotiate.c +275 -0
- data/vendor/libgit2/src/transports/auth_negotiate.h +27 -0
- data/vendor/libgit2/src/transports/cred.c +58 -0
- data/vendor/libgit2/src/transports/cred.h +14 -0
- data/vendor/libgit2/src/transports/cred_helpers.c +3 -0
- data/vendor/libgit2/src/transports/git.c +1 -0
- data/vendor/libgit2/src/transports/http.c +208 -82
- data/vendor/libgit2/src/transports/local.c +2 -2
- data/vendor/libgit2/src/transports/smart.c +2 -0
- data/vendor/libgit2/src/transports/smart.h +2 -0
- data/vendor/libgit2/src/transports/smart_protocol.c +10 -10
- data/vendor/libgit2/src/transports/ssh.c +243 -57
- data/vendor/libgit2/src/transports/winhttp.c +139 -35
- data/vendor/libgit2/src/tree-cache.c +118 -31
- data/vendor/libgit2/src/tree-cache.h +12 -7
- data/vendor/libgit2/src/tree.c +83 -64
- data/vendor/libgit2/src/tree.h +2 -3
- data/vendor/libgit2/src/unix/map.c +8 -2
- data/vendor/libgit2/src/unix/posix.h +23 -9
- data/vendor/libgit2/src/unix/realpath.c +8 -7
- data/vendor/libgit2/src/userdiff.h +3 -3
- data/vendor/libgit2/src/util.c +2 -92
- data/vendor/libgit2/src/util.h +3 -15
- data/vendor/libgit2/src/win32/findfile.c +0 -1
- data/vendor/libgit2/src/win32/map.c +3 -2
- data/vendor/libgit2/src/win32/mingw-compat.h +5 -12
- data/vendor/libgit2/src/win32/msvc-compat.h +3 -32
- data/vendor/libgit2/src/win32/posix.h +20 -32
- data/vendor/libgit2/src/win32/posix_w32.c +103 -31
- data/vendor/libgit2/src/win32/utf-conv.c +6 -36
- data/vendor/libgit2/src/win32/utf-conv.h +39 -0
- data/vendor/libgit2/src/win32/w32_util.h +0 -1
- metadata +32 -7
- data/vendor/libgit2/src/win32/path_w32.c +0 -305
- data/vendor/libgit2/src/win32/path_w32.h +0 -82
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0aa39e21ccc3e603f31e60c998ccc0c71980ba60
|
|
4
|
+
data.tar.gz: fff10f16bf3d155d9851ea92cbfa49b2f30e8dda
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e4bb2074cfea2e6cef066c7bc23b28c07d2dee537ebae03697328bde5dfa8ed012b8c4bab5ad3f52ad2a43781e9230937c9778f40e32a55baf5fd125fc8eede
|
|
7
|
+
data.tar.gz: cb09bd34a103015ad61d197989e31c7fa28df5e1199c10bf5b41e423a224d11b2b9f5e6063c07380d6617c1655ef266d3a8a3c4fbca8567ab0cc168b876f3a42
|
data/README.md
CHANGED
|
@@ -17,7 +17,12 @@ 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 installed on your system to be able to build the included version of `libgit2`.
|
|
20
|
+
You need to have CMake and `pkg-config` installed on your system to be able to build the included version of `libgit2`. On OS X, after installing [Homebrew](http://brew.sh/), you can get CMake with:
|
|
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).
|
|
21
26
|
|
|
22
27
|
If you're using bundler and want to bundle `libgit2` with Rugged, you can use the `:submodules` option:
|
|
23
28
|
|
|
@@ -96,7 +101,7 @@ repo.bare?
|
|
|
96
101
|
# => false
|
|
97
102
|
repo.empty?
|
|
98
103
|
# => true
|
|
99
|
-
repo.
|
|
104
|
+
repo.head_unborn?
|
|
100
105
|
# => false
|
|
101
106
|
repo.head_detached?
|
|
102
107
|
# => false
|
|
@@ -109,13 +114,15 @@ repo.workdir
|
|
|
109
114
|
|
|
110
115
|
# The HEAD of the repository.
|
|
111
116
|
ref = repo.head
|
|
112
|
-
# => #<Rugged::Reference:2228467240 {name: "refs/heads/master", target: "
|
|
117
|
+
# => #<Rugged::Reference:2228467240 {name: "refs/heads/master", target: #<Rugged::Commit:2228467250 {message: "helpful message", tree: #<Rugged::Tree:2228467260 {oid: 5d6f29220a0783b8085134df14ec4d960b6c3bf2}>}>
|
|
113
118
|
|
|
114
|
-
# From the returned ref, you can also access the `name` and
|
|
119
|
+
# From the returned ref, you can also access the `name`, `target`, and target SHA:
|
|
115
120
|
ref.name
|
|
116
121
|
# => "refs/heads/master"
|
|
117
122
|
ref.target
|
|
118
|
-
# => "
|
|
123
|
+
# => #<Rugged::Commit:2228467250 {message: "helpful message", tree: #<Rugged::Tree:2228467260 {oid: 5d6f29220a0783b8085134df14ec4d960b6c3bf2}>}>
|
|
124
|
+
ref.target_id
|
|
125
|
+
# => "2bc6a70483369f33f641ca44873497f13a15cde5"
|
|
119
126
|
|
|
120
127
|
# Reading an object
|
|
121
128
|
object = repo.read('a0ae5566e3c8a3bddffab21022056f0b5e03ef07')
|
data/ext/rugged/extconf.rb
CHANGED
|
@@ -15,18 +15,10 @@ 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
|
-
|
|
22
18
|
if !(MAKE = find_executable('gmake') || find_executable('make'))
|
|
23
19
|
abort "ERROR: GNU make is required to build Rugged."
|
|
24
20
|
end
|
|
25
21
|
|
|
26
|
-
if !find_executable('pkg-config')
|
|
27
|
-
abort "ERROR: pkg-config is required to build Rugged."
|
|
28
|
-
end
|
|
29
|
-
|
|
30
22
|
if arg_config("--use-system-libraries", !!ENV['RUGGED_USE_SYSTEM_LIBRARIES'])
|
|
31
23
|
puts "Building Rugged using system libraries.\n"
|
|
32
24
|
|
|
@@ -40,6 +32,14 @@ if arg_config("--use-system-libraries", !!ENV['RUGGED_USE_SYSTEM_LIBRARIES'])
|
|
|
40
32
|
#endif
|
|
41
33
|
SRC
|
|
42
34
|
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
|
|
|
@@ -47,7 +47,7 @@ else
|
|
|
47
47
|
Dir.mkdir("build") if !Dir.exists?("build")
|
|
48
48
|
|
|
49
49
|
Dir.chdir("build") do
|
|
50
|
-
sys("cmake .. -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo")
|
|
50
|
+
sys("cmake .. -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo -G \"Unix Makefiles\"")
|
|
51
51
|
sys(MAKE)
|
|
52
52
|
|
|
53
53
|
pcfile = File.join(LIBGIT2_DIR, "build", "libgit2.pc")
|
data/ext/rugged/rugged.c
CHANGED
|
@@ -299,7 +299,7 @@ static VALUE rb_git_minimize_oid(int argc, VALUE *argv, VALUE self)
|
|
|
299
299
|
static void cleanup_cb(void *unused)
|
|
300
300
|
{
|
|
301
301
|
(void)unused;
|
|
302
|
-
|
|
302
|
+
git_libgit2_shutdown();
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
void rugged_exception_raise(void)
|
|
@@ -446,6 +446,8 @@ void Init_rugged(void)
|
|
|
446
446
|
Init_rugged_remote_collection();
|
|
447
447
|
Init_rugged_notes();
|
|
448
448
|
Init_rugged_settings();
|
|
449
|
+
Init_rugged_submodule();
|
|
450
|
+
Init_rugged_submodule_collection();
|
|
449
451
|
Init_rugged_diff();
|
|
450
452
|
Init_rugged_patch();
|
|
451
453
|
Init_rugged_diff_delta();
|
|
@@ -484,7 +486,7 @@ void Init_rugged(void)
|
|
|
484
486
|
rb_define_const(rb_mRugged, "SORT_REVERSE", INT2FIX(GIT_SORT_REVERSE));
|
|
485
487
|
|
|
486
488
|
/* Initialize libgit2 */
|
|
487
|
-
|
|
489
|
+
git_libgit2_init();
|
|
488
490
|
|
|
489
491
|
/* Hook a global object to cleanup the library
|
|
490
492
|
* on shutdown */
|
data/ext/rugged/rugged.h
CHANGED
|
@@ -65,6 +65,8 @@ void Init_rugged_remote(void);
|
|
|
65
65
|
void Init_rugged_remote_collection(void);
|
|
66
66
|
void Init_rugged_notes(void);
|
|
67
67
|
void Init_rugged_settings(void);
|
|
68
|
+
void Init_rugged_submodule(void);
|
|
69
|
+
void Init_rugged_submodule_collection(void);
|
|
68
70
|
void Init_rugged_diff(void);
|
|
69
71
|
void Init_rugged_patch(void);
|
|
70
72
|
void Init_rugged_diff_delta(void);
|
|
@@ -79,6 +81,7 @@ VALUE rugged_raw_read(git_repository *repo, const git_oid *oid);
|
|
|
79
81
|
|
|
80
82
|
VALUE rugged_signature_new(const git_signature *sig, const char *encoding_name);
|
|
81
83
|
|
|
84
|
+
VALUE rugged_repo_new(VALUE klass, git_repository *repo);
|
|
82
85
|
VALUE rugged_index_new(VALUE klass, VALUE owner, git_index *index);
|
|
83
86
|
VALUE rugged_config_new(VALUE klass, VALUE owner, git_config *cfg);
|
|
84
87
|
VALUE rugged_object_new(VALUE owner, git_object *object);
|
|
@@ -117,13 +120,6 @@ static inline VALUE rugged_owner(VALUE object)
|
|
|
117
120
|
return rb_iv_get(object, "@owner");
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
static inline void rugged_validate_remote_url(VALUE rb_url)
|
|
121
|
-
{
|
|
122
|
-
Check_Type(rb_url, T_STRING);
|
|
123
|
-
if (!git_remote_valid_url(StringValueCStr(rb_url)))
|
|
124
|
-
rb_raise(rb_eArgError, "Invalid URL format");
|
|
125
|
-
}
|
|
126
|
-
|
|
127
123
|
extern void rugged_exception_raise(void);
|
|
128
124
|
|
|
129
125
|
static inline void rugged_exception_check(int errorcode)
|
data/ext/rugged/rugged_blob.c
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
#include "rugged.h"
|
|
26
26
|
#include <ctype.h>
|
|
27
|
+
#include <git2/sys/hashsig.h>
|
|
27
28
|
|
|
28
29
|
extern VALUE rb_mRugged;
|
|
29
30
|
extern VALUE rb_cRuggedObject;
|
|
@@ -31,6 +32,7 @@ extern VALUE rb_cRuggedRepo;
|
|
|
31
32
|
static ID id_read;
|
|
32
33
|
|
|
33
34
|
VALUE rb_cRuggedBlob;
|
|
35
|
+
VALUE rb_cRuggedBlobSig;
|
|
34
36
|
|
|
35
37
|
/*
|
|
36
38
|
* call-seq:
|
|
@@ -520,6 +522,57 @@ static VALUE rb_git_blob_to_buffer(int argc, VALUE *argv, VALUE self)
|
|
|
520
522
|
return rb_ret;
|
|
521
523
|
}
|
|
522
524
|
|
|
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
|
+
|
|
523
576
|
void Init_rugged_blob(void)
|
|
524
577
|
{
|
|
525
578
|
id_read = rb_intern("read");
|
|
@@ -539,4 +592,8 @@ void Init_rugged_blob(void)
|
|
|
539
592
|
rb_define_singleton_method(rb_cRuggedBlob, "from_io", rb_git_blob_from_io, -1);
|
|
540
593
|
|
|
541
594
|
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);
|
|
542
599
|
}
|
data/ext/rugged/rugged_cred.c
CHANGED
|
@@ -88,19 +88,42 @@ 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
|
+
|
|
91
99
|
void rugged_cred_extract(git_cred **cred, int allowed_types, VALUE rb_credential)
|
|
92
100
|
{
|
|
93
101
|
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
|
+
|
|
94
107
|
if (!(allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT))
|
|
95
108
|
rb_raise(rb_eArgError, "Invalid credential type");
|
|
96
109
|
|
|
97
110
|
rugged_cred_extract_userpass(cred, rb_credential);
|
|
98
111
|
} 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
|
+
|
|
99
117
|
if (!(allowed_types & GIT_CREDTYPE_SSH_KEY))
|
|
100
118
|
rb_raise(rb_eArgError, "Invalid credential type");
|
|
101
119
|
|
|
102
120
|
rugged_cred_extract_ssh_key(cred, rb_credential);
|
|
103
121
|
} 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
|
+
|
|
104
127
|
if (!(allowed_types & GIT_CREDTYPE_SSH_KEY))
|
|
105
128
|
rb_raise(rb_eArgError, "Invalid credential type");
|
|
106
129
|
|
data/ext/rugged/rugged_index.c
CHANGED
|
@@ -681,6 +681,10 @@ 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
|
+
|
|
684
688
|
error = git_index_read_tree(index, tree);
|
|
685
689
|
rugged_exception_check(error);
|
|
686
690
|
|
|
@@ -752,7 +756,7 @@ static VALUE rb_git_index_readtree(VALUE self, VALUE rb_tree)
|
|
|
752
756
|
* :recurse_untracked_dirs ::
|
|
753
757
|
* Even if +:include_untracked+ is true, untracked directories will only be
|
|
754
758
|
* marked with a single entry in the diff. If this flag is set to true,
|
|
755
|
-
* all files under ignored directories will be included in the
|
|
759
|
+
* all files under ignored directories will be included in the diff, too.
|
|
756
760
|
*
|
|
757
761
|
* :disable_pathspec_match ::
|
|
758
762
|
* If true, the given +:paths+ will be applied as exact matches, instead of
|
|
@@ -831,7 +835,7 @@ static VALUE rb_git_index_diff(int argc, VALUE *argv, VALUE self)
|
|
|
831
835
|
xfree(opts.pathspec.strings);
|
|
832
836
|
rugged_exception_check(error);
|
|
833
837
|
|
|
834
|
-
return rugged_diff_new(rb_cRuggedDiff,
|
|
838
|
+
return rugged_diff_new(rb_cRuggedDiff, owner, diff);
|
|
835
839
|
}
|
|
836
840
|
|
|
837
841
|
/*
|
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, transfer_progress_cb, update_tips_cb, NULL}
|
|
32
|
+
#define RUGGED_REMOTE_CALLBACKS_INIT {1, progress_cb, NULL, credentials_cb, NULL, transfer_progress_cb, update_tips_cb, NULL}
|
|
33
33
|
|
|
34
34
|
static int progress_cb(const char *str, int len, void *data)
|
|
35
35
|
{
|
|
@@ -322,7 +322,7 @@ static VALUE rb_git_remote_set_url(VALUE self, VALUE rb_url)
|
|
|
322
322
|
{
|
|
323
323
|
git_remote *remote;
|
|
324
324
|
|
|
325
|
-
|
|
325
|
+
Check_Type(rb_url, T_STRING);
|
|
326
326
|
Data_Get_Struct(self, git_remote, remote);
|
|
327
327
|
|
|
328
328
|
rugged_exception_check(
|
|
@@ -364,7 +364,7 @@ static VALUE rb_git_remote_set_push_url(VALUE self, VALUE rb_url)
|
|
|
364
364
|
{
|
|
365
365
|
git_remote *remote;
|
|
366
366
|
|
|
367
|
-
|
|
367
|
+
Check_Type(rb_url, T_STRING);
|
|
368
368
|
Data_Get_Struct(self, git_remote, remote);
|
|
369
369
|
|
|
370
370
|
rugged_exception_check(
|
|
@@ -499,40 +499,69 @@ static VALUE rb_git_remote_save(VALUE self)
|
|
|
499
499
|
|
|
500
500
|
/*
|
|
501
501
|
* call-seq:
|
|
502
|
-
* remote.
|
|
502
|
+
* remote.check_connection(direction, options = {}) -> boolean
|
|
503
503
|
*
|
|
504
|
-
*
|
|
504
|
+
* Try to connect to the +remote+. Useful to simulate
|
|
505
|
+
* <tt>git fetch --dry-run</tt> and <tt>git push --dry-run</tt>.
|
|
505
506
|
*
|
|
506
|
-
*
|
|
507
|
-
* for the remote are updated.
|
|
507
|
+
* Returns +true+ if connection is successful, +false+ otherwise.
|
|
508
508
|
*
|
|
509
|
-
*
|
|
510
|
-
* that haven't been automatically updated and need potential manual
|
|
511
|
-
* tweaking.
|
|
509
|
+
* +direction+ must be either +:fetch+ or +:push+.
|
|
512
510
|
*
|
|
513
|
-
*
|
|
514
|
-
* +ReferenceCollection#create_anonymous+ can not be given a name through
|
|
515
|
-
* this method.
|
|
511
|
+
* The following options can be passed in the +options+ Hash:
|
|
516
512
|
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
513
|
+
* +credentials+ ::
|
|
514
|
+
* The credentials to use for the connection. Can be either an instance of
|
|
515
|
+
* one of the Rugged::Credentials types, or a proc returning one of the
|
|
516
|
+
* former.
|
|
517
|
+
* The proc will be called with the +url+, the +username+ from the url (if
|
|
518
|
+
* applicable) and a list of applicable credential types.
|
|
519
|
+
*
|
|
520
|
+
* Example:
|
|
521
|
+
*
|
|
522
|
+
* remote = repo.remotes["origin"]
|
|
523
|
+
* success = remote.check_connection(:fetch)
|
|
524
|
+
* raise Error("Unable to pull without credentials") unless success
|
|
519
525
|
*/
|
|
520
|
-
static VALUE
|
|
526
|
+
static VALUE rb_git_remote_check_connection(int argc, VALUE *argv, VALUE self)
|
|
521
527
|
{
|
|
522
528
|
git_remote *remote;
|
|
523
|
-
|
|
524
|
-
|
|
529
|
+
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
|
530
|
+
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
|
|
531
|
+
VALUE rb_direction, rb_options;
|
|
532
|
+
ID id_direction;
|
|
533
|
+
int error, direction;
|
|
525
534
|
|
|
526
|
-
Check_Type(rb_new_name, T_STRING);
|
|
527
535
|
Data_Get_Struct(self, git_remote, remote);
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
);
|
|
536
|
+
rb_scan_args(argc, argv, "01:", &rb_direction, &rb_options);
|
|
537
|
+
|
|
538
|
+
Check_Type(rb_direction, T_SYMBOL);
|
|
539
|
+
id_direction = SYM2ID(rb_direction);
|
|
540
|
+
if (id_direction == rb_intern("fetch"))
|
|
541
|
+
direction = GIT_DIRECTION_FETCH;
|
|
542
|
+
else if (id_direction == rb_intern("push"))
|
|
543
|
+
direction = GIT_DIRECTION_PUSH;
|
|
544
|
+
else
|
|
545
|
+
rb_raise(rb_eTypeError, "Invalid direction. Expected :fetch or :push");
|
|
532
546
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
547
|
+
if (!NIL_P(rb_options))
|
|
548
|
+
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
|
|
549
|
+
|
|
550
|
+
if ((error = git_remote_set_callbacks(remote, &callbacks)) < 0)
|
|
551
|
+
goto cleanup;
|
|
552
|
+
|
|
553
|
+
if (git_remote_connect(remote, direction))
|
|
554
|
+
return Qfalse;
|
|
555
|
+
else {
|
|
556
|
+
git_remote_disconnect(remote);
|
|
557
|
+
return Qtrue;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
cleanup:
|
|
561
|
+
if (payload.exception)
|
|
562
|
+
rb_jump_tag(payload.exception);
|
|
563
|
+
rugged_exception_check(error);
|
|
564
|
+
return Qfalse;
|
|
536
565
|
}
|
|
537
566
|
|
|
538
567
|
/*
|
|
@@ -541,7 +570,7 @@ static VALUE rb_git_remote_rename(VALUE self, VALUE rb_new_name)
|
|
|
541
570
|
*
|
|
542
571
|
* Downloads new data from the remote for the given +refspecs+ and updates tips.
|
|
543
572
|
*
|
|
544
|
-
* You can optionally pass in
|
|
573
|
+
* You can optionally pass in a single or multiple alternative +refspecs+ to use instead of the fetch
|
|
545
574
|
* refspecs already configured for +remote+.
|
|
546
575
|
*
|
|
547
576
|
* Returns a hash containing statistics for the fetch operation.
|
|
@@ -584,26 +613,21 @@ static VALUE rb_git_remote_rename(VALUE self, VALUE rb_new_name)
|
|
|
584
613
|
*/
|
|
585
614
|
static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
|
|
586
615
|
{
|
|
587
|
-
git_remote *remote
|
|
616
|
+
git_remote *remote;
|
|
588
617
|
git_repository *repo;
|
|
589
618
|
git_signature *signature = NULL;
|
|
619
|
+
git_strarray refspecs;
|
|
590
620
|
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
|
591
621
|
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
|
|
592
622
|
|
|
593
623
|
char *log_message = NULL;
|
|
594
|
-
int error
|
|
624
|
+
int error;
|
|
595
625
|
|
|
596
626
|
VALUE rb_options, rb_refspecs, rb_result = Qnil, rb_repo = rugged_owner(self);
|
|
597
627
|
|
|
598
628
|
rb_scan_args(argc, argv, "01:", &rb_refspecs, &rb_options);
|
|
599
629
|
|
|
600
|
-
|
|
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
|
-
}
|
|
630
|
+
rugged_rb_ary_to_strarray(rb_refspecs, &refspecs);
|
|
607
631
|
|
|
608
632
|
Data_Get_Struct(self, git_remote, remote);
|
|
609
633
|
rugged_check_repo(rb_repo);
|
|
@@ -621,22 +645,11 @@ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
|
|
|
621
645
|
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
|
|
622
646
|
}
|
|
623
647
|
|
|
624
|
-
if ((error =
|
|
625
|
-
(error = git_remote_set_callbacks(tmp_remote, &callbacks)))
|
|
648
|
+
if ((error = git_remote_set_callbacks(remote, &callbacks)))
|
|
626
649
|
goto cleanup;
|
|
627
650
|
|
|
628
|
-
if (
|
|
629
|
-
|
|
630
|
-
for (i = 0; !error && i < RARRAY_LEN(rb_refspecs); ++i) {
|
|
631
|
-
VALUE rb_refspec = rb_ary_entry(rb_refspecs, i);
|
|
632
|
-
|
|
633
|
-
if ((error = git_remote_add_fetch(tmp_remote, StringValueCStr(rb_refspec))))
|
|
634
|
-
goto cleanup;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
if ((error = git_remote_fetch(tmp_remote, signature, log_message)) == GIT_OK) {
|
|
639
|
-
const git_transfer_progress *stats = git_remote_stats(tmp_remote);
|
|
651
|
+
if ((error = git_remote_fetch(remote, &refspecs, signature, log_message)) == GIT_OK) {
|
|
652
|
+
const git_transfer_progress *stats = git_remote_stats(remote);
|
|
640
653
|
|
|
641
654
|
rb_result = rb_hash_new();
|
|
642
655
|
rb_hash_aset(rb_result, CSTR2SYM("total_objects"), UINT2NUM(stats->total_objects));
|
|
@@ -650,8 +663,8 @@ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
|
|
|
650
663
|
|
|
651
664
|
cleanup:
|
|
652
665
|
|
|
666
|
+
xfree(refspecs.strings);
|
|
653
667
|
git_signature_free(signature);
|
|
654
|
-
git_remote_free(tmp_remote);
|
|
655
668
|
|
|
656
669
|
if (payload.exception)
|
|
657
670
|
rb_jump_tag(payload.exception);
|
|
@@ -827,9 +840,9 @@ void Init_rugged_remote(void)
|
|
|
827
840
|
rb_define_method(rb_cRuggedRemote, "add_fetch", rb_git_remote_add_fetch, 1);
|
|
828
841
|
rb_define_method(rb_cRuggedRemote, "add_push", rb_git_remote_add_push, 1);
|
|
829
842
|
rb_define_method(rb_cRuggedRemote, "ls", rb_git_remote_ls, -1);
|
|
843
|
+
rb_define_method(rb_cRuggedRemote, "check_connection", rb_git_remote_check_connection, -1);
|
|
830
844
|
rb_define_method(rb_cRuggedRemote, "fetch", rb_git_remote_fetch, -1);
|
|
831
845
|
rb_define_method(rb_cRuggedRemote, "push", rb_git_remote_push, -1);
|
|
832
846
|
rb_define_method(rb_cRuggedRemote, "clear_refspecs", rb_git_remote_clear_refspecs, 0);
|
|
833
847
|
rb_define_method(rb_cRuggedRemote, "save", rb_git_remote_save, 0);
|
|
834
|
-
rb_define_method(rb_cRuggedRemote, "rename!", rb_git_remote_rename, 1);
|
|
835
848
|
}
|