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

Re: [PATCH] checkout: add config variable checkout.autoDetach

From
Andy Koppe <andy.koppe@gmail.com>
Date
Nov 12, 2023, 09:15 UTC
Message-ID
<859a0c38-b7cd-4d6b-a4c8-c530fbe6e928@gmail.com>
In-Reply-To
<xmqqbkbzo6ba.fsf@gitster.g>
On 12/11/2023 06:04, Junio C Hamano wrote:
Show 19 quoted lines
> Andy Koppe <andy.koppe@gmail.com> writes:
> 
>> The git-checkout command without pathspecs automatically detaches HEAD
>> when switching to something other than a branch, whereas git-switch
>> requires the --detach option to do so.
>>
>> Add configuration variable checkout.autoDetach to choose the behavior
>> for both: true for automatic detaching, false for requiring --detach.
>>
>> Amend their documentation and tests accordingly.
>>
>> Signed-off-by: Andy Koppe <andy.koppe@gmail.com>
>> ---
> 
> "switch" was meant to be an experimental command to sort out this
> kind of UI ideas, and I think the fact that it requires a more
> explicit "--detach", where experienced users might just say "git
> checkout that-branch^0", has established itself as a more friendly
> and good thing to help new users. 

I agree, but as an experienced user, I nevertheless prefer switch and restore over checkout, because those are rather different tasks, and with checkout you're only ever a small thinko and errant dot away from losing your local changes. If switch and restore had existed first, I don't think anyone would be asking for mashing them together.

Incidentally, as reset is similarly overloaded, and restore can also replace the forms of reset that take pathspec arguments, was there a similar plan to factor the head-moving forms of reset out into a separate command? (I realise there'd be little appetite for that after the switch/restore experiment.)

> I do not know how others react to
> this kind of proliferation of configuration variables, but I do not
> mind this particular variable existing.

Thanks. There's also the checkout.guess variable as a closely related precedent.

Regards, Andy

Previous: Junio C HamanoNext: Phillip Wood
Message 3 of 5 in “checkout: add config variable checkout.autoDetach”
  1. checkout: add config variable checkout.autoDetachAndy Koppe, Nov 11, 2023
  2. Junio C HamanoNov 12, 2023
  3. Andy KoppeNov 12, 2023
  4. Phillip WoodNov 13, 2023
  5. Junio C HamanoNov 14, 2023

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.