git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* possible bug of git stash deleting uncommitted files in corner case
@ 2016-04-22 11:46 Daniele Segato
  2016-04-22 11:48 ` Daniele Segato
  0 siblings, 1 reply; 6+ messages in thread
From: Daniele Segato @ 2016-04-22 11:46 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-04-23  3:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-22 11:46 possible bug of git stash deleting uncommitted files in corner case Daniele Segato
2016-04-22 11:48 ` 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

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).