git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Fedor Biryukov <fedor.birjukov@gmail.com>
Cc: Bagas Sanjaya <bagasdotme@gmail.com>, git@vger.kernel.org
Subject: Re: Aborting 'rebase main feat' removes unversioned files
Date: Sat, 4 Sep 2021 06:18:02 -0400	[thread overview]
Message-ID: <YTNH2vMPuEW4SBMo@coredump.intra.peff.net> (raw)
In-Reply-To: <CAG2t84Xe2XwdwdAK42bRrwAeNaB3-A+WhgSsJGOoW9-rG1S9Xg@mail.gmail.com>

On Sat, Sep 04, 2021 at 11:51:19AM +0200, Fedor Biryukov 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.

I think it is a bug, and it seems to reproduce easily for me (with both
the current tip of master, and with v2.33.0). Here's the recipe you
showed, with a little debugging at the end:

  set -x
  git init repo
  cd repo
  git commit -m base --allow-empty
  git checkout -b feat
  echo feat >readme.txt
  git add readme.txt
  git commit -m txt=feat
  git checkout main
  echo precious >readme.txt

  cat readme.txt
  git checkout feat
  cat readme.txt
  git rebase main feat
  cat readme.txt

This produces:

  + cat readme.txt
  precious
  + git checkout 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
  + cat readme.txt
  precious
  + git rebase main feat
  Current branch feat is up to date.
  + cat readme.txt
  feat

So git-checkout was not willing to overwrite the untracked content, but
rebase was happy to obliterate it.

It does the right thing in very old versions. Bisecting, it looks like
the problem arrived in 5541bd5b8f (rebase: default to using the builtin
rebase, 2018-08-08). So the bug is in the conversion from the legacy
shell script to C (which makes sense; the shell version was just calling
"git checkout", which we know does the right thing).

-Peff

  parent reply	other threads:[~2021-09-04 10:18 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
2021-09-04 10:24             ` Jeff King
2021-09-04 18:32               ` Fedor Biryukov
2021-09-04 10:18         ` Jeff King [this message]
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=YTNH2vMPuEW4SBMo@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=bagasdotme@gmail.com \
    --cc=fedor.birjukov@gmail.com \
    --cc=git@vger.kernel.org \
    /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).