Skip to content

Commit eee455b

Browse files
philip-petersonGiteaBot
authored andcommitted
Pass --global when calling git config --get, for consistency with git config --set (go-gitea#23157)
This arose out of go-gitea#22451; it seems we are checking using non-global settings to see if a config value is set, in order to decide whether to call another global(-indeed) configuration command. This PR changes it so that both the check and the set are for global configuration.
1 parent 35a3b45 commit eee455b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

modules/git/git.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func CheckGitVersionAtLeast(atLeast string) error {
313313
}
314314

315315
func configSet(key, value string) error {
316-
stdout, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key).RunStdString(nil)
316+
stdout, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
317317
if err != nil && !err.IsExitCode(1) {
318318
return fmt.Errorf("failed to get git config %s, err: %w", key, err)
319319
}
@@ -332,7 +332,7 @@ func configSet(key, value string) error {
332332
}
333333

334334
func configSetNonExist(key, value string) error {
335-
_, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key).RunStdString(nil)
335+
_, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
336336
if err == nil {
337337
// already exist
338338
return nil
@@ -350,7 +350,7 @@ func configSetNonExist(key, value string) error {
350350
}
351351

352352
func configAddNonExist(key, value string) error {
353-
_, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil)
353+
_, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil)
354354
if err == nil {
355355
// already exist
356356
return nil
@@ -367,7 +367,7 @@ func configAddNonExist(key, value string) error {
367367
}
368368

369369
func configUnsetAll(key, value string) error {
370-
_, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key).RunStdString(nil)
370+
_, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
371371
if err == nil {
372372
// exist, need to remove
373373
_, _, err = NewCommand(DefaultContext, "config", "--global", "--unset-all").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil)

0 commit comments

Comments
 (0)