From f7faab353e876ac194a309b2edbee2aac0b24e09 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Tue, 11 Jun 2019 12:46:41 +0200 Subject: [PATCH] git util: fix Get/SetConfig error reporting --- internal/util/git.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/internal/util/git.go b/internal/util/git.go index a3b610a..0be9ecd 100644 --- a/internal/util/git.go +++ b/internal/util/git.go @@ -154,10 +154,12 @@ func (g *Git) ConfigGet(ctx context.Context, args ...string) (string, error) { args = append([]string{"config", "--get", "--null"}, args...) out, err := g.Output(ctx, nil, args...) - if exitError, ok := err.(*exec.ExitError); ok { - if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { - if waitStatus.ExitStatus() == 1 { - return "", &ErrGitKeyNotFound{Key: args[len(args)-1]} + if err != nil { + if exitError, ok := err.(*exec.ExitError); ok { + if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { + if waitStatus.ExitStatus() == 1 { + return "", &ErrGitKeyNotFound{Key: args[len(args)-1]} + } } } return "", err @@ -170,10 +172,12 @@ func (g *Git) ConfigSet(ctx context.Context, args ...string) (string, error) { args = append([]string{"config", "--null"}, args...) out, err := g.Output(ctx, nil, args...) - if exitError, ok := err.(*exec.ExitError); ok { - if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { - if waitStatus.ExitStatus() == 1 { - return "", &ErrGitKeyNotFound{Key: args[len(args)-1]} + if err != nil { + if exitError, ok := err.(*exec.ExitError); ok { + if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); ok { + if waitStatus.ExitStatus() == 1 { + return "", &ErrGitKeyNotFound{Key: args[len(args)-1]} + } } } return "", err