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
SHStefan Haller <lists@haller-berlin.de>
Date
Apr 20, 2023, 15:27 UTC
Message-ID
<2db5c4a5-533a-f004-cf26-7ef938d1f94d@haller-berlin.de>
In-Reply-To
<98548a5b-7d30-543b-b943-fd48d8926a33@gmail.com>
On 17.04.23 14:14, Phillip Wood wrote:
Show 16 quoted lines
> On 17/04/2023 09:21, Stefan Haller wrote:
>> 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.
> 
> If a user using stacked branches creates a new branch and then realizes
> they need to fix something on the parent before creating any commits on
> the new branch they would want both to be updated. e.g.   
>     $ git symbolic-ref HEAD
>     refs/heads/topic
>     $ git checkout -b another-topic
>     # fix a bug in topic - want topic and another-topic to be
>     # updated
>     $ git rebase -i --update-refs HEAD~2

OK, this is indeed one situation where my proposed change would do the wrong thing.

It is of course impossible for git to tell whether you were meaning to create a stack of branches here, or whether this is one of the cases where I'm creating a copy of a branch and want to "detach" it from its source branch, as in the examples I posted earlier in this thread.

In my personal experience the latter is much more common than the former, and it's also easier to correct the mistake manually in your example by hard-resetting one branch to the other again, so I still think it would be a useful change.

Any other opinions about this?
-Stefan
Previous: Phillip WoodNext: Stefan Haller
Message 7 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.