From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.157 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796136886; b=GWCEmyuH3wVnRsfj5FDzdjHagFJBz7iJaV+yzTHbT06HlNHpq8Uhd4h0ESDvavd6QQvH MfCykfqUDAHaBrB4gntu8iV2T+T8bkl7kwEg6Xy4ldGNBqES3wHc2RksLzNeaID3xzC5J HWo7MX7y3CgbcE1lmSY3XeuTlJp0YNECZ/+0TMrBlnGuew93JzDAlnAJmkgJpWRorA57F /6DacNwSPhrc5T/XUmiCzdcSRWSpWJ3dmfVit/7s6aJIvDk24Zyszg7l4pePylvVeW/Gv Ytlae3Spl2qZLUB4sgeS5LBqc6rT6YS1tUN/D63oY8SSeRmFGwdt1cmu9kx1VRpgv1g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796136886; 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:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=T0Ad5mj6Tp4vxlBZnAUgIT4UKTzTwaLYsnlC+iIRCHc=; b=ReqQUfKJHt7gqymmCrE4Jas9hYEdP/CSrAg5cx8wUwjOFSM4LNwE0PpV4D8u8mR6lcVd AZxsalb0GRhDGb53hylAVpax0YJNVIVFU67CJmOKTkcQknc0kAnRbJ9tO7eJgz3JACdAq RYZx8dogoR0PO9gd1BdvKkcLBJEXoWM+Vk9BmVJB5KQ5KPczt8nvY8h/iujVN/7evjuMQ cef3qew0SbiP5szoZQ6aCNwKnX39ywflYlLlIg33U8BKd5dfMkgdFwxOtHkZv4SzJkCj/ 9pTACzl4lbFwOFuJ4WSQ+IWypcVK7uJD9oOnf4pqkDNolV8UDpv4N65/f8wXL+1DGAA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=OrA4ueVe; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=VCKDw4xs; arc=none smtp.remote-ip=202.12.124.157 Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (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 B5A0C606A320 for ; Tue, 1 Dec 2026 14:54:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B5A0C606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=OrA4ueVe; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=VCKDw4xs Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 1E9AD7A056A for ; Tue, 1 Dec 2026 09:54:45 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Tue, 01 Dec 2026 09:54:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :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=fm3; t=1796136884; x=1796223284; bh=T0Ad5mj6Tp 4vxlBZnAUgIT4UKTzTwaLYsnlC+iIRCHc=; b=OrA4ueVeEeYsvLzKHx3mEXpYrL Y6k6wMbPLWAGvWVKFIFi9ePFLit01Ntan5kaQQ1WVMQmMCsSVKL7ULqtUAHGFLQA KjAmhtl353OEmjwd19FqpV6rTrsoBCME2MDoQh6Tt+UcyUTRAxCa0QsTwgGpQ+nr jKNuHE+WVPBv51h54Ssk0npvBeWFK0d/vQrJgFgfb+LSmseyC8OpYuvYmCvTCkIe ptDHqceXDOu4oBe+ZrSbI6LLEZ2SMeaimprG4WznyAw85fhCzttLxZ4MhrOha3Tp KvlMblTwi8epdSDIhp1CWkbjQIcuOMHTYK+VfuskHv1ohDTwlo8hdAvMi6jg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=fm3; t= 1796136884; x=1796223284; bh=T0Ad5mj6Tp4vxlBZnAUgIT4UKTzTwaLYsnl C+iIRCHc=; b=VCKDw4xsBixLa/eM/iKeBB32f/XUa+NapSrMXkivuGQee0MHShy JjUM8EppJYlwX1lK2Q0qKpR6WVCTqX6CsecXObuStRyZ4H4Nze4qPmsiG5chOqEB rqOg63lOPFbsma7BF4J0Bs1wHme2b57tjWtI2y/NRzUGkSgcDIVLqazrHcaTk+KU pvlR8tzUlfVWy2vg+nCtaZi/AznWA6HPuaiY7CSljLoR10WAHv4aw37663iJf4mB idPd5wf46QhMQGJa4T5Ryf81E8G0xAd+liKU5lKCHBRhwjvPrHVBfgOKnIYfqa/b uAapgfiXXAiVEdIz1vDBnHMfQHhswoz0M0g== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pks.im a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796136884; d=pks.im; mf=PHBzQHBrcy5pbT4=; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:uEgN8hiB26uZDPI5AVtzSXFKzc1TfYnojtEaG9b6xQWup1T Ltm8czQFRdkF2h4sMaXIqcNcwU4/ADmJDeStR+G0DHFp865L10N+6jZAiPcWr8y3 OmZwcPL6qJypyGPBbGakNJmVa9nenVAMe1OuNUe+v1SZY/c/jGlWd+30wjGRTwVy SJv5tAK2/B8Uq3YHFXDHuGGFamnvr120jsRODjEsbEMS+XhYQqkhW+3nVisNXJXi MWaN57zwIzlTWR/vDw3kgBuborVKr1MrszRVPB4/iUZIvcLIriUil4/FJ0n/GBRy FCTk+utKxpqKA9v7Y5mEShxPEet8Zlkj86T80kQ==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:RmX7Y7dTEP+kJbfCvIaDhteCHD5e6dCzy0hsxvB0TzM=:JtbSkWEyjOP/Ye+kudxPHCLtQya06NE+jaOAESaZK9I=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGdL1Oq+dtGeXqZQ2pGoWfRgBz/aksIOjT+I4niOPSVGsQ0XE+OP8B86WiT9+O9AC 9GsYUsq8otaVoJA9/6UrfmychmUMiC99i6/TUea96PA6fRxhob+vqsRt0zNmmfKd57OCYi jzXL/e6SGU8V1sQLdbwdI7k7rOpDztqZmm8lGp7Oo7/GjRLk7h4MnzN3oy8taBaGpQo9Wd 7Vbjl0Yv4Mq/9Jl9/dVG0aUPoMBXXPDzj6fKDssvhqA17iJ3/IkFNnd2kTvIvHeUBHgpDL Dw9oUPhUApGm4a/4RPJUj8UF72AWRT7ivg9bSBsX4llVGM+CTmC2hi86umSSWEJsSKlEES lsTsQ3AVlnnkPri8G1UjbRRUBffyzltHQWaGYmJKztdp2803yowt+lyHn1sC135XI60/4o 0kGYzN4ySikL4OlKVeGBnE0iP1FGM2yTCAsojr9gSqqDxD8N55SKr6RLo1lZrkoOUOtEZs 7wfWd00oiFezLGjXzixz/QK+GwvGsGZffLkOg47jSXp4BlYoRtLcfZ6jqrRiWdMZCaJM4w HIOzIpnJtNBDlmloG3gmxbQQoeqdQR7Qkx/1ZSZ266LgozHlwvKaiB/vwL5wBo6oc3wviM 8Qo5S31G/G6mfKEX+IMTCRypMH7dSR9i2KY+++k5XAveM7hMi+jv775ioXrQ X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Dec 2026 09:54:43 -0500 (EST) Received: by mail (OpenSMTPD) with ESMTPSA id 2431a0eb (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 1 Dec 2026 14:54:40 +0000 (UTC) Date: Tue, 1 Dec 2026 15:54:37 +0100 From: Patrick Steinhardt To: Aniket Gupta Cc: git@vger.kernel.org, Junio C Hamano , Matt Hunter , Mike Beaton , Phillip Wood Subject: Re: [PATCH v3] dir: ignore CRLF-empty and space-only lines in pattern files Message-ID: References: <20261106182945.1316297-1-aniketgupta3001@gmail.com> <20261129060057.74590-1-aniketgupta3001@gmail.com> <20261201080040.47247-1-aniketgupta3001@gmail.com> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261201080040.47247-1-aniketgupta3001@gmail.com> On Tue, Dec 01, 2026 at 01:30:40PM +0530, Aniket Gupta wrote: > add_patterns_from_buffer() skips an empty line which starts right at the > '\n', before it strips the '\r' or any trailing spaces. A two byte > "\r\n" line in a CRLF file, or a line that holds only spaces (with or > without the '\r') is not empty at that point. Stripping the '\r' and > calling trim_trailing_spaces() reduces it to an empty string, which is > then passed to add_pattern(). > > parse_path_pattern() turns that empty string into a 0 length pattern > with PATTERN_FLAG_NODIR. The directory walk checks a directory before it > appends the trailing slash. Thus, status and a plain add are not > affected. Huh, affected by what? At this point I have no idea what the issue even is, the only thing I know is that we have an empty pattern now. > A path argument that ends in a slash is a different scenario. > For eg, with "git check-ignore foo/", the basename is empty and > match_basename() matches the 0 length pattern and "check-ignore -v" > names that line as the reason foo/ is ignored. Okay. With git-check-ignore(1) we can append that slash ourselves, and thus it may trigger the bug. And this is in contrast to git-status(1) and git-add(1) seemingly, which never have that trailing slash. Sorry for repeating all of that, but I'm trying to deciper this AI message and am having a hard time doing so. > Cone-mode sparse-checkout is affected as well. For such a line, > add_pattern_to_hashsets() sees a pattern shorter than 2 characters, > warns "unrecognized pattern: ''" and disables cone pattern matching. Okay. Is this a cosmetic issue, or is it something that results in wrong behaviour? > Skip calling add_pattern() when the trimmed line is empty. This follows > gitignore(5) which says that trailing spaces are ignored unless quoted > with backslash. A file name made of spaces can still be matched by > quoting the spaces. Okay. I think overall this depends a bit on how you're reading that manpage and how you interpret "A blank line". When reading it I wouldn't necessarily think that the "Trailing spaces are ignored" rule also applies to "A blank line", but I think it's a sensible interpretation regardless of that. Would it make sense to maybe clarify the rule to say "A blank line or a line that consists of spaces, only, matches no files"? > diff --git a/dir.c b/dir.c > index d896e7be4b..5a8a28afef 100644 > --- a/dir.c > +++ b/dir.c > @@ -1249,7 +1249,8 @@ int add_patterns_from_buffer(char *buf, size_t size, > if (entry != buf + i && entry[0] != '#') { > buf[i - (i && buf[i-1] == '\r')] = 0; > trim_trailing_spaces(entry); > - add_pattern(entry, base, baselen, pl, lineno); > + if (*entry) > + add_pattern(entry, base, baselen, pl, lineno); > } > lineno++; > entry = buf + i + 1; The change looks obviously good to me. Thanks! Patrick