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

[bug] [UX] `stash save --untracked` produces a stash that *looks* empty

From
ASAlberto Scotto <scotto.alberto.86@gmail.com>
Date
Oct 5, 2014, 17:28 UTC
Message-ID
<CACsY31pSeijqGC4Rw=q+qAGHJQ+bNibindVReYoZZACvYL7O+A@mail.gmail.com>
Hi all,
I've just found that:
- given you have an empty staging area
- and you have only untracked files in your working dir
- when you do `git stash --untracked`
- then `git stash show` gives you an empty output => stash looks empty

My first thought was "oh god, my files are lost!" Second thought: "Jeez I found a bug in git! cool!" Then I found that actually `git stash apply` restores the apparently lost files So I think it's a UX issue. It cost me a few lost files already, as I thought "an empty stash? uhm.. can't remember what/when I stashed.. whatever.. let's just delete it and clean up a little bit this mess of stashes".

Here are the reproducible steps:
   1. create new fresh git repo in $REPO_DIR
   2. create a couple of files/dirs and commit
   3. edit src/MyClass.java and commit
   4. create dir src/new-dir with one file inside
   5. edit file.txt and stage it
   6. stash => stashes staged changes; only untracked files are left
   7. stash -u => stashes untracked changes => working dir is clean
   8. stash list
   9. git stash show -p => empty output
   10. git stash apply (restore stashed untracked files)

I made a bash script that runs through those steps. Please check it out. https://gist.github.com/alb-i986/a4002f1ac50ce355278e

Envs:
   - Mac OSX 10.9.5
   - Darwin 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT
      2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
      - git version 1.9.3 (Apple Git-50)
      - GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
   - Ubuntu precise <-
   https://github.com/alb-i986/vagrantfiles/tree/master/basic
      - Linux precise64 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51
      UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
      - git version 1.7.9.5
      - GNU bash, version 4.2.24(1)-release (x86_64-pc-linux-gnu)
Thank you

Alberto Scotto http://alb-i986.me

Next: Tanay Abhra
Message 1 of 3 in “[bug] [UX] `stash save --untracked` produces a stash that *looks* empty”
  1. Alberto ScottoOct 5, 2014
  2. Tanay AbhraOct 8, 2014
  3. Jeff KingOct 9, 2014

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.