Re: [PATCH v3 10/21] checkout: split part of it to new command 'switch'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 28, 2019 at 4:04 AM Duy Nguyen <pclouds@xxxxxxxxx> wrote:
>
> On Wed, Mar 27, 2019 at 5:24 PM Phillip Wood <phillip.wood123@xxxxxxxxx> wrote:
> >
> > On 26/03/2019 15:48, Elijah Newren wrote:
> > > On Tue, Mar 26, 2019 at 8:24 AM Duy Nguyen <pclouds@xxxxxxxxx> wrote:
> > >> On Tue, Mar 26, 2019 at 10:01 PM Elijah Newren <newren@xxxxxxxxx> wrote:
> > >
> > >> Yeah.. --ignore-in-process does not necessarily mean aborting
> > >> something when you just want to get out to examine some other commit.
> > >> And I agree doing nothing seems like the best (or least
> > >> confusing/surprising) option.
> > >>
> > >> There will be some funny thing. Like if you commit after switching
> > >> away and MERGE_HEAD is there, I think you will be creating a merge
> > >> commit.
> > >
> > > Yes, and in the middle of a cherry-pick with a range you've added some
> > > commits to one branch and some to another.  In the middle of a revert
> > > you're doing similar.  It sounds like crazytown to me (and maybe we
> > > shouldn't provide the --ignore-in-process flag unless users clamor for
> > > it
>
> I missed this part in my last reading. I think if we could safely
> switch away and get back to resume, then --ignore-in-process could
> still be useful. I sometimes switch to another commit to check out
> stuff then back. For interactive rebase with "edit" command for
> example, it's quite safe to do so. (yes the other option is "git
> worktree add", but that could be a heavy hammer sometimes)

Ah, switching not for the purpose of continuing the operation
elsewhere, but just to check things out with the intent of coming back
before continuing.  That does make sense.  Please do add a warning
when users do it, though.

> > I think that could be the way to go for merges and cherry-picks, or
>
> Just so we're clear, what is your "the way" to go? to remove
> CHERRY_HEAD_PICK and MERGE_HEAD (and other MERGE_* as well) if
> --ignore-in-process is specified? Or to leave MERGE_* and
> CHERRY_PICK_HEAD alone and delete other stuff?

Personally, I don't think `switch` should modify in-process state of
other operations ever.  Not merge state, not cherry-pick state, not
rebase state, not bisect state, etc.  And default should be for it to
error out if any such state exists.  In-process state should be
updated almost exclusively by `<operation>
--(continue|abort|skip|quit)` (or in bisect's case, the
bad/good/skip/reset commands).  They only reason I put the 'almost'
qualifier in there is that I'm not opposed to the _reset_ command
continuing to do some things with state because of backward
compatibility (and I might begrudgingly admit the same for other
commands if they touch it though I'm tempted to say any command other
than reset and the operation itself that touches in-process state
represents a bug that should be fixed).  However, I very much want to
steer users away from using reset (or other commands) to change state
and guide them to instead use `<operation>
--(continue|abort|skip|quit)`.  I think we make things confusing and
do users a disservice by not having in-process state be a totally
orthogonal thing that is only updated by that process's subcommand.

If people use --ignore-in-process, I think the state should remain and
we should give a big warning to the user about how the operation is
still in progress and likely to give very confusing results and
suggest either switching back to the current commit or running
`<operation> --quit` for them to clear it.

Also, if --ignore-in-process still fails because they need
--discard-changes too, then we could give a really obnoxious warning
about how they should probably consider --quit first if they really
want to switch.

> > possibly require --discard-changes as well. The only time I use checkout
> > like this is during a rebase if I want to rewind it - I edit the todo
> > list with the output of 'git log --pretty="pick %h %s" --reverse' and do
> > 'git checkout' followed by 'git rebase --continue' Though these days I
> > could add a 'reset' line to the todo list and skip the checkout.

I think Phillip's usecase is entirely consistent with the
don't-have-switch-touch-process-state view.


Hope that helps,
Elijah



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux