git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fedor Biryukov <fedor.birjukov@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Bagas Sanjaya <bagasdotme@gmail.com>, git@vger.kernel.org
Subject: Re: Aborting 'rebase main feat' removes unversioned files
Date: Sat, 4 Sep 2021 12:03:49 +0200	[thread overview]
Message-ID: <CAG2t84Ud9AFfHhCxyKWvcqVUKTrkRufdMsQL93cdUUvVAyNpzA@mail.gmail.com> (raw)
In-Reply-To: <CAG2t84WY35RvieOc5mhRJExwHdXuaiBafB4S4APkrnGiBM_t_g@mail.gmail.com>

Here's the output from Windows, where everything works as expected.

PS> git --version
git version 2.33.0.windows.2
PS> rm -re -fo *
PS> git init -b main
Initialized empty Git repository in C:/Users/ted/test/.git/
PS> git commit -m 'init' --allow-empty
[main (root-commit) ea4422d] init
PS> git checkout -b feat
Switched to a new branch 'feat'
PS> echo 123 > readme.txt
PS> git add readme.txt
PS> git commit -m 'txt=123'
[feat 82fe34b] txt=123
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 readme.txt
PS> git checkout main
Switched to branch 'main'
PS> echo 012 > readme.txt
PS> git status
On branch main
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        readme.txt

nothing added to commit but untracked files present (use "git add" to track)
PS> git rebase main feat
error: The following untracked working tree files would be overwritten
by checkout:
        readme.txt
Please move or remove them before you switch branches.
Aborting
error: could not detach HEAD
PS> git rebase --abort
fatal: No rebase in progress?

On Sat, Sep 4, 2021 at 11:58 AM Fedor Biryukov <fedor.birjukov@gmail.com> wrote:
>
> Just tested it on my MacBook. To my surprise, the file got deleted by
> 'git rebase main feat':
>
> 550$ git --version
> git version 2.33.0
>
> 551$ git init -b main
> Initialized empty Git repository in
> /Users/ted/workspace/git-abort-bug/test/.git/
>
> 552$ git commit -m 'init' --allow-empty
> [main (root-commit) ede7bdf] init
>
> 553$ git checkout -b feat
> Switched to a new branch 'feat'
>
> 554$ echo 123 > readme.txt
>
> 555$ git add readme.txt
>
> 556$ git commit -m 'txt=123'
> [feat 29ac3de] txt=123
>  1 file changed, 1 insertion(+)
>  create mode 100644 readme.txt
>
> 557$ git checkout main
> Switched to branch 'main'
>
> 558$ echo 012 > readme.txt
>
> 559$ git rebase main feat
> Current branch feat is up to date.
>
> 560$ git rebase --abort
> fatal: No rebase in progress?
>
> On Sat, Sep 4, 2021 at 11:51 AM Fedor Biryukov <fedor.birjukov@gmail.com> wrote:
> >
> > There is no way this could be the intended behavior, but the good news
> > is that I cannot reproduce it...
> > Looks like it occurs only in one git version (2.31.0.windows.1, IIRC).
> > And it does not occur in the latest git version: git version 2.33.0.windows.2.
> >
> > -Fedor
> >
> > On Sat, Sep 4, 2021 at 11:48 AM Jeff King <peff@peff.net> wrote:
> > >
> > > On Sat, Sep 04, 2021 at 01:57:11PM +0700, Bagas Sanjaya wrote:
> > >
> > > > On 04/09/21 03.33, Fedor Biryukov wrote:
> > > > > Looks like a bug in git rebase main feat.
> > > > >
> > > > > To reproduce:
> > > > > git init
> > > > > git commit -m 'init' --allow-empty
> > > > > git checkout -b feat
> > > > > echo 123 > readme.txt
> > > > > git add readme.txt
> > > > > git commit -m 'txt=123'
> > > > > git checkout main
> > > > > echo 012 > readme.txt
> > > > > git rebase main feat
> > > > > git rebase --abort
> > > > >
> > > >
> > > > Did you forget committing?
> > >
> > > I don't think so.
> > >
> > > The point is that "readme.txt" is not a tracked file on the main branch,
> > > and thus Git should consider it precious.
> > >
> > > I don't think the "rebase --abort" is the problem here, though. It's the
> > > command before:
> > >
> > >   git rebase main feat
> > >
> > > The "feat" branch is already ahead of "main" (which has no new commits),
> > > and so it just says:
> > >
> > >   Current branch feat is up to date.
> > >
> > > and leaves us on the "feat" branch. But in doing so, it overwrites the
> > > precious untracked content in the working tree.
> > >
> > > The "git rebase --abort" command then does nothing, because there's no
> > > rebase in progress.
> > >
> > > -Peff

  reply	other threads:[~2021-09-04 10:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAG2t84Uaw-Kdp+EXU8CY1QYfykFQj-hGLJnTSH8MYO8Vi_yqgA@mail.gmail.com>
2021-09-03 20:33 ` Aborting 'rebase main feat' removes unversioned files Fedor Biryukov
2021-09-04  6:57   ` Bagas Sanjaya
2021-09-04  9:48     ` Jeff King
2021-09-04  9:51       ` Fedor Biryukov
2021-09-04  9:58         ` Fedor Biryukov
2021-09-04 10:03           ` Fedor Biryukov [this message]
2021-09-04 10:24             ` Jeff King
2021-09-04 18:32               ` Fedor Biryukov
2021-09-04 10:18         ` Jeff King
2021-09-05  5:32           ` Elijah Newren
2021-09-05  7:43             ` Ævar Arnfjörð Bjarmason
2021-09-05 10:05               ` Fedor Biryukov
2021-09-08  0:40               ` Elijah Newren
2021-09-05 22:31             ` Junio C Hamano
2021-09-08  0:41               ` Elijah Newren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAG2t84Ud9AFfHhCxyKWvcqVUKTrkRufdMsQL93cdUUvVAyNpzA@mail.gmail.com \
    --to=fedor.birjukov@gmail.com \
    --cc=bagasdotme@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).