From: Brandon Williams <bmwill@google.com>
To: git@vger.kernel.org
Cc: Brandon Williams <bmwill@google.com>,
sbeller@google.com, pclouds@gmail.com, jonathantanmy@google.com
Subject: [PATCH v3 0/2] bringing attributes to pathspecs
Date: Mon, 13 Mar 2017 11:23:20 -0700 [thread overview]
Message-ID: <20170313182322.27539-1-bmwill@google.com> (raw)
In-Reply-To: <20170310185908.171589-1-bmwill@google.com>
v3 fixes some nits in style in the test script (using <<-\EOF instead of <<-EOF)
as well as fixing a few other minor things reported by Junio and Jonathan.
Brandon Williams (2):
pathspec: allow querying for attributes
pathspec: allow escaped query values
Documentation/glossary-content.txt | 21 ++++
attr.c | 17 ++++
attr.h | 1 +
dir.c | 43 +++++++-
pathspec.c | 159 +++++++++++++++++++++++++++--
pathspec.h | 15 ++-
t/t6135-pathspec-with-attrs.sh | 200 +++++++++++++++++++++++++++++++++++++
7 files changed, 446 insertions(+), 10 deletions(-)
create mode 100755 t/t6135-pathspec-with-attrs.sh
--- interdiff with bw/attr-pathspec
diff --git a/pathspec.c b/pathspec.c
index d7956f6bf..303efda83 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -139,7 +139,7 @@ static void parse_pathspec_attr_match(struct pathspec_item *item, const char *va
struct string_list_item *si;
struct string_list list = STRING_LIST_INIT_DUP;
- if (item->attr_check)
+ if (item->attr_check || item->attr_match)
die(_("Only one 'attr:' specification is allowed."));
if (!value || !*value)
@@ -149,9 +149,7 @@ static void parse_pathspec_attr_match(struct pathspec_item *item, const char *va
string_list_remove_empty_items(&list, 0);
item->attr_check = attr_check_alloc();
- ALLOC_GROW(item->attr_match,
- list.nr,
- item->attr_match_alloc);
+ item->attr_match = xcalloc(list.nr, sizeof(struct attr_match));
for_each_string_list_item(si, &list) {
size_t attr_len;
@@ -462,7 +460,6 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,
item->attr_check = NULL;
item->attr_match = NULL;
item->attr_match_nr = 0;
- item->attr_match_alloc = 0;
/* PATHSPEC_LITERAL_PATH ignores magic */
if (flags & PATHSPEC_LITERAL_PATH) {
@@ -712,8 +709,7 @@ void copy_pathspec(struct pathspec *dst, const struct pathspec *src)
COPY_ARRAY(d->attr_match, s->attr_match, d->attr_match_nr);
for (j = 0; j < d->attr_match_nr; j++) {
const char *value = s->attr_match[j].value;
- if (value)
- d->attr_match[j].value = xstrdup(value);
+ d->attr_match[j].value = xstrdup_or_null(value);
}
d->attr_check = attr_check_dup(s->attr_check);
diff --git a/pathspec.h b/pathspec.h
index 83625f006..55e976972 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -34,7 +34,6 @@ struct pathspec {
int nowildcard_len;
int flags;
int attr_match_nr;
- int attr_match_alloc;
struct attr_match {
char *value;
enum attr_match_mode {
diff --git a/t/t6135-pathspec-with-attrs.sh b/t/t6135-pathspec-with-attrs.sh
index f60af29a9..77b8cef66 100755
--- a/t/t6135-pathspec-with-attrs.sh
+++ b/t/t6135-pathspec-with-attrs.sh
@@ -4,7 +4,7 @@ test_description='test labels in pathspecs'
. ./test-lib.sh
test_expect_success 'setup a tree' '
- cat <<-EOF >expect &&
+ cat <<-\EOF >expect &&
fileA
fileAB
fileAC
@@ -49,7 +49,7 @@ test_expect_success 'pathspec with labels and non existent .gitattributes' '
'
test_expect_success 'setup .gitattributes' '
- cat <<-EOF >.gitattributes &&
+ cat <<-\EOF >.gitattributes &&
fileA labelA
fileB labelB
fileC labelC
@@ -66,7 +66,7 @@ test_expect_success 'setup .gitattributes' '
'
test_expect_success 'check specific set attr' '
- cat <<-EOF >expect &&
+ cat <<-\EOF >expect &&
fileSetLabel
sub/fileSetLabel
EOF
@@ -75,7 +75,7 @@ test_expect_success 'check specific set attr' '
'
test_expect_success 'check specific unset attr' '
- cat <<-EOF >expect &&
+ cat <<-\EOF >expect &&
fileUnsetLabel
sub/fileUnsetLabel
EOF
@@ -84,7 +84,7 @@ test_expect_success 'check specific unset attr' '
'
test_expect_success 'check specific value attr' '
- cat <<-EOF >expect &&
+ cat <<-\EOF >expect &&
fileValue
sub/fileValue
EOF
@@ -95,7 +95,7 @@ test_expect_success 'check specific value attr' '
'
test_expect_success 'check unspecified attr' '
- cat <<-EOF >expect &&
+ cat <<-\EOF >expect &&
.gitattributes
fileA
fileAB
@@ -119,7 +119,7 @@ test_expect_success 'check unspecified attr' '
'
test_expect_success 'check multiple unspecified attr' '
- cat <<-EOF >expect &&
+ cat <<-\EOF >expect &&
.gitattributes
fileC
fileNoLabel
@@ -133,7 +133,7 @@ test_expect_success 'check multiple unspecified attr' '
'
test_expect_success 'check label with more labels but excluded path' '
- cat <<-EOF >expect &&
+ cat <<-\EOF >expect &&
fileAB
fileB
fileBC
@@ -143,7 +143,7 @@ test_expect_success 'check label with more labels but excluded path' '
'
test_expect_success 'check label excluding other labels' '
- cat <<-EOF >expect &&
+ cat <<-\EOF >expect &&
fileAB
fileB
fileBC
--
2.12.0.246.ga2ecc84866-goog
next prev parent reply other threads:[~2017-03-13 18:23 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-09 21:07 [PATCH 0/2] bringing attributes to pathspecs Brandon Williams
2017-03-09 21:07 ` [PATCH 1/2] pathspec: allow querying for attributes Brandon Williams
2017-03-09 22:19 ` Jonathan Tan
2017-03-10 18:26 ` Brandon Williams
2017-03-13 2:43 ` Junio C Hamano
2017-03-13 18:30 ` Stefan Beller
2017-03-09 21:07 ` [PATCH 2/2] pathspec: allow escaped query values Brandon Williams
2017-03-09 22:31 ` Jonathan Tan
2017-03-10 18:53 ` Brandon Williams
2017-03-09 21:22 ` [PATCH 0/2] bringing attributes to pathspecs Stefan Beller
2017-03-10 18:59 ` [PATCH v2 " Brandon Williams
2017-03-10 18:59 ` [PATCH v2 1/2] pathspec: allow querying for attributes Brandon Williams
2017-03-10 19:56 ` Jonathan Tan
2017-03-11 0:28 ` Brandon Williams
2017-03-10 18:59 ` [PATCH v2 2/2] pathspec: allow escaped query values Brandon Williams
2017-03-13 18:23 ` Brandon Williams [this message]
2017-03-13 18:23 ` [PATCH v3 1/2] pathspec: allow querying for attributes Brandon Williams
2017-03-13 18:23 ` [PATCH v3 2/2] pathspec: allow escaped query values Brandon Williams
2017-03-13 22:30 ` [PATCH v3 0/2] bringing attributes to pathspecs Junio C Hamano
2017-03-13 22:38 ` Brandon Williams
2017-03-21 10:51 ` Duy Nguyen
2017-03-21 15:51 ` Junio C Hamano
2017-03-21 16:52 ` Brandon Williams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170313182322.27539-1-bmwill@google.com \
--to=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=jonathantanmy@google.com \
--cc=pclouds@gmail.com \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.