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_commit.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"
|
@@ -36,7 +19,7 @@ VALUE rb_cRuggedCommit;
|
|
36
19
|
* commit.message -> msg
|
37
20
|
*
|
38
21
|
* Return the message of this commit. This includes the full body of the
|
39
|
-
* message, with the short description, detailed
|
22
|
+
* message, with the short description, detailed description, and any
|
40
23
|
* optional footers or signatures after it.
|
41
24
|
*
|
42
25
|
* In Ruby 1.9+, the returned string will be encoded with the encoding
|
@@ -61,6 +44,35 @@ static VALUE rb_git_commit_message_GET(VALUE self)
|
|
61
44
|
return rb_enc_str_new(message, strlen(message), encoding);
|
62
45
|
}
|
63
46
|
|
47
|
+
/*
|
48
|
+
* call-seq:
|
49
|
+
* commit.summary -> summary
|
50
|
+
*
|
51
|
+
* Return the short summary message of this commit.
|
52
|
+
*
|
53
|
+
* In Ruby 1.9+, the returned string will be encoded with the encoding
|
54
|
+
* specified in the +Encoding+ header of the commit, if available.
|
55
|
+
*
|
56
|
+
* commit.message #=> "add a lot of RDoc docs\n\nthis includes docs for commit and blob"
|
57
|
+
* commit.summary #=> "add a lot of RDoc docs"
|
58
|
+
*/
|
59
|
+
static VALUE rb_git_commit_summary_GET(VALUE self)
|
60
|
+
{
|
61
|
+
git_commit *commit;
|
62
|
+
rb_encoding *encoding = rb_utf8_encoding();
|
63
|
+
const char *encoding_name;
|
64
|
+
const char *summary;
|
65
|
+
|
66
|
+
Data_Get_Struct(self, git_commit, commit);
|
67
|
+
|
68
|
+
summary = git_commit_summary(commit);
|
69
|
+
encoding_name = git_commit_message_encoding(commit);
|
70
|
+
if (encoding_name != NULL)
|
71
|
+
encoding = rb_enc_find(encoding_name);
|
72
|
+
|
73
|
+
return rb_enc_str_new(summary, strlen(summary), encoding);
|
74
|
+
}
|
75
|
+
|
64
76
|
/*
|
65
77
|
* call-seq:
|
66
78
|
* commit.committer -> signature
|
@@ -338,69 +350,44 @@ static VALUE rb_git_commit_amend(VALUE self, VALUE rb_data)
|
|
338
350
|
return rugged_create_oid(&commit_oid);
|
339
351
|
}
|
340
352
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
*
|
345
|
-
*
|
346
|
-
*
|
347
|
-
*
|
348
|
-
*
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
*
|
355
|
-
* - +:tree+: the tree for this commit, represented as a <tt>Rugged::Tree</tt>
|
356
|
-
* instance or an OID +String+.
|
357
|
-
* - +:update_ref+ (optional): a +String+ with the name of a reference in the
|
358
|
-
* repository which should be updated to point to this commit (e.g. "HEAD")
|
359
|
-
*
|
360
|
-
* When the commit is successfully written to disk, its +oid+ will be
|
361
|
-
* returned as a hex +String+.
|
362
|
-
*
|
363
|
-
* author = {:email=>"tanoku@gmail.com", :time=>Time.now, :name=>"Vicent Mart\303\255"}
|
353
|
+
struct commit_data {
|
354
|
+
VALUE rb_err_obj;
|
355
|
+
|
356
|
+
const char *update_ref;
|
357
|
+
const char *message;
|
358
|
+
git_tree *tree;
|
359
|
+
git_signature *author;
|
360
|
+
git_signature *committer;
|
361
|
+
int parent_count;
|
362
|
+
const git_commit **parents;
|
363
|
+
};
|
364
|
+
|
365
|
+
/**
|
366
|
+
* Parse the commit options into something we can re-use
|
364
367
|
*
|
365
|
-
*
|
366
|
-
*
|
367
|
-
* :message => "Hello world\n\n",
|
368
|
-
* :committer => author,
|
369
|
-
* :parents => ["2cb831a8aea28b2c1b9c63385585b864e4d3bad1"],
|
370
|
-
* :tree => some_tree) #=> "f148106ca58764adc93ad4e2d6b1d168422b9796"
|
368
|
+
* Note that parents may be set even when the function errors, so make
|
369
|
+
* sure to free this data.
|
371
370
|
*/
|
372
|
-
static VALUE
|
371
|
+
static VALUE parse_commit_options(struct commit_data *out, git_repository *repo, VALUE rb_data)
|
373
372
|
{
|
374
373
|
VALUE rb_message, rb_tree, rb_parents, rb_ref;
|
375
|
-
|
376
|
-
int parent_count, i, error = 0;
|
377
|
-
const git_commit **parents = NULL;
|
378
|
-
git_commit **free_list = NULL;
|
379
|
-
git_tree *tree;
|
380
|
-
git_signature *author, *committer;
|
381
|
-
git_oid commit_oid;
|
382
|
-
git_repository *repo;
|
383
|
-
const char *update_ref = NULL;
|
384
|
-
|
385
|
-
Check_Type(rb_data, T_HASH);
|
386
|
-
|
387
|
-
rugged_check_repo(rb_repo);
|
388
|
-
Data_Get_Struct(rb_repo, git_repository, repo);
|
374
|
+
int error = 0, parent_count, i;
|
389
375
|
|
390
376
|
rb_ref = rb_hash_aref(rb_data, CSTR2SYM("update_ref"));
|
391
377
|
if (!NIL_P(rb_ref)) {
|
392
378
|
Check_Type(rb_ref, T_STRING);
|
393
|
-
update_ref = StringValueCStr(rb_ref);
|
379
|
+
out->update_ref = StringValueCStr(rb_ref);
|
394
380
|
}
|
395
381
|
|
396
382
|
rb_message = rb_hash_aref(rb_data, CSTR2SYM("message"));
|
397
383
|
Check_Type(rb_message, T_STRING);
|
384
|
+
out->message = StringValueCStr(rb_message);
|
398
385
|
|
399
|
-
committer = rugged_signature_get(
|
386
|
+
out->committer = rugged_signature_get(
|
400
387
|
rb_hash_aref(rb_data, CSTR2SYM("committer")), repo
|
401
388
|
);
|
402
389
|
|
403
|
-
author = rugged_signature_get(
|
390
|
+
out->author = rugged_signature_get(
|
404
391
|
rb_hash_aref(rb_data, CSTR2SYM("author")), repo
|
405
392
|
);
|
406
393
|
|
@@ -408,16 +395,15 @@ static VALUE rb_git_commit_create(VALUE self, VALUE rb_repo, VALUE rb_data)
|
|
408
395
|
Check_Type(rb_parents, T_ARRAY);
|
409
396
|
|
410
397
|
rb_tree = rb_hash_aref(rb_data, CSTR2SYM("tree"));
|
411
|
-
tree = (git_tree *)rugged_object_get(repo, rb_tree, GIT_OBJ_TREE);
|
398
|
+
out->tree = (git_tree *)rugged_object_get(repo, rb_tree, GIT_OBJ_TREE);
|
412
399
|
|
413
|
-
parents =
|
414
|
-
free_list = alloca(RARRAY_LEN(rb_parents) * sizeof(void *));
|
400
|
+
out->parents = xcalloc(RARRAY_LEN(rb_parents), sizeof(void *));
|
415
401
|
parent_count = 0;
|
416
402
|
|
417
403
|
for (i = 0; i < (int)RARRAY_LEN(rb_parents); ++i) {
|
418
404
|
VALUE p = rb_ary_entry(rb_parents, i);
|
419
405
|
git_commit *parent = NULL;
|
420
|
-
git_commit *
|
406
|
+
git_commit *tmp = NULL;
|
421
407
|
|
422
408
|
if (NIL_P(p))
|
423
409
|
continue;
|
@@ -427,49 +413,106 @@ static VALUE rb_git_commit_create(VALUE self, VALUE rb_repo, VALUE rb_data)
|
|
427
413
|
|
428
414
|
error = git_oid_fromstr(&oid, StringValueCStr(p));
|
429
415
|
if (error < GIT_OK)
|
430
|
-
goto
|
416
|
+
goto out;
|
431
417
|
|
432
418
|
error = git_commit_lookup(&parent, repo, &oid);
|
433
419
|
if (error < GIT_OK)
|
434
|
-
goto
|
435
|
-
|
436
|
-
free_ptr = parent;
|
437
|
-
|
420
|
+
goto out;
|
438
421
|
} else if (rb_obj_is_kind_of(p, rb_cRuggedCommit)) {
|
439
|
-
Data_Get_Struct(p, git_commit,
|
422
|
+
Data_Get_Struct(p, git_commit, tmp);
|
423
|
+
if ((error = git_object_dup((git_object **) &parent, (git_object *) tmp)) < 0)
|
424
|
+
goto out;
|
440
425
|
} else {
|
441
|
-
rb_err_obj = rb_exc_new2(rb_eTypeError, "Invalid type for parent object");
|
442
|
-
|
426
|
+
out->rb_err_obj = rb_exc_new2(rb_eTypeError, "Invalid type for parent object");
|
427
|
+
error = -1;
|
428
|
+
goto out;
|
443
429
|
}
|
444
430
|
|
445
|
-
parents[parent_count] = parent;
|
446
|
-
free_list[parent_count] = free_ptr;
|
431
|
+
out->parents[parent_count] = parent;
|
447
432
|
parent_count++;
|
448
433
|
}
|
449
434
|
|
435
|
+
out:
|
436
|
+
out->parent_count = parent_count;
|
437
|
+
return error;
|
438
|
+
}
|
439
|
+
|
440
|
+
static void free_commit_options(struct commit_data *commit_data)
|
441
|
+
{
|
442
|
+
int i;
|
443
|
+
|
444
|
+
git_signature_free(commit_data->author);
|
445
|
+
git_signature_free(commit_data->committer);
|
446
|
+
|
447
|
+
git_object_free((git_object *)commit_data->tree);
|
448
|
+
|
449
|
+
for (i = 0; i < commit_data->parent_count; ++i)
|
450
|
+
git_object_free((git_object *) commit_data->parents[i]);
|
451
|
+
xfree(commit_data->parents);
|
452
|
+
}
|
453
|
+
|
454
|
+
/*
|
455
|
+
* call-seq:
|
456
|
+
* Commit.create(repository, data = {}) -> oid
|
457
|
+
*
|
458
|
+
* Write a new +Commit+ object to +repository+, with the given +data+
|
459
|
+
* arguments, passed as a +Hash+:
|
460
|
+
*
|
461
|
+
* - +:message+: a string with the full text for the commit's message
|
462
|
+
* - +:committer+ (optional): a hash with the signature for the committer,
|
463
|
+
* defaults to the signature from the configuration
|
464
|
+
* - +:author+ (optional): a hash with the signature for the author,
|
465
|
+
* defaults to the signature from the configuration
|
466
|
+
* - +:parents+: an +Array+ with zero or more parents for this commit,
|
467
|
+
* represented as <tt>Rugged::Commit</tt> instances, or OID +String+.
|
468
|
+
* - +:tree+: the tree for this commit, represented as a <tt>Rugged::Tree</tt>
|
469
|
+
* instance or an OID +String+.
|
470
|
+
* - +:update_ref+ (optional): a +String+ with the name of a reference in the
|
471
|
+
* repository which should be updated to point to this commit (e.g. "HEAD")
|
472
|
+
*
|
473
|
+
* When the commit is successfully written to disk, its +oid+ will be
|
474
|
+
* returned as a hex +String+.
|
475
|
+
*
|
476
|
+
* author = {:email=>"tanoku@gmail.com", :time=>Time.now, :name=>"Vicent Mart\303\255"}
|
477
|
+
*
|
478
|
+
* Rugged::Commit.create(r,
|
479
|
+
* :author => author,
|
480
|
+
* :message => "Hello world\n\n",
|
481
|
+
* :committer => author,
|
482
|
+
* :parents => ["2cb831a8aea28b2c1b9c63385585b864e4d3bad1"],
|
483
|
+
* :tree => some_tree) #=> "f148106ca58764adc93ad4e2d6b1d168422b9796"
|
484
|
+
*/
|
485
|
+
static VALUE rb_git_commit_create(VALUE self, VALUE rb_repo, VALUE rb_data)
|
486
|
+
{
|
487
|
+
int error = 0;
|
488
|
+
struct commit_data commit_data = { Qnil };
|
489
|
+
git_oid commit_oid;
|
490
|
+
git_repository *repo;
|
491
|
+
|
492
|
+
Check_Type(rb_data, T_HASH);
|
493
|
+
|
494
|
+
rugged_check_repo(rb_repo);
|
495
|
+
Data_Get_Struct(rb_repo, git_repository, repo);
|
496
|
+
|
497
|
+
if ((error = parse_commit_options(&commit_data, repo, rb_data)) < 0)
|
498
|
+
goto cleanup;
|
499
|
+
|
450
500
|
error = git_commit_create(
|
451
501
|
&commit_oid,
|
452
502
|
repo,
|
453
|
-
update_ref,
|
454
|
-
author,
|
455
|
-
committer,
|
503
|
+
commit_data.update_ref,
|
504
|
+
commit_data.author,
|
505
|
+
commit_data.committer,
|
456
506
|
NULL,
|
457
|
-
|
458
|
-
tree,
|
459
|
-
parent_count,
|
460
|
-
parents);
|
507
|
+
commit_data.message,
|
508
|
+
commit_data.tree,
|
509
|
+
commit_data.parent_count,
|
510
|
+
commit_data.parents);
|
461
511
|
|
462
512
|
cleanup:
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
git_object_free((git_object *)tree);
|
467
|
-
|
468
|
-
for (i = 0; i < parent_count; ++i)
|
469
|
-
git_object_free((git_object *)free_list[i]);
|
470
|
-
|
471
|
-
if (!NIL_P(rb_err_obj))
|
472
|
-
rb_exc_raise(rb_err_obj);
|
513
|
+
free_commit_options(&commit_data);
|
514
|
+
if (!NIL_P(commit_data.rb_err_obj))
|
515
|
+
rb_exc_raise(commit_data.rb_err_obj);
|
473
516
|
|
474
517
|
rugged_exception_check(error);
|
475
518
|
|
@@ -614,7 +657,7 @@ static VALUE rb_git_commit_header(VALUE self)
|
|
614
657
|
|
615
658
|
/*
|
616
659
|
* call-seq:
|
617
|
-
*
|
660
|
+
* Commit.extract_signature(repo, commit, field_name) -> [str, str]
|
618
661
|
*
|
619
662
|
* Returns +commit+'s signature in 'field' and the signed data
|
620
663
|
*
|
@@ -662,14 +705,121 @@ static VALUE rb_git_commit_extract_signature(int argc, VALUE *argv, VALUE self)
|
|
662
705
|
return ret;
|
663
706
|
}
|
664
707
|
|
708
|
+
/*
|
709
|
+
* call-seq:
|
710
|
+
* Commit.create_to_s(repository, data = {}) -> str
|
711
|
+
*
|
712
|
+
* Create a string with the contents of the commit, created with the
|
713
|
+
* given +data+ arguments, passed as a +Hash+:
|
714
|
+
*
|
715
|
+
* - +:message+: a string with the full text for the commit's message
|
716
|
+
* - +:committer+ (optional): a hash with the signature for the committer,
|
717
|
+
* defaults to the signature from the configuration
|
718
|
+
* - +:author+ (optional): a hash with the signature for the author,
|
719
|
+
* defaults to the signature from the configuration
|
720
|
+
* - +:parents+: an +Array+ with zero or more parents for this commit,
|
721
|
+
* represented as <tt>Rugged::Commit</tt> instances, or OID +String+.
|
722
|
+
* - +:tree+: the tree for this commit, represented as a <tt>Rugged::Tree</tt>
|
723
|
+
* instance or an OID +String+.
|
724
|
+
*
|
725
|
+
* author = {:email=>"tanoku@gmail.com", :time=>Time.now, :name=>"Vicent Mart\303\255"}
|
726
|
+
*
|
727
|
+
* Rugged::Commit.create(r,
|
728
|
+
* :author => author,
|
729
|
+
* :message => "Hello world\n\n",
|
730
|
+
* :committer => author,
|
731
|
+
* :parents => ["2cb831a8aea28b2c1b9c63385585b864e4d3bad1"],
|
732
|
+
* :tree => some_tree) #=> "tree some_tree\nparent 2cb831...."
|
733
|
+
*/
|
734
|
+
static VALUE rb_git_commit_create_to_s(VALUE self, VALUE rb_repo, VALUE rb_data)
|
735
|
+
{
|
736
|
+
int error = 0;
|
737
|
+
struct commit_data commit_data = { Qnil };
|
738
|
+
git_repository *repo;
|
739
|
+
git_buf buf = { 0 };
|
740
|
+
VALUE ret;
|
741
|
+
|
742
|
+
Check_Type(rb_data, T_HASH);
|
743
|
+
|
744
|
+
rugged_check_repo(rb_repo);
|
745
|
+
Data_Get_Struct(rb_repo, git_repository, repo);
|
746
|
+
|
747
|
+
if ((error = parse_commit_options(&commit_data, repo, rb_data)) < 0)
|
748
|
+
goto cleanup;
|
749
|
+
|
750
|
+
error = git_commit_create_buffer(
|
751
|
+
&buf,
|
752
|
+
repo,
|
753
|
+
commit_data.author,
|
754
|
+
commit_data.committer,
|
755
|
+
NULL,
|
756
|
+
commit_data.message,
|
757
|
+
commit_data.tree,
|
758
|
+
commit_data.parent_count,
|
759
|
+
commit_data.parents);
|
760
|
+
|
761
|
+
cleanup:
|
762
|
+
free_commit_options(&commit_data);
|
763
|
+
if (!NIL_P(commit_data.rb_err_obj))
|
764
|
+
rb_exc_raise(commit_data.rb_err_obj);
|
765
|
+
|
766
|
+
rugged_exception_check(error);
|
767
|
+
|
768
|
+
ret = rb_str_new_utf8(buf.ptr);
|
769
|
+
git_buf_free(&buf);
|
770
|
+
|
771
|
+
return ret;
|
772
|
+
}
|
773
|
+
|
774
|
+
/*
|
775
|
+
* call-seq:
|
776
|
+
* Commit.create_with_signature(repo, content, signature, field_name = "gpgsig") -> oid
|
777
|
+
*
|
778
|
+
* Create a commit from the +content+ string and the +signature+,
|
779
|
+
* adding this data to the +field_name+ header field in the resulting
|
780
|
+
* commit.
|
781
|
+
*
|
782
|
+
* Returns the new commit's object id.
|
783
|
+
*
|
784
|
+
*/
|
785
|
+
static VALUE rb_git_commit_create_with_signature(int argc, VALUE *argv, VALUE self)
|
786
|
+
{
|
787
|
+
int error;
|
788
|
+
git_oid id;
|
789
|
+
const char *field = NULL;
|
790
|
+
git_repository *repo;
|
791
|
+
VALUE rb_repo, rb_content, rb_signature, rb_field = Qnil;
|
792
|
+
|
793
|
+
rb_scan_args(argc, argv, "31", &rb_repo, &rb_content, &rb_signature, &rb_field);
|
794
|
+
|
795
|
+
rugged_check_repo(rb_repo);
|
796
|
+
Data_Get_Struct(rb_repo, git_repository, repo);
|
797
|
+
|
798
|
+
Check_Type(rb_content, T_STRING);
|
799
|
+
Check_Type(rb_signature, T_STRING);
|
800
|
+
|
801
|
+
if (!NIL_P(rb_field)) {
|
802
|
+
Check_Type(rb_field, T_STRING);
|
803
|
+
field = StringValueCStr(rb_field);
|
804
|
+
}
|
805
|
+
|
806
|
+
error = git_commit_create_with_signature(&id, repo, StringValueCStr(rb_content), StringValueCStr(rb_signature), field);
|
807
|
+
rugged_exception_check(error);
|
808
|
+
|
809
|
+
return rugged_create_oid(&id);
|
810
|
+
}
|
811
|
+
|
665
812
|
void Init_rugged_commit(void)
|
666
813
|
{
|
667
814
|
rb_cRuggedCommit = rb_define_class_under(rb_mRugged, "Commit", rb_cRuggedObject);
|
668
815
|
|
669
816
|
rb_define_singleton_method(rb_cRuggedCommit, "create", rb_git_commit_create, 2);
|
817
|
+
rb_define_singleton_method(rb_cRuggedCommit, "create_to_s", rb_git_commit_create_to_s, 2);
|
818
|
+
rb_define_singleton_method(rb_cRuggedCommit, "create_with_signature", rb_git_commit_create_with_signature, -1);
|
670
819
|
rb_define_singleton_method(rb_cRuggedCommit, "extract_signature", rb_git_commit_extract_signature, -1);
|
671
820
|
|
672
821
|
rb_define_method(rb_cRuggedCommit, "message", rb_git_commit_message_GET, 0);
|
822
|
+
rb_define_method(rb_cRuggedCommit, "summary", rb_git_commit_summary_GET, 0);
|
673
823
|
rb_define_method(rb_cRuggedCommit, "epoch_time", rb_git_commit_epoch_time_GET, 0);
|
674
824
|
rb_define_method(rb_cRuggedCommit, "committer", rb_git_commit_committer_GET, 0);
|
675
825
|
rb_define_method(rb_cRuggedCommit, "author", rb_git_commit_author_GET, 0);
|
data/ext/rugged/rugged_config.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"
|
data/ext/rugged/rugged_cred.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"
|
data/ext/rugged/rugged_diff.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"
|
@@ -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"
|
@@ -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"
|
@@ -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"
|