Skip to content

Commit a7ff63d

Browse files
committed
Fix Index#merge_file with custom labels
Previously this required that the custom labels (for ours, theirs, and ancestor) were fixnums instead of strings, which contradicts the docs.
1 parent b26e290 commit a7ff63d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

ext/rugged/rugged_index.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,19 +960,19 @@ void rugged_parse_merge_file_options(git_merge_file_options *opts, VALUE rb_opti
960960

961961
rb_value = rb_hash_aref(rb_options, CSTR2SYM("ancestor_label"));
962962
if (!NIL_P(rb_value)) {
963-
Check_Type(rb_value, T_FIXNUM);
963+
Check_Type(rb_value, T_STRING);
964964
opts->ancestor_label = StringValueCStr(rb_value);
965965
}
966966

967967
rb_value = rb_hash_aref(rb_options, CSTR2SYM("our_label"));
968968
if (!NIL_P(rb_value)) {
969-
Check_Type(rb_value, T_FIXNUM);
969+
Check_Type(rb_value, T_STRING);
970970
opts->our_label = StringValueCStr(rb_value);
971971
}
972972

973973
rb_value = rb_hash_aref(rb_options, CSTR2SYM("their_label"));
974974
if (!NIL_P(rb_value)) {
975-
Check_Type(rb_value, T_FIXNUM);
975+
Check_Type(rb_value, T_STRING);
976976
opts->their_label = StringValueCStr(rb_value);
977977
}
978978

test/index_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,13 @@ def test_merge_file
282282
assert_equal merge_file_result[:data], "<<<<<<< conflicts-one.txt\nThis is most certainly a conflict!\n=======\nThis is a conflict!!!\n>>>>>>> conflicts-one.txt\n"
283283
end
284284

285+
def test_merge_file_with_labels
286+
merge_file_result = @repo.index.merge_file("conflicts-one.txt", our_label: "ours", their_label: "theirs")
287+
288+
assert !merge_file_result[:automergeable]
289+
assert_equal merge_file_result[:path], "conflicts-one.txt"
290+
assert_equal merge_file_result[:data], "<<<<<<< ours\nThis is most certainly a conflict!\n=======\nThis is a conflict!!!\n>>>>>>> theirs\n"
291+
end
285292
end
286293

287294
class IndexRepositoryTest < Rugged::TestCase

0 commit comments

Comments
 (0)