# Git Ignore Exception bug

2 messages from 2016-09-09 to 2016-09-14. Participants: Nathan Williams, Dennis Kaarsemaker.
Thread: https://gitlist.dev/t/44051

## Nathan Williams, 2016-09-09 21:39

Subject: Git Ignore Exception bug
Message-ID: <CAC5iUd2mS1n1=sRB=Bs6tn3L3raAXrZaEcs765UFtQZB9XZuYg@mail.gmail.com>
URL: https://gitlist.dev/e/CAC5iUd2mS1n1%3DsRB%3DBs6tn3L3raAXrZaEcs765UFtQZB9XZuYg%40mail.gmail.com

```
it ignore doesn't seem to be working properly when adding exceptions.

Environment:

Mac, running latest El Capitan (10.11.6)

% git --version
git version 2.9.0

-----------cut here-------------
#!/bin/sh
TEMP=mktemp

# Create a temporary repo
mkdir repo
cd repo

git init

echo "foo/*" >> .gitignore
echo "!foo/bar" >> .gitignore
git add .gitignore
git commit -m "Ignore file with exceptions"

# Create the directory structure
mkdir foo
mkdir foo/bar

# Create files to be ignored
touch foo/1
touch foo/2

# Create files that should be identified
touch foo/bar/a
touch foo/bar/b

# Should ignore foo and indicate that all the files in foo/bar are un-committed
git status

# Move back to the regular directory
cd ..
-----------cut here-------------

Expected results
% git st
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        foo/bar/


Nate

```

## Dennis Kaarsemaker, 2016-09-14 11:26

Subject: Re: Git Ignore Exception bug
Message-ID: <1473852376.30531.20.camel@kaarsemaker.net>
URL: https://gitlist.dev/e/1473852376.30531.20.camel%40kaarsemaker.net
In-Reply-To: <CAC5iUd2mS1n1=sRB=Bs6tn3L3raAXrZaEcs765UFtQZB9XZuYg@mail.gmail.com>

```
On vr, 2016-09-09 at 15:39 -0600, Nathan Williams wrote:
> it ignore doesn't seem to be working properly when adding exceptions.

>8 -- snip testcase

> Expected results
> % git st
> On branch master
> Untracked files:
>   (use "git add <file>..." to include in what will be committed)
> 
>         foo/bar/

That expectation is wrong, it should show foo/. And indeed it does
(tested with 2.9.0 and 2.10.0-rc1)

$ sh -x testscript
+ rm -rf repo
+ mkdir repo
+ cd repo
+ git init
Initialized empty Git repository in /home/dennis/code/git/repo/.git/
+ echo foo/*
+ echo !foo/bar
+ git add .gitignore
+ git commit -m Ignore file with exceptions
[master (root-commit) 7e1b82a] Ignore file with exceptions
 1 file changed, 2 insertions(+)
 create mode 100644 .gitignore
+ mkdir foo
+ mkdir foo/bar
+ touch foo/1
+ touch foo/2
+ touch foo/bar/a
+ touch foo/bar/b
+ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	foo/

nothing added to commit but untracked files present (use "git add" to track)
-- 
Dennis Kaarsemaker
http://www.kaarsemaker.net



```
