index-pack: test and document --strict=<msg-id>=<severity>...

5d477a334a (fsck (receive-pack): allow demoting errors to warnings, 2015-06-22) allowed a list of fsck msg to downgrade to be passed to --strict. However this is a hidden argument that was not documented nor tested. Though it is true that most users would not call this option directly, (nor use index-pack for that matter) it is still useful to document and test this feature. Reviewed-by: Christian Couder <christian.couder@gmail.com> Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

John Cai committed Feb 1, 2024 at 01:38 UTC 2811019f47b7b6f4be256598612c3f574d8c242d
3 files changed +30 -3
Documentation/git-index-pack.txt
+7 -2
@@ -79,8 +79,13 @@ OPTIONS
79 to force the version for the generated pack index, and to force
80 64-bit index entries on objects located above the given offset.
81
82 ---strict::
83 - Die, if the pack contains broken objects or links.
82 +--strict[=<msg-id>=<severity>...]::
83 + Die, if the pack contains broken objects or links. An optional
84 + comma-separated list of `<msg-id>=<severity>` can be passed to change
85 + the severity of some possible issues, e.g.,
86 + `--strict="missingEmail=ignore,badTagName=error"`. See the entry for the
87 + `fsck.<msg-id>` configuration options in linkgit:git-fsck[1] for more
88 + information on the possible values of `<msg-id>` and `<severity>`.
89
90 --progress-title::
91 For internal use only.
builtin/index-pack.c
+1 -1
@@ -26,7 +26,7 @@
26 #include "setup.h"
27
28 static const char index_pack_usage[] =
29 -"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
29 +"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict[=<msg-id>=<severity>...]] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
30
31 struct object_entry {
32 struct pack_idx_entry idx;
t/t5300-pack-object.sh
+22
@@ -441,6 +441,28 @@ test_expect_success 'index-pack with --strict' '
441 )
442 '
443
444 +test_expect_success 'index-pack with --strict downgrading fsck msgs' '
445 + test_when_finished rm -rf strict &&
446 + git init strict &&
447 + (
448 + cd strict &&
449 + test_commit first hello &&
450 + cat >commit <<-EOF &&
451 + tree $(git rev-parse HEAD^{tree})
452 + parent $(git rev-parse HEAD)
453 + author A U Thor
454 + committer A U Thor
455 +
456 + commit: this is a commit with bad emails
457 +
458 + EOF
459 + git hash-object --literally -t commit -w --stdin <commit >commit_list &&
460 + PACK=$(git pack-objects test <commit_list) &&
461 + test_must_fail git index-pack --strict "test-$PACK.pack" &&
462 + git index-pack --strict="missingEmail=ignore" "test-$PACK.pack"
463 + )
464 +'
465 +
466 test_expect_success 'honor pack.packSizeLimit' '
467 git config pack.packSizeLimit 3m &&
468 packname_10=$(git pack-objects test-10 <obj-list) &&