git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Ilias Apostolou <ilias.apostolou.zero@gmail.com>
Cc: Taylor Blau <me@ttaylorr.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Request feature: –no-submodule
Date: Fri, 04 Jun 2021 07:06:52 +0900	[thread overview]
Message-ID: <xmqqim2u4n7n.fsf@gitster.g> (raw)
In-Reply-To: <9cc98ca3-bdc5-61bf-450a-99bb47673d6c@gmail.com> (Ilias Apostolou's message of "Thu, 3 Jun 2021 13:48:39 +0300")

Ilias Apostolou <ilias.apostolou.zero@gmail.com> writes:

> The reason we need to list all of the true files (except submodules)
> is for code refactoring using the sed unility, for example:
>
> git ls-files | grep -Ev '(png$|ico$)' | xargs sed -i 's/\r\n/\n/'
> ...
> In my opinion, this should be a feature for "ls-files" only, since it
> would be nice to have a clean stream of true files.

Ah, then pathspec is still the right tool to use, I would think.

For example,

    git ls-files -s ':(exclude)*.png' ':(exclude)*.ico' |
    sed -n -e 's/^100[76][54][54] [0-9a-f]* 0       //p' |
    xargs sed -i 's/\r\n/\n/'

that is,

 (1) ls-files -s can be used to learn what kind of path it is.
     Regular files are either 100644 or 100755.  That way, you can
     also exclude symbolic links, which your example use case would
     probably not want to touch.  And you can filter the output to
     have 'a clean stream of true files' fairly easily Depending on
     the details of your needs, it can be tweaked into 'a clean
     stream of executable files' etc., too.

 (2) pathspec magic like ':(exclude)' can be used to lose your "we
     know png and ico are not text files".

Hope this helps.

  reply	other threads:[~2021-06-03 22:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 10:31 Request feature: –no-submodule Ilias Apostolou
2021-06-02 20:31 ` Taylor Blau
2021-06-03  0:55   ` Junio C Hamano
2021-06-03  2:33     ` Taylor Blau
2021-06-03 10:48       ` Ilias Apostolou
2021-06-03 22:06         ` Junio C Hamano [this message]
2021-06-03 17:40       ` Junio C Hamano
2021-06-03 19:22         ` Jeff King
2021-06-03 21:54           ` Junio C Hamano
2021-06-04  4:03             ` Jeff King
2021-06-04  5:06               ` Junio C Hamano
2021-06-05  5:45                 ` Ilias Apostolou

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=xmqqim2u4n7n.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=ilias.apostolou.zero@gmail.com \
    --cc=me@ttaylorr.com \
    /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).