git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org, toon@iotcl.com
Subject: Re: [PATCH 0/2] check-attr: add support to work with revisions
Date: Tue, 6 Dec 2022 20:09:09 -0500	[thread overview]
Message-ID: <Y4/ntYotGKz2dx0E@nand.local> (raw)
In-Reply-To: <20221206103736.53909-1-karthik.188@gmail.com>

On Tue, Dec 06, 2022 at 11:37:34AM +0100, Karthik Nayak wrote:
> This series aims to add a new flag `-r|--revisions` to git-check-attr(1) which
> allows us to read gitattributes from the specified revision.

I haven't looked at the patches below yet, so take my $.02 with a grain
of salt, but I have definitely wished for something like this in the
past.

When scripting around to figure out which files at a given revision are
affected by a given attribute, I will often have to resort to writing
something like this when working in a bare repository:

  for repo in $LIST_OF_REPOS
  do
    export GIT_DIR="$repo"

    index="$(mktemp ...)"
		git read-tree --index-output="$index" HEAD 2>/dev/null || continue

    git ls-tree -rz --name-only HEAD |
    GIT_INDEX_FILE="$index" git check-attr --cached --stdin -z $attr |
    ruby -e '
      print $stdin.readlines.join.split("\0").
        each_slice(3).
        select { |path, _, val| val != "unspecified" && val != "unset" }.
        map(&:first).join("\0")
    '
  done

Which is just kind of gross.

I had at one point when writing the above script wished for a '--blob'
source option to check-attr. That might be sensible, but I think being
able to read from an arbitrary revision (looking at all of the relevant
.gitattributes file(s) recursively throughout the tree) is even more
useful, since it allows you to accurately construct the attributes state
in its entirety.

Anyway, my point is that I think that this is a useful feature, and one
that I (and I suspect other users, too) have wished for frequently in
the past.

Thanks,
Taylor

  parent reply	other threads:[~2022-12-07  1:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06 10:37 [PATCH 0/2] check-attr: add support to work with revisions Karthik Nayak
2022-12-06 10:37 ` [PATCH 1/2] t0003: move setup for `--all` into new block Karthik Nayak
2022-12-06 10:37 ` [PATCH 2/2] attr: add flag `-r|--revisions` to work with revisions Karthik Nayak
2022-12-06 11:27   ` Ævar Arnfjörð Bjarmason
2022-12-06 13:06     ` Karthik Nayak
2022-12-07  0:12   ` Junio C Hamano
2022-12-07  1:10     ` Eric Sunshine
2022-12-07 11:05       ` Karthik Nayak
2022-12-07 11:38     ` Ævar Arnfjörð Bjarmason
2022-12-07 12:33       ` Karthik Nayak
2022-12-07 11:40     ` Karthik Nayak
2022-12-07 11:53       ` Ævar Arnfjörð Bjarmason
2022-12-07 12:29         ` Karthik Nayak
2022-12-06 11:20 ` [PATCH 0/2] check-attr: add support " Philip Oakley
2022-12-06 13:00   ` Karthik Nayak
2022-12-07  1:09 ` Taylor Blau [this message]
2022-12-07  2:11   ` brian m. carlson

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=Y4/ntYotGKz2dx0E@nand.local \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@gmail.com \
    --cc=toon@iotcl.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).