Article View: linux.kernel.git
Article #1938Re: Q: .gitignore and asterisk "*"
From: Junio C Hamano
Date: Fri, 30 Oct 2026 16:59
Date: Fri, 30 Oct 2026 16:59
76 lines
15840 bytes
15840 bytes
"Windl, Ulrich" <u.windl@ukr.de> writes:
> I think the documentation for gitignore(5) could be improved regarding "*":
> It's nor clear whether "*" matches an empty string.
> So when I have
> foo.log
> foo.msg
> foo.sh
> foo-whatever.log
> foo-whetever.msg
> Would e.g. "foo*.log" cover all the logs?
>
> The manual says:
> • An asterisk "*" matches anything except a slash. The character "?"
> matches any one character except "/". The range notation, e.g.
> [a-zA-Z], can be used to match one of the characters in a range.
> See fnmatch(3) and the FNM_PATHNAME flag for a more detailed
> description.
Very good point.
The reference to fnmatch(3) may not make readers to consult the
documentation for the library function. The system they are on may
not even have "man". fnmatch(3) often refers to glob(7), which
typically would say that a '*' (not between brackets) matches any
string, including the empty string. The reference to FNM_PATHNAME
we have there is an attempt to refer back to fnmatch(3) that would
typically say that the wildcard does not match a slash.
How about rewriting the entry like so to reduce external references?
----- >8 -----
Subject: gitignore: rewrite wildcard description
The documentation for '.gitignore' makes reference to fnmatch(3) and
FNM_PATHNAME to describe how an asterisk "*" and a question mark "?"
behave. Even though it spells out that these wildcard characters
do not match a slash, it does not say if an asterisk matches an
empty string (it does).
Rewrite the section so that the readers would get a more complete
picture without requiring them to know what fnmatch(3) and glob(7)
says.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/gitignore.adoc | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git c/Documentation/gitignore.adoc w/Documentation/gitignore.adoc
index 7979e50f18..671a5a4c99 100644
--- c/Documentation/gitignore.adoc
+++ w/Documentation/gitignore.adoc
@@ -110,11 +110,16 @@ PATTERN FORMAT
and `a/frotz` that is a directory (all paths are relative from
the `.gitignore` file).
- - An asterisk "`*`" matches anything except a slash.
- The character "`?`" matches any one character except "`/`".
- The range notation, e.g. `[a-zA-Z]`, can be used to match
- one of the characters in a range. See fnmatch(3) and the
- FNM_PATHNAME flag for a more detailed description.
+ - An asterisk "`*`" matches string of any length, and a question mark
+ "`?`" matches any single character, but these wildcard characters
+ do not match a slash "`/`".
+
+ - A pair of brackets that enclose characters match one of the listed
+ characters, and a range notation inside them, e.g., "`[a-zA-Z]`",
+ would behave as if all the characters in the range were listed there
+ instead. Wildcard characters "`*`" and "`?`" lose their special
+ meaning inside a pair of brackets, e.g., "`[*]`" would match an
+ asterisk and nothing else.
- A backslash ("`\`") can be used to escape any character. E.g., "`\*`"
matches a literal asterisk (and "`\a`" matches "`a`", even though
Technical Details
Message-ID:
<xmqq5wyjxgyn.fsf@gitster.g>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73924-linux-kernel-git=dewy.ruReferences:
<07b3498d83424cac87221724b371839a@ukr.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73924-linux-kernel-git=dewy.ru
From: gitster@pobox.com (Junio C Hamano)
Newsgroups: linux.kernel.git
Subject: Re: Q: .gitignore and asterisk "*"
Date: Fri, 30 Oct 2026 09:59:12 -0700
Organization: Usenet Network
Message-ID: <xmqq5wyjxgyn.fsf@gitster.g>
References: <07b3498d83424cac87221724b371839a@ukr.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2280311"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:zg4/hkRwQfPa3mS45eOmZg69kPE= sha256:6k12HAWpxr0d8Dbdzkxa8MTyhC2D3nuFmJo+cw1X5fw=
sha1:OMHt90QaVLNBysBlUV4oYW30Eu0= sha256:uUb4Q4hauwkZQt1nwkG9wkCD2SBth8QOENowmHQygHc=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id E1029125CA6; Fri, 30 Oct 2026 20:04:49 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=pobox.com header.b=eM5/DUkT; dkim=pass (2048-bit key)
header.d=messagingengine.com header.b=E7a1MSYO
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id OxTLT12RRdH7;
Fri, 30 Oct 2026 20:04:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-73924-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=pobox.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 98D56125CA4; Fri, 30 Oct 2026 20:04:25 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 399702E531; Fri, 30 Oct 2026 16:59:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793379557;
b=AFlqv45AhEk7kT2cCcP0WVDLfhEqpwOH6CMpGQFOX3mHJMNT+YCSDKsnCldEcin9KHPB
0RPpePqdoid3eMdf1LamNpb3mmA9oTOHWomdBdLvs3lkJoRLUcIQBeiwmCHnEpwkY2kKb
CDvf0w6GA+zXfXrb1Eg1TtmAzUyLjNHD2f7bX4n6PZ4eIgY4WTgfP/EdU0jnR64+bsyeE
PJCgRmvT5qP0NCXYKeZJgGsexEpRLdjn9zwOoo+j09ViBkoYq6xoF03PXHzcaE3m85sXZ
4xZf/6Pdpcq7LJ+XWRksX+7fULlMJBgoa6rfbinDRcA65pihN8bK2o8rR5MEBbKaB8w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793379557;
h=X-Original-To:Received:DMARC-Filter:Received:Received:DKIM-Signature:
DKIM-Signature:X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:
Message-Instance:X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:
X-ME-Proxy:Feedback-ID:Received:From:To:Cc:Subject:In-Reply-To:
References:Date:Message-ID:User-Agent:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding;
bh=iqERUGJ3m8BWocc14o+S5UOkjKS8/jSvxyNvss38l5M=;
b=2HqsapPyM3iOpeZx9szwtINUx9XRLLip6EHU2ZiGJItdYgBDK7Ef7o4p3jmXwjxywyDa
R4bLDGNeajh/rXnZnfAabU2H1SDLO3Lvkgv6Yk5Wo7ViD36JahN5WbjSh6d9dTRGdo5lh
Na36s1ys7V/CRX2TI2cuz+fWjel/aECaA8aFbDUcJb9Wsm1kTVfTDhAjvd7RYRVfBTCOU
le+2VJVKhlKhLgy5bibl8l377h9TIkGr/EBnJllTV1cwa8bC2ZCZoVx1na5xm1Jj9WbCj
bSUEYzbw86W0B6v9DYDJVx2eIUbrV/UuoUSE4PS7OMDr+vJb0Ouk6vpAeW32j9bkLqg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm1 header.b="eM5/DUkT";
dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=E7a1MSYO;
dmarc=pass header.from=pobox.com;
spf=pass smtp.mailfrom=pobox.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C67A606A321;
Fri, 30 Oct 2026 16:59:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm1 header.b=eM5/DUkT;
dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=E7a1MSYO
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.154
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793379556;
b=2A7EwH4cUNzjLqVMnA/ZCImAQM08GV8MyDNeNVCnlP5TqjqAGPjeT/EN8u9xBj/E6Z3l
AQrb1wZ3YdLCr5LbP8FUvZQ+q7YJSxP6O1vKrK4PT2l9V2JiHtpPSHU21LxL4xF5I38Un
HMh7LW9IGyQwwdFNHfhkXPMHQzOIqoXoOibDrJCIfu/k2ZJwB2L36tjrUTdLPdSRV+7o4
boucVCUIdSfWxzjWAdD/mrER4sjC6W52H4TjYsX4xe8TvVS+DOizodnKMyKx+bQPDT6/O
7yb/3rsT7T9+sAYz90CRQvOTadxoHgLeEZWm6QvbRMJByXEVpVUtX7YbOT41pKRptXQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793379556;
h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature:
X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance:
X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:
Received:From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:
User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding;
bh=iqERUGJ3m8BWocc14o+S5UOkjKS8/jSvxyNvss38l5M=;
b=cmwrRuX9rxwmwUH/pmUnvRBLe+AhWjC88osjAUyaghiQxB6VxCiL0N3nRGm7MtgUGCf5
Sr8Cp8ItIqILTAiRhXYbJ1yT52snzQ0waX1aEi8Dt3VT47Qmx1Q4x5j2Oo4SyCfdCZveB
FXjjzSscrke8ZrcjSaeguf1KGQUx7uqRMvK4qX7KODMxfJzWSE0zm8gUKAJ9hxucCQAxQ
qppEZPdY+j8Ev/ggIKhZF03tepZAVd24OUMIsAjpdDIB8RrW4RGOeVfpLl2PrwIKPvT4b
ZkDYU/u7KoPVUcruRFY2iTPLmz+5QT6BIKc2MXoY75wXRhCBdLnNMbInnmrBew46a+Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=pobox.com;
spf=pass smtp.mailfrom=pobox.com;
dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm1 header.b="eM5/DUkT";
dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=E7a1MSYO;
arc=none smtp.remote-ip=202.12.124.154
X-Received: from fhigh-b3-smtp.messagingengine.com (fhigh-b3-smtp.messagingengine.com [202.12.124.154])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id C64A0606A31D
for <git@vger.kernel.org>; Fri, 30 Oct 2026 16:59:15 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C64A0606A31D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com
X-Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43])
by mailfhigh.stl.internal (Postfix) with ESMTP id E01BE7A00D8
for <git@vger.kernel.org>; Fri, 30 Oct 2026 12:59:14 -0400 (EDT)
X-Received: from phl-frontend-02 ([10.202.2.161])
by phl-compute-03.internal (MEProxy); Fri, 30 Oct 2026 12:59:14 -0400
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc
:cc:content-transfer-encoding:content-type:content-type:date
:date:from:from:in-reply-to:in-reply-to:message-id:mime-version
:references:reply-to:subject:subject:to:to; s=fm1; t=1793379554;
x=1793465954; bh=iqERUGJ3m8BWocc14o+S5UOkjKS8/jSvxyNvss38l5M=; b=
eM5/DUkTcxcBswYesLEGkfOu7C1n/St1isTjpC+AwwLKxs32vdDlVSgNKvrQI1Yc
uVOqG65mqzkQPncvdSA4MKpzTtBI435bsbnlGGn7UyXMvJXJhRP9eiZX+COR9zUL
EjEYnEOGSK4Q6NS8IwciUAoQ/6XDgPcnoQU6SQ/3GDaMqxpeFESXzsPIxwjwLhM5
JulVVCrk4+898ew0/w8y1ygD0+UXAChQjPkhj0mUTEebLtQUqMkUlM/mxUTKSuQ7
nX0F+XV98757rnLfloZ7xxPiHn1iiad165uqy2rYU4135fnPF/PUOgmzVSc2gikT
GQCPoLusGhpGDK3smgy/ZA==
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:cc:content-transfer-encoding
:content-type:content-type:date:date:feedback-id:feedback-id
:from:from:in-reply-to:in-reply-to:message-id:mime-version
:references:reply-to:subject:subject:to:to:x-me-proxy
:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1793379554; x=
1793465954; bh=iqERUGJ3m8BWocc14o+S5UOkjKS8/jSvxyNvss38l5M=; b=E
7a1MSYOjmBiQX8hVIUg59Y3Rshhh4FXJKDLmMNv2IX5WmBGC86qcFIrN36Srbzka
crTTRKV/WDXQBI2SaucMKCG5Ae5l5nhytypE3rgG3ivPqXBiRPftQifc+P6PgFpm
nr3BxEwQN7f2vWdqopRvCAkl6Kas+I43al7XPEkHsQCdJAmB3EijMbUfOqjcCSb2
2xs74l1KJoXObwlO7Gp/aUPo1AqgT4O8D9ytxPmOCN0IZv63XT7hqdQBvAlNinxY
JFjlDl44HWxoJo72tYS27NK5xyK4CPhPA+Gy9O8EP8v/PlhS8Ypjm2qpGXp2Sjkm
HK+qI5nHS2zO3i8DY/u5A==
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-08;
repo=github.com/dkim2wg/interop; date=2026-10-28; sw=lmtpprox;
action=sign d=pobox.com a=rsa-sha256;
X-DKIM2-Signature: i=1; m=1; t=1793379554; d=pobox.com;
mf=PGdpdHN0ZXJAcG9ib3guY29tPg==;
rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+;
s=fm1:rsa-sha256:k1/gLbInNvP8mcSwKkO+SFhnVcYsjWfumk0CP0MQJV0njeI
vzuvwZgUMuCtcu71544fNwYozS7uGRDxjBwwr61oDgW2mdm4EXoAzVGyhR68D4OK
I9n9SzOiO+Ldjt/hfYGIayOe4+EmeBDjI2NxMwqmUC9Abj5YRDfWlUQtPrVx2X1u
hdTTREt9dNI6PXdnnUBvfWSNeni3I0F8zO1PAPQ39qwjPuUw9IEPWTWJBsOnbl1h
C1AUdQln5yd9GiOnmoBPCColV1I0lz8tUln2zlgepvdORUl86hqrCFyOg6rTQf3o
hxXnx7hRms+9SKQRWvCx5trSsEChfOu4Su64bhg==;
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-08;
repo=github.com/dkim2wg/interop; date=2026-10-28; sw=lmtpprox;
action=mi-m=1; hc=13;
hn=cc,content-transfer-encoding,content-type,date,feedback-id,
from,in-reply-to,message-id,mime-version,references,subject,to,
user-agent;
X-Message-Instance: m=1; h=sha256:ywUVtFCRcs8nm6tGFMOaQg24Oa37UKVVa+/ni8Bwiq8=:x19N+z/Pasr7intik+GrShKgLNJlB9yYE1saVOZcI20=;
X-ME-Sender: <xms:4szkatulVNPACDw6H7jkf4IVXIC3g4U9NDC-KWkFd_Uw1mBM52O1cg>
<xme:4szkat5Xw4l4nn3mPbxjOHxOBkqnpGcO5Nucq5C_VeltfAano6DrtQdNwkA1HgFaF
_hejBE8Qc9PcRhHql2PnmSHUqrBbvnBVrxot2V0TdDVqtvBT5Tquw>
X-ME-Received: <xmr:4szkauLlQ-KPQG0vllzeQjDrnmXvccxpSs-RShV2_ilvSjpSCDOFkiCaRPIVi8KZQxf-7vRjbD_4XIfKPMWsXpt1gX2U9FVvG9i3>
X-ME-Proxy-Cause: dmFkZTGk94ehy9fIpCv8C8I7oKIBApgyUP13hvXg1/SFk6W/IAQN07MpVfvYDQWRswtJfe
WKctGgXm9kwx3zNnU9Qe7nUW42TO5Hn+FRt4GdRVVVaogPO6ej8ZZYDoZNQNAAP9rZ3IRX
v5CR+8lbFZzdRhuqYRhNxN8fFpusgJimw2GMGsB6PNO2HmhmPe17Tn710yw+YD/14j4DKa
G1+7YlGwGSea7Zc7AVQVQws+wiQ4v2BeBdYYhRXvIG93GHrQ9WjkpSYVm+9j8pCKrFKhXz
hmBcMYJpUo89NjTjeDjj0mKoSsvIn8O7LzJIE7sABcA1byAwBPTD2cIigqNwzkDyt1Owr7
q4sHErSvV8nc2uA6Uag33377NYWz1mbnTusfW6Xaxy8uWmQk1gRbqVM/Stwug3oHoFZ2DX
ES8Kwt5uEBFIqW346N+6iw7nF51rNByc89/c31ktGx3YASPRomF7V7iM5733SpiwEX+mVS
RQsyCOk8oi/3g98DeaW5z8bP0uv64wo7aKxNR7aVzYZ9TKc+NjhtGMPPg04iIwY6tWOBNs
6yPmp+m6pJc9N8i9vN5Hs1ewJufer6B0AuvQToE4mb72fBZCsoViXbhwWXAxJWMrHHdPcP
osRSulNVse4iIPIiqUtWNmx9CpNyotSWRY42iMBMj4B5atuNKZDbkec0F/VQ
X-ME-Proxy: <xmx:4szkat5wlCj5jdmcHnqFPK6aMzrRBBbrDkekHB_hqqVpMhuyWm0KJA>
<xmx:4szkahz-pJ-NksCJA1UJXhwiQMaQKRMDEUxRNtoFr17z8rlhPS-z2A>
<xmx:4szkahbb7smip94Wci2UgagC2515oEc9kiLj8oFYhTmQxYy8O3tUzQ>
<xmx:4szkajQWpA2cTB2I5uoE7qd1f-e7yKIJQ8b77WeuRBv72yWSOdppPA>
<xmx:4szkalguAgkObtZJHLSBkA6hJobOcR2jRUFjkKHDAt4dj4lLzud4zQVu>
X-Feedback-ID: if26b431b:Fastmail
X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri,
30 Oct 2026 12:59:14 -0400 (EDT)
X-Cc: "git@vger.kernel.org" <git@vger.kernel.org>
X-In-Reply-To: <07b3498d83424cac87221724b371839a@ukr.de> (Ulrich Windl's message
of "Fri, 30 Oct 2026 10:46:01 +0000")
X-User-Agent: Gnus/5.13 (Gnus v5.13)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list