Skip to content

Commit 1e230df

Browse files
committed
Merge branch 'jc/doc-fsck-msgids'
Add documentation for message IDs in fsck error messages. * jc/doc-fsck-msgids: Documentation: add lint-fsck-msgids fsck: document msg-id fsck: remove the unused MISSING_TREE_OBJECT fsck: remove the unused BAD_TAG_OBJECT
2 parents b1e3dd6 + 3882a0d commit 1e230df

File tree

6 files changed

+264
-2
lines changed

6 files changed

+264
-2
lines changed

Documentation/Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,19 @@ $(LINT_DOCS_MAN_SECTION_ORDER): .build/lint-docs/man-section-order/%.ok: %.txt
476476
.PHONY: lint-docs-man-section-order
477477
lint-docs-man-section-order: $(LINT_DOCS_MAN_SECTION_ORDER)
478478

479+
.PHONY: lint-docs-fsck-msgids
480+
LINT_DOCS_FSCK_MSGIDS = .build/lint-docs/fsck-msgids.ok
481+
$(LINT_DOCS_FSCK_MSGIDS): lint-fsck-msgids.perl
482+
$(LINT_DOCS_FSCK_MSGIDS): ../fsck.h fsck-msgids.txt
483+
$(call mkdir_p_parent_template)
484+
$(QUIET_GEN)$(PERL_PATH) lint-fsck-msgids.perl \
485+
../fsck.h fsck-msgids.txt $@
486+
487+
lint-docs-fsck-msgids: $(LINT_DOCS_FSCK_MSGIDS)
488+
479489
## Lint: list of targets above
480490
.PHONY: lint-docs
491+
lint-docs: lint-docs-fsck-msgids
481492
lint-docs: lint-docs-gitlink
482493
lint-docs: lint-docs-man-end-blurb
483494
lint-docs: lint-docs-man-section-order

Documentation/config/fsck.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ allow new instances of the same breakages go unnoticed.
3535
Setting an unknown `fsck.<msg-id>` value will cause fsck to die, but
3636
doing the same for `receive.fsck.<msg-id>` and `fetch.fsck.<msg-id>`
3737
will only cause git to warn.
38+
+
39+
See `Fsck Messages` section of linkgit:git-fsck[1] for supported
40+
values of `<msg-id>`.
41+
3842

3943
fsck.skipList::
4044
The path to a list of object names (i.e. one unabbreviated SHA-1 per

Documentation/fsck-msgids.txt

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
`badDate`::
2+
(ERROR) Invalid date format in an author/committer line.
3+
4+
`badDateOverflow`::
5+
(ERROR) Invalid date value in an author/committer line.
6+
7+
`badEmail`::
8+
(ERROR) Invalid email format in an author/committer line.
9+
10+
`badFilemode`::
11+
(INFO) A tree contains a bad filemode entry.
12+
13+
`badName`::
14+
(ERROR) An author/committer name is empty.
15+
16+
`badObjectSha1`::
17+
(ERROR) An object has a bad sha1.
18+
19+
`badParentSha1`::
20+
(ERROR) A commit object has a bad parent sha1.
21+
22+
`badTagName`::
23+
(INFO) A tag has an invalid format.
24+
25+
`badTimezone`::
26+
(ERROR) Found an invalid time zone in an author/committer line.
27+
28+
`badTree`::
29+
(ERROR) A tree cannot be parsed.
30+
31+
`badTreeSha1`::
32+
(ERROR) A tree has an invalid format.
33+
34+
`badType`::
35+
(ERROR) Found an invalid object type.
36+
37+
`duplicateEntries`::
38+
(ERROR) A tree contains duplicate file entries.
39+
40+
`emptyName`::
41+
(WARN) A path contains an empty name.
42+
43+
`extraHeaderEntry`::
44+
(IGNORE) Extra headers found after `tagger`.
45+
46+
`fullPathname`::
47+
(WARN) A path contains the full path starting with "/".
48+
49+
`gitattributesSymlink`::
50+
(INFO) `.gitattributes` is a symlink.
51+
52+
`gitignoreSymlink`::
53+
(INFO) `.gitignore` is a symlink.
54+
55+
`gitmodulesBlob`::
56+
(ERROR) A non-blob found at `.gitmodules`.
57+
58+
`gitmodulesLarge`::
59+
(ERROR) The `.gitmodules` file is too large to parse.
60+
61+
`gitmodulesMissing`::
62+
(ERROR) Unable to read `.gitmodules` blob.
63+
64+
`gitmodulesName`::
65+
(ERROR) A submodule name is invalid.
66+
67+
`gitmodulesParse`::
68+
(INFO) Could not parse `.gitmodules` blob.
69+
70+
`gitmodulesLarge`;
71+
(ERROR) `.gitmodules` blob is too large to parse.
72+
73+
`gitmodulesPath`::
74+
(ERROR) `.gitmodules` path is invalid.
75+
76+
`gitmodulesSymlink`::
77+
(ERROR) `.gitmodules` is a symlink.
78+
79+
`gitmodulesUpdate`::
80+
(ERROR) Found an invalid submodule update setting.
81+
82+
`gitmodulesUrl`::
83+
(ERROR) Found an invalid submodule url.
84+
85+
`hasDot`::
86+
(WARN) A tree contains an entry named `.`.
87+
88+
`hasDotdot`::
89+
(WARN) A tree contains an entry named `..`.
90+
91+
`hasDotgit`::
92+
(WARN) A tree contains an entry named `.git`.
93+
94+
`mailmapSymlink`::
95+
(INFO) `.mailmap` is a symlink.
96+
97+
`missingAuthor`::
98+
(ERROR) Author is missing.
99+
100+
`missingCommitter`::
101+
(ERROR) Committer is missing.
102+
103+
`missingEmail`::
104+
(ERROR) Email is missing in an author/committer line.
105+
106+
`missingNameBeforeEmail`::
107+
(ERROR) Missing name before an email in an author/committer line.
108+
109+
`missingObject`::
110+
(ERROR) Missing `object` line in tag object.
111+
112+
`missingSpaceBeforeDate`::
113+
(ERROR) Missing space before date in an author/committer line.
114+
115+
`missingSpaceBeforeEmail`::
116+
(ERROR) Missing space before the email in author/committer line.
117+
118+
`missingTag`::
119+
(ERROR) Unexpected end after `type` line in a tag object.
120+
121+
`missingTagEntry`::
122+
(ERROR) Missing `tag` line in a tag object.
123+
124+
`missingTaggerEntry`::
125+
(INFO) Missing `tagger` line in a tag object.
126+
127+
`missingTree`::
128+
(ERROR) Missing `tree` line in a commit object.
129+
130+
`missingType`::
131+
(ERROR) Invalid type value on the `type` line in a tag object.
132+
133+
`missingTypeEntry`::
134+
(ERROR) Missing `type` line in a tag object.
135+
136+
`multipleAuthors`::
137+
(ERROR) Multiple author lines found in a commit.
138+
139+
`nulInCommit`::
140+
(WARN) Found a NUL byte in the commit object body.
141+
142+
`nulInHeader`::
143+
(FATAL) NUL byte exists in the object header.
144+
145+
`nullSha1`::
146+
(WARN) Tree contains entries pointing to a null sha1.
147+
148+
`treeNotSorted`::
149+
(ERROR) A tree is not properly sorted.
150+
151+
`unknownType`::
152+
(ERROR) Found an unknown object type.
153+
154+
`unterminatedHeader`::
155+
(FATAL) Missing end-of-line in the object header.
156+
157+
`zeroPaddedDate`::
158+
(ERROR) Found a zero padded date in an author/commiter line.
159+
160+
`zeroPaddedFilemode`::
161+
(WARN) Found a zero padded filemode in a tree.

Documentation/git-fsck.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ hash mismatch <object>::
152152
object database value.
153153
This indicates a serious data integrity problem.
154154

155+
156+
FSCK MESSAGES
157+
-------------
158+
159+
The following lists the types of errors `git fsck` detects and what
160+
each error means, with their default severity. The severity of the
161+
error, other than those that are marked as "(FATAL)", can be tweaked
162+
by setting the corresponding `fsck.<msg-id>` configuration variable.
163+
164+
include::fsck-msgids.txt[]
165+
166+
155167
Environment Variables
156168
---------------------
157169

Documentation/lint-fsck-msgids.perl

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/perl
2+
3+
my ($fsck_h, $fsck_msgids_txt, $okfile) = @ARGV;
4+
5+
my (%in_fsck_h, $fh, $bad);
6+
7+
open($fh, "<", "$fsck_h") or die;
8+
while (<$fh>) {
9+
if (/^\s+FUNC\(([0-9A-Z_]+), ([A-Z]+)\)/) {
10+
my ($name, $severity) = ($1, $2);
11+
my ($first) = 1;
12+
$name = join('',
13+
map {
14+
y/A-Z/a-z/;
15+
if (!$first) {
16+
s/^(.)/uc($1)/e;
17+
} else {
18+
$first = 0;
19+
}
20+
$_;
21+
}
22+
split(/_/, $name));
23+
$in_fsck_h{$name} = $severity;
24+
}
25+
}
26+
close($fh);
27+
28+
open($fh, "<", "$fsck_msgids_txt") or die;
29+
my ($previous, $current);
30+
while (<$fh>) {
31+
if (!defined $current) {
32+
if (/^\`([a-zA-Z0-9]*)\`::/) {
33+
$current = $1;
34+
if ((defined $previous) &&
35+
($current le $previous)) {
36+
print STDERR "$previous >= $current in doc\n";
37+
$bad = 1;
38+
}
39+
}
40+
} elsif (/^\s+\(([A-Z]+)\) /) {
41+
my ($level) = $1;
42+
if (!exists $in_fsck_h{$current}) {
43+
print STDERR "$current does not exist in fsck.h\n";
44+
$bad = 1;
45+
} elsif ($in_fsck_h{$current} eq "") {
46+
print STDERR "$current defined twice\n";
47+
$bad = 1;
48+
} elsif ($in_fsck_h{$current} ne $level) {
49+
print STDERR "$current severity $level != $in_fsck_h{$current}\n";
50+
$bad = 1;
51+
}
52+
$previous = $current;
53+
$in_fsck_h{$current} = ""; # mark as seen.
54+
undef $current;
55+
}
56+
}
57+
close($fh);
58+
59+
for my $key (keys %in_fsck_h) {
60+
if ($in_fsck_h{$key} ne "") {
61+
print STDERR "$key not explained in doc.\n";
62+
$bad = 1;
63+
}
64+
}
65+
66+
die if ($bad);
67+
68+
open($fh, ">", "$okfile");
69+
print $fh "good\n";
70+
close($fh);

fsck.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ enum fsck_msg_type {
1313
FSCK_WARN,
1414
};
1515

16+
/*
17+
* Documentation/fsck-msgids.txt documents these; when
18+
* modifying this list in any way, make sure to keep the
19+
* two in sync.
20+
*/
21+
1622
#define FOREACH_FSCK_MSG_ID(FUNC) \
1723
/* fatal errors */ \
1824
FUNC(NUL_IN_HEADER, FATAL) \
@@ -24,7 +30,6 @@ enum fsck_msg_type {
2430
FUNC(BAD_NAME, ERROR) \
2531
FUNC(BAD_OBJECT_SHA1, ERROR) \
2632
FUNC(BAD_PARENT_SHA1, ERROR) \
27-
FUNC(BAD_TAG_OBJECT, ERROR) \
2833
FUNC(BAD_TIMEZONE, ERROR) \
2934
FUNC(BAD_TREE, ERROR) \
3035
FUNC(BAD_TREE_SHA1, ERROR) \
@@ -40,7 +45,6 @@ enum fsck_msg_type {
4045
FUNC(MISSING_TAG, ERROR) \
4146
FUNC(MISSING_TAG_ENTRY, ERROR) \
4247
FUNC(MISSING_TREE, ERROR) \
43-
FUNC(MISSING_TREE_OBJECT, ERROR) \
4448
FUNC(MISSING_TYPE, ERROR) \
4549
FUNC(MISSING_TYPE_ENTRY, ERROR) \
4650
FUNC(MULTIPLE_AUTHORS, ERROR) \

0 commit comments

Comments
 (0)