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

Re: Should --update-refs exclude refs pointing to the current HEAD?

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 5, 2024, 16:22 UTC
Message-ID
<xmqqsf144pi7.fsf@gitster.g>
In-Reply-To
<354f9fed-567f-42c8-9da9-148a5e223022@haller-berlin.de>
Stefan Haller <lists@haller-berlin.de> writes:
>> Both of these cases could be fixed by --update-refs not touching any
>> refs that point to the current HEAD. I'm having a hard time coming up
>> with cases where you would ever want those to be updated, in fact.

The point of "update-refs", as I understand it, is that in addition to the end point of the history (E in "git rebase --onto N O E"), any branch tips that are between O..E can be migrated to point at their rewritten counterparts. So I am not sure how it fundamentally solves much by protecting only refs that point at a single commit ("the current HEAD" in your statement).

When I want to see how the rebased history would look like without touching the original, I often rebase a detached HEAD (i.e. instead of the earlier one, use "git rebase --onto N O E^0", or when rebasing the current branch, "git rebase [--onto N] O HEAD^0") and that would protect the current branch well, but --update-refs of course would not work well. There is no handy place like detached HEAD that can be used to save rewritten version of these extra branch tips.

If branch tips A, B, and C are involved in the range of commits being rewritten, one way to help us in such a situation may be to teach "git rebase" to (1) somehow create a new set of proposed-A, proposed-B, and proposed-C refs (they do not have to be branches), while keeping the original A, B, and C intact, (2) allow us to inspect the resulting refs, compare the corresponding ones from these two sets, and (3) allow us to promote (possibly a subset of) proposed- ones to their counterpart real branches after we inspect them. The latter two do not have to be subcommands of "git rebase" but can be separate and new commands.

Previous: Stefan HallerNext: Elijah Newren
Message 9 of 18 in “Should --update-refs exclude refs pointing to the current HEAD?”
  1. Stefan HallerApr 17, 2023
  2. Stefan HallerApr 17, 2023
  3. Kristoffer HaugsbakkApr 17, 2023
  4. Stefan HallerApr 17, 2023
  5. Felipe ContrerasApr 18, 2023
  6. Phillip WoodApr 17, 2023
  7. Stefan HallerApr 20, 2023
  8. Stefan HallerMar 5, 2024
  9. Junio C HamanoMar 5, 2024
  10. Elijah NewrenMar 6, 2024
  11. Stefan HallerMar 6, 2024
  12. Elijah NewrenMar 7, 2024
  13. Stefan HallerMar 7, 2024
  14. Elijah NewrenMar 9, 2024
  15. Stefan HallerMar 12, 2024
  16. Kristoffer HaugsbakkMar 7, 2024
  17. Elijah NewrenMar 7, 2024
  18. Stefan HallerMar 24, 2024

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.