apply: make some parsing functions static again
[gitweb.git] / fsck.c
diff --git a/fsck.c b/fsck.c
index 6ed90ec15edceb40c7e9ba5c8646d6e36052a4fe..c9cf3de8d315c05cd238529ba20fe3925c993ec1 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -291,7 +291,7 @@ static int report(struct fsck_options *options, struct object *object,
 
        va_start(ap, fmt);
        strbuf_vaddf(&sb, fmt, ap);
-       result = options->error_func(object, msg_type, sb.buf);
+       result = options->error_func(options, object, msg_type, sb.buf);
        strbuf_release(&sb);
        va_end(ap);
 
@@ -323,6 +323,19 @@ static void put_object_name(struct fsck_options *options, struct object *obj,
        va_end(ap);
 }
 
+static const char *describe_object(struct fsck_options *o, struct object *obj)
+{
+       static struct strbuf buf = STRBUF_INIT;
+       char *name;
+
+       strbuf_reset(&buf);
+       strbuf_addstr(&buf, oid_to_hex(&obj->oid));
+       if (o->object_names && (name = lookup_decoration(o->object_names, obj)))
+               strbuf_addf(&buf, " (%s)", name);
+
+       return buf.buf;
+}
+
 static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *options)
 {
        struct tree_desc desc;
@@ -358,7 +371,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
                }
                else {
                        result = error("in tree %s: entry %s has bad mode %.6o",
-                                       oid_to_hex(&tree->object.oid), entry.path, entry.mode);
+                                       describe_object(options, &tree->object), entry.path, entry.mode);
                }
                if (result < 0)
                        return result;
@@ -454,7 +467,7 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options)
        case OBJ_TAG:
                return fsck_walk_tag((struct tag *)obj, data, options);
        default:
-               error("Unknown object type for %s", oid_to_hex(&obj->oid));
+               error("Unknown object type for %s", describe_object(options, obj));
                return -1;
        }
 }
@@ -897,12 +910,13 @@ int fsck_object(struct object *obj, void *data, unsigned long size,
                          obj->type);
 }
 
-int fsck_error_function(struct object *obj, int msg_type, const char *message)
+int fsck_error_function(struct fsck_options *o,
+       struct object *obj, int msg_type, const char *message)
 {
        if (msg_type == FSCK_WARN) {
-               warning("object %s: %s", oid_to_hex(&obj->oid), message);
+               warning("object %s: %s", describe_object(o, obj), message);
                return 0;
        }
-       error("object %s: %s", oid_to_hex(&obj->oid), message);
+       error("object %s: %s", describe_object(o, obj), message);
        return 1;
 }