git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Taylor Blau <me@ttaylorr.com>
Date
Dec 7, 2022, 01:09 UTC
Message-ID
<Y4/ntYotGKz2dx0E@nand.local>
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

Previous: Karthik NayakNext: brian m. carlson
Message 16 of 17 in “check-attr: add support to work with revisions”
  1. 0/2 check-attr: add support to work with revisionsKarthik Nayak, Dec 6, 2022
  2. 1/2 t0003: move setup for `--all` into new blockKarthik Nayak, Dec 6, 2022
  3. 2/2 attr: add flag `-r|--revisions` to work with revisionsKarthik Nayak, Dec 6, 2022
  4. Ævar Arnfjörð BjarmasonDec 6, 2022
  5. Karthik NayakDec 6, 2022
  6. Junio C HamanoDec 7, 2022
  7. Eric SunshineDec 7, 2022
  8. Karthik NayakDec 7, 2022
  9. Karthik NayakDec 7, 2022
  10. Ævar Arnfjörð BjarmasonDec 7, 2022
  11. Karthik NayakDec 7, 2022
  12. Ævar Arnfjörð BjarmasonDec 7, 2022
  13. Karthik NayakDec 7, 2022
  14. Philip OakleyDec 6, 2022
  15. Karthik NayakDec 6, 2022
  16. Taylor BlauDec 7, 2022
  17. brian m. carlsonDec 7, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.