git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug: Untracked file deleted by git-stash
@ 2018-05-10 19:21 Martin Kunev
  0 siblings, 0 replies; only message in thread
From: Martin Kunev @ 2018-05-10 19:21 UTC (permalink / raw)
  To: git

I stumbled upon the following issue with git 2.11.0 on Debian 9.

When a tracked file is removed and a directory with the same name is created, git-stash would delete the directory with all its contents. No warning is displayed and git stores no information about the deleted content (as far as I can tell). The following steps can be used to reproduce:

$ mkdir /tmp/bug; cd /tmp/bug
$ git init
Initialized empty Git repository in /tmp/bug/.git/
$ echo 'original file' > entry
$ git add entry
$ git commit -m 'entry added'
[master (root-commit) 483319e] entry added
 1 file changed, 1 insertion(+)
 create mode 100644 entry
$ rm entry
removed 'entry'
$ mkdir entry
$ echo 'data that will be destroyed' > entry/content
$ git status
On branch master
Changes not staged for commit:
    deleted:    entry

no changes added to commit
$ ls -l
total 4
drwxr-xr-x 2 martin root 4096 May 10 21:16 entry
$ git stash
Saved working directory and index state WIP on master: 483319e entry added
HEAD is now at 483319e entry added

After the stash, the working tree contains only the regular file entry and the stash contains no information about the directory or its contents:

$ ls -l
total 4
-rw-r--r-- 1 martin root 5 May 10 21:16 entry
$ git status
On branch master
nothing to commit, working tree clean
$ git stash show -p
diff --git a/entry b/entry
deleted file mode 100644
index 1269488..0000000
--- a/entry
+++ /dev/null
@@ -1 +0,0 @@
-original file

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-05-10 19:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-10 19:21 Bug: Untracked file deleted by git-stash Martin Kunev

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