Skip to content

Commit

Permalink
index-pack: test and document --strict=<msg>
Browse files Browse the repository at this point in the history
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. Let's do so now.

Signed-off-by: John Cai <[email protected]>
  • Loading branch information
john-cai committed Jan 20, 2024
1 parent 186b115 commit b6cc485
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Documentation/git-index-pack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ OPTIONS
to force the version for the generated pack index, and to force
64-bit index entries on objects located above the given offset.

--strict::
Die, if the pack contains broken objects or links.
--strict[=<msg-ids>]::
Die, if the pack contains broken objects or links. If `<msg-ids>` is passed,
it should be a comma-separated list of `<msg-id>=<severity>` elements where
`<msg-id>` and `<severity>` are used to change the severity of some possible
issues, eg: `--strict="missingEmail=ignore,badTagName=error"`. See the entry
for the `fsck.<msg-id>` configuration options in `linkgit:git-fsck[1] for
more information on the possible values of `<msg-id>` and `<severity>`.

--progress-title::
For internal use only.
Expand Down
2 changes: 1 addition & 1 deletion builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "setup.h"

static const char index_pack_usage[] =
"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict[=<msg-ids>]] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";

struct object_entry {
struct pack_idx_entry idx;
Expand Down
22 changes: 22 additions & 0 deletions t/t5300-pack-object.sh
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,28 @@ test_expect_success 'index-pack with --strict' '
)
'

test_expect_success 'index-pack with --strict downgrading fsck msgs' '
test_when_finished rm -rf strict &&
git init strict &&
(
cd strict &&
test_commit first hello &&
cat >commit <<-EOF &&
tree $(git rev-parse master^{tree})
parent $(git rev-parse master)
author A U Thor
committer A U Thor
commit: this is a commit wit bad emails
EOF
git hash-object --literally -t commit -w --stdin <commit >commit_list &&
PACK=$(git pack-objects test <commit_list) &&
test_must_fail git index-pack --strict "test-$PACK.pack" &&
git index-pack --strict="missingEmail=ignore" "test-$PACK.pack"
)
'

test_expect_success 'honor pack.packSizeLimit' '
git config pack.packSizeLimit 3m &&
packname_10=$(git pack-objects test-10 <obj-list) &&
Expand Down

0 comments on commit b6cc485

Please sign in to comment.