Skip to content

pathspec labels

Stefan Beller git 3 versions New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest5 patches 0 repliesNew
  2. v25 patches 11 repliesSuperseded
  3. v11 patch 0 repliesSuperseded

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5Documentation: fix a typoDocumentation/gitattributes.txt+1 -10 replies
2/5Documentation: correct typo in example for querying attributesDocumentation/technical/api-gitattributes.txt+1 -10 replies
3/5pathspec: move long magic parsing out of prefix_pathspecpathspec.c+47 -370 replies
4/5pathspec: move prefix check out of the inner looppathspec.c+10 -90 replies
5/5pathspec: record labelsDocumentation/gitattributes.txt Documentation/glossary-content.txt dir.c +3 more+293 -40 replies

Reviews trailers per patch

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

Read the v4 thread

Cover letter [PATCHv4 0/5] pathspec labels

Thanks Junio for the review!
Thanks Duy for suggestions to think about in the not-submodule case :)

* when invalid labels are found
-> in the .gitattributes "warn and ignore" -> in command line args die(..)
* treat labels set to false as unset.
* fixes in documentation/ reworded the commit message

Thanks,
Stefan

diff to current origin/sb/pathspec-label (v2 of the series, so a lot):

Documentation/gitattributes.txt +12 -0
index af2c682..b846848 100644
@@ -906,6 +906,18 @@ If this attribute is not set or has an invalid value, the value of the
 (See linkgit:git-config[1]).
 
 
+Attaching labels to path
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+`label`
+^^^^^^^
+By the value of this attribute you can specify a list of arbitrary strings
+to be attached to a path as labels. These labels can be used for
+easier paths matching using pathspecs (linkgit:gitglossary[1]).
+It is required to use only alphanumeric characters, dashes and
+underscores for the labels.
+
+
 USING MACRO ATTRIBUTES
 ----------------------
 
Documentation/glossary-content.txt +4 -5
index a1fc9e0..e264a58 100644
@@ -362,11 +362,6 @@ glob;;
 	For example, "Documentation/{asterisk}.html" matches
 	"Documentation/git.html" but not "Documentation/ppc/ppc.html"
 	or "tools/perf/Documentation/perf.html".
-
-label:<white space separated list>;;
-	Labels can be assigned to pathspecs in the .gitattributes file.
-	By specifying a list of labels the pattern will match only
-	files which have all of the listed labels.
 +
 Two consecutive asterisks ("`**`") in patterns matched against
 full pathname may have special meaning:
@@ -389,6 +384,10 @@ full pathname may have special meaning:
 +
 Glob magic is incompatible with literal magic.
 
+label=<white space separated list>;;
+	Additionally to matching the pathspec, the path must have a 'label'
+	attribute having set all labels listed here.
+
 exclude;;
 	After a path matches any non-exclude pathspec, it will be run
 	through all exclude pathspec (magic signature: `!`). If it
attr.h +0 -1
index f6fc7c3..8b08d33 100644
@@ -18,7 +18,6 @@ extern const char git_attr__false[];
 #define ATTR_TRUE(v) ((v) == git_attr__true)
 #define ATTR_FALSE(v) ((v) == git_attr__false)
 #define ATTR_UNSET(v) ((v) == NULL)
-#define ATTR_CUSTOM(v) (!(ATTR_UNSET(v) || ATTR_FALSE(v) || ATTR_TRUE(v)))
 
 /*
  * Send one or more git_attr_check to git_check_attr(), and
dir.c +40 -15

79 lines not on this page · raw message

pathspec.c +52 -17

112 lines not on this page · raw message

pathspec.h +2 -1
index e3f7ebf..bf02931 100644
@@ -32,7 +32,7 @@ struct pathspec {
 		int len, prefix;
 		int nowildcard_len;
 		int flags;
-		struct string_list *group;
+		struct string_list *labels;
 	} *items;
 };
 
@@ -99,5 +99,6 @@ extern char *find_pathspecs_matching_against_index(const struct pathspec *pathsp
 extern void add_pathspec_matches_against_index(const struct pathspec *pathspec, char *seen);
 extern const char *check_path_for_gitlink(const char *path);
 extern void die_if_path_beyond_symlink(const char *path, const char *prefix);
+extern int validate_label_name(const char *label);
 
 #endif /* PATHSPEC_H */
t/t6134-pathspec-with-labels.sh +117 -50

205 lines not on this page · raw message

Stefan Beller (5):
Documentation: fix a typo
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/gitattributes.txt               |  14 ++-
 Documentation/glossary-content.txt            |   4 +
 Documentation/technical/api-gitattributes.txt |   2 +-
 dir.c                                         |  56 +++++++++
 pathspec.c                                    | 144 ++++++++++++++++-------
 pathspec.h                                    |   2 +
 t/t6134-pathspec-with-labels.sh               | 158 ++++++++++++++++++++++++++
 7 files changed, 340 insertions(+), 40 deletions(-)
 create mode 100755 t/t6134-pathspec-with-labels.sh
Signature · 1 line
2.8.2.401.gb49ffe6.dirty