Jeff King <peff@xxxxxxxx> 于2021年9月8日周三 上午1:28写道: > > On Mon, Sep 06, 2021 at 09:30:45PM +0800, ZheNing Hu wrote: > > > Jeff King <peff@xxxxxxxx> 于2021年9月5日周日 下午8:49写道: > > > > > > On Sun, Sep 05, 2021 at 04:19:53PM +0800, ZheNing Hu wrote: > > > > > > > > In this version there are 2 patches, tested against 'git for-each-ref > > > > > --format="%(objectname) %(refname)"' on a fully packed repo with 500k > > > > > refs: > > > > > > > > > > > > > Regarding this 500k refs, is there any way I can reproduce it? > > > > > > Try this in a clone of linux.git (or any other repo): > > > > > > git rev-list HEAD | > > > head -500000 | > > > perl -lne 'print "create refs/foo/$. $_"' | > > > git update-ref --stdin > > > > > > git pack-refs --all --prune > > > > > > > Sorry, It seems that the above command is difficult to complete on my > > machine (it took more than ten minutes). It may be stuck on git update-ref. > > So I tried to reproduce it in a repo which containing 76K refs: > > Mine didn't take nearly that wrong, but it does depend on filesystem and > disk performance. It's going to create 500k lock files in refs/foo. :) > > You can cheat a bit like this: > > { > # grab existing packed refs; don't worry about peel lines or the > # header comment, we're producing a lowest-common denominator > # version of the file > grep '^[0-9a-f]' packed-refs > > # now make our new fake refs > git rev-list HEAD | > head -500000 | > perl -lne 'print "$_ refs/foo/$."' > } >packed-refs.tmp > mv packed-refs.tmp packed-refs > > # and now ask Git to repack to get everything sorted, etc > git pack-refs --all --prune > > It sounds like you were able to come up with a smaller version to play > with anyway, but I enjoy coming up with such hacks. :) > Thanks, this method really works. :-) > -Peff -- ZheNing Hu