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
Duy Nguyen <pclouds@gmail.com>
Date
Nov 19, 2018, 15:25 UTC
Message-ID
<CACsJy8Aq8kjtwv8ZtPOUHOp=59KL9dRiTQkFfbr5oPh9Swytwg@mail.gmail.com>
In-Reply-To
<878t1p1fnr.fsf@evledraar.gmail.com>

On Mon, Nov 19, 2018 at 12:16 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Show 26 quoted lines
> As an aside, how do you do the inverse of matching for an attribute by
> value? I.e.:
>
>     $ git ls-files | wc -l; git ls-files ':(attr:diff=perl)' | wc -l
>     3522
>     65
>
> I'd like something gives me all files that don't match diff=perl,
> i.e. 3522-65 = 3457 files, or what I'd get if I constructed such a match
> manually with excludes:
>
>     $ git ls-files $(grep diff=perl .gitattributes | cut -d ' ' -f1 | sed 's!^!:(exclude)!') | wc -l
>     3457
>
> From my reading of parse_pathspec_attr_match() and match_attrs() this
> isn't possible and I'd need to support ':(attr:diff!=perl)' via a new
> MATCH_NOT_VALUE mode. But I wanted to make sure I wasn't missing some
> subtlety, i.e. that this was implemented already via some other feature.
>
> I thought I could do:
>
>     git ls-files ':(exclude):(attr:diff=perl)'
>
> But we don't support chaining like that, and this would only exclude a
> file that's actually called ":(attr:diff=perl)". I.e. created via
> something like "touch ':(attr:diff=perl)'".

I think we allow :(exclude,attr:diff=perl) which should "exclude all paths that have diff=perl attribute". It's actually tested in t6135 for ls-files (but I didn't add the same test for 'git grep' because I was so confident it would work; I'll work on that).

-- 
Duy
Previous: Ævar Arnfjörð BjarmasonNext: Jeff King
Message 11 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.