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

Re: [PATCH v2 0/2] Document fsck msg ids

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 25, 2022, 04:40 UTC
Message-ID
<xmqqfsfcplcm.fsf@gitster.g>
In-Reply-To
<xmqqwn8oplsh.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
> Thanks.  I did a bit of sanity checking and it made my earlier
> suspicion stronger.  We MUST have at least an automated checker to
> check the doc against the fsck.h header, if not an automated
> generator of the doc from the fsck.h header.

FYI, here are a pair of quick-and-dirty Perl scripts that I used for the sanity checking. The first one "parses" the fsck-msgs.txt and formats lines like

    badTagName	INFO
i.e. camelCased error message name, a TAB, and the severity.

The second one reads the FOREACH_FSCK_MSG_ID() definition in fsck.h that look like "FUNC(BAD_TAG_NAME, INFO)", camelcases the name and shows what can be compared with the output of the first one.

There are two sanity checks that must pass when a developer updates the documentation.

 - The output from m.perl on the documentation must already be sorted.
 - The output from n.perl on fsck.h, when sorted, must match the
   output from m.perl on the documentation.

$ cat >m.perl <<\EOF #!/usr/bin/perl

my ($previous, $current);
while (<>) {
	if (!defined $current) {
		if (/^\`([a-zA-Z0-9]*)\`::/) {
			$current = $1;
			if ((defined $previous) &&
			    ($current le $previous)) {
				print STDERR "$previous >= $current???\n";
			}
		}
	} elsif (/^\s+\(([A-Z]+)\) /) {
		print "$current	$1\n";
		$previous = $current;
		undef $current;
	}
}
EOF
$ cat >n.perl <<\EOF
#!/usr/bin/perl
while (<>) {
	if (/^\s+FUNC\(([0-9A-Z_]+), ([A-Z]+)\)/) {
		my ($name, $severity) = ($1, $2);
		my ($first) = 1;
		$name = join('',
			     map {
				     y/A-Z/a-z/;
				     if (!$first) {
					     s/^(.)/uc($1)/e;
				     } else {
					     $first = 0;
				     }
				     $_;
			     }
			     split(/_/, $name));
		print "$name	$severity\n";
	}
}
EOF
$ perl m.perl Documentation/fsck-msgids.txt >/var/tmp/1
$ sort /var/tmp/1 >/var/tmp/2
$ diff -u /var/tmp/1 /var/tmp/2
#### no output should appear in the above comparison
$ perl n.perl fsck.h | sort >/var/tmp/2
$ diff -u /var/tmp/1 /var/tmp/2
#### no output should appear in the above comparison
Previous: Junio C HamanoNext: Junio C Hamano
Message 16 of 35 in “Document fsck msg ids”
  1. 0/2 Document fsck msg idsJohn Cai via GitGitGadget, Oct 24, 2022
  2. 2/2 fsck: document msg-idJohn Cai via GitGitGadget, Oct 24, 2022
  3. Junio C HamanoOct 24, 2022
  4. Ævar Arnfjörð BjarmasonOct 25, 2022
  5. Junio C HamanoOct 25, 2022
  6. 1/2 fsck: remove the unused BAD_TAG_OBJECTJohn Cai via GitGitGadget, Oct 24, 2022
  7. Junio C HamanoOct 24, 2022
  8. Junio C HamanoOct 24, 2022
  9. John CaiOct 24, 2022
  10. Jeff KingOct 24, 2022
  11. Junio C HamanoOct 24, 2022
  12. 0/2 Document fsck msg idsJohn Cai via GitGitGadget, Oct 25, 2022
  13. 1/2 fsck: remove the unused BAD_TAG_OBJECTJohn Cai via GitGitGadget, Oct 25, 2022
  14. 2/2 fsck: document msg-idJohn Cai via GitGitGadget, Oct 25, 2022
  15. Junio C HamanoOct 25, 2022
  16. Junio C HamanoOct 25, 2022
  17. Documentation: add lint-fsck-msgidsJunio C Hamano, Oct 25, 2022
  18. 0/4 document fsck error message idsJunio C Hamano, Oct 25, 2022
  19. 1/4 fsck: remove the unused BAD_TAG_OBJECTJunio C Hamano, Oct 25, 2022
  20. 2/4 fsck: remove the unused MISSING_TREE_OBJECTJunio C Hamano, Oct 25, 2022
  21. 3/4 fsck: document msg-idJunio C Hamano, Oct 25, 2022
  22. 4/4 Documentation: add lint-fsck-msgidsJunio C Hamano, Oct 25, 2022
  23. Ævar Arnfjörð BjarmasonOct 26, 2022
  24. Jeff KingOct 26, 2022
  25. Junio C HamanoOct 26, 2022
  26. Ævar Arnfjörð BjarmasonOct 26, 2022
  27. Jeff KingOct 28, 2022
  28. Ævar Arnfjörð BjarmasonOct 28, 2022
  29. Jeff KingOct 28, 2022
  30. Ævar Arnfjörð BjarmasonOct 28, 2022
  31. John CaiOct 28, 2022
  32. Ævar Arnfjörð BjarmasonOct 28, 2022
  33. Junio C HamanoOct 28, 2022
  34. Jeff KingOct 28, 2022
  35. Jeff KingOct 28, 2022

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.