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

Re: [PATCH 2/2] checkout: introduce "--to-branch" option

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 13, 2021, 21:52 UTC
Message-ID
<xmqqh7bcb2am.fsf@gitster.g>
In-Reply-To
<xmqqr1agb313.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 16 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> I don't see how it's fundimentally different than the DWIM logic of
>> taking "<name>" and seeing that there's only one "refs/heads/<name>",
>> and giving up in other cases where we get ambiguous reference names that
>> we can't resolve.
>
> In that example, once you obtained a local branch whose name is
> <name>, it is obvious how you would work with that.  Your next "git
> checkout <name>" would work on the local one, and only the initial
> one does something magical.
>
> Which makes quite a lot of sense.
>
> There is no similarity in it with "--to-branch <tag>" that is being
> discussed here.

Another thing you seem to be ignoring is that it requires you to prepare in advance and keep one (and only one) dormant branch for the <tag> you will use the "--to-branch <tag>" with, because it finds the branch whose tip exactly points at the tag.

You can use the command exactly once for the <tag> and check out that branch, but then what? Once you start working on that branch, you would by definition no longer have a suitable branch that can be used to with "--to-branch <tag>", because (1) it was the only one that pointed at <tag> or you'd have gotten an error, and (2) you have moved the tip of the branch so it no longer points at the tag. And you'd expect the user to say "git branch <next-branch> <tag>" in preparation for the next time you might want to use "--to-branch <tag>" and keep that pristine?

I do not think of any similar counterpart in "teach checkout <name> to dwim and fork from a remote-tracking branch from a remote, if there is no other remote with a branch with that name" DWIMming to these nonsense.

Previous: Junio C Hamano
Message 16 of 16 in “checkout: introduce "--to-branch" option”
  1. 0/2 checkout: introduce "--to-branch" optionZheNing Hu via GitGitGadget, Dec 10, 2021
  2. 1/2 checkout: handling branch_info memory leakZheNing Hu via GitGitGadget, Dec 10, 2021
  3. Ævar Arnfjörð BjarmasonDec 10, 2021
  4. 2/2 checkout: introduce "--to-branch" optionZheNing Hu via GitGitGadget, Dec 10, 2021
  5. Christian CouderDec 10, 2021
  6. ZheNing HuDec 11, 2021
  7. Ævar Arnfjörð BjarmasonDec 10, 2021
  8. ZheNing HuDec 11, 2021
  9. Bagas SanjayaDec 10, 2021
  10. ZheNing HuDec 11, 2021
  11. Junio C HamanoDec 10, 2021
  12. ZheNing HuDec 11, 2021
  13. Junio C HamanoDec 12, 2021
  14. Ævar Arnfjörð BjarmasonDec 13, 2021
  15. Junio C HamanoDec 13, 2021
  16. Junio C HamanoDec 13, 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.