Skip to content

Commit dc07568

Browse files
author
Vicent Marti
committed
Merge pull request #470 from libgit2/arthur/libgit2
Update to latest libgit2
2 parents 70fe889 + 0627d14 commit dc07568

File tree

9 files changed

+58
-219
lines changed

9 files changed

+58
-219
lines changed

ext/rugged/rugged_branch_collection.c

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,6 @@ static git_branch_t parse_branch_type(VALUE rb_filter)
120120
* Overwrites the branch with the given +name+, if it already exists,
121121
* instead of raising an exception.
122122
*
123-
* :message ::
124-
* A single line log message to be appended to the reflog.
125-
*
126-
* :signature ::
127-
* The signature to be used for populating the reflog entry.
128-
*
129123
* If a branch with the given +name+ already exists and +:force+ is not +true+,
130124
* an exception will be raised.
131125
*
@@ -137,8 +131,6 @@ static VALUE rb_git_branch_collection_create(int argc, VALUE *argv, VALUE self)
137131
git_repository *repo;
138132
git_reference *branch;
139133
git_commit *target;
140-
git_signature *signature = NULL;
141-
char *log_message = NULL;
142134
int error, force = 0;
143135

144136
rb_scan_args(argc, argv, "20:", &rb_name, &rb_target, &rb_options);
@@ -150,25 +142,14 @@ static VALUE rb_git_branch_collection_create(int argc, VALUE *argv, VALUE self)
150142
Check_Type(rb_target, T_STRING);
151143

152144
if (!NIL_P(rb_options)) {
153-
VALUE rb_val;
154-
155145
force = RTEST(rb_hash_aref(rb_options, CSTR2SYM("force")));
156-
157-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("signature"));
158-
if (!NIL_P(rb_val))
159-
signature = rugged_signature_get(rb_val, repo);
160-
161-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
162-
if (!NIL_P(rb_val))
163-
log_message = StringValueCStr(rb_val);
164146
}
165147

166148
target = (git_commit *)rugged_object_get(repo, rb_target, GIT_OBJ_COMMIT);
167149

168-
error = git_branch_create(&branch, repo, StringValueCStr(rb_name), target, force, signature, log_message);
150+
error = git_branch_create(&branch, repo, StringValueCStr(rb_name), target, force);
169151

170152
git_commit_free(target);
171-
git_signature_free(signature);
172153

173154
rugged_exception_check(error);
174155

@@ -342,12 +323,6 @@ static VALUE rb_git_branch_collection_delete(VALUE self, VALUE rb_name_or_branch
342323
* Overwrites the branch with the given +name+, if it already exists,
343324
* instead of raising an exception.
344325
*
345-
* :message ::
346-
* A single line log message to be appended to the reflog.
347-
*
348-
* :signature ::
349-
* The signature to be used for populating the reflog entry.
350-
*
351326
* If a branch with the given +new_name+ already exists and +:force+ is not +true+,
352327
* an exception will be raised.
353328
*
@@ -359,36 +334,23 @@ static VALUE rb_git_branch_collection_move(int argc, VALUE *argv, VALUE self)
359334
VALUE rb_repo = rugged_owner(self), rb_name_or_branch, rb_new_branch_name, rb_options;
360335
git_reference *old_branch = NULL, *new_branch = NULL;
361336
git_repository *repo;
362-
git_signature *signature = NULL;
363-
char *log_message = NULL;
364337
int error, force = 0;
365338

366339
rb_scan_args(argc, argv, "20:", &rb_name_or_branch, &rb_new_branch_name, &rb_options);
367340
Check_Type(rb_new_branch_name, T_STRING);
368341

369342
rugged_check_repo(rb_repo);
370343
Data_Get_Struct(rb_repo, git_repository, repo);
371-
344+
372345
error = rugged_branch_lookup(&old_branch, repo, rb_name_or_branch);
373346
rugged_exception_check(error);
374347

375348
if (!NIL_P(rb_options)) {
376-
VALUE rb_val;
377-
378349
force = RTEST(rb_hash_aref(rb_options, CSTR2SYM("force")));
379-
380-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("signature"));
381-
if (!NIL_P(rb_val))
382-
signature = rugged_signature_get(rb_val, repo);
383-
384-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
385-
if (!NIL_P(rb_val))
386-
log_message = StringValueCStr(rb_val);
387350
}
388351

389-
error = git_branch_move(&new_branch, old_branch, StringValueCStr(rb_new_branch_name), force, signature, log_message);
352+
error = git_branch_move(&new_branch, old_branch, StringValueCStr(rb_new_branch_name), force);
390353

391-
git_signature_free(signature);
392354
git_reference_free(old_branch);
393355

394356
rugged_exception_check(error);

ext/rugged/rugged_config.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,22 @@ static VALUE rb_git_config_new(VALUE klass, VALUE rb_path)
8787
static VALUE rb_git_config_get(VALUE self, VALUE rb_key)
8888
{
8989
git_config *config;
90-
const char *value;
90+
git_buf buf = { NULL };
9191
int error;
92+
VALUE rb_result;
9293

9394
Data_Get_Struct(self, git_config, config);
9495
Check_Type(rb_key, T_STRING);
9596

96-
error = git_config_get_string(&value, config, StringValueCStr(rb_key));
97+
error = git_config_get_string_buf(&buf, config, StringValueCStr(rb_key));
9798
if (error == GIT_ENOTFOUND)
9899
return Qnil;
99100

100101
rugged_exception_check(error);
101-
return rb_str_new_utf8(value);
102+
rb_result = rb_str_new_utf8(buf.ptr);
103+
git_buf_free(&buf);
104+
105+
return rb_result;
102106
}
103107

104108
/*

ext/rugged/rugged_reference_collection.c

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,15 @@ static VALUE rb_git_reference_collection_initialize(VALUE self, VALUE repo)
5858
* Overwrites the reference with the given +name+, if it already exists,
5959
* instead of raising an exception.
6060
*
61-
* :message ::
62-
* A single line log message to be appended to the reflog.
63-
*
64-
* :signature ::
65-
* The signature to be used for populating the reflog entry.
66-
*
6761
* If a reference with the given +name+ already exists and +:force+ is not +true+,
6862
* an exception will be raised.
69-
*
70-
* The +:message+ and +:signature+ options are ignored if the reference does not
71-
* belong to the standard set (+HEAD+, +refs/heads/*+, +refs/remotes/*+ or +refs/notes/*+)
72-
* and it does not have a reflog.
7363
*/
7464
static VALUE rb_git_reference_collection_create(int argc, VALUE *argv, VALUE self)
7565
{
7666
VALUE rb_repo = rugged_owner(self), rb_name, rb_target, rb_options;
7767
git_repository *repo;
7868
git_reference *ref;
7969
git_oid oid;
80-
git_signature *signature = NULL;
8170
char *log_message = NULL;
8271
int error, force = 0;
8372

@@ -89,28 +78,21 @@ static VALUE rb_git_reference_collection_create(int argc, VALUE *argv, VALUE sel
8978
Check_Type(rb_target, T_STRING);
9079

9180
if (!NIL_P(rb_options)) {
92-
VALUE rb_val;
93-
94-
force = RTEST(rb_hash_aref(rb_options, CSTR2SYM("force")));
95-
96-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("signature"));
97-
if (!NIL_P(rb_val))
98-
signature = rugged_signature_get(rb_val, repo);
99-
100-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
81+
VALUE rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
10182
if (!NIL_P(rb_val))
10283
log_message = StringValueCStr(rb_val);
84+
85+
force = RTEST(rb_hash_aref(rb_options, CSTR2SYM("force")));
10386
}
10487

10588
if (git_oid_fromstr(&oid, StringValueCStr(rb_target)) == GIT_OK) {
10689
error = git_reference_create(
107-
&ref, repo, StringValueCStr(rb_name), &oid, force, signature, log_message);
90+
&ref, repo, StringValueCStr(rb_name), &oid, force, log_message);
10891
} else {
10992
error = git_reference_symbolic_create(
110-
&ref, repo, StringValueCStr(rb_name), StringValueCStr(rb_target), force, signature, log_message);
93+
&ref, repo, StringValueCStr(rb_name), StringValueCStr(rb_target), force, log_message);
11194
}
11295

113-
git_signature_free(signature);
11496
rugged_exception_check(error);
11597

11698
return rugged_ref_new(rb_cRuggedReference, rb_repo, ref);
@@ -284,26 +266,15 @@ static VALUE rb_git_reference_collection_exist_p(VALUE self, VALUE rb_name_or_re
284266
* Overwrites the reference with the given +name+, if it already exists,
285267
* instead of raising an exception.
286268
*
287-
* :message ::
288-
* A single line log message to be appended to the reflog.
289-
*
290-
* :signature ::
291-
* The signature to be used for populating the reflog entry.
292-
*
293269
* If a reference with the given +new_name+ already exists and +:force+ is not +true+,
294270
* an exception will be raised.
295-
*
296-
* The +:message+ and +:signature+ options are ignored if the reference does not
297-
* belong to the standard set (+HEAD+, +refs/heads/*+, +refs/remotes/*+ or +refs/notes/*+)
298-
* and it does not have a reflog.
299271
*/
300272
static VALUE rb_git_reference_collection_rename(int argc, VALUE *argv, VALUE self)
301273
{
302274
VALUE rb_new_name, rb_name_or_ref, rb_options;
303275
VALUE rb_repo = rugged_owner(self);
304276
git_reference *ref, *out = NULL;
305277
git_repository *repo;
306-
git_signature *signature = NULL;
307278
char *log_message = NULL;
308279
int error, force = 0;
309280

@@ -320,24 +291,17 @@ static VALUE rb_git_reference_collection_rename(int argc, VALUE *argv, VALUE sel
320291
Data_Get_Struct(rb_repo, git_repository, repo);
321292

322293
if (!NIL_P(rb_options)) {
323-
VALUE rb_val;
324-
325-
force = RTEST(rb_hash_aref(rb_options, CSTR2SYM("force")));
326-
327-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("signature"));
328-
if (!NIL_P(rb_val))
329-
signature = rugged_signature_get(rb_val, repo);
330-
331-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
294+
VALUE rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
332295
if (!NIL_P(rb_val))
333296
log_message = StringValueCStr(rb_val);
297+
298+
force = RTEST(rb_hash_aref(rb_options, CSTR2SYM("force")));
334299
}
335300

336301
if ((error = git_reference_lookup(&ref, repo, StringValueCStr(rb_name_or_ref))) == GIT_OK)
337-
error = git_reference_rename(&out, ref, StringValueCStr(rb_new_name), force, signature, log_message);
302+
error = git_reference_rename(&out, ref, StringValueCStr(rb_new_name), force, log_message);
338303

339304
git_reference_free(ref);
340-
git_signature_free(signature);
341305

342306
rugged_exception_check(error);
343307

@@ -371,7 +335,6 @@ static VALUE rb_git_reference_collection_update(int argc, VALUE *argv, VALUE sel
371335
{
372336
VALUE rb_repo = rugged_owner(self), rb_name_or_ref, rb_target, rb_options;
373337
git_repository *repo = NULL;
374-
git_signature *signature = NULL;
375338
git_reference *ref = NULL, *out = NULL;
376339
char *log_message = NULL;
377340
int error;
@@ -391,13 +354,7 @@ static VALUE rb_git_reference_collection_update(int argc, VALUE *argv, VALUE sel
391354
rb_raise(rb_eTypeError, "Expecting a String or Rugged::Reference instance");
392355

393356
if (!NIL_P(rb_options)) {
394-
VALUE rb_val;
395-
396-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("signature"));
397-
if (!NIL_P(rb_val))
398-
signature = rugged_signature_get(rb_val, repo);
399-
400-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
357+
VALUE rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
401358
if (!NIL_P(rb_val))
402359
log_message = StringValueCStr(rb_val);
403360
}
@@ -414,15 +371,14 @@ static VALUE rb_git_reference_collection_update(int argc, VALUE *argv, VALUE sel
414371
error = git_oid_fromstr(&target, StringValueCStr(rb_target));
415372
if (error) goto cleanup;
416373

417-
error = git_reference_set_target(&out, ref, &target, signature, log_message);
374+
error = git_reference_set_target(&out, ref, &target, log_message);
418375
} else {
419-
error = git_reference_symbolic_set_target(&out, ref, StringValueCStr(rb_target), signature, log_message);
376+
error = git_reference_symbolic_set_target(&out, ref, StringValueCStr(rb_target), log_message);
420377
}
421378

422379
cleanup:
423380

424381
git_reference_free(ref);
425-
git_signature_free(signature);
426382
rugged_exception_check(error);
427383

428384
return rugged_ref_new(rb_cRuggedReference, rb_repo, out);

ext/rugged/rugged_remote.c

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,6 @@ static VALUE rb_git_remote_check_connection(int argc, VALUE *argv, VALUE self)
608608
* :message ::
609609
* The message to insert into the reflogs. Defaults to "fetch".
610610
*
611-
* :signature ::
612-
* The signature to be used for updating the reflogs.
613-
*
614611
* Example:
615612
*
616613
* remote = Rugged::Remote.lookup(@repo, 'origin')
@@ -624,7 +621,6 @@ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
624621
{
625622
git_remote *remote;
626623
git_repository *repo;
627-
git_signature *signature = NULL;
628624
git_strarray refspecs;
629625
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
630626
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
@@ -645,19 +641,15 @@ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
645641
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
646642

647643
if (!NIL_P(rb_options)) {
648-
VALUE rb_val = rb_hash_aref(rb_options, CSTR2SYM("signature"));
649-
if (!NIL_P(rb_val))
650-
signature = rugged_signature_get(rb_val, repo);
651-
652-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
644+
VALUE rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
653645
if (!NIL_P(rb_val))
654646
log_message = StringValueCStr(rb_val);
655647
}
656648

657649
if ((error = git_remote_set_callbacks(remote, &callbacks)))
658650
goto cleanup;
659651

660-
if ((error = git_remote_fetch(remote, &refspecs, signature, log_message)) == GIT_OK) {
652+
if ((error = git_remote_fetch(remote, &refspecs, log_message)) == GIT_OK) {
661653
const git_transfer_progress *stats = git_remote_stats(remote);
662654

663655
rb_result = rb_hash_new();
@@ -673,7 +665,6 @@ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
673665
cleanup:
674666

675667
xfree(refspecs.strings);
676-
git_signature_free(signature);
677668

678669
if (payload.exception)
679670
rb_jump_tag(payload.exception);
@@ -705,32 +696,23 @@ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
705696
* A callback that will be executed each time a reference is updated remotely. It will be
706697
* passed the +refname+, +old_oid+ and +new_oid+.
707698
*
708-
* :message ::
709-
* A single line log message to be appended to the reflog of each local remote-tracking
710-
* branch that gets updated. Defaults to: "fetch".
711-
*
712-
* :signature ::
713-
* The signature to be used for populating the reflog entries.
714-
*
715699
* Example:
716700
*
717701
* remote = Rugged::Remote.lookup(@repo, 'origin')
718702
* remote.push(["refs/heads/master", ":refs/heads/to_be_deleted"])
719703
*/
720704
static VALUE rb_git_remote_push(int argc, VALUE *argv, VALUE self)
721705
{
722-
VALUE rb_refspecs, rb_options, rb_val;
706+
VALUE rb_refspecs, rb_options;
723707
VALUE rb_repo = rugged_owner(self);
724708

725709
git_repository *repo;
726710
git_remote *remote;
727711
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
728-
git_signature *signature = NULL;
729712
git_strarray refspecs;
730713
git_push_options opts = GIT_PUSH_OPTIONS_INIT;
731714

732715
int error = 0;
733-
char *log_message = NULL;
734716

735717
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, rb_hash_new(), 0 };
736718

@@ -744,24 +726,13 @@ static VALUE rb_git_remote_push(int argc, VALUE *argv, VALUE self)
744726

745727
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
746728

747-
if (!NIL_P(rb_options)) {
748-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
749-
if (!NIL_P(rb_val))
750-
log_message = StringValueCStr(rb_val);
751-
752-
rb_val = rb_hash_aref(rb_options, CSTR2SYM("signature"));
753-
if (!NIL_P(rb_val))
754-
signature = rugged_signature_get(rb_val, repo);
755-
}
756-
757729
if ((error = git_remote_set_callbacks(remote, &callbacks)))
758730
goto cleanup;
759731

760-
error = git_remote_push(remote, &refspecs, &opts, signature, log_message);
732+
error = git_remote_push(remote, &refspecs, &opts);
761733

762734
cleanup:
763735
xfree(refspecs.strings);
764-
git_signature_free(signature);
765736

766737
if (payload.exception)
767738
rb_jump_tag(payload.exception);

0 commit comments

Comments
 (0)