summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ba002f3)
raw | patch | inline | side by side (parent: ba002f3)
author | Martin Koegler <mkoegler@auto.tuwien.ac.at> | |
Mon, 25 Feb 2008 21:46:09 +0000 (22:46 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 26 Feb 2008 07:57:35 +0000 (23:57 -0800) |
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fsck.c | patch | blob | history | |
fsck.h | patch | blob | history |
index 06808621517fe7134893018dff66a4295716780e..6883d1bd68d158290acb18ae9b4e8baba7525201 100644 (file)
--- a/fsck.c
+++ b/fsck.c
return error_func(obj, FSCK_ERROR, "unknown type '%d' (internal fsck error)",
obj->type);
}
+
+int fsck_error_function(struct object *obj, int type, const char *fmt, ...)
+{
+ va_list ap;
+ int len;
+ struct strbuf sb;
+
+ strbuf_init(&sb, 0);
+ strbuf_addf(&sb, "object %s:", obj->sha1?sha1_to_hex(obj->sha1):"(null)");
+
+ va_start(ap, fmt);
+ len = vsnprintf(sb.buf + sb.len, strbuf_avail(&sb), fmt, ap);
+ va_end(ap);
+
+ if (len < 0)
+ len = 0;
+ if (len >= strbuf_avail(&sb)) {
+ strbuf_grow(&sb, len + 2);
+ va_start(ap, fmt);
+ len = vsnprintf(sb.buf + sb.len, strbuf_avail(&sb), fmt, ap);
+ va_end(ap);
+ if (len >= strbuf_avail(&sb))
+ die("this should not happen, your snprintf is broken");
+ }
+
+ error(sb.buf);
+ strbuf_release(&sb);
+ return 1;
+}
index 9bd37c9f1cabb0c9ffb404e1f0f846b5123638e5..990ee02335a2e2693e32baa82b259c23843f2aa0 100644 (file)
--- a/fsck.h
+++ b/fsck.h
/* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */
typedef int (*fsck_error)(struct object *obj, int type, const char *err, ...);
+int fsck_error_function(struct object *obj, int type, const char *fmt, ...);
+
/* descend in all linked child objects
* the return value is:
* -1 error in processing the object