From: Junio C Hamano Date: Fri, 06 Nov 2026 20:16:48 GMT Subject: Re: git-ls-files(1) avoiding symlinks Message-ID: In-Reply-To: Alejandro Colomar writes: >> > With -z it becomes a bit tedious: >> > >> > $ git ls-files -z --format='%(objectmode) %(path)' \ >> > | grep -zv ^120000 \ >> > | sed -z 's/^.* //' \ >> > | grep -z '\.[ch]$' \ >> > | xargs -0 grepc creat; Shouldn't the grep|sed|grep be doable with a single sed invocation? >> > I expect git-ls-files(1) could make this much simpler, though: >> > >> > $ git ls-files --type f \ >> > | grep '\.[ch]$' \ >> > | xargs grepc creat; Not really. Why is "--type" have to be so special? What would the next person ask for? --size? The "ls-files" plumbing command is designed as a component to build your own pipeline with. Don't throw in random unrelated features to it. In the longer run, it is not a good substitute for improving the skill to construct a good pipeline. Learn the tools available to you that you already have heard of, so that you can make better uses of them (in this case "sed"). If you squash the grep|sed|grep pipeline into a single sed git ls-files -z -s "*.[ch]" | sed -z -n -e '/^120000/d' -e '/^.* 0 /s///p' | xargs -r -0 ls -ld the result does not look too bad. One unrelated tip for better readability is to end, not begin, your lines with the "|" pipe characters. That way you do not have to sprinkle so many unsightly backslashes ;-). HTH.