Skip to content

Commit 2c90347

Browse files
committed
Merge branch 'jc/index-pack-fsck-levels'
The "--fsck-objects" option of "git index-pack" now can take the optional parameter to tweak severity of different fsck errors. * jc/index-pack-fsck-levels: index-pack: --fsck-objects to take an optional argument for fsck msgs index-pack: test and document --strict=<msg-id>=<severity>...
2 parents 107023e + 0f8edf7 commit 2c90347

File tree

3 files changed

+62
-10
lines changed

3 files changed

+62
-10
lines changed

Documentation/git-index-pack.txt

Lines changed: 18 additions & 8 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.
@@ -91,13 +96,18 @@ default and "Indexing objects" when `--stdin` is specified.
9196
--check-self-contained-and-connected::
9297
Die if the pack contains broken links. For internal use only.
9398

94-
--fsck-objects::
95-
For internal use only.
99+
--fsck-objects[=<msg-id>=<severity>...]::
100+
Die if the pack contains broken objects, but unlike `--strict`, don't
101+
choke on broken links. If the pack contains a tree pointing to a
102+
.gitmodules blob that does not exist, prints the hash of that blob
103+
(for the caller to check) after the hash that goes into the name of the
104+
pack/idx file (see "Notes").
96105
+
97-
Die if the pack contains broken objects. If the pack contains a tree
98-
pointing to a .gitmodules blob that does not exist, prints the hash of
99-
that blob (for the caller to check) after the hash that goes into the
100-
name of the pack/idx file (see "Notes").
106+
An optional comma-separated list of `<msg-id>=<severity>` can be passed to
107+
change the severity of some possible issues, e.g.,
108+
`--fsck-objects="missingEmail=ignore,badTagName=ignore"`. See the entry for the
109+
`fsck.<msg-id>` configuration options in linkgit:git-fsck[1] for more
110+
information on the possible values of `<msg-id>` and `<severity>`.
101111

102112
--threads=<n>::
103113
Specifies the number of threads to spawn when resolving

builtin/index-pack.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "setup.h"
2525

2626
static const char index_pack_usage[] =
27-
"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
27+
"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict[=<msg-id>=<severity>...]] [--fsck-objects[=<msg-id>=<severity>...]] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
2828

2929
struct object_entry {
3030
struct pack_idx_entry idx;
@@ -1785,8 +1785,9 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
17851785
} else if (!strcmp(arg, "--check-self-contained-and-connected")) {
17861786
strict = 1;
17871787
check_self_contained_and_connected = 1;
1788-
} else if (!strcmp(arg, "--fsck-objects")) {
1788+
} else if (skip_to_optional_arg(arg, "--fsck-objects", &arg)) {
17891789
do_fsck_object = 1;
1790+
fsck_set_msg_types(&fsck_options, arg);
17901791
} else if (!strcmp(arg, "--verify")) {
17911792
verify = 1;
17921793
} else if (!strcmp(arg, "--verify-stat")) {

t/t5300-pack-object.sh

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

444+
test_expect_success 'setup for --strict and --fsck-objects downgrading fsck msgs' '
445+
git init strict &&
446+
(
447+
cd strict &&
448+
test_commit first hello &&
449+
cat >commit <<-EOF &&
450+
tree $(git rev-parse HEAD^{tree})
451+
parent $(git rev-parse HEAD)
452+
author A U Thor
453+
committer A U Thor
454+
455+
commit: this is a commit with bad emails
456+
457+
EOF
458+
git hash-object --literally -t commit -w --stdin <commit >commit_list &&
459+
git pack-objects test <commit_list >pack-name
460+
)
461+
'
462+
463+
test_with_bad_commit () {
464+
must_fail_arg="$1" &&
465+
must_pass_arg="$2" &&
466+
(
467+
cd strict &&
468+
test_expect_fail git index-pack "$must_fail_arg" "test-$(cat pack-name).pack"
469+
git index-pack "$must_pass_arg" "test-$(cat pack-name).pack"
470+
)
471+
}
472+
473+
test_expect_success 'index-pack with --strict downgrading fsck msgs' '
474+
test_with_bad_commit --strict --strict="missingEmail=ignore"
475+
'
476+
477+
test_expect_success 'index-pack with --fsck-objects downgrading fsck msgs' '
478+
test_with_bad_commit --fsck-objects --fsck-objects="missingEmail=ignore"
479+
'
480+
481+
test_expect_success 'cleanup for --strict and --fsck-objects downgrading fsck msgs' '
482+
rm -rf strict
483+
'
484+
444485
test_expect_success 'honor pack.packSizeLimit' '
445486
git config pack.packSizeLimit 3m &&
446487
packname_10=$(git pack-objects test-10 <obj-list) &&

0 commit comments

Comments
 (0)