Skip to content

Commit 4dd3b04

Browse files
peffgitster
authored andcommitted
fsck: downgrade tree badFilemode to "info"
The previous commit un-broke the "badFileMode" check; before then it was literally testing nothing. And as far as I can tell, it has been so since the very initial version of fsck. The current severity of "badFileMode" is just "warning". But in the --strict mode used by transfer.fsckObjects, that is elevated to an error. This will potentially cause hassle for users, because historical objects with bad modes will suddenly start causing pushes to many server operators to be rejected. At the same time, these bogus modes aren't actually a big risk. Because we canonicalize them everywhere besides fsck, they can't cause too much mischief in the real world. The worst thing you can do is end up with two almost-identical trees that have different hashes but are interpreted the same. That will generally cause things to be inefficient rather than wrong, and is a bug somebody working on a Git implementation would want to fix, but probably not worth inconveniencing users by refusing to push or fetch. So let's downgrade this to "info" by default, which is our setting for "mention this when fscking, but don't ever reject, even under strict mode". If somebody really wants to be paranoid, they can still adjust the level using config. Suggested-by: Xavier Morel <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 53602a9 commit 4dd3b04

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

fsck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ enum fsck_msg_type {
5656
FUNC(GITMODULES_PATH, ERROR) \
5757
FUNC(GITMODULES_UPDATE, ERROR) \
5858
/* warnings */ \
59-
FUNC(BAD_FILEMODE, WARN) \
6059
FUNC(EMPTY_NAME, WARN) \
6160
FUNC(FULL_PATHNAME, WARN) \
6261
FUNC(HAS_DOT, WARN) \
@@ -66,6 +65,7 @@ enum fsck_msg_type {
6665
FUNC(ZERO_PADDED_FILEMODE, WARN) \
6766
FUNC(NUL_IN_COMMIT, WARN) \
6867
/* infos (reported as warnings, but ignored by default) */ \
68+
FUNC(BAD_FILEMODE, INFO) \
6969
FUNC(GITMODULES_PARSE, INFO) \
7070
FUNC(GITIGNORE_SYMLINK, INFO) \
7171
FUNC(GITATTRIBUTES_SYMLINK, INFO) \

t/t5504-fetch-receive-strict.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,4 +352,21 @@ test_expect_success \
352352
grep "Cannot demote unterminatedheader" act
353353
'
354354

355+
test_expect_success 'badFilemode is not a strict error' '
356+
git init --bare badmode.git &&
357+
tree=$(
358+
cd badmode.git &&
359+
blob=$(echo blob | git hash-object -w --stdin | hex2oct) &&
360+
printf "123456 foo\0${blob}" |
361+
git hash-object -t tree --stdin -w --literally
362+
) &&
363+
364+
rm -rf dst.git &&
365+
git init --bare dst.git &&
366+
git -C dst.git config transfer.fsckObjects true &&
367+
368+
git -C badmode.git push ../dst.git $tree:refs/tags/tree 2>err &&
369+
grep "$tree: badFilemode" err
370+
'
371+
355372
test_done

0 commit comments

Comments
 (0)