Re: git fetch --prune fails with "fatal: bad object"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 06, 2024 at 01:12:31PM -0700, Fred Long wrote:

> Yeah, I saw that, and I think I know what's causing the problem. First I
> create a bare mirror of AOSP with "repo init --mirror" and "repo sync", then
> for all my different source trees I use "repo init --reference" to share
> objects with the mirror using alternates files. Running "repo sync" on the
> bare mirror works fine. The problem occurs when I run "repo sync" in one of
> my source trees. Commits and refs have been deleted from the mirror, but the
> refs are not deleted from the repos that point to the mirror. So it all
> makes sense now. Still, I wish there were a simple command I could run to
> remove the dangling refs.

Yep, that all makes sense.

As I said before, I don't think auto-deleting corrupted refs is great in
general, just because it can make a bad situation worse. But if you want
the foot-gun, here's a more complete script that you could run. It
_just_ looks in refs/remotes/, which is perhaps a bit safer.

  git for-each-ref --format='%(refname)' refs/remotes/ |
  git cat-file --batch-check='%(objectname)' |
  perl -alne 'print "delete $F[0]" if $F[1] eq "missing"' |
  tee /dev/stderr |
  git update-ref --stdin

-Peff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux