diff options
Diffstat (limited to 'Documentation/gitattributes.txt')
-rw-r--r-- | Documentation/gitattributes.txt | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt index ba02d4de59..643c1ba929 100644 --- a/Documentation/gitattributes.txt +++ b/Documentation/gitattributes.txt @@ -56,8 +56,9 @@ When more than one pattern matches the path, a later line overrides an earlier line. This overriding is done per attribute. The rules how the pattern matches paths are the same as in `.gitignore` files; see linkgit:gitignore[5]. +Unlike `.gitignore`, negative patterns are forbidden. -When deciding what attributes are assigned to a path, git +When deciding what attributes are assigned to a path, Git consults `$GIT_DIR/info/attributes` file (which has the highest precedence), `.gitattributes` file in the same directory as the path in question, and its parent directories up to the toplevel of the @@ -93,7 +94,7 @@ the name of the attribute prefixed with an exclamation point `!`. EFFECTS ------- -Certain operations by git can be influenced by assigning +Certain operations by Git can be influenced by assigning particular attributes to a path. Currently, the following operations are attributes-aware. @@ -103,7 +104,7 @@ Checking-out and checking-in These attributes affect how the contents stored in the repository are copied to the working tree files when commands such as 'git checkout' and 'git merge' run. They also affect how -git stores the contents you prepare in the working tree in the +Git stores the contents you prepare in the working tree in the repository upon 'git add' and 'git commit'. `text` @@ -123,22 +124,22 @@ Set:: Unset:: - Unsetting the `text` attribute on a path tells git not to + Unsetting the `text` attribute on a path tells Git not to attempt any end-of-line conversion upon checkin or checkout. Set to string value "auto":: When `text` is set to "auto", the path is marked for automatic - end-of-line normalization. If git decides that the content is + end-of-line normalization. If Git decides that the content is text, its line endings are normalized to LF on checkin. Unspecified:: - If the `text` attribute is unspecified, git uses the + If the `text` attribute is unspecified, Git uses the `core.autocrlf` configuration variable to determine if the file should be converted. -Any other value causes git to act as if `text` has been left +Any other value causes Git to act as if `text` has been left unspecified. `eol` @@ -150,13 +151,13 @@ content checks, effectively setting the `text` attribute. Set to string value "crlf":: - This setting forces git to normalize line endings for this + This setting forces Git to normalize line endings for this file on checkin and convert them to CRLF when the file is checked out. Set to string value "lf":: - This setting forces git to normalize line endings to LF on + This setting forces Git to normalize line endings to LF on checkin and prevents conversion to CRLF when the file is checked out. @@ -175,11 +176,11 @@ crlf=input eol=lf End-of-line conversion ^^^^^^^^^^^^^^^^^^^^^^ -While git normally leaves file contents alone, it can be configured to +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. -Here is an example that will make git normalize .txt, .vcproj and .sh +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. @@ -193,7 +194,7 @@ regardless of their content. Other source code management systems normalize all text files in their repositories, and there are two ways to enable similar automatic -normalization in git. +normalization in Git. 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 @@ -218,9 +219,9 @@ attribute to "auto" for _all_ files. * text=auto ------------------------ -This ensures that all files that git considers to be text will have +This ensures that all files that Git considers to be text will have normalized (LF) line endings in the repository. The `core.eol` -configuration variable controls which line endings git will use for +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 `core.autocrlf` is set. @@ -233,7 +234,7 @@ directory: ------------------------------------------------- $ echo "* text=auto" >>.gitattributes -$ rm .git/index # Remove the index to force git to +$ 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 @@ -248,17 +249,17 @@ unset their `text` attribute before running 'git add -u'. manual.pdf -text ------------------------ -Conversely, text files that git does not detect can have normalization +Conversely, text files that Git does not detect can have normalization enabled manually. ------------------------ weirdchars.txt text ------------------------ -If `core.safecrlf` is set to "true" or "warn", git verifies if +If `core.safecrlf` is set to "true" or "warn", Git verifies if the conversion is reversible for the current setting of -`core.autocrlf`. For "true", git rejects irreversible -conversions; for "warn", git only prints a warning but accepts +`core.autocrlf`. For "true", Git rejects irreversible +conversions; for "warn", Git only prints a warning but accepts an irreversible conversion. The safety triggers to prevent such a conversion done to the files in the work tree, but there are a few exceptions. Even though... @@ -279,7 +280,7 @@ few exceptions. Even though... `ident` ^^^^^^^ -When the attribute `ident` is set for a path, git replaces +When the attribute `ident` is set for a path, Git replaces `$Id$` in the blob object with `$Id:`, followed by the 40-character hexadecimal blob object name, followed by a dollar sign `$` upon checkout. Any byte sequence that begins with @@ -310,7 +311,7 @@ the appropriate filter program, the project should still be usable. Another use of the content filtering is to store the content that cannot be directly used in the repository (e.g. a UUID that refers to the true -content stored outside git, or an encrypted content) and turn it into a +content stored outside Git, or an encrypted content) and turn it into a usable form upon checkout (e.g. download the external content, or decrypt the encrypted content). @@ -396,7 +397,7 @@ clean/smudge filter or text/eol/ident attributes, merging anything where the attribute is not in place would normally cause merge conflicts. -To prevent these unnecessary merge conflicts, git can be told to run a +To prevent these unnecessary merge conflicts, Git can be told to run a virtual check-out and check-in of all three stages of a file when resolving a three-way merge by setting the `merge.renormalize` configuration variable. This prevents changes caused by check-in @@ -416,11 +417,11 @@ Generating diff text `diff` ^^^^^^ -The attribute `diff` affects how 'git' generates diffs for particular -files. It can tell git whether to generate a textual patch for the path +The attribute `diff` affects how Git generates diffs for particular +files. It can tell Git whether to generate a textual patch for the path or to treat the path as a binary file. It can also affect what line is -shown on the hunk header `@@ -k,l +n,m @@` line, tell git to use an -external command to generate the diff, or ask git to convert binary +shown on the hunk header `@@ -k,l +n,m @@` line, tell Git to use an +external command to generate the diff, or ask Git to convert binary files to a text format before generating the diff. Set:: @@ -448,7 +449,7 @@ String:: specify one or more options, as described in the following section. The options for the diff driver "foo" are defined by the configuration variables in the "diff.foo" section of the - git config file. + Git config file. Defining an external diff driver @@ -466,7 +467,7 @@ To define an external diff driver `jcdiff`, add a section to your command = j-c-diff ---------------------------------------------------------------- -When git needs to show you a diff for the path with `diff` +When Git needs to show you a diff for the path with `diff` attribute set to `jcdiff`, it calls the command you specified with the above configuration, i.e. `j-c-diff`, with 7 parameters, just like `GIT_EXTERNAL_DIFF` program is called. @@ -605,7 +606,7 @@ should generate it separately and send it as a comment _in addition to_ the usual binary diff that you might send. Because text conversion can be slow, especially when doing a -large number of them with `git log -p`, git provides a mechanism +large number of them with `git log -p`, Git provides a mechanism to cache the output and use it in future diffs. To enable caching, set the "cachetextconv" variable in your diff driver's config. For example: @@ -618,7 +619,7 @@ config. For example: This will cache the result of running "exif" on each blob indefinitely. If you change the textconv config variable for a -diff driver, git will automatically invalidate the cache entries +diff driver, Git will automatically invalidate the cache entries and re-run the textconv filter. If you want to invalidate the cache manually (e.g., because your version of "exif" was updated and now produces better output), you can remove the cache @@ -639,7 +640,7 @@ output to resemble unified diff. You are free to locate and report changes in the most appropriate way for your data format. A textconv, by comparison, is much more limiting. You provide a -transformation of the data into a line-oriented text format, and git +transformation of the data into a line-oriented text format, and Git uses its regular diff tools to generate the output. There are several advantages to choosing this method: @@ -649,7 +650,7 @@ advantages to choosing this method: odt2txt). 2. Git diff features. By performing only the transformation step - yourself, you can still utilize many of git's diff features, + yourself, you can still utilize many of Git's diff features, including colorization, word-diff, and combined diffs for merges. 3. Caching. Textconv caching can speed up repeated diffs, such as those @@ -674,7 +675,7 @@ attribute in the `.gitattributes` file: *.ps -diff ------------------------ -This will cause git to generate `Binary files differ` (or a binary +This will cause Git to generate `Binary files differ` (or a binary patch, if binary patches are enabled) instead of a regular diff. However, one may also want to specify other diff driver attributes. For @@ -830,7 +831,7 @@ control per path. Set:: - Notice all types of potential whitespace errors known to git. + Notice all types of potential whitespace errors known to Git. The tab width is taken from the value of the `core.whitespace` configuration variable. @@ -862,7 +863,7 @@ archive files. `export-subst` ^^^^^^^^^^^^^^ -If the attribute `export-subst` is set for a file then git will expand +If the attribute `export-subst` is set for a file then Git will expand several placeholders when adding this file to an archive. The expansion depends on the availability of a commit ID, i.e., if linkgit:git-archive[1] has been given a tree instead of a commit or a @@ -929,9 +930,12 @@ state. DEFINING MACRO ATTRIBUTES ------------------------- -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: +Custom macro attributes can be defined only in top-level gitattributes +files (`$GIT_DIR/info/attributes`, the `.gitattributes` file at the +top level of the working tree, or the global or system-wide +gitattributes files), not in `.gitattributes` files in working tree +subdirectories. The built-in macro attribute "binary" is equivalent +to: ------------ [attr]binary -diff -merge -text @@ -960,7 +964,7 @@ abc -foo -bar the attributes given to path `t/abc` are computed as follows: 1. By examining `t/.gitattributes` (which is in the same - directory as the path in question), git finds that the first + directory as the path in question), Git finds that the first line matches. `merge` attribute is set. It also finds that the second line matches, and attributes `foo` and `bar` are unset. |