Skip to content

Commit f62452e

Browse files
committed
Merge branch 'jt/transfer-fsck-with-promissor'
The transfer.fsckobjects configuration tells "git fetch" to validate the data and connected-ness of objects in the received pack; the code to perform this check has been taught about the narrow clone's convention that missing objects that are reachable from objects in a pack that came from a promissor remote is OK. * jt/transfer-fsck-with-promissor: fetch-pack: do not check links for partial fetch index-pack: support checking objects but not links
2 parents fddf9a2 + 98a2ea4 commit f62452e

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
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")) {

fetch-pack.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,17 @@ static int get_pack(struct fetch_pack_args *args,
886886
? fetch_fsck_objects
887887
: transfer_fsck_objects >= 0
888888
? transfer_fsck_objects
889-
: 0)
890-
argv_array_push(&cmd.args, "--strict");
889+
: 0) {
890+
if (args->from_promisor)
891+
/*
892+
* We cannot use --strict in index-pack because it
893+
* checks both broken objects and links, but we only
894+
* want to check for broken objects.
895+
*/
896+
argv_array_push(&cmd.args, "--fsck-objects");
897+
else
898+
argv_array_push(&cmd.args, "--strict");
899+
}
891900

892901
cmd.in = demux.out;
893902
cmd.git_cmd = 1;

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

t/t5616-partial-clone.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,15 @@ test_expect_success 'manual prefetch of missing objects' '
143143
test_line_count = 0 observed.oids
144144
'
145145

146+
test_expect_success 'partial clone with transfer.fsckobjects=1 uses index-pack --fsck-objects' '
147+
git init src &&
148+
test_commit -C src x &&
149+
test_config -C src uploadpack.allowfilter 1 &&
150+
test_config -C src uploadpack.allowanysha1inwant 1 &&
151+
152+
GIT_TRACE="$(pwd)/trace" git -c transfer.fsckobjects=1 \
153+
clone --filter="blob:none" "file://$(pwd)/src" dst &&
154+
grep "git index-pack.*--fsck-objects" trace
155+
'
156+
146157
test_done

0 commit comments

Comments
 (0)