Skip to content

Commit a07157a

Browse files
author
Junio C Hamano
committed
Merge branch 'jc/attr'
* jc/attr: Add 'filter' attribute and external filter driver definition. Add 'ident' conversion.
2 parents 96651ef + aa4ed40 commit a07157a

File tree

3 files changed

+531
-12
lines changed

3 files changed

+531
-12
lines changed

Documentation/gitattributes.txt

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,17 @@ are attributes-aware.
7878
Checking-out and checking-in
7979
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8080

81-
The attribute `crlf` affects how the contents stored in the
81+
These attributes affect how the contents stored in the
8282
repository are copied to the working tree files when commands
83-
such as `git checkout` and `git merge` run. It also affects how
83+
such as `git checkout` and `git merge` run. They also affect how
8484
git stores the contents you prepare in the working tree in the
8585
repository upon `git add` and `git commit`.
8686

87+
`crlf`
88+
^^^^^^
89+
90+
This attribute controls the line-ending convention.
91+
8792
Set::
8893

8994
Setting the `crlf` attribute on a path is meant to mark
@@ -129,6 +134,67 @@ converted to LF upon checkin, but there is no conversion done
129134
upon checkout.
130135

131136

137+
`ident`
138+
^^^^^^^
139+
140+
When the attribute `ident` is set to a path, git replaces
141+
`$ident$` in the blob object with `$ident:`, followed by
142+
40-character hexadecimal blob object name, followed by a dollar
143+
sign `$` upon checkout. Any byte sequence that begins with
144+
`$ident:` and ends with `$` in the worktree file is replaced
145+
with `$ident$` upon check-in.
146+
147+
148+
Interaction between checkin/checkout attributes
149+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150+
151+
In the check-in codepath, the worktree file is first converted
152+
with `ident` (if specified), and then with `crlf` (again, if
153+
specified and applicable).
154+
155+
In the check-out codepath, the blob content is first converted
156+
with `crlf`, and then `ident`.
157+
158+
159+
`filter`
160+
^^^^^^^^
161+
162+
A `filter` attribute can be set to a string value. This names
163+
filter driver specified in the configuration.
164+
165+
A filter driver consists of `clean` command and `smudge`
166+
command, either of which can be left unspecified. Upon
167+
checkout, when `smudge` command is specified, the command is fed
168+
the blob object from its standard input, and its standard output
169+
is used to update the worktree file. Similarly, `clean` command
170+
is used to convert the contents of worktree file upon checkin.
171+
172+
Missing filter driver definition in the config is not an error
173+
but makes the filter a no-op passthru.
174+
175+
The content filtering is done to massage the content into a
176+
shape that is more convenient for the platform, filesystem, and
177+
the user to use. The keyword here is "more convenient" and not
178+
"turning something unusable into usable". In other words, it is
179+
"hanging yourself because we gave you a long rope" if your
180+
project uses filtering mechanism in such a way that it makes
181+
your project unusable unless the checkout is done with a
182+
specific filter in effect.
183+
184+
185+
Interaction between checkin/checkout attributes
186+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
187+
188+
In the check-in codepath, the worktree file is first converted
189+
with `filter` driver (if specified and corresponding driver
190+
defined), then the result is processed with `ident` (if
191+
specified), and then finally with `crlf` (again, if specified
192+
and applicable).
193+
194+
In the check-out codepath, the blob content is first converted
195+
with `crlf`, and then `ident` and fed to `filter`.
196+
197+
132198
Generating diff text
133199
~~~~~~~~~~~~~~~~~~~~
134200

0 commit comments

Comments
 (0)