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

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 6, 2019, 19:48 UTC
Message-ID
<nycvar.QRO.7.76.6.1911041053190.46@tvgsbejvaqbjf.bet>
Hi Peff,

I only saw this problem arise on Sunday and wrote it off as a fluke while fetching in parallel, but it persisted today, under more controlled circumstances. I wanted to fast-forward a local branch:

$ git fetch origin master:master fatal: bad object .alternate error: https://github.com/git-for-windows/git did not send all necessary objects

`git grep`ing around, I saw that you added the code producing that error message, in 39b44ba771a (check_everything_connected: assume alternate ref tips are valid, 2019-07-01) and I verified manually through a combination of debugging and instrumenting that `add_one_alternate_ref()` is indeed responsible for that `.alternate`.

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.
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.
- Shouldn't the code be made smart enough to simply ignore (maybe with a
  warning) refs that point to gc'ed commits?

Ciao, Dscho

Footnote *1*: No, I do not usually push directly to `master`. The scenario here is that I had rebased Git for Windows' patches on top of v2.24.0, opened a PR for the PR build, everything checked out all right, and then I wanted to "merge" the PR, _without_ an extra merge commit on top.

Next: Jeff King
Message 1 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.