# Cogito and --exclude vs --exclude-per-directory

3 messages from 2005-11-16 to 2005-11-16. Participants: Karl Hasselström, Junio C Hamano.
Thread: https://gitlist.dev/t/2550

## Karl Hasselström, 2005-11-16 09:36

Subject: Cogito and --exclude vs --exclude-per-directory
Message-ID: <20051116093630.GA2783@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20051116093630.GA2783%40diana.vm.bytemark.co.uk

```
[Note: this experiment was done with git 0.99.9g and Cogito 0.15.1, so ]

It seems that --exclude patterns always take precedence over
--exclude-per-directory patterns. For example:

  $ ls -a
  ./  ../  .bar  bar.txt  .foo  foo.txt  .git/  .gitignore

  $ cat .gitignore
  !.bar

  $ git-ls-files -o --exclude='.*' --exclude='!.bar'
  .bar
  bar.txt
  foo.txt

  $ git-ls-files -o --exclude='.*' --exclude-per-directory=.gitignore
  bar.txt
  foo.txt

Is this the intended behavior?

Since Cogito specifies a few "default" ignore patterns with --exclude,
(such as .* and *.o) these become impossible to override with !
patterns in .gitignore files. In effect, the default patterns are
given priority over user-supplied patterns.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```

## Karl Hasselström, 2005-11-16 09:38

Subject: Re: Cogito and --exclude vs --exclude-per-directory
Message-ID: <20051116093804.GB2783@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20051116093804.GB2783%40diana.vm.bytemark.co.uk
In-Reply-To: <20051116093630.GA2783@diana.vm.bytemark.co.uk>

```
On 2005-11-16 10:36:30 +0100, Karl Hasselström wrote:

> [Note: this experiment was done with git 0.99.9g and Cogito 0.15.1,
> so ]

. . . please scream if I should just upgrade to fix all my problems.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```

## Junio C Hamano, 2005-11-16 19:01

Subject: Re: Cogito and --exclude vs --exclude-per-directory
Message-ID: <7vd5l08li9.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vd5l08li9.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20051116093630.GA2783@diana.vm.bytemark.co.uk>

```
Karl Hasselström <kha@treskal.com> writes:

> [Note: this experiment was done with git 0.99.9g and Cogito 0.15.1, so ]
>
> It seems that --exclude patterns always take precedence over
> --exclude-per-directory patterns.
>
> Is this the intended behavior?

Yes, we had a lengthy discussion on this before ls-files
acquired the exclude patterns.

Documentation/git-ls-files.txt "Exclude Patterns" summarizes the
precedence rule, and it was done that way to allow command line
users to override what are in individual per-directory pattern
files per-invocation basis.  That is, --exclude-per-directory is
to store project defaults, and --exclude is for end-users to
specify override per-invocation.  --exclude-from has the lowest
precedence to give overall default.  The example in the
documetation has a a good illustration.

	* --exclude-from contains '*.[oa]' to catch generic
          "uninteresting" files.

	* --exclude-per-directory files contain patterns to
          catch files that are built by the Makefile in the
          directory.

        * --exclude specifies whatever the user feels like for
          the particular invocation.

If I were writing a Porcelain, I would probably install default
exclude list in /usr/lib/MyPorcelain/exclude file and point at
the file with --exclude-from.  I may also be tempted to check
$HOME/.MyPorcelain/exclude file and add it to give defaults per
user, but I do not do Porcelains, so...

```
