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

Re: [RFC/PATCH] Add multiple workdir support to branch/checkout

From
Jay Soffian <jaysoffian@gmail.com>
Date
Oct 6, 2011, 04:02 UTC
Message-ID
<CAG+J_DwEx9y-5B+ZppW1jURCYE2f-rkniYnRFjEtd4+spPurQA@mail.gmail.com>
In-Reply-To
<7v1uuq51c3.fsf@alter.siamese.dyndns.org>
On Wed, Oct 5, 2011 at 9:57 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 7 quoted lines
> Jay Soffian <jaysoffian@gmail.com> writes:
>> Now they do what? Either commit --force or create a new branch?
>> Wouldn't it have been better to create the new branch before they
>> started editing?
>
> If they are going to commit, and if they knew that they are going to
> commit, yes.
Committing is obviously the common case for a checked-out branch.
> But why do you want to forbid people from just checking things out if they
> are not interested in committing? That is where I think you are going
> backwards.
Because if they do decide to commit, it's now harder for them to do so.

It would be great if git could intervene after the checkout, but before they edit any files, so that they don't have uncommitted work. Obviously that's not possible, so git should prevent them from getting to that point.

Let's consider the various situations:
1. master is checked out w/edits in workdir1, user wants to work on
topic in workdir2.
There's nothing to warn about in workdir2 neither at checkout nor commit time.
2. master is checked out w/edits in workdir1, user wants examine
unedited master in workdir2
At checkout time in workdir2:

My preference: checkout advices user to use --detach or --force. Your preference: checkout is silent.

Now user decides they want to commit to master in workdir2 (which is insane, they've got uncommitted changes to it in workdir1). What happens?

In my scenario, the commit happens on a detached HEAD. When they eventually switch back to a branch, git tells them how to move their commit to a branch.

In your scenario, commit complains. User now has to --force, stash, or create a new branch.

It's just seems insane to me putting in obstacles to the user committing their work. That's where I think you are going backwards.

You have a use case where using a detached HEAD doesn't work because you've scripted around the same branch multiply checked out. I think that's probably an exceedingly rare use case, and justifies "checkout --force".

Show 6 quoted lines
>> I guess it depends what you mostly use your workdirs for. For me, it's
>> to have different branches checked out, not to have the same branch
>> checked out in multiple locations.
>
> Then you wouldn't have any problem if commit refused to make commit on the
> branch that is checked out elsewhere, no?

Yes, I would, because by that point, I've already made the mistake of checking out the same branch twice. I want git to prevent me from doing that by accident. Because I don't want to ever be in the situation which comes next, which is that I've got uncommitted work for the same branch in two places!

> I am not saying we should never have an option to _warn_ checking out the
> same branch in multiple places. I am saying it is wrong to forbid doing so
> by default.

I am not saying we should never have an option to allow checking out the same branch in multiple places. I am saying it is wrong to allow doing so by default.

j.
Previous: Junio C HamanoNext: Nguyen Thai Ngoc Duy
Message 27 of 35 in “Add multiple workdir support to branch/checkout”
  1. Add multiple workdir support to branch/checkoutJay Soffian, Oct 5, 2011
  2. Jay SoffianOct 5, 2011
  3. Nguyen Thai Ngoc DuyOct 5, 2011
  4. Jay SoffianOct 5, 2011
  5. Junio C HamanoOct 5, 2011
  6. Jay SoffianOct 5, 2011
  7. Junio C HamanoOct 5, 2011
  8. Jay SoffianOct 5, 2011
  9. Andreas KreyOct 5, 2011
  10. Jay SoffianOct 5, 2011
  11. Jonathan NiederOct 5, 2011
  12. Jay SoffianOct 5, 2011
  13. Jonathan NiederOct 5, 2011
  14. Junio C HamanoOct 5, 2011
  15. Jay SoffianOct 5, 2011
  16. Jay SoffianOct 5, 2011
  17. Nguyen Thai Ngoc DuyOct 5, 2011
  18. Junio C HamanoOct 5, 2011
  19. Nguyen Thai Ngoc DuyOct 5, 2011
  20. Junio C HamanoOct 5, 2011
  21. Jay SoffianOct 6, 2011
  22. Junio C HamanoOct 6, 2011
  23. Jay SoffianOct 6, 2011
  24. Junio C HamanoOct 6, 2011
  25. Jay SoffianOct 6, 2011
  26. Junio C HamanoOct 6, 2011
  27. Jay SoffianOct 6, 2011
  28. Nguyen Thai Ngoc DuyOct 6, 2011
  29. Bernhard R. LinkOct 6, 2011
  30. Jeff KingOct 6, 2011
  31. Nguyen Thai Ngoc DuyOct 5, 2011
  32. Junio C HamanoOct 5, 2011
  33. Jay SoffianOct 5, 2011
  34. Jay SoffianOct 5, 2011
  35. Julián LanderrecheOct 8, 2011

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.