Skip to content

Commit 481b46d

Browse files
authored
Merge pull request #971 from alexjfisher/owner_validation
settings: Expose GIT_OPT_SET_OWNER_VALIDATION option
2 parents 7a2e703 + cd1debe commit 481b46d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

ext/rugged/rugged_settings.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ static VALUE rb_git_set_option(VALUE self, VALUE option, VALUE value)
9191
git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, fsync);
9292
}
9393

94+
else if (strcmp(opt, "owner_validation") == 0) {
95+
int validation = RTEST(value) ? 1 : 0;
96+
git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, validation);
97+
}
98+
9499
else {
95100
rb_raise(rb_eArgError, "Unknown option specified");
96101
}
@@ -135,6 +140,12 @@ static VALUE rb_git_get_option(VALUE self, VALUE option)
135140
return get_search_path(GIT_CONFIG_LEVEL_SYSTEM);
136141
}
137142

143+
else if (strcmp(opt, "owner_validation") == 0) {
144+
int validation;
145+
git_libgit2_opts(GIT_OPT_GET_OWNER_VALIDATION, &validation);
146+
return validation ? Qtrue : Qfalse;
147+
}
148+
138149
else {
139150
rb_raise(rb_eArgError, "Unknown option specified");
140151
}

test/lib_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ def test_fsync_gitdir
3737
Rugged::Settings['fsync_gitdir'] = false
3838
end
3939

40+
def test_owner_validation
41+
before = Rugged::Settings['owner_validation']
42+
43+
begin
44+
Rugged::Settings['owner_validation'] = false
45+
assert_equal(false, Rugged::Settings['owner_validation'])
46+
47+
Rugged::Settings['owner_validation'] = true
48+
assert_equal(true, Rugged::Settings['owner_validation'])
49+
50+
Rugged::Settings['owner_validation'] = false
51+
assert_equal(false, Rugged::Settings['owner_validation'])
52+
ensure
53+
Rugged::Settings['owner_validation'] = before
54+
end
55+
end
56+
4057
def test_search_path
4158
paths = [['search_path_global', '/tmp/global'],
4259
['search_path_xdg', '/tmp/xdg'],

0 commit comments

Comments
 (0)