Skip to content

Commit

Permalink
creds: gracefully handle lack of askpass helper
Browse files Browse the repository at this point in the history
If SSH_ASKPASS is unset on Windows, it's possible that the invocation of
cygpath -w can fail, since we'd pass it an empty string, which it
doesn't like.  Let's fix this by first checking for an empty string and
only if it is not empty, passing it to cygpath.
  • Loading branch information
bk2204 committed Dec 6, 2021
1 parent 66d4b17 commit e03b2b1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions creds/creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ func NewCredentialHelperContext(gitEnv config.Environment, osEnv config.Environm
if !ok {
askpass, _ = osEnv.Get("SSH_ASKPASS")
}
askpassfile, err := tools.TranslateCygwinPath(askpass)
if err != nil {
tracerx.Printf("Error reading askpass helper %q: %v", askpassfile, err)
}
if len(askpassfile) > 0 {
c.askpassCredHelper = &AskPassCredentialHelper{
Program: askpassfile,
if len(askpass) > 0 {
askpassfile, err := tools.TranslateCygwinPath(askpass)
if err != nil {
tracerx.Printf("Error reading askpass helper %q: %v", askpassfile, err)
}
if len(askpassfile) > 0 {
c.askpassCredHelper = &AskPassCredentialHelper{
Program: askpassfile,
}
}
}

Expand Down

0 comments on commit e03b2b1

Please sign in to comment.