blob: f869933deb0b8552c889a3e001d0f9abfe5bacab [file] [log] [blame]
Junio C Hamanoe90436a2007-04-22 07:22:131<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
Junio C Hamano9d971152012-12-19 00:43:115<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
Junio C Hamanoc14e6ad2014-10-31 20:25:536<meta name="generator" content="AsciiDoc 8.6.9" />
Junio C Hamanoeef01fe2010-12-13 08:31:587<title>gitattributes(5)</title>
Junio C Hamanoe90436a2007-04-22 07:22:138<style type="text/css">
Junio C Hamano9d971152012-12-19 00:43:119/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
10
11/* Default font. */
12body {
13 font-family: Georgia,serif;
14}
15
16/* Title font. */
17h1, h2, h3, h4, h5, h6,
18div.title, caption.title,
19thead, p.table.header,
20#toctitle,
21#author, #revnumber, #revdate, #revremark,
22#footer {
23 font-family: Arial,Helvetica,sans-serif;
Junio C Hamanoe90436a2007-04-22 07:22:1324}
25
26body {
27 margin: 1em 5% 1em 5%;
28}
29
Junio C Hamanoba4b9282008-07-06 05:20:3130a {
31 color: blue;
32 text-decoration: underline;
33}
34a:visited {
35 color: fuchsia;
36}
Junio C Hamanoe90436a2007-04-22 07:22:1337
38em {
39 font-style: italic;
Junio C Hamanoeef01fe2010-12-13 08:31:5840 color: navy;
Junio C Hamanoe90436a2007-04-22 07:22:1341}
42
43strong {
44 font-weight: bold;
Junio C Hamanoeef01fe2010-12-13 08:31:5845 color: #083194;
Junio C Hamanoe90436a2007-04-22 07:22:1346}
47
Junio C Hamanoe90436a2007-04-22 07:22:1348h1, h2, h3, h4, h5, h6 {
49 color: #527bbd;
Junio C Hamanoe90436a2007-04-22 07:22:1350 margin-top: 1.2em;
51 margin-bottom: 0.5em;
52 line-height: 1.3;
53}
54
Junio C Hamanoba4b9282008-07-06 05:20:3155h1, h2, h3 {
Junio C Hamanoe90436a2007-04-22 07:22:1356 border-bottom: 2px solid silver;
57}
58h2 {
Junio C Hamanoe90436a2007-04-22 07:22:1359 padding-top: 0.5em;
60}
Junio C Hamanoba4b9282008-07-06 05:20:3161h3 {
62 float: left;
63}
64h3 + * {
65 clear: left;
66}
Junio C Hamano9d971152012-12-19 00:43:1167h5 {
68 font-size: 1.0em;
69}
Junio C Hamanoe90436a2007-04-22 07:22:1370
71div.sectionbody {
Junio C Hamanoe90436a2007-04-22 07:22:1372 margin-left: 0;
73}
74
75hr {
76 border: 1px solid silver;
77}
78
79p {
80 margin-top: 0.5em;
81 margin-bottom: 0.5em;
82}
83
Junio C Hamanoeef01fe2010-12-13 08:31:5884ul, ol, li > p {
85 margin-top: 0;
86}
Junio C Hamano9d971152012-12-19 00:43:1187ul > li { color: #aaa; }
88ul > li > * { color: black; }
Junio C Hamanoeef01fe2010-12-13 08:31:5889
Junio C Hamanoc14e6ad2014-10-31 20:25:5390.monospaced, code, pre {
91 font-family: "Courier New", Courier, monospace;
92 font-size: inherit;
93 color: navy;
Junio C Hamanoe90436a2007-04-22 07:22:1394 padding: 0;
95 margin: 0;
96}
Junio C Hamanoc14e6ad2014-10-31 20:25:5397pre {
98 white-space: pre-wrap;
99}
Junio C Hamanoe90436a2007-04-22 07:22:13100
Junio C Hamano9d971152012-12-19 00:43:11101#author {
Junio C Hamanoe90436a2007-04-22 07:22:13102 color: #527bbd;
Junio C Hamanoe90436a2007-04-22 07:22:13103 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:31104 font-size: 1.1em;
Junio C Hamanoe90436a2007-04-22 07:22:13105}
Junio C Hamano9d971152012-12-19 00:43:11106#email {
Junio C Hamanoe90436a2007-04-22 07:22:13107}
Junio C Hamano9d971152012-12-19 00:43:11108#revnumber, #revdate, #revremark {
Junio C Hamanoe90436a2007-04-22 07:22:13109}
110
Junio C Hamano9d971152012-12-19 00:43:11111#footer {
Junio C Hamanoe90436a2007-04-22 07:22:13112 font-size: small;
113 border-top: 2px solid silver;
114 padding-top: 0.5em;
115 margin-top: 4.0em;
116}
Junio C Hamano9d971152012-12-19 00:43:11117#footer-text {
Junio C Hamanoe90436a2007-04-22 07:22:13118 float: left;
119 padding-bottom: 0.5em;
120}
Junio C Hamano9d971152012-12-19 00:43:11121#footer-badges {
Junio C Hamanoe90436a2007-04-22 07:22:13122 float: right;
123 padding-bottom: 0.5em;
124}
125
Junio C Hamano9d971152012-12-19 00:43:11126#preamble {
Junio C Hamanoeef01fe2010-12-13 08:31:58127 margin-top: 1.5em;
128 margin-bottom: 1.5em;
129}
Junio C Hamano9d971152012-12-19 00:43:11130div.imageblock, div.exampleblock, div.verseblock,
Junio C Hamanoe90436a2007-04-22 07:22:13131div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
132div.admonitionblock {
Junio C Hamano7bd050f2011-09-22 06:32:22133 margin-top: 1.0em;
Junio C Hamanoe90436a2007-04-22 07:22:13134 margin-bottom: 1.5em;
135}
136div.admonitionblock {
Junio C Hamano7bd050f2011-09-22 06:32:22137 margin-top: 2.0em;
138 margin-bottom: 2.0em;
139 margin-right: 10%;
140 color: #606060;
Junio C Hamanoe90436a2007-04-22 07:22:13141}
142
143div.content { /* Block element content. */
144 padding: 0;
145}
146
147/* Block element titles. */
148div.title, caption.title {
Junio C Hamanoeef01fe2010-12-13 08:31:58149 color: #527bbd;
Junio C Hamanoe90436a2007-04-22 07:22:13150 font-weight: bold;
151 text-align: left;
152 margin-top: 1.0em;
153 margin-bottom: 0.5em;
154}
155div.title + * {
156 margin-top: 0;
157}
158
159td div.title:first-child {
160 margin-top: 0.0em;
161}
162div.content div.title:first-child {
163 margin-top: 0.0em;
164}
165div.content + div.title {
166 margin-top: 0.0em;
167}
168
169div.sidebarblock > div.content {
170 background: #ffffee;
Junio C Hamano9d971152012-12-19 00:43:11171 border: 1px solid #dddddd;
172 border-left: 4px solid #f0f0f0;
Junio C Hamanoe90436a2007-04-22 07:22:13173 padding: 0.5em;
174}
175
176div.listingblock > div.content {
Junio C Hamano9d971152012-12-19 00:43:11177 border: 1px solid #dddddd;
178 border-left: 5px solid #f0f0f0;
179 background: #f8f8f8;
Junio C Hamanoe90436a2007-04-22 07:22:13180 padding: 0.5em;
181}
182
Junio C Hamano7bd050f2011-09-22 06:32:22183div.quoteblock, div.verseblock {
184 padding-left: 1.0em;
185 margin-left: 1.0em;
Junio C Hamanoeef01fe2010-12-13 08:31:58186 margin-right: 10%;
Junio C Hamano9d971152012-12-19 00:43:11187 border-left: 5px solid #f0f0f0;
188 color: #888;
Junio C Hamanoe90436a2007-04-22 07:22:13189}
Junio C Hamano7bd050f2011-09-22 06:32:22190
Junio C Hamanoeef01fe2010-12-13 08:31:58191div.quoteblock > div.attribution {
192 padding-top: 0.5em;
Junio C Hamanoe90436a2007-04-22 07:22:13193 text-align: right;
194}
Junio C Hamanoeef01fe2010-12-13 08:31:58195
Junio C Hamano9d971152012-12-19 00:43:11196div.verseblock > pre.content {
197 font-family: inherit;
198 font-size: inherit;
Junio C Hamanoeef01fe2010-12-13 08:31:58199}
200div.verseblock > div.attribution {
201 padding-top: 0.75em;
202 text-align: left;
203}
204/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
Junio C Hamanoba4b9282008-07-06 05:20:31205div.verseblock + div.attribution {
206 text-align: left;
207}
Junio C Hamanoe90436a2007-04-22 07:22:13208
209div.admonitionblock .icon {
210 vertical-align: top;
211 font-size: 1.1em;
212 font-weight: bold;
213 text-decoration: underline;
214 color: #527bbd;
215 padding-right: 0.5em;
216}
217div.admonitionblock td.content {
218 padding-left: 0.5em;
Junio C Hamano7bd050f2011-09-22 06:32:22219 border-left: 3px solid #dddddd;
Junio C Hamanoe90436a2007-04-22 07:22:13220}
221
222div.exampleblock > div.content {
Junio C Hamano7bd050f2011-09-22 06:32:22223 border-left: 3px solid #dddddd;
224 padding-left: 0.5em;
Junio C Hamanoe90436a2007-04-22 07:22:13225}
226
Junio C Hamanoe90436a2007-04-22 07:22:13227div.imageblock div.content { padding-left: 0; }
Junio C Hamanoc14e6ad2014-10-31 20:25:53228span.image img { border-style: none; vertical-align: text-bottom; }
Junio C Hamanoeef01fe2010-12-13 08:31:58229a.image:visited { color: white; }
Junio C Hamanoe90436a2007-04-22 07:22:13230
231dl {
232 margin-top: 0.8em;
233 margin-bottom: 0.8em;
234}
235dt {
236 margin-top: 0.5em;
237 margin-bottom: 0;
Junio C Hamanoeef01fe2010-12-13 08:31:58238 font-style: normal;
239 color: navy;
Junio C Hamanoe90436a2007-04-22 07:22:13240}
241dd > *:first-child {
Junio C Hamanoeef01fe2010-12-13 08:31:58242 margin-top: 0.1em;
Junio C Hamanoe90436a2007-04-22 07:22:13243}
244
245ul, ol {
246 list-style-position: outside;
247}
Junio C Hamanoeef01fe2010-12-13 08:31:58248ol.arabic {
249 list-style-type: decimal;
250}
251ol.loweralpha {
Junio C Hamanoe90436a2007-04-22 07:22:13252 list-style-type: lower-alpha;
253}
Junio C Hamanoeef01fe2010-12-13 08:31:58254ol.upperalpha {
255 list-style-type: upper-alpha;
256}
257ol.lowerroman {
258 list-style-type: lower-roman;
259}
260ol.upperroman {
261 list-style-type: upper-roman;
262}
263
264div.compact ul, div.compact ol,
265div.compact p, div.compact p,
266div.compact div, div.compact div {
267 margin-top: 0.1em;
268 margin-bottom: 0.1em;
269}
Junio C Hamanoe90436a2007-04-22 07:22:13270
Junio C Hamanoe90436a2007-04-22 07:22:13271tfoot {
272 font-weight: bold;
273}
Junio C Hamanoeef01fe2010-12-13 08:31:58274td > div.verse {
275 white-space: pre;
276}
Junio C Hamanoeef01fe2010-12-13 08:31:58277
278div.hdlist {
Junio C Hamanoe90436a2007-04-22 07:22:13279 margin-top: 0.8em;
280 margin-bottom: 0.8em;
281}
Junio C Hamanoeef01fe2010-12-13 08:31:58282div.hdlist tr {
283 padding-bottom: 15px;
Junio C Hamanoba4b9282008-07-06 05:20:31284}
Junio C Hamanoeef01fe2010-12-13 08:31:58285dt.hdlist1.strong, td.hdlist1.strong {
286 font-weight: bold;
287}
288td.hdlist1 {
Junio C Hamanoe90436a2007-04-22 07:22:13289 vertical-align: top;
Junio C Hamanoeef01fe2010-12-13 08:31:58290 font-style: normal;
Junio C Hamanoe90436a2007-04-22 07:22:13291 padding-right: 0.8em;
Junio C Hamanoeef01fe2010-12-13 08:31:58292 color: navy;
Junio C Hamanoe90436a2007-04-22 07:22:13293}
Junio C Hamanoeef01fe2010-12-13 08:31:58294td.hdlist2 {
Junio C Hamanoe90436a2007-04-22 07:22:13295 vertical-align: top;
296}
Junio C Hamanoeef01fe2010-12-13 08:31:58297div.hdlist.compact tr {
298 margin: 0;
299 padding-bottom: 0;
300}
301
302.comment {
303 background: yellow;
304}
Junio C Hamanoe90436a2007-04-22 07:22:13305
Junio C Hamano7bd050f2011-09-22 06:32:22306.footnote, .footnoteref {
307 font-size: 0.8em;
308}
309
310span.footnote, span.footnoteref {
311 vertical-align: super;
312}
313
314#footnotes {
315 margin: 20px 0 20px 0;
316 padding: 7px 0 0 0;
317}
318
319#footnotes div.footnote {
320 margin: 0 0 5px 0;
321}
322
323#footnotes hr {
324 border: none;
325 border-top: 1px solid silver;
326 height: 1px;
327 text-align: left;
328 margin-left: 0;
329 width: 20%;
330 min-width: 100px;
331}
332
Junio C Hamano9d971152012-12-19 00:43:11333div.colist td {
334 padding-right: 0.5em;
335 padding-bottom: 0.3em;
336 vertical-align: top;
337}
338div.colist td img {
339 margin-top: 0.3em;
Junio C Hamanoe90436a2007-04-22 07:22:13340}
Junio C Hamanoba4b9282008-07-06 05:20:31341
Junio C Hamano9d971152012-12-19 00:43:11342@media print {
343 #footer-badges { display: none; }
344}
345
346#toc {
Junio C Hamano7bd050f2011-09-22 06:32:22347 margin-bottom: 2.5em;
348}
349
Junio C Hamano9d971152012-12-19 00:43:11350#toctitle {
Junio C Hamanoba4b9282008-07-06 05:20:31351 color: #527bbd;
Junio C Hamanoba4b9282008-07-06 05:20:31352 font-size: 1.1em;
353 font-weight: bold;
354 margin-top: 1.0em;
355 margin-bottom: 0.1em;
356}
357
Junio C Hamanoc14e6ad2014-10-31 20:25:53358div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
Junio C Hamanoba4b9282008-07-06 05:20:31359 margin-top: 0;
360 margin-bottom: 0;
361}
362div.toclevel2 {
363 margin-left: 2em;
364 font-size: 0.9em;
365}
366div.toclevel3 {
367 margin-left: 4em;
368 font-size: 0.9em;
369}
370div.toclevel4 {
371 margin-left: 6em;
372 font-size: 0.9em;
373}
Junio C Hamano9d971152012-12-19 00:43:11374
375span.aqua { color: aqua; }
376span.black { color: black; }
377span.blue { color: blue; }
378span.fuchsia { color: fuchsia; }
379span.gray { color: gray; }
380span.green { color: green; }
381span.lime { color: lime; }
382span.maroon { color: maroon; }
383span.navy { color: navy; }
384span.olive { color: olive; }
385span.purple { color: purple; }
386span.red { color: red; }
387span.silver { color: silver; }
388span.teal { color: teal; }
389span.white { color: white; }
390span.yellow { color: yellow; }
391
392span.aqua-background { background: aqua; }
393span.black-background { background: black; }
394span.blue-background { background: blue; }
395span.fuchsia-background { background: fuchsia; }
396span.gray-background { background: gray; }
397span.green-background { background: green; }
398span.lime-background { background: lime; }
399span.maroon-background { background: maroon; }
400span.navy-background { background: navy; }
401span.olive-background { background: olive; }
402span.purple-background { background: purple; }
403span.red-background { background: red; }
404span.silver-background { background: silver; }
405span.teal-background { background: teal; }
406span.white-background { background: white; }
407span.yellow-background { background: yellow; }
408
409span.big { font-size: 2em; }
410span.small { font-size: 0.6em; }
411
412span.underline { text-decoration: underline; }
413span.overline { text-decoration: overline; }
414span.line-through { text-decoration: line-through; }
415
Junio C Hamanoc14e6ad2014-10-31 20:25:53416div.unbreakable { page-break-inside: avoid; }
417
Junio C Hamano9d971152012-12-19 00:43:11418
419/*
420 * xhtml11 specific
421 *
422 * */
423
424div.tableblock {
425 margin-top: 1.0em;
426 margin-bottom: 1.5em;
427}
428div.tableblock > table {
429 border: 3px solid #527bbd;
430}
431thead, p.table.header {
432 font-weight: bold;
433 color: #527bbd;
434}
435p.table {
436 margin-top: 0;
437}
438/* Because the table frame attribute is overriden by CSS in most browsers. */
439div.tableblock > table[frame="void"] {
440 border-style: none;
441}
442div.tableblock > table[frame="hsides"] {
443 border-left-style: none;
444 border-right-style: none;
445}
446div.tableblock > table[frame="vsides"] {
447 border-top-style: none;
448 border-bottom-style: none;
449}
450
451
452/*
453 * html5 specific
454 *
455 * */
456
457table.tableblock {
458 margin-top: 1.0em;
459 margin-bottom: 1.5em;
460}
461thead, p.tableblock.header {
462 font-weight: bold;
463 color: #527bbd;
464}
465p.tableblock {
466 margin-top: 0;
467}
468table.tableblock {
469 border-width: 3px;
470 border-spacing: 0px;
471 border-style: solid;
472 border-color: #527bbd;
473 border-collapse: collapse;
474}
475th.tableblock, td.tableblock {
476 border-width: 1px;
477 padding: 4px;
478 border-style: solid;
479 border-color: #527bbd;
480}
481
482table.tableblock.frame-topbot {
483 border-left-style: hidden;
484 border-right-style: hidden;
485}
486table.tableblock.frame-sides {
487 border-top-style: hidden;
488 border-bottom-style: hidden;
489}
490table.tableblock.frame-none {
491 border-style: hidden;
492}
493
494th.tableblock.halign-left, td.tableblock.halign-left {
495 text-align: left;
496}
497th.tableblock.halign-center, td.tableblock.halign-center {
498 text-align: center;
499}
500th.tableblock.halign-right, td.tableblock.halign-right {
501 text-align: right;
502}
503
504th.tableblock.valign-top, td.tableblock.valign-top {
505 vertical-align: top;
506}
507th.tableblock.valign-middle, td.tableblock.valign-middle {
508 vertical-align: middle;
509}
510th.tableblock.valign-bottom, td.tableblock.valign-bottom {
511 vertical-align: bottom;
512}
513
514
515/*
516 * manpage specific
517 *
518 * */
519
520body.manpage h1 {
Junio C Hamanoeef01fe2010-12-13 08:31:58521 padding-top: 0.5em;
522 padding-bottom: 0.5em;
523 border-top: 2px solid silver;
524 border-bottom: 2px solid silver;
525}
Junio C Hamano9d971152012-12-19 00:43:11526body.manpage h2 {
Junio C Hamanoeef01fe2010-12-13 08:31:58527 border-style: none;
528}
Junio C Hamano9d971152012-12-19 00:43:11529body.manpage div.sectionbody {
530 margin-left: 3em;
Junio C Hamanoeef01fe2010-12-13 08:31:58531}
532
533@media print {
Junio C Hamano9d971152012-12-19 00:43:11534 body.manpage div#toc { display: none; }
Junio C Hamanoeef01fe2010-12-13 08:31:58535}
Junio C Hamanoc14e6ad2014-10-31 20:25:53536
537
Junio C Hamanoe90436a2007-04-22 07:22:13538</style>
Junio C Hamano7bd050f2011-09-22 06:32:22539<script type="text/javascript">
540/*<![CDATA[*/
Junio C Hamano7bd050f2011-09-22 06:32:22541var asciidoc = { // Namespace.
542
543/////////////////////////////////////////////////////////////////////
544// Table Of Contents generator
545/////////////////////////////////////////////////////////////////////
546
547/* Author: Mihai Bazon, September 2002
548 * http://students.infoiasi.ro/~mishoo
549 *
550 * Table Of Content generator
551 * Version: 0.4
552 *
553 * Feel free to use this script under the terms of the GNU General Public
554 * License, as long as you do not remove or alter this notice.
555 */
556
557 /* modified by Troy D. Hanson, September 2006. License: GPL */
558 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
559
560// toclevels = 1..4.
561toc: function (toclevels) {
562
563 function getText(el) {
564 var text = "";
565 for (var i = el.firstChild; i != null; i = i.nextSibling) {
566 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
567 text += i.data;
568 else if (i.firstChild != null)
569 text += getText(i);
570 }
571 return text;
572 }
573
574 function TocEntry(el, text, toclevel) {
575 this.element = el;
576 this.text = text;
577 this.toclevel = toclevel;
578 }
579
580 function tocEntries(el, toclevels) {
581 var result = new Array;
Junio C Hamanoc14e6ad2014-10-31 20:25:53582 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
Junio C Hamano7bd050f2011-09-22 06:32:22583 // Function that scans the DOM tree for header elements (the DOM2
584 // nodeIterator API would be a better technique but not supported by all
585 // browsers).
586 var iterate = function (el) {
587 for (var i = el.firstChild; i != null; i = i.nextSibling) {
588 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
589 var mo = re.exec(i.tagName);
590 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
591 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
592 }
593 iterate(i);
594 }
595 }
596 }
597 iterate(el);
598 return result;
599 }
600
601 var toc = document.getElementById("toc");
Junio C Hamano9d971152012-12-19 00:43:11602 if (!toc) {
603 return;
604 }
605
606 // Delete existing TOC entries in case we're reloading the TOC.
607 var tocEntriesToRemove = [];
608 var i;
609 for (i = 0; i < toc.childNodes.length; i++) {
610 var entry = toc.childNodes[i];
Junio C Hamanoc14e6ad2014-10-31 20:25:53611 if (entry.nodeName.toLowerCase() == 'div'
Junio C Hamano9d971152012-12-19 00:43:11612 && entry.getAttribute("class")
613 && entry.getAttribute("class").match(/^toclevel/))
614 tocEntriesToRemove.push(entry);
615 }
616 for (i = 0; i < tocEntriesToRemove.length; i++) {
617 toc.removeChild(tocEntriesToRemove[i]);
618 }
619
620 // Rebuild TOC entries.
Junio C Hamano7bd050f2011-09-22 06:32:22621 var entries = tocEntries(document.getElementById("content"), toclevels);
622 for (var i = 0; i < entries.length; ++i) {
623 var entry = entries[i];
624 if (entry.element.id == "")
625 entry.element.id = "_toc_" + i;
626 var a = document.createElement("a");
627 a.href = "#" + entry.element.id;
628 a.appendChild(document.createTextNode(entry.text));
629 var div = document.createElement("div");
630 div.appendChild(a);
631 div.className = "toclevel" + entry.toclevel;
632 toc.appendChild(div);
633 }
634 if (entries.length == 0)
635 toc.parentNode.removeChild(toc);
636},
637
638
639/////////////////////////////////////////////////////////////////////
640// Footnotes generator
641/////////////////////////////////////////////////////////////////////
642
643/* Based on footnote generation code from:
644 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
645 */
646
647footnotes: function () {
Junio C Hamano9d971152012-12-19 00:43:11648 // Delete existing footnote entries in case we're reloading the footnodes.
649 var i;
Junio C Hamano7bd050f2011-09-22 06:32:22650 var noteholder = document.getElementById("footnotes");
Junio C Hamano9d971152012-12-19 00:43:11651 if (!noteholder) {
652 return;
653 }
654 var entriesToRemove = [];
655 for (i = 0; i < noteholder.childNodes.length; i++) {
656 var entry = noteholder.childNodes[i];
Junio C Hamanoc14e6ad2014-10-31 20:25:53657 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
Junio C Hamano9d971152012-12-19 00:43:11658 entriesToRemove.push(entry);
659 }
660 for (i = 0; i < entriesToRemove.length; i++) {
661 noteholder.removeChild(entriesToRemove[i]);
662 }
663
664 // Rebuild footnote entries.
665 var cont = document.getElementById("content");
Junio C Hamano7bd050f2011-09-22 06:32:22666 var spans = cont.getElementsByTagName("span");
667 var refs = {};
668 var n = 0;
669 for (i=0; i<spans.length; i++) {
670 if (spans[i].className == "footnote") {
671 n++;
Junio C Hamano9d971152012-12-19 00:43:11672 var note = spans[i].getAttribute("data-note");
673 if (!note) {
674 // Use [\s\S] in place of . so multi-line matches work.
675 // Because JavaScript has no s (dotall) regex flag.
676 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
677 spans[i].innerHTML =
678 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
679 "' title='View footnote' class='footnote'>" + n + "</a>]";
680 spans[i].setAttribute("data-note", note);
681 }
Junio C Hamano7bd050f2011-09-22 06:32:22682 noteholder.innerHTML +=
683 "<div class='footnote' id='_footnote_" + n + "'>" +
684 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
685 n + "</a>. " + note + "</div>";
Junio C Hamano7bd050f2011-09-22 06:32:22686 var id =spans[i].getAttribute("id");
687 if (id != null) refs["#"+id] = n;
688 }
689 }
690 if (n == 0)
691 noteholder.parentNode.removeChild(noteholder);
692 else {
693 // Process footnoterefs.
694 for (i=0; i<spans.length; i++) {
695 if (spans[i].className == "footnoteref") {
696 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
697 href = href.match(/#.*/)[0]; // Because IE return full URL.
698 n = refs[href];
699 spans[i].innerHTML =
700 "[<a href='#_footnote_" + n +
701 "' title='View footnote' class='footnote'>" + n + "</a>]";
702 }
703 }
704 }
Junio C Hamano9d971152012-12-19 00:43:11705},
706
707install: function(toclevels) {
708 var timerId;
709
710 function reinstall() {
711 asciidoc.footnotes();
712 if (toclevels) {
713 asciidoc.toc(toclevels);
714 }
715 }
716
717 function reinstallAndRemoveTimer() {
718 clearInterval(timerId);
719 reinstall();
720 }
721
722 timerId = setInterval(reinstall, 500);
723 if (document.addEventListener)
724 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
725 else
726 window.onload = reinstallAndRemoveTimer;
Junio C Hamano7bd050f2011-09-22 06:32:22727}
728
729}
Junio C Hamano9d971152012-12-19 00:43:11730asciidoc.install();
Junio C Hamano7bd050f2011-09-22 06:32:22731/*]]>*/
732</script>
Junio C Hamanoe90436a2007-04-22 07:22:13733</head>
Junio C Hamano9d971152012-12-19 00:43:11734<body class="manpage">
Junio C Hamanoe90436a2007-04-22 07:22:13735<div id="header">
736<h1>
737gitattributes(5) Manual Page
738</h1>
739<h2>NAME</h2>
740<div class="sectionbody">
741<p>gitattributes -
742 defining attributes per path
743</p>
744</div>
745</div>
Junio C Hamano7bd050f2011-09-22 06:32:22746<div id="content">
Junio C Hamano9d971152012-12-19 00:43:11747<div class="sect1">
Junio C Hamanoeef01fe2010-12-13 08:31:58748<h2 id="_synopsis">SYNOPSIS</h2>
Junio C Hamanoe90436a2007-04-22 07:22:13749<div class="sectionbody">
Junio C Hamanoeef01fe2010-12-13 08:31:58750<div class="paragraph"><p>$GIT_DIR/info/attributes, .gitattributes</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:13751</div>
Junio C Hamano9d971152012-12-19 00:43:11752</div>
753<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31754<h2 id="_description">DESCRIPTION</h2>
Junio C Hamanoe90436a2007-04-22 07:22:13755<div class="sectionbody">
Junio C Hamanoc14e6ad2014-10-31 20:25:53756<div class="paragraph"><p>A <code>gitattributes</code> file is a simple text file that gives
757<code>attributes</code> to pathnames.</p></div>
758<div class="paragraph"><p>Each line in <code>gitattributes</code> file is of form:</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:13759<div class="literalblock">
760<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53761<pre><code>pattern attr1 attr2 ...</code></pre>
Junio C Hamanoe90436a2007-04-22 07:22:13762</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58763<div class="paragraph"><p>That is, a pattern followed by an attributes list,
Junio C Hamanocbe0eb22017-02-27 23:37:49764separated by whitespaces. Leading and trailing whitespaces are
765ignored. Lines that begin with <em>#</em> are ignored. Patterns
766that begin with a double quote are quoted in C style.
767When the pattern matches the path in question, the attributes
768listed on the line are given to the path.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58769<div class="paragraph"><p>Each attribute can be in one of these states for a given path:</p></div>
770<div class="dlist"><dl>
771<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13772Set
773</dt>
774<dd>
775<p>
776 The path has the attribute with special value "true";
777 this is specified by listing only the name of the
778 attribute in the attribute list.
779</p>
780</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58781<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13782Unset
783</dt>
784<dd>
785<p>
786 The path has the attribute with special value "false";
787 this is specified by listing the name of the attribute
Junio C Hamanoc14e6ad2014-10-31 20:25:53788 prefixed with a dash <code>-</code> in the attribute list.
Junio C Hamanoe90436a2007-04-22 07:22:13789</p>
790</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58791<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13792Set to a value
793</dt>
794<dd>
795<p>
796 The path has the attribute with specified string value;
797 this is specified by listing the name of the attribute
Junio C Hamanoc14e6ad2014-10-31 20:25:53798 followed by an equal sign <code>=</code> and its value in the
Junio C Hamanoe90436a2007-04-22 07:22:13799 attribute list.
800</p>
801</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58802<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13803Unspecified
804</dt>
805<dd>
806<p>
Junio C Hamanod533bdb2009-02-25 09:56:58807 No pattern matches the path, and nothing says if
Junio C Hamano22572e72007-04-25 05:59:25808 the path has or does not have the attribute, the
809 attribute for the path is said to be Unspecified.
Junio C Hamanoe90436a2007-04-22 07:22:13810</p>
811</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31812</dl></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58813<div class="paragraph"><p>When more than one pattern matches the path, a later line
Junio C Hamano22572e72007-04-25 05:59:25814overrides an earlier line. This overriding is done per
Junio C Hamanod533bdb2009-02-25 09:56:58815attribute. The rules how the pattern matches paths are the
Junio C Hamanoc14e6ad2014-10-31 20:25:53816same as in <code>.gitignore</code> files; see <a href="gitignore.html">gitignore(5)</a>.
817Unlike <code>.gitignore</code>, negative patterns are forbidden.</p></div>
Junio C Hamano076ffcc2013-02-06 05:13:21818<div class="paragraph"><p>When deciding what attributes are assigned to a path, Git
Junio C Hamanoc14e6ad2014-10-31 20:25:53819consults <code>$GIT_DIR/info/attributes</code> file (which has the highest
820precedence), <code>.gitattributes</code> file in the same directory as the
Junio C Hamanob4a9ede2009-04-08 07:36:32821path in question, and its parent directories up to the toplevel of the
Junio C Hamanoc14e6ad2014-10-31 20:25:53822work tree (the further the directory that contains <code>.gitattributes</code>
Junio C Hamano3b4609d2010-09-30 00:04:34823is from the path in question, the lower its precedence). Finally
824global and system-wide files are considered (they have the lowest
825precedence).</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53826<div class="paragraph"><p>When the <code>.gitattributes</code> file is missing from the work tree, the
Junio C Hamano6631a092012-10-10 22:50:57827path in the index is used as a fall-back. During checkout process,
Junio C Hamanoc14e6ad2014-10-31 20:25:53828<code>.gitattributes</code> in the index is used and then the file in the
Junio C Hamano6631a092012-10-10 22:50:57829working tree is used as a fall-back.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58830<div class="paragraph"><p>If you wish to affect only a single repository (i.e., to assign
Junio C Hamano3b4609d2010-09-30 00:04:34831attributes to files that are particular to
Junio C Hamanoeef01fe2010-12-13 08:31:58832one user&#8217;s workflow for that repository), then
Junio C Hamanoc14e6ad2014-10-31 20:25:53833attributes should be placed in the <code>$GIT_DIR/info/attributes</code> file.
Junio C Hamano99dc24a2008-03-27 23:49:50834Attributes which should be version-controlled and distributed to other
835repositories (i.e., attributes of interest to all users) should go into
Junio C Hamanoc14e6ad2014-10-31 20:25:53836<code>.gitattributes</code> files. Attributes that should affect all repositories
Junio C Hamano3b4609d2010-09-30 00:04:34837for a single user should be placed in a file specified by the
Junio C Hamano322c6242015-03-23 21:32:46838<code>core.attributesFile</code> configuration option (see <a href="git-config.html">git-config(1)</a>).
Junio C Hamano8edb4c72012-07-09 20:33:55839Its default value is $XDG_CONFIG_HOME/git/attributes. If $XDG_CONFIG_HOME
840is either not set or empty, $HOME/.config/git/attributes is used instead.
Junio C Hamano3b4609d2010-09-30 00:04:34841Attributes for all users on a system should be placed in the
Junio C Hamanoc14e6ad2014-10-31 20:25:53842<code>$(prefix)/etc/gitattributes</code> file.</p></div>
Junio C Hamanocbe0eb22017-02-27 23:37:49843<div class="paragraph"><p>Sometimes you would need to override a setting of an attribute
Junio C Hamanoc14e6ad2014-10-31 20:25:53844for a path to <code>Unspecified</code> state. This can be done by listing
845the name of the attribute prefixed with an exclamation point <code>!</code>.</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:13846</div>
Junio C Hamano9d971152012-12-19 00:43:11847</div>
848<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31849<h2 id="_effects">EFFECTS</h2>
Junio C Hamanoe90436a2007-04-22 07:22:13850<div class="sectionbody">
Junio C Hamano076ffcc2013-02-06 05:13:21851<div class="paragraph"><p>Certain operations by Git can be influenced by assigning
Junio C Hamano2a8f6dc2007-07-09 08:48:38852particular attributes to a path. Currently, the following
Junio C Hamanoba4b9282008-07-06 05:20:31853operations are attributes-aware.</p></div>
Junio C Hamano9d971152012-12-19 00:43:11854<div class="sect2">
855<h3 id="_checking_out_and_checking_in">Checking-out and checking-in</h3>
Junio C Hamanoeef01fe2010-12-13 08:31:58856<div class="paragraph"><p>These attributes affect how the contents stored in the
Junio C Hamanoe90436a2007-04-22 07:22:13857repository are copied to the working tree files when commands
Junio C Hamano1aa40d22010-01-21 17:46:43858such as <em>git checkout</em> and <em>git merge</em> run. They also affect how
Junio C Hamano076ffcc2013-02-06 05:13:21859Git stores the contents you prepare in the working tree in the
Junio C Hamano1aa40d22010-01-21 17:46:43860repository upon <em>git add</em> and <em>git commit</em>.</p></div>
Junio C Hamano9d971152012-12-19 00:43:11861<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:53862<h4 id="_code_text_code"><code>text</code></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58863<div class="paragraph"><p>This attribute enables and controls end-of-line normalization. When a
Junio C Hamanobb88cf42010-06-21 15:23:55864text file is normalized, its line endings are converted to LF in the
865repository. To control what line ending style is used in the working
Junio C Hamanoc14e6ad2014-10-31 20:25:53866directory, use the <code>eol</code> attribute for a single file and the
Junio C Hamanoeed15af2016-07-25 22:49:42867<code>core.eol</code> configuration variable for all text files.
868Note that <code>core.autocrlf</code> overrides <code>core.eol</code></p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58869<div class="dlist"><dl>
870<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13871Set
872</dt>
873<dd>
874<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53875 Setting the <code>text</code> attribute on a path enables end-of-line
Junio C Hamanobb88cf42010-06-21 15:23:55876 normalization and marks the path as a text file. End-of-line
877 conversion takes place without guessing the content type.
Junio C Hamanoe90436a2007-04-22 07:22:13878</p>
879</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58880<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13881Unset
882</dt>
883<dd>
884<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53885 Unsetting the <code>text</code> attribute on a path tells Git not to
Junio C Hamanofcb740a2008-08-31 06:32:05886 attempt any end-of-line conversion upon checkin or checkout.
Junio C Hamanoe90436a2007-04-22 07:22:13887</p>
888</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58889<dt class="hdlist1">
Junio C Hamanobb88cf42010-06-21 15:23:55890Set to string value "auto"
891</dt>
892<dd>
893<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53894 When <code>text</code> is set to "auto", the path is marked for automatic
Junio C Hamanoeed15af2016-07-25 22:49:42895 end-of-line conversion. If Git decides that the content is
896 text, its line endings are converted to LF on checkin.
Junio C Hamano0f1d17c2016-08-12 19:42:26897 When the file has been committed with CRLF, no conversion is done.
Junio C Hamanobb88cf42010-06-21 15:23:55898</p>
899</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58900<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:13901Unspecified
902</dt>
903<dd>
904<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53905 If the <code>text</code> attribute is unspecified, Git uses the
906 <code>core.autocrlf</code> configuration variable to determine if the
Junio C Hamanobb88cf42010-06-21 15:23:55907 file should be converted.
Junio C Hamanoe90436a2007-04-22 07:22:13908</p>
909</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31910</dl></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53911<div class="paragraph"><p>Any other value causes Git to act as if <code>text</code> has been left
Junio C Hamanobb88cf42010-06-21 15:23:55912unspecified.</p></div>
Junio C Hamano9d971152012-12-19 00:43:11913</div>
914<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:53915<h4 id="_code_eol_code"><code>eol</code></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:58916<div class="paragraph"><p>This attribute sets a specific line-ending style to be used in the
Junio C Hamanoeed15af2016-07-25 22:49:42917working directory. It enables end-of-line conversion without any
Junio C Hamano8d57fa92017-09-19 05:01:08918content checks, effectively setting the <code>text</code> attribute. Note that
919setting this attribute on paths which are in the index with CRLF line
920endings may make the paths to be considered dirty. Adding the path to
921the index again will normalize the line endings in the index.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:58922<div class="dlist"><dl>
923<dt class="hdlist1">
Junio C Hamanobb88cf42010-06-21 15:23:55924Set to string value "crlf"
925</dt>
926<dd>
927<p>
Junio C Hamano076ffcc2013-02-06 05:13:21928 This setting forces Git to normalize line endings for this
Junio C Hamanobb88cf42010-06-21 15:23:55929 file on checkin and convert them to CRLF when the file is
930 checked out.
931</p>
932</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:58933<dt class="hdlist1">
Junio C Hamanobb88cf42010-06-21 15:23:55934Set to string value "lf"
935</dt>
936<dd>
937<p>
Junio C Hamano076ffcc2013-02-06 05:13:21938 This setting forces Git to normalize line endings to LF on
Junio C Hamanobb88cf42010-06-21 15:23:55939 checkin and prevents conversion to CRLF when the file is
940 checked out.
941</p>
942</dd>
943</dl></div>
Junio C Hamano9d971152012-12-19 00:43:11944</div>
945<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:53946<h4 id="_backwards_compatibility_with_code_crlf_code_attribute">Backwards compatibility with <code>crlf</code> attribute</h4>
947<div class="paragraph"><p>For backwards compatibility, the <code>crlf</code> attribute is interpreted as
Junio C Hamanobb88cf42010-06-21 15:23:55948follows:</p></div>
949<div class="listingblock">
950<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53951<pre><code>crlf text
Junio C Hamanobb88cf42010-06-21 15:23:55952-crlf -text
Junio C Hamanoc14e6ad2014-10-31 20:25:53953crlf=input eol=lf</code></pre>
Junio C Hamanobb88cf42010-06-21 15:23:55954</div></div>
Junio C Hamano9d971152012-12-19 00:43:11955</div>
956<div class="sect3">
Junio C Hamanobb88cf42010-06-21 15:23:55957<h4 id="_end_of_line_conversion">End-of-line conversion</h4>
Junio C Hamano076ffcc2013-02-06 05:13:21958<div class="paragraph"><p>While Git normally leaves file contents alone, it can be configured to
Junio C Hamanobb88cf42010-06-21 15:23:55959normalize line endings to LF in the repository and, optionally, to
960convert them to CRLF when files are checked out.</p></div>
Junio C Hamanoe7808d72016-08-26 21:48:01961<div class="paragraph"><p>If you simply want to have CRLF line endings in your working directory
962regardless of the repository you are working with, you can set the
963config variable "core.autocrlf" without using any attributes.</p></div>
964<div class="listingblock">
965<div class="content">
966<pre><code>[core]
967 autocrlf = true</code></pre>
968</div></div>
969<div class="paragraph"><p>This does not force normalization of text files, but does ensure
970that text files that you introduce to the repository have their line
971endings normalized to LF when they are added, and that files that are
972already normalized in the repository stay normalized.</p></div>
973<div class="paragraph"><p>If you want to ensure that text files that any contributor introduces to
974the repository have their line endings normalized, you can set the
975<code>text</code> attribute to "auto" for <em>all</em> files.</p></div>
976<div class="listingblock">
977<div class="content">
978<pre><code>* text=auto</code></pre>
979</div></div>
980<div class="paragraph"><p>The attributes allow a fine-grained control, how the line endings
981are converted.
982Here is an example that will make Git normalize .txt, .vcproj and .sh
Junio C Hamanobb88cf42010-06-21 15:23:55983files, ensure that .vcproj files have CRLF and .sh files have LF in
984the working directory, and prevent .jpg files from being normalized
985regardless of their content.</p></div>
986<div class="listingblock">
987<div class="content">
Junio C Hamanoeed15af2016-07-25 22:49:42988<pre><code>* text=auto
989*.txt text
990*.vcproj text eol=crlf
991*.sh text eol=lf
Junio C Hamanoc14e6ad2014-10-31 20:25:53992*.jpg -text</code></pre>
Junio C Hamanobb88cf42010-06-21 15:23:55993</div></div>
Junio C Hamanobb88cf42010-06-21 15:23:55994<div class="admonitionblock">
995<table><tr>
996<td class="icon">
997<div class="title">Note</div>
998</td>
Junio C Hamanoe7808d72016-08-26 21:48:01999<td class="content">When <code>text=auto</code> conversion is enabled in a cross-platform
1000project using push and pull to a central repository the text files
1001containing CRLFs should be normalized.</td>
Junio C Hamanobb88cf42010-06-21 15:23:551002</tr></table>
1003</div>
Junio C Hamanoe7808d72016-08-26 21:48:011004<div class="paragraph"><p>From a clean working directory:</p></div>
Junio C Hamanobb88cf42010-06-21 15:23:551005<div class="listingblock">
1006<div class="content">
Junio C Hamanoe7808d72016-08-26 21:48:011007<pre><code>$ echo "* text=auto" &gt;.gitattributes
Junio C Hamano4886c772017-11-27 03:33:281008$ git add --renormalize .
Junio C Hamanobb88cf42010-06-21 15:23:551009$ git status # Show files that will be normalized
Junio C Hamanoc14e6ad2014-10-31 20:25:531010$ git commit -m "Introduce end-of-line normalization"</code></pre>
Junio C Hamanobb88cf42010-06-21 15:23:551011</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581012<div class="paragraph"><p>If any files that should not be normalized show up in <em>git status</em>,
Junio C Hamanoc14e6ad2014-10-31 20:25:531013unset their <code>text</code> attribute before running <em>git add -u</em>.</p></div>
Junio C Hamanobb88cf42010-06-21 15:23:551014<div class="listingblock">
1015<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531016<pre><code>manual.pdf -text</code></pre>
Junio C Hamanobb88cf42010-06-21 15:23:551017</div></div>
Junio C Hamano076ffcc2013-02-06 05:13:211018<div class="paragraph"><p>Conversely, text files that Git does not detect can have normalization
Junio C Hamanobb88cf42010-06-21 15:23:551019enabled manually.</p></div>
1020<div class="listingblock">
1021<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531022<pre><code>weirdchars.txt text</code></pre>
Junio C Hamanobb88cf42010-06-21 15:23:551023</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531024<div class="paragraph"><p>If <code>core.safecrlf</code> is set to "true" or "warn", Git verifies if
Junio C Hamano26e590a2008-02-17 03:53:511025the conversion is reversible for the current setting of
Junio C Hamanoc14e6ad2014-10-31 20:25:531026<code>core.autocrlf</code>. For "true", Git rejects irreversible
Junio C Hamano076ffcc2013-02-06 05:13:211027conversions; for "warn", Git only prints a warning but accepts
Junio C Hamano26e590a2008-02-17 03:53:511028an irreversible conversion. The safety triggers to prevent such
1029a conversion done to the files in the work tree, but there are a
Junio C Hamanoba4b9282008-07-06 05:20:311030few exceptions. Even though&#8230;</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581031<div class="ulist"><ul>
Junio C Hamano26e590a2008-02-17 03:53:511032<li>
1033<p>
Junio C Hamano1aa40d22010-01-21 17:46:431034<em>git add</em> itself does not touch the files in the work tree, the
Junio C Hamano26e590a2008-02-17 03:53:511035 next checkout would, so the safety triggers;
1036</p>
1037</li>
1038<li>
1039<p>
Junio C Hamano1aa40d22010-01-21 17:46:431040<em>git apply</em> to update a text file with a patch does touch the files
Junio C Hamano26e590a2008-02-17 03:53:511041 in the work tree, but the operation is about text files and CRLF
1042 conversion is about fixing the line ending inconsistencies, so the
1043 safety does not trigger;
1044</p>
1045</li>
1046<li>
1047<p>
Junio C Hamano1aa40d22010-01-21 17:46:431048<em>git diff</em> itself does not touch the files in the work tree, it is
1049 often run to inspect the changes you intend to next <em>git add</em>. To
Junio C Hamano26e590a2008-02-17 03:53:511050 catch potential problems early, safety triggers.
1051</p>
1052</li>
Junio C Hamanoba4b9282008-07-06 05:20:311053</ul></div>
Junio C Hamano9d971152012-12-19 00:43:111054</div>
1055<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:531056<h4 id="_code_ident_code"><code>ident</code></h4>
1057<div class="paragraph"><p>When the attribute <code>ident</code> is set for a path, Git replaces
1058<code>$Id$</code> in the blob object with <code>$Id:</code>, followed by the
Junio C Hamano469d60e2007-04-29 18:30:34105940-character hexadecimal blob object name, followed by a dollar
Junio C Hamanoc14e6ad2014-10-31 20:25:531060sign <code>$</code> upon checkout. Any byte sequence that begins with
1061<code>$Id:</code> and ends with <code>$</code> in the worktree file is replaced
1062with <code>$Id$</code> upon check-in.</p></div>
Junio C Hamano9d971152012-12-19 00:43:111063</div>
1064<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:531065<h4 id="_code_filter_code"><code>filter</code></h4>
1066<div class="paragraph"><p>A <code>filter</code> attribute can be set to a string value that names a
Junio C Hamanoba4b9282008-07-06 05:20:311067filter driver specified in the configuration.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531068<div class="paragraph"><p>A filter driver consists of a <code>clean</code> command and a <code>smudge</code>
Junio C Hamano469d60e2007-04-29 18:30:341069command, either of which can be left unspecified. Upon
Junio C Hamanoc14e6ad2014-10-31 20:25:531070checkout, when the <code>smudge</code> command is specified, the command is
Junio C Hamano361c1332007-11-14 12:17:221071fed the blob object from its standard input, and its standard
1072output is used to update the worktree file. Similarly, the
Junio C Hamanoc14e6ad2014-10-31 20:25:531073<code>clean</code> command is used to convert the contents of worktree file
Junio C Hamanof2f28b12016-10-31 21:41:581074upon checkin. By default these commands process only a single
1075blob and terminate. If a long running <code>process</code> filter is used
1076in place of <code>clean</code> and/or <code>smudge</code> filters, then Git can process
1077all blobs with a single filter command invocation for the entire
1078life of a single Git command, for example <code>git add --all</code>. If a
1079long running <code>process</code> filter is configured then it always takes
1080precedence over a configured single blob filter. See section
1081below for the description of the protocol used to communicate with
1082a <code>process</code> filter.</p></div>
Junio C Hamano90a5b7b2012-02-28 23:40:311083<div class="paragraph"><p>One use of the content filtering is to massage the content into a shape
1084that is more convenient for the platform, filesystem, and the user to use.
1085For this mode of operation, the key phrase here is "more convenient" and
1086not "turning something unusable into usable". In other words, the intent
1087is that if someone unsets the filter driver definition, or does not have
1088the appropriate filter program, the project should still be usable.</p></div>
1089<div class="paragraph"><p>Another use of the content filtering is to store the content that cannot
1090be directly used in the repository (e.g. a UUID that refers to the true
Junio C Hamano076ffcc2013-02-06 05:13:211091content stored outside Git, or an encrypted content) and turn it into a
Junio C Hamano90a5b7b2012-02-28 23:40:311092usable form upon checkout (e.g. download the external content, or decrypt
1093the encrypted content).</p></div>
1094<div class="paragraph"><p>These two filters behave differently, and by default, a filter is taken as
1095the former, massaging the contents into more convenient shape. A missing
1096filter driver definition in the config, or a filter driver that exits with
1097a non-zero status, is not an error but makes the filter a no-op passthru.</p></div>
1098<div class="paragraph"><p>You can declare that a filter turns a content that by itself is unusable
1099into a usable content by setting the filter.&lt;driver&gt;.required configuration
Junio C Hamanoc14e6ad2014-10-31 20:25:531100variable to <code>true</code>.</p></div>
Junio C Hamano4886c772017-11-27 03:33:281101<div class="paragraph"><p>Note: Whenever the clean filter is changed, the repo should be renormalized:
1102$ git add --renormalize .</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531103<div class="paragraph"><p>For example, in .gitattributes, you would assign the <code>filter</code>
Junio C Hamano6a548ef2009-12-17 00:16:201104attribute for paths.</p></div>
1105<div class="listingblock">
1106<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531107<pre><code>*.c filter=indent</code></pre>
Junio C Hamano6a548ef2009-12-17 00:16:201108</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581109<div class="paragraph"><p>Then you would define a "filter.indent.clean" and "filter.indent.smudge"
Junio C Hamano6a548ef2009-12-17 00:16:201110configuration in your .git/config to specify a pair of commands to
1111modify the contents of C programs when the source files are checked
1112in ("clean" is run) and checked out (no change is made because the
1113command is "cat").</p></div>
1114<div class="listingblock">
1115<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531116<pre><code>[filter "indent"]
Junio C Hamano6a548ef2009-12-17 00:16:201117 clean = indent
Junio C Hamanoc14e6ad2014-10-31 20:25:531118 smudge = cat</code></pre>
Junio C Hamano6a548ef2009-12-17 00:16:201119</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531120<div class="paragraph"><p>For best results, <code>clean</code> should not alter its output further if it is
Junio C Hamanoeef01fe2010-12-13 08:31:581121run twice ("clean&#8594;clean" should be equivalent to "clean"), and
Junio C Hamanoc14e6ad2014-10-31 20:25:531122multiple <code>smudge</code> commands should not alter <code>clean</code>'s output
Junio C Hamanoeef01fe2010-12-13 08:31:581123("smudge&#8594;smudge&#8594;clean" should be equivalent to "clean"). See the
Junio C Hamano2db3e752010-09-03 21:33:061124section on merging below.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581125<div class="paragraph"><p>The "indent" filter is well-behaved in this regard: it will not modify
Junio C Hamano2db3e752010-09-03 21:33:061126input that is already correctly indented. In this case, the lack of a
Junio C Hamanoeef01fe2010-12-13 08:31:581127smudge filter means that the clean filter <em>must</em> accept its own output
Junio C Hamano2db3e752010-09-03 21:33:061128without modifying it.</p></div>
Junio C Hamano90a5b7b2012-02-28 23:40:311129<div class="paragraph"><p>If a filter <em>must</em> succeed in order to make the stored contents usable,
Junio C Hamanoc14e6ad2014-10-31 20:25:531130you can declare that the filter is <code>required</code>, in the configuration:</p></div>
Junio C Hamano90a5b7b2012-02-28 23:40:311131<div class="listingblock">
1132<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531133<pre><code>[filter "crypt"]
Junio C Hamano90a5b7b2012-02-28 23:40:311134 clean = openssl enc ...
1135 smudge = openssl enc -d ...
Junio C Hamanoc14e6ad2014-10-31 20:25:531136 required</code></pre>
Junio C Hamano90a5b7b2012-02-28 23:40:311137</div></div>
Junio C Hamanoe0552e42011-01-06 00:34:471138<div class="paragraph"><p>Sequence "%f" on the filter command line is replaced with the name of
1139the file the filter is working on. A filter might use this in keyword
1140substitution. For example:</p></div>
1141<div class="listingblock">
1142<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531143<pre><code>[filter "p4"]
Junio C Hamanoe0552e42011-01-06 00:34:471144 clean = git-p4-filter --clean %f
Junio C Hamanoc14e6ad2014-10-31 20:25:531145 smudge = git-p4-filter --smudge %f</code></pre>
Junio C Hamanoe0552e42011-01-06 00:34:471146</div></div>
Junio C Hamanoe548d1b2016-08-08 22:26:491147<div class="paragraph"><p>Note that "%f" is the name of the path that is being worked on. Depending
1148on the version that is being filtered, the corresponding file on disk may
1149not exist, or may have different contents. So, smudge and clean commands
1150should not try to access the file on disk, but only act as filters on the
1151content provided to them on standard input.</p></div>
Junio C Hamano9d971152012-12-19 00:43:111152</div>
1153<div class="sect3">
Junio C Hamanof2f28b12016-10-31 21:41:581154<h4 id="_long_running_filter_process">Long Running Filter Process</h4>
1155<div class="paragraph"><p>If the filter command (a string value) is defined via
1156<code>filter.&lt;driver&gt;.process</code> then Git can process all blobs with a
1157single filter invocation for the entire life of a single Git
Junio C Hamano640779d2018-02-14 01:29:141158command. This is achieved by using the long-running process protocol
1159(described in technical/long-running-process-protocol.txt).</p></div>
1160<div class="paragraph"><p>When Git encounters the first file that needs to be cleaned or smudged,
1161it starts the filter and performs the handshake. In the handshake, the
1162welcome message sent by Git is "git-filter-client", only version 2 is
1163suppported, and the supported capabilities are "clean", "smudge", and
1164"delay".</p></div>
Junio C Hamanof2f28b12016-10-31 21:41:581165<div class="paragraph"><p>Afterwards Git sends a list of "key=value" pairs terminated with
1166a flush packet. The list will contain at least the filter command
1167(based on the supported capabilities) and the pathname of the file
1168to filter relative to the repository root. Right after the flush packet
1169Git sends the content split in zero or more pkt-line packets and a
1170flush packet to terminate content. Please note, that the filter
1171must not send any response before it received the content and the
Junio C Hamano9e35abf2016-12-27 22:37:271172final flush packet. Also note that the "value" of a "key=value" pair
1173can contain the "=" character whereas the key would never contain
1174that character.</p></div>
Junio C Hamanof2f28b12016-10-31 21:41:581175<div class="listingblock">
1176<div class="content">
1177<pre><code>packet: git&gt; command=smudge
1178packet: git&gt; pathname=path/testfile.dat
1179packet: git&gt; 0000
1180packet: git&gt; CONTENT
1181packet: git&gt; 0000</code></pre>
1182</div></div>
1183<div class="paragraph"><p>The filter is expected to respond with a list of "key=value" pairs
1184terminated with a flush packet. If the filter does not experience
1185problems then the list must contain a "success" status. Right after
1186these packets the filter is expected to send the content in zero
1187or more pkt-line packets and a flush packet at the end. Finally, a
1188second list of "key=value" pairs terminated with a flush packet
1189is expected. The filter can change the status in the second list
1190or keep the status as is with an empty list. Please note that the
1191empty list must be terminated with a flush packet regardless.</p></div>
1192<div class="listingblock">
1193<div class="content">
1194<pre><code>packet: git&lt; status=success
1195packet: git&lt; 0000
1196packet: git&lt; SMUDGED_CONTENT
1197packet: git&lt; 0000
1198packet: git&lt; 0000 # empty list, keep "status=success" unchanged!</code></pre>
1199</div></div>
1200<div class="paragraph"><p>If the result content is empty then the filter is expected to respond
1201with a "success" status and a flush packet to signal the empty content.</p></div>
1202<div class="listingblock">
1203<div class="content">
1204<pre><code>packet: git&lt; status=success
1205packet: git&lt; 0000
1206packet: git&lt; 0000 # empty content!
1207packet: git&lt; 0000 # empty list, keep "status=success" unchanged!</code></pre>
1208</div></div>
1209<div class="paragraph"><p>In case the filter cannot or does not want to process the content,
1210it is expected to respond with an "error" status.</p></div>
1211<div class="listingblock">
1212<div class="content">
1213<pre><code>packet: git&lt; status=error
1214packet: git&lt; 0000</code></pre>
1215</div></div>
1216<div class="paragraph"><p>If the filter experiences an error during processing, then it can
1217send the status "error" after the content was (partially or
1218completely) sent.</p></div>
1219<div class="listingblock">
1220<div class="content">
1221<pre><code>packet: git&lt; status=success
1222packet: git&lt; 0000
1223packet: git&lt; HALF_WRITTEN_ERRONEOUS_CONTENT
1224packet: git&lt; 0000
1225packet: git&lt; status=error
1226packet: git&lt; 0000</code></pre>
1227</div></div>
1228<div class="paragraph"><p>In case the filter cannot or does not want to process the content
1229as well as any future content for the lifetime of the Git process,
1230then it is expected to respond with an "abort" status at any point
1231in the protocol.</p></div>
1232<div class="listingblock">
1233<div class="content">
1234<pre><code>packet: git&lt; status=abort
1235packet: git&lt; 0000</code></pre>
1236</div></div>
1237<div class="paragraph"><p>Git neither stops nor restarts the filter process in case the
1238"error"/"abort" status is set. However, Git sets its exit code
1239according to the <code>filter.&lt;driver&gt;.required</code> flag, mimicking the
1240behavior of the <code>filter.&lt;driver&gt;.clean</code> / <code>filter.&lt;driver&gt;.smudge</code>
1241mechanism.</p></div>
1242<div class="paragraph"><p>If the filter dies during the communication or does not adhere to
1243the protocol then Git will stop the filter process and restart it
1244with the next file that needs to be processed. Depending on the
1245<code>filter.&lt;driver&gt;.required</code> flag Git will interpret that as error.</p></div>
Junio C Hamano4b2a6c12017-08-22 18:32:371246</div>
1247<div class="sect3">
1248<h4 id="_delay">Delay</h4>
1249<div class="paragraph"><p>If the filter supports the "delay" capability, then Git can send the
1250flag "can-delay" after the filter command and pathname. This flag
1251denotes that the filter can delay filtering the current blob (e.g. to
1252compensate network latencies) by responding with no content but with
1253the status "delayed" and a flush packet.</p></div>
1254<div class="listingblock">
1255<div class="content">
1256<pre><code>packet: git&gt; command=smudge
1257packet: git&gt; pathname=path/testfile.dat
1258packet: git&gt; can-delay=1
1259packet: git&gt; 0000
1260packet: git&gt; CONTENT
1261packet: git&gt; 0000
1262packet: git&lt; status=delayed
1263packet: git&lt; 0000</code></pre>
1264</div></div>
1265<div class="paragraph"><p>If the filter supports the "delay" capability then it must support the
1266"list_available_blobs" command. If Git sends this command, then the
1267filter is expected to return a list of pathnames representing blobs
1268that have been delayed earlier and are now available.
1269The list must be terminated with a flush packet followed
1270by a "success" status that is also terminated with a flush packet. If
1271no blobs for the delayed paths are available, yet, then the filter is
1272expected to block the response until at least one blob becomes
1273available. The filter can tell Git that it has no more delayed blobs
1274by sending an empty list. As soon as the filter responds with an empty
1275list, Git stops asking. All blobs that Git has not received at this
1276point are considered missing and will result in an error.</p></div>
1277<div class="listingblock">
1278<div class="content">
1279<pre><code>packet: git&gt; command=list_available_blobs
1280packet: git&gt; 0000
1281packet: git&lt; pathname=path/testfile.dat
1282packet: git&lt; pathname=path/otherfile.dat
1283packet: git&lt; 0000
1284packet: git&lt; status=success
1285packet: git&lt; 0000</code></pre>
1286</div></div>
1287<div class="paragraph"><p>After Git received the pathnames, it will request the corresponding
1288blobs again. These requests contain a pathname and an empty content
1289section. The filter is expected to respond with the smudged content
1290in the usual way as explained above.</p></div>
1291<div class="listingblock">
1292<div class="content">
1293<pre><code>packet: git&gt; command=smudge
1294packet: git&gt; pathname=path/testfile.dat
1295packet: git&gt; 0000
1296packet: git&gt; 0000 # empty content!
1297packet: git&lt; status=success
1298packet: git&lt; 0000
1299packet: git&lt; SMUDGED_CONTENT
1300packet: git&lt; 0000
1301packet: git&lt; 0000 # empty list, keep "status=success" unchanged!</code></pre>
1302</div></div>
1303</div>
1304<div class="sect3">
1305<h4 id="_example">Example</h4>
Junio C Hamanof2f28b12016-10-31 21:41:581306<div class="paragraph"><p>A long running filter demo implementation can be found in
1307<code>contrib/long-running-filter/example.pl</code> located in the Git
1308core repository. If you develop your own long running filter
1309process then the <code>GIT_TRACE_PACKET</code> environment variables can be
1310very helpful for debugging (see <a href="git.html">git(1)</a>).</p></div>
1311<div class="paragraph"><p>Please note that you cannot use an existing <code>filter.&lt;driver&gt;.clean</code>
1312or <code>filter.&lt;driver&gt;.smudge</code> command with <code>filter.&lt;driver&gt;.process</code>
1313because the former two use a different inter process communication
1314protocol than the latter one.</p></div>
1315</div>
1316<div class="sect3">
Junio C Hamanoba4b9282008-07-06 05:20:311317<h4 id="_interaction_between_checkin_checkout_attributes">Interaction between checkin/checkout attributes</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581318<div class="paragraph"><p>In the check-in codepath, the worktree file is first converted
Junio C Hamanoc14e6ad2014-10-31 20:25:531319with <code>filter</code> driver (if specified and corresponding driver
1320defined), then the result is processed with <code>ident</code> (if
1321specified), and then finally with <code>text</code> (again, if specified
Junio C Hamanoba4b9282008-07-06 05:20:311322and applicable).</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581323<div class="paragraph"><p>In the check-out codepath, the blob content is first converted
Junio C Hamanoc14e6ad2014-10-31 20:25:531324with <code>text</code>, and then <code>ident</code> and fed to <code>filter</code>.</p></div>
Junio C Hamano9d971152012-12-19 00:43:111325</div>
1326<div class="sect3">
Junio C Hamano2db3e752010-09-03 21:33:061327<h4 id="_merging_branches_with_differing_checkin_checkout_attributes">Merging branches with differing checkin/checkout attributes</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581328<div class="paragraph"><p>If you have added attributes to a file that cause the canonical
Junio C Hamano2db3e752010-09-03 21:33:061329repository format for that file to change, such as adding a
1330clean/smudge filter or text/eol/ident attributes, merging anything
1331where the attribute is not in place would normally cause merge
1332conflicts.</p></div>
Junio C Hamano076ffcc2013-02-06 05:13:211333<div class="paragraph"><p>To prevent these unnecessary merge conflicts, Git can be told to run a
Junio C Hamano2db3e752010-09-03 21:33:061334virtual check-out and check-in of all three stages of a file when
Junio C Hamanoc14e6ad2014-10-31 20:25:531335resolving a three-way merge by setting the <code>merge.renormalize</code>
Junio C Hamano2db3e752010-09-03 21:33:061336configuration variable. This prevents changes caused by check-in
1337conversion from causing spurious merge conflicts when a converted file
1338is merged with an unconverted file.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581339<div class="paragraph"><p>As long as a "smudge&#8594;clean" results in the same output as a "clean"
Junio C Hamano2db3e752010-09-03 21:33:061340even on files that are already smudged, this strategy will
1341automatically resolve all filter-related conflicts. Filters that do
1342not act in this way may cause additional merge conflicts that must be
1343resolved manually.</p></div>
Junio C Hamano9d971152012-12-19 00:43:111344</div>
1345</div>
1346<div class="sect2">
1347<h3 id="_generating_diff_text">Generating diff text</h3>
1348<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:531349<h4 id="_code_diff_code"><code>diff</code></h4>
1350<div class="paragraph"><p>The attribute <code>diff</code> affects how Git generates diffs for particular
Junio C Hamano076ffcc2013-02-06 05:13:211351files. It can tell Git whether to generate a textual patch for the path
Junio C Hamano28363492008-11-14 08:26:311352or to treat the path as a binary file. It can also affect what line is
Junio C Hamanoc14e6ad2014-10-31 20:25:531353shown on the hunk header <code>@@ -k,l +n,m @@</code> line, tell Git to use an
Junio C Hamano076ffcc2013-02-06 05:13:211354external command to generate the diff, or ask Git to convert binary
Junio C Hamano28363492008-11-14 08:26:311355files to a text format before generating the diff.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581356<div class="dlist"><dl>
1357<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:131358Set
1359</dt>
1360<dd>
1361<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531362 A path to which the <code>diff</code> attribute is set is treated
Junio C Hamanoe90436a2007-04-22 07:22:131363 as text, even when they contain byte values that
1364 normally never appear in text files, such as NUL.
1365</p>
1366</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581367<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:131368Unset
1369</dt>
1370<dd>
1371<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531372 A path to which the <code>diff</code> attribute is unset will
1373 generate <code>Binary files differ</code> (or a binary patch, if
Junio C Hamano28363492008-11-14 08:26:311374 binary patches are enabled).
Junio C Hamanoe90436a2007-04-22 07:22:131375</p>
1376</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581377<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:131378Unspecified
1379</dt>
1380<dd>
1381<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531382 A path to which the <code>diff</code> attribute is unspecified
Junio C Hamanoe90436a2007-04-22 07:22:131383 first gets its contents inspected, and if it looks like
Junio C Hamano8e61f1f2014-09-11 21:53:451384 text and is smaller than core.bigFileThreshold, it is treated
Junio C Hamanoc14e6ad2014-10-31 20:25:531385 as text. Otherwise it would generate <code>Binary files differ</code>.
Junio C Hamanoe90436a2007-04-22 07:22:131386</p>
1387</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581388<dt class="hdlist1">
Junio C Hamano9db95ca2007-04-23 07:27:051389String
1390</dt>
1391<dd>
1392<p>
Junio C Hamano28363492008-11-14 08:26:311393 Diff is shown using the specified diff driver. Each driver may
1394 specify one or more options, as described in the following
1395 section. The options for the diff driver "foo" are defined
1396 by the configuration variables in the "diff.foo" section of the
Junio C Hamano076ffcc2013-02-06 05:13:211397 Git config file.
Junio C Hamano9db95ca2007-04-23 07:27:051398</p>
1399</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311400</dl></div>
Junio C Hamano9d971152012-12-19 00:43:111401</div>
1402<div class="sect3">
Junio C Hamano28363492008-11-14 08:26:311403<h4 id="_defining_an_external_diff_driver">Defining an external diff driver</h4>
Junio C Hamanoc14e6ad2014-10-31 20:25:531404<div class="paragraph"><p>The definition of a diff driver is done in <code>gitconfig</code>, not
1405<code>gitattributes</code> file, so strictly speaking this manual page is a
Junio C Hamanoba4b9282008-07-06 05:20:311406wrong place to talk about it. However&#8230;</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531407<div class="paragraph"><p>To define an external diff driver <code>jcdiff</code>, add a section to your
1408<code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p></div>
Junio C Hamano9db95ca2007-04-23 07:27:051409<div class="listingblock">
1410<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531411<pre><code>[diff "jcdiff"]
1412 command = j-c-diff</code></pre>
Junio C Hamano9db95ca2007-04-23 07:27:051413</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531414<div class="paragraph"><p>When Git needs to show you a diff for the path with <code>diff</code>
1415attribute set to <code>jcdiff</code>, it calls the command you specified
1416with the above configuration, i.e. <code>j-c-diff</code>, with 7
1417parameters, just like <code>GIT_EXTERNAL_DIFF</code> program is called.
Junio C Hamanoa28a9202012-06-21 07:08:231418See <a href="git.html">git(1)</a> for details.</p></div>
Junio C Hamano9d971152012-12-19 00:43:111419</div>
1420<div class="sect3">
Junio C Hamanoba4b9282008-07-06 05:20:311421<h4 id="_defining_a_custom_hunk_header">Defining a custom hunk-header</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581422<div class="paragraph"><p>Each group of changes (called a "hunk") in the textual diff output
Junio C Hamanoba4b9282008-07-06 05:20:311423is prefixed with a line of the form:</p></div>
Junio C Hamano2a8f6dc2007-07-09 08:48:381424<div class="literalblock">
1425<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531426<pre><code>@@ -k,l +n,m @@ TEXT</code></pre>
Junio C Hamano2a8f6dc2007-07-09 08:48:381427</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581428<div class="paragraph"><p>This is called a <em>hunk header</em>. The "TEXT" portion is by default a line
Junio C Hamano5e4d8de2008-09-19 06:27:021429that begins with an alphabet, an underscore or a dollar sign; this
1430matches what GNU <em>diff -p</em> output uses. This default selection however
1431is not suited for some contents, and you can use a customized pattern
1432to make a selection.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531433<div class="paragraph"><p>First, in .gitattributes, you would assign the <code>diff</code> attribute
Junio C Hamanoba4b9282008-07-06 05:20:311434for paths.</p></div>
Junio C Hamano2a8f6dc2007-07-09 08:48:381435<div class="listingblock">
1436<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531437<pre><code>*.tex diff=tex</code></pre>
Junio C Hamano2a8f6dc2007-07-09 08:48:381438</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581439<div class="paragraph"><p>Then, you would define a "diff.tex.xfuncname" configuration to
Junio C Hamano2a8f6dc2007-07-09 08:48:381440specify a regular expression that matches a line that you would
Junio C Hamano3bd66e92009-04-18 06:17:561441want to appear as the hunk header "TEXT". Add a section to your
Junio C Hamanoc14e6ad2014-10-31 20:25:531442<code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p></div>
Junio C Hamano2a8f6dc2007-07-09 08:48:381443<div class="listingblock">
1444<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531445<pre><code>[diff "tex"]
1446 xfuncname = "^(\\\\(sub)*section\\{.*)$"</code></pre>
Junio C Hamano2a8f6dc2007-07-09 08:48:381447</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581448<div class="paragraph"><p>Note. A single level of backslashes are eaten by the
Junio C Hamano2a8f6dc2007-07-09 08:48:381449configuration file parser, so you would need to double the
1450backslashes; the pattern above picks a line that begins with a
Junio C Hamanoc14e6ad2014-10-31 20:25:531451backslash, and zero or more occurrences of <code>sub</code> followed by
1452<code>section</code> followed by open brace, to the end of line.</p></div>
1453<div class="paragraph"><p>There are a few built-in patterns to make this easier, and <code>tex</code>
Junio C Hamano2a8f6dc2007-07-09 08:48:381454is one of them, so you do not have to write the above in your
1455configuration file (you still need to enable this with the
Junio C Hamanoc14e6ad2014-10-31 20:25:531456attribute mechanism, via <code>.gitattributes</code>). The following built in
Junio C Hamanoa76cb0d2008-08-13 20:04:101457patterns are available:</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581458<div class="ulist"><ul>
Junio C Hamanoa76cb0d2008-08-13 20:04:101459<li>
1460<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531461<code>ada</code> suitable for source code in the Ada language.
Junio C Hamano4f07aec2012-09-25 19:08:441462</p>
1463</li>
1464<li>
1465<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531466<code>bibtex</code> suitable for files with BibTeX coded references.
Junio C Hamanoa76cb0d2008-08-13 20:04:101467</p>
1468</li>
1469<li>
1470<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531471<code>cpp</code> suitable for source code in the C and C++ languages.
Junio C Hamano20d47e32009-01-26 06:36:021472</p>
1473</li>
1474<li>
1475<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531476<code>csharp</code> suitable for source code in the C# language.
Junio C Hamano53ba6d02010-08-22 07:25:121477</p>
1478</li>
1479<li>
1480<p>
Junio C Hamanofedb1b42016-06-20 21:23:401481<code>css</code> suitable for cascading style sheets.
1482</p>
1483</li>
1484<li>
1485<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531486<code>fortran</code> suitable for source code in the Fortran language.
Junio C Hamano3b4609d2010-09-30 00:04:341487</p>
1488</li>
1489<li>
1490<p>
Junio C Hamanod7ed4042015-08-03 19:43:001491<code>fountain</code> suitable for Fountain documents.
1492</p>
1493</li>
1494<li>
1495<p>
Junio C Hamanoa25ccc42018-03-08 21:36:141496<code>golang</code> suitable for source code in the Go language.
1497</p>
1498</li>
1499<li>
1500<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531501<code>html</code> suitable for HTML/XHTML documents.
Junio C Hamanof24b8062008-09-09 01:34:391502</p>
1503</li>
1504<li>
1505<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531506<code>java</code> suitable for source code in the Java language.
Junio C Hamanoa76cb0d2008-08-13 20:04:101507</p>
1508</li>
1509<li>
1510<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531511<code>matlab</code> suitable for source code in the MATLAB language.
Junio C Hamano92887a32011-12-07 00:26:291512</p>
1513</li>
1514<li>
1515<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531516<code>objc</code> suitable for source code in the Objective-C language.
Junio C Hamanoa476efa2008-10-10 15:31:421517</p>
1518</li>
1519<li>
1520<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531521<code>pascal</code> suitable for source code in the Pascal/Delphi language.
Junio C Hamanoa76cb0d2008-08-13 20:04:101522</p>
1523</li>
1524<li>
1525<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531526<code>perl</code> suitable for source code in the Perl language.
Junio C Hamano9b6fafe2011-01-14 00:43:221527</p>
1528</li>
1529<li>
1530<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531531<code>php</code> suitable for source code in the PHP language.
Junio C Hamanof24b8062008-09-09 01:34:391532</p>
1533</li>
1534<li>
1535<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531536<code>python</code> suitable for source code in the Python language.
Junio C Hamano3f2f6e52008-08-21 10:34:221537</p>
1538</li>
1539<li>
1540<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531541<code>ruby</code> suitable for source code in the Ruby language.
Junio C Hamanoa76cb0d2008-08-13 20:04:101542</p>
1543</li>
1544<li>
1545<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531546<code>tex</code> suitable for source code for LaTeX documents.
Junio C Hamanoa76cb0d2008-08-13 20:04:101547</p>
1548</li>
1549</ul></div>
Junio C Hamano9d971152012-12-19 00:43:111550</div>
1551<div class="sect3">
Junio C Hamano20d47e32009-01-26 06:36:021552<h4 id="_customizing_word_diff">Customizing word diff</h4>
Junio C Hamanoc14e6ad2014-10-31 20:25:531553<div class="paragraph"><p>You can customize the rules that <code>git diff --word-diff</code> uses to
Junio C Hamano20d47e32009-01-26 06:36:021554split words in a line, by specifying an appropriate regular expression
1555in the "diff.*.wordRegex" configuration variable. For example, in TeX
1556a backslash followed by a sequence of letters forms a command, but
1557several such commands can be run together without intervening
Junio C Hamano3bd66e92009-04-18 06:17:561558whitespace. To separate them, use a regular expression in your
Junio C Hamanoc14e6ad2014-10-31 20:25:531559<code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p></div>
Junio C Hamano20d47e32009-01-26 06:36:021560<div class="listingblock">
1561<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531562<pre><code>[diff "tex"]
1563 wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"</code></pre>
Junio C Hamano20d47e32009-01-26 06:36:021564</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581565<div class="paragraph"><p>A built-in pattern is provided for all languages listed in the
Junio C Hamano20d47e32009-01-26 06:36:021566previous section.</p></div>
Junio C Hamano9d971152012-12-19 00:43:111567</div>
1568<div class="sect3">
Junio C Hamano28363492008-11-14 08:26:311569<h4 id="_performing_text_diffs_of_binary_files">Performing text diffs of binary files</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581570<div class="paragraph"><p>Sometimes it is desirable to see the diff of a text-converted
Junio C Hamano28363492008-11-14 08:26:311571version of some binary files. For example, a word processor
1572document can be converted to an ASCII text representation, and
1573the diff of the text shown. Even though this conversion loses
1574some information, the resulting diff is useful for human
1575viewing (but cannot be applied directly).</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531576<div class="paragraph"><p>The <code>textconv</code> config option is used to define a program for
Junio C Hamano28363492008-11-14 08:26:311577performing such a conversion. The program should take a single
1578argument, the name of a file to convert, and produce the
1579resulting text on stdout.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581580<div class="paragraph"><p>For example, to show the diff of the exif information of a
Junio C Hamano28363492008-11-14 08:26:311581file instead of the binary information (assuming you have the
Junio C Hamano3bd66e92009-04-18 06:17:561582exif tool installed), add the following section to your
Junio C Hamanoc14e6ad2014-10-31 20:25:531583<code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file):</p></div>
Junio C Hamano28363492008-11-14 08:26:311584<div class="listingblock">
1585<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531586<pre><code>[diff "jpg"]
1587 textconv = exif</code></pre>
Junio C Hamano28363492008-11-14 08:26:311588</div></div>
1589<div class="admonitionblock">
1590<table><tr>
1591<td class="icon">
1592<div class="title">Note</div>
1593</td>
1594<td class="content">The text conversion is generally a one-way conversion;
1595in this example, we lose the actual image contents and focus
1596just on the text data. This means that diffs generated by
Junio C Hamanoeef01fe2010-12-13 08:31:581597textconv are <em>not</em> suitable for applying. For this reason,
Junio C Hamanoc14e6ad2014-10-31 20:25:531598only <code>git diff</code> and the <code>git log</code> family of commands (i.e.,
1599log, whatchanged, show) will perform text conversion. <code>git
1600format-patch</code> will never generate this output. If you want to
Junio C Hamano28363492008-11-14 08:26:311601send somebody a text-converted diff of a binary file (e.g.,
1602because it quickly conveys the changes you have made), you
Junio C Hamanoeef01fe2010-12-13 08:31:581603should generate it separately and send it as a comment <em>in
1604addition to</em> the usual binary diff that you might send.</td>
Junio C Hamano28363492008-11-14 08:26:311605</tr></table>
1606</div>
Junio C Hamanoeef01fe2010-12-13 08:31:581607<div class="paragraph"><p>Because text conversion can be slow, especially when doing a
Junio C Hamanoc14e6ad2014-10-31 20:25:531608large number of them with <code>git log -p</code>, Git provides a mechanism
Junio C Hamanocb39aea2010-05-09 07:24:481609to cache the output and use it in future diffs. To enable
Junio C Hamanoeef01fe2010-12-13 08:31:581610caching, set the "cachetextconv" variable in your diff driver&#8217;s
Junio C Hamanocb39aea2010-05-09 07:24:481611config. For example:</p></div>
1612<div class="listingblock">
1613<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531614<pre><code>[diff "jpg"]
Junio C Hamanocb39aea2010-05-09 07:24:481615 textconv = exif
Junio C Hamanoc14e6ad2014-10-31 20:25:531616 cachetextconv = true</code></pre>
Junio C Hamanocb39aea2010-05-09 07:24:481617</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581618<div class="paragraph"><p>This will cache the result of running "exif" on each blob
Junio C Hamanocb39aea2010-05-09 07:24:481619indefinitely. If you change the textconv config variable for a
Junio C Hamano076ffcc2013-02-06 05:13:211620diff driver, Git will automatically invalidate the cache entries
Junio C Hamanocb39aea2010-05-09 07:24:481621and re-run the textconv filter. If you want to invalidate the
1622cache manually (e.g., because your version of "exif" was updated
1623and now produces better output), you can remove the cache
Junio C Hamanoc14e6ad2014-10-31 20:25:531624manually with <code>git update-ref -d refs/notes/textconv/jpg</code> (where
Junio C Hamanocb39aea2010-05-09 07:24:481625"jpg" is the name of the diff driver, as in the example above).</p></div>
Junio C Hamano9d971152012-12-19 00:43:111626</div>
1627<div class="sect3">
Junio C Hamanof93530e2011-05-25 23:59:591628<h4 id="_choosing_textconv_versus_external_diff">Choosing textconv versus external diff</h4>
1629<div class="paragraph"><p>If you want to show differences between binary or specially-formatted
1630blobs in your repository, you can choose to use either an external diff
1631command, or to use textconv to convert them to a diff-able text format.
1632Which method you choose depends on your exact situation.</p></div>
1633<div class="paragraph"><p>The advantage of using an external diff command is flexibility. You are
1634not bound to find line-oriented changes, nor is it necessary for the
1635output to resemble unified diff. You are free to locate and report
1636changes in the most appropriate way for your data format.</p></div>
1637<div class="paragraph"><p>A textconv, by comparison, is much more limiting. You provide a
Junio C Hamano076ffcc2013-02-06 05:13:211638transformation of the data into a line-oriented text format, and Git
Junio C Hamanof93530e2011-05-25 23:59:591639uses its regular diff tools to generate the output. There are several
1640advantages to choosing this method:</p></div>
1641<div class="olist arabic"><ol class="arabic">
1642<li>
1643<p>
1644Ease of use. It is often much simpler to write a binary to text
1645 transformation than it is to perform your own diff. In many cases,
1646 existing programs can be used as textconv filters (e.g., exif,
1647 odt2txt).
1648</p>
1649</li>
1650<li>
1651<p>
1652Git diff features. By performing only the transformation step
Junio C Hamano076ffcc2013-02-06 05:13:211653 yourself, you can still utilize many of Git&#8217;s diff features,
Junio C Hamanof93530e2011-05-25 23:59:591654 including colorization, word-diff, and combined diffs for merges.
1655</p>
1656</li>
1657<li>
1658<p>
1659Caching. Textconv caching can speed up repeated diffs, such as those
Junio C Hamanoc14e6ad2014-10-31 20:25:531660 you might trigger by running <code>git log -p</code>.
Junio C Hamanof93530e2011-05-25 23:59:591661</p>
1662</li>
1663</ol></div>
Junio C Hamano9d971152012-12-19 00:43:111664</div>
1665<div class="sect3">
Junio C Hamano9b6fafe2011-01-14 00:43:221666<h4 id="_marking_files_as_binary">Marking files as binary</h4>
1667<div class="paragraph"><p>Git usually guesses correctly whether a blob contains text or binary
1668data by examining the beginning of the contents. However, sometimes you
1669may want to override its decision, either because a blob contains binary
1670data later in the file, or because the content, while technically
1671composed of text characters, is opaque to a human reader. For example,
Junio C Hamanofb5ffde2014-11-04 22:38:561672many postscript files contain only ASCII characters, but produce noisy
Junio C Hamano9b6fafe2011-01-14 00:43:221673and meaningless diffs.</p></div>
1674<div class="paragraph"><p>The simplest way to mark a file as binary is to unset the diff
Junio C Hamanoc14e6ad2014-10-31 20:25:531675attribute in the <code>.gitattributes</code> file:</p></div>
Junio C Hamano9b6fafe2011-01-14 00:43:221676<div class="listingblock">
1677<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531678<pre><code>*.ps -diff</code></pre>
Junio C Hamano9b6fafe2011-01-14 00:43:221679</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531680<div class="paragraph"><p>This will cause Git to generate <code>Binary files differ</code> (or a binary
Junio C Hamano9b6fafe2011-01-14 00:43:221681patch, if binary patches are enabled) instead of a regular diff.</p></div>
1682<div class="paragraph"><p>However, one may also want to specify other diff driver attributes. For
Junio C Hamanoc14e6ad2014-10-31 20:25:531683example, you might want to use <code>textconv</code> to convert postscript files to
Junio C Hamanofb5ffde2014-11-04 22:38:561684an ASCII representation for human viewing, but otherwise treat them as
Junio C Hamanoc14e6ad2014-10-31 20:25:531685binary files. You cannot specify both <code>-diff</code> and <code>diff=ps</code> attributes.
1686The solution is to use the <code>diff.*.binary</code> config option:</p></div>
Junio C Hamano9b6fafe2011-01-14 00:43:221687<div class="listingblock">
1688<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531689<pre><code>[diff "ps"]
Junio C Hamano9b6fafe2011-01-14 00:43:221690 textconv = ps2ascii
Junio C Hamanoc14e6ad2014-10-31 20:25:531691 binary = true</code></pre>
Junio C Hamano9b6fafe2011-01-14 00:43:221692</div></div>
Junio C Hamano9d971152012-12-19 00:43:111693</div>
1694</div>
1695<div class="sect2">
1696<h3 id="_performing_a_three_way_merge">Performing a three-way merge</h3>
1697<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:531698<h4 id="_code_merge_code"><code>merge</code></h4>
1699<div class="paragraph"><p>The attribute <code>merge</code> affects how three versions of a file are
1700merged when a file-level merge is necessary during <code>git merge</code>,
1701and other commands such as <code>git revert</code> and <code>git cherry-pick</code>.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581702<div class="dlist"><dl>
1703<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:131704Set
1705</dt>
1706<dd>
1707<p>
1708 Built-in 3-way merge driver is used to merge the
Junio C Hamanoc14e6ad2014-10-31 20:25:531709 contents in a way similar to <em>merge</em> command of <code>RCS</code>
Junio C Hamanoe90436a2007-04-22 07:22:131710 suite. This is suitable for ordinary text files.
1711</p>
1712</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581713<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:131714Unset
1715</dt>
1716<dd>
1717<p>
1718 Take the version from the current branch as the
1719 tentative merge result, and declare that the merge has
Junio C Hamanofa28cb12011-03-19 01:35:351720 conflicts. This is suitable for binary files that do
Junio C Hamanoe90436a2007-04-22 07:22:131721 not have a well-defined merge semantics.
1722</p>
1723</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581724<dt class="hdlist1">
Junio C Hamanoe90436a2007-04-22 07:22:131725Unspecified
1726</dt>
1727<dd>
1728<p>
1729 By default, this uses the same built-in 3-way merge
Junio C Hamanoc14e6ad2014-10-31 20:25:531730 driver as is the case when the <code>merge</code> attribute is set.
1731 However, the <code>merge.default</code> configuration variable can name
Junio C Hamanofa28cb12011-03-19 01:35:351732 different merge driver to be used with paths for which the
Junio C Hamanoc14e6ad2014-10-31 20:25:531733 <code>merge</code> attribute is unspecified.
Junio C Hamanoe90436a2007-04-22 07:22:131734</p>
1735</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581736<dt class="hdlist1">
Junio C Hamano9db95ca2007-04-23 07:27:051737String
Junio C Hamanoe90436a2007-04-22 07:22:131738</dt>
1739<dd>
1740<p>
1741 3-way merge is performed using the specified custom
1742 merge driver. The built-in 3-way merge driver can be
1743 explicitly specified by asking for "text" driver; the
1744 built-in "take the current branch" driver can be
Junio C Hamano22572e72007-04-25 05:59:251745 requested with "binary".
Junio C Hamanoe90436a2007-04-22 07:22:131746</p>
1747</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311748</dl></div>
Junio C Hamano9d971152012-12-19 00:43:111749</div>
1750<div class="sect3">
Junio C Hamanoba4b9282008-07-06 05:20:311751<h4 id="_built_in_merge_drivers">Built-in merge drivers</h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581752<div class="paragraph"><p>There are a few built-in low-level merge drivers defined that
Junio C Hamanoc14e6ad2014-10-31 20:25:531753can be asked for via the <code>merge</code> attribute.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581754<div class="dlist"><dl>
1755<dt class="hdlist1">
Junio C Hamanof556fc22007-12-23 08:16:381756text
1757</dt>
1758<dd>
1759<p>
1760 Usual 3-way file level merge for text files. Conflicted
Junio C Hamanoc14e6ad2014-10-31 20:25:531761 regions are marked with conflict markers <code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code>,
1762 <code>=======</code> and <code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code>. The version from your branch
1763 appears before the <code>=======</code> marker, and the version
1764 from the merged branch appears after the <code>=======</code>
Junio C Hamanof556fc22007-12-23 08:16:381765 marker.
1766</p>
1767</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581768<dt class="hdlist1">
Junio C Hamanof556fc22007-12-23 08:16:381769binary
1770</dt>
1771<dd>
1772<p>
1773 Keep the version from your branch in the work tree, but
1774 leave the path in the conflicted state for the user to
1775 sort out.
1776</p>
1777</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581778<dt class="hdlist1">
Junio C Hamanof556fc22007-12-23 08:16:381779union
1780</dt>
1781<dd>
1782<p>
1783 Run 3-way file level merge for text files, but take
1784 lines from both versions, instead of leaving conflict
1785 markers. This tends to leave the added lines in the
1786 resulting file in random order and the user should
1787 verify the result. Do not use this if you do not
1788 understand the implications.
1789</p>
1790</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311791</dl></div>
Junio C Hamano9d971152012-12-19 00:43:111792</div>
1793<div class="sect3">
Junio C Hamanoba4b9282008-07-06 05:20:311794<h4 id="_defining_a_custom_merge_driver">Defining a custom merge driver</h4>
Junio C Hamanoc14e6ad2014-10-31 20:25:531795<div class="paragraph"><p>The definition of a merge driver is done in the <code>.git/config</code>
1796file, not in the <code>gitattributes</code> file, so strictly speaking this
Junio C Hamanoba4b9282008-07-06 05:20:311797manual page is a wrong place to talk about it. However&#8230;</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531798<div class="paragraph"><p>To define a custom merge driver <code>filfre</code>, add a section to your
1799<code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:131800<div class="listingblock">
1801<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531802<pre><code>[merge "filfre"]
Junio C Hamanoe90436a2007-04-22 07:22:131803 name = feel-free merge driver
Junio C Hamanodf5384b2015-06-24 21:12:121804 driver = filfre %O %A %B %L %P
Junio C Hamanoc14e6ad2014-10-31 20:25:531805 recursive = binary</code></pre>
Junio C Hamanoe90436a2007-04-22 07:22:131806</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531807<div class="paragraph"><p>The <code>merge.*.name</code> variable gives the driver a human-readable
Junio C Hamanoba4b9282008-07-06 05:20:311808name.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581809<div class="paragraph"><p>The &#8216;merge.*.driver` variable&#8217;s value is used to construct a
Junio C Hamanoc14e6ad2014-10-31 20:25:531810command to run to merge ancestor&#8217;s version (<code>%O</code>), current
1811version (<code>%A</code>) and the other branches&#8217; version (<code>%B</code>). These
Junio C Hamanoe90436a2007-04-22 07:22:131812three tokens are replaced with the names of temporary files that
1813hold the contents of these versions when the command line is
Junio C Hamano86660db2010-02-24 01:12:541814built. Additionally, %L will be replaced with the conflict marker
1815size (see below).</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581816<div class="paragraph"><p>The merge driver is expected to leave the result of the merge in
Junio C Hamanoc14e6ad2014-10-31 20:25:531817the file named with <code>%A</code> by overwriting it, and exit with zero
Junio C Hamanoe90436a2007-04-22 07:22:131818status if it managed to merge them cleanly, or non-zero if there
Junio C Hamanoba4b9282008-07-06 05:20:311819were conflicts.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531820<div class="paragraph"><p>The <code>merge.*.recursive</code> variable specifies what other merge
Junio C Hamanoe90436a2007-04-22 07:22:131821driver to use when the merge driver is called for an internal
1822merge between common ancestors, when there are more than one.
1823When left unspecified, the driver itself is used for both
Junio C Hamanoba4b9282008-07-06 05:20:311824internal merge and the final merge.</p></div>
Junio C Hamanodf5384b2015-06-24 21:12:121825<div class="paragraph"><p>The merge driver can learn the pathname in which the merged result
1826will be stored via placeholder <code>%P</code>.</p></div>
Junio C Hamano9d971152012-12-19 00:43:111827</div>
1828<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:531829<h4 id="_code_conflict_marker_size_code"><code>conflict-marker-size</code></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581830<div class="paragraph"><p>This attribute controls the length of conflict markers left in
Junio C Hamano1aa40d22010-01-21 17:46:431831the work tree file during a conflicted merge. Only setting to
1832the value to a positive integer has any meaningful effect.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531833<div class="paragraph"><p>For example, this line in <code>.gitattributes</code> can be used to tell the merge
Junio C Hamano1aa40d22010-01-21 17:46:431834machinery to leave much longer (instead of the usual 7-character-long)
Junio C Hamanoc14e6ad2014-10-31 20:25:531835conflict markers when merging the file <code>Documentation/git-merge.txt</code>
Junio C Hamano1aa40d22010-01-21 17:46:431836results in a conflict.</p></div>
1837<div class="listingblock">
1838<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531839<pre><code>Documentation/git-merge.txt conflict-marker-size=32</code></pre>
Junio C Hamano1aa40d22010-01-21 17:46:431840</div></div>
Junio C Hamano9d971152012-12-19 00:43:111841</div>
1842</div>
1843<div class="sect2">
1844<h3 id="_checking_whitespace_errors">Checking whitespace errors</h3>
1845<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:531846<h4 id="_code_whitespace_code"><code>whitespace</code></h4>
1847<div class="paragraph"><p>The <code>core.whitespace</code> configuration variable allows you to define what
Junio C Hamanoba4b9282008-07-06 05:20:311848<em>diff</em> and <em>apply</em> should consider whitespace errors for all paths in
Junio C Hamanoa28a9202012-06-21 07:08:231849the project (See <a href="git-config.html">git-config(1)</a>). This attribute gives you finer
Junio C Hamanoba4b9282008-07-06 05:20:311850control per path.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581851<div class="dlist"><dl>
1852<dt class="hdlist1">
Junio C Hamano942b35e2007-12-09 10:19:331853Set
1854</dt>
1855<dd>
1856<p>
Junio C Hamano076ffcc2013-02-06 05:13:211857 Notice all types of potential whitespace errors known to Git.
Junio C Hamanoc14e6ad2014-10-31 20:25:531858 The tab width is taken from the value of the <code>core.whitespace</code>
Junio C Hamanoeef01fe2010-12-13 08:31:581859 configuration variable.
Junio C Hamano942b35e2007-12-09 10:19:331860</p>
1861</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581862<dt class="hdlist1">
Junio C Hamano942b35e2007-12-09 10:19:331863Unset
1864</dt>
1865<dd>
1866<p>
1867 Do not notice anything as error.
1868</p>
1869</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581870<dt class="hdlist1">
Junio C Hamano942b35e2007-12-09 10:19:331871Unspecified
1872</dt>
1873<dd>
1874<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531875 Use the value of the <code>core.whitespace</code> configuration variable to
Junio C Hamano942b35e2007-12-09 10:19:331876 decide what to notice as error.
1877</p>
1878</dd>
Junio C Hamanoeef01fe2010-12-13 08:31:581879<dt class="hdlist1">
Junio C Hamano942b35e2007-12-09 10:19:331880String
1881</dt>
1882<dd>
1883<p>
1884 Specify a comma separate list of common whitespace problems to
Junio C Hamanoc14e6ad2014-10-31 20:25:531885 notice in the same format as the <code>core.whitespace</code> configuration
Junio C Hamano942b35e2007-12-09 10:19:331886 variable.
1887</p>
1888</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311889</dl></div>
Junio C Hamano9d971152012-12-19 00:43:111890</div>
1891</div>
1892<div class="sect2">
1893<h3 id="_creating_an_archive">Creating an archive</h3>
1894<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:531895<h4 id="_code_export_ignore_code"><code>export-ignore</code></h4>
1896<div class="paragraph"><p>Files and directories with the attribute <code>export-ignore</code> won&#8217;t be added to
Junio C Hamanoba4b9282008-07-06 05:20:311897archive files.</p></div>
Junio C Hamano9d971152012-12-19 00:43:111898</div>
1899<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:531900<h4 id="_code_export_subst_code"><code>export-subst</code></h4>
1901<div class="paragraph"><p>If the attribute <code>export-subst</code> is set for a file then Git will expand
Junio C Hamanoba4b9282008-07-06 05:20:311902several placeholders when adding this file to an archive. The
1903expansion depends on the availability of a commit ID, i.e., if
Junio C Hamanoa28a9202012-06-21 07:08:231904<a href="git-archive.html">git-archive(1)</a> has been given a tree instead of a commit or a
Junio C Hamanoba4b9282008-07-06 05:20:311905tag then no replacement will be done. The placeholders are the same
Junio C Hamanoc14e6ad2014-10-31 20:25:531906as those for the option <code>--pretty=format:</code> of <a href="git-log.html">git-log(1)</a>,
1907except that they need to be wrapped like this: <code>$Format:PLACEHOLDERS$</code>
1908in the file. E.g. the string <code>$Format:%H$</code> will be replaced by the
Junio C Hamanoba4b9282008-07-06 05:20:311909commit hash.</p></div>
Junio C Hamano9d971152012-12-19 00:43:111910</div>
1911</div>
1912<div class="sect2">
1913<h3 id="_packing_objects">Packing objects</h3>
1914<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:531915<h4 id="_code_delta_code"><code>delta</code></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581916<div class="paragraph"><p>Delta compression will not be attempted for blobs for paths with the
Junio C Hamanoc14e6ad2014-10-31 20:25:531917attribute <code>delta</code> set to false.</p></div>
Junio C Hamano9d971152012-12-19 00:43:111918</div>
1919</div>
1920<div class="sect2">
1921<h3 id="_viewing_files_in_gui_tools">Viewing files in GUI tools</h3>
1922<div class="sect3">
Junio C Hamanoc14e6ad2014-10-31 20:25:531923<h4 id="_code_encoding_code"><code>encoding</code></h4>
Junio C Hamanoeef01fe2010-12-13 08:31:581924<div class="paragraph"><p>The value of this attribute specifies the character encoding that should
Junio C Hamanoa28a9202012-06-21 07:08:231925be used by GUI tools (e.g. <a href="gitk.html">gitk(1)</a> and <a href="git-gui.html">git-gui(1)</a>) to
Junio C Hamanod3452a02008-11-15 08:07:551926display the contents of the relevant file. Note that due to performance
Junio C Hamanoa28a9202012-06-21 07:08:231927considerations <a href="gitk.html">gitk(1)</a> does not use this attribute unless you
Junio C Hamanod3452a02008-11-15 08:07:551928manually enable per-file encodings in its options.</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581929<div class="paragraph"><p>If this attribute is not set or has an invalid value, the value of the
Junio C Hamanoc14e6ad2014-10-31 20:25:531930<code>gui.encoding</code> configuration variable is used instead
Junio C Hamanoa28a9202012-06-21 07:08:231931(See <a href="git-config.html">git-config(1)</a>).</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:131932</div>
Junio C Hamano9d971152012-12-19 00:43:111933</div>
1934</div>
1935</div>
1936<div class="sect1">
Junio C Hamano86d84362011-08-04 00:21:511937<h2 id="_using_macro_attributes">USING MACRO ATTRIBUTES</h2>
Junio C Hamanofcb740a2008-08-31 06:32:051938<div class="sectionbody">
Junio C Hamanoeef01fe2010-12-13 08:31:581939<div class="paragraph"><p>You do not want any end-of-line conversions applied to, nor textual diffs
Junio C Hamanofcb740a2008-08-31 06:32:051940produced for, any binary file you track. You would need to specify e.g.</p></div>
1941<div class="listingblock">
1942<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531943<pre><code>*.jpg -text -diff</code></pre>
Junio C Hamanofcb740a2008-08-31 06:32:051944</div></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581945<div class="paragraph"><p>but that may become cumbersome, when you have many attributes. Using
Junio C Hamano86d84362011-08-04 00:21:511946macro attributes, you can define an attribute that, when set, also
1947sets or unsets a number of other attributes at the same time. The
Junio C Hamanoc14e6ad2014-10-31 20:25:531948system knows a built-in macro attribute, <code>binary</code>:</p></div>
Junio C Hamanofcb740a2008-08-31 06:32:051949<div class="listingblock">
1950<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531951<pre><code>*.jpg binary</code></pre>
Junio C Hamanofcb740a2008-08-31 06:32:051952</div></div>
Junio C Hamano86d84362011-08-04 00:21:511953<div class="paragraph"><p>Setting the "binary" attribute also unsets the "text" and "diff"
1954attributes as above. Note that macro attributes can only be "Set",
1955though setting one might have the effect of setting or unsetting other
1956attributes or even returning other attributes to the "Unspecified"
1957state.</p></div>
Junio C Hamanofcb740a2008-08-31 06:32:051958</div>
Junio C Hamano9d971152012-12-19 00:43:111959</div>
1960<div class="sect1">
Junio C Hamano86d84362011-08-04 00:21:511961<h2 id="_defining_macro_attributes">DEFINING MACRO ATTRIBUTES</h2>
Junio C Hamanofcb740a2008-08-31 06:32:051962<div class="sectionbody">
Junio C Hamanoc5bd79e2014-01-27 21:31:261963<div class="paragraph"><p>Custom macro attributes can be defined only in top-level gitattributes
Junio C Hamanoc14e6ad2014-10-31 20:25:531964files (<code>$GIT_DIR/info/attributes</code>, the <code>.gitattributes</code> file at the
Junio C Hamanoc5bd79e2014-01-27 21:31:261965top level of the working tree, or the global or system-wide
Junio C Hamanoc14e6ad2014-10-31 20:25:531966gitattributes files), not in <code>.gitattributes</code> files in working tree
Junio C Hamanoc5bd79e2014-01-27 21:31:261967subdirectories. The built-in macro attribute "binary" is equivalent
1968to:</p></div>
Junio C Hamanofcb740a2008-08-31 06:32:051969<div class="listingblock">
1970<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531971<pre><code>[attr]binary -diff -merge -text</code></pre>
Junio C Hamanofcb740a2008-08-31 06:32:051972</div></div>
1973</div>
Junio C Hamano9d971152012-12-19 00:43:111974</div>
1975<div class="sect1">
Junio C Hamano4b2a6c12017-08-22 18:32:371976<h2 id="_example_2">EXAMPLE</h2>
Junio C Hamanoe90436a2007-04-22 07:22:131977<div class="sectionbody">
Junio C Hamanoc14e6ad2014-10-31 20:25:531978<div class="paragraph"><p>If you have these three <code>gitattributes</code> file:</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:131979<div class="listingblock">
1980<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531981<pre><code>(in $GIT_DIR/info/attributes)
Junio C Hamanoe90436a2007-04-22 07:22:131982
1983a* foo !bar -baz
1984
1985(in .gitattributes)
1986abc foo bar baz
1987
1988(in t/.gitattributes)
1989ab* merge=filfre
1990abc -foo -bar
Junio C Hamanoc14e6ad2014-10-31 20:25:531991*.c frotz</code></pre>
Junio C Hamanoe90436a2007-04-22 07:22:131992</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531993<div class="paragraph"><p>the attributes given to path <code>t/abc</code> are computed as follows:</p></div>
Junio C Hamanoeef01fe2010-12-13 08:31:581994<div class="olist arabic"><ol class="arabic">
Junio C Hamanoe90436a2007-04-22 07:22:131995<li>
1996<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531997By examining <code>t/.gitattributes</code> (which is in the same
Junio C Hamano076ffcc2013-02-06 05:13:211998 directory as the path in question), Git finds that the first
Junio C Hamanoc14e6ad2014-10-31 20:25:531999 line matches. <code>merge</code> attribute is set. It also finds that
2000 the second line matches, and attributes <code>foo</code> and <code>bar</code>
Junio C Hamanoe90436a2007-04-22 07:22:132001 are unset.
2002</p>
2003</li>
2004<li>
2005<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:532006Then it examines <code>.gitattributes</code> (which is in the parent
Junio C Hamanoe90436a2007-04-22 07:22:132007 directory), and finds that the first line matches, but
Junio C Hamanoc14e6ad2014-10-31 20:25:532008 <code>t/.gitattributes</code> file already decided how <code>merge</code>, <code>foo</code>
2009 and <code>bar</code> attributes should be given to this path, so it
2010 leaves <code>foo</code> and <code>bar</code> unset. Attribute <code>baz</code> is set.
Junio C Hamanoe90436a2007-04-22 07:22:132011</p>
2012</li>
2013<li>
2014<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:532015Finally it examines <code>$GIT_DIR/info/attributes</code>. This file
Junio C Hamanoe90436a2007-04-22 07:22:132016 is used to override the in-tree settings. The first line is
Junio C Hamanoc14e6ad2014-10-31 20:25:532017 a match, and <code>foo</code> is set, <code>bar</code> is reverted to unspecified
2018 state, and <code>baz</code> is unset.
Junio C Hamanoe90436a2007-04-22 07:22:132019</p>
2020</li>
Junio C Hamanoba4b9282008-07-06 05:20:312021</ol></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:532022<div class="paragraph"><p>As the result, the attributes assignment to <code>t/abc</code> becomes:</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:132023<div class="listingblock">
2024<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:532025<pre><code>foo set to true
Junio C Hamanoe90436a2007-04-22 07:22:132026bar unspecified
2027baz set to false
2028merge set to string value "filfre"
Junio C Hamanoc14e6ad2014-10-31 20:25:532029frotz unspecified</code></pre>
Junio C Hamanoe90436a2007-04-22 07:22:132030</div></div>
2031</div>
Junio C Hamano9d971152012-12-19 00:43:112032</div>
2033<div class="sect1">
Junio C Hamanof7279012011-08-18 06:13:132034<h2 id="_see_also">SEE ALSO</h2>
2035<div class="sectionbody">
Junio C Hamanoa28a9202012-06-21 07:08:232036<div class="paragraph"><p><a href="git-check-attr.html">git-check-attr(1)</a>.</p></div>
Junio C Hamanof7279012011-08-18 06:13:132037</div>
Junio C Hamano9d971152012-12-19 00:43:112038</div>
2039<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:312040<h2 id="_git">GIT</h2>
Junio C Hamanoe90436a2007-04-22 07:22:132041<div class="sectionbody">
Junio C Hamanoa28a9202012-06-21 07:08:232042<div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamanoe90436a2007-04-22 07:22:132043</div>
Junio C Hamano7bd050f2011-09-22 06:32:222044</div>
Junio C Hamano9d971152012-12-19 00:43:112045</div>
Junio C Hamano7bd050f2011-09-22 06:32:222046<div id="footnotes"><hr /></div>
Junio C Hamanoe90436a2007-04-22 07:22:132047<div id="footer">
2048<div id="footer-text">
Junio C Hamano2ef0ba32018-01-26 23:13:532049Last updated
Junio C Hamanoa25ccc42018-03-08 21:36:142050 2018-03-08 13:35:19 PST
Junio C Hamanoe90436a2007-04-22 07:22:132051</div>
2052</div>
2053</body>
2054</html>