diff --git a/ext/rugged/rugged_settings.c b/ext/rugged/rugged_settings.c index 2db4e29c4..abab82ded 100644 --- a/ext/rugged/rugged_settings.c +++ b/ext/rugged/rugged_settings.c @@ -91,6 +91,11 @@ static VALUE rb_git_set_option(VALUE self, VALUE option, VALUE value) git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, fsync); } + else if (strcmp(opt, "owner_validation") == 0) { + int validation = RTEST(value) ? 1 : 0; + git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, validation); + } + else { rb_raise(rb_eArgError, "Unknown option specified"); } @@ -135,6 +140,12 @@ static VALUE rb_git_get_option(VALUE self, VALUE option) return get_search_path(GIT_CONFIG_LEVEL_SYSTEM); } + else if (strcmp(opt, "owner_validation") == 0) { + int validation; + git_libgit2_opts(GIT_OPT_GET_OWNER_VALIDATION, &validation); + return validation ? Qtrue : Qfalse; + } + else { rb_raise(rb_eArgError, "Unknown option specified"); } diff --git a/test/lib_test.rb b/test/lib_test.rb index 776eb47c0..34f128cc4 100644 --- a/test/lib_test.rb +++ b/test/lib_test.rb @@ -37,6 +37,23 @@ def test_fsync_gitdir Rugged::Settings['fsync_gitdir'] = false end + def test_owner_validation + before = Rugged::Settings['owner_validation'] + + begin + Rugged::Settings['owner_validation'] = false + assert_equal(false, Rugged::Settings['owner_validation']) + + Rugged::Settings['owner_validation'] = true + assert_equal(true, Rugged::Settings['owner_validation']) + + Rugged::Settings['owner_validation'] = false + assert_equal(false, Rugged::Settings['owner_validation']) + ensure + Rugged::Settings['owner_validation'] = before + end + end + def test_search_path paths = [['search_path_global', '/tmp/global'], ['search_path_xdg', '/tmp/xdg'],