* [PATCH] .editorconfig: separate tree-wide glob patterns
@ 2026-03-15 21:23 Taylor Blau
2026-03-16 0:09 ` Taylor Blau
0 siblings, 1 reply; 2+ messages in thread
From: Taylor Blau @ 2026-03-15 21:23 UTC (permalink / raw)
To: git; +Cc: brian m. carlson, Junio C Hamano, Phillip Wood
In 046e1117d5d (templates: add .gitattributes entry for sample hooks,
2026-02-13), we added a sub-directory specific pattern to our
.editorconfig's main section. Prior to 046e1117d5d, all glob patterns
within that section applied to files at any level in the tree (e.g., the
`*.c` rule matched both "pack-objects.c" and "builtin/pack-objects.c").
Ordinarily, we would expect that the change in 046e1117d5d would not
have an effect outside of applying our settings to
`templates/hooks/*.sample` in addition to the existing globs, that is
not the case.
The EditorConfig specification has a quirk[1] which changes the behavior
of globbed patterns when the section contains patterns which contain
path separators. Namely:
If the glob contains a path separator (a / not inside square
brackets), then the glob is relative to the directory level of the
particular .editorconfig file itself. Otherwise the pattern may also
match at any level below the .editorconfig level. [...]
While it seems like this should apply only within a particular glob
(e.g., in a section covering `{*.foo,bar/*.baz}` all `*.foo` files (at
any level of the tree) should match, but `*.baz` files match only when
they are within directory `bar`), it seems to apply to *all* globs
within that section's filter.
In practice, this means that a file like "builtin/pack-objects.c" would
have matched the rules in our main section until commit 046e1117d5d was
applied, but no longer afterwords.
(It's possible that this isn't what the specification intends and that
instead I'm observing implementation-specific quirks. I first saw this
in vim-editorconfig, which is quite popular, so perhaps this is part of
the de-facto specification.)
To ensure that these rules are applied in a pre-046e1117d5d fashion,
split this section in two: one for patterns that don't contain path
separators and another for ones that do. This restores the
pre-046e1117d5d behavior where, e.g., our `*.c` rule matches C files at
any level within the tree.
Add a brief note above this rule in an attempt to prevent similar
changes in the future.
[1]: https://spec.editorconfig.org/#glob-expressions
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
.editorconfig | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/.editorconfig b/.editorconfig
index 6e4eaa8e955..d06f5c6100b 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -4,7 +4,14 @@ insert_final_newline = true
# The settings for C (*.c and *.h) files are mirrored in .clang-format. Keep
# them in sync.
-[{*.{c,h,sh,bash,perl,pl,pm,txt,adoc},config.mak.*,Makefile,templates/hooks/*.sample}]
+#
+# Only list glob patterns intended to match throughout the entire tree. Create
+# new rules for files in specific sub-directories (as below), if needed.
+[{*.{c,h,sh,bash,perl,pl,pm,txt,adoc},config.mak.*,Makefile}]
+indent_style = tab
+tab_width = 8
+
+[templates/hooks/*.sample]
indent_style = tab
tab_width = 8
base-commit: dc6ecd5354dca88d51b6d6562777fc8fc10d77e1
--
2.53.0.308.g50d063e335a
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] .editorconfig: separate tree-wide glob patterns
2026-03-15 21:23 [PATCH] .editorconfig: separate tree-wide glob patterns Taylor Blau
@ 2026-03-16 0:09 ` Taylor Blau
0 siblings, 0 replies; 2+ messages in thread
From: Taylor Blau @ 2026-03-16 0:09 UTC (permalink / raw)
To: git; +Cc: brian m. carlson, Junio C Hamano, Phillip Wood,
Patrick Steinhardt
On Sun, Mar 15, 2026 at 05:23:31PM -0400, Taylor Blau wrote:
> ---
> .editorconfig | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
Heh, serves me right for trying to send something to the list after
vacation without being fully caught up ;-). Patrick already took care of
this in his series [1].
Our approach is ever so slightly different, but the end result is the
same. His patch is further along, so let's drop this one in favor of
his.
Sorry for the noise :-).
Thanks,
Taylor
[1]: https://lore.kernel.org/git/20260311-b4-pks-editorconfig-fix-subdirs-v1-1-4938193ccd31@pks.im/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-16 0:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-15 21:23 [PATCH] .editorconfig: separate tree-wide glob patterns Taylor Blau
2026-03-16 0:09 ` Taylor Blau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox