git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG] "fatal: bad object .alternate" during fetch with alternates

From
Jeff King <peff@peff.net>
Date
Nov 6, 2019, 20:59 UTC
Message-ID
<20191106205907.GA4122@sigill.intra.peff.net>
In-Reply-To
<nycvar.QRO.7.76.6.1911041053190.46@tvgsbejvaqbjf.bet>
On Wed, Nov 06, 2019 at 08:48:05PM +0100, Johannes Schindelin wrote:
Show 9 quoted lines
> Now, I think the two factors that trigger this bug over here are:
> 
> - I had all the objects locally already, as I had pushed from a topic
>   branch to `master` [*1*].
> 
> - My worktree's `.git/objects` is connected to an alternate that is
>   connected to the current Git repository (yes, it is circular, long
>   story...) and has refs pointing to commits its alternate that have
>   been gc'ed away.

I think this second one is the crux of the issue. Your alternate is a corrupt repository, and I don't think that's something we ought to be worried about supporting in general.

That said, those alternate objects should be used as UNINTERESTING traversal tips. And rev-list usually tries to avoid bailing out for missing UNINTERESTING objects. I suspect it's less aggressive about doing so for the actual tips (because usually for_each_ref()'s internal logic would skip broken refs entirely).

> So I see two problems with this error message:
> 
> - It is not helpful. It should not say `.alternate`, it should mention
>   the ref itself, and ideally even the path of the alternate.

It doesn't know the refname. The data transfer between the alternate and the borrowing repo was tightened to just pass over object names. We could probably pass the alternate path, though.

> - Shouldn't the code be made smart enough to simply ignore (maybe with a
>   warning) refs that point to gc'ed commits?
I'll take a look at the rev-list thing I mentioned above.
-Peff
Previous: Johannes SchindelinNext: Jeff King
Message 2 of 6 in “[BUG] "fatal: bad object .alternate" during fetch with alternates”
  1. Johannes SchindelinNov 6, 2019
  2. Jeff KingNov 6, 2019
  3. Jeff KingNov 6, 2019
  4. Jeff KingNov 6, 2019
  5. Johannes SchindelinNov 7, 2019
  6. Jeff KingNov 8, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.