From: Jake Stine <jake.stine@gmail.com>
To: git@vger.kernel.org
Subject: [bug] git stash push {dir-pathspec} wipes untracked files
Date: Thu, 15 Mar 2018 09:40:38 -0700 [thread overview]
Message-ID: <CABWk7R9xNDHJbbsMZbOyhcYXq-bD6Krvbw_mKDBJFALALS3AHA@mail.gmail.com> (raw)
Hi, I ran into what I believe is a bug today. I’m using primarily Git
for Windows 2.16.2 and also reproduced the behavior on Git for Windows
2.15.1 and Git 2.14.1 on Ubuntu:
Given any repository with at least one subdirectory:
1. Create some untracked files in the subdir
2. Modify a tracked file in the subdir
3. Execute `git stash push subdir`
4. The untracked files will be removed, without warning.
`git stash push` behaves as-expcted and does not touch untracked
files. It’s only when a directory tree is specified as [pathspec]
that the problem occurs.
Here's the precise reproduction case executed on a linux box:
jake@jake-VirtualBox:~/woot$ git --version
git version 2.14.1
jake@jake-VirtualBox:~/woot$ git config --global user.email jake.stine@gmail.com
jake@jake-VirtualBox:~/woot$ git config --global user.name "Jake Stine"
jake@jake-VirtualBox:~$ git init woot
Initialized empty Git repository in /home/jake/woot/.git/
jake@jake-VirtualBox:~$ cd woot
jake@jake-VirtualBox:~/woot$ mkdir subdir
jake@jake-VirtualBox:~/woot$ echo "test" > meh.txt
jake@jake-VirtualBox:~/woot$ echo "test" > subdir/meh2.txt
jake@jake-VirtualBox:~/woot$ git add meh.txt subdir/meh2.txt
jake@jake-VirtualBox:~/woot$ git commit --message="stash bug testing"
jake@jake-VirtualBox:~/woot$ git commit --message="stash bug testing"
[master (root-commit) 2c05580] stash bug testing
2 files changed, 2 insertions(+)
create mode 100644 meh.txt
create mode 100644 subdir/meh2.txt
jake@jake-VirtualBox:~/woot$ echo "test" > subdir/untracked.txt
jake@jake-VirtualBox:~/woot$ echo "append" >> subdir/meh2.txt
jake@jake-VirtualBox:~/woot$ git stash push subdir
Saved working directory and index state WIP on master: 2c05580 stash bug testing
jake@jake-VirtualBox:~/woot$ ls subdir
meh2.txt
The expected result is that when I do `ls subdir` the file
"untracked.txt" still exists. Alternatively, git stash should warn me
before destroying my untracked files, and require I specify --force or
similar to invoke destructive behavior.
Thanks!
Jake Stine
next reply other threads:[~2018-03-15 16:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-15 16:40 Jake Stine [this message]
2018-03-15 16:52 ` [bug] git stash push {dir-pathspec} wipes untracked files Junio C Hamano
2018-03-15 17:02 ` Randall S. Becker
2018-03-15 20:39 ` Igor Djordjevic
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=CABWk7R9xNDHJbbsMZbOyhcYXq-bD6Krvbw_mKDBJFALALS3AHA@mail.gmail.com \
--to=jake.stine@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).