fix git-annex repair false positive

Avoid treating refs/annex/last-index or other refs that are not commit
objects as evidence of repository corruption.

The repair code checks to find bad refs by trying to run `git log` on
them, and assumes that no output means something is broken.  But git log
on a tree object is empty.

This was worth fixing generally, not as a special case, since it's certainly
possible that other things store tree or other objects in refs.

Sponsored-by: Max Thoursie on Patreon
This commit is contained in:
Joey Hess 2022-05-04 11:32:23 -04:00
parent d0b1ecf464
commit 0406c33f58
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 39 additions and 12 deletions

View file

@ -45,4 +45,4 @@ The bug is very easy to reproduce. This happens in a bigger repository of mine,
Using it daily, with small-sized repositories.
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,14 @@
[[!comment format=mdwn
username="joey"
subject="""comment 3"""
date="2022-05-04T15:06:31Z"
content="""
Thank you, your "Reproducible Example" worked for me to reproduce it!
Great work finding this and tracking down an easy way to reproduce it.
So the root of the problem is refs/annex/last-index,
which contains a tree object, not a commit object. That is unusual for a ref,
but git-annex has a good reason to record a tree's ref there.
Fixed
"""]]