contrib/git-credential-gnome-keyring.c: small stylistic cleanups
Signed-off-by: John Szakmeister <john@szakmeister.net> Signed-off-by: Junio C Hamano <gitster@pobox.com> Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
parent
a155a5f075
commit
0162b3c430
@ -130,8 +130,7 @@ static GnomeKeyringResult gnome_keyring_item_delete_sync(const char *keyring, gu
|
|||||||
/*
|
/*
|
||||||
* This credential struct and API is simplified from git's credential.{h,c}
|
* This credential struct and API is simplified from git's credential.{h,c}
|
||||||
*/
|
*/
|
||||||
struct credential
|
struct credential {
|
||||||
{
|
|
||||||
char *protocol;
|
char *protocol;
|
||||||
char *host;
|
char *host;
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
@ -140,19 +139,16 @@ struct credential
|
|||||||
char *password;
|
char *password;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CREDENTIAL_INIT \
|
#define CREDENTIAL_INIT { NULL, NULL, 0, NULL, NULL, NULL }
|
||||||
{ NULL,NULL,0,NULL,NULL,NULL }
|
|
||||||
|
|
||||||
typedef int (*credential_op_cb)(struct credential *);
|
typedef int (*credential_op_cb)(struct credential *);
|
||||||
|
|
||||||
struct credential_operation
|
struct credential_operation {
|
||||||
{
|
|
||||||
char *name;
|
char *name;
|
||||||
credential_op_cb op;
|
credential_op_cb op;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CREDENTIAL_OP_END \
|
#define CREDENTIAL_OP_END { NULL, NULL }
|
||||||
{ NULL,NULL }
|
|
||||||
|
|
||||||
/* ----------------- GNOME Keyring functions ----------------- */
|
/* ----------------- GNOME Keyring functions ----------------- */
|
||||||
|
|
||||||
@ -298,8 +294,7 @@ static int keyring_erase(struct credential *c)
|
|||||||
if (result == GNOME_KEYRING_RESULT_CANCELLED)
|
if (result == GNOME_KEYRING_RESULT_CANCELLED)
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
if (result != GNOME_KEYRING_RESULT_OK)
|
if (result != GNOME_KEYRING_RESULT_OK) {
|
||||||
{
|
|
||||||
g_critical("%s", gnome_keyring_result_to_message(result));
|
g_critical("%s", gnome_keyring_result_to_message(result));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@ -312,8 +307,7 @@ static int keyring_erase(struct credential *c)
|
|||||||
|
|
||||||
gnome_keyring_network_password_list_free(entries);
|
gnome_keyring_network_password_list_free(entries);
|
||||||
|
|
||||||
if (result != GNOME_KEYRING_RESULT_OK)
|
if (result != GNOME_KEYRING_RESULT_OK) {
|
||||||
{
|
|
||||||
g_critical("%s", gnome_keyring_result_to_message(result));
|
g_critical("%s", gnome_keyring_result_to_message(result));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@ -325,8 +319,7 @@ static int keyring_erase(struct credential *c)
|
|||||||
* Table with helper operation callbacks, used by generic
|
* Table with helper operation callbacks, used by generic
|
||||||
* credential helper main function.
|
* credential helper main function.
|
||||||
*/
|
*/
|
||||||
static struct credential_operation const credential_helper_ops[] =
|
static struct credential_operation const credential_helper_ops[] = {
|
||||||
{
|
|
||||||
{ "get", keyring_get },
|
{ "get", keyring_get },
|
||||||
{ "store", keyring_store },
|
{ "store", keyring_store },
|
||||||
{ "erase", keyring_erase },
|
{ "erase", keyring_erase },
|
||||||
@ -360,8 +353,7 @@ static int credential_read(struct credential *c)
|
|||||||
|
|
||||||
key = buf = gnome_keyring_memory_alloc(1024);
|
key = buf = gnome_keyring_memory_alloc(1024);
|
||||||
|
|
||||||
while (fgets(buf, 1024, stdin))
|
while (fgets(buf, 1024, stdin)) {
|
||||||
{
|
|
||||||
line_len = strlen(buf);
|
line_len = strlen(buf);
|
||||||
|
|
||||||
if (line_len && buf[line_len-1] == '\n')
|
if (line_len && buf[line_len-1] == '\n')
|
||||||
@ -398,7 +390,8 @@ static int credential_read(struct credential *c)
|
|||||||
} else if (!strcmp(key, "password")) {
|
} else if (!strcmp(key, "password")) {
|
||||||
gnome_keyring_memory_free(c->password);
|
gnome_keyring_memory_free(c->password);
|
||||||
c->password = gnome_keyring_memory_strdup(value);
|
c->password = gnome_keyring_memory_strdup(value);
|
||||||
while (*value) *value++ = '\0';
|
while (*value)
|
||||||
|
*value++ = '\0';
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Ignore other lines; we don't know what they mean, but
|
* Ignore other lines; we don't know what they mean, but
|
||||||
|
Loading…
Reference in New Issue
Block a user