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

Re: Expanding Includes in .gitignore

From
Alexei Lozovsky <a.lozovsky@gmail.com>
Date
Oct 27, 2016, 08:19 UTC
Message-ID
<CALhvvbYqeWw+q=TPxTpve6JKoy0URYeWxj2vVOnzrA_g3Z3esA@mail.gmail.com>
In-Reply-To
<80919456-7563-2c16-ba23-ce4fcc2777de@pelly.co>
> I'm thinking something like ". path/to/include/file" in an ignore file,
> and/or creating .gitignore.d and/or allowing $HOME/.config/git/ignore
> and $GIT_DIR/info/exclude to be directories. Or some sane and consistent
> mixture of these things.

I think the rc.d-like approach with directories is better as it does not add new magical filenames (what if I absolutely do need to name my directories ". path", with a space? :) keeping the syntax of gitignores themselves simple, and allowing us to think of files as still being separate entities. This can be useful for the following case:

> In the case of a directory the plan would be to add links to files
> stored/sourced elsewhere. This does pose a precedence question which I
> haven't thought about yet, but probably makes it too hard for the
> limited value it brings.

As I understand, the precedence only matters for negative patterns (the ones that start with an exclamation mark, !). For example, suppose you have files 'foo1' and 'foo2'. This .gitignore

    foo*
    !foo1

will ignore foo2, but will show foo1. However, if the lines are swapped:

    !foo1
    foo*
then both foo1 and foo2 will be ignored.

Now, if we consider the case of multiple .gitignore files, it could be unexpected and possibly annoying for negative patterns in one file to affect the patterns added by some other files. I would find it more conceptually simple to apply individual .gitignores one by one, as opposed to parsing them all and creating one giant exclusion rule. (In technical terms, this means keeping one struct exclude_list for each .gitignore, not merging them all into one single list.)

In this case there should be no precendence problems as applied gitignores only add new ignored files, without un-ignoring anything previously ignored by other files.

However, if we allow textual inclusion, then it means that we can put a gitignore into our gitignore so that we can unignore while we ignore, which again brings us the question of whether it is actually needed and expected.

> I would like to know the desirability/practicality/stupidity of such a
> feature as I believe it is within my skillset to implement it.

In my mind, this feature definitely has utility and it can be implemented in backwards-compatible way, so why not.

However, I do not recall any precendent of git using rc.d-like configs. And some can argue that your goal can be achieved by generating the .gitignore by some external means and symlinking the result into .git/info/exclude, so this is not Git's problem and we should not be overcomplicating things with something as simple as a list exclude patterns. This line of argument also can be used to opposes any textual inclusion as well, because it can be expanded into 'why don't we add a Turing-complete programming language then to specify the patterns to ignore'.

Previous: Aaron PellyNext: Aaron Pelly
Message 4 of 24 in “Expanding Includes in .gitignore”
  1. Aaron PellyOct 27, 2016
  2. Stefan BellerOct 27, 2016
  3. Aaron PellyOct 27, 2016
  4. Alexei LozovskyOct 27, 2016
  5. Aaron PellyOct 27, 2016
  6. Jeff KingOct 27, 2016
  7. Jacob KellerOct 27, 2016
  8. Aaron PellyOct 27, 2016
  9. Jeff KingOct 27, 2016
  10. Aaron PellyOct 27, 2016
  11. Jacob KellerOct 27, 2016
  12. Duy NguyenOct 30, 2016
  13. Aaron PellyOct 27, 2016
  14. Jeff KingOct 27, 2016
  15. Jeff KingOct 27, 2016
  16. Aaron PellyOct 27, 2016
  17. Aaron PellyOct 27, 2016
  18. Junio C HamanoOct 28, 2016
  19. Aaron PellyOct 28, 2016
  20. Duy NguyenOct 30, 2016
  21. Jeff KingOct 30, 2016
  22. Aaron PellyOct 27, 2016
  23. Aaron PellyOct 27, 2016
  24. Jeff KingOct 28, 2016

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.