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

Re: Bug report: git branch behaves as if --no-replace-objects is passed

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 30, 2021, 23:04 UTC
Message-ID
<xmqqlfa4b5we.fsf@gitster.g>
In-Reply-To
<CABPp-BEVFi+EsGMCv=qEhe_OGwmWwXF-mg9rjWYNuF0tDZnASg@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
Show 7 quoted lines
> Your "as long as" is I think the assumption that's violated in the
> workflow in question.  You may have the replace ref defined, but
> others don't[1].  Neither party has the actual original deadbeef
> commit[2].  Having deadbeef in refs/heads/foobar leads eventually to
> creating commits with deadbeef as an explicit parent, as we discussed
> above.  While that's internally consistent, as you point out, can you
> push your new commit elsewhere without pushing the replace refs too?

I think the change to "branch --contains" would be an improvement whether you actually have deadbeef or not, but in any case, defining (eh, rather, being able to define) a replacement for something you do not have is the ultimate source of the problem. And that "bug" has not very much specific to how "branch --contains" should behave.

> Why does `git branch` (in conjunction with one user deciding to fetch
> replace refs) make it so easy to create a branch that cannot readily
> be shared with others?

In other words, I do not think it is "git branch" or "git checkout -b" that brought your repository into a broken state. The "replace" mechanism may have room for improvement to avoid such a corruption.

IIRC, the original "graft" mechanism did not even have any UI, so it was pretty much "you can graft any parent to any child, and if you break the repository you can keep both halves". Now "replace" has a dedicated UI component in the form of "git replace" command, we should be able to teach it how to record replacement more safely.

Previous: Elijah NewrenNext: Elijah Newren
Message 9 of 10 in “Bug report: git branch behaves as if --no-replace-objects is passed”
  1. Elijah NewrenMar 30, 2021
  2. Jeff KingMar 30, 2021
  3. Junio C HamanoMar 30, 2021
  4. Elijah NewrenMar 30, 2021
  5. Elijah NewrenMar 30, 2021
  6. Junio C HamanoMar 30, 2021
  7. Junio C HamanoMar 30, 2021
  8. Elijah NewrenMar 30, 2021
  9. Junio C HamanoMar 30, 2021
  10. Elijah NewrenMar 31, 2021

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.