rugged 0.24.6.1 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/ext/rugged/extconf.rb +9 -2
- data/ext/rugged/rugged.c +85 -21
- data/ext/rugged/rugged.h +7 -21
- data/ext/rugged/rugged_backend.c +3 -20
- data/ext/rugged/rugged_blame.c +7 -24
- data/ext/rugged/rugged_blob.c +136 -59
- data/ext/rugged/rugged_branch.c +3 -20
- data/ext/rugged/rugged_branch_collection.c +3 -20
- data/ext/rugged/rugged_commit.c +251 -101
- data/ext/rugged/rugged_config.c +3 -20
- data/ext/rugged/rugged_cred.c +3 -20
- data/ext/rugged/rugged_diff.c +3 -20
- data/ext/rugged/rugged_diff_delta.c +3 -20
- data/ext/rugged/rugged_diff_hunk.c +3 -20
- data/ext/rugged/rugged_diff_line.c +3 -20
- data/ext/rugged/rugged_index.c +46 -229
- data/ext/rugged/rugged_note.c +3 -20
- data/ext/rugged/rugged_object.c +3 -20
- data/ext/rugged/rugged_patch.c +192 -34
- data/ext/rugged/rugged_rebase.c +90 -48
- data/ext/rugged/rugged_reference.c +4 -21
- data/ext/rugged/rugged_reference_collection.c +3 -20
- data/ext/rugged/rugged_remote.c +70 -42
- data/ext/rugged/rugged_remote_collection.c +3 -20
- data/ext/rugged/rugged_repo.c +50 -59
- data/ext/rugged/rugged_revwalk.c +4 -21
- data/ext/rugged/rugged_settings.c +3 -20
- data/ext/rugged/rugged_signature.c +3 -20
- data/ext/rugged/rugged_submodule.c +4 -21
- data/ext/rugged/rugged_submodule_collection.c +3 -20
- data/ext/rugged/rugged_tag.c +3 -20
- data/ext/rugged/rugged_tag_collection.c +3 -20
- data/ext/rugged/rugged_tree.c +189 -184
- data/lib/rugged/attributes.rb +5 -0
- data/lib/rugged/blob.rb +5 -0
- data/lib/rugged/branch.rb +6 -1
- data/lib/rugged/commit.rb +5 -0
- data/lib/rugged/console.rb +5 -0
- data/lib/rugged/credentials.rb +5 -0
- data/lib/rugged/diff/delta.rb +5 -0
- data/lib/rugged/diff/hunk.rb +5 -0
- data/lib/rugged/diff/line.rb +5 -0
- data/lib/rugged/diff.rb +5 -0
- data/lib/rugged/index.rb +120 -0
- data/lib/rugged/object.rb +5 -0
- data/lib/rugged/patch.rb +5 -0
- data/lib/rugged/reference.rb +5 -0
- data/lib/rugged/remote.rb +5 -0
- data/lib/rugged/repository.rb +9 -4
- data/lib/rugged/submodule_collection.rb +5 -0
- data/lib/rugged/tag.rb +5 -0
- data/lib/rugged/tree.rb +156 -1
- data/lib/rugged/version.rb +6 -1
- data/lib/rugged/walker.rb +5 -0
- data/lib/rugged.rb +5 -0
- data/vendor/libgit2/CMakeLists.txt +12 -2
- data/vendor/libgit2/include/git2/blob.h +39 -28
- data/vendor/libgit2/include/git2/commit.h +76 -0
- data/vendor/libgit2/include/git2/common.h +21 -1
- data/vendor/libgit2/include/git2/describe.h +5 -2
- data/vendor/libgit2/include/git2/diff.h +62 -7
- data/vendor/libgit2/include/git2/errors.h +2 -1
- data/vendor/libgit2/include/git2/index.h +25 -0
- data/vendor/libgit2/include/git2/merge.h +10 -1
- data/vendor/libgit2/include/git2/odb.h +47 -1
- data/vendor/libgit2/include/git2/pack.h +4 -4
- data/vendor/libgit2/include/git2/patch.h +1 -1
- data/vendor/libgit2/include/git2/proxy.h +92 -0
- data/vendor/libgit2/include/git2/refs.h +11 -0
- data/vendor/libgit2/include/git2/remote.h +21 -8
- data/vendor/libgit2/include/git2/repository.h +20 -1
- data/vendor/libgit2/include/git2/revwalk.h +4 -6
- data/vendor/libgit2/include/git2/signature.h +13 -0
- data/vendor/libgit2/include/git2/submodule.h +11 -3
- data/vendor/libgit2/include/git2/sys/merge.h +177 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +11 -0
- data/vendor/libgit2/include/git2/sys/remote.h +16 -0
- data/vendor/libgit2/include/git2/sys/stream.h +2 -1
- data/vendor/libgit2/include/git2/sys/time.h +31 -0
- data/vendor/libgit2/include/git2/sys/transport.h +3 -1
- data/vendor/libgit2/include/git2/tag.h +9 -0
- data/vendor/libgit2/include/git2/transaction.h +9 -0
- data/vendor/libgit2/include/git2/tree.h +55 -0
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/annotated_commit.c +99 -80
- data/vendor/libgit2/src/annotated_commit.h +5 -2
- data/vendor/libgit2/src/apply.c +377 -0
- data/vendor/libgit2/src/apply.h +21 -0
- data/vendor/libgit2/src/array.h +0 -1
- data/vendor/libgit2/src/blob.c +71 -39
- data/vendor/libgit2/src/branch.c +7 -5
- data/vendor/libgit2/src/buffer.c +252 -20
- data/vendor/libgit2/src/buffer.h +8 -0
- data/vendor/libgit2/src/checkout.c +69 -42
- data/vendor/libgit2/src/clone.c +0 -8
- data/vendor/libgit2/src/commit.c +193 -49
- data/vendor/libgit2/src/commit_list.c +8 -3
- data/vendor/libgit2/src/commit_list.h +1 -0
- data/vendor/libgit2/src/common.h +2 -1
- data/vendor/libgit2/src/config.c +3 -3
- data/vendor/libgit2/src/config_file.c +20 -10
- data/vendor/libgit2/src/crlf.c +1 -0
- data/vendor/libgit2/src/curl_stream.c +106 -6
- data/vendor/libgit2/src/delta.c +238 -62
- data/vendor/libgit2/src/delta.h +79 -58
- data/vendor/libgit2/src/describe.c +1 -1
- data/vendor/libgit2/src/diff.c +32 -1554
- data/vendor/libgit2/src/diff.h +14 -122
- data/vendor/libgit2/src/diff_driver.c +4 -6
- data/vendor/libgit2/src/diff_file.c +3 -0
- data/vendor/libgit2/src/diff_generate.c +1613 -0
- data/vendor/libgit2/src/diff_generate.h +123 -0
- data/vendor/libgit2/src/diff_parse.c +101 -0
- data/vendor/libgit2/src/diff_parse.h +18 -0
- data/vendor/libgit2/src/diff_print.c +263 -144
- data/vendor/libgit2/src/diff_stats.c +21 -12
- data/vendor/libgit2/src/diff_tform.c +1 -0
- data/vendor/libgit2/src/diff_tform.h +22 -0
- data/vendor/libgit2/src/diff_xdiff.c +9 -9
- data/vendor/libgit2/src/diff_xdiff.h +5 -5
- data/vendor/libgit2/src/fetchhead.c +8 -8
- data/vendor/libgit2/src/filebuf.c +6 -1
- data/vendor/libgit2/src/filebuf.h +1 -0
- data/vendor/libgit2/src/fileops.c +22 -1
- data/vendor/libgit2/src/fileops.h +8 -2
- data/vendor/libgit2/src/fnmatch.c +18 -5
- data/vendor/libgit2/src/global.c +21 -4
- data/vendor/libgit2/src/global.h +6 -0
- data/vendor/libgit2/src/graph.c +1 -1
- data/vendor/libgit2/src/index.c +159 -46
- data/vendor/libgit2/src/index.h +2 -0
- data/vendor/libgit2/src/iterator.c +1573 -1468
- data/vendor/libgit2/src/iterator.h +52 -69
- data/vendor/libgit2/src/merge.c +163 -64
- data/vendor/libgit2/src/merge.h +61 -2
- data/vendor/libgit2/src/merge_driver.c +397 -0
- data/vendor/libgit2/src/merge_driver.h +60 -0
- data/vendor/libgit2/src/merge_file.c +11 -49
- data/vendor/libgit2/src/netops.c +12 -10
- data/vendor/libgit2/src/object_api.c +19 -1
- data/vendor/libgit2/src/odb.c +228 -52
- data/vendor/libgit2/src/odb_loose.c +19 -1
- data/vendor/libgit2/src/odb_mempack.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +27 -1
- data/vendor/libgit2/src/openssl_stream.c +4 -5
- data/vendor/libgit2/src/pack-objects.c +105 -76
- data/vendor/libgit2/src/pack-objects.h +13 -12
- data/vendor/libgit2/src/pack.c +16 -10
- data/vendor/libgit2/src/pack.h +2 -0
- data/vendor/libgit2/src/patch.c +216 -0
- data/vendor/libgit2/src/patch.h +66 -0
- data/vendor/libgit2/src/{diff_patch.c → patch_generate.c} +203 -376
- data/vendor/libgit2/src/patch_generate.h +68 -0
- data/vendor/libgit2/src/patch_parse.c +1159 -0
- data/vendor/libgit2/src/patch_parse.h +56 -0
- data/vendor/libgit2/src/path.c +38 -2
- data/vendor/libgit2/src/path.h +18 -0
- data/vendor/libgit2/src/pathspec.c +1 -1
- data/vendor/libgit2/src/pool.h +5 -0
- data/vendor/libgit2/src/pqueue.c +12 -5
- data/vendor/libgit2/src/pqueue.h +1 -0
- data/vendor/libgit2/src/proxy.c +32 -0
- data/vendor/libgit2/src/proxy.h +14 -0
- data/vendor/libgit2/src/push.c +1 -1
- data/vendor/libgit2/src/rebase.c +63 -36
- data/vendor/libgit2/src/refdb.c +4 -2
- data/vendor/libgit2/src/refdb_fs.c +82 -54
- data/vendor/libgit2/src/refs.c +13 -1
- data/vendor/libgit2/src/remote.c +20 -81
- data/vendor/libgit2/src/repository.c +212 -29
- data/vendor/libgit2/src/reset.c +1 -1
- data/vendor/libgit2/src/revparse.c +1 -1
- data/vendor/libgit2/src/revwalk.c +260 -184
- data/vendor/libgit2/src/settings.c +11 -3
- data/vendor/libgit2/src/signature.c +27 -2
- data/vendor/libgit2/src/sortedcache.c +14 -5
- data/vendor/libgit2/src/stash.c +1 -0
- data/vendor/libgit2/src/status.c +1 -0
- data/vendor/libgit2/src/stransport_stream.c +4 -2
- data/vendor/libgit2/src/stream.h +2 -2
- data/vendor/libgit2/src/submodule.c +16 -4
- data/vendor/libgit2/src/sysdir.c +1 -1
- data/vendor/libgit2/src/transport.c +3 -5
- data/vendor/libgit2/src/transports/http.c +38 -13
- data/vendor/libgit2/src/transports/local.c +4 -1
- data/vendor/libgit2/src/transports/smart.c +6 -0
- data/vendor/libgit2/src/transports/smart.h +1 -0
- data/vendor/libgit2/src/transports/smart_pkt.c +5 -13
- data/vendor/libgit2/src/transports/smart_protocol.c +22 -7
- data/vendor/libgit2/src/transports/winhttp.c +144 -11
- data/vendor/libgit2/src/tree.c +267 -2
- data/vendor/libgit2/src/unix/posix.h +10 -0
- data/vendor/libgit2/src/unix/pthread.h +2 -0
- data/vendor/libgit2/src/util.c +25 -2
- data/vendor/libgit2/src/util.h +10 -0
- data/vendor/libgit2/src/varint.c +44 -0
- data/vendor/libgit2/src/varint.h +15 -0
- data/vendor/libgit2/src/vector.c +58 -0
- data/vendor/libgit2/src/vector.h +8 -0
- data/vendor/libgit2/src/win32/posix.h +3 -0
- data/vendor/libgit2/src/win32/thread.c +18 -0
- data/vendor/libgit2/src/win32/thread.h +2 -0
- data/vendor/libgit2/src/win32/w32_util.h +1 -1
- data/vendor/libgit2/src/zstream.c +37 -8
- data/vendor/libgit2/src/zstream.h +8 -1
- metadata +100 -82
- data/vendor/libgit2/Makefile.embed +0 -60
- data/vendor/libgit2/src/delta-apply.c +0 -166
- data/vendor/libgit2/src/delta-apply.h +0 -62
- data/vendor/libgit2/src/diff_patch.h +0 -83
data/ext/rugged/rugged_rebase.c
CHANGED
@@ -1,25 +1,8 @@
|
|
1
1
|
/*
|
2
|
-
*
|
2
|
+
* Copyright (C) the Rugged contributors. All rights reserved.
|
3
3
|
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
11
|
-
* furnished to do so, subject to the following conditions:
|
12
|
-
*
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
14
|
-
* all copies or substantial portions of the Software.
|
15
|
-
*
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
* THE SOFTWARE.
|
4
|
+
* This file is part of Rugged, distributed under the MIT license.
|
5
|
+
* For full terms see the included LICENSE file.
|
23
6
|
*/
|
24
7
|
|
25
8
|
#include "rugged.h"
|
@@ -27,6 +10,8 @@
|
|
27
10
|
extern VALUE rb_mRugged;
|
28
11
|
extern VALUE rb_cRuggedIndex;
|
29
12
|
extern VALUE rb_cRuggedRepo;
|
13
|
+
extern VALUE rb_cRuggedCommit;
|
14
|
+
extern VALUE rb_cRuggedReference;
|
30
15
|
|
31
16
|
VALUE rb_cRuggedRebase;
|
32
17
|
|
@@ -67,9 +52,66 @@ VALUE rugged_rebase_new(VALUE klass, VALUE owner, git_rebase *rebase)
|
|
67
52
|
return rb_rebase;
|
68
53
|
}
|
69
54
|
|
55
|
+
struct get_annotated_commit_args {
|
56
|
+
git_annotated_commit **annotated_commit;
|
57
|
+
VALUE rb_repo;
|
58
|
+
VALUE rb_value;
|
59
|
+
};
|
60
|
+
|
61
|
+
static void get_annotated_commit(git_annotated_commit **annotated_commit, VALUE rb_repo, VALUE rb_value)
|
62
|
+
{
|
63
|
+
git_repository *repo;
|
64
|
+
int error;
|
65
|
+
|
66
|
+
rugged_check_repo(rb_repo);
|
67
|
+
Data_Get_Struct(rb_repo, git_repository, repo);
|
68
|
+
|
69
|
+
if (rb_obj_is_kind_of(rb_value, rb_cRuggedCommit)) {
|
70
|
+
const git_commit * commit;
|
71
|
+
const git_oid * oid;
|
72
|
+
|
73
|
+
Data_Get_Struct(rb_value, git_commit, commit);
|
74
|
+
|
75
|
+
oid = git_commit_id(commit);
|
76
|
+
error = git_annotated_commit_lookup(annotated_commit, repo, oid);
|
77
|
+
} else if (rb_obj_is_kind_of(rb_value, rb_cRuggedReference)) {
|
78
|
+
const git_reference * ref;
|
79
|
+
|
80
|
+
Data_Get_Struct(rb_value, git_reference, ref);
|
81
|
+
|
82
|
+
error = git_annotated_commit_from_ref(annotated_commit, repo, ref);
|
83
|
+
} else if (TYPE(rb_value) == T_STRING) {
|
84
|
+
error = git_annotated_commit_from_revspec(annotated_commit, repo, StringValueCStr(rb_value));
|
85
|
+
} else {
|
86
|
+
rb_raise(rb_eTypeError, "Expecting a Rugged::Reference, Rugged::Commit or String instance");
|
87
|
+
}
|
88
|
+
|
89
|
+
rugged_exception_check(error);
|
90
|
+
}
|
91
|
+
|
92
|
+
static void get_annotated_commit_wrapper(struct get_annotated_commit_args *args)
|
93
|
+
{
|
94
|
+
get_annotated_commit(args->annotated_commit, args->rb_repo, args->rb_value);
|
95
|
+
}
|
96
|
+
|
97
|
+
static int rugged_get_annotated_commit(
|
98
|
+
git_annotated_commit ** annotated_commit, VALUE rb_repo, VALUE rb_value)
|
99
|
+
{
|
100
|
+
struct get_annotated_commit_args args;
|
101
|
+
int exception;
|
102
|
+
|
103
|
+
args.annotated_commit = annotated_commit;
|
104
|
+
args.rb_repo = rb_repo;
|
105
|
+
args.rb_value = rb_value;
|
106
|
+
|
107
|
+
rb_protect((VALUE (*)(VALUE))get_annotated_commit_wrapper, (VALUE)&args, &exception);
|
108
|
+
|
109
|
+
return exception;
|
110
|
+
}
|
111
|
+
|
70
112
|
/*
|
71
113
|
* call-seq:
|
72
|
-
* Rebase.new(repo, branch, upstream[, onto][, options]) ->
|
114
|
+
* Rebase.new(repo, branch, upstream[, onto][, options]) -> new_rebase
|
73
115
|
*
|
74
116
|
* Initialize a new rebase operation. This will put +repo+ in a
|
75
117
|
* rebase state.
|
@@ -89,8 +131,8 @@ VALUE rugged_rebase_new(VALUE klass, VALUE owner, git_rebase *rebase)
|
|
89
131
|
*
|
90
132
|
* :inmemory ::
|
91
133
|
* Do not put the repository in a rebase state but perform all the
|
92
|
-
* operations in-memory. In case of conflicts, the
|
93
|
-
* returned by #next will contain the index which can be used to
|
134
|
+
* operations in-memory. In case of conflicts, the rebase operation
|
135
|
+
* Hash returned by #next will contain the index which can be used to
|
94
136
|
* resolve conflicts.
|
95
137
|
*
|
96
138
|
* :rewrite_notes_ref ::
|
@@ -100,9 +142,8 @@ VALUE rugged_rebase_new(VALUE klass, VALUE owner, git_rebase *rebase)
|
|
100
142
|
*/
|
101
143
|
static VALUE rb_git_rebase_new(int argc, VALUE* argv, VALUE klass)
|
102
144
|
{
|
103
|
-
int error;
|
104
|
-
|
105
|
-
git_rebase *rebase;
|
145
|
+
int error = 0, exception = 0;
|
146
|
+
git_rebase *rebase = NULL;
|
106
147
|
git_repository *repo;
|
107
148
|
git_annotated_commit *branch = NULL, *upstream = NULL, *onto = NULL;
|
108
149
|
VALUE rb_repo, rb_branch, rb_upstream, rb_onto, rb_options;
|
@@ -110,24 +151,20 @@ static VALUE rb_git_rebase_new(int argc, VALUE* argv, VALUE klass)
|
|
110
151
|
|
111
152
|
rb_scan_args(argc, argv, "31:", &rb_repo, &rb_branch, &rb_upstream, &rb_onto, &rb_options);
|
112
153
|
Data_Get_Struct(rb_repo, git_repository, repo);
|
113
|
-
str_branch = rugged_refname_from_string_or_ref(rb_branch);
|
114
|
-
str_upstream = rugged_refname_from_string_or_ref(rb_upstream);
|
115
|
-
Check_Type(rb_branch, T_STRING);
|
116
|
-
Check_Type(rb_upstream, T_STRING);
|
117
|
-
if (!NIL_P(rb_onto))
|
118
|
-
str_onto = rugged_refname_from_string_or_ref(rb_onto);
|
119
154
|
|
120
|
-
|
155
|
+
if ((exception = rugged_get_annotated_commit(&branch, rb_repo, rb_branch)))
|
156
|
+
goto cleanup;
|
121
157
|
|
122
|
-
if ((
|
123
|
-
(error = git_annotated_commit_from_revspec(&upstream, repo, str_upstream)) < 0)
|
158
|
+
if ((exception = rugged_get_annotated_commit(&upstream, rb_repo, rb_upstream)))
|
124
159
|
goto cleanup;
|
125
160
|
|
126
161
|
if (!NIL_P(rb_onto)) {
|
127
|
-
if ((
|
162
|
+
if ((exception = rugged_get_annotated_commit(&onto, rb_repo, rb_onto)))
|
128
163
|
goto cleanup;
|
129
164
|
}
|
130
165
|
|
166
|
+
parse_rebase_options(&options, rb_options);
|
167
|
+
|
131
168
|
error = git_rebase_init(&rebase, repo, branch, upstream, onto, &options);
|
132
169
|
|
133
170
|
cleanup:
|
@@ -135,6 +172,9 @@ cleanup:
|
|
135
172
|
git_annotated_commit_free(upstream);
|
136
173
|
git_annotated_commit_free(onto);
|
137
174
|
|
175
|
+
if (exception)
|
176
|
+
rb_jump_tag(exception);
|
177
|
+
|
138
178
|
rugged_exception_check(error);
|
139
179
|
|
140
180
|
return rugged_rebase_new(klass, rb_repo, rebase);
|
@@ -194,7 +234,7 @@ static VALUE rb_git_rebase_next(VALUE self)
|
|
194
234
|
}
|
195
235
|
/*
|
196
236
|
* call-seq:
|
197
|
-
*
|
237
|
+
* rebase.inmemory_index -> index
|
198
238
|
*
|
199
239
|
* Gets the index produced by the last operation, which is the result
|
200
240
|
* of +next+ and which will be committed by the next invocation of
|
@@ -218,12 +258,15 @@ static VALUE rb_git_rebase_inmemory_index(VALUE self)
|
|
218
258
|
|
219
259
|
/*
|
220
260
|
* call-seq:
|
221
|
-
*
|
261
|
+
* rebase.commit(author: nil, committer: committer, message: nil) -> oid or nil
|
222
262
|
*
|
223
263
|
* Commit the current patch. Any conflicts must have been resolved.
|
224
264
|
*
|
225
265
|
* If +author+ is +nil+, the existing author for the commit will be
|
226
266
|
* used. If +message+ is +nil+, the existing message will be used.
|
267
|
+
*
|
268
|
+
* Returns a string containing the oid of the newly created commit,
|
269
|
+
* or +nil+ if there are no changes to be committed.
|
227
270
|
*/
|
228
271
|
static VALUE rb_git_rebase_commit(int argc, VALUE *argv, VALUE self)
|
229
272
|
{
|
@@ -237,6 +280,8 @@ static VALUE rb_git_rebase_commit(int argc, VALUE *argv, VALUE self)
|
|
237
280
|
Data_Get_Struct(self, git_rebase, rebase);
|
238
281
|
rb_scan_args(argc, argv, ":", &rb_options);
|
239
282
|
|
283
|
+
Check_Type(rb_options, T_HASH);
|
284
|
+
|
240
285
|
rb_author = rb_hash_aref(rb_options, CSTR2SYM("author"));
|
241
286
|
rb_committer = rb_hash_aref(rb_options, CSTR2SYM("committer"));
|
242
287
|
rb_message = rb_hash_aref(rb_options, CSTR2SYM("message"));
|
@@ -258,6 +303,11 @@ static VALUE rb_git_rebase_commit(int argc, VALUE *argv, VALUE self)
|
|
258
303
|
git_signature_free(author);
|
259
304
|
git_signature_free(committer);
|
260
305
|
|
306
|
+
if (error == GIT_EAPPLIED) {
|
307
|
+
giterr_clear();
|
308
|
+
return Qnil;
|
309
|
+
}
|
310
|
+
|
261
311
|
rugged_exception_check(error);
|
262
312
|
|
263
313
|
return rugged_create_oid(&id);
|
@@ -265,7 +315,7 @@ static VALUE rb_git_rebase_commit(int argc, VALUE *argv, VALUE self)
|
|
265
315
|
|
266
316
|
/*
|
267
317
|
* call-seq:
|
268
|
-
*
|
318
|
+
* rebase.abort -> nil
|
269
319
|
*
|
270
320
|
* Abort the rebase currently in process, resetting the repository
|
271
321
|
* and working directory to their state before the rebase began.
|
@@ -282,7 +332,7 @@ static VALUE rb_git_rebase_abort(VALUE self)
|
|
282
332
|
|
283
333
|
/*
|
284
334
|
* call-seq:
|
285
|
-
*
|
335
|
+
* rebase.finish -> nil
|
286
336
|
*
|
287
337
|
* Finish the rebase currently in progress once all patches have been
|
288
338
|
* applied.
|
@@ -345,11 +395,3 @@ void Init_rugged_rebase(void)
|
|
345
395
|
rb_define_method(rb_cRuggedRebase, "abort", rb_git_rebase_abort, 0);
|
346
396
|
rb_define_method(rb_cRuggedRebase, "finish", rb_git_rebase_finish, 1);
|
347
397
|
}
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
@@ -1,25 +1,8 @@
|
|
1
1
|
/*
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
11
|
-
* furnished to do so, subject to the following conditions:
|
12
|
-
*
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
14
|
-
* all copies or substantial portions of the Software.
|
15
|
-
*
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
* THE SOFTWARE.
|
2
|
+
* Copyright (C) the Rugged contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of Rugged, distributed under the MIT license.
|
5
|
+
* For full terms see the included LICENSE file.
|
23
6
|
*/
|
24
7
|
|
25
8
|
#include "rugged.h"
|
@@ -1,25 +1,8 @@
|
|
1
1
|
/*
|
2
|
-
*
|
2
|
+
* Copyright (C) the Rugged contributors. All rights reserved.
|
3
3
|
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
11
|
-
* furnished to do so, subject to the following conditions:
|
12
|
-
*
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
14
|
-
* all copies or substantial portions of the Software.
|
15
|
-
*
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
* THE SOFTWARE.
|
4
|
+
* This file is part of Rugged, distributed under the MIT license.
|
5
|
+
* For full terms see the included LICENSE file.
|
23
6
|
*/
|
24
7
|
|
25
8
|
#include "rugged.h"
|
data/ext/rugged/rugged_remote.c
CHANGED
@@ -1,25 +1,8 @@
|
|
1
1
|
/*
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
11
|
-
* furnished to do so, subject to the following conditions:
|
12
|
-
*
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
14
|
-
* all copies or substantial portions of the Software.
|
15
|
-
*
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
* THE SOFTWARE.
|
2
|
+
* Copyright (C) the Rugged contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of Rugged, distributed under the MIT license.
|
5
|
+
* For full terms see the included LICENSE file.
|
23
6
|
*/
|
24
7
|
|
25
8
|
#include "rugged.h"
|
@@ -29,8 +12,6 @@ extern VALUE rb_cRuggedRepo;
|
|
29
12
|
extern VALUE rb_eRuggedError;
|
30
13
|
VALUE rb_cRuggedRemote;
|
31
14
|
|
32
|
-
#define RUGGED_REMOTE_CALLBACKS_INIT {1, progress_cb, NULL, credentials_cb, NULL, transfer_progress_cb, update_tips_cb, NULL, NULL, push_update_reference_cb, NULL}
|
33
|
-
|
34
15
|
static int progress_cb(const char *str, int len, void *data)
|
35
16
|
{
|
36
17
|
struct rugged_remote_cb_payload *payload = data;
|
@@ -96,6 +77,27 @@ static int update_tips_cb(const char *refname, const git_oid *src, const git_oid
|
|
96
77
|
return payload->exception ? GIT_ERROR : GIT_OK;
|
97
78
|
}
|
98
79
|
|
80
|
+
static int certificate_check_cb(git_cert *cert, int valid, const char *host, void *data)
|
81
|
+
{
|
82
|
+
struct rugged_remote_cb_payload *payload = data;
|
83
|
+
VALUE args = rb_ary_new2(3);
|
84
|
+
VALUE ret;
|
85
|
+
|
86
|
+
if (NIL_P(payload->certificate_check))
|
87
|
+
return valid ? 0 : GIT_ECERTIFICATE;
|
88
|
+
|
89
|
+
rb_ary_push(args, payload->certificate_check);
|
90
|
+
rb_ary_push(args, valid ? Qtrue : Qfalse);
|
91
|
+
rb_ary_push(args, rb_str_new_utf8(host));
|
92
|
+
|
93
|
+
ret = rb_protect(rugged__block_yield_splat, args, &payload->exception);
|
94
|
+
|
95
|
+
if (payload->exception)
|
96
|
+
return GIT_ERROR;
|
97
|
+
|
98
|
+
return rugged_parse_bool(ret) ? GIT_OK : GIT_ECERTIFICATE;
|
99
|
+
}
|
100
|
+
|
99
101
|
struct extract_cred_args
|
100
102
|
{
|
101
103
|
VALUE rb_callback;
|
@@ -155,11 +157,9 @@ static int credentials_cb(
|
|
155
157
|
return payload->exception ? GIT_ERROR : GIT_OK;
|
156
158
|
}
|
157
159
|
|
158
|
-
#define CALLABLE_OR_RAISE(ret,
|
159
|
-
do {
|
160
|
-
|
161
|
-
\
|
162
|
-
if (!NIL_P(ret) && !rb_respond_to(ret, rb_intern("call"))) \
|
160
|
+
#define CALLABLE_OR_RAISE(ret, name) \
|
161
|
+
do { \
|
162
|
+
if (!rb_respond_to(ret, rb_intern("call"))) \
|
163
163
|
rb_raise(rb_eArgError, "Expected a Proc or an object that responds to #call (:" name " )."); \
|
164
164
|
} while (0);
|
165
165
|
|
@@ -168,16 +168,39 @@ void rugged_remote_init_callbacks_and_payload_from_options(
|
|
168
168
|
git_remote_callbacks *callbacks,
|
169
169
|
struct rugged_remote_cb_payload *payload)
|
170
170
|
{
|
171
|
-
|
172
|
-
|
173
|
-
prefilled.payload = payload;
|
174
|
-
memcpy(callbacks, &prefilled, sizeof(git_remote_callbacks));
|
171
|
+
callbacks->payload = payload;
|
172
|
+
callbacks->push_update_reference = push_update_reference_cb;
|
175
173
|
|
176
174
|
if (!NIL_P(rb_options)) {
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
175
|
+
payload->progress = rb_hash_aref(rb_options, CSTR2SYM("progress"));
|
176
|
+
if (!NIL_P(payload->progress)) {
|
177
|
+
CALLABLE_OR_RAISE(payload->progress, "progress");
|
178
|
+
callbacks->sideband_progress = progress_cb;
|
179
|
+
}
|
180
|
+
|
181
|
+
payload->credentials = rb_hash_aref(rb_options, CSTR2SYM("credentials"));
|
182
|
+
if (!NIL_P(payload->credentials)) {
|
183
|
+
CALLABLE_OR_RAISE(payload->credentials, "credentials");
|
184
|
+
callbacks->credentials = credentials_cb;
|
185
|
+
}
|
186
|
+
|
187
|
+
payload->certificate_check = rb_hash_aref(rb_options, CSTR2SYM("certificate_check"));
|
188
|
+
if (!NIL_P(payload->certificate_check)) {
|
189
|
+
CALLABLE_OR_RAISE(payload->certificate_check, "certificate_check");
|
190
|
+
callbacks->certificate_check = certificate_check_cb;
|
191
|
+
}
|
192
|
+
|
193
|
+
payload->transfer_progress = rb_hash_aref(rb_options, CSTR2SYM("transfer_progress"));
|
194
|
+
if (!NIL_P(payload->transfer_progress)) {
|
195
|
+
CALLABLE_OR_RAISE(payload->transfer_progress, "transfer_progress");
|
196
|
+
callbacks->transfer_progress = transfer_progress_cb;
|
197
|
+
}
|
198
|
+
|
199
|
+
payload->update_tips = rb_hash_aref(rb_options, CSTR2SYM("update_tips"));
|
200
|
+
if (!NIL_P(payload->update_tips)) {
|
201
|
+
CALLABLE_OR_RAISE(payload->update_tips, "update_tips");
|
202
|
+
callbacks->update_tips = update_tips_cb;
|
203
|
+
}
|
181
204
|
}
|
182
205
|
}
|
183
206
|
|
@@ -274,7 +297,7 @@ static VALUE rb_git_remote_ls(int argc, VALUE *argv, VALUE self)
|
|
274
297
|
git_strarray custom_headers = {0};
|
275
298
|
const git_remote_head **heads;
|
276
299
|
|
277
|
-
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
|
300
|
+
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
|
278
301
|
|
279
302
|
VALUE rb_options;
|
280
303
|
|
@@ -291,7 +314,7 @@ static VALUE rb_git_remote_ls(int argc, VALUE *argv, VALUE self)
|
|
291
314
|
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
|
292
315
|
init_custom_headers(rb_options, &custom_headers);
|
293
316
|
|
294
|
-
if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, &callbacks, &custom_headers)) ||
|
317
|
+
if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, &callbacks, NULL, &custom_headers)) ||
|
295
318
|
(error = git_remote_ls(&heads, &heads_len, remote)))
|
296
319
|
goto cleanup;
|
297
320
|
|
@@ -471,7 +494,7 @@ static VALUE rb_git_remote_check_connection(int argc, VALUE *argv, VALUE self)
|
|
471
494
|
git_remote *remote;
|
472
495
|
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
473
496
|
git_strarray custom_headers = {0};
|
474
|
-
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
|
497
|
+
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
|
475
498
|
VALUE rb_direction, rb_options;
|
476
499
|
ID id_direction;
|
477
500
|
int error, direction;
|
@@ -491,7 +514,7 @@ static VALUE rb_git_remote_check_connection(int argc, VALUE *argv, VALUE self)
|
|
491
514
|
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
|
492
515
|
init_custom_headers(rb_options, &custom_headers);
|
493
516
|
|
494
|
-
error = git_remote_connect(remote, direction, &callbacks, &custom_headers);
|
517
|
+
error = git_remote_connect(remote, direction, &callbacks, NULL, &custom_headers);
|
495
518
|
git_remote_disconnect(remote);
|
496
519
|
|
497
520
|
git_strarray_free(&custom_headers);
|
@@ -537,6 +560,11 @@ static VALUE rb_git_remote_check_connection(int argc, VALUE *argv, VALUE self)
|
|
537
560
|
* A callback that will be executed each time a reference is updated locally. It will be
|
538
561
|
* passed the +refname+, +old_oid+ and +new_oid+.
|
539
562
|
*
|
563
|
+
* :certificate_check ::
|
564
|
+
* A callback that will be executed each time we validate a certificate using https. It
|
565
|
+
* will be passed the +valid+, +host_name+ and the callback should return a true/false to
|
566
|
+
* indicate if the certificate has been validated.
|
567
|
+
*
|
540
568
|
* :message ::
|
541
569
|
* The message to insert into the reflogs. Defaults to "fetch".
|
542
570
|
*
|
@@ -559,7 +587,7 @@ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
|
|
559
587
|
git_strarray refspecs;
|
560
588
|
git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
|
561
589
|
const git_transfer_progress *stats;
|
562
|
-
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
|
590
|
+
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
|
563
591
|
|
564
592
|
char *log_message = NULL;
|
565
593
|
int error;
|
@@ -650,7 +678,7 @@ static VALUE rb_git_remote_push(int argc, VALUE *argv, VALUE self)
|
|
650
678
|
|
651
679
|
int error = 0;
|
652
680
|
|
653
|
-
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, rb_hash_new(), 0 };
|
681
|
+
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, rb_hash_new(), 0 };
|
654
682
|
|
655
683
|
rb_scan_args(argc, argv, "01:", &rb_refspecs, &rb_options);
|
656
684
|
|
@@ -1,25 +1,8 @@
|
|
1
1
|
/*
|
2
|
-
*
|
2
|
+
* Copyright (C) the Rugged contributors. All rights reserved.
|
3
3
|
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
11
|
-
* furnished to do so, subject to the following conditions:
|
12
|
-
*
|
13
|
-
* The above copyright notice and this permission notice shall be included in
|
14
|
-
* all copies or substantial portions of the Software.
|
15
|
-
*
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
* THE SOFTWARE.
|
4
|
+
* This file is part of Rugged, distributed under the MIT license.
|
5
|
+
* For full terms see the included LICENSE file.
|
23
6
|
*/
|
24
7
|
|
25
8
|
#include "rugged.h"
|