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

Re: [PATCH] checkout: do not switch branch during a rebase unless -f is given

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Sep 28, 2010, 05:47 UTC
Message-ID
<AANLkTin19PREB3B68s+ejsgtXwe3CBxZF-caCvRp4UXv@mail.gmail.com>
In-Reply-To
<AANLkTinUudOXmhKW-+rkcpzb-VNnSBLZwGZcjrS6UdMu@mail.gmail.com>
2010/9/28 Jonathan Nieder <jrnieder@gmail.com>:
Show 13 quoted lines
> (+cc: Frédéric, Dscho, Christian)
>
> Nguyễn Thái Ngọc Duy wrote:
>
>> It does not make much sense to switch branch when you are in a middle
>> of a rebase. Sometimes you might want to switch away for a moment then
>> back with "git checkout - ". But I find myself so many times switching
>> away then forget that I was rebasing something.
>>
>> Avoid doing that by default. Users can use -f if they really want to.
>
> Nice! But I worry is that scripts that use "git checkout" porcelain
> during a rebase would be broken.

Right. I used git-rebase from my installation, the new "git checkout" from worktree and missed that as a result.

Show 16 quoted lines
> Even rebase --interactive uses checkout from time to time:
>
>  - for preserving merges
>  - to move to the correct branch in response to "git rebase -i
> <upstream> <branch>"
>  - to move to the target in "git rebase -i --onto <new base> <upstream>"
>
> Unfortunately I do not have any good advice. Would it make sense to
>
>  - first, change these call sites in git to use checkout -f
>  - teach checkout to warn (without erroring out) to give people time
> to change their scripts
>  - warn loudly about the upcoming change in the release notes
>  - later, change checkout to error out when -f is not supplied
>
> or am I being too paranoid?

No. But I don't like the idea of making scripts use "checkout -f". My intention was to stop users from doing that, not scripts. Putting "-f" everywhere might have more negative side effects.

Maybe adding "--porcelain" to checkout first, updating scripts to use it, then only check for rebase/bisect/am when --porcelain is missing.

-- 
Duy
Previous: Jonathan NiederNext: Nguyen Thai Ngoc Duy
Message 4 of 12 in “commit: do not switch branch during a rebase unless -f is given”
  1. commit: do not switch branch during a rebase unless -f is givenNguyễn Thái Ngọc Duy, Sep 28, 2010
  2. checkout: do not switch branch during a rebase unless -f is givenNguyễn Thái Ngọc Duy, Sep 28, 2010
  3. Jonathan NiederSep 28, 2010
  4. Nguyen Thai Ngoc DuySep 28, 2010
  5. Nguyen Thai Ngoc DuyNov 9, 2010
  6. Jonathan NiederNov 9, 2010
  7. Sverre RabbelierNov 9, 2010
  8. Jonathan NiederNov 9, 2010
  9. Nguyen Thai Ngoc DuyNov 9, 2010
  10. Jonathan NiederNov 9, 2010
  11. Junio C HamanoSep 28, 2010
  12. Sverre RabbelierSep 28, 2010

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.