Method: Rugged::Repository#cherrypick_commit
- Defined in:
- ext/rugged/rugged_repo.c
#cherrypick_commit(commit, our_commit, [mainline, options]) ⇒ nil
Cherry-pick the given commit on the given base in-memory and return an index with the result.
‘commit` can be either a string containing a commit id or a `Rugged::Commit` object.
‘our_commit` is the base commit, can be either a string containing a commit id or a `Rugged::Commit` object.
‘mainline` when cherry-picking a merge, this is the parent number
(starting from 1) which should be considered the mainline.
2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 |
# File 'ext/rugged/rugged_repo.c', line 2700
static VALUE rb_git_repo_cherrypick_commit(int argc, VALUE *argv, VALUE self)
{
VALUE rb_options, rb_commit, rb_our_commit, rb_mainline;
git_repository *repo;
git_commit *commit, *our_commit;
git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
git_index *index;
int error, mainline;
rb_scan_args(argc, argv, "21:", &rb_commit, &rb_our_commit, &rb_mainline, &rb_options);
if (TYPE(rb_commit) == T_STRING) {
rb_commit = rugged_object_rev_parse(self, rb_commit, 1);
}
if (TYPE(rb_our_commit) == T_STRING) {
rb_our_commit = rugged_object_rev_parse(self, rb_our_commit, 1);
}
if (!rb_obj_is_kind_of(rb_commit, rb_cRuggedCommit)) {
rb_raise(rb_eArgError, "Expected a Rugged::Commit.");
}
if (!rb_obj_is_kind_of(rb_our_commit, rb_cRuggedCommit)) {
rb_raise(rb_eArgError, "Expected a Rugged::Commit.");
}
Data_Get_Struct(self, git_repository, repo);
TypedData_Get_Struct(rb_commit, git_commit, &rugged_object_type, commit);
TypedData_Get_Struct(rb_our_commit, git_commit, &rugged_object_type, our_commit);
rugged_parse_merge_options(&opts, rb_options);
mainline = NIL_P(rb_mainline) ? 0 : FIX2UINT(rb_mainline);
error = git_cherrypick_commit(&index, repo, commit, our_commit, mainline, &opts);
rugged_exception_check(error);
return rugged_index_new(rb_cRuggedIndex, self, index);
}
|