Skip to content

Commit ffb2c0f

Browse files
jonathantanmygitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7fb6aef commit ffb2c0f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Documentation/git-index-pack.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ OPTIONS
7777
--check-self-contained-and-connected::
7878
Die if the pack contains broken links. For internal use only.
7979

80+
--fsck-objects::
81+
Die if the pack contains broken objects. For internal use only.
82+
8083
--threads=<n>::
8184
Specifies the number of threads to spawn when resolving
8285
deltas. This requires that index-pack be compiled with

builtin/index-pack.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
828828
free(has_data);
829829
}
830830

831-
if (strict) {
831+
if (strict || do_fsck_object) {
832832
read_lock();
833833
if (type == OBJ_BLOB) {
834834
struct blob *blob = lookup_blob(oid);
@@ -854,7 +854,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
854854
if (do_fsck_object &&
855855
fsck_object(obj, buf, size, &fsck_options))
856856
die(_("Error in object"));
857-
if (fsck_walk(obj, NULL, &fsck_options))
857+
if (strict && fsck_walk(obj, NULL, &fsck_options))
858858
die(_("Not all child objects of %s are reachable"), oid_to_hex(&obj->oid));
859859

860860
if (obj->type == OBJ_TREE) {
@@ -1689,6 +1689,8 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
16891689
} else if (!strcmp(arg, "--check-self-contained-and-connected")) {
16901690
strict = 1;
16911691
check_self_contained_and_connected = 1;
1692+
} else if (!strcmp(arg, "--fsck-objects")) {
1693+
do_fsck_object = 1;
16921694
} else if (!strcmp(arg, "--verify")) {
16931695
verify = 1;
16941696
} else if (!strcmp(arg, "--verify-stat")) {

t/t5302-pack-index.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,9 @@ EOF
262262
grep "^warning:.* expected .tagger. line" err
263263
'
264264

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+
265270
test_done

0 commit comments

Comments
 (0)