threads / patch / 28008

patch, 2 partsClarify semantics of git attribute macros

Subject: [PATCH 0/2] Clarify semantics of git attribute macros

## tl;dr

7 messages between Aug 3, 2011 and Aug 3, 2011. Diffs are folded; open one to read it.

replies: 6people: 4as markdown or json

Michael Haggerty· Aug 3, 2011, 13:41 UTC · lore

Make it clearer that attribute macros do not only affect other attributes, but are attributes themselves.

The second patch changes the nomenclature in gitattributes(5) from "attribute macro" to "macro attribute", which I think makes the point a tiny bit clearer. But it is definitely optional.

Michael Haggerty (2):
  gitattributes: Clarify discussion of attribute macros
  gitattributes: Reword "attribute macro" to "macro attribute"
 Documentation/gitattributes.txt |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)
-- 
1.7.6.8.gd2879
Michael Haggerty· Aug 3, 2011, 13:41 UTC · re: Michael Haggerty · lore

[PATCH 1/2] gitattributes: Clarify discussion of attribute macros

In particular, make it clear that attribute macros are themselves recorded as attributes in addition to setting other attributes.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 Documentation/gitattributes.txt |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
Show changes to Documentation/gitattributes.txt +8 −5
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 412c55b..ccb3f3f 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -879,16 +879,19 @@ produced for, any binary file you track.  You would need to specify e.g.
 ------------
 
 but that may become cumbersome, when you have many attributes.  Using
-attribute macros, you can specify groups of attributes set or unset at
-the same time.  The system knows a built-in attribute macro, `binary`:
+attribute macros, you can define an attribute that, when set, also
+sets or unsets a number of other attributes at the same time.  The
+system knows a built-in attribute macro, `binary`:
 
 ------------
 *.jpg binary
 ------------
 
-which is equivalent to the above.  Note that the attribute macros can only
-be "Set" (see the above example that sets "binary" macro as if it were an
-ordinary attribute --- setting it in turn unsets "text" and "diff").
+Setting the "binary" attribute also unsets the "text" and "diff"
+attributes as above.  Note that attribute macros can only be "Set",
+though setting one might have the effect of setting or unsetting other
+attributes or even returning other attributes to the "Unspecified"
+state.
 
 
 DEFINING ATTRIBUTE MACROS
-- 
1.7.6.8.gd2879
Jeff King· Aug 3, 2011, 19:46 UTC · re: Michael Haggerty · lore

Re: [PATCH 1/2] gitattributes: Clarify discussion of attribute macros

On Wed, Aug 03, 2011 at 03:41:29PM +0200, Michael Haggerty wrote:
Show 8 quoted lines
> -which is equivalent to the above.  Note that the attribute macros can only
> -be "Set" (see the above example that sets "binary" macro as if it were an
> -ordinary attribute --- setting it in turn unsets "text" and "diff").
> +Setting the "binary" attribute also unsets the "text" and "diff"
> +attributes as above.  Note that attribute macros can only be "Set",
> +though setting one might have the effect of setting or unsetting other
> +attributes or even returning other attributes to the "Unspecified"
> +state.

This is slightly confusing. You can "unset" an attribute macro, and it will be reported as "unset". Which seems to contradict what is written above (although the error comes from the previous text). I think there are two possibilities for what a user might expect unsetting a macro to do for the sub-attributes:

  1. Leave them unspecified.
  2. Negate them (i.e., "-binary" means "text diff".
and we do (1).

I don't know if that was intentional, or if the behavior is simply accidental and the original code was simply never meant to have "-binary" called at all.

-Peff
Junio C Hamano· Aug 3, 2011, 21:40 UTC · re: Jeff King · lore

Re: [PATCH 1/2] gitattributes: Clarify discussion of attribute macros

Jeff King <peff@peff.net> writes:
> I don't know if that was intentional, or if the behavior is simply
> accidental and the original code was simply never meant to have
> "-binary" called at all.
The latter. You were never expected to say -macro at all.
Jeff King· Aug 3, 2011, 22:40 UTC · re: Junio C Hamano · lore

Re: [PATCH 1/2] gitattributes: Clarify discussion of attribute macros

On Wed, Aug 03, 2011 at 02:40:19PM -0700, Junio C Hamano wrote:
Show 7 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > I don't know if that was intentional, or if the behavior is simply
> > accidental and the original code was simply never meant to have
> > "-binary" called at all.
> 
> The latter. You were never expected to say -macro at all.

OK. Maybe we should flag an error, then? Or if not, then make the documentation more clear that it's not allowed (or even say the current behavior is reasonable, and document it).

-Peff
Michael Haggerty· Aug 3, 2011, 13:41 UTC · re: Michael Haggerty · lore

[PATCH 2/2] gitattributes: Reword "attribute macro" to "macro attribute"

The new wording makes it clearer that such a beast is an attribute in addition to being a macro (as opposed to being only a macro that is used for attributes).

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 Documentation/gitattributes.txt |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
Show changes to Documentation/gitattributes.txt +9 −9
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index ccb3f3f..2bbe76b 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -79,7 +79,7 @@ Attributes for all users on a system should be placed in the
 `$(prefix)/etc/gitattributes` file.
 
 Sometimes you would need to override an setting of an attribute
-for a path to `unspecified` state.  This can be done by listing
+for a path to `Unspecified` state.  This can be done by listing
 the name of the attribute prefixed with an exclamation point `!`.
 
 
@@ -868,7 +868,7 @@ If this attribute is not set or has an invalid value, the value of the
 (See linkgit:git-config[1]).
 
 
-USING ATTRIBUTE MACROS
+USING MACRO ATTRIBUTES
 ----------------------
 
 You do not want any end-of-line conversions applied to, nor textual diffs
@@ -879,27 +879,27 @@ produced for, any binary file you track.  You would need to specify e.g.
 ------------
 
 but that may become cumbersome, when you have many attributes.  Using
-attribute macros, you can define an attribute that, when set, also
+macro attributes, you can define an attribute that, when set, also
 sets or unsets a number of other attributes at the same time.  The
-system knows a built-in attribute macro, `binary`:
+system knows a built-in macro attribute, `binary`:
 
 ------------
 *.jpg binary
 ------------
 
 Setting the "binary" attribute also unsets the "text" and "diff"
-attributes as above.  Note that attribute macros can only be "Set",
+attributes as above.  Note that macro attributes can only be "Set",
 though setting one might have the effect of setting or unsetting other
 attributes or even returning other attributes to the "Unspecified"
 state.
 
 
-DEFINING ATTRIBUTE MACROS
+DEFINING MACRO ATTRIBUTES
 -------------------------
 
-Custom attribute macros can be defined only in the `.gitattributes` file
-at the toplevel (i.e. not in any subdirectory).  The built-in attribute
-macro "binary" is equivalent to:
+Custom macro attributes can be defined only in the `.gitattributes`
+file at the toplevel (i.e. not in any subdirectory).  The built-in
+macro attribute "binary" is equivalent to:
 
 ------------
 [attr]binary -diff -text
-- 
1.7.6.8.gd2879
Philip Oakley· Aug 3, 2011, 21:34 UTC · re: Michael Haggerty · lore

Re: [PATCH 0/2] Clarify semantics of git attribute macros

From: "Michael Haggerty"
> Make it clearer that attribute macros do not only affect other
> attributes, but are attributes themselves.

I felt that this summary was the better wording. It is simple and direct. i.e. "Note: Attribute macros not only affect attributes, but are attributes themselves."

Philip Oakley Scotland

← back to recent threads