contrib/git-credential-gnome-keyring.c: report failure to store password

Produce an error message when we fail to store a password to the keyring. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Casey committed Sep 23, 2013 at 11:49 UTC 81c57e2c9d99ced72bcc6b9633109dff73a04526
1 file changed +9 -1
contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
+9 -1
@@ -125,6 +125,7 @@ static int keyring_store(struct credential *c)
125 {
126 guint32 item_id;
127 char *object = NULL;
128 + GnomeKeyringResult result;
129
130 /*
131 * Sanity check that what we are storing is actually sensible.
@@ -139,7 +140,7 @@ static int keyring_store(struct credential *c)
140
141 object = keyring_object(c);
142
142 - gnome_keyring_set_network_password_sync(
143 + result = gnome_keyring_set_network_password_sync(
144 GNOME_KEYRING_DEFAULT,
145 c->username,
146 NULL /* domain */,
@@ -152,6 +153,13 @@ static int keyring_store(struct credential *c)
153 &item_id);
154
155 g_free(object);
156 +
157 + if (result != GNOME_KEYRING_RESULT_OK &&
158 + result != GNOME_KEYRING_RESULT_CANCELLED) {
159 + g_critical("%s", gnome_keyring_result_to_message(result));
160 + return EXIT_FAILURE;
161 + }
162 +
163 return EXIT_SUCCESS;
164 }
165