Skip to content

Commit

Permalink
contrib/git-credential-gnome-keyring.c: use glib messaging functions
Browse files Browse the repository at this point in the history
Rather than roll our own, let's use the messaging functions provided
by glib.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Brandon Casey authored and Junio C Hamano committed Oct 16, 2013
1 parent 68a65f5 commit 3006297
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <glib.h>
#include <gnome-keyring.h>
Expand Down Expand Up @@ -58,30 +57,6 @@ struct credential_operation
#define CREDENTIAL_OP_END \
{ NULL,NULL }

/* ---------------- common helper functions ----------------- */

static inline void warning(const char *fmt, ...)
{
va_list ap;

va_start(ap, fmt);
fprintf(stderr, "warning: ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n" );
va_end(ap);
}

static inline void error(const char *fmt, ...)
{
va_list ap;

va_start(ap, fmt);
fprintf(stderr, "error: ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n" );
va_end(ap);
}

/* ----------------- GNOME Keyring functions ----------------- */

/* create a special keyring option string, if path is given */
Expand Down Expand Up @@ -127,7 +102,7 @@ static int keyring_get(struct credential *c)
return EXIT_SUCCESS;

if (result != GNOME_KEYRING_RESULT_OK) {
error("%s",gnome_keyring_result_to_message(result));
g_critical("%s", gnome_keyring_result_to_message(result));
return EXIT_FAILURE;
}

Expand Down Expand Up @@ -220,7 +195,7 @@ static int keyring_erase(struct credential *c)

if (result != GNOME_KEYRING_RESULT_OK)
{
error("%s",gnome_keyring_result_to_message(result));
g_critical("%s", gnome_keyring_result_to_message(result));
return EXIT_FAILURE;
}

Expand All @@ -234,7 +209,7 @@ static int keyring_erase(struct credential *c)

if (result != GNOME_KEYRING_RESULT_OK)
{
error("%s",gnome_keyring_result_to_message(result));
g_critical("%s", gnome_keyring_result_to_message(result));
return EXIT_FAILURE;
}

Expand Down Expand Up @@ -292,7 +267,7 @@ static int credential_read(struct credential *c)

value = strchr(buf,'=');
if (!value) {
warning("invalid credential line: %s", key);
g_warning("invalid credential line: %s", key);
gnome_keyring_memory_free(buf);
return -1;
}
Expand Down

0 comments on commit 3006297

Please sign in to comment.