On Sun, Jan 05, 2025 at 09:50:31PM +0800, shejialuo wrote: > diff --git a/refs/packed-backend.c b/refs/packed-backend.c > index d83ce2838f..df65fec5a5 100644 > --- a/refs/packed-backend.c > +++ b/refs/packed-backend.c > @@ -1980,6 +1989,50 @@ static int packed_fsck_ref_oid(struct fsck_options *o, struct ref_store *ref_sto > return ret; > } > > +static int packed_fsck_ref_sorted(struct fsck_options *o, > + struct ref_store *ref_store, > + struct fsck_packed_ref_entry **entries, > + int nr) > +{ > + size_t hexsz = ref_store->repo->hash_algo->hexsz; > + struct strbuf packed_entry = STRBUF_INIT; > + struct fsck_ref_report report = { 0 }; > + struct strbuf refname1 = STRBUF_INIT; > + struct strbuf refname2 = STRBUF_INIT; > + int ret = 0; > + > + for (int i = 1; i < nr; i++) { > + const char *r1 = entries[i - 1]->record.start + hexsz + 1; > + const char *r2 = entries[i]->record.start + hexsz + 1; > + > + if (cmp_packed_refname(r1, r2) >= 0) { Makes sense. It has been a source of bugs a couple years ago, and it can silently make you receive wrong results, so this is quite a sensible check to have. Patrick