-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maintenance locks and interactivity #598
Changes from all commits
1eae5bd
979bd6f
1fe1292
a18c320
e5459ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
#include "strbuf.h" | ||
#include "urlmatch.h" | ||
#include "git-compat-util.h" | ||
#include "trace2.h" | ||
#include "repository.h" | ||
|
||
void credential_init(struct credential *c) | ||
{ | ||
|
@@ -196,14 +198,36 @@ static char *credential_ask_one(const char *what, struct credential *c, | |
return xstrdup(r); | ||
} | ||
|
||
static void credential_getpass(struct credential *c) | ||
static int credential_getpass(struct credential *c) | ||
{ | ||
int interactive; | ||
char *value; | ||
if (!git_config_get_maybe_bool("credential.interactive", &interactive) && | ||
!interactive) { | ||
trace2_data_intmax("credential", the_repository, | ||
"interactive/skipped", 1); | ||
return -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to trace the fact that the interactive credential prompt was skipped? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting idea. I was thinking that the lack of the other region would be enough. Do you propose using a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could do something like a trace2_data_intmax(... "credential", "interactive/skipped", 1) only log the true case. |
||
} | ||
if (!git_config_get_string("credential.interactive", &value)) { | ||
int same = !strcmp(value, "never"); | ||
free(value); | ||
if (same) { | ||
trace2_data_intmax("credential", the_repository, | ||
"interactive/skipped", 1); | ||
return -1; | ||
} | ||
} | ||
|
||
trace2_region_enter("credential", "interactive", the_repository); | ||
if (!c->username) | ||
c->username = credential_ask_one("Username", c, | ||
PROMPT_ASKPASS|PROMPT_ECHO); | ||
if (!c->password) | ||
c->password = credential_ask_one("Password", c, | ||
PROMPT_ASKPASS); | ||
trace2_region_leave("credential", "interactive", the_repository); | ||
|
||
return 0; | ||
} | ||
|
||
int credential_read(struct credential *c, FILE *fp) | ||
|
@@ -381,8 +405,8 @@ void credential_fill(struct credential *c) | |
c->helpers.items[i].string); | ||
} | ||
|
||
credential_getpass(c); | ||
if (!c->username && !c->password) | ||
if (credential_getpass(c) || | ||
(!c->username && !c->password)) | ||
die("unable to get password from user"); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit. As an alternative to defining a static string here, you could #define a macro and use that in each of the fprintf() format strings below (like we do for the
PRIuMAX
orPRItime
strings).