Skip to content

Commit 0f2a646

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 a4fbb6b commit 0f2a646

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/git/lib.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,15 @@ def show(objectish=nil, path=nil)
501501
## WRITE COMMANDS ##
502502

503503
def config_set(name, value)
504-
command('config', [name, value])
504+
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)