summaryrefslogtreecommitdiffstats
path: root/gitattributes.html
diff options
context:
space:
mode:
authorJunio C Hamano <junio@kernel.org>2010-06-21 15:23:55 +0000
committerJunio C Hamano <junio@kernel.org>2010-06-21 15:23:55 +0000
commitbb88cf46ef8a2521a253db9ab576e12202a54fa5 (patch)
treebbc5092df07bff8072a1d42a422ab68b4dbd7aac /gitattributes.html
parentf5de4cf4e1e8bccd17515d71186e752f4716cac9 (diff)
downloadgit-htmldocs-bb88cf46ef8a2521a253db9ab576e12202a54fa5.tar.gz
Autogenerated HTML docs for v1.7.1-524-g6df2
Diffstat (limited to 'gitattributes.html')
-rw-r--r--gitattributes.html170
1 files changed, 138 insertions, 32 deletions
diff --git a/gitattributes.html b/gitattributes.html
index 761528f41..e5abf0c9b 100644
--- a/gitattributes.html
+++ b/gitattributes.html
@@ -410,18 +410,21 @@ repository are copied to the working tree files when commands
such as <em>git checkout</em> and <em>git merge</em> run. They also affect how
git stores the contents you prepare in the working tree in the
repository upon <em>git add</em> and <em>git commit</em>.</p></div>
-<h4 id="_tt_crlf_tt"><tt>crlf</tt></h4>
-<div class="para"><p>This attribute controls the line-ending convention.</p></div>
+<h4 id="_tt_text_tt"><tt>text</tt></h4>
+<div class="para"><p>This attribute enables and controls end-of-line normalization. When a
+text file is normalized, its line endings are converted to LF in the
+repository. To control what line ending style is used in the working
+directory, use the <tt>eol</tt> attribute for a single file and the
+<tt>core.eol</tt> configuration variable for all text files.</p></div>
<div class="vlist"><dl>
<dt>
Set
</dt>
<dd>
<p>
- Setting the <tt>crlf</tt> attribute on a path is meant to mark
- the path as a "text" file. <em>core.autocrlf</em> conversion
- takes place without guessing the content type by
- inspection.
+ Setting the <tt>text</tt> attribute on a path enables end-of-line
+ normalization and marks the path as a text file. End-of-line
+ conversion takes place without guessing the content type.
</p>
</dd>
<dt>
@@ -429,43 +432,146 @@ Unset
</dt>
<dd>
<p>
- Unsetting the <tt>crlf</tt> attribute on a path tells git not to
+ Unsetting the <tt>text</tt> attribute on a path tells git not to
attempt any end-of-line conversion upon checkin or checkout.
</p>
</dd>
<dt>
+Set to string value "auto"
+</dt>
+<dd>
+<p>
+ When <tt>text</tt> is set to "auto", the path is marked for automatic
+ end-of-line normalization. If git decides that the content is
+ text, its line endings are normalized to LF on checkin.
+</p>
+</dd>
+<dt>
Unspecified
</dt>
<dd>
<p>
- Unspecified <tt>crlf</tt> attribute tells git to apply the
- <tt>core.autocrlf</tt> conversion when the file content looks
- like text.
+ If the <tt>text</tt> attribute is unspecified, git uses the
+ <tt>core.autocrlf</tt> configuration variable to determine if the
+ file should be converted.
</p>
</dd>
+</dl></div>
+<div class="para"><p>Any other value causes git to act as if <tt>text</tt> has been left
+unspecified.</p></div>
+<h4 id="_tt_eol_tt"><tt>eol</tt></h4>
+<div class="para"><p>This attribute sets a specific line-ending style to be used in the
+working directory. It enables end-of-line normalization without any
+content checks, effectively setting the <tt>text</tt> attribute.</p></div>
+<div class="vlist"><dl>
<dt>
-Set to string value "input"
+Set to string value "crlf"
</dt>
<dd>
<p>
- This is similar to setting the attribute to <tt>true</tt>, but
- also forces git to act as if <tt>core.autocrlf</tt> is set to
- <tt>input</tt> for the path.
+ This setting forces git to normalize line endings for this
+ file on checkin and convert them to CRLF when the file is
+ checked out.
+</p>
+</dd>
+<dt>
+Set to string value "lf"
+</dt>
+<dd>
+<p>
+ This setting forces git to normalize line endings to LF on
+ checkin and prevents conversion to CRLF when the file is
+ checked out.
</p>
</dd>
</dl></div>
-<div class="para"><p>Any other value set to <tt>crlf</tt> attribute is ignored and git acts
-as if the attribute is left unspecified.</p></div>
-<h4 id="_the_tt_core_autocrlf_tt_conversion">The <tt>core.autocrlf</tt> conversion</h4>
-<div class="para"><p>If the configuration variable <tt>core.autocrlf</tt> is false, no
-conversion is done.</p></div>
-<div class="para"><p>When <tt>core.autocrlf</tt> is true, it means that the platform wants
-CRLF line endings for files in the working tree, and you want to
-convert them back to the normal LF line endings when checking
-in to the repository.</p></div>
-<div class="para"><p>When <tt>core.autocrlf</tt> is set to "input", line endings are
-converted to LF upon checkin, but there is no conversion done
-upon checkout.</p></div>
+<h4 id="_backwards_compatibility_with_tt_crlf_tt_attribute">Backwards compatibility with <tt>crlf</tt> attribute</h4>
+<div class="para"><p>For backwards compatibility, the <tt>crlf</tt> attribute is interpreted as
+follows:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>crlf text
+-crlf -text
+crlf=input eol=lf</tt></pre>
+</div></div>
+<h4 id="_end_of_line_conversion">End-of-line conversion</h4>
+<div class="para"><p>While git normally leaves file contents alone, it can be configured to
+normalize line endings to LF in the repository and, optionally, to
+convert them to CRLF when files are checked out.</p></div>
+<div class="para"><p>Here is an example that will make git normalize .txt, .vcproj and .sh
+files, ensure that .vcproj files have CRLF and .sh files have LF in
+the working directory, and prevent .jpg files from being normalized
+regardless of their content.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>*.txt text
+*.vcproj eol=crlf
+*.sh eol=lf
+*.jpg -text</tt></pre>
+</div></div>
+<div class="para"><p>Other source code management systems normalize all text files in their
+repositories, and there are two ways to enable similar automatic
+normalization in git.</p></div>
+<div class="para"><p>If you simply want to have CRLF line endings in your working directory
+regardless of the repository you are working with, you can set the
+config variable "core.autocrlf" without changing any attributes.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>[core]
+ autocrlf = true</tt></pre>
+</div></div>
+<div class="para"><p>This does not force normalization of all text files, but does ensure
+that text files that you introduce to the repository have their line
+endings normalized to LF when they are added, and that files that are
+already normalized in the repository stay normalized.</p></div>
+<div class="para"><p>If you want to interoperate with a source code management system that
+enforces end-of-line normalization, or you simply want all text files
+in your repository to be normalized, you should instead set the <tt>text</tt>
+attribute to "auto" for _all_ files.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>* text=auto</tt></pre>
+</div></div>
+<div class="para"><p>This ensures that all files that git considers to be text will have
+normalized (LF) line endings in the repository. The <tt>core.eol</tt>
+configuration variable controls which line endings git will use for
+normalized files in your working directory; the default is to use the
+native line ending for your platform, or CRLF if <tt>core.autocrlf</tt> is
+set.</p></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">When <tt>text=auto</tt> normalization is enabled in an existing
+repository, any text files containing CRLFs should be normalized. If
+they are not they will be normalized the next time someone tries to
+change them, causing unfortunate misattribution. From a clean working
+directory:</td>
+</tr></table>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>$ echo "* text=auto" &gt;&gt;.gitattributes
+$ rm .git/index # Remove the index to force git to
+$ git reset # re-scan the working directory
+$ git status # Show files that will be normalized
+$ git add -u
+$ git add .gitattributes
+$ git commit -m "Introduce end-of-line normalization"</tt></pre>
+</div></div>
+<div class="para"><p>If any files that should not be normalized show up in <em>git status</em>,
+unset their <tt>text</tt> attribute before running <em>git add -u</em>.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>manual.pdf -text</tt></pre>
+</div></div>
+<div class="para"><p>Conversely, text files that git does not detect can have normalization
+enabled manually.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>weirdchars.txt text</tt></pre>
+</div></div>
<div class="para"><p>If <tt>core.safecrlf</tt> is set to "true" or "warn", git verifies if
the conversion is reversible for the current setting of
<tt>core.autocrlf</tt>. For "true", git rejects irreversible
@@ -543,10 +649,10 @@ command is "cat").</p></div>
<div class="para"><p>In the check-in codepath, the worktree file is first converted
with <tt>filter</tt> driver (if specified and corresponding driver
defined), then the result is processed with <tt>ident</tt> (if
-specified), and then finally with <tt>crlf</tt> (again, if specified
+specified), and then finally with <tt>text</tt> (again, if specified
and applicable).</p></div>
<div class="para"><p>In the check-out codepath, the blob content is first converted
-with <tt>crlf</tt>, and then <tt>ident</tt> and fed to <tt>filter</tt>.</p></div>
+with <tt>text</tt>, and then <tt>ident</tt> and fed to <tt>filter</tt>.</p></div>
<h3 id="_generating_diff_text">Generating diff text</h3><div style="clear:left"></div>
<h4 id="_tt_diff_tt"><tt>diff</tt></h4>
<div class="para"><p>The attribute <tt>diff</tt> affects how <em>git</em> generates diffs for particular
@@ -991,7 +1097,7 @@ manually enable per-file encodings in its options.</p></div>
produced for, any binary file you track. You would need to specify e.g.</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>*.jpg -crlf -diff</tt></pre>
+<pre><tt>*.jpg -text -diff</tt></pre>
</div></div>
<div class="para"><p>but that may become cumbersome, when you have many attributes. Using
attribute macros, you can specify groups of attributes set or unset at
@@ -1002,7 +1108,7 @@ the same time. The system knows a built-in attribute macro, <tt>binary</tt>:</p
</div></div>
<div class="para"><p>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 "crlf" and "diff").</p></div>
+ordinary attribute --- setting it in turn unsets "text" and "diff").</p></div>
</div>
<h2 id="_defining_attribute_macros">DEFINING ATTRIBUTE MACROS</h2>
<div class="sectionbody">
@@ -1011,7 +1117,7 @@ at the toplevel (i.e. not in any subdirectory). The built-in attribute
macro "binary" is equivalent to:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>[attr]binary -diff -crlf</tt></pre>
+<pre><tt>[attr]binary -diff -text</tt></pre>
</div></div>
</div>
<h2 id="_example">EXAMPLE</h2>
@@ -1076,7 +1182,7 @@ frotz unspecified</tt></pre>
</div>
<div id="footer">
<div id="footer-text">
-Last updated 2010-05-21 14:57:20 UTC
+Last updated 2010-06-21 15:23:42 UTC
</div>
</div>
</body>