@@ -330,12 +330,12 @@ static int readline(char **out)
330330 return error ;
331331}
332332
333- static int ask (char * * out , const char * prompt )
333+ static int ask (char * * out , const char * prompt , char optional )
334334{
335335 printf ("%s " , prompt );
336336 fflush (stdout );
337337
338- if (!readline (out )) {
338+ if (!readline (out ) && ! optional ) {
339339 fprintf (stderr , "Could not read response: %s" , strerror (errno ));
340340 return -1 ;
341341 }
@@ -359,9 +359,9 @@ int cred_acquire_cb(git_cred **out,
359359 if (allowed_types & GIT_CREDTYPE_SSH_KEY ) {
360360 int n ;
361361
362- if ((error = ask (& username , "Username:" )) < 0 ||
363- (error = ask (& privkey , "SSH Key:" )) < 0 ||
364- (error = ask (& password , "Password:" )) < 0 )
362+ if ((error = ask (& username , "Username:" , 0 )) < 0 ||
363+ (error = ask (& privkey , "SSH Key:" , 0 )) < 0 ||
364+ (error = ask (& password , "Password:" , 1 )) < 0 )
365365 goto out ;
366366
367367 if ((n = snprintf (NULL , 0 , "%s.pub" , privkey )) < 0 ||
@@ -371,13 +371,13 @@ int cred_acquire_cb(git_cred **out,
371371
372372 error = git_cred_ssh_key_new (out , username , pubkey , privkey , password );
373373 } else if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT ) {
374- if ((error = ask (& username , "Username:" )) < 0 ||
375- (error = ask (& password , "Password:" )) < 0 )
374+ if ((error = ask (& username , "Username:" , 0 )) < 0 ||
375+ (error = ask (& password , "Password:" , 1 )) < 0 )
376376 goto out ;
377377
378378 error = git_cred_userpass_plaintext_new (out , username , password );
379379 } else if (allowed_types & GIT_CREDTYPE_USERNAME ) {
380- if ((error = ask (& username , "Username:" )) < 0 )
380+ if ((error = ask (& username , "Username:" , 0 )) < 0 )
381381 goto out ;
382382
383383 error = git_cred_username_new (out , username );
0 commit comments