From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Jeff King" <peff@peff.net>,
"Eric Sunshine" <sunshine@sunshineco.com>,
git@vger.kernel.org, "SZEDER Gábor" <szeder@ira.uka.de>
Subject: [PATCH v2] Make error message after failing commit_lock_file() less confusing
Date: Thu, 3 Dec 2015 11:31:27 +0100 [thread overview]
Message-ID: <1449138687-23675-1-git-send-email-szeder@ira.uka.de> (raw)
In-Reply-To: <20151203113034.Horde.-yFsRNWlpgbiVEym_u1l1wY@webmail.informatik.kit.edu>
The error message after a failing commit_lock_file() call sometimes
looks like this, causing confusion:
$ git remote add remote git@server.com/repo.git
error: could not commit config file .git/config
# Huh?!
# I didn't want to commit anything, especially not my config file!
While in the narrow context of the lockfile module using the verb
'commit' in the error message makes perfect sense, in the broader
context of git the word 'commit' already has a very specific meaning,
hence the confusion.
Reword these error messages to say "could not write" instead of "could
not commit".
While at it, include strerror in the error messages after writing the
config file fails, to provide some information about the cause of the
failure, and update the style of the error message after writing the
reflog fails, to match surrounding error messages (i.e. no '' around
the pathname and no () around the error description).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
Notes:
Changes since v1:
* Don't pass strerror() to die_errno().
config.c | 6 ++++--
credential-store.c | 2 +-
fast-import.c | 2 +-
refs.c | 2 +-
4 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/config.c b/config.c
index 248a21ab94..86a5eb2571 100644
--- a/config.c
+++ b/config.c
@@ -2144,7 +2144,8 @@ int git_config_set_multivar_in_file(const char *config_filename,
}
if (commit_lock_file(lock) < 0) {
- error("could not commit config file %s", config_filename);
+ error("could not write config file %s: %s", config_filename,
+ strerror(errno));
ret = CONFIG_NO_WRITE;
lock = NULL;
goto out_free;
@@ -2330,7 +2331,8 @@ int git_config_rename_section_in_file(const char *config_filename,
fclose(config_file);
unlock_and_out:
if (commit_lock_file(lock) < 0)
- ret = error("could not commit config file %s", config_filename);
+ ret = error("could not write config file %s: %s",
+ config_filename, strerror(errno));
out:
free(filename_buf);
return ret;
diff --git a/credential-store.c b/credential-store.c
index 00aea3aa30..54c4e04737 100644
--- a/credential-store.c
+++ b/credential-store.c
@@ -64,7 +64,7 @@ static void rewrite_credential_file(const char *fn, struct credential *c,
print_line(extra);
parse_credential_file(fn, c, NULL, print_line);
if (commit_lock_file(&credential_lock) < 0)
- die_errno("unable to commit credential store");
+ die_errno("unable to write credential store");
}
static void store_credential_file(const char *fn, struct credential *c)
diff --git a/fast-import.c b/fast-import.c
index e3b421d514..3c65edb5c4 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1824,7 +1824,7 @@ static void dump_marks(void)
dump_marks_helper(f, 0, marks);
if (commit_lock_file(&mark_lock)) {
- failure |= error("Unable to commit marks file %s: %s",
+ failure |= error("Unable to write file %s: %s",
export_marks_file, strerror(errno));
return;
}
diff --git a/refs.c b/refs.c
index 132eff52ca..b1c7b229b7 100644
--- a/refs.c
+++ b/refs.c
@@ -4684,7 +4684,7 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
get_lock_file_path(lock->lk));
rollback_lock_file(&reflog_lock);
} else if (commit_lock_file(&reflog_lock)) {
- status |= error("unable to commit reflog '%s' (%s)",
+ status |= error("unable to write reflog %s: %s",
log_file, strerror(errno));
} else if (update && commit_ref(lock)) {
status |= error("couldn't set %s", lock->ref_name);
--
2.6.3.420.g7bbb372
next prev parent reply other threads:[~2015-12-03 10:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-30 11:40 [PATCH] Make error message after failing commit_lock_file() less confusing SZEDER Gábor
2015-12-01 23:17 ` Jeff King
2015-12-02 2:19 ` Junio C Hamano
2015-12-02 4:28 ` Eric Sunshine
2015-12-03 10:30 ` SZEDER Gábor
2015-12-03 10:31 ` SZEDER Gábor [this message]
2015-12-16 11:22 ` [PATCH] credential-store: don't pass strerror to die_errno() SZEDER Gábor
2015-12-16 18:20 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1449138687-23675-1-git-send-email-szeder@ira.uka.de \
--to=szeder@ira.uka.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).