git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[BUG] Bug in git stash

From
NFNikolay Frantsev <nikolay@frantsev.ru>
Date
Jan 14, 2013, 09:18 UTC
Message-ID
<CAOJsraHfKRoK1G8tA2ROUH6qt-q0kG6WesZr5enOeeqFF_AC=w@mail.gmail.com>
Hi, I found very strange bug in git stash. Testcase attached to this mail.
1. I have a test repo with two modified files and one new file with
content witch added to commit (see repo in attached file):

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: 3 # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: 1 # modified: 2 #

2. Stashing two modified files into stash named one:

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git stash save --keep-index one Saved working directory and index state On master: one HEAD is now at 7e495f9 files added

3. Checking status, files stashed successfully:

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: 3 #

4. Stashing one added to commit file into stash named zero:

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git stash save zero Saved working directory and index state On master: zero HEAD is now at 7e495f9 files added

5. Checking status, files stashed successfully:

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git status # On branch master nothing to commit, working directory clean

6. Trying to unstash first stashed changes (on step 2), there a bug:

nikolay@localhost:~/Desktop/git-stash_bug/bug$ git stash pop stash@{1} # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: 3 # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: 1 # modified: 2 # Dropped stash@{1} (7926ab7285753c179a368a3a7e8ebfb0f39d0437)

Why there a new empty file named 3?
I'm using git 1.8.1, same problem confirmed on git 1.7.12.4.
--
Nikolay Frantsev
Homepage: http://frantsev.ru/
Next: Johannes Sixt
Message 1 of 2 in “[BUG] Bug in git stash”
  1. Nikolay FrantsevJan 14, 2013
  2. Johannes SixtJan 14, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.