🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #4225

Re: [PATCH v3] dir: ignore CRLF-empty and space-only lines in pattern files

#4225
From: Aniket Gupta
Date: Tue, 01 Dec 2026 19:11
46 lines
13100 bytes
> 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.

The problem is a line in a pattern file that "looks empty" but isnt. It
is either a 2 byte "\r\n" line in a file with CRLF line endings, or a
line that holds only spaces. Git skips an empty line by default,
however, these 2 lines only become empty after git strips the "\r" and
the trailing spaces, and by then, it passes the empty string to
add_pattern() which records a zero length pattern. A zero length pattern
matches a path argument that ends in a slash because its basename is
empty, so "git check-ignore foo/" says an untracked foo/ is ignored
because of that line. In a cone-mode sparse-checkout file, the same line
makes git print 2 warnings and disable cone matching. In the patch I try
to skip a line which is empty after trimming. Allow me to start the
message this way in v4.

> 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.

True. status and add match a directory before they add the slash.
check-ignore can be given a path argument that ends in one.

> Sorry for repeating all of that, but I'm trying to deciper this AI
> message and am having a hard time doing so.

Claude discovered the problem while I was trying to understand the code
around it. Since I am new to open source and English not being my first
language, I use it to review my code and to correct my messages. I
realize I am only making it more complicated for your understanding.

> Okay. Is this a cosmetic issue, or is it something that results in
> wrong behaviour?

It does not check out wrong files, but it is more than cosmetic. With
one such line in a cone-mode sparse-checkout file, git prints 2 warnings
and disables cone matching. Because of that, the sparse index is
expanded to a full one, and "git sparse-checkout list" shows raw
patterns like "/a/" instead of the directory name "a". I can explain
like this in v4.

> 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"?

Yeah I think that would help. I will change it in gitignore.adoc in v4.
Technical Details
Message-ID: <20261201191133.16201-1-aniketgupta3001@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76821-linux-kernel-git=dewy.ru
References: <20261106182945.1316297-1-aniketgupta3001@gmail.com> <20261129060057.74590-1-aniketgupta3001@gmail.com> <20261201080040.47247-1-aniketgupta3001@gmail.com> <aw7frcoTfryxeIPX@pks.im>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76821-linux-kernel-git=dewy.ru
From: aniketgupta3001@gmail.com (Aniket Gupta)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v3] dir: ignore CRLF-empty and space-only lines in pattern files
Date: Wed,  2 Dec 2026 00:41:33 +0530
Organization: Usenet Network
Message-ID: <20261201191133.16201-1-aniketgupta3001@gmail.com>
References: <20261106182945.1316297-1-aniketgupta3001@gmail.com> <20261129060057.74590-1-aniketgupta3001@gmail.com> <20261201080040.47247-1-aniketgupta3001@gmail.com> <aw7frcoTfryxeIPX@pks.im>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1799005"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:PD5RAr2AzI9X3a8j79OV9niMClU= sha256:Wvl0wTVj2iART3tA+FqlKXwevQq/DcqTFck9ojRJKuA=
	sha1:Wr9hvZ43WEyH4EITGGnWt1gKgkA= sha256:yCFysiJ9Qb2TdgaN4jWVKaxqD0+KgV9CQ9RnNq+UN4A=
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 DDA3D117474; Tue,  1 Dec 2026 22:11:55 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.049
X-Spam-Status: No, score=-2.049 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
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 F6yLLK4ynIvA;
	Tue,  1 Dec 2026 22:11:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-76821-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 07E2E117400; Tue,  1 Dec 2026 22:11:45 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 60A442825E; Tue,  1 Dec 2026 19:11:43 +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=1796152302;
	b=Fli6gT/NW6VOOZo7JMzgmZNShuGEZZ6J0VGZY508JDpsin6hdr1A2duG+NqrD70P7a2S
	 b1FnBGZOKDtzM/sJCW0YPW1FPN6tdikKJKPyPFsXcvRZhXa2OKnKZTqEa5ZOWWcrLA6vm
	 E53TYa3uvcfsO2eq/clSjT5t239zGCIrRNJ886jO09hKduXwLTsCmcUh8nP4RH6spNInc
	 KhknqvOr1QdPo7UdI0OvmURdBnDc9gQ4vCSM9L++SvZC9qbS27278D2XQKR6FiocUuEHR
	 K8Zyz804VfdbOUBVc4iKgLINir6eafPA51eFpgwkw0kKdNTwH6LQt4SzV/jlYUrdUNw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796152302;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Y92Yis+9uSTVEfGdDJfSRMLJ+j4cKiqZ3xcGcZ88jQI=;
	b=JyHVREOXlwsgcate+zoAYOgmkuqB6XZ0C/HnEWUe91cKEII6iVmvLnR02Vs53ZgS0IYf
	 MBBNU4P1grTtd75S0hZszzW5hgEFjb5Ny3q3mBK7Bq4uZrBEbXK2FvJhl8D9J91OaxBvb
	 cIBZ+NujSCwXXIHJxF07vb2loX+vXo7ZTnVZHeOCcllgouawq2itB/inetutaLInUPZUH
	 Kzb7DhwOBv5oazdCkuo32c5Xtyoy7B+i6XeCM02LC8vMVmc+Ng3pwZ83rMmUWLVss2pSp
	 9tZaGIYZbS338ytc8UpOuPz4O3SvdRzYOaoOpG/VKLk6XgPNYdmoS+C7ii7An11Q1Eg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=mUBNXCNg;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.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 AC4B6606A32C;
	Tue,  1 Dec 2026 19:11:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=mUBNXCNg
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.46
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796152301;
	b=4tvlPx5WOg+3egW+ggtGOjioiqV1zmRE5/pkjLwUdLBlhgeOJlOzwsSvjc0yOjk28GDA
	 ZelfD0TjS+6/dsEyJiNPxf4TXiAb3WYHaNc6wYjjODsfScqmqwwETWh9ePi1xKrUJBY0O
	 eg0vlwsqC8XEQFvDMCpQiGEDiI7zaNUG7GtdvwU+rK3FqhfdJKZwZalPk0+vrLR2Fflgg
	 dIc+yMd34bfy7y+7JgYRfEUmlJj5GmfRplur6TTu94M9PgbER4nZC/i2rz4vy0aY5Swtn
	 Gp3m6Ynx3BkfryUXurKLSfGqN85PybjiAqR3k5vplkNHjHlkN/abMWQtOvOPo32nzuA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796152301;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Y92Yis+9uSTVEfGdDJfSRMLJ+j4cKiqZ3xcGcZ88jQI=;
	b=Ait2SR7oGhOBCnM6avVtKByLM5E2tO3WRRPZv/Iy6iM7s4kDesPefHvhHHUEiIlcWtxf
	 MlzRmu0k1LQCf2kRzpbtCdylQD3RqT+TEczJmo19d3SmZ+TWxsLS24jJlOOOk2fIixV45
	 9JzDmKhvpsFLPm/ct7+xuCJ3vV19OUzx63EM6rtsrAxDZww//i3lbqqWhrk15OLsNLq2w
	 ArSp1boqinUkdSRkup7odUufDP++XFF1ZXKI/4wMIPr/S3t2DcRXaNYxYRUzeSKcG1vun
	 qIKxSSt8oItB39jGBuQTqMxg2R6bHzMY12HJG2nPIuObPYvxV7ARhqaar4h1PdBh8+Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=mUBNXCNg;
	arc=none smtp.remote-ip=74.125.82.46
X-Received: from mail-dl1-f46.google.com (mail-dl1-f46.google.com [74.125.82.46])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8267B606A31A
	for <git@vger.kernel.org>; Tue,  1 Dec 2026 19:11:41 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8267B606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dl1-f46.google.com with SMTP id a92af1059eb24-1b5ade5e0c1so6311973c88.1
        for <git@vger.kernel.org>; Tue, 01 Dec 2026 11:11:41 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796152301; x=1796757101; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=Y92Yis+9uSTVEfGdDJfSRMLJ+j4cKiqZ3xcGcZ88jQI=;
        b=mUBNXCNgS6GgIOmJsh3h6NQ+QQne+zI7Igaz1pP5d6dx+35GClvCy5qTAJ2DOpd+8y
         gpPD978Z+CstIph1pVEfblPyqtC2+Rim2ZIR4lSIMutmr1DRCHnhDPoIQa0hrbH+2pfw
         JIkJtIujzz+892b9IpNVqQ5IA/qY0wNqUJHAsSgCSy1tdrbjWBFme6P9G+Rd4tIWfFv3
         Y31l0N89UE6aLWZmcfAt4aHVsUfLTYGoLI2920ejDSnn/c3rIDtA3T9XuYS8Xqd7LcRW
         oJptrN1P5xsrB5LSf1cdgvDniR3Zl/N6qCC0kyM/UONgrtnqb6XhQW0HJF4IP5jV38C3
         6HEQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796152301; x=1796757101;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=Y92Yis+9uSTVEfGdDJfSRMLJ+j4cKiqZ3xcGcZ88jQI=;
        b=pzW2fUegkohUO1fj1tlQP/rNi7nWS1f6Fr4xIMALonloOc3BOcowkbkBlOwlrrgjJg
         ztq4NyLPQJwqYV0VYYnfkqQrV3ptdoSpS6NSRy9e7yCrRVb8fM/21h0q3ve9dApo00K9
         CSUCf6FtUxN7B+JYU5S25C+LdEXoIC1PCw0tpmRb0ePuGjFOrTymEcYtd76q8JIgdMgq
         UzGLeG3thHc57WPMFmPLXJWG5VZB1PjSBdgCIPqZVFIXglRcgLkAaYl3yl3ZxMorHFhJ
         65G6oxDI/7iJlQpUkUZLYsMfYb+qqc5e4m42qnS/6jnpEUqmjYbgMEdMd7W1ckQHis0M
         +63g==
X-Gm-Message-State: APuU4Z8jDI1/xPlDwPnVQCDaMvoWB0LEHajaKLQ/STvnMrQ/ZIA9hawk
	S3DdbAIIs9KUdxYwaNKx5CsKnDO6zXGRS2JyLCp0yaKGlVyEAcphEVNs
X-Gm-Gg: AZFdTZcFSQE5SeKu1nLdS63jnuYrxQ1YTfQtgyf81KaHdaoJ9B1YdGLPaunFPMgl+kv
	81DeOCEFAKZ1jgdw/JqRWOJQDn/Uydk0+1W0IVKwkxFYXy9QKCd4m3na1O++oixIquxqSspExMw
	VA6txgWfYM4VizcAIfieDybBICWZwTLvVoES1xdwW7EYE0I6LJM9d6C7qsr/Ek0yPtq5HkcoaaW
	HjtP3Kx1Y21Z+62nDAP5BwQ4ZtUYl9iEwrb0oHyW5to2y9otxb4p6AJA4SKgEuoCfZEhyzPC0xL
	4B9/edbB+xJRmIviqvePcBVi+1+agZW1TZ9GOVaHC80cQG0ud815Jlr2zAJeUNYvWDwoRmRdUQT
	QTr4NOpPEkXkZ5Gs0KuKMe8bj4n/V8utfi+GOvJT/as622G8c7zL49x4+N3BfVcSmp2dA84vEfr
	YSNGl+WjZwydERmMg5Fwf8gX2ycedzCTn7lXxlGtMGXkZBK0xXMPdNS1UoyjfqQb7Q0ILPZ1j9y
	THjxr58/TxlHfTTcX3cDAUJoL/a+As1kJvO1dDwzg4fyItYkGsDVIw4NHFq+HHDqIMc5C5vqy0Q
	w2xD4QfI3FI94Y/bA5lpnR6HiVovDguuQK+RJR0jac6CvgUobiSokrHunmYXdK+A8Jfd3dx1vO4
	Pxfo04bNQgGFM8D4268KHHA==
X-Received: by 2002:a05:7022:7f01:b0:1b2:490b:6fdd with SMTP id a92af1059eb24-1b5568aeb2bmr31241800c88.24.1796152300512;
        Tue, 01 Dec 2026 11:11:40 -0800 (PST)
X-Received: from localhost.localdomain ([223.190.80.135])
        by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b59d8c0cafsm33166517c88.7.2026.12.01.11.11.37
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Tue, 01 Dec 2026 11:11:40 -0800 (PST)
X-Cc: git@vger.kernel.org,
	Junio C Hamano <gitster@pobox.com>,
	Matt Hunter <m@lfurio.us>,
	Mike Beaton <mjsbeaton@gmail.com>,
	Phillip Wood <phillip.wood123@gmail.com>
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <aw7frcoTfryxeIPX@pks.im>
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