index-pack: support checking objects but not links
The index-pack command currently supports the --check-self-contained-and-connected argument, for internal use only, that instructs it to only check for broken links and not broken objects. For partial clones, we need the inverse, so add a --fsck-objects argument that checks for broken objects and not broken links, also for internal use only. This will be used by fetch-pack in a subsequent patch. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Tan committed
Mar 14, 2018 at 11:42 UTC
ffb2c0fe5c2dbfe2be0a4743ffed622295e1124c
3 files changed
+12
-2
Documentation/git-index-pack.txt
+3
@@ -77,6 +77,9 @@ OPTIONS
77
--check-self-contained-and-connected::
78
Die if the pack contains broken links. For internal use only.
79
80
+--fsck-objects::
81
+ Die if the pack contains broken objects. For internal use only.
82
+
83
--threads=<n>::
84
Specifies the number of threads to spawn when resolving
85
deltas. This requires that index-pack be compiled with
builtin/index-pack.c
+4
-2
@@ -828,7 +828,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
828
free(has_data);
829
}
830
831
- if (strict) {
831
+ if (strict || do_fsck_object) {
832
read_lock();
833
if (type == OBJ_BLOB) {
834
struct blob *blob = lookup_blob(oid);
@@ -854,7 +854,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
854
if (do_fsck_object &&
855
fsck_object(obj, buf, size, &fsck_options))
856
die(_("Error in object"));
857
- if (fsck_walk(obj, NULL, &fsck_options))
857
+ if (strict && fsck_walk(obj, NULL, &fsck_options))
858
die(_("Not all child objects of %s are reachable"), oid_to_hex(&obj->oid));
859
860
if (obj->type == OBJ_TREE) {
@@ -1689,6 +1689,8 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1689
} else if (!strcmp(arg, "--check-self-contained-and-connected")) {
1690
strict = 1;
1691
check_self_contained_and_connected = 1;
1692
+ } else if (!strcmp(arg, "--fsck-objects")) {
1693
+ do_fsck_object = 1;
1694
} else if (!strcmp(arg, "--verify")) {
1695
verify = 1;
1696
} else if (!strcmp(arg, "--verify-stat")) {
t/t5302-pack-index.sh
+5
@@ -262,4 +262,9 @@ EOF
262
grep "^warning:.* expected .tagger. line" err
263
'
264
265
+test_expect_success 'index-pack --fsck-objects also warns upon missing tagger in tag' '
266
+ git index-pack --fsck-objects tag-test-${pack1}.pack 2>err &&
267
+ grep "^warning:.* expected .tagger. line" err
268
+'
269
+
270
test_done