Revamp the attr subsystem!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest35 patches 7 repliesIn review
- v2 posting 2/236 patches 12 repliesSuperseded
- v2 posting 1/236 patches 28 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 28 patches | 15 replies | Superseded |
Changes in v3 from the cover letter
* dropped one patch (that exposes git_attr_counted, nobody uses it throughout the series )
* added pathspec guarding and added a test with git-add to see if it works.
* squashed "SQUASH" commits.
* changed test for multithreaded tests as git-status makes use of pathspec code that doesn't support this new magic yet.
Patches in v3 No applies recorded yet
Reviews trailers per patch
None of the 35 patches has a Reviewed-by or Acked-by.
| Patch | Junio C Hamano |
|---|---|
| 1/35 | |
| 2/35 | |
| 3/35 | |
| 4/35 | |
| 5/35 | |
| 6/35 | |
| 7/35 | |
| 8/35 | |
| 9/35 | |
| 10/35 | |
| 11/35 | |
| 12/35 | |
| 13/35 | |
| 14/35 | |
| 15/35 | |
| 16/35 | |
| 17/35 | |
| 18/35 | |
| 19/35 | |
| 20/35 | |
| 21/35 | |
| 22/35 | |
| 23/35 | |
| 24/35 | |
| 25/35 | |
| 26/35 | |
| 27/35 | |
| 28/35 | |
| 29/35 | |
| 30/35 | |
| 31/35 | |
| 32/35 | Helped-by |
| 33/35 | |
| 34/35 | |
| 35/35 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCHv3 00/35] Revamp the attr subsystem!
previous discussion: https://public-inbox.org/git/[email protected]/
Changes since v2:
* dropped one patch (that exposes git_attr_counted, nobody uses it throughout the series )
* added pathspec guarding and added a test with git-add to see if it works.
* squashed "SQUASH" commits.
* changed test for multithreaded tests as git-status makes use of pathspec code that doesn't support this new magic yet.
interdiff to currently queued at the bottom of this email.
v2 was:
previous discussion at https://public-inbox.org/git/[email protected]
This implements the discarded series':
jc/attr
jc/attr-more
sb/pathspec-label
sb/submodule-default-paths
This includes
* The fixes for windows
* Junios latest suggestion to use git_attr_check_initv instead of alloc/append.
* I implemented the thread safe attr API in patch 27 (attr: convert to new threadsafe API)
* patch 28 (attr: keep attr stack for each check) makes it actually possible to run in a multithreaded environment.
* I added a test for the multithreaded when it is introduced in patch 32 (pathspec: allow querying for attributes) as well as a test to disallow multiple "attr"s in a pathspec.
Thanks,
Stefan
Junio C Hamano (23):
commit.c: use strchrnul() to scan for one line
attr.c: use strchrnul() to scan for one line
attr.c: update a stale comment on "struct match_attr" attr.c: explain the lack of attr-name syntax check in parse_attr() attr.c: complete a sentence in a comment
attr.c: mark where #if DEBUG ends more clearly
attr.c: simplify macroexpand_one()
attr.c: tighten constness around "git_attr" structure attr.c: plug small leak in parse_attr_line()
attr: rename function and struct related to checking attributes
attr: (re)introduce git_check_attr() and struct git_attr_check
attr: convert git_all_attrs() to use "struct git_attr_check"
attr: convert git_check_attrs() callers to use the new API
attr: retire git_check_attrs() API
attr: add counted string version of git_check_attr()
attr: expose validity check for attribute names
attr.c: add push_stack() helper
attr.c: pass struct git_attr_check down the callchain attr.c: rename a local variable check
attr.c: correct ugly hack for git_all_attrs()
attr.c: introduce empty_attr_check_elems()
attr.c: always pass check[] to collect_some_attrs() attr.c: outline the future plans by heavily commenting
Nguyễn Thái Ngọc Duy (1):
attr: support quoting pathname patterns in C style
Stefan Beller (11):
attr: make git_check_attr_counted static
attr: convert to new threadsafe API
attr: keep attr stack for each check
Documentation: fix a typo
pathspec: move long magic parsing out of prefix_pathspec
pathspec: move prefix check out of the inner loop
pathspec: allow querying for attributes
pathspec: allow escaped query values
submodule update: add --init-default-path switch
clone: add --init-submodule=<pathspec> switch
completion: clone can initialize specific submodules
Documentation/config.txt | 5 + Documentation/git-clone.txt | 23 +- Documentation/git-submodule.txt | 17 +- Documentation/gitattributes.txt | 10 +- Documentation/glossary-content.txt | 20 + Documentation/technical/api-gitattributes.txt | 140 ++++--- archive.c | 25 +- attr.c | 517 ++++++++++++++++++-------- attr.h | 71 ++-- builtin/check-attr.c | 74 ++-- builtin/clone.c | 36 +- builtin/pack-objects.c | 27 +- commit.c | 3 +- common-main.c | 2 + contrib/completion/git-completion.bash | 1 + convert.c | 46 ++- dir.c | 41 +- git-submodule.sh | 21 +- hashmap.h | 2 + ll-merge.c | 35 +- pathspec.c | 228 ++++++++++-- pathspec.h | 19 +- t/t0003-attributes.sh | 26 ++ t/t6134-pathspec-with-labels.sh | 201 ++++++++++ t/t7400-submodule-basic.sh | 134 +++++++ userdiff.c | 21 +- ws.c | 19 +- 27 files changed, 1354 insertions(+), 410 deletions(-) create mode 100755 t/t6134-pathspec-with-labels.sh
-- interdiff to current origin/sb/attr:
attr.c +4 -4
@@ -135,7 +135,7 @@ static void report_invalid_attr(const char *name, size_t len,strbuf_release (&err); } -struct git_attr *git_attr_counted (const char *name,size_t len) +static struct git_attr *git_attr_internal (const char *name,int len) {unsigned hval =hash_name (name, len);unsigned pos = hval %HASHSIZE ;
@@ -171,7 +171,7 @@ struct git_attr *git_attr_counted(const char *name, size_t len)struct git_attr *git_attr (const char *name) { -return git_attr_counted (name,strlen (name)); +return git_attr_internal (name,strlen (name)); }/* What does a matched pattern decide? */
@@ -259,7 +259,7 @@ static const char *parse_attr(const char *src, int lineno, const char *cp,else { e->setto =xmemdupz (equals +1 , ep - equals -1 ); } - e->attr =git_attr_counted (cp, len); + e->attr =git_attr_internal (cp, len); }return ep +strspn (ep, blank); }
@@ -320,7 +320,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,sizeof (struct attr_state ) * num_attr + (is_macro ? 0 : namelen + 1));if (is_macro) { - res->u.attr =git_attr_counted (name, namelen); + res->u.attr =git_attr_internal (name, namelen); res->u.attr->maybe_macro =1 ; }else {char *p = (char *)&(res->state[num_attr]);
attr.h +1 -1
@@ -2,7 +2,7 @@#define ATTR_H /* -* Must be called on platforms that do not support static initialisation +* Must be called on platforms that do not support static initialization * of mutexes. */ extern void attr_start (void );
dir.c +4 -2
@@ -140,7 +140,8 @@ static size_t common_prefix_len(const struct pathspec *pathspec)PATHSPEC_LITERAL |PATHSPEC_GLOB |PATHSPEC_ICASE | - PATHSPEC_EXCLUDE); +PATHSPEC_EXCLUDE | + PATHSPEC_ATTR);for (n =0 ; n < pathspec->nr; n++) {size_t i =0 , len =0 , item_len;
@@ -349,7 +350,8 @@ static int do_match_pathspec(const struct pathspec *ps,PATHSPEC_LITERAL |PATHSPEC_GLOB |PATHSPEC_ICASE | - PATHSPEC_EXCLUDE); +PATHSPEC_EXCLUDE | + PATHSPEC_ATTR);if (!ps->nr) { if (!ps->recursive ||
pathspec.c +1 -0
@@ -232,6 +232,7 @@ static void eat_long_magic(struct pathspec_item *item, const char *elt,char *attr_body =xmemdupz (body, len -strlen ("attr:" ));parse_pathspec_attr_match (item, attr_body);free (attr_body); + *magic |=PATHSPEC_ATTR ;continue ; }
pathspec.h +3 -1
@@ -8,13 +8,15 @@#define PATHSPEC_GLOB (1<<3)#define PATHSPEC_ICASE (1<<4)#define PATHSPEC_EXCLUDE (1<<5) +#define PATHSPEC_ATTR (1<<6)#define PATHSPEC_ALL_MAGIC \ (PATHSPEC_FROMTOP | \ PATHSPEC_MAXDEPTH | \ PATHSPEC_LITERAL | \ PATHSPEC_GLOB | \ PATHSPEC_ICASE | \ - PATHSPEC_EXCLUDE) + PATHSPEC_EXCLUDE | \ + PATHSPEC_ATTR)#define PATHSPEC_ONESTAR 1/* the pathspec pattern satisfies GFNM_ONESTAR */
t/t6134-pathspec-with-labels.sh +17 -1
@@ -160,7 +160,23 @@ test_expect_success 'fail on multiple attr specifiers in one pathspec item' ' ' test_expect_success 'checking attributes in a multithreaded process' ' - git status ":(attr:labelB)" + cat <<-EOF >expect && + fileA:A + EOF + echo A >fileA && + echo A >fileB && + git grep A -- ":(attr:labelA)" >actual && + test_cmp expect actual +' + +test_expect_success 'fail if attr magic is used places not implemented' ' + # The main purpose of this test is to check that we actually fail + # when you attempt to use attr magic in commands that do not implement + # attr magic. This test does not advocate git-add to stay that way, + # though, but git-add is convenient as it has its own internal pathspec + # parsing. + test_must_fail git add ":(attr:labelB)" 2>actual && + test_i18ngrep "unsupported magic" actual ' test_expect_success 'abort on giving invalid label on the command line' '
Signature · 1 line
2.10.1.469.g00a8914