git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: phillip.wood@dunelm.org.uk
Cc: Till Friebe <friebetill@gmail.com>, git@vger.kernel.org
Subject: Re: Lost files after git stash && git stash pop
Date: Sun, 23 Jul 2023 22:52:39 +0200	[thread overview]
Message-ID: <20230723205239.5snlakmd5ocy67q2@tb-raspi4> (raw)
In-Reply-To: <a373a659-a232-77cb-a177-a517b1f228f4@gmail.com>

On Sun, Jul 23, 2023 at 11:01:29AM +0100, Phillip Wood wrote:
> On 22/07/2023 22:44, Torsten Bögershausen wrote:
> > On Fri, Jul 21, 2023 at 07:31:53PM +0200, Till Friebe wrote:
> > > Thank you for filling out a Git bug report!
> > > Please answer the following questions to help us understand your issue.
> > >
> > > What did you do before the bug happened? (Steps to reproduce your issue)
> > > ```
> > > git init
> > > mkdir README
> > > touch README/README
> > > git add .
> > > git commit -m "Init project"
> > > echo "Test" > README/README
> > > mv README/README README2
> > > rmdir README
> > > mv README2 README
> > > git stash
> > > git stash pop
> > > ```
> > >
> > > What did you expect to happen? (Expected behavior)
> > > I expected that after the `git stash pop` the README file would be back.
> > >
> > > What happened instead? (Actual behavior)
> > > This README with "Test" file was deleted and I lost 5 hours of work.
> >
> > That is always sad to hear, when work is lost.
>
> Indeed it is. Thanks Till for providing an easy reproducer.
>
> > However, I personally wonder if this is a bug or not.
>
> I think whenever git overwrites an untracked file without the user passing
> some option indicating that they want to do so it is a bug.

OK, agreed after reading the next sentence.

> For example "git
> checkout" refuses to overwrite untracked files by default. Sadly this seems
> to be a known bug in do_push_stash() where we are using "git reset --hard"
> to remove the stashed changes from the working copy. This was documented in
> 94b7f1563a (Comment important codepaths regarding nuking untracked
> files/dirs, 2021-09-27). The stash implementation does a lot of necessary
> forking of subprocesses, in this case I think it would be better to call
> unpack_trees() directly with UNPACK_RESET_PROTECT_UNTRACKED.

Thanks for the fast response.

This is not an area of Git, where I have much understanding of the code.
But is seems as if pop_stash() in builtin/stash.c
(and the called functions) seems to be the problem here ?


  reply	other threads:[~2023-07-23 20:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 17:31 Lost files after git stash && git stash pop Till Friebe
2023-07-22 21:44 ` Torsten Bögershausen
2023-07-23 10:01   ` Phillip Wood
2023-07-23 20:52     ` Torsten Bögershausen [this message]
2023-07-24  9:59       ` Phillip Wood
2023-08-08 17:26 ` [PATCH v1 1/1] git stash needing mkdir deletes untracked file tboegi
2023-08-08 18:03   ` Torsten Bögershausen
2023-08-08 19:28   ` Eric Sunshine
2023-08-09 13:15   ` Phillip Wood
2023-08-09 18:47     ` Torsten Bögershausen
2023-08-15  9:15       ` Phillip Wood
2023-08-15 15:25         ` Torsten Bögershausen
2023-08-15 18:03         ` Junio C Hamano
2023-08-09 20:57     ` Junio C Hamano
2023-08-15  9:16       ` Phillip Wood

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20230723205239.5snlakmd5ocy67q2@tb-raspi4 \
    --to=tboegi@web.de \
    --cc=friebetill@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@dunelm.org.uk \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).