From: Martin Kunev <martinkunev@gmail.com>
To: git@vger.kernel.org
Subject: Bug: Untracked file deleted by git-stash
Date: Thu, 10 May 2018 21:21:52 +0200 [thread overview]
Message-ID: <20180510212152.08d2b9a7@martofr> (raw)
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
reply other threads:[~2018-05-10 19:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20180510212152.08d2b9a7@martofr \
--to=martinkunev@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).