* [PATCH v2 00/19] Add --all option to git-check-attr
@ 2011-07-28 4:46 Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 01/19] doc: Add a link from gitattributes(5) to git-check-attr(1) Michael Haggerty
` (18 more replies)
0 siblings, 19 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
This version of the patch series fixes a formatting problem found by
Junio and mentions in the documentation that "-a" means the same as
"--all".
Currently it is possible to inquire the values of particular
attributes on particular files, using either the API function
git_checkattr() or the command "git check-attr". But it is not
possible to ask for *all* attributes that are associated with a
particular file. This patch series adds that functionality:
* A new API call git_allattr()
* A new option "git check-attr --all -- pathnames"
Along the way, several small cleanups are made in the general
neighborhood, including:
* Disallow the empty string as an attribute name
* Provide access to the name attribute of git_attr
* Fail with an error message if no pathnames are provided on the
command line (and --stdin is not used)
* If --stdin is used, interpret all command-line arguments as
attribute names
* Rename struct git_attr_check to git_attr_value
Most of the patches are hopefully self-explanatory; see the individual
patch emails for discussion of changes that might potentially be
controversial.
Michael Haggerty (19):
doc: Add a link from gitattributes(5) to git-check-attr(1)
doc: Correct git_attr() calls in example code
Remove anachronism from comment
Disallow the empty string as an attribute name
git-check-attr: Add missing "&&"
git-check-attr: Add tests of command-line parsing
Provide access to the name attribute of git_attr
git-check-attr: Use git_attr_name()
Allow querying all attributes on a file
git-check-attr: Extract a function output_attr()
git-check-attr: Introduce a new variable
git-check-attr: Extract a function error_with_usage()
git-check-attr: Handle each error separately
git-check-attr: Process command-line args more systematically
git-check-attr: Error out if no pathnames are specified
git-check-attr: Add an --all option to show all attributes
git-check-attr: Drive two tests using the same raw data
git-check-attr: Fix command-line handling to match docs
Rename struct git_attr_check to git_attr_value
Documentation/git-check-attr.txt | 23 ++++-
Documentation/gitattributes.txt | 3 +
Documentation/technical/api-gitattributes.txt | 66 +++++++++-----
archive.c | 4 +-
attr.c | 62 +++++++++++--
attr.h | 24 ++++-
builtin/check-attr.c | 123 ++++++++++++++++--------
builtin/pack-objects.c | 4 +-
convert.c | 10 +-
ll-merge.c | 6 +-
t/t0003-attributes.sh | 61 +++++++++----
userdiff.c | 2 +-
ws.c | 4 +-
13 files changed, 279 insertions(+), 113 deletions(-)
--
1.7.6.8.gd2879
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v2 01/19] doc: Add a link from gitattributes(5) to git-check-attr(1)
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 02/19] doc: Correct git_attr() calls in example code Michael Haggerty
` (17 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
Documentation/gitattributes.txt | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 412c55b..3d86434 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -952,6 +952,9 @@ frotz unspecified
----------------------------------------------------------------
+SEE ALSO
+--------
+linkgit:git-check-attr[1].
GIT
---
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 02/19] doc: Correct git_attr() calls in example code
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 01/19] doc: Add a link from gitattributes(5) to git-check-attr(1) Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 03/19] Remove anachronism from comment Michael Haggerty
` (16 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Commit 7fb0eaa2 (2010-01-17) changed git_attr() to take a string
instead of a string and a length. Update the documentation
accordingly.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
Documentation/technical/api-gitattributes.txt | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Documentation/technical/api-gitattributes.txt b/Documentation/technical/api-gitattributes.txt
index 9d97eaa..916720f 100644
--- a/Documentation/technical/api-gitattributes.txt
+++ b/Documentation/technical/api-gitattributes.txt
@@ -11,9 +11,9 @@ Data Structure
`struct git_attr`::
An attribute is an opaque object that is identified by its name.
- Pass the name and its length to `git_attr()` function to obtain
- the object of this type. The internal representation of this
- structure is of no interest to the calling programs.
+ Pass the name to `git_attr()` function to obtain the object of
+ this type. The internal representation of this structure is
+ of no interest to the calling programs.
`struct git_attr_check`::
@@ -72,8 +72,8 @@ static void setup_check(void)
{
if (check[0].attr)
return; /* already done */
- check[0].attr = git_attr("crlf", 4);
- check[1].attr = git_attr("ident", 5);
+ check[0].attr = git_attr("crlf");
+ check[1].attr = git_attr("ident");
}
------------
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 03/19] Remove anachronism from comment
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 01/19] doc: Add a link from gitattributes(5) to git-check-attr(1) Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 02/19] doc: Correct git_attr() calls in example code Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 04/19] Disallow the empty string as an attribute name Michael Haggerty
` (15 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Setting attributes to arbitrary values ("attribute=value") is now
supported, so it is no longer necessary for this comment to justify
prohibiting '=' in an attribute name.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
attr.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/attr.c b/attr.c
index f6b3f7e..4a1244f 100644
--- a/attr.c
+++ b/attr.c
@@ -50,10 +50,8 @@ static unsigned hash_name(const char *name, int namelen)
static int invalid_attr_name(const char *name, int namelen)
{
/*
- * Attribute name cannot begin with '-' and from
- * [-A-Za-z0-9_.]. We'd specifically exclude '=' for now,
- * as we might later want to allow non-binary value for
- * attributes, e.g. "*.svg merge=special-merge-program-for-svg"
+ * Attribute name cannot begin with '-' and must consist of
+ * characters from [-A-Za-z0-9_.].
*/
if (*name == '-')
return -1;
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 04/19] Disallow the empty string as an attribute name
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (2 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 03/19] Remove anachronism from comment Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 05/19] git-check-attr: Add missing "&&" Michael Haggerty
` (14 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Previously, it was possible to have a line like "file.txt =foo" in a
.gitattribute file, after which an invocation like "git check-attr ''
-- file.txt" would succeed. This patch disallows both constructs.
Please note that any existing .gitattributes file that tries to set an
empty attribute will now trigger the error message "error: : not a
valid attribute name" whereas previously the nonsense was allowed
through.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
attr.c | 2 +-
t/t0003-attributes.sh | 6 ++++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/attr.c b/attr.c
index 4a1244f..b1d1d6d 100644
--- a/attr.c
+++ b/attr.c
@@ -53,7 +53,7 @@ static int invalid_attr_name(const char *name, int namelen)
* Attribute name cannot begin with '-' and must consist of
* characters from [-A-Za-z0-9_.].
*/
- if (*name == '-')
+ if (namelen <= 0 || *name == '-')
return -1;
while (namelen--) {
char ch = *name++;
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index ebbc755..8c76b79 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -42,6 +42,12 @@ test_expect_success 'setup' '
'
+test_expect_success 'command line checks' '
+
+ test_must_fail git check-attr "" -- f
+
+'
+
test_expect_success 'attribute test' '
attr_check f f &&
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 05/19] git-check-attr: Add missing "&&"
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (3 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 04/19] Disallow the empty string as an attribute name Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 06/19] git-check-attr: Add tests of command-line parsing Michael Haggerty
` (13 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
t/t0003-attributes.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 8c76b79..dae76b3 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -35,7 +35,7 @@ test_expect_success 'setup' '
echo "h test=a/b/h" &&
echo "d/* test=a/b/d/*"
echo "d/yes notest"
- ) >a/b/.gitattributes
+ ) >a/b/.gitattributes &&
(
echo "global test=global"
) >"$HOME"/global-gitattributes
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 06/19] git-check-attr: Add tests of command-line parsing
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (4 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 05/19] git-check-attr: Add missing "&&" Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 07/19] Provide access to the name attribute of git_attr Michael Haggerty
` (12 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
t/t0003-attributes.sh | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index dae76b3..f1debeb 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -44,6 +44,13 @@ test_expect_success 'setup' '
test_expect_success 'command line checks' '
+ test_must_fail git check-attr &&
+ test_must_fail git check-attr -- &&
+ test_must_fail git check-attr -- f &&
+ echo "f" | test_must_fail git check-attr --stdin &&
+ echo "f" | test_must_fail git check-attr --stdin -- f &&
+ echo "f" | test_must_fail git check-attr --stdin test -- f &&
+ echo "f" | test_must_fail git check-attr --stdin test f &&
test_must_fail git check-attr "" -- f
'
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 07/19] Provide access to the name attribute of git_attr
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (5 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 06/19] git-check-attr: Add tests of command-line parsing Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 08/19] git-check-attr: Use git_attr_name() Michael Haggerty
` (11 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
It will be present in any likely future reimplementation, and its
availability simplifies other code.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
Documentation/technical/api-gitattributes.txt | 3 ++-
attr.c | 5 +++++
attr.h | 7 +++++++
3 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/Documentation/technical/api-gitattributes.txt b/Documentation/technical/api-gitattributes.txt
index 916720f..ab3a84d 100644
--- a/Documentation/technical/api-gitattributes.txt
+++ b/Documentation/technical/api-gitattributes.txt
@@ -13,7 +13,8 @@ Data Structure
An attribute is an opaque object that is identified by its name.
Pass the name to `git_attr()` function to obtain the object of
this type. The internal representation of this structure is
- of no interest to the calling programs.
+ of no interest to the calling programs. The name of the
+ attribute can be retrieved by calling `git_attr_name()`.
`struct git_attr_check`::
diff --git a/attr.c b/attr.c
index b1d1d6d..bfa1f43 100644
--- a/attr.c
+++ b/attr.c
@@ -36,6 +36,11 @@ static int attr_nr;
static struct git_attr_check *check_all_attr;
static struct git_attr *(git_attr_hash[HASHSIZE]);
+char *git_attr_name(struct git_attr *attr)
+{
+ return attr->name;
+}
+
static unsigned hash_name(const char *name, int namelen)
{
unsigned val = 0, c;
diff --git a/attr.h b/attr.h
index 8b3f19b..d4f875a 100644
--- a/attr.h
+++ b/attr.h
@@ -29,6 +29,13 @@ struct git_attr_check {
const char *value;
};
+/*
+ * Return the name of the attribute represented by the argument. The
+ * return value is a pointer to a null-delimited string that is part
+ * of the internal data structure; it should not be modified or freed.
+ */
+char *git_attr_name(struct git_attr *);
+
int git_checkattr(const char *path, int, struct git_attr_check *);
enum git_attr_direction {
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 08/19] git-check-attr: Use git_attr_name()
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (6 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 07/19] Provide access to the name attribute of git_attr Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 09/19] Allow querying all attributes on a file Michael Haggerty
` (10 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
builtin/check-attr.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 3016d29..5f04126 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -21,7 +21,7 @@ static const struct option check_attr_options[] = {
};
static void check_attr(int cnt, struct git_attr_check *check,
- const char** name, const char *file)
+ const char *file)
{
int j;
if (git_checkattr(file, cnt, check))
@@ -37,12 +37,11 @@ static void check_attr(int cnt, struct git_attr_check *check,
value = "unspecified";
quote_c_style(file, NULL, stdout, 0);
- printf(": %s: %s\n", name[j], value);
+ printf(": %s: %s\n", git_attr_name(check[j].attr), value);
}
}
-static void check_attr_stdin_paths(int cnt, struct git_attr_check *check,
- const char** name)
+static void check_attr_stdin_paths(int cnt, struct git_attr_check *check)
{
struct strbuf buf, nbuf;
int line_termination = null_term_line ? 0 : '\n';
@@ -56,7 +55,7 @@ static void check_attr_stdin_paths(int cnt, struct git_attr_check *check,
die("line is badly quoted");
strbuf_swap(&buf, &nbuf);
}
- check_attr(cnt, check, name, buf.buf);
+ check_attr(cnt, check, buf.buf);
maybe_flush_or_die(stdout, "attribute to stdout");
}
strbuf_release(&buf);
@@ -113,10 +112,10 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
}
if (stdin_paths)
- check_attr_stdin_paths(cnt, check, argv);
+ check_attr_stdin_paths(cnt, check);
else {
for (i = doubledash; i < argc; i++)
- check_attr(cnt, check, argv, argv[i]);
+ check_attr(cnt, check, argv[i]);
maybe_flush_or_die(stdout, "attribute to stdout");
}
return 0;
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 09/19] Allow querying all attributes on a file
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (7 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 08/19] git-check-attr: Use git_attr_name() Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-08-02 15:34 ` Junio C Hamano
2011-07-28 4:46 ` [PATCH v2 10/19] git-check-attr: Extract a function output_attr() Michael Haggerty
` (9 subsequent siblings)
18 siblings, 1 reply; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Add a function, git_allattrs(), that reports on all attributes that
are set on a path.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
Documentation/technical/api-gitattributes.txt | 45 +++++++++++++++++-------
attr.c | 43 +++++++++++++++++++++++
attr.h | 9 +++++
3 files changed, 84 insertions(+), 13 deletions(-)
diff --git a/Documentation/technical/api-gitattributes.txt b/Documentation/technical/api-gitattributes.txt
index ab3a84d..640240e 100644
--- a/Documentation/technical/api-gitattributes.txt
+++ b/Documentation/technical/api-gitattributes.txt
@@ -22,19 +22,6 @@ Data Structure
to `git_checkattr()` function, and receives the results.
-Calling Sequence
-----------------
-
-* Prepare an array of `struct git_attr_check` to define the list of
- attributes you would want to check. To populate this array, you would
- need to define necessary attributes by calling `git_attr()` function.
-
-* Call git_checkattr() to check the attributes for the path.
-
-* Inspect `git_attr_check` structure to see how each of the attribute in
- the array is defined for the path.
-
-
Attribute Values
----------------
@@ -58,6 +45,19 @@ If none of the above returns true, `.value` member points at a string
value of the attribute for the path.
+Querying Specific Attributes
+----------------------------
+
+* Prepare an array of `struct git_attr_check` to define the list of
+ attributes you would want to check. To populate this array, you would
+ need to define necessary attributes by calling `git_attr()` function.
+
+* Call `git_checkattr()` to check the attributes for the path.
+
+* Inspect `git_attr_check` structure to see how each of the attribute in
+ the array is defined for the path.
+
+
Example
-------
@@ -109,4 +109,23 @@ static void setup_check(void)
}
------------
+
+Querying All Attributes
+-----------------------
+
+To get the values of all attributes associated with a file:
+
+* Call `git_allattrs()`, which returns an array of `git_attr_check`
+ structures.
+
+* Iterate over the `git_attr_check` array to examine the attribute
+ names and values. The name of the attribute described by a
+ `git_attr_check` object can be retrieved via
+ `git_attr_name(check[i].attr)`. (Please note that no items will be
+ returned for unset attributes, so `ATTR_UNSET()` will return false
+ for all returned `git_array_check` objects.)
+
+* Free the `git_array_check` array.
+
+
(JC)
diff --git a/attr.c b/attr.c
index bfa1f43..9c2fca8 100644
--- a/attr.c
+++ b/attr.c
@@ -737,6 +737,49 @@ int git_checkattr(const char *path, int num, struct git_attr_check *check)
return 0;
}
+int git_allattrs(const char *path, int *num, struct git_attr_check **check)
+{
+ struct attr_stack *stk;
+ const char *cp;
+ int dirlen, pathlen, i, rem, count, j;
+
+ bootstrap_attr_stack();
+ for (i = 0; i < attr_nr; i++)
+ check_all_attr[i].value = ATTR__UNKNOWN;
+
+ pathlen = strlen(path);
+ cp = strrchr(path, '/');
+ if (!cp)
+ dirlen = 0;
+ else
+ dirlen = cp - path;
+ prepare_attr_stack(path, dirlen);
+ rem = attr_nr;
+ for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)
+ rem = fill(path, pathlen, stk, rem);
+
+ /* Count the number of attributes that are set. */
+ count = 0;
+ for (i = 0; i < attr_nr; i++) {
+ const char *value = check_all_attr[i].value;
+ if (value != ATTR__UNSET && value != ATTR__UNKNOWN)
+ ++count;
+ }
+ *num = count;
+ *check = xmalloc(sizeof(*check_all_attr) * count);
+ j = 0;
+ for (i = 0; i < attr_nr; i++) {
+ const char *value = check_all_attr[i].value;
+ if (value != ATTR__UNSET && value != ATTR__UNKNOWN) {
+ (*check)[j].attr = check_all_attr[i].attr;
+ (*check)[j].value = value;
+ ++j;
+ }
+ }
+
+ return 0;
+}
+
void git_attr_set_direction(enum git_attr_direction new, struct index_state *istate)
{
enum git_attr_direction old = direction;
diff --git a/attr.h b/attr.h
index d4f875a..83202f0 100644
--- a/attr.h
+++ b/attr.h
@@ -38,6 +38,15 @@ char *git_attr_name(struct git_attr *);
int git_checkattr(const char *path, int, struct git_attr_check *);
+/*
+ * Retrieve all attributes that apply to the specified path. *num
+ * will be set the the number of attributes on the path; **check will
+ * be set to point at a newly-allocated array of git_attr_check
+ * objects describing the attributes and their values. *check must be
+ * free()ed by the caller.
+ */
+int git_allattrs(const char *path, int *num, struct git_attr_check **check);
+
enum git_attr_direction {
GIT_ATTR_CHECKIN,
GIT_ATTR_CHECKOUT,
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 10/19] git-check-attr: Extract a function output_attr()
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (8 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 09/19] Allow querying all attributes on a file Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 11/19] git-check-attr: Introduce a new variable Michael Haggerty
` (8 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
builtin/check-attr.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 5f04126..384c5a6 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -20,12 +20,10 @@ static const struct option check_attr_options[] = {
OPT_END()
};
-static void check_attr(int cnt, struct git_attr_check *check,
+static void output_attr(int cnt, struct git_attr_check *check,
const char *file)
{
int j;
- if (git_checkattr(file, cnt, check))
- die("git_checkattr died");
for (j = 0; j < cnt; j++) {
const char *value = check[j].value;
@@ -41,6 +39,14 @@ static void check_attr(int cnt, struct git_attr_check *check,
}
}
+static void check_attr(int cnt, struct git_attr_check *check,
+ const char *file)
+{
+ if (git_checkattr(file, cnt, check))
+ die("git_checkattr died");
+ output_attr(cnt, check, file);
+}
+
static void check_attr_stdin_paths(int cnt, struct git_attr_check *check)
{
struct strbuf buf, nbuf;
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 11/19] git-check-attr: Introduce a new variable
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (9 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 10/19] git-check-attr: Extract a function output_attr() Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 12/19] git-check-attr: Extract a function error_with_usage() Michael Haggerty
` (7 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Avoid reusing variable "doubledash" to mean something other than the
expected "position of a double-dash, if any".
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
builtin/check-attr.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 384c5a6..c527078 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -71,7 +71,7 @@ static void check_attr_stdin_paths(int cnt, struct git_attr_check *check)
int cmd_check_attr(int argc, const char **argv, const char *prefix)
{
struct git_attr_check *check;
- int cnt, i, doubledash;
+ int cnt, i, doubledash, filei;
const char *errstr = NULL;
argc = parse_options(argc, argv, prefix, check_attr_options,
@@ -92,14 +92,15 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
/* If there is no double dash, we handle only one attribute */
if (doubledash < 0) {
cnt = 1;
- doubledash = 0;
- } else
+ filei = 1;
+ } else {
cnt = doubledash;
- doubledash++;
+ filei = doubledash + 1;
+ }
if (cnt <= 0)
errstr = "No attribute specified";
- else if (stdin_paths && doubledash < argc)
+ else if (stdin_paths && filei < argc)
errstr = "Can't specify files with --stdin";
if (errstr) {
error("%s", errstr);
@@ -120,7 +121,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
if (stdin_paths)
check_attr_stdin_paths(cnt, check);
else {
- for (i = doubledash; i < argc; i++)
+ for (i = filei; i < argc; i++)
check_attr(cnt, check, argv[i]);
maybe_flush_or_die(stdout, "attribute to stdout");
}
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 12/19] git-check-attr: Extract a function error_with_usage()
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (10 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 11/19] git-check-attr: Introduce a new variable Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 13/19] git-check-attr: Handle each error separately Michael Haggerty
` (6 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
builtin/check-attr.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index c527078..d004222 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -68,6 +68,12 @@ static void check_attr_stdin_paths(int cnt, struct git_attr_check *check)
strbuf_release(&nbuf);
}
+static NORETURN void error_with_usage(const char *msg)
+{
+ error("%s", msg);
+ usage_with_options(check_attr_usage, check_attr_options);
+}
+
int cmd_check_attr(int argc, const char **argv, const char *prefix)
{
struct git_attr_check *check;
@@ -103,8 +109,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
else if (stdin_paths && filei < argc)
errstr = "Can't specify files with --stdin";
if (errstr) {
- error("%s", errstr);
- usage_with_options(check_attr_usage, check_attr_options);
+ error_with_usage(errstr);
}
check = xcalloc(cnt, sizeof(*check));
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 13/19] git-check-attr: Handle each error separately
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (11 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 12/19] git-check-attr: Extract a function error_with_usage() Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 14/19] git-check-attr: Process command-line args more systematically Michael Haggerty
` (5 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
This will make the code easier to refactor.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
builtin/check-attr.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index d004222..de3fef7 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -78,7 +78,6 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
{
struct git_attr_check *check;
int cnt, i, doubledash, filei;
- const char *errstr = NULL;
argc = parse_options(argc, argv, prefix, check_attr_options,
check_attr_usage, PARSE_OPT_KEEP_DASHDASH);
@@ -105,12 +104,10 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
}
if (cnt <= 0)
- errstr = "No attribute specified";
- else if (stdin_paths && filei < argc)
- errstr = "Can't specify files with --stdin";
- if (errstr) {
- error_with_usage(errstr);
- }
+ error_with_usage("No attribute specified");
+
+ if (stdin_paths && filei < argc)
+ error_with_usage("Can't specify files with --stdin");
check = xcalloc(cnt, sizeof(*check));
for (i = 0; i < cnt; i++) {
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 14/19] git-check-attr: Process command-line args more systematically
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (12 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 13/19] git-check-attr: Handle each error separately Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 15/19] git-check-attr: Error out if no pathnames are specified Michael Haggerty
` (4 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
builtin/check-attr.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index de3fef7..e9b827f 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -81,8 +81,6 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, check_attr_options,
check_attr_usage, PARSE_OPT_KEEP_DASHDASH);
- if (!argc)
- usage_with_options(check_attr_usage, check_attr_options);
if (read_cache() < 0) {
die("invalid cache");
@@ -94,8 +92,17 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
doubledash = i;
}
- /* If there is no double dash, we handle only one attribute */
- if (doubledash < 0) {
+ /* Check attribute argument(s): */
+ if (doubledash == 0) {
+ error_with_usage("No attribute specified");
+ } else if (doubledash < 0) {
+ /*
+ * There is no double dash; treat the first
+ * argument as an attribute.
+ */
+ if (!argc)
+ error_with_usage("No attribute specified");
+
cnt = 1;
filei = 1;
} else {
@@ -103,9 +110,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
filei = doubledash + 1;
}
- if (cnt <= 0)
- error_with_usage("No attribute specified");
-
+ /* Check file argument(s): */
if (stdin_paths && filei < argc)
error_with_usage("Can't specify files with --stdin");
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 15/19] git-check-attr: Error out if no pathnames are specified
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (13 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 14/19] git-check-attr: Process command-line args more systematically Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 16/19] git-check-attr: Add an --all option to show all attributes Michael Haggerty
` (3 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
If no pathnames are passed as command-line arguments and the --stdin
option is not specified, fail with the error message "No file
specified". Add tests of this behavior.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
builtin/check-attr.c | 9 +++++++--
t/t0003-attributes.sh | 2 ++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index e9b827f..6cf6421 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -111,8 +111,13 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
}
/* Check file argument(s): */
- if (stdin_paths && filei < argc)
- error_with_usage("Can't specify files with --stdin");
+ if (stdin_paths) {
+ if (filei < argc)
+ error_with_usage("Can't specify files with --stdin");
+ } else {
+ if (filei >= argc)
+ error_with_usage("No file specified");
+ }
check = xcalloc(cnt, sizeof(*check));
for (i = 0; i < cnt; i++) {
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index f1debeb..2254005 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -46,6 +46,8 @@ test_expect_success 'command line checks' '
test_must_fail git check-attr &&
test_must_fail git check-attr -- &&
+ test_must_fail git check-attr test &&
+ test_must_fail git check-attr test -- &&
test_must_fail git check-attr -- f &&
echo "f" | test_must_fail git check-attr --stdin &&
echo "f" | test_must_fail git check-attr --stdin -- f &&
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 16/19] git-check-attr: Add an --all option to show all attributes
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (14 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 15/19] git-check-attr: Error out if no pathnames are specified Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 17/19] git-check-attr: Drive two tests using the same raw data Michael Haggerty
` (2 subsequent siblings)
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Add new usage patterns
git check-attr [-a | --all] [--] pathname...
git check-attr --stdin [-a | --all] < <list-of-paths>
which display all attributes associated with the specified file(s).
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
Documentation/git-check-attr.txt | 16 ++++++++++-
builtin/check-attr.c | 52 ++++++++++++++++++++++++++-----------
t/t0003-attributes.sh | 24 +++++++++++++++++
3 files changed, 74 insertions(+), 18 deletions(-)
diff --git a/Documentation/git-check-attr.txt b/Documentation/git-check-attr.txt
index 30eca6c..798e5d5 100644
--- a/Documentation/git-check-attr.txt
+++ b/Documentation/git-check-attr.txt
@@ -9,8 +9,8 @@ git-check-attr - Display gitattributes information
SYNOPSIS
--------
[verse]
-'git check-attr' attr... [--] pathname...
-'git check-attr' --stdin [-z] attr... < <list-of-paths>
+'git check-attr' [-a | --all | attr...] [--] pathname...
+'git check-attr' --stdin [-z] [-a | --all | attr...] < <list-of-paths>
DESCRIPTION
-----------
@@ -19,6 +19,11 @@ For every pathname, this command will list if each attribute is 'unspecified',
OPTIONS
-------
+-a, --all::
+ List all attributes that are associated with the specified
+ paths. If this option is used, then 'unspecified' attributes
+ will not be included in the output.
+
--stdin::
Read file names from stdin instead of from the command-line.
@@ -69,6 +74,13 @@ org/example/MyClass.java: diff: java
org/example/MyClass.java: myAttr: set
---------------
+* Listing all attributes for a file:
+---------------
+$ git check-attr --all -- org/example/MyClass.java
+org/example/MyClass.java: diff: java
+org/example/MyClass.java: myAttr: set
+---------------
+
* Listing an attribute for multiple files:
---------------
$ git check-attr myAttr -- org/example/MyClass.java org/example/NoMyAttr.java
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 6cf6421..48834b4 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -4,16 +4,18 @@
#include "quote.h"
#include "parse-options.h"
+static int all_attrs;
static int stdin_paths;
static const char * const check_attr_usage[] = {
-"git check-attr attr... [--] pathname...",
-"git check-attr --stdin attr... < <list-of-paths>",
+"git check-attr [-a | --all | attr...] [--] pathname...",
+"git check-attr --stdin [-a | --all | attr...] < <list-of-paths>",
NULL
};
static int null_term_line;
static const struct option check_attr_options[] = {
+ OPT_BOOLEAN('a', "all", &all_attrs, "report all attributes set on file"),
OPT_BOOLEAN(0 , "stdin", &stdin_paths, "read file names from stdin"),
OPT_BOOLEAN('z', NULL, &null_term_line,
"input paths are terminated by a null character"),
@@ -42,9 +44,16 @@ static void output_attr(int cnt, struct git_attr_check *check,
static void check_attr(int cnt, struct git_attr_check *check,
const char *file)
{
- if (git_checkattr(file, cnt, check))
- die("git_checkattr died");
- output_attr(cnt, check, file);
+ if (check != NULL) {
+ if (git_checkattr(file, cnt, check))
+ die("git_checkattr died");
+ output_attr(cnt, check, file);
+ } else {
+ if (git_allattrs(file, &cnt, &check))
+ die("git_allattrs died");
+ output_attr(cnt, check, file);
+ free(check);
+ }
}
static void check_attr_stdin_paths(int cnt, struct git_attr_check *check)
@@ -92,8 +101,14 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
doubledash = i;
}
- /* Check attribute argument(s): */
- if (doubledash == 0) {
+ /* Process --all and/or attribute arguments: */
+ if (all_attrs) {
+ if (doubledash >= 1)
+ error_with_usage("Attributes and --all both specified");
+
+ cnt = 0;
+ filei = doubledash + 1;
+ } else if (doubledash == 0) {
error_with_usage("No attribute specified");
} else if (doubledash < 0) {
/*
@@ -119,15 +134,20 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
error_with_usage("No file specified");
}
- check = xcalloc(cnt, sizeof(*check));
- for (i = 0; i < cnt; i++) {
- const char *name;
- struct git_attr *a;
- name = argv[i];
- a = git_attr(name);
- if (!a)
- return error("%s: not a valid attribute name", name);
- check[i].attr = a;
+ if (all_attrs) {
+ check = NULL;
+ } else {
+ check = xcalloc(cnt, sizeof(*check));
+ for (i = 0; i < cnt; i++) {
+ const char *name;
+ struct git_attr *a;
+ name = argv[i];
+ a = git_attr(name);
+ if (!a)
+ return error("%s: not a valid attribute name",
+ name);
+ check[i].attr = a;
+ }
}
if (stdin_paths)
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 2254005..8892ba3 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -107,6 +107,30 @@ EOF
test_cmp expect actual
'
+test_expect_success 'attribute test: --all option' '
+
+ cat <<EOF > all &&
+f: test: f
+a/f: test: f
+a/c/f: test: f
+a/g: test: a/g
+a/b/g: test: a/b/g
+b/g: test: unspecified
+a/b/h: test: a/b/h
+a/b/d/g: test: a/b/d/*
+onoff: test: unset
+offon: test: set
+no: notest: set
+a/b/d/no: test: a/b/d/*
+a/b/d/no: notest: set
+a/b/d/yes: notest: set
+EOF
+
+ grep -v unspecified < all | sort > expect &&
+ sed -e "s/:.*//" < all | uniq | git check-attr --stdin --all | sort > actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'root subdir attribute test' '
attr_check a/i a/i &&
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 17/19] git-check-attr: Drive two tests using the same raw data
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (15 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 16/19] git-check-attr: Add an --all option to show all attributes Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 18/19] git-check-attr: Fix command-line handling to match docs Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 19/19] Rename struct git_attr_check to git_attr_value Michael Haggerty
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
t/t0003-attributes.sh | 59 +++++++++++++++++++-----------------------------
1 files changed, 23 insertions(+), 36 deletions(-)
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 8892ba3..a49f8a9 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -38,7 +38,25 @@ test_expect_success 'setup' '
) >a/b/.gitattributes &&
(
echo "global test=global"
- ) >"$HOME"/global-gitattributes
+ ) >"$HOME"/global-gitattributes &&
+ cat <<EOF >expect-all
+f: test: f
+a/f: test: f
+a/c/f: test: f
+a/g: test: a/g
+a/b/g: test: a/b/g
+b/g: test: unspecified
+a/b/h: test: a/b/h
+a/b/d/g: test: a/b/d/*
+onoff: test: unset
+offon: test: set
+no: notest: set
+no: test: unspecified
+a/b/d/no: notest: set
+a/b/d/no: test: a/b/d/*
+a/b/d/yes: notest: set
+a/b/d/yes: test: unspecified
+EOF
'
@@ -87,47 +105,16 @@ test_expect_success 'core.attributesfile' '
test_expect_success 'attribute test: read paths from stdin' '
- cat <<EOF > expect &&
-f: test: f
-a/f: test: f
-a/c/f: test: f
-a/g: test: a/g
-a/b/g: test: a/b/g
-b/g: test: unspecified
-a/b/h: test: a/b/h
-a/b/d/g: test: a/b/d/*
-onoff: test: unset
-offon: test: set
-no: test: unspecified
-a/b/d/no: test: a/b/d/*
-a/b/d/yes: test: unspecified
-EOF
-
+ grep -v notest < expect-all > expect &&
sed -e "s/:.*//" < expect | git check-attr --stdin test > actual &&
test_cmp expect actual
'
test_expect_success 'attribute test: --all option' '
- cat <<EOF > all &&
-f: test: f
-a/f: test: f
-a/c/f: test: f
-a/g: test: a/g
-a/b/g: test: a/b/g
-b/g: test: unspecified
-a/b/h: test: a/b/h
-a/b/d/g: test: a/b/d/*
-onoff: test: unset
-offon: test: set
-no: notest: set
-a/b/d/no: test: a/b/d/*
-a/b/d/no: notest: set
-a/b/d/yes: notest: set
-EOF
-
- grep -v unspecified < all | sort > expect &&
- sed -e "s/:.*//" < all | uniq | git check-attr --stdin --all | sort > actual &&
+ grep -v unspecified < expect-all | sort > expect &&
+ sed -e "s/:.*//" < expect-all | uniq |
+ git check-attr --stdin --all | sort > actual &&
test_cmp expect actual
'
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 18/19] git-check-attr: Fix command-line handling to match docs
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (16 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 17/19] git-check-attr: Drive two tests using the same raw data Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 19/19] Rename struct git_attr_check to git_attr_value Michael Haggerty
18 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
According to the git-check-attr synopsis, if the '--stdin' option is
used then no pathnames are expected on the command line. Change the
behavior to match this description; namely, if '--stdin' is used but
not '--', then treat all command-line arguments as attribute names.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
Documentation/git-check-attr.txt | 7 +++++--
builtin/check-attr.c | 15 +++++++++------
t/t0003-attributes.sh | 1 -
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/Documentation/git-check-attr.txt b/Documentation/git-check-attr.txt
index 798e5d5..1f7312a 100644
--- a/Documentation/git-check-attr.txt
+++ b/Documentation/git-check-attr.txt
@@ -33,8 +33,11 @@ OPTIONS
\--::
Interpret all preceding arguments as attributes and all following
- arguments as path names. If not supplied, only the first argument will
- be treated as an attribute.
+ arguments as path names.
+
+If none of `--stdin`, `--all`, or `--` is used, the first argument
+will be treated as an attribute and the rest of the arguments as
+pathnames.
OUTPUT
------
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 48834b4..9fe0b93 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -111,15 +111,18 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
} else if (doubledash == 0) {
error_with_usage("No attribute specified");
} else if (doubledash < 0) {
- /*
- * There is no double dash; treat the first
- * argument as an attribute.
- */
if (!argc)
error_with_usage("No attribute specified");
- cnt = 1;
- filei = 1;
+ if (stdin_paths) {
+ /* Treat all arguments as attribute names. */
+ cnt = argc;
+ filei = argc;
+ } else {
+ /* Treat exactly one argument as an attribute name. */
+ cnt = 1;
+ filei = 1;
+ }
} else {
cnt = doubledash;
filei = doubledash + 1;
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index a49f8a9..5acb2d5 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -70,7 +70,6 @@ test_expect_success 'command line checks' '
echo "f" | test_must_fail git check-attr --stdin &&
echo "f" | test_must_fail git check-attr --stdin -- f &&
echo "f" | test_must_fail git check-attr --stdin test -- f &&
- echo "f" | test_must_fail git check-attr --stdin test f &&
test_must_fail git check-attr "" -- f
'
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v2 19/19] Rename struct git_attr_check to git_attr_value
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
` (17 preceding siblings ...)
2011-07-28 4:46 ` [PATCH v2 18/19] git-check-attr: Fix command-line handling to match docs Michael Haggerty
@ 2011-07-28 4:46 ` Michael Haggerty
2011-08-02 15:46 ` Junio C Hamano
18 siblings, 1 reply; 24+ messages in thread
From: Michael Haggerty @ 2011-07-28 4:46 UTC (permalink / raw)
To: gitster; +Cc: git, Michael Haggerty
This described its purpose better, especially when used with
git_allattrs().
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
Documentation/technical/api-gitattributes.txt | 20 ++++++++++----------
archive.c | 4 ++--
attr.c | 8 ++++----
attr.h | 12 ++++++------
builtin/check-attr.c | 8 ++++----
builtin/pack-objects.c | 4 ++--
convert.c | 10 +++++-----
ll-merge.c | 6 +++---
userdiff.c | 2 +-
ws.c | 4 ++--
10 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/Documentation/technical/api-gitattributes.txt b/Documentation/technical/api-gitattributes.txt
index 640240e..c64969d 100644
--- a/Documentation/technical/api-gitattributes.txt
+++ b/Documentation/technical/api-gitattributes.txt
@@ -16,7 +16,7 @@ Data Structure
of no interest to the calling programs. The name of the
attribute can be retrieved by calling `git_attr_name()`.
-`struct git_attr_check`::
+`struct git_attr_value`::
This structure represents a set of attributes to check in a call
to `git_checkattr()` function, and receives the results.
@@ -27,7 +27,7 @@ Attribute Values
An attribute for a path can be in one of four states: Set, Unset,
Unspecified or set to a string, and `.value` member of `struct
-git_attr_check` records it. There are three macros to check these:
+git_attr_value` records it. There are three macros to check these:
`ATTR_TRUE()`::
@@ -48,13 +48,13 @@ value of the attribute for the path.
Querying Specific Attributes
----------------------------
-* Prepare an array of `struct git_attr_check` to define the list of
+* Prepare an array of `struct git_attr_value` to define the list of
attributes you would want to check. To populate this array, you would
need to define necessary attributes by calling `git_attr()` function.
* Call `git_checkattr()` to check the attributes for the path.
-* Inspect `git_attr_check` structure to see how each of the attribute in
+* Inspect `git_attr_value` structure to see how each of the attribute in
the array is defined for the path.
@@ -63,12 +63,12 @@ Example
To see how attributes "crlf" and "indent" are set for different paths.
-. Prepare an array of `struct git_attr_check` with two elements (because
+. Prepare an array of `struct git_attr_value` with two elements (because
we are checking two attributes). Initialize their `attr` member with
pointers to `struct git_attr` obtained by calling `git_attr()`:
------------
-static struct git_attr_check check[2];
+static struct git_attr_value check[2];
static void setup_check(void)
{
if (check[0].attr)
@@ -78,7 +78,7 @@ static void setup_check(void)
}
------------
-. Call `git_checkattr()` with the prepared array of `struct git_attr_check`:
+. Call `git_checkattr()` with the prepared array of `struct git_attr_value`:
------------
const char *path;
@@ -115,12 +115,12 @@ Querying All Attributes
To get the values of all attributes associated with a file:
-* Call `git_allattrs()`, which returns an array of `git_attr_check`
+* Call `git_allattrs()`, which returns an array of `git_attr_value`
structures.
-* Iterate over the `git_attr_check` array to examine the attribute
+* Iterate over the `git_attr_value` array to examine the attribute
names and values. The name of the attribute described by a
- `git_attr_check` object can be retrieved via
+ `git_attr_value` object can be retrieved via
`git_attr_name(check[i].attr)`. (Please note that no items will be
returned for unset attributes, so `ATTR_UNSET()` will return false
for all returned `git_array_check` objects.)
diff --git a/archive.c b/archive.c
index 2a7a28e..9a180b6 100644
--- a/archive.c
+++ b/archive.c
@@ -81,7 +81,7 @@ static void *sha1_file_to_archive(const char *path, const unsigned char *sha1,
return buffer;
}
-static void setup_archive_check(struct git_attr_check *check)
+static void setup_archive_check(struct git_attr_value *check)
{
static struct git_attr *attr_export_ignore;
static struct git_attr *attr_export_subst;
@@ -107,7 +107,7 @@ static int write_archive_entry(const unsigned char *sha1, const char *base,
struct archiver_context *c = context;
struct archiver_args *args = c->args;
write_archive_entry_fn_t write_entry = c->write_entry;
- struct git_attr_check check[2];
+ struct git_attr_value check[2];
const char *path_without_prefix;
int convert = 0;
int err;
diff --git a/attr.c b/attr.c
index 9c2fca8..d2a7727 100644
--- a/attr.c
+++ b/attr.c
@@ -33,7 +33,7 @@ struct git_attr {
};
static int attr_nr;
-static struct git_attr_check *check_all_attr;
+static struct git_attr_value *check_all_attr;
static struct git_attr *(git_attr_hash[HASHSIZE]);
char *git_attr_name(struct git_attr *attr)
@@ -646,7 +646,7 @@ static int macroexpand_one(int attr_nr, int rem);
static int fill_one(const char *what, struct match_attr *a, int rem)
{
- struct git_attr_check *check = check_all_attr;
+ struct git_attr_value *check = check_all_attr;
int i;
for (i = a->num_attr - 1; 0 < rem && 0 <= i; i--) {
@@ -706,7 +706,7 @@ static int macroexpand_one(int attr_nr, int rem)
return rem;
}
-int git_checkattr(const char *path, int num, struct git_attr_check *check)
+int git_checkattr(const char *path, int num, struct git_attr_value *check)
{
struct attr_stack *stk;
const char *cp;
@@ -737,7 +737,7 @@ int git_checkattr(const char *path, int num, struct git_attr_check *check)
return 0;
}
-int git_allattrs(const char *path, int *num, struct git_attr_check **check)
+int git_allattrs(const char *path, int *num, struct git_attr_value **check)
{
struct attr_stack *stk;
const char *cp;
diff --git a/attr.h b/attr.h
index 83202f0..4dc4db0 100644
--- a/attr.h
+++ b/attr.h
@@ -14,17 +14,17 @@ struct git_attr *git_attr(const char *);
extern const char git_attr__true[];
extern const char git_attr__false[];
-/* For public to check git_attr_check results */
+/* For public to check git_attr_value results */
#define ATTR_TRUE(v) ((v) == git_attr__true)
#define ATTR_FALSE(v) ((v) == git_attr__false)
#define ATTR_UNSET(v) ((v) == NULL)
/*
- * Send one or more git_attr_check to git_checkattr(), and
+ * Send one or more git_attr_value to git_checkattr(), and
* each 'value' member tells what its value is.
* Unset one is returned as NULL.
*/
-struct git_attr_check {
+struct git_attr_value {
struct git_attr *attr;
const char *value;
};
@@ -36,16 +36,16 @@ struct git_attr_check {
*/
char *git_attr_name(struct git_attr *);
-int git_checkattr(const char *path, int, struct git_attr_check *);
+int git_checkattr(const char *path, int, struct git_attr_value *);
/*
* Retrieve all attributes that apply to the specified path. *num
* will be set the the number of attributes on the path; **check will
- * be set to point at a newly-allocated array of git_attr_check
+ * be set to point at a newly-allocated array of git_attr_value
* objects describing the attributes and their values. *check must be
* free()ed by the caller.
*/
-int git_allattrs(const char *path, int *num, struct git_attr_check **check);
+int git_allattrs(const char *path, int *num, struct git_attr_value **check);
enum git_attr_direction {
GIT_ATTR_CHECKIN,
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 9fe0b93..781b7df 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -22,7 +22,7 @@ static const struct option check_attr_options[] = {
OPT_END()
};
-static void output_attr(int cnt, struct git_attr_check *check,
+static void output_attr(int cnt, struct git_attr_value *check,
const char *file)
{
int j;
@@ -41,7 +41,7 @@ static void output_attr(int cnt, struct git_attr_check *check,
}
}
-static void check_attr(int cnt, struct git_attr_check *check,
+static void check_attr(int cnt, struct git_attr_value *check,
const char *file)
{
if (check != NULL) {
@@ -56,7 +56,7 @@ static void check_attr(int cnt, struct git_attr_check *check,
}
}
-static void check_attr_stdin_paths(int cnt, struct git_attr_check *check)
+static void check_attr_stdin_paths(int cnt, struct git_attr_value *check)
{
struct strbuf buf, nbuf;
int line_termination = null_term_line ? 0 : '\n';
@@ -85,7 +85,7 @@ static NORETURN void error_with_usage(const char *msg)
int cmd_check_attr(int argc, const char **argv, const char *prefix)
{
- struct git_attr_check *check;
+ struct git_attr_value *check;
int cnt, i, doubledash, filei;
argc = parse_options(argc, argv, prefix, check_attr_options,
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 84e6daf..a0becea 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -619,7 +619,7 @@ static unsigned name_hash(const char *name)
return hash;
}
-static void setup_delta_attr_check(struct git_attr_check *check)
+static void setup_delta_attr_check(struct git_attr_value *check)
{
static struct git_attr *attr_delta;
@@ -631,7 +631,7 @@ static void setup_delta_attr_check(struct git_attr_check *check)
static int no_try_delta(const char *path)
{
- struct git_attr_check check[1];
+ struct git_attr_value check[1];
setup_delta_attr_check(check);
if (git_checkattr(path, ARRAY_SIZE(check), check))
diff --git a/convert.c b/convert.c
index 85939c2..ab582f8 100644
--- a/convert.c
+++ b/convert.c
@@ -641,7 +641,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
return 1;
}
-static int git_path_check_crlf(const char *path, struct git_attr_check *check)
+static int git_path_check_crlf(const char *path, struct git_attr_value *check)
{
const char *value = check->value;
@@ -658,7 +658,7 @@ static int git_path_check_crlf(const char *path, struct git_attr_check *check)
return CRLF_GUESS;
}
-static int git_path_check_eol(const char *path, struct git_attr_check *check)
+static int git_path_check_eol(const char *path, struct git_attr_value *check)
{
const char *value = check->value;
@@ -672,7 +672,7 @@ static int git_path_check_eol(const char *path, struct git_attr_check *check)
}
static struct convert_driver *git_path_check_convert(const char *path,
- struct git_attr_check *check)
+ struct git_attr_value *check)
{
const char *value = check->value;
struct convert_driver *drv;
@@ -685,7 +685,7 @@ static struct convert_driver *git_path_check_convert(const char *path,
return NULL;
}
-static int git_path_check_ident(const char *path, struct git_attr_check *check)
+static int git_path_check_ident(const char *path, struct git_attr_value *check)
{
const char *value = check->value;
@@ -718,7 +718,7 @@ static const char *conv_attr_name[] = {
static void convert_attrs(struct conv_attrs *ca, const char *path)
{
int i;
- static struct git_attr_check ccheck[NUM_CONV_ATTRS];
+ static struct git_attr_value ccheck[NUM_CONV_ATTRS];
if (!ccheck[0].attr) {
for (i = 0; i < NUM_CONV_ATTRS; i++)
diff --git a/ll-merge.c b/ll-merge.c
index 6ce512e..65f326e 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -324,7 +324,7 @@ static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr
return &ll_merge_drv[LL_TEXT_MERGE];
}
-static int git_path_check_merge(const char *path, struct git_attr_check check[2])
+static int git_path_check_merge(const char *path, struct git_attr_value check[2])
{
if (!check[0].attr) {
check[0].attr = git_attr("merge");
@@ -350,7 +350,7 @@ int ll_merge(mmbuffer_t *result_buf,
mmfile_t *theirs, const char *their_label,
const struct ll_merge_options *opts)
{
- static struct git_attr_check check[2];
+ static struct git_attr_value check[2];
static const struct ll_merge_options default_opts;
const char *ll_driver_name = NULL;
int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
@@ -382,7 +382,7 @@ int ll_merge(mmbuffer_t *result_buf,
int ll_merge_marker_size(const char *path)
{
- static struct git_attr_check check;
+ static struct git_attr_value check;
int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
if (!check.attr)
diff --git a/userdiff.c b/userdiff.c
index 01d3a8b..cde9537 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -262,7 +262,7 @@ struct userdiff_driver *userdiff_find_by_name(const char *name) {
struct userdiff_driver *userdiff_find_by_path(const char *path)
{
static struct git_attr *attr;
- struct git_attr_check check;
+ struct git_attr_value check;
if (!attr)
attr = git_attr("diff");
diff --git a/ws.c b/ws.c
index 9fb9b14..4a76ef8 100644
--- a/ws.c
+++ b/ws.c
@@ -74,7 +74,7 @@ unsigned parse_whitespace_rule(const char *string)
return rule;
}
-static void setup_whitespace_attr_check(struct git_attr_check *check)
+static void setup_whitespace_attr_check(struct git_attr_value *check)
{
static struct git_attr *attr_whitespace;
@@ -85,7 +85,7 @@ static void setup_whitespace_attr_check(struct git_attr_check *check)
unsigned whitespace_rule(const char *pathname)
{
- struct git_attr_check attr_whitespace_rule;
+ struct git_attr_value attr_whitespace_rule;
setup_whitespace_attr_check(&attr_whitespace_rule);
if (!git_checkattr(pathname, 1, &attr_whitespace_rule)) {
--
1.7.6.8.gd2879
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v2 09/19] Allow querying all attributes on a file
2011-07-28 4:46 ` [PATCH v2 09/19] Allow querying all attributes on a file Michael Haggerty
@ 2011-08-02 15:34 ` Junio C Hamano
2011-08-04 3:16 ` Michael Haggerty
0 siblings, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2011-08-02 15:34 UTC (permalink / raw)
To: Michael Haggerty; +Cc: git
Michael Haggerty <mhagger@alum.mit.edu> writes:
> Add a function, git_allattrs(), that reports on all attributes that
> are set on a path.
>
> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
> ---
> Documentation/technical/api-gitattributes.txt | 45 +++++++++++++++++-------
> attr.c | 43 +++++++++++++++++++++++
> attr.h | 9 +++++
> 3 files changed, 84 insertions(+), 13 deletions(-)
>
> diff --git a/Documentation/technical/api-gitattributes.txt b/Documentation/technical/api-gitattributes.txt
> index ab3a84d..640240e 100644
> --- a/Documentation/technical/api-gitattributes.txt
> +++ b/Documentation/technical/api-gitattributes.txt
> @@ -22,19 +22,6 @@ Data Structure
> ...
> (JC)
The last line, I think, can now be dropped. This was a marker saying "we
lack documentation for this API; bug this person for necessary information
and write one".
> diff --git a/attr.c b/attr.c
> index bfa1f43..9c2fca8 100644
> --- a/attr.c
> +++ b/attr.c
> @@ -737,6 +737,49 @@ int git_checkattr(const char *path, int num, struct git_attr_check *check)
> return 0;
> }
>
> +int git_allattrs(const char *path, int *num, struct git_attr_check **check)
> +{
> + struct attr_stack *stk;
> + const char *cp;
> + int dirlen, pathlen, i, rem, count, j;
> +
> + bootstrap_attr_stack();
> + for (i = 0; i < attr_nr; i++)
> + check_all_attr[i].value = ATTR__UNKNOWN;
> +
> + pathlen = strlen(path);
> + cp = strrchr(path, '/');
> + if (!cp)
> + dirlen = 0;
> + else
> + dirlen = cp - path;
> + prepare_attr_stack(path, dirlen);
> + rem = attr_nr;
> + for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)
> + rem = fill(path, pathlen, stk, rem);
Shouldn't the above part at least should be refactored instead of copied
and pasted from git_checkattr()?
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 19/19] Rename struct git_attr_check to git_attr_value
2011-07-28 4:46 ` [PATCH v2 19/19] Rename struct git_attr_check to git_attr_value Michael Haggerty
@ 2011-08-02 15:46 ` Junio C Hamano
2011-08-04 3:20 ` Michael Haggerty
0 siblings, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2011-08-02 15:46 UTC (permalink / raw)
To: Michael Haggerty; +Cc: git
Michael Haggerty <mhagger@alum.mit.edu> writes:
> This described its purpose better, especially when used with
> git_allattrs().
You probably meant s/described/describes/ but more importantly does it
really? It is a structure used to probe into the attributes system for the
state of various attributes on a path, and the set of possible states
includes "there is no value" (aka unset), so it feels actively wrong to
call it attr_value and that is why I didn't call it in the first place.
I also think git_all_attrs() (i.e. word-break underscore after "all") is
more in line with the naming throughout the codebase, after looking at
output from
$ git grep -e _all'[a-z]' --and --not -e alloc -e _all_ -- '*.c'
Other than these, and the earlier comment about the copy&paste done from
git_checkattr (which by the way should probably be "git_check_attr"), it
seems that the series mostly consist of good clean-ups and an addition of
a new and (probably) useful feature that is straightforward. Nice.
Thanks.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 09/19] Allow querying all attributes on a file
2011-08-02 15:34 ` Junio C Hamano
@ 2011-08-04 3:16 ` Michael Haggerty
0 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-08-04 3:16 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On 08/02/2011 05:34 PM, Junio C Hamano wrote:
> Michael Haggerty <mhagger@alum.mit.edu> writes:
>
>> Add a function, git_allattrs(), that reports on all attributes that
>> are set on a path.
>>
>> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
>> ---
>> Documentation/technical/api-gitattributes.txt | 45 +++++++++++++++++-------
>> attr.c | 43 +++++++++++++++++++++++
>> attr.h | 9 +++++
>> 3 files changed, 84 insertions(+), 13 deletions(-)
>>
>> diff --git a/Documentation/technical/api-gitattributes.txt b/Documentation/technical/api-gitattributes.txt
>> index ab3a84d..640240e 100644
>> --- a/Documentation/technical/api-gitattributes.txt
>> +++ b/Documentation/technical/api-gitattributes.txt
>> @@ -22,19 +22,6 @@ Data Structure
>> ...
>> (JC)
>
> The last line, I think, can now be dropped. This was a marker saying "we
> lack documentation for this API; bug this person for necessary information
> and write one".
OK; I will drop the line in the re-roll.
>> diff --git a/attr.c b/attr.c
>> index bfa1f43..9c2fca8 100644
>> --- a/attr.c
>> +++ b/attr.c
>> @@ -737,6 +737,49 @@ int git_checkattr(const char *path, int num, struct git_attr_check *check)
>> return 0;
>> }
>>
>> +int git_allattrs(const char *path, int *num, struct git_attr_check **check)
>> +{
>> + struct attr_stack *stk;
>> + const char *cp;
>> + int dirlen, pathlen, i, rem, count, j;
>> +
>> + bootstrap_attr_stack();
>> + for (i = 0; i < attr_nr; i++)
>> + check_all_attr[i].value = ATTR__UNKNOWN;
>> +
>> + pathlen = strlen(path);
>> + cp = strrchr(path, '/');
>> + if (!cp)
>> + dirlen = 0;
>> + else
>> + dirlen = cp - path;
>> + prepare_attr_stack(path, dirlen);
>> + rem = attr_nr;
>> + for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)
>> + rem = fill(path, pathlen, stk, rem);
>
> Shouldn't the above part at least should be refactored instead of copied
> and pasted from git_checkattr()?
Quite right. Will be fixed in re-roll.
Michael
--
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v2 19/19] Rename struct git_attr_check to git_attr_value
2011-08-02 15:46 ` Junio C Hamano
@ 2011-08-04 3:20 ` Michael Haggerty
0 siblings, 0 replies; 24+ messages in thread
From: Michael Haggerty @ 2011-08-04 3:20 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Thanks for the good feedback.
On 08/02/2011 05:46 PM, Junio C Hamano wrote:
> Michael Haggerty <mhagger@alum.mit.edu> writes:
>
>> This described its purpose better, especially when used with
>> git_allattrs().
>
> You probably meant s/described/describes/ but more importantly does it
> really? It is a structure used to probe into the attributes system for the
> state of various attributes on a path, and the set of possible states
> includes "there is no value" (aka unset), so it feels actively wrong to
> call it attr_value and that is why I didn't call it in the first place.
I don't think it is so unusual for a "value" object to be able to
reflect the fact that the value is unset, but I can understand your
point of view too. I will omit this renaming in the re-roll.
> I also think git_all_attrs() (i.e. word-break underscore after "all") is
> more in line with the naming throughout the codebase, after looking at
> output from
>
> $ git grep -e _all'[a-z]' --and --not -e alloc -e _all_ -- '*.c'
>
> Other than these, and the earlier comment about the copy&paste done from
> git_checkattr (which by the way should probably be "git_check_attr"), it
> seems that the series mostly consist of good clean-ups and an addition of
> a new and (probably) useful feature that is straightforward. Nice.
I thought the name was awkward, too, but I chose it to be consistent
with git_checkattr(). So in the re-roll I will happily rename both
functions.
Michael
--
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2011-08-04 3:20 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-28 4:46 [PATCH v2 00/19] Add --all option to git-check-attr Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 01/19] doc: Add a link from gitattributes(5) to git-check-attr(1) Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 02/19] doc: Correct git_attr() calls in example code Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 03/19] Remove anachronism from comment Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 04/19] Disallow the empty string as an attribute name Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 05/19] git-check-attr: Add missing "&&" Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 06/19] git-check-attr: Add tests of command-line parsing Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 07/19] Provide access to the name attribute of git_attr Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 08/19] git-check-attr: Use git_attr_name() Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 09/19] Allow querying all attributes on a file Michael Haggerty
2011-08-02 15:34 ` Junio C Hamano
2011-08-04 3:16 ` Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 10/19] git-check-attr: Extract a function output_attr() Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 11/19] git-check-attr: Introduce a new variable Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 12/19] git-check-attr: Extract a function error_with_usage() Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 13/19] git-check-attr: Handle each error separately Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 14/19] git-check-attr: Process command-line args more systematically Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 15/19] git-check-attr: Error out if no pathnames are specified Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 16/19] git-check-attr: Add an --all option to show all attributes Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 17/19] git-check-attr: Drive two tests using the same raw data Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 18/19] git-check-attr: Fix command-line handling to match docs Michael Haggerty
2011-07-28 4:46 ` [PATCH v2 19/19] Rename struct git_attr_check to git_attr_value Michael Haggerty
2011-08-02 15:46 ` Junio C Hamano
2011-08-04 3:20 ` Michael Haggerty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).