🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #2507

git-ls-files(1) avoiding symlinks

#2507
From: Alejandro Colomar
Date: Fri, 06 Nov 2026 13:35
88 lines
10577 bytes
--7via6c44zxtslhjm
Content-Type: text/plain; protected-headers=v1; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
From: Alejandro Colomar <alx+git@kernel.org>
To: git@vger.kernel.org
Cc: Andy Shevchenko <andy@kernel.org>, 
	Linus Torvalds <torvalds@linux-foundation.org>, Krzysztof Kozlowski <krzk@kernel.org>
Subject: git-ls-files(1) avoiding symlinks
Message-ID: <au3Tyaz_LoYDuskn@devuan>
MIME-Version: 1.0

Hi!

Yesterday, we were discussing alternative methods for grepping source
code.  Here's a list of similar alternatives:

	$ find . -type f | xargs grep ARRAY_END;
	$ git ls-files | xargs grep ARRAY_END;
	$ git grep ARRAY_END;

The version using find(1) has some problems: it is slow, especially
after having built a kernel, when the directory is full of temporary
objects.

The version using git-grep(1) without IPC is the fastest, and doesn't
have any problems, but it is limited to just grep(1).  If we want to use
sed(1), or any other programs, we're out of luck.

A common program I want to use is grepc(1), which searches source code.
See for example this code for finding the creat(2) system call:

	$ git ls-files | grep '\.[ch]$' | xargs grepc creat;
	fs/open.c:SYSCALL_DEFINE2(creat, const char __user *, pathname, umode_t, m=
ode)
	{
		int flags =3D O_CREAT | O_WRONLY | O_TRUNC;

		if (force_o_largefile())
			flags |=3D O_LARGEFILE;
		return do_sys_open(AT_FDCWD, pathname, flags, mode);
	}
	include/linux/syscalls.h:asmlinkage long sys_creat(const char __user *path=
name, umode_t mode);
	tools/include/nolibc/fcntl.h:static __attribute__((unused))
	int creat(const char *path, mode_t mode)
	{
		return open(path, O_CREAT | O_WRONLY | O_TRUNC, mode);
	}

A problem with git-ls-files(1) is that it doesn't have a way to filter
files by type.  That is, it will list symlinks, which will affect the
search.  With find(1), I can control that with '-type f', which makes
sure I only search in regular files.  I'd like to have some feature in
git-ls-files(1) that allows me to print files of the specified type.
Since git(1) knows the type of the files, this should be doable without
much overhead, right?


Have a lovely day!
Alex

--=20
<https://www.alejandro-colomar.es>

--7via6c44zxtslhjm
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmrt134ACgkQ64mZXMKQ
wqmJhRAAulEzINHRrIWpLPk3xnynEzvWEEtsSH+Tyr9+B5sDT3NyAeNFG+R8KYHn
pOMWu21EGooZN3UTUTAem7XHP8n6Pye9CeHxQLVCe7aYoLgArOsW884jtvKSzV7/
HwAY4tVFku+piVbQDKWy9F0BM8davweH69AWsHqjHy2HGtliK9G++hZfMejiXnPl
lUtExjbQ8O+v5NTYnDUzI7zY/riOVXOFFnAjfCluAvZueih4mfnFaedTTTBefR0/
LPsrGDFQJRwlkBLH41OaF7UguqCIJctcY7U9zqs+5Yw3aXX7VHilVBKJm1LBMgah
wkcuBXTptqBLK9jz4xHofq0QDhBXeubPsBNRu6HllK9lxePDPKOfsEBp+EebyPa3
MbOqQb1hhWRjyE7kRSmLrCa3yLzULg7BUfERjLmA3VQQ+H2Pg7NHCKsbVZmFxQPb
qntfLFVBp5I0h7sBUkD1afqT/Wax7eVCrh6ZMHcabYabMed9Ev60eeg4VJPguCsP
1Ra0WqVZOwMhcI/tVVksF8ENplyl35+2UC5PKpHi4qXEuva2PkcNOvvlIp5HWwju
/74PjclsfkcI/uFqAm+F05qihCMwaQJMyQKfYQ75bYC/TrqIF21cRI5LYTu4ptGr
0Z+bZHEMUWIJlNTFPvW1JshORig6sQLlz25HKI1ugfiG2kvDY48=
=Dq8C
-----END PGP SIGNATURE-----

--7via6c44zxtslhjm--
Technical Details
Message-ID: <au3Tyaz_LoYDuskn@devuan>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74665-linux-kernel-git=dewy.ru

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-74665-linux-kernel-git=dewy.ru
From: alx+git@kernel.org (Alejandro Colomar)
Newsgroups: linux.kernel.git
Subject: git-ls-files(1) avoiding symlinks
Date: Fri, 6 Nov 2026 14:35:01 +0100
Organization: Usenet Network
Message-ID: <au3Tyaz_LoYDuskn@devuan>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
	protocol="application/pgp-signature"; boundary="7via6c44zxtslhjm"
Injection-Info: usenet.network;
	logging-data="3889332"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:m0foaDT4xTCcthk4xwAZM8JbGqo= sha256:eiDLSNOBPPylzXkB5WCeeRqPLHEuOBfWlhTdLzMCMDY=
	sha1:+mE9Uj/N5/W+QNOqvFeTGL0vA1w= sha256:LafZWR7HnPv1lTMudWx+4vcmwT0G9Fa0fYAhYJJl6kU=
Content-Disposition: inline
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 DA92711326B; Fri,  6 Nov 2026 16:35:25 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org
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 iLcp4zd7BEIF;
	Fri,  6 Nov 2026 16:35:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=git+bounces-74665-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 850E8113269; Fri,  6 Nov 2026 16:35:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id D2F11600759; Fri,  6 Nov 2026 13:35:09 +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=1793972107;
	b=SISuUwSCYnlPCU7kzvddag8+A4Ko23lDQO4bum+GMeNggsgc7/g1eJQ9y4+cOHz0idWn
	 QAEYTfDwVodEJ2gcXLjpGJjjPAACZXI9rT68qTBRuNM1z0kQUh+I2VH2f5tcWPkYWtDOi
	 UuRnP78EvSxck2o+7SL5nhS4Zuo+syI2ucZVYgJgAMhBW3l/bkpwpm7naEJFQpWeHCZIa
	 AkDSZO6dZedUHKrecEzY53cvsR8RpxxeMOUn5u3qFxn/iqguVjaMFsGdBK7gQB7R7KgI7
	 Zc6fscGWdWVQgB8gvaPbMXE53/+zRfGDavPvtZOMQpE30xi/RgsRunox/PdKpbOC4oQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793972107;
	h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc:
	 Subject:Message-ID:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Type:Content-Disposition;
	bh=PimiOtQN6Zq1SKEJyM58IsHsPBtVdaagUqPWuAWNFv4=;
	b=H4kmsQDSVhL+lOt7hX0MMdgUBwwNI2IM2GWnW6MlA2g6j8YJCyATJvVAaYTkzWG/gWOF
	 9AhKWCyoxR5bnyfZB6sk6warEm7CuAhNz7v7ObSXEd72c4CvTJLNWS8ukkq0RRucTRISK
	 7tuEbQbjjjPqzUHfOSzr+a4zNwWVCHhxW/Wpm1+N6sIpvBeRrYPqQKRUkMHpWqP9bnWmA
	 Dg6jznXh0iTrt41o36T1ZHKZLSCAHylmPThR0LyMxK4UjQtsdd/QZ0IsKo2Kd/0LFpoR3
	 KRsxxykqA0HntSef/td7YzBTMezDMmepUR8Ges1H3G0ENEOV7X/YGtBON9uC6SWtMJQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=k95qwiGL;
	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 530EC606A330;
	Fri,  6 Nov 2026 13:35:07 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=k95qwiGL
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793972106;
	b=o2bo+H0Nvhp2QwQjxx54xlgCOxeY0hriaGcSCRizw7TlbKAIi8QCnC4sgIZOVhU4jO/T
	 mAT+kEiKmiQrekd6ZqN+lk2J8gJSqBsAAufdbQtb+zRkRdWCSXXEPnQdGwnxB/ZY7y+Ct
	 Ee3YadcjHLRs5UUm3RwcpUZ1uDvJQ1U34ARiQVODT/s5yLem8RUMV/Dmhj2JHY/oBhTOn
	 LXjj1otWvfX/84Bt6OR32C24Q8lk4FgQb5EExX83f3BHMww9z60ikO3gDOokDSpzRBtsn
	 R8Q72mk+69aogYC0M0pfUtEb9BcLZyXnBI9kPmXaHAMa5zA1IdPY/NLUY0nzKsC59Jw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793972106;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 MIME-Version:Content-Type:Content-Disposition;
	bh=PimiOtQN6Zq1SKEJyM58IsHsPBtVdaagUqPWuAWNFv4=;
	b=I6UvuQTMLjdlf2GrncocKhJLxTXgKa4CkKaklRP7eEGU3XDZ9FvpKjgC0blyN7Oj550I
	 i/Q0jtqUrDvmYOeyqrqQeLT6jnjGYiwTZCLlbp0I0uxS22fBaU6/TiAqCFqZbzt2DatCK
	 0TRPjVcQc5w5TrSOg3K91LQpkpqNVc/ch3O/4dZJZZIJWAoGUa1l+kgWhoTpcGH0ZvS/D
	 Zpd1MAu7q+XmVXp7DMjav2Ft50ruaGkWIkM3mQLZwZzJABRFQOuu0ESJ2h07lFtUB6vsH
	 1XRMWba84upJX7cxJPYNDqDqKyWaq88SmtdE4L0yxNZOKTXwXI3EvDa+/n8af14KZww==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=k95qwiGL;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32472606A326
	for <git@vger.kernel.org>; Fri,  6 Nov 2026 13:35:05 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFD8E1F0089F;
	Fri,  6 Nov 2026 13:35:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793972105;
	bh=PimiOtQN6Zq1SKEJyM58IsHsPBtVdaagUqPWuAWNFv4=;
	h=Date:From:To:Cc:Subject;
	b=k95qwiGL8S3h1Nm+ldESGyiWgMKubkSCNCID/26zkHnf698ZwHQctpt2qsLlNyD4K
	 xOf2EZEMLru+vSQLZTcCHBtG5WICX0FDqebKmAN74FfN3hdyXpPmKS5eM3p08uQiHj
	 op8aq/9kL1yJv4caPeyhlKMKHVIJBVbZw91uAwgBE14f6fbkQ2OnLQTx5fnkxj5alY
	 HX+20p0PQSU8WP9S+6HQA3dFC7iJT77RddNn7KsJPTiyQMGNrVT278evWqPgUi/oWT
	 AF3VftHbXVwZuTSO4ZTLIFoGosAbJ9cKxY/QzI28hFyvKJY/JvVY3uZfIJmKXLXMB/
	 OvT5JALUOrnWg==
X-Cc: Andy Shevchenko <andy@kernel.org>, 
	Linus Torvalds <torvalds@linux-foundation.org>, Krzysztof Kozlowski <krzk@kernel.org>
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