Method: Rugged::Repository#merge_commits
- Defined in:
- ext/rugged/rugged_repo.c
#merge_commits(our_commit, their_commit, options = {}) ⇒ Object
Merges the two given commits, returning a Rugged::Index that reflects the result of the merge.
our_commit
and their_commit
can either be Rugged::Commit objects, or OIDs resolving to the former.
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 |
# File 'ext/rugged/rugged_repo.c', line 1064
static VALUE rb_git_repo_merge_commits(int argc, VALUE *argv, VALUE self)
{
VALUE rb_our_commit, rb_their_commit, rb_options;
git_commit *our_commit, *their_commit;
git_index *index;
git_repository *repo;
git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
int error;
rb_scan_args(argc, argv, "20:", &rb_our_commit, &rb_their_commit, &rb_options);
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_our_commit, rb_cRuggedCommit)) {
rb_raise(rb_eArgError, "Expected a Rugged::Commit.");
}
if (TYPE(rb_their_commit) == T_STRING) {
rb_their_commit = rugged_object_rev_parse(self, rb_their_commit, 1);
}
if (!rb_obj_is_kind_of(rb_their_commit, rb_cRuggedCommit)) {
rb_raise(rb_eArgError, "Expected a Rugged::Commit.");
}
if (!NIL_P(rb_options)) {
Check_Type(rb_options, T_HASH);
rugged_parse_merge_options(&opts, rb_options);
}
Data_Get_Struct(self, git_repository, repo);
TypedData_Get_Struct(rb_our_commit, git_commit, &rugged_object_type, our_commit);
TypedData_Get_Struct(rb_their_commit, git_commit, &rugged_object_type, their_commit);
error = git_merge_commits(&index, repo, our_commit, their_commit, &opts);
if (error == GIT_EMERGECONFLICT)
return Qnil;
rugged_exception_check(error);
return rugged_index_new(rb_cRuggedIndex, self, index);
}
|