Skip to content

RFC pathspec labels [WAS: submodule groups]

Stefan Beller git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 20 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4Documentation: correct typo in example for querying attributesDocumentation/technical/api-gitattributes.txt+1 -10 replies
2/4pathspec: move long magic parsing out of prefix_pathspecpathspec.c+47 -370 replies
3/4pathspec: move prefix check out of the inner looppathspec.c+10 -91 reply
4/4pathspec: record labelsDocumentation/glossary-content.txt attr.h dir.c +3 more+152 -15 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

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

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.

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

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)"

Feedback welcome!

Thanks,
Stefan

[1] http://thread.gmane.org/gmane.comp.version-control.git/294212
[2] http://thread.gmane.org/gmane.comp.version-control.git/294212/focus=294391

Stefan Beller (4):
Documentation: correct typo in example for querying attributes
pathspec: move long magic parsing out of prefix_pathspec
pathspec: move prefix check out of the inner loop
pathspec: record labels

 Documentation/glossary-content.txt            |   5 ++
 Documentation/technical/api-gitattributes.txt |   2 +-
 attr.h                                        |   1 +
 dir.c                                         |  31 ++++++++
 pathspec.c                                    | 109 +++++++++++++++++---------
 pathspec.h                                    |   1 +
 t/t6134-pathspec-with-labels.sh               |  91 +++++++++++++++++++++
 7 files changed, 201 insertions(+), 39 deletions(-)
 create mode 100755 t/t6134-pathspec-with-labels.sh
Signature · 1 line
2.8.2.400.g66c4903.dirty