Skip to content

Commit 1ac6ce3

Browse files
mpapisMichal Papis
authored and
Michal Papis
committed
Allow creating new config entries
Git 2.1.2 introduced setting values even if they did not previously exist. The git-ruby library keeps compatibility with Git 1.6, this fixes the problem of older versions not being able to create new values. Signed-off-by: Michal Papis <michal.papis@toptal.com>
1 parent 9bd4407 commit 1ac6ce3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/git/lib.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,14 @@ def show(objectish=nil, path=nil)
502502

503503
def config_set(name, value)
504504
command('config', [name, value])
505+
rescue Git::GitExecuteError
506+
command('config', ['--add', name, value])
505507
end
506508

507509
def global_config_set(name, value)
508510
command('config', ['--global', name, value], false)
511+
rescue Git::GitExecuteError
512+
command('config', ['--global', '--add', name, value], false)
509513
end
510514

511515
# updates the repository index using the working directory content

0 commit comments

Comments
 (0)