@@ -151,38 +151,16 @@ git_config_global_set <- function(name, value, add = FALSE) {
151151# ' @export
152152# ' @rdname git_config
153153# ' @useDynLib gert R_git_config_unset
154- # ' @param pattern Regular expression matching values to unset. Note: the regular
155- # ' expressions engine used depends on the libgit2 installation; you can check
156- # ' this using `libgit2_config()$regex_backend`
157- # ' (`"`\code{\Sexpr[stage=render,results=rd]{gert::libgit2_config()$regex_backend}}`"`
158- # ' for this installation).
159- # ' @param fixed If `TRUE`, only unset values that match `pattern` entirely and
160- # ' as-is.
161- git_config_unset <- function (name , pattern , fixed = FALSE , repo = ' .' )
162- {
163- git_config_unset_impl(
164- name , pattern , fixed , git_open(repo ),
165- function () git_config_local_get(name , repo = repo )
166- )
154+ # ' @param pattern optional regular expression, for matching values to unset in
155+ # ' case of multiple values
156+ git_config_unset <- function (name , pattern = NULL , repo = ' .' ){
157+ .Call(R_git_config_unset , git_open(repo ), name , pattern )
167158}
168159
169160# ' @export
170161# ' @rdname git_config
171- git_config_global_unset <- function (name , pattern , fixed = FALSE )
172- {
173- git_config_unset_impl(
174- name , pattern , fixed , NULL ,
175- function () git_config_global_get(name )
176- )
177- }
178-
179- git_config_unset_impl <- function (name , pattern , fixed , repo , get_val_cb ) {
180- if (fixed ) pattern <- fixed_regex(pattern )
181- prev <- (get_val_cb )()
182- .Call(R_git_config_unset , repo , name , pattern )
183- post <- (get_val_cb )()
184- out <- setdiff(prev , post )
185- invisible (out )
162+ git_config_global_unset <- function (name , pattern = NULL ){
163+ .Call(R_git_config_unset , NULL , name , pattern )
186164}
187165
188166# ' Show libgit2 version and capabilities
@@ -200,15 +178,6 @@ libgit2_config <- function() {
200178 res
201179}
202180
203- # helper used in git_config_unset()
204- fixed_regex <- function (string ) {
205- metachars <- c(" ." , " \\ " , " |" , " (" , " )" , " [" , " ]" , " {" , " }" , " ^" , " $" , " *" , " +" , " ?" )
206- for (metachar in metachars ) {
207- string <- gsub(metachar , paste0(" \\ " , metachar ), string , fixed = TRUE )
208- }
209- paste0(" ^" , string , " $" )
210- }
211-
212181# helpers used in tests
213182configure_local_user <- function (repo = " ." ) {
214183 git_config_set(' user.name' , " Jerry Johnson" , repo = repo )
0 commit comments