From ce3045e081548e0797c647490e5048bd46752462 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sat, 3 Oct 2026 15:49:17 +0200 Subject: [PATCH] topdir.mk: Derive GITIGNORE_PATTERNS_END from TOP The !-exceptions in the generated .gitignore are computed by a grep pattern that hardcodes the project name, while the top ignore line comes from GITIGNORE_PATTERNS_TOP. A project that overrides GITIGNORE_PATTERNS_TOP - jw-pkg's Makefile sets it to empty - still gets the hardcoded exceptions, and patterns a project adds there get no exceptions at all, so the two can drift apart. Derive the exception pattern from the same variable: - new GITIGNORE_PATTERNS_TOP_INV joins the patterns of GITIGNORE_PATTERNS_TOP with |, each wrapped in word boundaries, plus the __init__.py pattern - GITIGNORE_PATTERNS_END greps the tracked files for that alternation with grep -E instead of a hardcoded BRE, so the dot in __init__.py is literal instead of matching any character With the default GITIGNORE_PATTERNS_TOP the generated .gitignore is byte-for-byte identical to before. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.0.0 Signed-off-by: Jan Lindemann --- make/topdir.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make/topdir.mk b/make/topdir.mk index f1bd44c4..e83c60e3 100644 --- a/make/topdir.mk +++ b/make/topdir.mk @@ -98,7 +98,8 @@ JW_PKG_TMPL_UPDATE ?= $(PYTHON) $(JWB_SCRIPT_DIR)/jw-pkg.py -p $(PROJEC projects create-file --format tmpl --search-path $(subst $(space),:,$(JW_PKG_TMPL_SEARCH_PATH)) --template-name GITIGNORE_PATTERNS_TOP ?= $(PROJECT) -GITIGNORE_PATTERNS_END ?= $(addprefix !,$(shell git ls-files 2>/dev/null | grep "\(\b$(PROJECT)\b\|__init__.py\)" | xargs)) +GITIGNORE_PATTERNS_TOP_INV ?= $(subst $(space),|,$(strip $(addprefix \b,$(addsuffix \b,$(GITIGNORE_PATTERNS_TOP))) __init__\.py)) +GITIGNORE_PATTERNS_END ?= $(addprefix !,$(shell git ls-files 2>/dev/null | grep -E "($(GITIGNORE_PATTERNS_TOP_INV))" | xargs)) all: topdir config test: all -- 2.56.0