Re: [PATCH 0/2] check-attr: add support to work with revisions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux