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

Re: [PATCH v2] checkout: teach --worktree

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Jun 24, 2020, 10:20 UTC
Message-ID
<dd17f82a-f5b3-d57e-d296-c1b5ecc8c1f5@gmail.com>
In-Reply-To
<20200623155538.GA2014954@generichostname>
Hi Denton
On 23/06/2020 16:55, Denton Liu wrote:
Show 15 quoted lines
> Hi Phillip,
> 
> Sorry for the late reply.
> 
> On Tue, Jun 16, 2020 at 05:01:53PM +0100, Phillip Wood wrote:
>> I'm afraid I'm not sure that adding another option to `git checkout` is a
>> good idea. The behavior of `git checkout` is already complicated enough
>> which is why we ended up with switch and restore separating out branch
>> switching from file updating.
> 
> I think that since this option clearly applies only for a
> restore-type action and there are checks in place to ensure that
> the user is not attempting to use it for a switch-type action, it
> doesn't introduce much more complexity than the `git restore --worktree`
> option does.

It introduces more complexity to checkout by existing. The point I was trying to make was that checkout is complicated to use and adding more features makes that problem worse. As to being obvious that it applies to a restore-type action, when I first saw the patch subject line my immediate thought was that it was going to be doing something with worktrees.

I am worried that people will think 'checkout --worktree' is the same as 'restore --worktree' but it isn't it's the same as 'restore --overlay --worktree'. Having subtle differences like this between commands is confusing for users and wastes our time answering queries about the difference on the mailing list. It is not possible to make 'checkout --worktree' imply --no-overlay as that would be inconsistent with 'checkout <pathspec>'

Show 7 quoted lines
> 
>> Given `git restore` provides a way to update the worktree without touching
>> the index I'm not convinced we should be further complicating `git checkout`
>> especially as it defaults to --overlay unless -p is given which is confusing
>> in itself.
> 
> I don't think it'll hurt to provide more than one way of doing it.

I disagree, it is confusing to users if they see one person saying "use checkout" and another "use restore". They will wonder if there is a difference between them and which one is better. It's to be expected that there will be some overlap in functionality between commands as git grows and adds new commands but in this case we're adding functionality that already exists. There was a lot of thought and discussion put into designing and implementing 'switch' and 'restore' to make more predictable and easier for users to understand, adding more options to 'checkout' under cuts that by muddying the waters on which command should be used.

Show 6 quoted lines
> As a
> pretty long-time user of git, I've been having trouble picking up the
> switch/restore commands in favour of good ol' checkout due to muscle
> memory. I agree that I should try and switch over to these new commands
> but old habits die hard and I think it would be much easier to just
> provide this option to checkout.

While I have sympathy with that (I still use checkout myself a lot of the time) it's hard to argue you have a muscle memory for an option that does not exist!

Best Wishes
Phillip
> Thanks,
> 
> Denton
> 
Previous: Denton Liu
Message 9 of 9 in “checkout: teach --worktree”
  1. checkout: teach --worktreeDenton Liu, Jun 13, 2020
  2. Eric SunshineJun 14, 2020
  3. Denton LiuJun 14, 2020
  4. Denton LiuJun 14, 2020
  5. Junio C HamanoJun 14, 2020
  6. checkout: teach --worktreeDenton Liu, Jun 14, 2020
  7. Phillip WoodJun 16, 2020
  8. Denton LiuJun 23, 2020
  9. Phillip WoodJun 24, 2020

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.