{"thread":{"id":"8433","subject":"[PATCH] git-fsck: learn about --verbose","startedAt":"2007-06-05T02:44:00Z","lastAt":"2007-06-05T02:44:00Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"44024","messageId":"Pine.LNX.4.64.0706050341500.4046@racer.site","threadId":"8433","inReplyTo":null,"subject":"[PATCH] git-fsck: learn about --verbose","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-06-05T02:44:00Z","receivedAt":"2007-06-05T02:44:00Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWith --verbose, it gets really chatty now.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tSteven Grimm on IRC said that this might come in handy someday, \n\talthough it did not help _his_ case.\n\n Documentation/git-fsck.txt |    5 ++++-\n builtin-fsck.c             |   42 +++++++++++++++++++++++++++++++++++++++++-\n 2 files changed, 45 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-fsck.txt b/Documentation/git-fsck.txt\nindex 8c68cf0..ed6413a 100644\n--- a/Documentation/git-fsck.txt\n+++ b/Documentation/git-fsck.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git-fsck' [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]\n-\t\t [--full] [--strict] [<object>*]\n+\t\t [--full] [--strict] [--verbose] [<object>*]\n \n DESCRIPTION\n -----------\n@@ -61,6 +61,9 @@ index file and all SHA1 references in .git/refs/* as heads.\n \tobjects that triggers this check, but it is recommended\n \tto check new projects with this flag.\n \n+--verbose::\n+\tBe chatty.\n+\n It tests SHA1 and general object sanity, and it does full tracking of\n the resulting reachability and everything else. It prints out any\n corruption it finds (missing or bad objects), and if you use the\ndiff --git a/builtin-fsck.c b/builtin-fsck.c\nindex 9959818..bacae5d 100644\n--- a/builtin-fsck.c\n+++ b/builtin-fsck.c\n@@ -20,6 +20,7 @@ static int check_strict;\n static int keep_cache_objects;\n static unsigned char head_sha1[20];\n static int errors_found;\n+static int verbose;\n #define ERROR_OBJECT 01\n #define ERROR_REACHABLE 02\n \n@@ -149,6 +150,9 @@ static void check_unreachable_object(struct object *obj)\n \n static void check_object(struct object *obj)\n {\n+\tif (verbose)\n+\t\tfprintf(stderr, \"Checking %s\\n\", sha1_to_hex(obj->sha1));\n+\n \tif (obj->flags & REACHABLE)\n \t\tcheck_reachable_object(obj);\n \telse\n@@ -161,6 +165,9 @@ static void check_connectivity(void)\n \n \t/* Look up all the requirements, warn about missing objects.. */\n \tmax = get_max_object_index();\n+\tif (verbose)\n+\t\tfprintf(stderr, \"Checking connectivity (%d objects)\\n\", max);\n+\n \tfor (i = 0; i < max; i++) {\n \t\tstruct object *obj = get_indexed_object(i);\n \n@@ -229,6 +236,10 @@ static int fsck_tree(struct tree *item)\n \tconst char *o_name;\n \tconst unsigned char *o_sha1;\n \n+\tif (verbose)\n+\t\tfprintf(stderr, \"Checking tree %s\\n\",\n+\t\t\t\tsha1_to_hex(item->object.sha1));\n+\n \tinit_tree_desc(&desc, item->buffer, item->size);\n \n \to_mode = 0;\n@@ -317,6 +328,10 @@ static int fsck_commit(struct commit *commit)\n \tchar *buffer = commit->buffer;\n \tunsigned char tree_sha1[20], sha1[20];\n \n+\tif (verbose)\n+\t\tfprintf(stderr, \"Checking commit %s\\n\",\n+\t\t\tsha1_to_hex(commit->object.sha1));\n+\n \tif (memcmp(buffer, \"tree \", 5))\n \t\treturn objerror(&commit->object, \"invalid format - expected 'tree' line\");\n \tif (get_sha1_hex(buffer+5, tree_sha1) || buffer[45] != '\\n')\n@@ -345,6 +360,10 @@ static int fsck_tag(struct tag *tag)\n {\n \tstruct object *tagged = tag->tagged;\n \n+\tif (verbose)\n+\t\tfprintf(stderr, \"Checking tag %s\\n\",\n+\t\t\tsha1_to_hex(tag->object.sha1));\n+\n \tif (!tagged) {\n \t\treturn objerror(&tag->object, \"could not load tagged object\");\n \t}\n@@ -446,6 +465,9 @@ static void fsck_dir(int i, char *path)\n \tif (!dir)\n \t\treturn;\n \n+\tif (verbose)\n+\t\tfprintf(stderr, \"Checking directory %s\\n\", path);\n+\n \twhile ((de = readdir(dir)) != NULL) {\n \t\tchar name[100];\n \t\tunsigned char sha1[20];\n@@ -480,6 +502,10 @@ static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,\n {\n \tstruct object *obj;\n \n+\tif (verbose)\n+\t\tfprintf(stderr, \"Checking reflog %s->%s\\n\",\n+\t\t\tsha1_to_hex(osha1), sha1_to_hex(nsha1));\n+\n \tif (!is_null_sha1(osha1)) {\n \t\tobj = lookup_object(osha1);\n \t\tif (obj) {\n@@ -549,6 +575,10 @@ static void get_default_heads(void)\n static void fsck_object_dir(const char *path)\n {\n \tint i;\n+\n+\tif (verbose)\n+\t\tfprintf(stderr, \"Checking object directory\\n\");\n+\n \tfor (i = 0; i < 256; i++) {\n \t\tstatic char dir[4096];\n \t\tsprintf(dir, \"%s/%02x\", path, i);\n@@ -564,6 +594,9 @@ static int fsck_head_link(void)\n \tint null_is_error = 0;\n \tconst char *head_points_at = resolve_ref(\"HEAD\", sha1, 0, &flag);\n \n+\tif (verbose)\n+\t\tfprintf(stderr, \"Checking HEAD link\\n\");\n+\n \tif (!head_points_at)\n \t\treturn error(\"Invalid HEAD\");\n \tif (!strcmp(head_points_at, \"HEAD\"))\n@@ -586,6 +619,9 @@ static int fsck_cache_tree(struct cache_tree *it)\n \tint i;\n \tint err = 0;\n \n+\tif (verbose)\n+\t\tfprintf(stderr, \"Checking cache tree\\n\");\n+\n \tif (0 <= it->entry_count) {\n \t\tstruct object *obj = parse_object(it->sha1);\n \t\tif (!obj) {\n@@ -605,7 +641,7 @@ static int fsck_cache_tree(struct cache_tree *it)\n \n static const char fsck_usage[] =\n \"git-fsck [--tags] [--root] [[--unreachable] [--cache] [--full] \"\n-\"[--strict] <head-sha1>*]\";\n+\"[--strict] [--verbose] <head-sha1>*]\";\n \n int cmd_fsck(int argc, char **argv, const char *prefix)\n {\n@@ -645,6 +681,10 @@ int cmd_fsck(int argc, char **argv, const char *prefix)\n \t\t\tcheck_strict = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"--verbose\")) {\n+\t\t\tverbose = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (*arg == '-')\n \t\t\tusage(fsck_usage);\n \t}\n-- \n1.5.2.1.2626.ge1044-dirty\n"}]}