public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Patrick Steinhardt <ps@pks.im>, git@vger.kernel.org
Cc: Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH] editorconfig: fix style not applying to subdirs anymore
Date: Wed, 11 Mar 2026 14:16:53 +0000	[thread overview]
Message-ID: <1eb3b78c-5833-4fa9-83f6-237d4a3e78d3@gmail.com> (raw)
In-Reply-To: <20260311-b4-pks-editorconfig-fix-subdirs-v1-1-4938193ccd31@pks.im>



On 11/03/2026 07:09, Patrick Steinhardt wrote:
> In 046e1117d5 (templates: add .gitattributes entry for sample hooks,
> 2026-02-13) we have added another pattern to our EditorConfig that sets
> the style for our hook templates. As our templates are located in
> "templates/hooks/", we explicitly specify that subdirectory as part of
> the globbing pattern.
> 
> This change causes files in other subdirectories, like for example
> "builtin/add.c", to not be configured properly anymore. This seems to
> stem from a subtlety in the EditorConfig specification [1]:
> 
>    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.
> 
> What's interesting is that the _whole_ expression is considered to be
> the glob.

Ouch, I'd missed that, thanks for fixing it

> So when the expression used is for example "{*.c,foo/*.h}",
> then it will be considered a single glob, and because it contains a path
> separator we will now anchor "*.c" matches to the same directory as the
> ".editorconfig" file.
> 
> Fix this issue by splitting out the configuration for hook templates
> into a separate section. It leads to a tiny bit of duplication, but the
> alternative would be something like the following (note the "{,**/}"):
> 
>    [{{,**/}*.{c,h,sh,bash,perl,pl,pm,txt,adoc},config.mak.*,{,**/}Makefile,templates/hooks/*.sample}]
>    indent_style = tab
>    tab_width = 8
> 
> This starts to become somewhat hard to read, so the duplication feels
> like the better tradeoff.

Agreed

Thanks

Phillip

> [1]: https://spec.editorconfig.org/#glob-expressions
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> Hi,
> 
> this fixes a small regression in our EditorConfig introduced in
> 046e1117d5 (templates: add .gitattributes entry for sample hooks,
> 2026-02-13). Thanks!
> 
> Patrick
> ---
>   .editorconfig | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/.editorconfig b/.editorconfig
> index 6e4eaa8e95..82e121a417 100644
> --- a/.editorconfig
> +++ b/.editorconfig
> @@ -4,7 +4,11 @@ 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}]
> +[{*.{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: 7f19e4e1b6a3ad259e2ed66033e01e03b8b74c5e
> change-id: 20260311-b4-pks-editorconfig-fix-subdirs-981e6db389ec
> 
> 


  reply	other threads:[~2026-03-11 14:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11  7:09 [PATCH] editorconfig: fix style not applying to subdirs anymore Patrick Steinhardt
2026-03-11 14:16 ` Phillip Wood [this message]
2026-03-11 17:32   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1eb3b78c-5833-4fa9-83f6-237d4a3e78d3@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox