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

Re: [RFC PATCH 0/4] pathspec labels [WAS: submodule groups]

From
Duy Nguyen <pclouds@gmail.com>
Date
May 15, 2016, 10:06 UTC
Message-ID
<CACsJy8BK-u2VV3kkq3ANHCanYqMwphqgxZmooQfewA_J7e8MPw@mail.gmail.com>
In-Reply-To
<20160513001936.7623-1-sbeller@google.com>
On Fri, May 13, 2016 at 7:19 AM, Stefan Beller <sbeller@google.com> wrote:
Show 32 quoted lines
> After some fruitful discussion[1] in which Junio suggested trying a very
> different route[2] that is more general and not submodule related, I considered
> doing a mock for this.
>
> This lets you label arbitrary pathspecs, e.g. in git.git we may want to have:
>
>     t/t[0-9]*.sh label=tests
>
> such that
>
>     $ git log --author=Beller ":(label=tests)"
>
> would show all commits in which I touched tests.
>
> This has suprisingly few lines of code, as the first 3 patches are refactoring.
> The actual new feature is in the last patch.
>
> This would solve the submodule issues I want to solve, as I can produce a
> .gitattributes like:
>
>     ./submodule1 label=default
>     ./submodule2 label=default
>     ./submodule3 label=optional-feature1
>
> and then I'd instruct the users to clone like this:
>
>     git clone .. superproject
>     cd superproject
>     git submodule update --init :(label:default)
>
> The second part of the submodule series to collapse these three commands
> will come as an extra series later, then.
Yeah. I can see the use of this, even without submodules.
Show 7 quoted lines
> What annoys me here:
> Attributes can only be set once at the moment, there is no way to collect all
> attributes. If we'd have such a collection feature we would be able to
> configure this:
>
>     *.[ch] label=C,code
>     contrib/** label=oldstuff

Instead of putting everything in under the same attribute name "label", make one attribute per label? Would this work?

*.[ch] c-group code-group

And the pathspec magic name can be simply "attr", any git attribute can be used with it, e.g. :(attr:c-group)

Show 11 quoted lines
> and run this:
>
>     git status ":(label:C oldstuff)"
>
> which would be the equivalent to
>
>     contrib/**.[ch]
>
> as in this proposed implementation the labels which are given within one
> pathspec item are logical AND. To get the logical OR, you'd have to give multiple
> pathspec items, i.e. ":(label:C)" ":(label:oldstuff)"

It's even better if pathspec does not have to deal with combination logic. Can attr macros deal with that (or if it can't at the moment, can we improve it)?

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 25 in “pathspec labels [WAS: submodule groups]”
  1. 0/4 pathspec labels [WAS: submodule groups]Stefan Beller, May 13, 2016
  2. 1/4 Documentation: correct typo in example for querying attributesStefan Beller, May 13, 2016
  3. 2/4 pathspec: move long magic parsing out of prefix_pathspecStefan Beller, May 13, 2016
  4. 3/4 pathspec: move prefix check out of the inner loopStefan Beller, May 13, 2016
  5. Junio C HamanoMay 13, 2016
  6. 4/4 pathspec: record labelsStefan Beller, May 13, 2016
  7. Junio C HamanoMay 13, 2016
  8. Stefan BellerMay 13, 2016
  9. Junio C HamanoMay 13, 2016
  10. Stefan BellerMay 13, 2016
  11. Junio C HamanoMay 13, 2016
  12. Duy NguyenMay 15, 2016
  13. Junio C HamanoMay 15, 2016
  14. Junio C HamanoMay 15, 2016
  15. Duy NguyenMay 16, 2016
  16. Stefan BellerMay 16, 2016
  17. Junio C HamanoMay 16, 2016
  18. Stefan BellerMay 16, 2016
  19. Junio C HamanoMay 16, 2016
  20. Stefan BellerMay 16, 2016
  21. Junio C HamanoMay 16, 2016
  22. Stefan BellerMay 16, 2016
  23. Junio C HamanoMay 16, 2016
  24. Stefan BellerMay 16, 2016
  25. Junio C HamanoMay 16, 2016

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.