Skip to content

Commit efaba7c

Browse files
dschogitster
authored andcommitted
fsck: optionally ignore specific fsck issues completely
An fsck issue in a legacy repository might be so common that one would like not to bother the user with mentioning it at all. With this change, that is possible by setting the respective message type to "ignore". This change "abuses" the missingEmail=warn test to verify that "ignore" is also accepted and works correctly. And while at it, it makes sure that multiple options work, too (they are passed to unpack-objects or index-pack as a comma-separated list via the --strict=... command-line option). Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f50c440 commit efaba7c

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

fsck.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ static int parse_msg_type(const char *str)
131131
return FSCK_ERROR;
132132
else if (!strcmp(str, "warn"))
133133
return FSCK_WARN;
134+
else if (!strcmp(str, "ignore"))
135+
return FSCK_IGNORE;
134136
else
135137
die("Unknown fsck message type: '%s'", str);
136138
}
@@ -222,6 +224,9 @@ static int report(struct fsck_options *options, struct object *object,
222224
struct strbuf sb = STRBUF_INIT;
223225
int msg_type = fsck_msg_type(id, options), result;
224226

227+
if (msg_type == FSCK_IGNORE)
228+
return 0;
229+
225230
if (msg_type == FSCK_FATAL)
226231
msg_type = FSCK_ERROR;
227232

fsck.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#define FSCK_ERROR 1
55
#define FSCK_WARN 2
6+
#define FSCK_IGNORE 3
67

78
struct fsck_options;
89

t/t5504-fetch-receive-strict.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,14 @@ test_expect_success 'push with receive.fsck.missingEmail=warn' '
133133
git --git-dir=dst/.git config \
134134
receive.fsck.missingEmail warn &&
135135
git push --porcelain dst bogus >act 2>&1 &&
136-
grep "missingEmail" act
136+
grep "missingEmail" act &&
137+
git --git-dir=dst/.git branch -D bogus &&
138+
git --git-dir=dst/.git config --add \
139+
receive.fsck.missingEmail ignore &&
140+
git --git-dir=dst/.git config --add \
141+
receive.fsck.badDate warn &&
142+
git push --porcelain dst bogus >act 2>&1 &&
143+
test_must_fail grep "missingEmail" act
137144
'
138145

139146
test_expect_success \

0 commit comments

Comments
 (0)