From c8ef467671b9f24de34b11a9d74cfd5ccf763a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Wed, 17 Jun 2026 07:36:23 +0200 Subject: [PATCH] index: correct the `NIL_P` check when adding clonflicts Thanks to Yuhang Wu from firstdepth for reporting. --- ext/rugged/rugged_index.c | 4 ++-- test/index_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ext/rugged/rugged_index.c b/ext/rugged/rugged_index.c index 17f4e653c..f576514bb 100644 --- a/ext/rugged/rugged_index.c +++ b/ext/rugged/rugged_index.c @@ -784,8 +784,8 @@ static VALUE rb_git_conflict_add(VALUE self, VALUE rb_conflict) error = git_index_conflict_add(index, NIL_P(rb_ancestor) ? NULL : &ancestor, - NIL_P(rb_theirs) ? NULL : &ours, - NIL_P(rb_ours) ? NULL : &theirs); + NIL_P(rb_ours) ? NULL : &ours, + NIL_P(rb_theirs) ? NULL : &theirs); rugged_exception_check(error); return Qnil; diff --git a/test/index_test.rb b/test/index_test.rb index dff6e44a9..518449e4f 100644 --- a/test/index_test.rb +++ b/test/index_test.rb @@ -259,6 +259,14 @@ def test_conflict_add @repo.index.conflict_add(conflict) assert_equal @repo.index.conflicts.size, 4 + + conflict[:ours] = nil + conflict[:theirs][:path] = "yet-another-conflict.txt" + + @repo.index.conflict_add(conflict) + + assert_equal @repo.index.conflicts.size, 5 + end def test_conflict_cleanup