From: "Guido Martínez" <mtzguido@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Jeff King" <peff@peff.net>,
"Guido Martínez via GitGitGadget" <gitgitgadget@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH] ls-files: add an --exclude-links option
Date: Wed, 21 Jun 2023 13:02:21 -0700 [thread overview]
Message-ID: <CA++DQU=5fSHcOssVD-qCiX_kpRh-Pa3TeSRMwRggLDWTK0j_XQ@mail.gmail.com> (raw)
In-Reply-To: <xmqq352kha1l.fsf@gitster.g>
On Wed, Jun 21, 2023 at 12:47 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Guido Martínez <mtzguido@gmail.com> writes:
>
> > So would it make sense to
> > 1- Add the file type filter to ls-files
>
> I think it definitely makes sense to extend the filtering criteria
> supported by ls-files beyond what we currently support (i.e.
> pathspec).
>
> I also wonder if "file type filter" could just be implemented as the
> magic pathspec. For example, we can already use the magic pathspec
> 'attr' (read on "pathspec" in "git help glossary") this way:
>
> $ git ls-files ":(attr:eol=crlf)"
>
> to list only those files for which the 'eol' attribute is set to
> 'crlf' (i.e. they must be checked out for DOS no matter what your
> platform actually is). That is even more flexible than the
> hardcoded "is it a regular file? is it a symlink? is it a
> submodule" file types. And the magic pathspec is understood not
> everywhere but by git subcommands other than "ls-files".
>
> We can either invent a new pathspec magic "filetype" and express
> them this way,
>
> $ git ls-files ":(filetype:regular)" # 100644 and 100755
> $ git ls-files ":(filetype:symbolic-link)" # 120000
> $ git ls-files ":(filetype:submodule)" # 160000
>
> or we invent a magic attribute "filetype" that is automatically
> given to every path, and express the above more like so:
>
> $ git ls-files ":(attr:filetype=regular)" # 100644 and 100755
> $ git ls-files ":(attr:filetype=symbolic-link)" # 120000
> $ git ls-files ":(attr:filetype=submodule)" # 160000
>
> may be even better, as there are git subcommands other than ls-files
> that supports magic pathspec. For example, it might be even useful
> to do something like
>
> $ git diff v1.0 v2.0 -- ":(attr:filetype=executable)"
>
> instead of saying
>
> $ git diff v1.0 v2.0 -- \*.sh \*.perl \*.py \*.bat
>
> So, yeah, whether it is done via the magic pathspec or "ls-files"
> specific option, teaching "ls-files" to support more filtering
> criteria would make sense.
Thanks, I was totally unaware of this magic pathspec, I'll see what it
takes to add attr:filetype.
> > 2- Use that to implement a proper git-do-for-paths script/binary,
> > which can take pathspecs, filetype filters, -n, -P, and maybe more
> > ?
>
> The primary obstacle was you'd need a custom perl script to filter
> "ls-files -z" output, but once that need is gone, I actually do not
> think it buys us a lot to have such a wrapper. Treat the improved
> ls-files as what it is, i.e. a plumbing command that can be used as
> a building block of your workflow, and piping its output to xargs
> would just be fine.
Yup, totally fine by me. I'll just keep that script locally then.
Thanks again,
Guido
>
> Thanks.
prev parent reply other threads:[~2023-06-21 20:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-21 6:08 [PATCH] ls-files: add an --exclude-links option Guido Martínez via GitGitGadget
2023-06-21 8:17 ` Jeff King
2023-06-21 15:19 ` Guido Martínez
2023-06-21 16:08 ` Junio C Hamano
2023-06-21 17:54 ` Guido Martínez
2023-06-21 19:47 ` Junio C Hamano
2023-06-21 20:02 ` Guido Martínez [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA++DQU=5fSHcOssVD-qCiX_kpRh-Pa3TeSRMwRggLDWTK0j_XQ@mail.gmail.com' \
--to=mtzguido@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).