git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 3/4] fsck: give the error function a chance to see the fsck_options

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 17, 2016, 10:59 UTC
Message-ID
<ffad4bc034bdffdfb05a59d08d070d0461b44f8e.1468752290.git.johannes.schindelin@gmx.de>
In-Reply-To
<cover.1468752290.git.johannes.schindelin@gmx.de>

We will need this in the next commit, where fsck will be taught to optionally name the objects when reporting issues about them.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin/fsck.c | 3 ++-
 fsck.c         | 5 +++--
 fsck.h         | 6 ++++--
 3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 87df191..6c9d598 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -82,7 +82,8 @@ static int objerror(struct object *obj, const char *err)
 	return -1;
 }
 
-static int fsck_error_func(struct object *obj, int type, const char *message)
+static int fsck_error_func(struct fsck_options *o,
+	struct object *obj, int type, const char *message)
 {
 	objreport(obj, (type == FSCK_WARN) ? "warning" : "error", message);
 	return (type == FSCK_WARN) ? 0 : 1;
diff --git a/fsck.c b/fsck.c
index 6ed90ec..828c5c6 100644
--- 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);
 
@@ -897,7 +897,8 @@ 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);
diff --git a/fsck.h b/fsck.h
index 26c0d41..1891c18 100644
--- a/fsck.h
+++ b/fsck.h
@@ -23,9 +23,11 @@ int is_valid_msg_type(const char *msg_id, const char *msg_type);
 typedef int (*fsck_walk_func)(struct object *obj, int type, void *data, struct fsck_options *options);
 
 /* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */
-typedef int (*fsck_error)(struct object *obj, int type, const char *message);
+typedef int (*fsck_error)(struct fsck_options *o,
+	struct object *obj, int type, const char *message);
 
-int fsck_error_function(struct object *obj, int type, const char *message);
+int fsck_error_function(struct fsck_options *o,
+	struct object *obj, int type, const char *message);
 
 struct fsck_options {
 	fsck_walk_func walk;
-- 
2.9.0.281.g286a8d9
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 13 of 16 in “Teach `git fsck` a new option: `--name-objects`”
  1. 0/3 Teach `git fsck` a new option: `--name-objects`Johannes Schindelin, Jul 14, 2016
  2. 1/3 fsck: refactor how to describe objectsJohannes Schindelin, Jul 14, 2016
  3. Junio C HamanoJul 14, 2016
  4. 2/3 fsck_walk(): optionally name objects on the goJohannes Schindelin, Jul 14, 2016
  5. Junio C HamanoJul 14, 2016
  6. Johannes SchindelinJul 17, 2016
  7. 3/3 fsck: optionally show more helpful info for broken linksJohannes Schindelin, Jul 14, 2016
  8. Eric SunshineJul 15, 2016
  9. Johannes SchindelinJul 17, 2016
  10. Junio C HamanoJul 14, 2016
  11. 0/4 Teach `git fsck` a new option: `--name-objects`Johannes Schindelin, Jul 17, 2016
  12. 2/4 fsck_walk(): optionally name objects on the goJohannes Schindelin, Jul 17, 2016
  13. 3/4 fsck: give the error function a chance to see the fsck_optionsJohannes Schindelin, Jul 17, 2016
  14. 4/4 fsck: optionally show more helpful info for broken linksJohannes Schindelin, Jul 17, 2016
  15. 1/4 fsck: refactor how to describe objectsJohannes Schindelin, Jul 17, 2016
  16. Junio C HamanoJul 18, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.