git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] extending git-ls-files --exclude.

From
Junio C Hamano <junkio@cox.net>
Date
Jul 25, 2005, 19:56 UTC
Message-ID
<7v1x5mmzhq.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20050725064140.95259.qmail@web26304.mail.ukl.yahoo.com>
Marco Costalba <mcostalba@yahoo.it> writes:
Show 6 quoted lines
> Peraphs, if the file name of excluded list is the same for each directory, 
> e.g. .gitignore or something similar, instead of --exclude-per-directory
> we can use a concept of file validity 'scope' and just use --exclude-from=<file>.
> If entering in a directory <file> is found its contents are appended and 
> removed when leaving directory. A bad analogy can be with the use of 
> recursive Makefile.

I do not know if you noticed it, but the patch already have the concept of "scope". If a pattern has a slash '/' it is scoped to the named directory by using FNM_PATHNAME. "The named directory" for command line --exclude and --exclude-from are relative to the project top while it is relative to the directory the file being used is in for --exclude-per-directory case.

> If we use the 'scope' logic we can just prepend path when adding entries
> and serach with with FNM_PATHNAME flag.

You suggest to always use FNM_PATHNAME by adjusting the pattern by prefixing the scope. While that can theoretically be made to work just as the posted patch does, you need to realize it is a lot more cumbersome to deal with metacharacters in pathnames your way. If the prefix you need to add (because you are now looking at a path for that directory which has a funny name) is "foo*bar", you need to add "foo\*bar" to the pattern in order to make sure that the asterisk is not used to match anything other than a literal asterisk, for example.

You could argue that nobody should use funny characters in pathnames, and you could further argue that current Porcelains do not handle certain characters in pathnames anyway so why bother. But ls-files being core, which is "the funny filesystem layer to build SCM on", I would like to be careful not to be unnecessarily restrictive.

Previous: Junio C Hamano
Message 3 of 3 in “Re: [RFC] extending git-ls-files --exclude.”
  1. Marco CostalbaJul 25, 2005
  2. Junio C HamanoJul 25, 2005
  3. Junio C HamanoJul 25, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.