# Bug: stash save -u removes (some) ignored files

3 messages from 2015-11-03 to 2015-11-04. Participants: Felipe Sateler, Atousa Duprat.
Thread: https://gitlist.dev/t/40720

## Felipe Sateler, 2015-11-03 22:37

Subject: Bug: stash save -u removes (some) ignored files
Message-ID: <CAAfdZj8=pqWDB9U3=bPeKXGzsZvzns2xX8WxEzQAy08wgSm=ZQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAAfdZj8%3DpqWDB9U3%3DbPeKXGzsZvzns2xX8WxEzQAy08wgSm%3DZQ%40mail.gmail.com

```
I have seen the following problem:

felipe@felipe:testgit% cat .gitignore
**/notrack/*
!**/notrack/track/
notrackfile**

felipe@felipe:testgit% find *
newfile
notrack
notrack/1
notrackfile1

felipe@felipe:testgit% git status --porcelain
?? newfile

felipe@felipe:testgit% git stash save -u
Saved working directory and index state WIP on master: 523cb39 Initial commit
HEAD is now at 523cb39 Initial commit

felipe@felipe:testgit% find *
notrackfile1

So, after a stash save, git decided to keep the untracked file in the
current directory, but not the ones inside the untracked directory.
However, the files were "correctly" ignored and did not appear on the stash:

felipe@felipe:testgit% git stash pop
Already up-to-date!
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        newfile

nothing added to commit but untracked files present (use "git add" to track)
Dropped refs/stash@{0} (e6508f345af1dd207557ad0291e7e3bce8a89b1e)

felipe@felipe:testgit% find *
newfile
notrackfile1

I think the correct behaviour should be to left the ignored files
untouched in both scenarios.

This is with git 2.6.1 (from debian).

I note that if I add a file inside the notrack/track directory, it is
correctly kept, but the files in notrack/ are still deleted.

-- 

Saludos,
Felipe Sateler

```

## Atousa Duprat, 2015-11-04 06:23

Subject: Re: Bug: stash save -u removes (some) ignored files
Message-ID: <CA+izobsNJ+Aj6JwFTtZVD_+8m9uXV-iiM7Z2aYWNCnWXFd82Dg@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BizobsNJ%2BAj6JwFTtZVD_%2B8m9uXV-iiM7Z2aYWNCnWXFd82Dg%40mail.gmail.com
In-Reply-To: <CAAfdZj8=pqWDB9U3=bPeKXGzsZvzns2xX8WxEzQAy08wgSm=ZQ@mail.gmail.com>

```
> felipe@felipe:testgit% git stash save -u

This does the following:
$ GIT_TRACE=1 git stash save -u
[...]
21:59:10.606094 git.c:348               trace: built-in: git 'clean'
'--force' '--quiet' '-d'

git-clean -d removes untracked directories in addition to untracked files.
Should 'git stash save -u' issue a 'git clean -d' or simply a 'git clean'?

Atousa

On Tue, Nov 3, 2015 at 2:37 PM, Felipe Sateler <fsateler@debian.org> wrote:
> I have seen the following problem:
>
> felipe@felipe:testgit% cat .gitignore
> **/notrack/*
> !**/notrack/track/
> notrackfile**
>
> felipe@felipe:testgit% find *
> newfile
> notrack
> notrack/1
> notrackfile1
>
> felipe@felipe:testgit% git status --porcelain
> ?? newfile
>
> felipe@felipe:testgit% git stash save -u
> Saved working directory and index state WIP on master: 523cb39 Initial commit
> HEAD is now at 523cb39 Initial commit
>
> felipe@felipe:testgit% find *
> notrackfile1
>
> So, after a stash save, git decided to keep the untracked file in the
> current directory, but not the ones inside the untracked directory.
> However, the files were "correctly" ignored and did not appear on the stash:
>
> felipe@felipe:testgit% git stash pop
> Already up-to-date!
> On branch master
> Untracked files:
>   (use "git add <file>..." to include in what will be committed)
>
>         newfile
>
> nothing added to commit but untracked files present (use "git add" to track)
> Dropped refs/stash@{0} (e6508f345af1dd207557ad0291e7e3bce8a89b1e)
>
> felipe@felipe:testgit% find *
> newfile
> notrackfile1
>
> I think the correct behaviour should be to left the ignored files
> untouched in both scenarios.
>
> This is with git 2.6.1 (from debian).
>
> I note that if I add a file inside the notrack/track directory, it is
> correctly kept, but the files in notrack/ are still deleted.
>
> --
>
> Saludos,
> Felipe Sateler
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Atousa Pahlevan, PhD
M.Math. University of Waterloo, Canada
Ph.D. Department of Computer Science, University of Victoria, Canada
Voice: 415-341-6206
Email: apahlevan@ieee.org
Website: www.apahlevan.org

```

## Felipe Sateler, 2015-11-04 12:27

Subject: Re: Bug: stash save -u removes (some) ignored files
Message-ID: <CAAfdZj_t86AuhU7dgx81-MXFp7Fe=TCZ0uzRu37+FUp80mvy5Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAAfdZj_t86AuhU7dgx81-MXFp7Fe%3DTCZ0uzRu37%2BFUp80mvy5Q%40mail.gmail.com
In-Reply-To: <CA+izobsNJ+Aj6JwFTtZVD_+8m9uXV-iiM7Z2aYWNCnWXFd82Dg@mail.gmail.com>

```
On 4 November 2015 at 03:23, Atousa Duprat <atousa.p@gmail.com> wrote:
>> felipe@felipe:testgit% git stash save -u
>
> This does the following:
> $ GIT_TRACE=1 git stash save -u
> [...]
> 21:59:10.606094 git.c:348               trace: built-in: git 'clean'
> '--force' '--quiet' '-d'
>
> git-clean -d removes untracked directories in addition to untracked files.
> Should 'git stash save -u' issue a 'git clean -d' or simply a 'git clean'?

It appears to be intentionally done[1]. Maybe the problem is that
git-clean -d should not remove untracked directories that contain
ignored files?


[1] http://article.gmane.org/gmane.comp.version-control.git/180214

-- 

Saludos,
Felipe Sateler

```
