Subject: Re: fetch and bundle don't work in (semi-)broken repo

From: Uwe Kleine-König <[email-masked]>
Date: Wed, 20 Oct 2010 09:59:45 +0200

Hello,

On Tue, Oct 19, 2010 at 04:48:23PM -0400, Nicolas Pitre wrote:
> On Tue, 19 Oct 2010, Uwe Kleine-König wrote:
> 
> > Hi Jonathan,
> > 
> > On Tue, Oct 19, 2010 at 01:39:25PM -0500, Jonathan Nieder wrote:
> > > Uwe Kleine-König wrote:
> > > 
> > > > 	ukl@hostname:~/path1/linux-2.6$ git fetch ~/path2/linux-2.6 sectionmismatches
> > > > 	remote: Counting objects: 118, done.
> > > > 	remote: error: unable to find 40aaeb204dc04d3cf15c060133f65538b43b13b0
> > > > 	remote: Compressing objects: 100% (83/83), done.
> > > > 	remote: fatal: unable to read 40aaeb204dc04d3cf15c060133f65538b43b13b0
> > > > 	error: git upload-pack: git-pack-objects died with error.
> > > > 	fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
> > > 
> > > Sounds like alternates or workdir allowed gc to be overzealous, indeed.
> > > 
> > > Could you:
> > > 
> > >  1. Make a copy of the corrupted repo, just in case.
> > >  2. Explode all backs with "git unpack-objects"
> 
> That's usually unnecessary.  If the pack itself is corrupted, trying to 
> unpack it all won't help.
> 
> > I did:
> > 
> > 	mv .git/objects/pack .git/objects/pack.bak
> > 	rm .git/objects/info/alternates
> > 	for p in .git/objects/pack.bak/*.pack ~/path1/linux-2.6/.git/objects/pack/*.pack; do
> > 		git unpack-objects < $p
> > 	done
> 
> Ouch!  You will end up with a multi-gigabyte repository, which will be 
> abominably slow.
> 
> > >  3. Identify the missing object, as explained in
> > >     Documentation/howto/recover-corrupted-blob-object.txt?
> 
> That's useful when you have only one corrupted object and you want to 
> recreate it from raw material.  But ideally you should simply find a 
> pack that contains the problematic object in another repository and copy 
> it with its index 
> file into the broken repository.
> 
> > and I'm running git-fsck --full now over night as it's bedtime here.
> 
> Given that you exploded your repo into loose objects, it'll take _time_.
Well it took 34 minutes, which is OK I guess.

I will study the output a bit now.

For the interested (all lines matching "dangling" removed):

	22:10:57 I: Started git fsck --full
	22:44:14 O: broken link from    tree 519af383e181399db929823299bbd14c04b4229a
	22:44:14 O: to    tree d58c333c44672cb933df5a353dfb63ac571964e8
	22:44:14 O: broken link from  commit e8f7f6a23979c398249a15fb71b3e52dae933fa3
	22:44:14 O: to    tree 7f22979d86cf00c8bd3487feb973353ab5a1beee
	22:44:14 O: broken link from  commit 3164f6598ae44703a89822ced9746c1876ba7fab
	22:44:14 O: to    tree 1017bb1f45b8527ee3c7cfc30288b8098bcf0915
	22:44:14 O: broken link from  commit 124dde2ea387dc9509b0a5574c6f44f7d348a65d
	22:44:14 O: to    tree e4d0ac236995847e4e1d15c6d0afb47787255703
	22:44:14 O: broken link from  commit 60deff2fffd90b217d90284295d5a910f21fe98e
	22:44:14 O: to    tree 18bb32cfd08228820f929d62e63933fe2896b424
	22:44:14 O: broken link from  commit 0b84e651b84dba73772fda15a8a66de8cc274af0
	22:44:14 O: to    tree f8939a09d73b78459381b7991423529592e66324
	22:44:14 O: broken link from  commit e0de1d3c3355f9b1e3474417f05657a1041e7c8a
	22:44:14 O: to    tree 776ad9ac45dab11f2644151a690e1035789a49b6
	22:44:14 O: broken link from  commit 76d1acb95eef413a2501a63cb7f7f4036b71ed37
	22:44:14 O: to  commit f6b6cb2336198913371e66664f28c135df01aea5
	22:44:14 O: broken link from    tree bb473ad85c260b6a1659aa2059cac23b337842e3
	22:44:14 O: to    tree e035bc14698cc3e9abfca1a174feacb25e7e262a
	22:44:14 O: broken link from    tree bb473ad85c260b6a1659aa2059cac23b337842e3
	22:44:14 O: to    tree 8908b2458c1a2c6a6db81e88d96a01aa9a89abe5
	22:44:14 O: broken link from    tree ee35b3a549f45830ed50eb1032836a71ab2b7886
	22:44:14 O: to    tree f2f33722af4b5e32ac17f914cf24cc96c6e80077
	22:44:14 O: broken link from    tree ee35b3a549f45830ed50eb1032836a71ab2b7886
	22:44:14 O: to    tree 70f0188991b8406ec6ec75a504cf50c778fc1001
	22:44:14 O: broken link from    tree 1772732da7d4751d3c0febd7b0ceee61a84702f0
	22:44:14 O: to    tree dc3c1a018fcf2797a860af0cb899fe6be1173da3
	22:44:14 O: broken link from    tree 1772732da7d4751d3c0febd7b0ceee61a84702f0
	22:44:14 O: to    tree 2ade2c0731e57fc6b1baddb6faf683847d706179
	22:44:14 O: broken link from    tree 1772732da7d4751d3c0febd7b0ceee61a84702f0
	22:44:14 O: to    tree 659f4a6280150b7ae7b8f824257ad3cbb7cd1788
	22:44:14 O: broken link from    tree f29915a03ea5ba8739aacfcbb349d40b019481ed
	22:44:14 O: to    tree b52d608d7743b1e096725d4b8d7c7769b19f6674
	22:44:15 O: missing tree 7f22979d86cf00c8bd3487feb973353ab5a1beee
	22:44:15 O: missing tree 70f0188991b8406ec6ec75a504cf50c778fc1001
	22:44:15 O: missing tree dc3c1a018fcf2797a860af0cb899fe6be1173da3
	22:44:15 O: missing tree f8939a09d73b78459381b7991423529592e66324
	22:44:15 O: missing tree e4d0ac236995847e4e1d15c6d0afb47787255703
	22:44:15 O: missing tree 2ade2c0731e57fc6b1baddb6faf683847d706179
	22:44:15 O: missing tree 8908b2458c1a2c6a6db81e88d96a01aa9a89abe5
	22:44:15 O: missing tree 18bb32cfd08228820f929d62e63933fe2896b424
	22:44:15 O: missing tree d58c333c44672cb933df5a353dfb63ac571964e8
	22:44:15 O: missing tree f2f33722af4b5e32ac17f914cf24cc96c6e80077
	22:44:16 O: missing tree 1017bb1f45b8527ee3c7cfc30288b8098bcf0915
	22:44:16 O: missing tree e035bc14698cc3e9abfca1a174feacb25e7e262a
	22:44:16 O: missing tree 659f4a6280150b7ae7b8f824257ad3cbb7cd1788
	22:44:16 O: missing commit f6b6cb2336198913371e66664f28c135df01aea5
	22:44:16 O: missing tree 776ad9ac45dab11f2644151a690e1035789a49b6
	22:44:16 O: missing tree b52d608d7743b1e096725d4b8d7c7769b19f6674
	22:44:16 O: missing blob 40aaeb204dc04d3cf15c060133f65538b43b13b0

Here is the output for the object bundle and fetch wail about, but
nothing about a tree that would need it :-(  Actually it's the only one
of the missing objects that is not described above (and it's the only
blob).

	22:44:17 I: Finished with exitcode 2

Now I'm running

	git for-each-ref | while read sha type name; do
		echo $name;
		git log --raw --full-history $sha | grep 40aaeb204dc04d3cf15c060133f65538b43b13b0;
	done

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |