All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "John Cai via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, John Cai <johncai86@gmail.com>
Subject: Re: [PATCH v2 0/2] Document fsck msg ids
Date: Mon, 24 Oct 2022 21:40:09 -0700	[thread overview]
Message-ID: <xmqqfsfcplcm.fsf@gitster.g> (raw)
In-Reply-To: <xmqqwn8oplsh.fsf@gitster.g> (Junio C. Hamano's message of "Mon, 24 Oct 2022 21:30:38 -0700")

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


  reply	other threads:[~2022-10-25  4:40 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24 15:00 [PATCH 0/2] Document fsck msg ids John Cai via GitGitGadget
2022-10-24 15:00 ` [PATCH 1/2] fsck: remove the unused BAD_TAG_OBJECT John Cai via GitGitGadget
2022-10-24 16:57   ` Junio C Hamano
2022-10-24 18:16     ` Junio C Hamano
2022-10-24 18:33       ` John Cai
2022-10-24 23:39         ` Jeff King
2022-10-24 15:00 ` [PATCH 2/2] fsck: document msg-id John Cai via GitGitGadget
2022-10-24 17:33   ` Junio C Hamano
2022-10-25  9:41     ` Ævar Arnfjörð Bjarmason
2022-10-25 16:07       ` Junio C Hamano
2022-10-24 18:51 ` [PATCH 0/2] Document fsck msg ids Junio C Hamano
2022-10-25  3:17 ` [PATCH v2 " John Cai via GitGitGadget
2022-10-25  3:17   ` [PATCH v2 1/2] fsck: remove the unused BAD_TAG_OBJECT John Cai via GitGitGadget
2022-10-25  3:17   ` [PATCH v2 2/2] fsck: document msg-id John Cai via GitGitGadget
2022-10-25  4:30   ` [PATCH v2 0/2] Document fsck msg ids Junio C Hamano
2022-10-25  4:40     ` Junio C Hamano [this message]
2022-10-25  5:12     ` [PATCH] Documentation: add lint-fsck-msgids Junio C Hamano
2022-10-25 22:42   ` [PATCH v3 0/4] document fsck error message ids Junio C Hamano
2022-10-25 22:42     ` [PATCH v3 1/4] fsck: remove the unused BAD_TAG_OBJECT Junio C Hamano
2022-10-25 22:42     ` [PATCH v3 2/4] fsck: remove the unused MISSING_TREE_OBJECT Junio C Hamano
2022-10-25 22:42     ` [PATCH v3 3/4] fsck: document msg-id Junio C Hamano
2022-10-25 22:42     ` [PATCH v3 4/4] Documentation: add lint-fsck-msgids Junio C Hamano
2022-10-26  2:43       ` Ævar Arnfjörð Bjarmason
2022-10-26  5:34         ` Jeff King
2022-10-26  6:46           ` Junio C Hamano
2022-10-26 11:35           ` Ævar Arnfjörð Bjarmason
2022-10-28  1:23             ` Jeff King
2022-10-28  2:04               ` Ævar Arnfjörð Bjarmason
2022-10-28  5:32                 ` Jeff King
2022-10-28 10:41                   ` Ævar Arnfjörð Bjarmason
2022-10-28  3:02             ` John Cai
2022-10-28  3:11               ` Ævar Arnfjörð Bjarmason
2022-10-28  5:32                 ` Junio C Hamano
2022-10-28  5:37                   ` Jeff King
2022-10-28  5:35                 ` Jeff King

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=xmqqfsfcplcm.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johncai86@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.