{"thread":{"id":"65256","subject":"[PATCH] .editorconfig: separate tree-wide glob patterns","startedAt":"2026-03-15T21:23:33Z","lastAt":"2026-03-16T00:09:46Z","messageCount":2,"participants":["Taylor Blau"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"539050","messageId":"518d71de9cdd71d0fc259740cf0da075bcf79746.1773609807.git.me@ttaylorr.com","threadId":"65256","inReplyTo":null,"subject":"[PATCH] .editorconfig: separate tree-wide glob patterns","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2026-03-15T21:23:31Z","receivedAt":"2026-03-15T21:23:33Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"In 046e1117d5d (templates: add .gitattributes entry for sample hooks,\n2026-02-13), we added a sub-directory specific pattern to our\n.editorconfig's main section. Prior to 046e1117d5d, all glob patterns\nwithin that section applied to files at any level in the tree (e.g., the\n`*.c` rule matched both \"pack-objects.c\" and \"builtin/pack-objects.c\").\n\nOrdinarily, we would expect that the change in 046e1117d5d would not\nhave an effect outside of applying our settings to\n`templates/hooks/*.sample` in addition to the existing globs, that is\nnot the case.\n\nThe EditorConfig specification has a quirk[1] which changes the behavior\nof globbed patterns when the section contains patterns which contain\npath separators. Namely:\n\n    If the glob contains a path separator (a / not inside square\n    brackets), then the glob is relative to the directory level of the\n    particular .editorconfig file itself. Otherwise the pattern may also\n    match at any level below the .editorconfig level. [...]\n\nWhile it seems like this should apply only within a particular glob\n(e.g., in a section covering `{*.foo,bar/*.baz}` all `*.foo` files (at\nany level of the tree) should match, but `*.baz` files match only when\nthey are within directory `bar`), it seems to apply to *all* globs\nwithin that section's filter.\n\nIn practice, this means that a file like \"builtin/pack-objects.c\" would\nhave matched the rules in our main section until commit 046e1117d5d was\napplied, but no longer afterwords.\n\n(It's possible that this isn't what the specification intends and that\ninstead I'm observing implementation-specific quirks. I first saw this\nin vim-editorconfig, which is quite popular, so perhaps this is part of\nthe de-facto specification.)\n\nTo ensure that these rules are applied in a pre-046e1117d5d fashion,\nsplit this section in two: one for patterns that don't contain path\nseparators and another for ones that do. This restores the\npre-046e1117d5d behavior where, e.g., our `*.c` rule matches C files at\nany level within the tree.\n\nAdd a brief note above this rule in an attempt to prevent similar\nchanges in the future.\n\n[1]: https://spec.editorconfig.org/#glob-expressions\n\nSigned-off-by: Taylor Blau <me@ttaylorr.com>\n---\n .editorconfig | 9 ++++++++-\n 1 file changed, 8 insertions(+), 1 deletion(-)\n\ndiff --git a/.editorconfig b/.editorconfig\nindex 6e4eaa8e955..d06f5c6100b 100644\n--- a/.editorconfig\n+++ b/.editorconfig\n@@ -4,7 +4,14 @@ insert_final_newline = true\n \n # The settings for C (*.c and *.h) files are mirrored in .clang-format.  Keep\n # them in sync.\n-[{*.{c,h,sh,bash,perl,pl,pm,txt,adoc},config.mak.*,Makefile,templates/hooks/*.sample}]\n+#\n+# Only list glob patterns intended to match throughout the entire tree. Create\n+# new rules for files in specific sub-directories (as below), if needed.\n+[{*.{c,h,sh,bash,perl,pl,pm,txt,adoc},config.mak.*,Makefile}]\n+indent_style = tab\n+tab_width = 8\n+\n+[templates/hooks/*.sample]\n indent_style = tab\n tab_width = 8\n \n\nbase-commit: dc6ecd5354dca88d51b6d6562777fc8fc10d77e1\n-- \n2.53.0.308.g50d063e335a\n"},{"id":"539053","messageId":"abdKRVm29/zJsMZW@nand.local","threadId":"65256","inReplyTo":"518d71de9cdd71d0fc259740cf0da075bcf79746.1773609807.git.me@ttaylorr.com","subject":"Re: [PATCH] .editorconfig: separate tree-wide glob patterns","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2026-03-16T00:09:41Z","receivedAt":"2026-03-16T00:09:46Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Sun, Mar 15, 2026 at 05:23:31PM -0400, Taylor Blau wrote:\n> ---\n>  .editorconfig | 9 ++++++++-\n>  1 file changed, 8 insertions(+), 1 deletion(-)\n\nHeh, serves me right for trying to send something to the list after\nvacation without being fully caught up ;-). Patrick already took care of\nthis in his series [1].\n\nOur approach is ever so slightly different, but the end result is the\nsame. His patch is further along, so let's drop this one in favor of\nhis.\n\nSorry for the noise :-).\n\nThanks,\nTaylor\n\n[1]: https://lore.kernel.org/git/20260311-b4-pks-editorconfig-fix-subdirs-v1-1-4938193ccd31@pks.im/\n"}]}