threads / discuss / 2550

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

Subject: Cogito and --exclude vs --exclude-per-directory

## tl;dr

3 messages between Nov 16, 2005 and Nov 16, 2005.

replies: 2people: 2as markdown or json

Karl Hasselström· Nov 16, 2005, 09:36 UTC · lore
[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· Nov 16, 2005, 09:38 UTC · re: Karl Hasselström · lore

Re: Cogito and --exclude vs --exclude-per-directory

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· Nov 16, 2005, 19:01 UTC · re: Karl Hasselström · lore

Re: Cogito and --exclude vs --exclude-per-directory

Karl Hasselström <kha@treskal.com> writes:
Show 6 quoted lines
> [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...

← back to recent threads