summaryrefslogtreecommitdiff
path: root/fsck.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2015-06-22 15:25:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-06-23 21:27:35 (GMT)
commit71ab8fa840fcca4b4f80acba6a529e3cbc174b65 (patch)
tree1d55b99408581d28068c89433e6b72f4b7a57fda /fsck.c
parent5d477a334a68698709f07ebda4999c10997ef6f7 (diff)
downloadgit-71ab8fa840fcca4b4f80acba6a529e3cbc174b65.zip
git-71ab8fa840fcca4b4f80acba6a529e3cbc174b65.tar.gz
git-71ab8fa840fcca4b4f80acba6a529e3cbc174b65.tar.bz2
fsck: report the ID of the error/warning
Some repositories written by legacy code have objects with non-fatal fsck issues. To allow the user to ignore those issues, let's print out the ID (e.g. when encountering "missingEmail", the user might want to call `git config --add receive.fsck.missingEmail=warn`). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fsck.c')
-rw-r--r--fsck.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/fsck.c b/fsck.c
index e6e8dc4..4748f1e 100644
--- a/fsck.c
+++ b/fsck.c
@@ -189,6 +189,24 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values)
free(to_free);
}
+static void append_msg_id(struct strbuf *sb, const char *msg_id)
+{
+ for (;;) {
+ char c = *(msg_id)++;
+
+ if (!c)
+ break;
+ if (c != '_')
+ strbuf_addch(sb, tolower(c));
+ else {
+ assert(*msg_id);
+ strbuf_addch(sb, *(msg_id)++);
+ }
+ }
+
+ strbuf_addstr(sb, ": ");
+}
+
__attribute__((format (printf, 4, 5)))
static int report(struct fsck_options *options, struct object *object,
enum fsck_msg_id id, const char *fmt, ...)
@@ -197,6 +215,8 @@ static int report(struct fsck_options *options, struct object *object,
struct strbuf sb = STRBUF_INIT;
int msg_type = fsck_msg_type(id, options), result;
+ append_msg_id(&sb, msg_id_info[id].id_string);
+
va_start(ap, fmt);
strbuf_vaddf(&sb, fmt, ap);
result = options->error_func(object, msg_type, sb.buf);