diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-03-05 10:04:49 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-03-05 10:04:49 -0800 |
| commit | d93be9cbcaf80f4d1ff56a3d7aa5d722236b6eac (patch) | |
| tree | 2febbd0e230148934704a2eebe27fcd7d58780c4 /pack-check.c | |
| parent | db227bce2224b55b11954a5f292a0b035b7d9279 (diff) | |
| parent | 13eb65d36615d7269df053015bddf7987ef6d923 (diff) | |
| download | git-d93be9cbcaf80f4d1ff56a3d7aa5d722236b6eac.tar.xz | |
Merge branch 'ps/fsck-stream-from-the-right-object-instance'
"fsck" iterates over packfiles and its access to pack data caused
the list to be permuted, which caused it to loop forever; the code
to access pack data by "fsck" has been updated to avoid this.
* ps/fsck-stream-from-the-right-object-instance:
pack-check: fix verification of large objects
packfile: expose function to read object stream for an offset
object-file: adapt `stream_object_signature()` to take a stream
t/helper: improve "genrandom" test helper
Diffstat (limited to 'pack-check.c')
| -rw-r--r-- | pack-check.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/pack-check.c b/pack-check.c index 67cb2cf72f..7378c80730 100644 --- a/pack-check.c +++ b/pack-check.c @@ -9,6 +9,7 @@ #include "packfile.h" #include "object-file.h" #include "odb.h" +#include "odb/streaming.h" struct idx_entry { off_t offset; @@ -104,6 +105,7 @@ static int verify_packfile(struct repository *r, QSORT(entries, nr_objects, compare_entries); for (i = 0; i < nr_objects; i++) { + struct odb_read_stream *stream = NULL; void *data; struct object_id oid; enum object_type type; @@ -152,7 +154,9 @@ static int verify_packfile(struct repository *r, type) < 0) err = error("packed %s from %s is corrupt", oid_to_hex(&oid), p->pack_name); - else if (!data && stream_object_signature(r, &oid) < 0) + else if (!data && + (packfile_read_object_stream(&stream, &oid, p, entries[i].offset) < 0 || + stream_object_signature(r, stream, &oid) < 0)) err = error("packed %s from %s is corrupt", oid_to_hex(&oid), p->pack_name); else if (fn) { @@ -163,12 +167,14 @@ static int verify_packfile(struct repository *r, } if (((base_count + i) & 1023) == 0) display_progress(progress, base_count + i); - free(data); + if (stream) + odb_read_stream_close(stream); + free(data); } + display_progress(progress, base_count + i); free(entries); - return err; } |
