From: Martin Koegler <mkoegler@auto.tuwien.ac.at>
To: git@vger.kernel.org
Cc: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Subject: [PATCH 06/10] add common fsck error printing function
Date: Mon, 25 Feb 2008 22:54:56 +0100 [thread overview]
Message-ID: <12039765001192-git-send-email-mkoegler@auto.tuwien.ac.at> (raw)
In-Reply-To: <12039765002397-git-send-email-mkoegler@auto.tuwien.ac.at>
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
fsck.c | 30 ++++++++++++++++++++++++++++++
fsck.h | 2 ++
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/fsck.c b/fsck.c
index 3ce33ff..a8c24a9 100644
--- a/fsck.c
+++ b/fsck.c
@@ -311,3 +311,33 @@ int fsck_object(struct object *obj, int strict, fsck_error error_func)
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;
+}
diff --git a/fsck.h b/fsck.h
index a5d60d0..188c84b 100644
--- a/fsck.h
+++ b/fsck.h
@@ -17,6 +17,8 @@ typedef int (*fsck_walk_func)(struct object *obj, int type, void *data);
/* 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
--
1.5.4.3.g3c5f
next prev parent reply other threads:[~2008-02-25 21:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-25 21:54 [PATCH 01/10] add generic, type aware object chain walker Martin Koegler
2008-02-25 21:54 ` [PATCH 02/10] builtin-fsck: move away from object-refs to fsck_walk Martin Koegler
2008-02-25 21:54 ` [PATCH 03/10] Remove unused object-ref code Martin Koegler
2008-02-25 21:54 ` [PATCH 04/10] builtin-fsck: reports missing parent commits Martin Koegler
2008-02-25 21:54 ` [PATCH 05/10] builtin-fsck: move common object checking code to fsck.c Martin Koegler
2008-02-25 21:54 ` Martin Koegler [this message]
2008-02-25 21:54 ` [PATCH 07/10] unpack-object: cache for non written objects Martin Koegler
2008-02-25 21:54 ` [PATCH 08/10] unpack-objects: prevent writing of inconsistent objects Martin Koegler
2008-02-25 21:54 ` [PATCH 09/10] index-pack: introduce checking mode Martin Koegler
2008-02-25 21:55 ` [PATCH 10/10] receive-pack: use strict mode for unpacking objects Martin Koegler
2008-02-26 9:19 ` [PATCH 05/10] builtin-fsck: move common object checking code to fsck.c Junio C Hamano
2008-02-26 21:35 ` Martin Koegler
2008-02-27 7:48 ` Junio C Hamano
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=12039765001192-git-send-email-mkoegler@auto.tuwien.ac.at \
--to=mkoegler@auto.tuwien.ac.at \
--cc=git@vger.kernel.org \
/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).