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

RE: [bug] git stash push {dir-pathspec} wipes untracked files

From
Randall S. Becker <rsbecker@nexbridge.com>
Date
Mar 15, 2018, 17:02 UTC
Message-ID
<002f01d3bc7f$7b6261f0$722725d0$@nexbridge.com>
In-Reply-To
<xmqq1sgl703v.fsf@gitster-ct.c.googlers.com>
Show 40 quoted lines
> -----Original Message-----
> From: git-owner@vger.kernel.org <git-owner@vger.kernel.org> On Behalf
> Of Junio C Hamano
> Sent: March 15, 2018 12:52 PM
> To: Jake Stine <jake.stine@gmail.com>
> Cc: git@vger.kernel.org
> Subject: Re: [bug] git stash push {dir-pathspec} wipes untracked files
> 
> Jake Stine <jake.stine@gmail.com> writes:
> 
> > 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.
> 
> I wonder if this is the same as the topic on this thread.
> 
>   https://public-
> inbox.org/git/CA+HNv10i7AvWXjrQjxxy1LNJTmhr7LE4TwxhHUYBiWtmJCOf_
> A@mail.gmail.com/
> 
> What is curious is that the fix bba067d2 ("stash: don't delete untracked files
> that match pathspec", 2018-01-06) appeared first in 2.16.2, on which
> Windows 2.16.2 is supposed to be built upon.
> 
> > Here's the precise reproduction case executed on a linux box:
> 
> This does not reproduce for me with v2.16.2-17-g38e79b1fda (the tip of
> 'maint'); I do not have an  install of vanilla v2.16.2 handy, but I suspect v2.16.2
> would work just fine, too.
This does not reproduce for me either in v2.16.2.9-g3dbadef9f (which is the NonStop port of 2.16.2)
On branch master
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:   subdir/a
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        subdir/b
no changes added to commit (use "git add" and/or "git commit -a")
/home/randall/foot: git stash push subdir
Saved working directory and index state WIP on master: b772270 i
/home/randall/foot: ls subdir
a  b
/home/randall/foot: git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        subdir/b
nothing added to commit but untracked files present (use "git add" to track)
Previous: Junio C HamanoNext: Igor Djordjevic
Message 3 of 4 in “[bug] git stash push {dir-pathspec} wipes untracked files”
  1. Jake StineMar 15, 2018
  2. Junio C HamanoMar 15, 2018
  3. Randall S. BeckerMar 15, 2018
  4. Igor DjordjevicMar 15, 2018

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.