Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings: Expose GIT_OPT_SET_OWNER_VALIDATION option #971

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ext/rugged/rugged_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down
17 changes: 17 additions & 0 deletions test/lib_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down