# does "git clean" deliberately ignore "core.excludesFile"?

7 messages from 2019-02-23 to 2019-02-24. Participants: Robert P. J. Day, Junio C Hamano, Johannes Schindelin.
Thread: https://gitlist.dev/t/50571

## Robert P. J. Day, 2019-02-23 15:11

Subject: does "git clean" deliberately ignore "core.excludesFile"?
Message-ID: <alpine.LFD.2.21.1902231008530.28936@localhost.localdomain>
URL: https://gitlist.dev/e/alpine.LFD.2.21.1902231008530.28936%40localhost.localdomain

```

  not sure why i never noticed this before, but the "-x" option for
"git clean" reads:

 -x
     Don’t use the standard ignore rules read from .gitignore
     (per directory) and $GIT_DIR/info/exclude, but do still use
     the ignore rules given with -e options. This allows
     removing all untracked files, including build products.
     This can be used (possibly in conjunction with git reset)
     to create a pristine working directory to test a clean
     build.

  but i see no mention of whether the file specified by
core.excludesFile is taken into account, and perusing the source code
doesn't seem to show that command checking that config option.

  am i misreading something? and if not, is there a reason git clean
does not consult core.excludesFile?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
```

## Junio C Hamano, 2019-02-23 15:28

Subject: Re: does "git clean" deliberately ignore "core.excludesFile"?
Message-ID: <xmqqimxao76b.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqimxao76b.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <alpine.LFD.2.21.1902231008530.28936@localhost.localdomain>

```
"Robert P. J. Day" <rpjday@crashcourse.ca> writes:

>   am i misreading something? and if not, is there a reason git clean
> does not consult core.excludesFile?

Can you ask "git log" and "git blame" whch of  core.excludesFile and
"clean -x" features came earlier and by how big a difference?

Most likely this is because the exclude came much much later, and
either we forgot to teach the implementation of clean to pay
attention to it or (much more likely) the implementaiton is fine but
we did not update the doc, which was trying to overly be exhaustive,
doing no good (if the original just stopped at saying "... the
standard ignore rules read from the usual places", we won't be
having this discussion).

```

## Johannes Schindelin, 2019-02-23 18:06

Subject: Re: does "git clean" deliberately ignore "core.excludesFile"?
Message-ID: <nycvar.QRO.7.76.6.1902231905180.45@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.1902231905180.45%40tvgsbejvaqbjf.bet
In-Reply-To: <xmqqimxao76b.fsf@gitster-ct.c.googlers.com>

```
Hi,

On Sat, 23 Feb 2019, Junio C Hamano wrote:

> "Robert P. J. Day" <rpjday@crashcourse.ca> writes:
> 
> >   am i misreading something? and if not, is there a reason git clean
> > does not consult core.excludesFile?
> 
> Can you ask "git log" and "git blame" whch of  core.excludesFile and
> "clean -x" features came earlier and by how big a difference?

Or maybe we can have a look why the `core.excludesfile` regression test
case in t7300 does not catch this?

https://github.com/git/git/blob/v2.21.0-rc2/t/t7300-clean.sh#L408-L417

Ciao,
Dscho

```

## Johannes Schindelin, 2019-02-23 18:19

Subject: Re: does "git clean" deliberately ignore "core.excludesFile"?
Message-ID: <nycvar.QRO.7.76.6.1902231912370.45@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.1902231912370.45%40tvgsbejvaqbjf.bet
In-Reply-To: <nycvar.QRO.7.76.6.1902231905180.45@tvgsbejvaqbjf.bet>

```
Hi,

On Sat, 23 Feb 2019, Johannes Schindelin wrote:

> On Sat, 23 Feb 2019, Junio C Hamano wrote:
> 
> > "Robert P. J. Day" <rpjday@crashcourse.ca> writes:
> > 
> > >   am i misreading something? and if not, is there a reason git clean
> > > does not consult core.excludesFile?
> > 
> > Can you ask "git log" and "git blame" whch of  core.excludesFile and
> > "clean -x" features came earlier and by how big a difference?
> 
> Or maybe we can have a look why the `core.excludesfile` regression test
> case in t7300 does not catch this?
> 
> https://github.com/git/git/blob/v2.21.0-rc2/t/t7300-clean.sh#L408-L417

I actually doubt that `git clean` ignores `core.excludesFile`: in
https://github.com/git/git/blob/v2.21.0-rc2/config.c#L1297-L1298,
`git_default_core_config()` (which is called via the `git_clean_config()`
-> `git_color_default_config()` -> `git_default_config()` chain from
`cmd_clean()`) does interpret `core.excludesFile`:

	if (!strcmp(var, "core.excludesfile"))
		return git_config_pathname(&excludes_file, var, value);

Then, `cmd_clean()` goes on to parse the options, setting the `ignored`
variable upon `-x` and then doing
[this](https://github.com/git/git/blob/v2.21.0-rc2/builtin/clean.c#L957-L958):

	if (!ignored)
		setup_standard_excludes(&dir);

This function specifically looks at `excludes_file` in
https://github.com/git/git/blob/v2.21.0-rc2/dir.c#L2481-L2483:

	if (excludes_file && !access_or_warn(excludes_file, R_OK, 0))
		add_excludes_from_file_1(dir, excludes_file,
					 dir->untracked ? &dir->ss_excludes_file : NULL);

So I am quite puzzled by the claim that `git clean` might not consult
`core.excludesFile`.

Robert, care to come up with an example demonstrating where it does not?

Ciao,
Johannes

```

## Robert P. J. Day, 2019-02-23 18:32

Subject: Re: does "git clean" deliberately ignore "core.excludesFile"?
Message-ID: <alpine.LFD.2.21.1902231328560.2222@localhost.localdomain>
URL: https://gitlist.dev/e/alpine.LFD.2.21.1902231328560.2222%40localhost.localdomain
In-Reply-To: <nycvar.QRO.7.76.6.1902231912370.45@tvgsbejvaqbjf.bet>

```
On Sat, 23 Feb 2019, Johannes Schindelin wrote:

> Hi,
>
> On Sat, 23 Feb 2019, Johannes Schindelin wrote:
>
> > On Sat, 23 Feb 2019, Junio C Hamano wrote:
> >
> > > "Robert P. J. Day" <rpjday@crashcourse.ca> writes:
> > >
> > > >   am i misreading something? and if not, is there a reason git clean
> > > > does not consult core.excludesFile?
> > >
> > > Can you ask "git log" and "git blame" whch of  core.excludesFile and
> > > "clean -x" features came earlier and by how big a difference?
> >
> > Or maybe we can have a look why the `core.excludesfile` regression test
> > case in t7300 does not catch this?
> >
> > https://github.com/git/git/blob/v2.21.0-rc2/t/t7300-clean.sh#L408-L417
>
> I actually doubt that `git clean` ignores `core.excludesFile`: in
> https://github.com/git/git/blob/v2.21.0-rc2/config.c#L1297-L1298,
> `git_default_core_config()` (which is called via the `git_clean_config()`
> -> `git_color_default_config()` -> `git_default_config()` chain from
> `cmd_clean()`) does interpret `core.excludesFile`:
>
> 	if (!strcmp(var, "core.excludesfile"))
> 		return git_config_pathname(&excludes_file, var, value);
>
> Then, `cmd_clean()` goes on to parse the options, setting the `ignored`
> variable upon `-x` and then doing
> [this](https://github.com/git/git/blob/v2.21.0-rc2/builtin/clean.c#L957-L958):
>
> 	if (!ignored)
> 		setup_standard_excludes(&dir);
>
> This function specifically looks at `excludes_file` in
> https://github.com/git/git/blob/v2.21.0-rc2/dir.c#L2481-L2483:
>
> 	if (excludes_file && !access_or_warn(excludes_file, R_OK, 0))
> 		add_excludes_from_file_1(dir, excludes_file,
> 					 dir->untracked ? &dir->ss_excludes_file : NULL);
>
> So I am quite puzzled by the claim that `git clean` might not consult
> `core.excludesFile`.
>
> Robert, care to come up with an example demonstrating where it does not?

  sorry i wasn't clear, all i was pointing out was that "man
git-clean" *explicitly* mentioned two locations related to cleaning:

  -x
        Don’t use the standard ignore rules read from .gitignore
        (per directory) and $GIT_DIR/info/exclude, ...

without additionally *explicitly* mentioning core.excludesFile. if the
man page simply said something like, "using the standard ignore
processing" and left it at that, it would be fine, but to list two of
the locations without the third is potentially confusing.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
```

## Junio C Hamano, 2019-02-24 05:30

Subject: Re: does "git clean" deliberately ignore "core.excludesFile"?
Message-ID: <xmqq5zt9oirx.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqq5zt9oirx.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <alpine.LFD.2.21.1902231328560.2222@localhost.localdomain>

```
"Robert P. J. Day" <rpjday@crashcourse.ca> writes:

> On Sat, 23 Feb 2019, Johannes Schindelin wrote:
>
>> Robert, care to come up with an example demonstrating where it does not?
>
>   sorry i wasn't clear, all i was pointing out was that "man
> git-clean" *explicitly* mentioned two locations related to cleaning:
> ...
> without additionally *explicitly* mentioning core.excludesFile.

OK, so together with the homework Dscho did for you and what I wrote
earlier, I think you have enough information to answer the question
yourself.

That is, the code does *not* ignore, and the doc was trying to be
(overly) exhaustive but because it predates core.excludesFile, after
the introduction of that configuration, it no longer is exhaustigve
and has become stale.

Which would leave a small, easy and low-hanging fruit, I guess ;-).

Thanks.

```

## Johannes Schindelin, 2019-02-24 14:15

Subject: Re: does "git clean" deliberately ignore "core.excludesFile"?
Message-ID: <nycvar.QRO.7.76.6.1902241515120.45@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.1902241515120.45%40tvgsbejvaqbjf.bet
In-Reply-To: <xmqq5zt9oirx.fsf@gitster-ct.c.googlers.com>

```
Hi,

On Sat, 23 Feb 2019, Junio C Hamano wrote:

> "Robert P. J. Day" <rpjday@crashcourse.ca> writes:
> 
> > On Sat, 23 Feb 2019, Johannes Schindelin wrote:
> >
> >> Robert, care to come up with an example demonstrating where it does not?
> >
> >   sorry i wasn't clear, all i was pointing out was that "man
> > git-clean" *explicitly* mentioned two locations related to cleaning:
> > ...
> > without additionally *explicitly* mentioning core.excludesFile.
> 
> OK, so together with the homework Dscho did for you and what I wrote
> earlier, I think you have enough information to answer the question
> yourself.
> 
> That is, the code does *not* ignore, and the doc was trying to be
> (overly) exhaustive but because it predates core.excludesFile, after
> the introduction of that configuration, it no longer is exhaustigve
> and has become stale.
> 
> Which would leave a small, easy and low-hanging fruit, I guess ;-).

#leftoverbits

;-)

Thanks,
Dscho

> Thanks.
> 

```
