Skip to content

Commit 06ac739

Browse files
author
Vicent Marti
committed
Merge pull request #486 from libgit2/arthur/latest-libgit2
Update to the latest libgit2 changes
2 parents 0205e80 + 18f47b8 commit 06ac739

File tree

11 files changed

+290
-339
lines changed

11 files changed

+290
-339
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ matrix:
2020
fast_finish: true
2121
allow_failures:
2222
- rvm: rbx-2
23+
- rvm: ruby-head
2324

2425
install:
2526
- ./vendor/libgit2/script/install-deps-${TRAVIS_OS_NAME}.sh

CHANGELOG.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
1-
21
* Add accessors for the Repository ident.
32

43
Added `Repository#ident` and `Repository#ident=` to read and set the
54
identity that is used when writing reflog entries.
65

76
*Arthur Schreiber*
87

8+
* `Rugged::Remote` instances are now immutable.
9+
10+
* `Remote#clear_refspecs` and `Remote#save` were removed without
11+
replacement.
12+
13+
* `Remote#url=` and `Remote#push_url=` were removed and replaced by
14+
`RemoteCollection#set_url` and `RemoteCollection#set_push_url`.
15+
16+
* `Remote#add_push` and `Remote#add_fetch` were removed and replaced by
17+
`RemoteCollection#add_push_refspec` and
18+
`RemoteCollection#add_fetch_refspec`.
19+
20+
*Arthur Schreiber*
21+
22+
* Update bundled libgit2 to 9042693e283f65d9afb4906ed693a862a250664b.
23+
24+
*Arthur Schreiber*
25+
926
* Updated the API of reflog modifying methods.
1027

1128
This removes both the optional `:message` as well as `:signature` options from
@@ -29,10 +46,6 @@
2946

3047
*Arthur Schreiber*
3148

32-
* Update bundled libgit2 to 8311db0cf8ae15b46edd14358a8238862e0bac4d.
33-
34-
*Arthur Schreiber*
35-
3649

3750
## Rugged 0.22.2 (May 17, 2015) ##
3851

ext/rugged/rugged_diff.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,15 @@ void rugged_parse_diff_options(git_diff_options *opts, VALUE rb_options)
120120
}
121121

122122
if (RTEST(rb_hash_aref(rb_options, CSTR2SYM("show_untracked_content")))) {
123-
opts->flags |= GIT_DIFF_SHOW_UNTRACKED_CONTENT ;
123+
opts->flags |= GIT_DIFF_SHOW_UNTRACKED_CONTENT;
124124
}
125125

126126
if (RTEST(rb_hash_aref(rb_options, CSTR2SYM("show_unmodified")))) {
127-
opts->flags |= GIT_DIFF_SHOW_UNTRACKED_CONTENT ;
127+
opts->flags |= GIT_DIFF_SHOW_UNMODIFIED;
128+
}
129+
130+
if (RTEST(rb_hash_aref(rb_options, CSTR2SYM("show_binary")))) {
131+
opts->flags |= GIT_DIFF_SHOW_BINARY;
128132
}
129133

130134
if (RTEST(rb_hash_aref(rb_options, CSTR2SYM("patience")))) {
@@ -643,7 +647,7 @@ static VALUE rb_git_diff_stat(VALUE self)
643647
Data_Get_Struct(self, git_diff, diff);
644648

645649
git_diff_foreach(
646-
diff, diff_file_stats_cb, NULL, diff_line_stats_cb, &stats);
650+
diff, diff_file_stats_cb, NULL, NULL, diff_line_stats_cb, &stats);
647651

648652
return rb_ary_new3(
649653
3, INT2FIX(stats.files), INT2FIX(stats.adds), INT2FIX(stats.dels));

ext/rugged/rugged_index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ static VALUE rb_git_indexentry_fromC(const git_index_entry *entry)
555555
return rb_entry;
556556
}
557557

558-
static inline unsigned int
558+
static inline uint32_t
559559
default_entry_value(VALUE rb_entry, const char *key)
560560
{
561561
VALUE val = rb_hash_aref(rb_entry, CSTR2SYM(key));
@@ -587,7 +587,7 @@ static void rb_git_indexentry_toC(git_index_entry *entry, VALUE rb_entry)
587587
entry->mode = default_entry_value(rb_entry, "mode");
588588
entry->gid = default_entry_value(rb_entry, "gid");
589589
entry->uid = default_entry_value(rb_entry, "uid");
590-
entry->file_size = (git_off_t)default_entry_value(rb_entry, "file_size");
590+
entry->file_size = default_entry_value(rb_entry, "file_size");
591591

592592
if ((val = rb_hash_aref(rb_entry, CSTR2SYM("mtime"))) != Qnil) {
593593
if (!rb_obj_is_kind_of(val, rb_cTime))

ext/rugged/rugged_remote.c

Lines changed: 27 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ static VALUE rb_git_remote_ls(int argc, VALUE *argv, VALUE self)
264264

265265
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
266266

267-
if ((error = git_remote_set_callbacks(remote, &callbacks)) ||
268-
(error = git_remote_connect(remote, GIT_DIRECTION_FETCH)) ||
267+
if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, &callbacks)) ||
269268
(error = git_remote_ls(&heads, &heads_len, remote)))
270269
goto cleanup;
271270

@@ -319,28 +318,6 @@ static VALUE rb_git_remote_url(VALUE self)
319318
return rb_str_new_utf8(git_remote_url(remote));
320319
}
321320

322-
/*
323-
* call-seq:
324-
* remote.url = url -> url
325-
*
326-
* Sets the remote's url without persisting it in the config.
327-
* Existing connections will not be updated.
328-
*
329-
* remote.url = 'git://github.com/libgit2/rugged.git' #=> "git://github.com/libgit2/rugged.git"
330-
*/
331-
static VALUE rb_git_remote_set_url(VALUE self, VALUE rb_url)
332-
{
333-
git_remote *remote;
334-
335-
Check_Type(rb_url, T_STRING);
336-
Data_Get_Struct(self, git_remote, remote);
337-
338-
rugged_exception_check(
339-
git_remote_set_url(remote, StringValueCStr(rb_url))
340-
);
341-
return rb_url;
342-
}
343-
344321
/*
345322
* call-seq:
346323
* remote.push_url() -> string or nil
@@ -372,13 +349,18 @@ static VALUE rb_git_remote_push_url(VALUE self)
372349
*/
373350
static VALUE rb_git_remote_set_push_url(VALUE self, VALUE rb_url)
374351
{
352+
VALUE rb_repo = rugged_owner(self);
375353
git_remote *remote;
354+
git_repository *repo;
355+
356+
rugged_check_repo(rb_repo);
357+
Data_Get_Struct(rb_repo, git_repository, repo);
376358

377359
Check_Type(rb_url, T_STRING);
378360
Data_Get_Struct(self, git_remote, remote);
379361

380362
rugged_exception_check(
381-
git_remote_set_pushurl(remote, StringValueCStr(rb_url))
363+
git_remote_set_pushurl(repo, git_remote_name(remote), StringValueCStr(rb_url))
382364
);
383365

384366
return rb_url;
@@ -427,86 +409,6 @@ static VALUE rb_git_remote_push_refspecs(VALUE self)
427409
return rb_git_remote_refspecs(self, GIT_DIRECTION_PUSH);
428410
}
429411

430-
static VALUE rb_git_remote_add_refspec(VALUE self, VALUE rb_refspec, git_direction direction)
431-
{
432-
git_remote *remote;
433-
int error = 0;
434-
435-
Data_Get_Struct(self, git_remote, remote);
436-
437-
Check_Type(rb_refspec, T_STRING);
438-
439-
if (direction == GIT_DIRECTION_FETCH)
440-
error = git_remote_add_fetch(remote, StringValueCStr(rb_refspec));
441-
else
442-
error = git_remote_add_push(remote, StringValueCStr(rb_refspec));
443-
444-
rugged_exception_check(error);
445-
446-
return Qnil;
447-
}
448-
449-
/*
450-
* call-seq:
451-
* remote.add_fetch(refspec) -> nil
452-
*
453-
* Add a fetch refspec to the remote.
454-
*/
455-
static VALUE rb_git_remote_add_fetch(VALUE self, VALUE rb_refspec)
456-
{
457-
return rb_git_remote_add_refspec(self, rb_refspec, GIT_DIRECTION_FETCH);
458-
}
459-
460-
/*
461-
* call-seq:
462-
* remote.add_push(refspec) -> nil
463-
*
464-
* Add a push refspec to the remote.
465-
*/
466-
static VALUE rb_git_remote_add_push(VALUE self, VALUE rb_refspec)
467-
{
468-
return rb_git_remote_add_refspec(self, rb_refspec, GIT_DIRECTION_PUSH);
469-
}
470-
471-
/*
472-
* call-seq:
473-
* remote.clear_refspecs -> nil
474-
*
475-
* Remove all configured fetch and push refspecs from the remote.
476-
*/
477-
static VALUE rb_git_remote_clear_refspecs(VALUE self)
478-
{
479-
git_remote *remote;
480-
481-
Data_Get_Struct(self, git_remote, remote);
482-
483-
git_remote_clear_refspecs(remote);
484-
485-
return Qnil;
486-
}
487-
488-
/*
489-
* call-seq:
490-
* remote.save -> true
491-
*
492-
* Saves the remote data (url, fetchspecs, ...) to the config.
493-
*
494-
* Anonymous, in-memory remotes created through
495-
* +ReferenceCollection#create_anonymous+ can not be saved.
496-
* Doing so will result in an exception being raised.
497-
*/
498-
static VALUE rb_git_remote_save(VALUE self)
499-
{
500-
git_remote *remote;
501-
502-
Data_Get_Struct(self, git_remote, remote);
503-
504-
rugged_exception_check(
505-
git_remote_save(remote)
506-
);
507-
return Qtrue;
508-
}
509-
510412
/*
511413
* call-seq:
512414
* remote.check_connection(direction, options = {}) -> boolean
@@ -556,21 +458,13 @@ static VALUE rb_git_remote_check_connection(int argc, VALUE *argv, VALUE self)
556458

557459
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
558460

559-
if ((error = git_remote_set_callbacks(remote, &callbacks)) < 0)
560-
goto cleanup;
561-
562-
if (git_remote_connect(remote, direction))
563-
return Qfalse;
564-
else {
565-
git_remote_disconnect(remote);
566-
return Qtrue;
567-
}
461+
error = git_remote_connect(remote, direction, &callbacks);
462+
git_remote_disconnect(remote);
568463

569-
cleanup:
570464
if (payload.exception)
571465
rb_jump_tag(payload.exception);
572-
rugged_exception_check(error);
573-
return Qfalse;
466+
467+
return error ? Qfalse : Qtrue;
574468
}
575469

576470
/*
@@ -622,7 +516,8 @@ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
622516
git_remote *remote;
623517
git_repository *repo;
624518
git_strarray refspecs;
625-
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
519+
git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
520+
const git_transfer_progress *stats;
626521
struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
627522

628523
char *log_message = NULL;
@@ -638,31 +533,15 @@ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
638533
rugged_check_repo(rb_repo);
639534
Data_Get_Struct(rb_repo, git_repository, repo);
640535

641-
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
536+
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &opts.callbacks, &payload);
642537

643538
if (!NIL_P(rb_options)) {
644539
VALUE rb_val = rb_hash_aref(rb_options, CSTR2SYM("message"));
645540
if (!NIL_P(rb_val))
646541
log_message = StringValueCStr(rb_val);
647542
}
648543

649-
if ((error = git_remote_set_callbacks(remote, &callbacks)))
650-
goto cleanup;
651-
652-
if ((error = git_remote_fetch(remote, &refspecs, log_message)) == GIT_OK) {
653-
const git_transfer_progress *stats = git_remote_stats(remote);
654-
655-
rb_result = rb_hash_new();
656-
rb_hash_aset(rb_result, CSTR2SYM("total_objects"), UINT2NUM(stats->total_objects));
657-
rb_hash_aset(rb_result, CSTR2SYM("indexed_objects"), UINT2NUM(stats->indexed_objects));
658-
rb_hash_aset(rb_result, CSTR2SYM("received_objects"), UINT2NUM(stats->received_objects));
659-
rb_hash_aset(rb_result, CSTR2SYM("local_objects"), UINT2NUM(stats->local_objects));
660-
rb_hash_aset(rb_result, CSTR2SYM("total_deltas"), UINT2NUM(stats->total_deltas));
661-
rb_hash_aset(rb_result, CSTR2SYM("indexed_deltas"), UINT2NUM(stats->indexed_deltas));
662-
rb_hash_aset(rb_result, CSTR2SYM("received_bytes"), INT2FIX(stats->received_bytes));
663-
}
664-
665-
cleanup:
544+
error = git_remote_fetch(remote, &refspecs, &opts, log_message);
666545

667546
xfree(refspecs.strings);
668547

@@ -671,6 +550,17 @@ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self)
671550

672551
rugged_exception_check(error);
673552

553+
stats = git_remote_stats(remote);
554+
555+
rb_result = rb_hash_new();
556+
rb_hash_aset(rb_result, CSTR2SYM("total_objects"), UINT2NUM(stats->total_objects));
557+
rb_hash_aset(rb_result, CSTR2SYM("indexed_objects"), UINT2NUM(stats->indexed_objects));
558+
rb_hash_aset(rb_result, CSTR2SYM("received_objects"), UINT2NUM(stats->received_objects));
559+
rb_hash_aset(rb_result, CSTR2SYM("local_objects"), UINT2NUM(stats->local_objects));
560+
rb_hash_aset(rb_result, CSTR2SYM("total_deltas"), UINT2NUM(stats->total_deltas));
561+
rb_hash_aset(rb_result, CSTR2SYM("indexed_deltas"), UINT2NUM(stats->indexed_deltas));
562+
rb_hash_aset(rb_result, CSTR2SYM("received_bytes"), INT2FIX(stats->received_bytes));
563+
674564
return rb_result;
675565
}
676566

@@ -708,7 +598,6 @@ static VALUE rb_git_remote_push(int argc, VALUE *argv, VALUE self)
708598

709599
git_repository *repo;
710600
git_remote *remote;
711-
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
712601
git_strarray refspecs;
713602
git_push_options opts = GIT_PUSH_OPTIONS_INIT;
714603

@@ -724,14 +613,10 @@ static VALUE rb_git_remote_push(int argc, VALUE *argv, VALUE self)
724613
Data_Get_Struct(rb_repo, git_repository, repo);
725614
Data_Get_Struct(self, git_remote, remote);
726615

727-
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload);
728-
729-
if ((error = git_remote_set_callbacks(remote, &callbacks)))
730-
goto cleanup;
616+
rugged_remote_init_callbacks_and_payload_from_options(rb_options, &opts.callbacks, &payload);
731617

732618
error = git_remote_push(remote, &refspecs, &opts);
733619

734-
cleanup:
735620
xfree(refspecs.strings);
736621

737622
if (payload.exception)
@@ -746,20 +631,14 @@ void Init_rugged_remote(void)
746631
{
747632
rb_cRuggedRemote = rb_define_class_under(rb_mRugged, "Remote", rb_cObject);
748633

749-
750634
rb_define_method(rb_cRuggedRemote, "name", rb_git_remote_name, 0);
751635
rb_define_method(rb_cRuggedRemote, "url", rb_git_remote_url, 0);
752-
rb_define_method(rb_cRuggedRemote, "url=", rb_git_remote_set_url, 1);
753636
rb_define_method(rb_cRuggedRemote, "push_url", rb_git_remote_push_url, 0);
754637
rb_define_method(rb_cRuggedRemote, "push_url=", rb_git_remote_set_push_url, 1);
755638
rb_define_method(rb_cRuggedRemote, "fetch_refspecs", rb_git_remote_fetch_refspecs, 0);
756639
rb_define_method(rb_cRuggedRemote, "push_refspecs", rb_git_remote_push_refspecs, 0);
757-
rb_define_method(rb_cRuggedRemote, "add_fetch", rb_git_remote_add_fetch, 1);
758-
rb_define_method(rb_cRuggedRemote, "add_push", rb_git_remote_add_push, 1);
759640
rb_define_method(rb_cRuggedRemote, "ls", rb_git_remote_ls, -1);
760641
rb_define_method(rb_cRuggedRemote, "check_connection", rb_git_remote_check_connection, -1);
761642
rb_define_method(rb_cRuggedRemote, "fetch", rb_git_remote_fetch, -1);
762643
rb_define_method(rb_cRuggedRemote, "push", rb_git_remote_push, -1);
763-
rb_define_method(rb_cRuggedRemote, "clear_refspecs", rb_git_remote_clear_refspecs, 0);
764-
rb_define_method(rb_cRuggedRemote, "save", rb_git_remote_save, 0);
765644
}

0 commit comments

Comments
 (0)