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

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

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Dec 19, 2022, 08:45 UTC
Message-ID
<221219.86fsdb22hb.gmgdl@evledraar.gmail.com>
In-Reply-To
<xmqq7cyrm0tr.fsf@gitster.g>
On Sat, Dec 17 2022, Junio C Hamano wrote:
Show 17 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> So we could invent that as this series currently does with:
>>
>> 	git check-attrs --revision <rev> <attr>... <path>...
>>
>> Or, as I suggested:
>>
>>         git check-attr [<rev>:]<attr>... -- <path>...
>
> What does <rev>:<attr> really mean?  As the syntax for the proposed
> feature, I do not think it makes much sense.  For example:
>
>   $ git check-attr HEAD:text HEAD^:text -- README.txt
>
>  - With which README.txt are we checking the attribute?  The one
>    taken from HEAD or HEAD^ or the index or the working tree?
All of them, but I do think this rightly points out that the "rev before
path" part of this doesn't make sense, but shouldn't we be making this
work like "git grep" with <rev>/<path> combinations? I.e.:
	
	$ git -P grep -m 1 oid HEAD~:cache.h v2.26.0:cache.h v1.6.0:cache.h
	HEAD~:cache.h:#include "oid-array.h"
	v2.26.0:cache.h:void git_inflate_init(git_zstream *);
	v1.6.0:cache.h:static inline void copy_cache_entry(struct cache_entry *dst, struct cache_entry *src)
I.e. we currently support:
	git check-attr [-a | --all | <attr>...] [--] <pathname>...
	git check-attr --stdin [-z] [-a | --all | <attr>...]
So if we add to that:
	git check-attr --stdin [-z] <rev>:<pathname>...
We'd have this do the right thing:
	
	$ git check-attr diff -- README.md HEAD:git-send-email.perl v1.6.0:git-send-email.perl
	README.md: diff: unspecified
	HEAD:git-send-email.perl: diff: perl
	v1.6.0:git-send-email.perl: diff: perl

Which would technically break backwards compatibility, as we now "support" it (we just interpret the whole thing as a path), but I think such revision-looking paths aren't worth worrying about

>  - When we say "README.txt has the text attribute", how does the
>    user tell which "text" applies to the path?  From HEAD?  From
>    HEAD^?

Regardless of what I'm suggesting here, the "git check-attr" output already has a one-to-one line output correspondance with its input, so just as it does now we'd print both.

This looks like a bug though (on master, the missing "\n" is there in the output):

	$ ./git check-attr diffgit-send-email.perl foo.perl git-send-email.perl
	foo.perl: diffgit-send-email.perl: unspecified
	git-send-email.perl: diffgit-send-email.perl: unspecified
>  - Does the same attribute 'text' have different meaning when coming
>    from two different tree-ish?

Yes, just like "git grep", we'd need to parse & apply the .gitattributes for that revision. Whether we call it "<rev>:<path>", "--revision <rev> <path>" or whatever we'd always want to do that, otherwise what's the point?

Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 19 in “check-attr: add support to work with revisions”
  1. 0/2 check-attr: add support to work with revisionsKarthik Nayak, Dec 16, 2022
  2. 1/2 t0003: move setup for `--all` into new blockKarthik Nayak, Dec 16, 2022
  3. 2/2 attr: add flag `-r|--revisions` to work with revisionsKarthik Nayak, Dec 16, 2022
  4. Junio C HamanoDec 16, 2022
  5. Karthik NayakDec 17, 2022
  6. Toon ClaesDec 21, 2022
  7. Junio C HamanoDec 17, 2022
  8. Karthik NayakDec 17, 2022
  9. Ævar Arnfjörð BjarmasonDec 16, 2022
  10. Junio C HamanoDec 16, 2022
  11. Ævar Arnfjörð BjarmasonDec 19, 2022
  12. Junio C HamanoDec 16, 2022
  13. Karthik NayakDec 17, 2022
  14. Junio C HamanoDec 16, 2022
  15. Karthik NayakDec 17, 2022
  16. Phillip WoodDec 17, 2022
  17. Karthik NayakDec 17, 2022
  18. Ævar Arnfjörð BjarmasonDec 19, 2022
  19. Karthik NayakDec 19, 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.