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

Re: possible bug of git stash deleting uncommitted files in corner case

From
Remi Galan Alfonso <remi.galan-alfonso@ensimag.grenoble-inp.fr>
Date
Apr 22, 2016, 12:29 UTC
Message-ID
<1304154573.4013923.1461328186541.JavaMail.zimbra@ensimag.grenoble-inp.fr>
In-Reply-To
<CAND5yRvU1-AgvQW106fHbNN-GRQ615HjTDjR6AY9gkpoquBgDw@mail.gmail.com>
Daniele Segato <daniele.segato@gmail.com> wrote:
Show 26 quoted lines
> git init
> echo 'X' > foo
> git add foo
> git commit -m 'foo file committed'
> 
> rm foo
> mkdir foo
> echo 'B' > foo/bar
> 
> # git status
> 
> git stash
> 
> at this point stash deleted the "bar" file, in his case all the work
> on the previous couple of hours, but he didn't know yet
> 
> the foo directory was gone, replaced by the foo file
> 
> git stash pop
> 
> did not complained and deleted foo file again
> 
> I know my co-worker shouldn't had created a directory with the same
> file he was deleting but I also think git shouldn't have allowed him
> to stash at all, or should have been clever enough to actually stash
> the directory with its files.
AFAIK it is a bug.
Without even going to the stash command,
    git init
    echo 'X' >foo
    git add foo
    git commit -m "Adding foo"
    rm foo
    mkdir foo
    echo 'B' >foo/bar
    git status
At this point the state is incorrect, the file foo/bar isn't there, as
you mentionned.
>  $ git --version
> git version 1.9.1
Contrary to what I expected, this seems to still be the case with:
  $ git --version
  git version 2.8.0.rc2
Being at $daywork right now, I am unable to test this any further.

Thanks, Rémi

Previous: Daniele SegatoNext: Junio C Hamano
Message 3 of 6 in “possible bug of git stash deleting uncommitted files in corner case”
  1. Daniele SegatoApr 22, 2016
  2. Daniele SegatoApr 22, 2016
  3. Remi Galan AlfonsoApr 22, 2016
  4. Junio C HamanoApr 22, 2016
  5. Remi Galan AlfonsoApr 22, 2016
  6. Jeff KingApr 23, 2016

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.