[PATCH 06/18] fsck: report the ID of the error/warning
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Dec 8, 2014, 16:14 UTC
- Message-ID
- <2bc462ca50abdc07a89d1a8c58ac1633748b3b91.1418055173.git.johannes.schindelin@gmx.de>
- In-Reply-To
- <cover.1418055173.git.johannes.schindelin@gmx.de>
Some legacy code has objects with non-fatal fsck issues; To enable the user to ignore those issues, let's print out the ID (e.g. when encountering "missing-email", the user might want to call `git config receive.fsck.missing-email warn`).
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- fsck.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/fsck.c b/fsck.c index 9e6d70f..ff50a87 100644 --- a/fsck.c +++ b/fsck.c @@ -154,6 +154,23 @@ void fsck_strict_mode(struct fsck_options *options, const char *mode) } } +static void append_msg_id(struct strbuf *sb, const char *msg_id) +{ + for (;;) { + char c = *(msg_id)++; + + if (!c) + break; + if (c == '_') + c = '-'; + else + c = tolower(c); + strbuf_addch(sb, c); + } + + 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, ...) @@ -162,6 +179,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_str[id]); + va_start(ap, fmt); strbuf_vaddf(&sb, fmt, ap); result = options->error_func(object, msg_type, sb.buf);
-- 2.0.0.rc3.9669.g840d1f9