Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1 | <!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> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 8.2.5" /> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 7 | <style type="text/css"> |
| 8 | /* Debug borders */ |
| 9 | p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { |
| 10 | /* |
| 11 | border: 1px solid red; |
| 12 | */ |
| 13 | } |
| 14 | |
| 15 | body { |
| 16 | margin: 1em 5% 1em 5%; |
| 17 | } |
| 18 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 19 | a { |
| 20 | color: blue; |
| 21 | text-decoration: underline; |
| 22 | } |
| 23 | a:visited { |
| 24 | color: fuchsia; |
| 25 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 26 | |
| 27 | em { |
| 28 | font-style: italic; |
| 29 | } |
| 30 | |
| 31 | strong { |
| 32 | font-weight: bold; |
| 33 | } |
| 34 | |
| 35 | tt { |
| 36 | color: navy; |
| 37 | } |
| 38 | |
| 39 | h1, h2, h3, h4, h5, h6 { |
| 40 | color: #527bbd; |
| 41 | font-family: sans-serif; |
| 42 | margin-top: 1.2em; |
| 43 | margin-bottom: 0.5em; |
| 44 | line-height: 1.3; |
| 45 | } |
| 46 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 47 | h1, h2, h3 { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 48 | border-bottom: 2px solid silver; |
| 49 | } |
| 50 | h2 { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 51 | padding-top: 0.5em; |
| 52 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 53 | h3 { |
| 54 | float: left; |
| 55 | } |
| 56 | h3 + * { |
| 57 | clear: left; |
| 58 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 59 | |
| 60 | div.sectionbody { |
| 61 | font-family: serif; |
| 62 | margin-left: 0; |
| 63 | } |
| 64 | |
| 65 | hr { |
| 66 | border: 1px solid silver; |
| 67 | } |
| 68 | |
| 69 | p { |
| 70 | margin-top: 0.5em; |
| 71 | margin-bottom: 0.5em; |
| 72 | } |
| 73 | |
| 74 | pre { |
| 75 | padding: 0; |
| 76 | margin: 0; |
| 77 | } |
| 78 | |
| 79 | span#author { |
| 80 | color: #527bbd; |
| 81 | font-family: sans-serif; |
| 82 | font-weight: bold; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 83 | font-size: 1.1em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 84 | } |
| 85 | span#email { |
| 86 | } |
| 87 | span#revision { |
| 88 | font-family: sans-serif; |
| 89 | } |
| 90 | |
| 91 | div#footer { |
| 92 | font-family: sans-serif; |
| 93 | font-size: small; |
| 94 | border-top: 2px solid silver; |
| 95 | padding-top: 0.5em; |
| 96 | margin-top: 4.0em; |
| 97 | } |
| 98 | div#footer-text { |
| 99 | float: left; |
| 100 | padding-bottom: 0.5em; |
| 101 | } |
| 102 | div#footer-badges { |
| 103 | float: right; |
| 104 | padding-bottom: 0.5em; |
| 105 | } |
| 106 | |
| 107 | div#preamble, |
| 108 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
| 109 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 110 | div.admonitionblock { |
| 111 | margin-right: 10%; |
| 112 | margin-top: 1.5em; |
| 113 | margin-bottom: 1.5em; |
| 114 | } |
| 115 | div.admonitionblock { |
| 116 | margin-top: 2.5em; |
| 117 | margin-bottom: 2.5em; |
| 118 | } |
| 119 | |
| 120 | div.content { /* Block element content. */ |
| 121 | padding: 0; |
| 122 | } |
| 123 | |
| 124 | /* Block element titles. */ |
| 125 | div.title, caption.title { |
| 126 | font-family: sans-serif; |
| 127 | font-weight: bold; |
| 128 | text-align: left; |
| 129 | margin-top: 1.0em; |
| 130 | margin-bottom: 0.5em; |
| 131 | } |
| 132 | div.title + * { |
| 133 | margin-top: 0; |
| 134 | } |
| 135 | |
| 136 | td div.title:first-child { |
| 137 | margin-top: 0.0em; |
| 138 | } |
| 139 | div.content div.title:first-child { |
| 140 | margin-top: 0.0em; |
| 141 | } |
| 142 | div.content + div.title { |
| 143 | margin-top: 0.0em; |
| 144 | } |
| 145 | |
| 146 | div.sidebarblock > div.content { |
| 147 | background: #ffffee; |
| 148 | border: 1px solid silver; |
| 149 | padding: 0.5em; |
| 150 | } |
| 151 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 152 | div.listingblock { |
| 153 | margin-right: 0%; |
| 154 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 155 | div.listingblock > div.content { |
| 156 | border: 1px solid silver; |
| 157 | background: #f4f4f4; |
| 158 | padding: 0.5em; |
| 159 | } |
| 160 | |
| 161 | div.quoteblock > div.content { |
| 162 | padding-left: 2.0em; |
| 163 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 164 | |
| 165 | div.attribution { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 166 | text-align: right; |
| 167 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 168 | div.verseblock + div.attribution { |
| 169 | text-align: left; |
| 170 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 171 | |
| 172 | div.admonitionblock .icon { |
| 173 | vertical-align: top; |
| 174 | font-size: 1.1em; |
| 175 | font-weight: bold; |
| 176 | text-decoration: underline; |
| 177 | color: #527bbd; |
| 178 | padding-right: 0.5em; |
| 179 | } |
| 180 | div.admonitionblock td.content { |
| 181 | padding-left: 0.5em; |
| 182 | border-left: 2px solid silver; |
| 183 | } |
| 184 | |
| 185 | div.exampleblock > div.content { |
| 186 | border-left: 2px solid silver; |
| 187 | padding: 0.5em; |
| 188 | } |
| 189 | |
| 190 | div.verseblock div.content { |
| 191 | white-space: pre; |
| 192 | } |
| 193 | |
| 194 | div.imageblock div.content { padding-left: 0; } |
| 195 | div.imageblock img { border: 1px solid silver; } |
| 196 | span.image img { border-style: none; } |
| 197 | |
| 198 | dl { |
| 199 | margin-top: 0.8em; |
| 200 | margin-bottom: 0.8em; |
| 201 | } |
| 202 | dt { |
| 203 | margin-top: 0.5em; |
| 204 | margin-bottom: 0; |
| 205 | font-style: italic; |
| 206 | } |
| 207 | dd > *:first-child { |
| 208 | margin-top: 0; |
| 209 | } |
| 210 | |
| 211 | ul, ol { |
| 212 | list-style-position: outside; |
| 213 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 214 | div.olist2 ol { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 215 | list-style-type: lower-alpha; |
| 216 | } |
| 217 | |
| 218 | div.tableblock > table { |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 219 | border: 3px solid #527bbd; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 220 | } |
| 221 | thead { |
| 222 | font-family: sans-serif; |
| 223 | font-weight: bold; |
| 224 | } |
| 225 | tfoot { |
| 226 | font-weight: bold; |
| 227 | } |
| 228 | |
| 229 | div.hlist { |
| 230 | margin-top: 0.8em; |
| 231 | margin-bottom: 0.8em; |
| 232 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 233 | div.hlist td { |
| 234 | padding-bottom: 5px; |
| 235 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 236 | td.hlist1 { |
| 237 | vertical-align: top; |
| 238 | font-style: italic; |
| 239 | padding-right: 0.8em; |
| 240 | } |
| 241 | td.hlist2 { |
| 242 | vertical-align: top; |
| 243 | } |
| 244 | |
| 245 | @media print { |
| 246 | div#footer-badges { display: none; } |
| 247 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 248 | |
| 249 | div#toctitle { |
| 250 | color: #527bbd; |
| 251 | font-family: sans-serif; |
| 252 | font-size: 1.1em; |
| 253 | font-weight: bold; |
| 254 | margin-top: 1.0em; |
| 255 | margin-bottom: 0.1em; |
| 256 | } |
| 257 | |
| 258 | div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { |
| 259 | margin-top: 0; |
| 260 | margin-bottom: 0; |
| 261 | } |
| 262 | div.toclevel2 { |
| 263 | margin-left: 2em; |
| 264 | font-size: 0.9em; |
| 265 | } |
| 266 | div.toclevel3 { |
| 267 | margin-left: 4em; |
| 268 | font-size: 0.9em; |
| 269 | } |
| 270 | div.toclevel4 { |
| 271 | margin-left: 6em; |
| 272 | font-size: 0.9em; |
| 273 | } |
| 274 | include1::./stylesheets/xhtml11-manpage.css[] |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 275 | /* Workarounds for IE6's broken and incomplete CSS2. */ |
| 276 | |
| 277 | div.sidebar-content { |
| 278 | background: #ffffee; |
| 279 | border: 1px solid silver; |
| 280 | padding: 0.5em; |
| 281 | } |
| 282 | div.sidebar-title, div.image-title { |
| 283 | font-family: sans-serif; |
| 284 | font-weight: bold; |
| 285 | margin-top: 0.0em; |
| 286 | margin-bottom: 0.5em; |
| 287 | } |
| 288 | |
| 289 | div.listingblock div.content { |
| 290 | border: 1px solid silver; |
| 291 | background: #f4f4f4; |
| 292 | padding: 0.5em; |
| 293 | } |
| 294 | |
| 295 | div.quoteblock-content { |
| 296 | padding-left: 2.0em; |
| 297 | } |
| 298 | |
| 299 | div.exampleblock-content { |
| 300 | border-left: 2px solid silver; |
| 301 | padding-left: 0.5em; |
| 302 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 303 | |
| 304 | /* IE6 sets dynamically generated links as visited. */ |
| 305 | div#toc a:visited { color: blue; } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 306 | </style> |
| 307 | <title>gitattributes(5)</title> |
| 308 | </head> |
| 309 | <body> |
| 310 | <div id="header"> |
| 311 | <h1> |
| 312 | gitattributes(5) Manual Page |
| 313 | </h1> |
| 314 | <h2>NAME</h2> |
| 315 | <div class="sectionbody"> |
| 316 | <p>gitattributes - |
| 317 | defining attributes per path |
| 318 | </p> |
| 319 | </div> |
| 320 | </div> |
| 321 | <h2>SYNOPSIS</h2> |
| 322 | <div class="sectionbody"> |
Junio C Hamano | 17bd227 | 2008-09-01 06:11:17 | [diff] [blame] | 323 | <div class="para"><p>$GIT_DIR/info/attributes, .gitattributes</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 324 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 325 | <h2 id="_description">DESCRIPTION</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 326 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 327 | <div class="para"><p>A <tt>gitattributes</tt> file is a simple text file that gives |
| 328 | <tt>attributes</tt> to pathnames.</p></div> |
| 329 | <div class="para"><p>Each line in <tt>gitattributes</tt> file is of form:</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 330 | <div class="literalblock"> |
| 331 | <div class="content"> |
| 332 | <pre><tt>glob attr1 attr2 ...</tt></pre> |
| 333 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 334 | <div class="para"><p>That is, a glob pattern followed by an attributes list, |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 335 | separated by whitespaces. When the glob pattern matches the |
| 336 | path in question, the attributes listed on the line are given to |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 337 | the path.</p></div> |
| 338 | <div class="para"><p>Each attribute can be in one of these states for a given path:</p></div> |
| 339 | <div class="vlist"><dl> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 340 | <dt> |
| 341 | Set |
| 342 | </dt> |
| 343 | <dd> |
| 344 | <p> |
| 345 | The path has the attribute with special value "true"; |
| 346 | this is specified by listing only the name of the |
| 347 | attribute in the attribute list. |
| 348 | </p> |
| 349 | </dd> |
| 350 | <dt> |
| 351 | Unset |
| 352 | </dt> |
| 353 | <dd> |
| 354 | <p> |
| 355 | The path has the attribute with special value "false"; |
| 356 | this is specified by listing the name of the attribute |
| 357 | prefixed with a dash <tt>-</tt> in the attribute list. |
| 358 | </p> |
| 359 | </dd> |
| 360 | <dt> |
| 361 | Set to a value |
| 362 | </dt> |
| 363 | <dd> |
| 364 | <p> |
| 365 | The path has the attribute with specified string value; |
| 366 | this is specified by listing the name of the attribute |
| 367 | followed by an equal sign <tt>=</tt> and its value in the |
| 368 | attribute list. |
| 369 | </p> |
| 370 | </dd> |
| 371 | <dt> |
| 372 | Unspecified |
| 373 | </dt> |
| 374 | <dd> |
| 375 | <p> |
| 376 | No glob pattern matches the path, and nothing says if |
Junio C Hamano | 22572e7 | 2007-04-25 05:59:25 | [diff] [blame] | 377 | the path has or does not have the attribute, the |
| 378 | attribute for the path is said to be Unspecified. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 379 | </p> |
| 380 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 381 | </dl></div> |
| 382 | <div class="para"><p>When more than one glob pattern matches the path, a later line |
Junio C Hamano | 22572e7 | 2007-04-25 05:59:25 | [diff] [blame] | 383 | overrides an earlier line. This overriding is done per |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 384 | attribute.</p></div> |
| 385 | <div class="para"><p>When deciding what attributes are assigned to a path, git |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 386 | consults <tt>$GIT_DIR/info/attributes</tt> file (which has the highest |
| 387 | precedence), <tt>.gitattributes</tt> file in the same directory as the |
| 388 | path in question, and its parent directories (the further the |
| 389 | directory that contains <tt>.gitattributes</tt> is from the path in |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 390 | question, the lower its precedence).</p></div> |
| 391 | <div class="para"><p>If you wish to affect only a single repository (i.e., to assign |
Junio C Hamano | 99dc24a | 2008-03-27 23:49:50 | [diff] [blame] | 392 | attributes to files that are particular to one user's workflow), then |
| 393 | attributes should be placed in the <tt>$GIT_DIR/info/attributes</tt> file. |
| 394 | Attributes which should be version-controlled and distributed to other |
| 395 | repositories (i.e., attributes of interest to all users) should go into |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 396 | <tt>.gitattributes</tt> files.</p></div> |
| 397 | <div class="para"><p>Sometimes you would need to override an setting of an attribute |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 398 | for a path to <tt>unspecified</tt> state. This can be done by listing |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 399 | the name of the attribute prefixed with an exclamation point <tt>!</tt>.</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 400 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 401 | <h2 id="_effects">EFFECTS</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 402 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 403 | <div class="para"><p>Certain operations by git can be influenced by assigning |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 404 | particular attributes to a path. Currently, the following |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 405 | operations are attributes-aware.</p></div> |
| 406 | <h3 id="_checking_out_and_checking_in">Checking-out and checking-in</h3><div style="clear:left"></div> |
| 407 | <div class="para"><p>These attributes affect how the contents stored in the |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 408 | repository are copied to the working tree files when commands |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 409 | such as <em>git-checkout</em> and <em>git-merge</em> run. They also affect how |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 410 | git stores the contents you prepare in the working tree in the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 411 | repository upon <em>git-add</em> and <em>git-commit</em>.</p></div> |
| 412 | <h4 id="_tt_crlf_tt"><tt>crlf</tt></h4> |
| 413 | <div class="para"><p>This attribute controls the line-ending convention.</p></div> |
| 414 | <div class="vlist"><dl> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 415 | <dt> |
| 416 | Set |
| 417 | </dt> |
| 418 | <dd> |
| 419 | <p> |
| 420 | Setting the <tt>crlf</tt> attribute on a path is meant to mark |
| 421 | the path as a "text" file. <em>core.autocrlf</em> conversion |
| 422 | takes place without guessing the content type by |
| 423 | inspection. |
| 424 | </p> |
| 425 | </dd> |
| 426 | <dt> |
| 427 | Unset |
| 428 | </dt> |
| 429 | <dd> |
| 430 | <p> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 431 | Unsetting the <tt>crlf</tt> attribute on a path tells git not to |
| 432 | attempt any end-of-line conversion upon checkin or checkout. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 433 | </p> |
| 434 | </dd> |
| 435 | <dt> |
| 436 | Unspecified |
| 437 | </dt> |
| 438 | <dd> |
| 439 | <p> |
| 440 | Unspecified <tt>crlf</tt> attribute tells git to apply the |
| 441 | <tt>core.autocrlf</tt> conversion when the file content looks |
| 442 | like text. |
| 443 | </p> |
| 444 | </dd> |
| 445 | <dt> |
| 446 | Set to string value "input" |
| 447 | </dt> |
| 448 | <dd> |
| 449 | <p> |
| 450 | This is similar to setting the attribute to <tt>true</tt>, but |
| 451 | also forces git to act as if <tt>core.autocrlf</tt> is set to |
| 452 | <tt>input</tt> for the path. |
| 453 | </p> |
| 454 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 455 | </dl></div> |
| 456 | <div class="para"><p>Any other value set to <tt>crlf</tt> attribute is ignored and git acts |
| 457 | as if the attribute is left unspecified.</p></div> |
| 458 | <h4 id="_the_tt_core_autocrlf_tt_conversion">The <tt>core.autocrlf</tt> conversion</h4> |
| 459 | <div class="para"><p>If the configuration variable <tt>core.autocrlf</tt> is false, no |
| 460 | conversion is done.</p></div> |
| 461 | <div class="para"><p>When <tt>core.autocrlf</tt> is true, it means that the platform wants |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 462 | CRLF line endings for files in the working tree, and you want to |
| 463 | convert them back to the normal LF line endings when checking |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 464 | in to the repository.</p></div> |
| 465 | <div class="para"><p>When <tt>core.autocrlf</tt> is set to "input", line endings are |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 466 | converted to LF upon checkin, but there is no conversion done |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 467 | upon checkout.</p></div> |
| 468 | <div class="para"><p>If <tt>core.safecrlf</tt> is set to "true" or "warn", git verifies if |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 469 | the conversion is reversible for the current setting of |
| 470 | <tt>core.autocrlf</tt>. For "true", git rejects irreversible |
| 471 | conversions; for "warn", git only prints a warning but accepts |
| 472 | an irreversible conversion. The safety triggers to prevent such |
| 473 | a conversion done to the files in the work tree, but there are a |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 474 | few exceptions. Even though…</p></div> |
| 475 | <div class="ilist"><ul> |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 476 | <li> |
| 477 | <p> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 478 | <em>git-add</em> itself does not touch the files in the work tree, the |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 479 | next checkout would, so the safety triggers; |
| 480 | </p> |
| 481 | </li> |
| 482 | <li> |
| 483 | <p> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 484 | <em>git-apply</em> to update a text file with a patch does touch the files |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 485 | in the work tree, but the operation is about text files and CRLF |
| 486 | conversion is about fixing the line ending inconsistencies, so the |
| 487 | safety does not trigger; |
| 488 | </p> |
| 489 | </li> |
| 490 | <li> |
| 491 | <p> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 492 | <em>git-diff</em> itself does not touch the files in the work tree, it is |
| 493 | often run to inspect the changes you intend to next <em>git-add</em>. To |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 494 | catch potential problems early, safety triggers. |
| 495 | </p> |
| 496 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 497 | </ul></div> |
| 498 | <h4 id="_tt_ident_tt"><tt>ident</tt></h4> |
Junio C Hamano | 6f1bbb7 | 2008-10-31 11:32:55 | [diff] [blame^] | 499 | <div class="para"><p>When the attribute <tt>ident</tt> is set for a path, git replaces |
| 500 | <tt>$Id$</tt> in the blob object with <tt>$Id:</tt>, followed by the |
Junio C Hamano | 469d60e | 2007-04-29 18:30:34 | [diff] [blame] | 501 | 40-character hexadecimal blob object name, followed by a dollar |
| 502 | sign <tt>$</tt> upon checkout. Any byte sequence that begins with |
Junio C Hamano | 0430e3a | 2007-05-15 03:13:17 | [diff] [blame] | 503 | <tt>$Id:</tt> and ends with <tt>$</tt> in the worktree file is replaced |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 504 | with <tt>$Id$</tt> upon check-in.</p></div> |
| 505 | <h4 id="_tt_filter_tt"><tt>filter</tt></h4> |
| 506 | <div class="para"><p>A <tt>filter</tt> attribute can be set to a string value that names a |
| 507 | filter driver specified in the configuration.</p></div> |
| 508 | <div class="para"><p>A filter driver consists of a <tt>clean</tt> command and a <tt>smudge</tt> |
Junio C Hamano | 469d60e | 2007-04-29 18:30:34 | [diff] [blame] | 509 | command, either of which can be left unspecified. Upon |
Junio C Hamano | 361c133 | 2007-11-14 12:17:22 | [diff] [blame] | 510 | checkout, when the <tt>smudge</tt> command is specified, the command is |
| 511 | fed the blob object from its standard input, and its standard |
| 512 | output is used to update the worktree file. Similarly, the |
| 513 | <tt>clean</tt> command is used to convert the contents of worktree file |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 514 | upon checkin.</p></div> |
| 515 | <div class="para"><p>A missing filter driver definition in the config is not an error |
| 516 | but makes the filter a no-op passthru.</p></div> |
| 517 | <div class="para"><p>The content filtering is done to massage the content into a |
Junio C Hamano | 469d60e | 2007-04-29 18:30:34 | [diff] [blame] | 518 | shape that is more convenient for the platform, filesystem, and |
Junio C Hamano | 361c133 | 2007-11-14 12:17:22 | [diff] [blame] | 519 | the user to use. The key phrase here is "more convenient" and not |
Junio C Hamano | 4fd58d4 | 2007-09-30 00:51:14 | [diff] [blame] | 520 | "turning something unusable into usable". In other words, the |
| 521 | intent is that if someone unsets the filter driver definition, |
| 522 | or does not have the appropriate filter program, the project |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 523 | should still be usable.</p></div> |
| 524 | <h4 id="_interaction_between_checkin_checkout_attributes">Interaction between checkin/checkout attributes</h4> |
| 525 | <div class="para"><p>In the check-in codepath, the worktree file is first converted |
Junio C Hamano | 469d60e | 2007-04-29 18:30:34 | [diff] [blame] | 526 | with <tt>filter</tt> driver (if specified and corresponding driver |
| 527 | defined), then the result is processed with <tt>ident</tt> (if |
| 528 | specified), and then finally with <tt>crlf</tt> (again, if specified |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 529 | and applicable).</p></div> |
| 530 | <div class="para"><p>In the check-out codepath, the blob content is first converted |
| 531 | with <tt>crlf</tt>, and then <tt>ident</tt> and fed to <tt>filter</tt>.</p></div> |
| 532 | <h3 id="_generating_diff_text">Generating diff text</h3><div style="clear:left"></div> |
| 533 | <div class="para"><p>The attribute <tt>diff</tt> affects if <em>git-diff</em> generates textual |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 534 | patch for the path or just says <tt>Binary files differ</tt>. It also |
| 535 | can affect what line is shown on the hunk header <tt>@@ -k,l +n,m @@</tt> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 536 | line.</p></div> |
| 537 | <div class="vlist"><dl> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 538 | <dt> |
| 539 | Set |
| 540 | </dt> |
| 541 | <dd> |
| 542 | <p> |
| 543 | A path to which the <tt>diff</tt> attribute is set is treated |
| 544 | as text, even when they contain byte values that |
| 545 | normally never appear in text files, such as NUL. |
| 546 | </p> |
| 547 | </dd> |
| 548 | <dt> |
| 549 | Unset |
| 550 | </dt> |
| 551 | <dd> |
| 552 | <p> |
| 553 | A path to which the <tt>diff</tt> attribute is unset will |
| 554 | generate <tt>Binary files differ</tt>. |
| 555 | </p> |
| 556 | </dd> |
| 557 | <dt> |
| 558 | Unspecified |
| 559 | </dt> |
| 560 | <dd> |
| 561 | <p> |
| 562 | A path to which the <tt>diff</tt> attribute is unspecified |
| 563 | first gets its contents inspected, and if it looks like |
| 564 | text, it is treated as text. Otherwise it would |
| 565 | generate <tt>Binary files differ</tt>. |
| 566 | </p> |
| 567 | </dd> |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 568 | <dt> |
| 569 | String |
| 570 | </dt> |
| 571 | <dd> |
| 572 | <p> |
| 573 | Diff is shown using the specified custom diff driver. |
| 574 | The driver program is given its input using the same |
| 575 | calling convention as used for GIT_EXTERNAL_DIFF |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 576 | program. This name is also used for custom hunk header |
| 577 | selection. |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 578 | </p> |
| 579 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 580 | </dl></div> |
| 581 | <h4 id="_defining_a_custom_diff_driver">Defining a custom diff driver</h4> |
| 582 | <div class="para"><p>The definition of a diff driver is done in <tt>gitconfig</tt>, not |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 583 | <tt>gitattributes</tt> file, so strictly speaking this manual page is a |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 584 | wrong place to talk about it. However…</p></div> |
| 585 | <div class="para"><p>To define a custom diff driver <tt>jcdiff</tt>, add a section to your |
| 586 | <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div> |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 587 | <div class="listingblock"> |
| 588 | <div class="content"> |
| 589 | <pre><tt>[diff "jcdiff"] |
| 590 | command = j-c-diff</tt></pre> |
| 591 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 592 | <div class="para"><p>When git needs to show you a diff for the path with <tt>diff</tt> |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 593 | attribute set to <tt>jcdiff</tt>, it calls the command you specified |
| 594 | with the above configuration, i.e. <tt>j-c-diff</tt>, with 7 |
| 595 | parameters, just like <tt>GIT_EXTERNAL_DIFF</tt> program is called. |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 596 | See <a href="git.html">git(1)</a> for details.</p></div> |
| 597 | <h4 id="_defining_a_custom_hunk_header">Defining a custom hunk-header</h4> |
Junio C Hamano | 5e4d8de | 2008-09-19 06:27:02 | [diff] [blame] | 598 | <div class="para"><p>Each group of changes (called a "hunk") in the textual diff output |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 599 | is prefixed with a line of the form:</p></div> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 600 | <div class="literalblock"> |
| 601 | <div class="content"> |
| 602 | <pre><tt>@@ -k,l +n,m @@ TEXT</tt></pre> |
| 603 | </div></div> |
Junio C Hamano | 5e4d8de | 2008-09-19 06:27:02 | [diff] [blame] | 604 | <div class="para"><p>This is called a <em>hunk header</em>. The "TEXT" portion is by default a line |
| 605 | that begins with an alphabet, an underscore or a dollar sign; this |
| 606 | matches what GNU <em>diff -p</em> output uses. This default selection however |
| 607 | is not suited for some contents, and you can use a customized pattern |
| 608 | to make a selection.</p></div> |
| 609 | <div class="para"><p>First, in .gitattributes, you would assign the <tt>diff</tt> attribute |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 610 | for paths.</p></div> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 611 | <div class="listingblock"> |
| 612 | <div class="content"> |
| 613 | <pre><tt>*.tex diff=tex</tt></pre> |
| 614 | </div></div> |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 615 | <div class="para"><p>Then, you would define a "diff.tex.xfuncname" configuration to |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 616 | specify a regular expression that matches a line that you would |
Junio C Hamano | 5e4d8de | 2008-09-19 06:27:02 | [diff] [blame] | 617 | want to appear as the hunk header "TEXT", like this:</p></div> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 618 | <div class="listingblock"> |
| 619 | <div class="content"> |
| 620 | <pre><tt>[diff "tex"] |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 621 | xfuncname = "^(\\\\(sub)*section\\{.*)$"</tt></pre> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 622 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 623 | <div class="para"><p>Note. A single level of backslashes are eaten by the |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 624 | configuration file parser, so you would need to double the |
| 625 | backslashes; the pattern above picks a line that begins with a |
Junio C Hamano | a638742 | 2007-08-25 03:54:27 | [diff] [blame] | 626 | backslash, and zero or more occurrences of <tt>sub</tt> followed by |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 627 | <tt>section</tt> followed by open brace, to the end of line.</p></div> |
| 628 | <div class="para"><p>There are a few built-in patterns to make this easier, and <tt>tex</tt> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 629 | is one of them, so you do not have to write the above in your |
| 630 | configuration file (you still need to enable this with the |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 631 | attribute mechanism, via <tt>.gitattributes</tt>). The following built in |
| 632 | patterns are available:</p></div> |
| 633 | <div class="ilist"><ul> |
| 634 | <li> |
| 635 | <p> |
| 636 | <tt>bibtex</tt> suitable for files with BibTeX coded references. |
| 637 | </p> |
| 638 | </li> |
| 639 | <li> |
| 640 | <p> |
Junio C Hamano | f24b806 | 2008-09-09 01:34:39 | [diff] [blame] | 641 | <tt>html</tt> suitable for HTML/XHTML documents. |
| 642 | </p> |
| 643 | </li> |
| 644 | <li> |
| 645 | <p> |
Junio C Hamano | 675570c | 2008-09-13 06:07:28 | [diff] [blame] | 646 | <tt>java</tt> suitable for source code in the Java language. |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 647 | </p> |
| 648 | </li> |
| 649 | <li> |
| 650 | <p> |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 651 | <tt>objc</tt> suitable for source code in the Objective-C language. |
| 652 | </p> |
| 653 | </li> |
| 654 | <li> |
| 655 | <p> |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 656 | <tt>pascal</tt> suitable for source code in the Pascal/Delphi language. |
| 657 | </p> |
| 658 | </li> |
| 659 | <li> |
| 660 | <p> |
Junio C Hamano | f24b806 | 2008-09-09 01:34:39 | [diff] [blame] | 661 | <tt>php</tt> suitable for source code in the PHP language. |
| 662 | </p> |
| 663 | </li> |
| 664 | <li> |
| 665 | <p> |
Junio C Hamano | 3f2f6e5 | 2008-08-21 10:34:22 | [diff] [blame] | 666 | <tt>python</tt> suitable for source code in the Python language. |
| 667 | </p> |
| 668 | </li> |
| 669 | <li> |
| 670 | <p> |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 671 | <tt>ruby</tt> suitable for source code in the Ruby language. |
| 672 | </p> |
| 673 | </li> |
| 674 | <li> |
| 675 | <p> |
| 676 | <tt>tex</tt> suitable for source code for LaTeX documents. |
| 677 | </p> |
| 678 | </li> |
| 679 | </ul></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 680 | <h3 id="_performing_a_three_way_merge">Performing a three-way merge</h3><div style="clear:left"></div> |
| 681 | <div class="para"><p>The attribute <tt>merge</tt> affects how three versions of a file is |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 682 | merged when a file-level merge is necessary during <tt>git merge</tt>, |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 683 | and other programs such as <tt>git revert</tt> and <tt>git cherry-pick</tt>.</p></div> |
| 684 | <div class="vlist"><dl> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 685 | <dt> |
| 686 | Set |
| 687 | </dt> |
| 688 | <dd> |
| 689 | <p> |
| 690 | Built-in 3-way merge driver is used to merge the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 691 | contents in a way similar to <em>merge</em> command of <tt>RCS</tt> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 692 | suite. This is suitable for ordinary text files. |
| 693 | </p> |
| 694 | </dd> |
| 695 | <dt> |
| 696 | Unset |
| 697 | </dt> |
| 698 | <dd> |
| 699 | <p> |
| 700 | Take the version from the current branch as the |
| 701 | tentative merge result, and declare that the merge has |
| 702 | conflicts. This is suitable for binary files that does |
| 703 | not have a well-defined merge semantics. |
| 704 | </p> |
| 705 | </dd> |
| 706 | <dt> |
| 707 | Unspecified |
| 708 | </dt> |
| 709 | <dd> |
| 710 | <p> |
| 711 | By default, this uses the same built-in 3-way merge |
| 712 | driver as is the case the <tt>merge</tt> attribute is set. |
| 713 | However, <tt>merge.default</tt> configuration variable can name |
| 714 | different merge driver to be used for paths to which the |
| 715 | <tt>merge</tt> attribute is unspecified. |
| 716 | </p> |
| 717 | </dd> |
| 718 | <dt> |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 719 | String |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 720 | </dt> |
| 721 | <dd> |
| 722 | <p> |
| 723 | 3-way merge is performed using the specified custom |
| 724 | merge driver. The built-in 3-way merge driver can be |
| 725 | explicitly specified by asking for "text" driver; the |
| 726 | built-in "take the current branch" driver can be |
Junio C Hamano | 22572e7 | 2007-04-25 05:59:25 | [diff] [blame] | 727 | requested with "binary". |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 728 | </p> |
| 729 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 730 | </dl></div> |
| 731 | <h4 id="_built_in_merge_drivers">Built-in merge drivers</h4> |
| 732 | <div class="para"><p>There are a few built-in low-level merge drivers defined that |
| 733 | can be asked for via the <tt>merge</tt> attribute.</p></div> |
| 734 | <div class="vlist"><dl> |
Junio C Hamano | f556fc2 | 2007-12-23 08:16:38 | [diff] [blame] | 735 | <dt> |
| 736 | text |
| 737 | </dt> |
| 738 | <dd> |
| 739 | <p> |
| 740 | Usual 3-way file level merge for text files. Conflicted |
| 741 | regions are marked with conflict markers <tt><<<<<<<</tt>, |
| 742 | <tt>=======</tt> and <tt>>>>>>>></tt>. The version from your branch |
| 743 | appears before the <tt>=======</tt> marker, and the version |
| 744 | from the merged branch appears after the <tt>=======</tt> |
| 745 | marker. |
| 746 | </p> |
| 747 | </dd> |
| 748 | <dt> |
| 749 | binary |
| 750 | </dt> |
| 751 | <dd> |
| 752 | <p> |
| 753 | Keep the version from your branch in the work tree, but |
| 754 | leave the path in the conflicted state for the user to |
| 755 | sort out. |
| 756 | </p> |
| 757 | </dd> |
| 758 | <dt> |
| 759 | union |
| 760 | </dt> |
| 761 | <dd> |
| 762 | <p> |
| 763 | Run 3-way file level merge for text files, but take |
| 764 | lines from both versions, instead of leaving conflict |
| 765 | markers. This tends to leave the added lines in the |
| 766 | resulting file in random order and the user should |
| 767 | verify the result. Do not use this if you do not |
| 768 | understand the implications. |
| 769 | </p> |
| 770 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 771 | </dl></div> |
| 772 | <h4 id="_defining_a_custom_merge_driver">Defining a custom merge driver</h4> |
| 773 | <div class="para"><p>The definition of a merge driver is done in the <tt>.git/config</tt> |
Junio C Hamano | f556fc2 | 2007-12-23 08:16:38 | [diff] [blame] | 774 | file, not in the <tt>gitattributes</tt> file, so strictly speaking this |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 775 | manual page is a wrong place to talk about it. However…</p></div> |
| 776 | <div class="para"><p>To define a custom merge driver <tt>filfre</tt>, add a section to your |
| 777 | <tt>$GIT_DIR/config</tt> file (or <tt>$HOME/.gitconfig</tt> file) like this:</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 778 | <div class="listingblock"> |
| 779 | <div class="content"> |
| 780 | <pre><tt>[merge "filfre"] |
| 781 | name = feel-free merge driver |
| 782 | driver = filfre %O %A %B |
| 783 | recursive = binary</tt></pre> |
| 784 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 785 | <div class="para"><p>The <tt>merge.*.name</tt> variable gives the driver a human-readable |
| 786 | name.</p></div> |
| 787 | <div class="para"><p>The <tt>merge.*.driver</tt> variable's value is used to construct a |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 788 | command to run to merge ancestor's version (<tt>%O</tt>), current |
| 789 | version (<tt>%A</tt>) and the other branches' version (<tt>%B</tt>). These |
| 790 | three tokens are replaced with the names of temporary files that |
| 791 | hold the contents of these versions when the command line is |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 792 | built.</p></div> |
| 793 | <div class="para"><p>The merge driver is expected to leave the result of the merge in |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 794 | the file named with <tt>%A</tt> by overwriting it, and exit with zero |
| 795 | status if it managed to merge them cleanly, or non-zero if there |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 796 | were conflicts.</p></div> |
| 797 | <div class="para"><p>The <tt>merge.*.recursive</tt> variable specifies what other merge |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 798 | driver to use when the merge driver is called for an internal |
| 799 | merge between common ancestors, when there are more than one. |
| 800 | When left unspecified, the driver itself is used for both |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 801 | internal merge and the final merge.</p></div> |
| 802 | <h3 id="_checking_whitespace_errors">Checking whitespace errors</h3><div style="clear:left"></div> |
| 803 | <h4 id="_tt_whitespace_tt"><tt>whitespace</tt></h4> |
| 804 | <div class="para"><p>The <tt>core.whitespace</tt> configuration variable allows you to define what |
| 805 | <em>diff</em> and <em>apply</em> should consider whitespace errors for all paths in |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 806 | the project (See <a href="git-config.html">git-config(1)</a>). This attribute gives you finer |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 807 | control per path.</p></div> |
| 808 | <div class="vlist"><dl> |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 809 | <dt> |
| 810 | Set |
| 811 | </dt> |
| 812 | <dd> |
| 813 | <p> |
| 814 | Notice all types of potential whitespace errors known to git. |
| 815 | </p> |
| 816 | </dd> |
| 817 | <dt> |
| 818 | Unset |
| 819 | </dt> |
| 820 | <dd> |
| 821 | <p> |
| 822 | Do not notice anything as error. |
| 823 | </p> |
| 824 | </dd> |
| 825 | <dt> |
| 826 | Unspecified |
| 827 | </dt> |
| 828 | <dd> |
| 829 | <p> |
| 830 | Use the value of <tt>core.whitespace</tt> configuration variable to |
| 831 | decide what to notice as error. |
| 832 | </p> |
| 833 | </dd> |
| 834 | <dt> |
| 835 | String |
| 836 | </dt> |
| 837 | <dd> |
| 838 | <p> |
| 839 | Specify a comma separate list of common whitespace problems to |
| 840 | notice in the same format as <tt>core.whitespace</tt> configuration |
| 841 | variable. |
| 842 | </p> |
| 843 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 844 | </dl></div> |
| 845 | <h3 id="_creating_an_archive">Creating an archive</h3><div style="clear:left"></div> |
| 846 | <h4 id="_tt_export_ignore_tt"><tt>export-ignore</tt></h4> |
| 847 | <div class="para"><p>Files and directories with the attribute <tt>export-ignore</tt> won't be added to |
| 848 | archive files.</p></div> |
| 849 | <h4 id="_tt_export_subst_tt"><tt>export-subst</tt></h4> |
| 850 | <div class="para"><p>If the attribute <tt>export-subst</tt> is set for a file then git will expand |
| 851 | several placeholders when adding this file to an archive. The |
| 852 | expansion depends on the availability of a commit ID, i.e., if |
| 853 | <a href="git-archive.html">git-archive(1)</a> has been given a tree instead of a commit or a |
| 854 | tag then no replacement will be done. The placeholders are the same |
| 855 | as those for the option <tt>--pretty=format:</tt> of <a href="git-log.html">git-log(1)</a>, |
| 856 | except that they need to be wrapped like this: <tt>$Format:PLACEHOLDERS$</tt> |
| 857 | in the file. E.g. the string <tt>$Format:%H$</tt> will be replaced by the |
| 858 | commit hash.</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 859 | </div> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 860 | <h2 id="_using_attribute_macros">USING ATTRIBUTE MACROS</h2> |
| 861 | <div class="sectionbody"> |
| 862 | <div class="para"><p>You do not want any end-of-line conversions applied to, nor textual diffs |
| 863 | produced for, any binary file you track. You would need to specify e.g.</p></div> |
| 864 | <div class="listingblock"> |
| 865 | <div class="content"> |
| 866 | <pre><tt>*.jpg -crlf -diff</tt></pre> |
| 867 | </div></div> |
| 868 | <div class="para"><p>but that may become cumbersome, when you have many attributes. Using |
| 869 | attribute macros, you can specify groups of attributes set or unset at |
| 870 | the same time. The system knows a built-in attribute macro, <tt>binary</tt>:</p></div> |
| 871 | <div class="listingblock"> |
| 872 | <div class="content"> |
| 873 | <pre><tt>*.jpg binary</tt></pre> |
| 874 | </div></div> |
| 875 | <div class="para"><p>which is equivalent to the above. Note that the attribute macros can only |
| 876 | be "Set" (see the above example that sets "binary" macro as if it were an |
| 877 | ordinary attribute --- setting it in turn unsets "crlf" and "diff").</p></div> |
| 878 | </div> |
| 879 | <h2 id="_defining_attribute_macros">DEFINING ATTRIBUTE MACROS</h2> |
| 880 | <div class="sectionbody"> |
| 881 | <div class="para"><p>Custom attribute macros can be defined only in the <tt>.gitattributes</tt> file |
| 882 | at the toplevel (i.e. not in any subdirectory). The built-in attribute |
| 883 | macro "binary" is equivalent to:</p></div> |
| 884 | <div class="listingblock"> |
| 885 | <div class="content"> |
| 886 | <pre><tt>[attr]binary -diff -crlf</tt></pre> |
| 887 | </div></div> |
| 888 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 889 | <h2 id="_example">EXAMPLE</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 890 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 891 | <div class="para"><p>If you have these three <tt>gitattributes</tt> file:</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 892 | <div class="listingblock"> |
| 893 | <div class="content"> |
| 894 | <pre><tt>(in $GIT_DIR/info/attributes) |
| 895 | |
| 896 | a* foo !bar -baz |
| 897 | |
| 898 | (in .gitattributes) |
| 899 | abc foo bar baz |
| 900 | |
| 901 | (in t/.gitattributes) |
| 902 | ab* merge=filfre |
| 903 | abc -foo -bar |
| 904 | *.c frotz</tt></pre> |
| 905 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 906 | <div class="para"><p>the attributes given to path <tt>t/abc</tt> are computed as follows:</p></div> |
| 907 | <div class="olist"><ol> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 908 | <li> |
| 909 | <p> |
| 910 | By examining <tt>t/.gitattributes</tt> (which is in the same |
Junio C Hamano | a638742 | 2007-08-25 03:54:27 | [diff] [blame] | 911 | directory as the path in question), git finds that the first |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 912 | line matches. <tt>merge</tt> attribute is set. It also finds that |
| 913 | the second line matches, and attributes <tt>foo</tt> and <tt>bar</tt> |
| 914 | are unset. |
| 915 | </p> |
| 916 | </li> |
| 917 | <li> |
| 918 | <p> |
| 919 | Then it examines <tt>.gitattributes</tt> (which is in the parent |
| 920 | directory), and finds that the first line matches, but |
| 921 | <tt>t/.gitattributes</tt> file already decided how <tt>merge</tt>, <tt>foo</tt> |
| 922 | and <tt>bar</tt> attributes should be given to this path, so it |
| 923 | leaves <tt>foo</tt> and <tt>bar</tt> unset. Attribute <tt>baz</tt> is set. |
| 924 | </p> |
| 925 | </li> |
| 926 | <li> |
| 927 | <p> |
Junio C Hamano | bdeff82 | 2007-07-30 09:07:17 | [diff] [blame] | 928 | Finally it examines <tt>$GIT_DIR/info/attributes</tt>. This file |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 929 | is used to override the in-tree settings. The first line is |
| 930 | a match, and <tt>foo</tt> is set, <tt>bar</tt> is reverted to unspecified |
| 931 | state, and <tt>baz</tt> is unset. |
| 932 | </p> |
| 933 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 934 | </ol></div> |
| 935 | <div class="para"><p>As the result, the attributes assignment to <tt>t/abc</tt> becomes:</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 936 | <div class="listingblock"> |
| 937 | <div class="content"> |
| 938 | <pre><tt>foo set to true |
| 939 | bar unspecified |
| 940 | baz set to false |
| 941 | merge set to string value "filfre" |
| 942 | frotz unspecified</tt></pre> |
| 943 | </div></div> |
| 944 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 945 | <h2 id="_git">GIT</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 946 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 947 | <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 948 | </div> |
| 949 | <div id="footer"> |
| 950 | <div id="footer-text"> |
Junio C Hamano | 6f1bbb7 | 2008-10-31 11:32:55 | [diff] [blame^] | 951 | Last updated 2008-10-31 11:28:59 UTC |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 952 | </div> |
| 953 | </div> |
| 954 | </body> |
| 955 | </html> |