git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] diff: treat -crlf files as binary

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 30, 2008, 21:34 UTC
Message-ID
<7vljyefaps.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<32541b130808291456k3de953a2yd1e93bc27ad14293@mail.gmail.com>
"Avery Pennarun" <apenwarr@gmail.com> writes:
> I think the bug is that "crlf=false" should not be considered the same
> as "binary=true", which seems to be a bug in the documentation, not
> the program.
Yeah, that's right.  How about doing something like this?
 Documentation/gitattributes.txt |   39 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 36 insertions(+), 3 deletions(-)
diff --git i/Documentation/gitattributes.txt w/Documentation/gitattributes.txt
index db16b0c..ec8a860 100644
--- i/Documentation/gitattributes.txt
+++ w/Documentation/gitattributes.txt
@@ -105,9 +105,8 @@ Set::
 
 Unset::
 
-	Unsetting the `crlf` attribute on a path is meant to
-	mark the path as a "binary" file.  The path never goes
-	through line endings conversion upon checkin/checkout.
+	Unsetting the `crlf` attribute on a path is tells git
+	not to attempt any end-of-line conversion  upon checkin/checkout.
 
 Unspecified::
 
@@ -482,6 +481,40 @@ in the file.  E.g. the string `$Format:%H$` will be replaced by the
 commit hash.
 
 
+USING ATTRIBUTE MACROS
+----------------------
+
+You do not want any end-of-line conversions applied to, nor textual diffs
+produced for any binary file you track.  You would need to specify e.g.
+
+------------
+*.jpg -crlf -diff
+------------
+
+but that is cumbersome.  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`:
+
+------------
+*.jpg binary
+------------
+
+which is equivalent to the above.  Note that the attribute macros can only
+be "Set" (see the above example).
+
+
+DEFINING ATTRIBUTE MACROS
+-------------------------
+
+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:
+
+------------
+[attr]binary -diff -crlf
+------------
+
+
 EXAMPLE
 -------
 
Previous: Avery PennarunNext: Avery Pennarun
Message 3 of 8 in “diff: treat -crlf files as binary”
  1. diff: treat -crlf files as binaryJunio C Hamano, Aug 29, 2008
  2. Avery PennarunAug 29, 2008
  3. Junio C HamanoAug 30, 2008
  4. Avery PennarunAug 31, 2008
  5. Matthieu MoyAug 31, 2008
  6. Alex RiesenAug 31, 2008
  7. Junio C HamanoAug 31, 2008
  8. Avery PennarunAug 31, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.