@@ -119,14 +119,19 @@ git_config_global_get <- function(name) {
119119# ' @param add if `TRUE`, append a new entry for `name` instead of replacing
120120# ' existing one(s). Equivalent to `git config --add`. Only supported for
121121# ' string values.
122- git_config_set <- function (name , value , add = FALSE , repo = ' .' ) {
123- if (! is.logical(add ) || length(add ) != 1 ) {
124- stop(" Argument add must be a logical of length 1." , call. = FALSE )
125- }
122+ # ' @param unset if `TRUE`, delete all entries for `name` matching the regular
123+ # ' expression `value`, equivalent `git config --unset`. If `TRUE` and
124+ # ' `value == NULL`, delete all entries for `name`, equivalent to
125+ # ' `git config --unset-all`.
126+ git_config_set <- function (
127+ name , value ,
128+ add = FALSE , unset = FALSE ,
129+ repo = ' .'
130+ ) {
126131 repo <- git_open(repo )
127132 name <- as.character(name )
128133 out <- git_config_local_get(name , repo = repo )
129- .Call( R_git_config_set , repo , name , value , add )
134+ git_config_set_impl( name , value , repo , add , unset )
130135 if (length(out ) > 0 ) {
131136 invisible (out )
132137 } else {
@@ -136,16 +141,30 @@ git_config_set <- function(name, value, add = FALSE, repo = '.') {
136141
137142# ' @export
138143# ' @rdname git_config
139- git_config_global_set <- function (name , value , add = FALSE ) {
144+ git_config_global_set <- function (name , value , add = FALSE , unset = FALSE ) {
140145 out <- git_config_global_get(name )
141- .Call( R_git_config_set , NULL , name , value , add )
146+ git_config_set_impl( name , value , repo = NULL , add , unset )
142147 if (length(out ) > 0 ) {
143148 invisible (out )
144149 } else {
145150 invisible (NULL )
146151 }
147152}
148153
154+ git_config_set_impl <- function (name , value , repo , add , unset ) {
155+ if (! is.logical(add ) || length(add ) != 1 ) {
156+ stop(" Argument add must be a logical of length 1." , call. = FALSE )
157+ }
158+ if (! is.logical(unset ) || length(unset ) != 1 ) {
159+ stop(" Argument unset must be a logical of length 1." , call. = FALSE )
160+ }
161+ if (add && unset ) {
162+ stop(" Arguments 'add' and 'unset' cannot both be TRUE." , call. = FALSE )
163+ }
164+ name <- as.character(name )
165+ .Call(R_git_config_set , repo , name , value , add , unset )
166+ }
167+
149168# ' Show libgit2 version and capabilities
150169# '
151170# ' `libgit2_config()` reveals which version of libgit2 gert is using and which
0 commit comments