From: Daniele Segato <daniele.segato@gmail.com>
To: git@vger.kernel.org
Subject: possible bug of git stash deleting uncommitted files in corner case
Date: Fri, 22 Apr 2016 13:46:50 +0200 [thread overview]
Message-ID: <CAND5yRvCK9YuVOJ91CHbnbWAVYcPrpihGkoKs28f7PJgzRwW6Q@mail.gmail.com> (raw)
Hi,
my coworker today claimed git stash deleted his files, I made him
explain me what he did and I think it could actually be a bug even if
happening only in a corner case better explained with code to
reproduce:
git init
echo 'X' > foo
git add foo
git commit -m 'foo file committed'
what follow is the corner case I'm talking about: he deleted the file,
created a directory with THE SAME name and added lot of files in it,
in this example I'll only add one
rm foo
mkdir foo
echo 'B' > foo/bar
at this point the working directory looks like this:
$ tree
.
└── foo
└── bar
1 directory, 1 file
but apparently git status does not seem to see foo directory at all:
$ git status
On branch master
Changes not staged for commit:
deleted: foo
no changes added to commit (use "git add" and/or "git commit -a")
I expected something more like:
$ git status
On branch master
Changes not staged for commit:
deleted: foo
Untracked files:
foo/
no changes added to commit (use "git add" and/or "git commit -a")
Anyway he went on and decided to stash his work:
git stash
at this point stash deleted the "bar" file, in his case all the work
on the previous couple of hours, but he didn't know yet
$ git stash show stash@{0}
foo | 1 -
1 file changed, 1 deletion(-)
the foo directory was gone, replaced by the foo file
git stash pop
did not complained and deleted foo file again
I know my co-worker shouldn't had created a directory with the same
file he was deleting but I also think git shouldn't have allowed him
to stash at all, or should have been cleaver enough to actually stash
the directory with its files.
Regards,
Daniele Segato
next reply other threads:[~2016-04-22 11:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-22 11:46 Daniele Segato [this message]
2016-04-22 11:48 ` possible bug of git stash deleting uncommitted files in corner case Daniele Segato
2016-04-22 12:29 ` Remi Galan Alfonso
2016-04-22 17:37 ` Junio C Hamano
2016-04-22 19:04 ` Remi Galan Alfonso
2016-04-23 3:53 ` Jeff King
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=CAND5yRvCK9YuVOJ91CHbnbWAVYcPrpihGkoKs28f7PJgzRwW6Q@mail.gmail.com \
--to=daniele.segato@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.
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).