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

Re: [PATCH 0/5] Make :(attr) pathspec work with "git log"

From
Jeff King <peff@peff.net>
Date
Nov 19, 2018, 12:09 UTC
Message-ID
<20181119120927.GA31660@sigill.intra.peff.net>
In-Reply-To
<87d0r217vr.fsf@evledraar.gmail.com>
On Sun, Nov 18, 2018 at 08:51:52PM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 29 quoted lines
> > But this also reveals an interesting thing: even though we walk on a
> > tree, we check attributes from _worktree_ (and optionally fall back to
> > the index). This is how attributes are implemented since forever. I
> > think this is not a big deal if we communicate clearly with the user.
> > But otherwise, this series can be scraped, as reading attributes from
> > a specific tree could be a lot of work.
> 
> I'm very happy to see this implemented, and I think the behavior
> described here is the right way to go. E.g. in git.git we have diff=perl
> entries in .gitattributes. It would suck if:
> 
>     git log ':(attr:diff=perl)'
> 
> Would only list commits as far as 20460635a8 (".gitattributes: use the
> "perl" differ for Perl", 2018-04-26), since that's when we stop having
> that attribute. Ditto for wanting to run "grep" on e.g. perl files in
> 2.12.0.
> 
> I have also run into cases where I want to use a .gitattributes file
> from a specific commit. E.g. when writing pre-receive hooks where I've
> wanted the .gitattributes of the commit being pushed to configure
> something about it. But as you note this isn't supported at all.
> 
> But a concern is whether we should be making :(attr:*) behave like this
> for now. Are we going to regret it later? I don't think so, I think
> wanting to use the current working tree's / index's is the most sane
> default, and if we get the ability to read it from revisions as we
> e.g. walk the log it would make most sense to just call that
> :(treeattr:*) or something like that.

I think that ship already sailed with the fact that "git log -p" will show diffs using the worktree attrs. I agree that it would sometimes be nice to specify attributes from a particular tree, but at this point the default probably needs to remain as it is.

-Peff
Previous: Duy NguyenNext: Junio C Hamano
Message 12 of 15 in “Make :(attr) pathspec work with "git log"”
  1. 0/5 Make :(attr) pathspec work with "git log"Nguyễn Thái Ngọc Duy, Nov 18, 2018
  2. 1/5 tree.c: make read_tree*() take 'struct repository *'Nguyễn Thái Ngọc Duy, Nov 18, 2018
  3. 2/5 tree-walk.c: make tree_entry_interesting() take an indexNguyễn Thái Ngọc Duy, Nov 18, 2018
  4. 3/5 pathspec.h: clean up "extern" in function declarationsNguyễn Thái Ngọc Duy, Nov 18, 2018
  5. 4/5 dir.c: move, rename and export match_attrs()Nguyễn Thái Ngọc Duy, Nov 18, 2018
  6. 5/5 tree-walk: support :(attr) matchingNguyễn Thái Ngọc Duy, Nov 18, 2018
  7. Ævar Arnfjörð BjarmasonNov 18, 2018
  8. Duy NguyenNov 19, 2018
  9. Ævar Arnfjörð BjarmasonNov 18, 2018
  10. Ævar Arnfjörð BjarmasonNov 19, 2018
  11. Duy NguyenNov 19, 2018
  12. Jeff KingNov 19, 2018
  13. Junio C HamanoNov 19, 2018
  14. Ævar Arnfjörð BjarmasonNov 19, 2018
  15. Duy NguyenNov 19, 2018

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.