From: lennart spitzner <len48@web.de>
To: git@vger.kernel.org
Subject: bug report: `git stash save -u` deletes directory whose contents are .gitignored
Date: Wed, 14 Oct 2015 00:48:03 +0200 [thread overview]
Message-ID: <561D8A23.2090601@web.de> (raw)
hi,
- `git stash save -u` deletes a directory, even though the _contents_
of that directory are .gitignored (e.g. "foo/*" in .gitignore).
Detailed reproduction below.
- The behaviour is not present when instead .gitignoring the directory
itself (e.g. "foo"). This does imo not excuse the behaviour of the
described case.
- The behaviour is not present with just `git stash save`.
- The expected behaviour is: Only files listed in `git status` are
stashed away; other things are left untouched. Potential exception:
empty directories.
- I am aware that `git stash save -u` is supposed to have semantics
involving the equivalent of `reset --hard` and `clean -f`. Neither of
those expose the directory-deletion behaviour.
additional comments, not directly relevant to this bug:
- both `git stash save; git stash pop` and `git stash save -u; git
stash pop` should ideally behave as an "identity effect". The latter
might affect the index (i.e. have an effect equivalent to `git reset`
or something in that direction). Any other effect / special cases are
bad interface design imo. If a differing design was chosen on purpose,
i am thankful for pointers on the reasoning.
- no, i luckily did not truely lose files due to the current behaviour.
lennart
----
reproduction:
> git init
Initialized empty Git repository in $SOMEDIR/.git/
> mkdir ignore-contents
> echo "ignore-contents/*" > .gitignore
> git add .gitignore
> git commit -m "initial" > /dev/null
> touch ignore-contents/blah.txt
> touch abc.txt
> git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
abc.txt
nothing added to commit but untracked files present (use "git add" to
track)
> ls -1a
.
..
abc.txt
.git
.gitignore
ignore-contents
> git stash save -u
Saved working directory and index state WIP on master: adc468b initial
HEAD is now at adc468b initial
> ls -1a
.
..
.git
.gitignore
> git stash pop &> /dev/null
> ls -1a
.
..
abc.txt
.git
.gitignore
> git --version
git version 2.6.1
reply other threads:[~2015-10-13 22:48 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=561D8A23.2090601@web.de \
--to=len48@web.de \
--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).