* [Bug] "git stash -u": Data loss of ignored content in directories
@ 2016-04-16 13:14 Ulrich Buchgraber
0 siblings, 0 replies; only message in thread
From: Ulrich Buchgraber @ 2016-04-16 13:14 UTC (permalink / raw
To: git
Hello,
A "git stash -u" cleans all untracked files (after storing them), and
normally does not clean ignored files.
But: It cleans ignored files _within_ a directory, when the directory
itself is not ignored, but its content (e.g. a "dir/*" ignore filter).
The bug seems to be that in the cleanup phase of "git stash -u" Git
immediately deletes untracked directories without checking if there
are ignored files in there.
See the following reproduction sample. The last "ls" command shows
that the file "ignored_dir_with_star/ignored.txt" is lost.
git init
mkdir ignored_dir && touch ignored_dir/ignored.txt
mkdir ignored_dir_with_star && touch ignored_dir_with_star/ignored.txt
echo "/ignored_dir" >> .gitignore
echo "/ignored_dir_with_star/*" >> .gitignore
git add .gitignore
git commit -m "added ignores"
touch untracked.txt
ls -R
# => Output:
# .:
# ignored_dir/ ignored_dir_with_star/ untracked.txt
#
# ./ignored_dir:
# ignored.txt
#
# ./ignored_dir_with_star:
# ignored.txt
git stash -u
git stash pop
ls -R
# => Output:
# .:
# ignored_dir/ untracked.txt
#
# ./ignored_dir:
# ignored.txt
Note that there is no data loss when instead using "git stash" or "git
stash -a".
(Tested with Git 2.8.1 on Ubuntu and Git for Windows version 2.8.1.windows.1.)
Ulrich
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-16 13:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-16 13:14 [Bug] "git stash -u": Data loss of ignored content in directories Ulrich Buchgraber
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).