Skip to content

Commit 2811019

Browse files
john-caigitster
authored andcommitted
index-pack: test and document --strict=<msg-id>=<severity>...
5d477a3 (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 <[email protected]> Signed-off-by: John Cai <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 564d025 commit 2811019

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

Documentation/git-index-pack.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,13 @@ OPTIONS
7979
to force the version for the generated pack index, and to force
8080
64-bit index entries on objects located above the given offset.
8181

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>`.
8489

8590
--progress-title::
8691
For internal use only.

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "setup.h"
2727

2828
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>])";
3030

3131
struct object_entry {
3232
struct pack_idx_entry idx;

t/t5300-pack-object.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,28 @@ test_expect_success 'index-pack with --strict' '
441441
)
442442
'
443443

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+
444466
test_expect_success 'honor pack.packSizeLimit' '
445467
git config pack.packSizeLimit 3m &&
446468
packname_10=$(git pack-objects test-10 <obj-list) &&

0 commit comments

Comments
 (0)