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> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 5 | <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 8.6.9" /> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 7 | <title>gitattributes(5)</title> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 8 | <style type="text/css"> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 9 | /* Shared CSS for AsciiDoc xhtml11 and html5 backends */ |
| 10 | |
| 11 | /* Default font. */ |
| 12 | body { |
| 13 | font-family: Georgia,serif; |
| 14 | } |
| 15 | |
| 16 | /* Title font. */ |
| 17 | h1, h2, h3, h4, h5, h6, |
| 18 | div.title, caption.title, |
| 19 | thead, p.table.header, |
| 20 | #toctitle, |
| 21 | #author, #revnumber, #revdate, #revremark, |
| 22 | #footer { |
| 23 | font-family: Arial,Helvetica,sans-serif; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | body { |
| 27 | margin: 1em 5% 1em 5%; |
| 28 | } |
| 29 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 30 | a { |
| 31 | color: blue; |
| 32 | text-decoration: underline; |
| 33 | } |
| 34 | a:visited { |
| 35 | color: fuchsia; |
| 36 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 37 | |
| 38 | em { |
| 39 | font-style: italic; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 40 | color: navy; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | strong { |
| 44 | font-weight: bold; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 45 | color: #083194; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 46 | } |
| 47 | |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 48 | h1, h2, h3, h4, h5, h6 { |
| 49 | color: #527bbd; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 50 | margin-top: 1.2em; |
| 51 | margin-bottom: 0.5em; |
| 52 | line-height: 1.3; |
| 53 | } |
| 54 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 55 | h1, h2, h3 { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 56 | border-bottom: 2px solid silver; |
| 57 | } |
| 58 | h2 { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 59 | padding-top: 0.5em; |
| 60 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 61 | h3 { |
| 62 | float: left; |
| 63 | } |
| 64 | h3 + * { |
| 65 | clear: left; |
| 66 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 67 | h5 { |
| 68 | font-size: 1.0em; |
| 69 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 70 | |
| 71 | div.sectionbody { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 72 | margin-left: 0; |
| 73 | } |
| 74 | |
| 75 | hr { |
| 76 | border: 1px solid silver; |
| 77 | } |
| 78 | |
| 79 | p { |
| 80 | margin-top: 0.5em; |
| 81 | margin-bottom: 0.5em; |
| 82 | } |
| 83 | |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 84 | ul, ol, li > p { |
| 85 | margin-top: 0; |
| 86 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 87 | ul > li { color: #aaa; } |
| 88 | ul > li > * { color: black; } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 89 | |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 90 | .monospaced, code, pre { |
| 91 | font-family: "Courier New", Courier, monospace; |
| 92 | font-size: inherit; |
| 93 | color: navy; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 94 | padding: 0; |
| 95 | margin: 0; |
| 96 | } |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 97 | pre { |
| 98 | white-space: pre-wrap; |
| 99 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 100 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 101 | #author { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 102 | color: #527bbd; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 103 | font-weight: bold; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 104 | font-size: 1.1em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 105 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 106 | #email { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 107 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 108 | #revnumber, #revdate, #revremark { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 109 | } |
| 110 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 111 | #footer { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 112 | font-size: small; |
| 113 | border-top: 2px solid silver; |
| 114 | padding-top: 0.5em; |
| 115 | margin-top: 4.0em; |
| 116 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 117 | #footer-text { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 118 | float: left; |
| 119 | padding-bottom: 0.5em; |
| 120 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 121 | #footer-badges { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 122 | float: right; |
| 123 | padding-bottom: 0.5em; |
| 124 | } |
| 125 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 126 | #preamble { |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 127 | margin-top: 1.5em; |
| 128 | margin-bottom: 1.5em; |
| 129 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 130 | div.imageblock, div.exampleblock, div.verseblock, |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 131 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 132 | div.admonitionblock { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 133 | margin-top: 1.0em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 134 | margin-bottom: 1.5em; |
| 135 | } |
| 136 | div.admonitionblock { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 137 | margin-top: 2.0em; |
| 138 | margin-bottom: 2.0em; |
| 139 | margin-right: 10%; |
| 140 | color: #606060; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | div.content { /* Block element content. */ |
| 144 | padding: 0; |
| 145 | } |
| 146 | |
| 147 | /* Block element titles. */ |
| 148 | div.title, caption.title { |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 149 | color: #527bbd; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 150 | font-weight: bold; |
| 151 | text-align: left; |
| 152 | margin-top: 1.0em; |
| 153 | margin-bottom: 0.5em; |
| 154 | } |
| 155 | div.title + * { |
| 156 | margin-top: 0; |
| 157 | } |
| 158 | |
| 159 | td div.title:first-child { |
| 160 | margin-top: 0.0em; |
| 161 | } |
| 162 | div.content div.title:first-child { |
| 163 | margin-top: 0.0em; |
| 164 | } |
| 165 | div.content + div.title { |
| 166 | margin-top: 0.0em; |
| 167 | } |
| 168 | |
| 169 | div.sidebarblock > div.content { |
| 170 | background: #ffffee; |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 171 | border: 1px solid #dddddd; |
| 172 | border-left: 4px solid #f0f0f0; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 173 | padding: 0.5em; |
| 174 | } |
| 175 | |
| 176 | div.listingblock > div.content { |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 177 | border: 1px solid #dddddd; |
| 178 | border-left: 5px solid #f0f0f0; |
| 179 | background: #f8f8f8; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 180 | padding: 0.5em; |
| 181 | } |
| 182 | |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 183 | div.quoteblock, div.verseblock { |
| 184 | padding-left: 1.0em; |
| 185 | margin-left: 1.0em; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 186 | margin-right: 10%; |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 187 | border-left: 5px solid #f0f0f0; |
| 188 | color: #888; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 189 | } |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 190 | |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 191 | div.quoteblock > div.attribution { |
| 192 | padding-top: 0.5em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 193 | text-align: right; |
| 194 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 195 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 196 | div.verseblock > pre.content { |
| 197 | font-family: inherit; |
| 198 | font-size: inherit; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 199 | } |
| 200 | div.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 Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 205 | div.verseblock + div.attribution { |
| 206 | text-align: left; |
| 207 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 208 | |
| 209 | div.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 | } |
| 217 | div.admonitionblock td.content { |
| 218 | padding-left: 0.5em; |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 219 | border-left: 3px solid #dddddd; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | div.exampleblock > div.content { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 223 | border-left: 3px solid #dddddd; |
| 224 | padding-left: 0.5em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 225 | } |
| 226 | |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 227 | div.imageblock div.content { padding-left: 0; } |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 228 | span.image img { border-style: none; vertical-align: text-bottom; } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 229 | a.image:visited { color: white; } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 230 | |
| 231 | dl { |
| 232 | margin-top: 0.8em; |
| 233 | margin-bottom: 0.8em; |
| 234 | } |
| 235 | dt { |
| 236 | margin-top: 0.5em; |
| 237 | margin-bottom: 0; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 238 | font-style: normal; |
| 239 | color: navy; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 240 | } |
| 241 | dd > *:first-child { |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 242 | margin-top: 0.1em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | ul, ol { |
| 246 | list-style-position: outside; |
| 247 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 248 | ol.arabic { |
| 249 | list-style-type: decimal; |
| 250 | } |
| 251 | ol.loweralpha { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 252 | list-style-type: lower-alpha; |
| 253 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 254 | ol.upperalpha { |
| 255 | list-style-type: upper-alpha; |
| 256 | } |
| 257 | ol.lowerroman { |
| 258 | list-style-type: lower-roman; |
| 259 | } |
| 260 | ol.upperroman { |
| 261 | list-style-type: upper-roman; |
| 262 | } |
| 263 | |
| 264 | div.compact ul, div.compact ol, |
| 265 | div.compact p, div.compact p, |
| 266 | div.compact div, div.compact div { |
| 267 | margin-top: 0.1em; |
| 268 | margin-bottom: 0.1em; |
| 269 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 270 | |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 271 | tfoot { |
| 272 | font-weight: bold; |
| 273 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 274 | td > div.verse { |
| 275 | white-space: pre; |
| 276 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 277 | |
| 278 | div.hdlist { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 279 | margin-top: 0.8em; |
| 280 | margin-bottom: 0.8em; |
| 281 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 282 | div.hdlist tr { |
| 283 | padding-bottom: 15px; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 284 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 285 | dt.hdlist1.strong, td.hdlist1.strong { |
| 286 | font-weight: bold; |
| 287 | } |
| 288 | td.hdlist1 { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 289 | vertical-align: top; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 290 | font-style: normal; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 291 | padding-right: 0.8em; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 292 | color: navy; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 293 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 294 | td.hdlist2 { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 295 | vertical-align: top; |
| 296 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 297 | div.hdlist.compact tr { |
| 298 | margin: 0; |
| 299 | padding-bottom: 0; |
| 300 | } |
| 301 | |
| 302 | .comment { |
| 303 | background: yellow; |
| 304 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 305 | |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 306 | .footnote, .footnoteref { |
| 307 | font-size: 0.8em; |
| 308 | } |
| 309 | |
| 310 | span.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 Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 333 | div.colist td { |
| 334 | padding-right: 0.5em; |
| 335 | padding-bottom: 0.3em; |
| 336 | vertical-align: top; |
| 337 | } |
| 338 | div.colist td img { |
| 339 | margin-top: 0.3em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 340 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 341 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 342 | @media print { |
| 343 | #footer-badges { display: none; } |
| 344 | } |
| 345 | |
| 346 | #toc { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 347 | margin-bottom: 2.5em; |
| 348 | } |
| 349 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 350 | #toctitle { |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 351 | color: #527bbd; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 352 | font-size: 1.1em; |
| 353 | font-weight: bold; |
| 354 | margin-top: 1.0em; |
| 355 | margin-bottom: 0.1em; |
| 356 | } |
| 357 | |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 358 | div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 359 | margin-top: 0; |
| 360 | margin-bottom: 0; |
| 361 | } |
| 362 | div.toclevel2 { |
| 363 | margin-left: 2em; |
| 364 | font-size: 0.9em; |
| 365 | } |
| 366 | div.toclevel3 { |
| 367 | margin-left: 4em; |
| 368 | font-size: 0.9em; |
| 369 | } |
| 370 | div.toclevel4 { |
| 371 | margin-left: 6em; |
| 372 | font-size: 0.9em; |
| 373 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 374 | |
| 375 | span.aqua { color: aqua; } |
| 376 | span.black { color: black; } |
| 377 | span.blue { color: blue; } |
| 378 | span.fuchsia { color: fuchsia; } |
| 379 | span.gray { color: gray; } |
| 380 | span.green { color: green; } |
| 381 | span.lime { color: lime; } |
| 382 | span.maroon { color: maroon; } |
| 383 | span.navy { color: navy; } |
| 384 | span.olive { color: olive; } |
| 385 | span.purple { color: purple; } |
| 386 | span.red { color: red; } |
| 387 | span.silver { color: silver; } |
| 388 | span.teal { color: teal; } |
| 389 | span.white { color: white; } |
| 390 | span.yellow { color: yellow; } |
| 391 | |
| 392 | span.aqua-background { background: aqua; } |
| 393 | span.black-background { background: black; } |
| 394 | span.blue-background { background: blue; } |
| 395 | span.fuchsia-background { background: fuchsia; } |
| 396 | span.gray-background { background: gray; } |
| 397 | span.green-background { background: green; } |
| 398 | span.lime-background { background: lime; } |
| 399 | span.maroon-background { background: maroon; } |
| 400 | span.navy-background { background: navy; } |
| 401 | span.olive-background { background: olive; } |
| 402 | span.purple-background { background: purple; } |
| 403 | span.red-background { background: red; } |
| 404 | span.silver-background { background: silver; } |
| 405 | span.teal-background { background: teal; } |
| 406 | span.white-background { background: white; } |
| 407 | span.yellow-background { background: yellow; } |
| 408 | |
| 409 | span.big { font-size: 2em; } |
| 410 | span.small { font-size: 0.6em; } |
| 411 | |
| 412 | span.underline { text-decoration: underline; } |
| 413 | span.overline { text-decoration: overline; } |
| 414 | span.line-through { text-decoration: line-through; } |
| 415 | |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 416 | div.unbreakable { page-break-inside: avoid; } |
| 417 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 418 | |
| 419 | /* |
| 420 | * xhtml11 specific |
| 421 | * |
| 422 | * */ |
| 423 | |
| 424 | div.tableblock { |
| 425 | margin-top: 1.0em; |
| 426 | margin-bottom: 1.5em; |
| 427 | } |
| 428 | div.tableblock > table { |
| 429 | border: 3px solid #527bbd; |
| 430 | } |
| 431 | thead, p.table.header { |
| 432 | font-weight: bold; |
| 433 | color: #527bbd; |
| 434 | } |
| 435 | p.table { |
| 436 | margin-top: 0; |
| 437 | } |
| 438 | /* Because the table frame attribute is overriden by CSS in most browsers. */ |
| 439 | div.tableblock > table[frame="void"] { |
| 440 | border-style: none; |
| 441 | } |
| 442 | div.tableblock > table[frame="hsides"] { |
| 443 | border-left-style: none; |
| 444 | border-right-style: none; |
| 445 | } |
| 446 | div.tableblock > table[frame="vsides"] { |
| 447 | border-top-style: none; |
| 448 | border-bottom-style: none; |
| 449 | } |
| 450 | |
| 451 | |
| 452 | /* |
| 453 | * html5 specific |
| 454 | * |
| 455 | * */ |
| 456 | |
| 457 | table.tableblock { |
| 458 | margin-top: 1.0em; |
| 459 | margin-bottom: 1.5em; |
| 460 | } |
| 461 | thead, p.tableblock.header { |
| 462 | font-weight: bold; |
| 463 | color: #527bbd; |
| 464 | } |
| 465 | p.tableblock { |
| 466 | margin-top: 0; |
| 467 | } |
| 468 | table.tableblock { |
| 469 | border-width: 3px; |
| 470 | border-spacing: 0px; |
| 471 | border-style: solid; |
| 472 | border-color: #527bbd; |
| 473 | border-collapse: collapse; |
| 474 | } |
| 475 | th.tableblock, td.tableblock { |
| 476 | border-width: 1px; |
| 477 | padding: 4px; |
| 478 | border-style: solid; |
| 479 | border-color: #527bbd; |
| 480 | } |
| 481 | |
| 482 | table.tableblock.frame-topbot { |
| 483 | border-left-style: hidden; |
| 484 | border-right-style: hidden; |
| 485 | } |
| 486 | table.tableblock.frame-sides { |
| 487 | border-top-style: hidden; |
| 488 | border-bottom-style: hidden; |
| 489 | } |
| 490 | table.tableblock.frame-none { |
| 491 | border-style: hidden; |
| 492 | } |
| 493 | |
| 494 | th.tableblock.halign-left, td.tableblock.halign-left { |
| 495 | text-align: left; |
| 496 | } |
| 497 | th.tableblock.halign-center, td.tableblock.halign-center { |
| 498 | text-align: center; |
| 499 | } |
| 500 | th.tableblock.halign-right, td.tableblock.halign-right { |
| 501 | text-align: right; |
| 502 | } |
| 503 | |
| 504 | th.tableblock.valign-top, td.tableblock.valign-top { |
| 505 | vertical-align: top; |
| 506 | } |
| 507 | th.tableblock.valign-middle, td.tableblock.valign-middle { |
| 508 | vertical-align: middle; |
| 509 | } |
| 510 | th.tableblock.valign-bottom, td.tableblock.valign-bottom { |
| 511 | vertical-align: bottom; |
| 512 | } |
| 513 | |
| 514 | |
| 515 | /* |
| 516 | * manpage specific |
| 517 | * |
| 518 | * */ |
| 519 | |
| 520 | body.manpage h1 { |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 521 | padding-top: 0.5em; |
| 522 | padding-bottom: 0.5em; |
| 523 | border-top: 2px solid silver; |
| 524 | border-bottom: 2px solid silver; |
| 525 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 526 | body.manpage h2 { |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 527 | border-style: none; |
| 528 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 529 | body.manpage div.sectionbody { |
| 530 | margin-left: 3em; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | @media print { |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 534 | body.manpage div#toc { display: none; } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 535 | } |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 536 | |
| 537 | |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 538 | </style> |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 539 | <script type="text/javascript"> |
| 540 | /*<![CDATA[*/ |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 541 | var 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. |
| 561 | toc: 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 Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 582 | var re = new RegExp('[hH]([1-'+(toclevels+1)+'])'); |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 583 | // 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 Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 602 | 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 Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 611 | if (entry.nodeName.toLowerCase() == 'div' |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 612 | && 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 Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 621 | 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 | |
| 647 | footnotes: function () { |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 648 | // Delete existing footnote entries in case we're reloading the footnodes. |
| 649 | var i; |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 650 | var noteholder = document.getElementById("footnotes"); |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 651 | 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 Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 657 | if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote") |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 658 | 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 Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 666 | 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 Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 672 | 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 Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 682 | 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 Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 686 | 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 Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 705 | }, |
| 706 | |
| 707 | install: 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 Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 730 | asciidoc.install(); |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 731 | /*]]>*/ |
| 732 | </script> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 733 | </head> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 734 | <body class="manpage"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 735 | <div id="header"> |
| 736 | <h1> |
| 737 | gitattributes(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 Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 746 | <div id="content"> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 747 | <div class="sect1"> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 748 | <h2 id="_synopsis">SYNOPSIS</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 749 | <div class="sectionbody"> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 750 | <div class="paragraph"><p>$GIT_DIR/info/attributes, .gitattributes</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 751 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 752 | </div> |
| 753 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 754 | <h2 id="_description">DESCRIPTION</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 755 | <div class="sectionbody"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 756 | <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 Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 759 | <div class="literalblock"> |
| 760 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 761 | <pre><code>pattern attr1 attr2 ...</code></pre> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 762 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 763 | <div class="paragraph"><p>That is, a pattern followed by an attributes list, |
Junio C Hamano | d533bdb | 2009-02-25 09:56:58 | [diff] [blame] | 764 | separated by whitespaces. When the pattern matches the |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 765 | path in question, the attributes listed on the line are given to |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 766 | the path.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 767 | <div class="paragraph"><p>Each attribute can be in one of these states for a given path:</p></div> |
| 768 | <div class="dlist"><dl> |
| 769 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 770 | Set |
| 771 | </dt> |
| 772 | <dd> |
| 773 | <p> |
| 774 | The path has the attribute with special value "true"; |
| 775 | this is specified by listing only the name of the |
| 776 | attribute in the attribute list. |
| 777 | </p> |
| 778 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 779 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 780 | Unset |
| 781 | </dt> |
| 782 | <dd> |
| 783 | <p> |
| 784 | The path has the attribute with special value "false"; |
| 785 | this is specified by listing the name of the attribute |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 786 | prefixed with a dash <code>-</code> in the attribute list. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 787 | </p> |
| 788 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 789 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 790 | Set to a value |
| 791 | </dt> |
| 792 | <dd> |
| 793 | <p> |
| 794 | The path has the attribute with specified string value; |
| 795 | this is specified by listing the name of the attribute |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 796 | followed by an equal sign <code>=</code> and its value in the |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 797 | attribute list. |
| 798 | </p> |
| 799 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 800 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 801 | Unspecified |
| 802 | </dt> |
| 803 | <dd> |
| 804 | <p> |
Junio C Hamano | d533bdb | 2009-02-25 09:56:58 | [diff] [blame] | 805 | No pattern matches the path, and nothing says if |
Junio C Hamano | 22572e7 | 2007-04-25 05:59:25 | [diff] [blame] | 806 | the path has or does not have the attribute, the |
| 807 | attribute for the path is said to be Unspecified. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 808 | </p> |
| 809 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 810 | </dl></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 811 | <div class="paragraph"><p>When more than one pattern matches the path, a later line |
Junio C Hamano | 22572e7 | 2007-04-25 05:59:25 | [diff] [blame] | 812 | overrides an earlier line. This overriding is done per |
Junio C Hamano | d533bdb | 2009-02-25 09:56:58 | [diff] [blame] | 813 | attribute. The rules how the pattern matches paths are the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 814 | same as in <code>.gitignore</code> files; see <a href="gitignore.html">gitignore(5)</a>. |
| 815 | Unlike <code>.gitignore</code>, negative patterns are forbidden.</p></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 816 | <div class="paragraph"><p>When deciding what attributes are assigned to a path, Git |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 817 | consults <code>$GIT_DIR/info/attributes</code> file (which has the highest |
| 818 | precedence), <code>.gitattributes</code> file in the same directory as the |
Junio C Hamano | b4a9ede | 2009-04-08 07:36:32 | [diff] [blame] | 819 | path in question, and its parent directories up to the toplevel of the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 820 | work tree (the further the directory that contains <code>.gitattributes</code> |
Junio C Hamano | 3b4609d | 2010-09-30 00:04:34 | [diff] [blame] | 821 | is from the path in question, the lower its precedence). Finally |
| 822 | global and system-wide files are considered (they have the lowest |
| 823 | precedence).</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 824 | <div class="paragraph"><p>When the <code>.gitattributes</code> file is missing from the work tree, the |
Junio C Hamano | 6631a09 | 2012-10-10 22:50:57 | [diff] [blame] | 825 | path in the index is used as a fall-back. During checkout process, |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 826 | <code>.gitattributes</code> in the index is used and then the file in the |
Junio C Hamano | 6631a09 | 2012-10-10 22:50:57 | [diff] [blame] | 827 | working tree is used as a fall-back.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 828 | <div class="paragraph"><p>If you wish to affect only a single repository (i.e., to assign |
Junio C Hamano | 3b4609d | 2010-09-30 00:04:34 | [diff] [blame] | 829 | attributes to files that are particular to |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 830 | one user’s workflow for that repository), then |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 831 | attributes should be placed in the <code>$GIT_DIR/info/attributes</code> file. |
Junio C Hamano | 99dc24a | 2008-03-27 23:49:50 | [diff] [blame] | 832 | Attributes which should be version-controlled and distributed to other |
| 833 | repositories (i.e., attributes of interest to all users) should go into |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 834 | <code>.gitattributes</code> files. Attributes that should affect all repositories |
Junio C Hamano | 3b4609d | 2010-09-30 00:04:34 | [diff] [blame] | 835 | for a single user should be placed in a file specified by the |
Junio C Hamano | 322c624 | 2015-03-23 21:32:46 | [diff] [blame] | 836 | <code>core.attributesFile</code> configuration option (see <a href="git-config.html">git-config(1)</a>). |
Junio C Hamano | 8edb4c7 | 2012-07-09 20:33:55 | [diff] [blame] | 837 | Its default value is $XDG_CONFIG_HOME/git/attributes. If $XDG_CONFIG_HOME |
| 838 | is either not set or empty, $HOME/.config/git/attributes is used instead. |
Junio C Hamano | 3b4609d | 2010-09-30 00:04:34 | [diff] [blame] | 839 | Attributes for all users on a system should be placed in the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 840 | <code>$(prefix)/etc/gitattributes</code> file.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 841 | <div class="paragraph"><p>Sometimes you would need to override an setting of an attribute |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 842 | for a path to <code>Unspecified</code> state. This can be done by listing |
| 843 | the name of the attribute prefixed with an exclamation point <code>!</code>.</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 844 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 845 | </div> |
| 846 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 847 | <h2 id="_effects">EFFECTS</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 848 | <div class="sectionbody"> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 849 | <div class="paragraph"><p>Certain operations by Git can be influenced by assigning |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 850 | particular attributes to a path. Currently, the following |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 851 | operations are attributes-aware.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 852 | <div class="sect2"> |
| 853 | <h3 id="_checking_out_and_checking_in">Checking-out and checking-in</h3> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 854 | <div class="paragraph"><p>These attributes affect how the contents stored in the |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 855 | repository are copied to the working tree files when commands |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 856 | such as <em>git checkout</em> and <em>git merge</em> run. They also affect how |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 857 | Git stores the contents you prepare in the working tree in the |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 858 | repository upon <em>git add</em> and <em>git commit</em>.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 859 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 860 | <h4 id="_code_text_code"><code>text</code></h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 861 | <div class="paragraph"><p>This attribute enables and controls end-of-line normalization. When a |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 862 | text file is normalized, its line endings are converted to LF in the |
| 863 | repository. To control what line ending style is used in the working |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 864 | directory, use the <code>eol</code> attribute for a single file and the |
| 865 | <code>core.eol</code> configuration variable for all text files.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 866 | <div class="dlist"><dl> |
| 867 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 868 | Set |
| 869 | </dt> |
| 870 | <dd> |
| 871 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 872 | Setting the <code>text</code> attribute on a path enables end-of-line |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 873 | normalization and marks the path as a text file. End-of-line |
| 874 | conversion takes place without guessing the content type. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 875 | </p> |
| 876 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 877 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 878 | Unset |
| 879 | </dt> |
| 880 | <dd> |
| 881 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 882 | Unsetting the <code>text</code> attribute on a path tells Git not to |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 883 | attempt any end-of-line conversion upon checkin or checkout. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 884 | </p> |
| 885 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 886 | <dt class="hdlist1"> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 887 | Set to string value "auto" |
| 888 | </dt> |
| 889 | <dd> |
| 890 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 891 | When <code>text</code> is set to "auto", the path is marked for automatic |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 892 | end-of-line normalization. If Git decides that the content is |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 893 | text, its line endings are normalized to LF on checkin. |
| 894 | </p> |
| 895 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 896 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 897 | Unspecified |
| 898 | </dt> |
| 899 | <dd> |
| 900 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 901 | If the <code>text</code> attribute is unspecified, Git uses the |
| 902 | <code>core.autocrlf</code> configuration variable to determine if the |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 903 | file should be converted. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 904 | </p> |
| 905 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 906 | </dl></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 907 | <div class="paragraph"><p>Any other value causes Git to act as if <code>text</code> has been left |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 908 | unspecified.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 909 | </div> |
| 910 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 911 | <h4 id="_code_eol_code"><code>eol</code></h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 912 | <div class="paragraph"><p>This attribute sets a specific line-ending style to be used in the |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 913 | working directory. It enables end-of-line normalization without any |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 914 | content checks, effectively setting the <code>text</code> attribute.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 915 | <div class="dlist"><dl> |
| 916 | <dt class="hdlist1"> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 917 | Set to string value "crlf" |
| 918 | </dt> |
| 919 | <dd> |
| 920 | <p> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 921 | This setting forces Git to normalize line endings for this |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 922 | file on checkin and convert them to CRLF when the file is |
| 923 | checked out. |
| 924 | </p> |
| 925 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 926 | <dt class="hdlist1"> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 927 | Set to string value "lf" |
| 928 | </dt> |
| 929 | <dd> |
| 930 | <p> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 931 | This setting forces Git to normalize line endings to LF on |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 932 | checkin and prevents conversion to CRLF when the file is |
| 933 | checked out. |
| 934 | </p> |
| 935 | </dd> |
| 936 | </dl></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 937 | </div> |
| 938 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 939 | <h4 id="_backwards_compatibility_with_code_crlf_code_attribute">Backwards compatibility with <code>crlf</code> attribute</h4> |
| 940 | <div class="paragraph"><p>For backwards compatibility, the <code>crlf</code> attribute is interpreted as |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 941 | follows:</p></div> |
| 942 | <div class="listingblock"> |
| 943 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 944 | <pre><code>crlf text |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 945 | -crlf -text |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 946 | crlf=input eol=lf</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 947 | </div></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 948 | </div> |
| 949 | <div class="sect3"> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 950 | <h4 id="_end_of_line_conversion">End-of-line conversion</h4> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 951 | <div class="paragraph"><p>While Git normally leaves file contents alone, it can be configured to |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 952 | normalize line endings to LF in the repository and, optionally, to |
| 953 | convert them to CRLF when files are checked out.</p></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 954 | <div class="paragraph"><p>Here is an example that will make Git normalize .txt, .vcproj and .sh |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 955 | files, ensure that .vcproj files have CRLF and .sh files have LF in |
| 956 | the working directory, and prevent .jpg files from being normalized |
| 957 | regardless of their content.</p></div> |
| 958 | <div class="listingblock"> |
| 959 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 960 | <pre><code>*.txt text |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 961 | *.vcproj eol=crlf |
| 962 | *.sh eol=lf |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 963 | *.jpg -text</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 964 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 965 | <div class="paragraph"><p>Other source code management systems normalize all text files in their |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 966 | repositories, and there are two ways to enable similar automatic |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 967 | normalization in Git.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 968 | <div class="paragraph"><p>If you simply want to have CRLF line endings in your working directory |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 969 | regardless of the repository you are working with, you can set the |
| 970 | config variable "core.autocrlf" without changing any attributes.</p></div> |
| 971 | <div class="listingblock"> |
| 972 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 973 | <pre><code>[core] |
| 974 | autocrlf = true</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 975 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 976 | <div class="paragraph"><p>This does not force normalization of all text files, but does ensure |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 977 | that text files that you introduce to the repository have their line |
| 978 | endings normalized to LF when they are added, and that files that are |
| 979 | already normalized in the repository stay normalized.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 980 | <div class="paragraph"><p>If you want to interoperate with a source code management system that |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 981 | enforces end-of-line normalization, or you simply want all text files |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 982 | in your repository to be normalized, you should instead set the <code>text</code> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 983 | attribute to "auto" for <em>all</em> files.</p></div> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 984 | <div class="listingblock"> |
| 985 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 986 | <pre><code>* text=auto</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 987 | </div></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 988 | <div class="paragraph"><p>This ensures that all files that Git considers to be text will have |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 989 | normalized (LF) line endings in the repository. The <code>core.eol</code> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 990 | configuration variable controls which line endings Git will use for |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 991 | normalized files in your working directory; the default is to use the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 992 | native line ending for your platform, or CRLF if <code>core.autocrlf</code> is |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 993 | set.</p></div> |
| 994 | <div class="admonitionblock"> |
| 995 | <table><tr> |
| 996 | <td class="icon"> |
| 997 | <div class="title">Note</div> |
| 998 | </td> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 999 | <td class="content">When <code>text=auto</code> normalization is enabled in an existing |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1000 | repository, any text files containing CRLFs should be normalized. If |
| 1001 | they are not they will be normalized the next time someone tries to |
| 1002 | change them, causing unfortunate misattribution. From a clean working |
| 1003 | directory:</td> |
| 1004 | </tr></table> |
| 1005 | </div> |
| 1006 | <div class="listingblock"> |
| 1007 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1008 | <pre><code>$ echo "* text=auto" >>.gitattributes |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1009 | $ rm .git/index # Remove the index to force Git to |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1010 | $ git reset # re-scan the working directory |
| 1011 | $ git status # Show files that will be normalized |
| 1012 | $ git add -u |
| 1013 | $ git add .gitattributes |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1014 | $ git commit -m "Introduce end-of-line normalization"</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1015 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1016 | <div class="paragraph"><p>If any files that should not be normalized show up in <em>git status</em>, |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1017 | unset their <code>text</code> attribute before running <em>git add -u</em>.</p></div> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1018 | <div class="listingblock"> |
| 1019 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1020 | <pre><code>manual.pdf -text</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1021 | </div></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1022 | <div class="paragraph"><p>Conversely, text files that Git does not detect can have normalization |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1023 | enabled manually.</p></div> |
| 1024 | <div class="listingblock"> |
| 1025 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1026 | <pre><code>weirdchars.txt text</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1027 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1028 | <div class="paragraph"><p>If <code>core.safecrlf</code> is set to "true" or "warn", Git verifies if |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 1029 | the conversion is reversible for the current setting of |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1030 | <code>core.autocrlf</code>. For "true", Git rejects irreversible |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1031 | conversions; for "warn", Git only prints a warning but accepts |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 1032 | an irreversible conversion. The safety triggers to prevent such |
| 1033 | 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] | 1034 | few exceptions. Even though…</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1035 | <div class="ulist"><ul> |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 1036 | <li> |
| 1037 | <p> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1038 | <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] | 1039 | next checkout would, so the safety triggers; |
| 1040 | </p> |
| 1041 | </li> |
| 1042 | <li> |
| 1043 | <p> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1044 | <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] | 1045 | in the work tree, but the operation is about text files and CRLF |
| 1046 | conversion is about fixing the line ending inconsistencies, so the |
| 1047 | safety does not trigger; |
| 1048 | </p> |
| 1049 | </li> |
| 1050 | <li> |
| 1051 | <p> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1052 | <em>git diff</em> itself does not touch the files in the work tree, it is |
| 1053 | 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] | 1054 | catch potential problems early, safety triggers. |
| 1055 | </p> |
| 1056 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1057 | </ul></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1058 | </div> |
| 1059 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1060 | <h4 id="_code_ident_code"><code>ident</code></h4> |
| 1061 | <div class="paragraph"><p>When the attribute <code>ident</code> is set for a path, Git replaces |
| 1062 | <code>$Id$</code> in the blob object with <code>$Id:</code>, followed by the |
Junio C Hamano | 469d60e | 2007-04-29 18:30:34 | [diff] [blame] | 1063 | 40-character hexadecimal blob object name, followed by a dollar |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1064 | sign <code>$</code> upon checkout. Any byte sequence that begins with |
| 1065 | <code>$Id:</code> and ends with <code>$</code> in the worktree file is replaced |
| 1066 | with <code>$Id$</code> upon check-in.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1067 | </div> |
| 1068 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1069 | <h4 id="_code_filter_code"><code>filter</code></h4> |
| 1070 | <div class="paragraph"><p>A <code>filter</code> attribute can be set to a string value that names a |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1071 | filter driver specified in the configuration.</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1072 | <div class="paragraph"><p>A filter driver consists of a <code>clean</code> command and a <code>smudge</code> |
Junio C Hamano | 469d60e | 2007-04-29 18:30:34 | [diff] [blame] | 1073 | command, either of which can be left unspecified. Upon |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1074 | checkout, when the <code>smudge</code> command is specified, the command is |
Junio C Hamano | 361c133 | 2007-11-14 12:17:22 | [diff] [blame] | 1075 | fed the blob object from its standard input, and its standard |
| 1076 | output is used to update the worktree file. Similarly, the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1077 | <code>clean</code> command is used to convert the contents of worktree file |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1078 | upon checkin.</p></div> |
Junio C Hamano | 90a5b7b | 2012-02-28 23:40:31 | [diff] [blame] | 1079 | <div class="paragraph"><p>One use of the content filtering is to massage the content into a shape |
| 1080 | that is more convenient for the platform, filesystem, and the user to use. |
| 1081 | For this mode of operation, the key phrase here is "more convenient" and |
| 1082 | not "turning something unusable into usable". In other words, the intent |
| 1083 | is that if someone unsets the filter driver definition, or does not have |
| 1084 | the appropriate filter program, the project should still be usable.</p></div> |
| 1085 | <div class="paragraph"><p>Another use of the content filtering is to store the content that cannot |
| 1086 | be directly used in the repository (e.g. a UUID that refers to the true |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1087 | content stored outside Git, or an encrypted content) and turn it into a |
Junio C Hamano | 90a5b7b | 2012-02-28 23:40:31 | [diff] [blame] | 1088 | usable form upon checkout (e.g. download the external content, or decrypt |
| 1089 | the encrypted content).</p></div> |
| 1090 | <div class="paragraph"><p>These two filters behave differently, and by default, a filter is taken as |
| 1091 | the former, massaging the contents into more convenient shape. A missing |
| 1092 | filter driver definition in the config, or a filter driver that exits with |
| 1093 | a non-zero status, is not an error but makes the filter a no-op passthru.</p></div> |
| 1094 | <div class="paragraph"><p>You can declare that a filter turns a content that by itself is unusable |
| 1095 | into a usable content by setting the filter.<driver>.required configuration |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1096 | variable to <code>true</code>.</p></div> |
| 1097 | <div class="paragraph"><p>For example, in .gitattributes, you would assign the <code>filter</code> |
Junio C Hamano | 6a548ef | 2009-12-17 00:16:20 | [diff] [blame] | 1098 | attribute for paths.</p></div> |
| 1099 | <div class="listingblock"> |
| 1100 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1101 | <pre><code>*.c filter=indent</code></pre> |
Junio C Hamano | 6a548ef | 2009-12-17 00:16:20 | [diff] [blame] | 1102 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1103 | <div class="paragraph"><p>Then you would define a "filter.indent.clean" and "filter.indent.smudge" |
Junio C Hamano | 6a548ef | 2009-12-17 00:16:20 | [diff] [blame] | 1104 | configuration in your .git/config to specify a pair of commands to |
| 1105 | modify the contents of C programs when the source files are checked |
| 1106 | in ("clean" is run) and checked out (no change is made because the |
| 1107 | command is "cat").</p></div> |
| 1108 | <div class="listingblock"> |
| 1109 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1110 | <pre><code>[filter "indent"] |
Junio C Hamano | 6a548ef | 2009-12-17 00:16:20 | [diff] [blame] | 1111 | clean = indent |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1112 | smudge = cat</code></pre> |
Junio C Hamano | 6a548ef | 2009-12-17 00:16:20 | [diff] [blame] | 1113 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1114 | <div class="paragraph"><p>For best results, <code>clean</code> should not alter its output further if it is |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1115 | run twice ("clean→clean" should be equivalent to "clean"), and |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1116 | multiple <code>smudge</code> commands should not alter <code>clean</code>'s output |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1117 | ("smudge→smudge→clean" should be equivalent to "clean"). See the |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 1118 | section on merging below.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1119 | <div class="paragraph"><p>The "indent" filter is well-behaved in this regard: it will not modify |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 1120 | input that is already correctly indented. In this case, the lack of a |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1121 | smudge filter means that the clean filter <em>must</em> accept its own output |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 1122 | without modifying it.</p></div> |
Junio C Hamano | 90a5b7b | 2012-02-28 23:40:31 | [diff] [blame] | 1123 | <div class="paragraph"><p>If a filter <em>must</em> succeed in order to make the stored contents usable, |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1124 | you can declare that the filter is <code>required</code>, in the configuration:</p></div> |
Junio C Hamano | 90a5b7b | 2012-02-28 23:40:31 | [diff] [blame] | 1125 | <div class="listingblock"> |
| 1126 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1127 | <pre><code>[filter "crypt"] |
Junio C Hamano | 90a5b7b | 2012-02-28 23:40:31 | [diff] [blame] | 1128 | clean = openssl enc ... |
| 1129 | smudge = openssl enc -d ... |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1130 | required</code></pre> |
Junio C Hamano | 90a5b7b | 2012-02-28 23:40:31 | [diff] [blame] | 1131 | </div></div> |
Junio C Hamano | e0552e4 | 2011-01-06 00:34:47 | [diff] [blame] | 1132 | <div class="paragraph"><p>Sequence "%f" on the filter command line is replaced with the name of |
| 1133 | the file the filter is working on. A filter might use this in keyword |
| 1134 | substitution. For example:</p></div> |
| 1135 | <div class="listingblock"> |
| 1136 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1137 | <pre><code>[filter "p4"] |
Junio C Hamano | e0552e4 | 2011-01-06 00:34:47 | [diff] [blame] | 1138 | clean = git-p4-filter --clean %f |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1139 | smudge = git-p4-filter --smudge %f</code></pre> |
Junio C Hamano | e0552e4 | 2011-01-06 00:34:47 | [diff] [blame] | 1140 | </div></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1141 | </div> |
| 1142 | <div class="sect3"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1143 | <h4 id="_interaction_between_checkin_checkout_attributes">Interaction between checkin/checkout attributes</h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1144 | <div class="paragraph"><p>In the check-in codepath, the worktree file is first converted |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1145 | with <code>filter</code> driver (if specified and corresponding driver |
| 1146 | defined), then the result is processed with <code>ident</code> (if |
| 1147 | specified), and then finally with <code>text</code> (again, if specified |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1148 | and applicable).</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1149 | <div class="paragraph"><p>In the check-out codepath, the blob content is first converted |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1150 | with <code>text</code>, and then <code>ident</code> and fed to <code>filter</code>.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1151 | </div> |
| 1152 | <div class="sect3"> |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 1153 | <h4 id="_merging_branches_with_differing_checkin_checkout_attributes">Merging branches with differing checkin/checkout attributes</h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1154 | <div class="paragraph"><p>If you have added attributes to a file that cause the canonical |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 1155 | repository format for that file to change, such as adding a |
| 1156 | clean/smudge filter or text/eol/ident attributes, merging anything |
| 1157 | where the attribute is not in place would normally cause merge |
| 1158 | conflicts.</p></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1159 | <div class="paragraph"><p>To prevent these unnecessary merge conflicts, Git can be told to run a |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 1160 | virtual check-out and check-in of all three stages of a file when |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1161 | resolving a three-way merge by setting the <code>merge.renormalize</code> |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 1162 | configuration variable. This prevents changes caused by check-in |
| 1163 | conversion from causing spurious merge conflicts when a converted file |
| 1164 | is merged with an unconverted file.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1165 | <div class="paragraph"><p>As long as a "smudge→clean" results in the same output as a "clean" |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 1166 | even on files that are already smudged, this strategy will |
| 1167 | automatically resolve all filter-related conflicts. Filters that do |
| 1168 | not act in this way may cause additional merge conflicts that must be |
| 1169 | resolved manually.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1170 | </div> |
| 1171 | </div> |
| 1172 | <div class="sect2"> |
| 1173 | <h3 id="_generating_diff_text">Generating diff text</h3> |
| 1174 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1175 | <h4 id="_code_diff_code"><code>diff</code></h4> |
| 1176 | <div class="paragraph"><p>The attribute <code>diff</code> affects how Git generates diffs for particular |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1177 | files. It can tell Git whether to generate a textual patch for the path |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1178 | or to treat the path as a binary file. It can also affect what line is |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1179 | shown on the hunk header <code>@@ -k,l +n,m @@</code> line, tell Git to use an |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1180 | external command to generate the diff, or ask Git to convert binary |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1181 | files to a text format before generating the diff.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1182 | <div class="dlist"><dl> |
| 1183 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1184 | Set |
| 1185 | </dt> |
| 1186 | <dd> |
| 1187 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1188 | A path to which the <code>diff</code> attribute is set is treated |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1189 | as text, even when they contain byte values that |
| 1190 | normally never appear in text files, such as NUL. |
| 1191 | </p> |
| 1192 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1193 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1194 | Unset |
| 1195 | </dt> |
| 1196 | <dd> |
| 1197 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1198 | A path to which the <code>diff</code> attribute is unset will |
| 1199 | generate <code>Binary files differ</code> (or a binary patch, if |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1200 | binary patches are enabled). |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1201 | </p> |
| 1202 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1203 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1204 | Unspecified |
| 1205 | </dt> |
| 1206 | <dd> |
| 1207 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1208 | A path to which the <code>diff</code> attribute is unspecified |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1209 | first gets its contents inspected, and if it looks like |
Junio C Hamano | 8e61f1f | 2014-09-11 21:53:45 | [diff] [blame] | 1210 | text and is smaller than core.bigFileThreshold, it is treated |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1211 | as text. Otherwise it would generate <code>Binary files differ</code>. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1212 | </p> |
| 1213 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1214 | <dt class="hdlist1"> |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 1215 | String |
| 1216 | </dt> |
| 1217 | <dd> |
| 1218 | <p> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1219 | Diff is shown using the specified diff driver. Each driver may |
| 1220 | specify one or more options, as described in the following |
| 1221 | section. The options for the diff driver "foo" are defined |
| 1222 | by the configuration variables in the "diff.foo" section of the |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1223 | Git config file. |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 1224 | </p> |
| 1225 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1226 | </dl></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1227 | </div> |
| 1228 | <div class="sect3"> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1229 | <h4 id="_defining_an_external_diff_driver">Defining an external diff driver</h4> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1230 | <div class="paragraph"><p>The definition of a diff driver is done in <code>gitconfig</code>, not |
| 1231 | <code>gitattributes</code> file, so strictly speaking this manual page is a |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1232 | wrong place to talk about it. However…</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1233 | <div class="paragraph"><p>To define an external diff driver <code>jcdiff</code>, add a section to your |
| 1234 | <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p></div> |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 1235 | <div class="listingblock"> |
| 1236 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1237 | <pre><code>[diff "jcdiff"] |
| 1238 | command = j-c-diff</code></pre> |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 1239 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1240 | <div class="paragraph"><p>When Git needs to show you a diff for the path with <code>diff</code> |
| 1241 | attribute set to <code>jcdiff</code>, it calls the command you specified |
| 1242 | with the above configuration, i.e. <code>j-c-diff</code>, with 7 |
| 1243 | parameters, just like <code>GIT_EXTERNAL_DIFF</code> program is called. |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1244 | See <a href="git.html">git(1)</a> for details.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1245 | </div> |
| 1246 | <div class="sect3"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1247 | <h4 id="_defining_a_custom_hunk_header">Defining a custom hunk-header</h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1248 | <div class="paragraph"><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] | 1249 | is prefixed with a line of the form:</p></div> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1250 | <div class="literalblock"> |
| 1251 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1252 | <pre><code>@@ -k,l +n,m @@ TEXT</code></pre> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1253 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1254 | <div class="paragraph"><p>This is called a <em>hunk header</em>. The "TEXT" portion is by default a line |
Junio C Hamano | 5e4d8de | 2008-09-19 06:27:02 | [diff] [blame] | 1255 | that begins with an alphabet, an underscore or a dollar sign; this |
| 1256 | matches what GNU <em>diff -p</em> output uses. This default selection however |
| 1257 | is not suited for some contents, and you can use a customized pattern |
| 1258 | to make a selection.</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1259 | <div class="paragraph"><p>First, in .gitattributes, you would assign the <code>diff</code> attribute |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1260 | for paths.</p></div> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1261 | <div class="listingblock"> |
| 1262 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1263 | <pre><code>*.tex diff=tex</code></pre> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1264 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1265 | <div class="paragraph"><p>Then, you would define a "diff.tex.xfuncname" configuration to |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1266 | specify a regular expression that matches a line that you would |
Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 1267 | want to appear as the hunk header "TEXT". Add a section to your |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1268 | <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p></div> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1269 | <div class="listingblock"> |
| 1270 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1271 | <pre><code>[diff "tex"] |
| 1272 | xfuncname = "^(\\\\(sub)*section\\{.*)$"</code></pre> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1273 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1274 | <div class="paragraph"><p>Note. A single level of backslashes are eaten by the |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1275 | configuration file parser, so you would need to double the |
| 1276 | backslashes; the pattern above picks a line that begins with a |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1277 | backslash, and zero or more occurrences of <code>sub</code> followed by |
| 1278 | <code>section</code> followed by open brace, to the end of line.</p></div> |
| 1279 | <div class="paragraph"><p>There are a few built-in patterns to make this easier, and <code>tex</code> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1280 | is one of them, so you do not have to write the above in your |
| 1281 | configuration file (you still need to enable this with the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1282 | attribute mechanism, via <code>.gitattributes</code>). The following built in |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1283 | patterns are available:</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1284 | <div class="ulist"><ul> |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1285 | <li> |
| 1286 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1287 | <code>ada</code> suitable for source code in the Ada language. |
Junio C Hamano | 4f07aec | 2012-09-25 19:08:44 | [diff] [blame] | 1288 | </p> |
| 1289 | </li> |
| 1290 | <li> |
| 1291 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1292 | <code>bibtex</code> suitable for files with BibTeX coded references. |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1293 | </p> |
| 1294 | </li> |
| 1295 | <li> |
| 1296 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1297 | <code>cpp</code> suitable for source code in the C and C++ languages. |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 1298 | </p> |
| 1299 | </li> |
| 1300 | <li> |
| 1301 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1302 | <code>csharp</code> suitable for source code in the C# language. |
Junio C Hamano | 53ba6d0 | 2010-08-22 07:25:12 | [diff] [blame] | 1303 | </p> |
| 1304 | </li> |
| 1305 | <li> |
| 1306 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1307 | <code>fortran</code> suitable for source code in the Fortran language. |
Junio C Hamano | 3b4609d | 2010-09-30 00:04:34 | [diff] [blame] | 1308 | </p> |
| 1309 | </li> |
| 1310 | <li> |
| 1311 | <p> |
Junio C Hamano | d7ed404 | 2015-08-03 19:43:00 | [diff] [blame] | 1312 | <code>fountain</code> suitable for Fountain documents. |
| 1313 | </p> |
| 1314 | </li> |
| 1315 | <li> |
| 1316 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1317 | <code>html</code> suitable for HTML/XHTML documents. |
Junio C Hamano | f24b806 | 2008-09-09 01:34:39 | [diff] [blame] | 1318 | </p> |
| 1319 | </li> |
| 1320 | <li> |
| 1321 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1322 | <code>java</code> suitable for source code in the Java language. |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1323 | </p> |
| 1324 | </li> |
| 1325 | <li> |
| 1326 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1327 | <code>matlab</code> suitable for source code in the MATLAB language. |
Junio C Hamano | 92887a3 | 2011-12-07 00:26:29 | [diff] [blame] | 1328 | </p> |
| 1329 | </li> |
| 1330 | <li> |
| 1331 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1332 | <code>objc</code> suitable for source code in the Objective-C language. |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 1333 | </p> |
| 1334 | </li> |
| 1335 | <li> |
| 1336 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1337 | <code>pascal</code> suitable for source code in the Pascal/Delphi language. |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1338 | </p> |
| 1339 | </li> |
| 1340 | <li> |
| 1341 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1342 | <code>perl</code> suitable for source code in the Perl language. |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1343 | </p> |
| 1344 | </li> |
| 1345 | <li> |
| 1346 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1347 | <code>php</code> suitable for source code in the PHP language. |
Junio C Hamano | f24b806 | 2008-09-09 01:34:39 | [diff] [blame] | 1348 | </p> |
| 1349 | </li> |
| 1350 | <li> |
| 1351 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1352 | <code>python</code> suitable for source code in the Python language. |
Junio C Hamano | 3f2f6e5 | 2008-08-21 10:34:22 | [diff] [blame] | 1353 | </p> |
| 1354 | </li> |
| 1355 | <li> |
| 1356 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1357 | <code>ruby</code> suitable for source code in the Ruby language. |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1358 | </p> |
| 1359 | </li> |
| 1360 | <li> |
| 1361 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1362 | <code>tex</code> suitable for source code for LaTeX documents. |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1363 | </p> |
| 1364 | </li> |
| 1365 | </ul></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1366 | </div> |
| 1367 | <div class="sect3"> |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 1368 | <h4 id="_customizing_word_diff">Customizing word diff</h4> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1369 | <div class="paragraph"><p>You can customize the rules that <code>git diff --word-diff</code> uses to |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 1370 | split words in a line, by specifying an appropriate regular expression |
| 1371 | in the "diff.*.wordRegex" configuration variable. For example, in TeX |
| 1372 | a backslash followed by a sequence of letters forms a command, but |
| 1373 | several such commands can be run together without intervening |
Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 1374 | whitespace. To separate them, use a regular expression in your |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1375 | <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p></div> |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 1376 | <div class="listingblock"> |
| 1377 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1378 | <pre><code>[diff "tex"] |
| 1379 | wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"</code></pre> |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 1380 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1381 | <div class="paragraph"><p>A built-in pattern is provided for all languages listed in the |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 1382 | previous section.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1383 | </div> |
| 1384 | <div class="sect3"> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1385 | <h4 id="_performing_text_diffs_of_binary_files">Performing text diffs of binary files</h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1386 | <div class="paragraph"><p>Sometimes it is desirable to see the diff of a text-converted |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1387 | version of some binary files. For example, a word processor |
| 1388 | document can be converted to an ASCII text representation, and |
| 1389 | the diff of the text shown. Even though this conversion loses |
| 1390 | some information, the resulting diff is useful for human |
| 1391 | viewing (but cannot be applied directly).</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1392 | <div class="paragraph"><p>The <code>textconv</code> config option is used to define a program for |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1393 | performing such a conversion. The program should take a single |
| 1394 | argument, the name of a file to convert, and produce the |
| 1395 | resulting text on stdout.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1396 | <div class="paragraph"><p>For example, to show the diff of the exif information of a |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1397 | file instead of the binary information (assuming you have the |
Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 1398 | exif tool installed), add the following section to your |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1399 | <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file):</p></div> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1400 | <div class="listingblock"> |
| 1401 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1402 | <pre><code>[diff "jpg"] |
| 1403 | textconv = exif</code></pre> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1404 | </div></div> |
| 1405 | <div class="admonitionblock"> |
| 1406 | <table><tr> |
| 1407 | <td class="icon"> |
| 1408 | <div class="title">Note</div> |
| 1409 | </td> |
| 1410 | <td class="content">The text conversion is generally a one-way conversion; |
| 1411 | in this example, we lose the actual image contents and focus |
| 1412 | just on the text data. This means that diffs generated by |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1413 | textconv are <em>not</em> suitable for applying. For this reason, |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1414 | only <code>git diff</code> and the <code>git log</code> family of commands (i.e., |
| 1415 | log, whatchanged, show) will perform text conversion. <code>git |
| 1416 | format-patch</code> will never generate this output. If you want to |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1417 | send somebody a text-converted diff of a binary file (e.g., |
| 1418 | because it quickly conveys the changes you have made), you |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1419 | should generate it separately and send it as a comment <em>in |
| 1420 | addition to</em> the usual binary diff that you might send.</td> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1421 | </tr></table> |
| 1422 | </div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1423 | <div class="paragraph"><p>Because text conversion can be slow, especially when doing a |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1424 | large number of them with <code>git log -p</code>, Git provides a mechanism |
Junio C Hamano | cb39aea | 2010-05-09 07:24:48 | [diff] [blame] | 1425 | to cache the output and use it in future diffs. To enable |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1426 | caching, set the "cachetextconv" variable in your diff driver’s |
Junio C Hamano | cb39aea | 2010-05-09 07:24:48 | [diff] [blame] | 1427 | config. For example:</p></div> |
| 1428 | <div class="listingblock"> |
| 1429 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1430 | <pre><code>[diff "jpg"] |
Junio C Hamano | cb39aea | 2010-05-09 07:24:48 | [diff] [blame] | 1431 | textconv = exif |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1432 | cachetextconv = true</code></pre> |
Junio C Hamano | cb39aea | 2010-05-09 07:24:48 | [diff] [blame] | 1433 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1434 | <div class="paragraph"><p>This will cache the result of running "exif" on each blob |
Junio C Hamano | cb39aea | 2010-05-09 07:24:48 | [diff] [blame] | 1435 | indefinitely. If you change the textconv config variable for a |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1436 | diff driver, Git will automatically invalidate the cache entries |
Junio C Hamano | cb39aea | 2010-05-09 07:24:48 | [diff] [blame] | 1437 | and re-run the textconv filter. If you want to invalidate the |
| 1438 | cache manually (e.g., because your version of "exif" was updated |
| 1439 | and now produces better output), you can remove the cache |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1440 | manually with <code>git update-ref -d refs/notes/textconv/jpg</code> (where |
Junio C Hamano | cb39aea | 2010-05-09 07:24:48 | [diff] [blame] | 1441 | "jpg" is the name of the diff driver, as in the example above).</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1442 | </div> |
| 1443 | <div class="sect3"> |
Junio C Hamano | f93530e | 2011-05-25 23:59:59 | [diff] [blame] | 1444 | <h4 id="_choosing_textconv_versus_external_diff">Choosing textconv versus external diff</h4> |
| 1445 | <div class="paragraph"><p>If you want to show differences between binary or specially-formatted |
| 1446 | blobs in your repository, you can choose to use either an external diff |
| 1447 | command, or to use textconv to convert them to a diff-able text format. |
| 1448 | Which method you choose depends on your exact situation.</p></div> |
| 1449 | <div class="paragraph"><p>The advantage of using an external diff command is flexibility. You are |
| 1450 | not bound to find line-oriented changes, nor is it necessary for the |
| 1451 | output to resemble unified diff. You are free to locate and report |
| 1452 | changes in the most appropriate way for your data format.</p></div> |
| 1453 | <div class="paragraph"><p>A textconv, by comparison, is much more limiting. You provide a |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1454 | transformation of the data into a line-oriented text format, and Git |
Junio C Hamano | f93530e | 2011-05-25 23:59:59 | [diff] [blame] | 1455 | uses its regular diff tools to generate the output. There are several |
| 1456 | advantages to choosing this method:</p></div> |
| 1457 | <div class="olist arabic"><ol class="arabic"> |
| 1458 | <li> |
| 1459 | <p> |
| 1460 | Ease of use. It is often much simpler to write a binary to text |
| 1461 | transformation than it is to perform your own diff. In many cases, |
| 1462 | existing programs can be used as textconv filters (e.g., exif, |
| 1463 | odt2txt). |
| 1464 | </p> |
| 1465 | </li> |
| 1466 | <li> |
| 1467 | <p> |
| 1468 | Git diff features. By performing only the transformation step |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1469 | yourself, you can still utilize many of Git’s diff features, |
Junio C Hamano | f93530e | 2011-05-25 23:59:59 | [diff] [blame] | 1470 | including colorization, word-diff, and combined diffs for merges. |
| 1471 | </p> |
| 1472 | </li> |
| 1473 | <li> |
| 1474 | <p> |
| 1475 | Caching. Textconv caching can speed up repeated diffs, such as those |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1476 | you might trigger by running <code>git log -p</code>. |
Junio C Hamano | f93530e | 2011-05-25 23:59:59 | [diff] [blame] | 1477 | </p> |
| 1478 | </li> |
| 1479 | </ol></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1480 | </div> |
| 1481 | <div class="sect3"> |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1482 | <h4 id="_marking_files_as_binary">Marking files as binary</h4> |
| 1483 | <div class="paragraph"><p>Git usually guesses correctly whether a blob contains text or binary |
| 1484 | data by examining the beginning of the contents. However, sometimes you |
| 1485 | may want to override its decision, either because a blob contains binary |
| 1486 | data later in the file, or because the content, while technically |
| 1487 | composed of text characters, is opaque to a human reader. For example, |
Junio C Hamano | fb5ffde | 2014-11-04 22:38:56 | [diff] [blame] | 1488 | many postscript files contain only ASCII characters, but produce noisy |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1489 | and meaningless diffs.</p></div> |
| 1490 | <div class="paragraph"><p>The simplest way to mark a file as binary is to unset the diff |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1491 | attribute in the <code>.gitattributes</code> file:</p></div> |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1492 | <div class="listingblock"> |
| 1493 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1494 | <pre><code>*.ps -diff</code></pre> |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1495 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1496 | <div class="paragraph"><p>This will cause Git to generate <code>Binary files differ</code> (or a binary |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1497 | patch, if binary patches are enabled) instead of a regular diff.</p></div> |
| 1498 | <div class="paragraph"><p>However, one may also want to specify other diff driver attributes. For |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1499 | example, you might want to use <code>textconv</code> to convert postscript files to |
Junio C Hamano | fb5ffde | 2014-11-04 22:38:56 | [diff] [blame] | 1500 | an ASCII representation for human viewing, but otherwise treat them as |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1501 | binary files. You cannot specify both <code>-diff</code> and <code>diff=ps</code> attributes. |
| 1502 | The solution is to use the <code>diff.*.binary</code> config option:</p></div> |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1503 | <div class="listingblock"> |
| 1504 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1505 | <pre><code>[diff "ps"] |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1506 | textconv = ps2ascii |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1507 | binary = true</code></pre> |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1508 | </div></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1509 | </div> |
| 1510 | </div> |
| 1511 | <div class="sect2"> |
| 1512 | <h3 id="_performing_a_three_way_merge">Performing a three-way merge</h3> |
| 1513 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1514 | <h4 id="_code_merge_code"><code>merge</code></h4> |
| 1515 | <div class="paragraph"><p>The attribute <code>merge</code> affects how three versions of a file are |
| 1516 | merged when a file-level merge is necessary during <code>git merge</code>, |
| 1517 | and other commands such as <code>git revert</code> and <code>git cherry-pick</code>.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1518 | <div class="dlist"><dl> |
| 1519 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1520 | Set |
| 1521 | </dt> |
| 1522 | <dd> |
| 1523 | <p> |
| 1524 | Built-in 3-way merge driver is used to merge the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1525 | contents in a way similar to <em>merge</em> command of <code>RCS</code> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1526 | suite. This is suitable for ordinary text files. |
| 1527 | </p> |
| 1528 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1529 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1530 | Unset |
| 1531 | </dt> |
| 1532 | <dd> |
| 1533 | <p> |
| 1534 | Take the version from the current branch as the |
| 1535 | tentative merge result, and declare that the merge has |
Junio C Hamano | fa28cb1 | 2011-03-19 01:35:35 | [diff] [blame] | 1536 | conflicts. This is suitable for binary files that do |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1537 | not have a well-defined merge semantics. |
| 1538 | </p> |
| 1539 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1540 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1541 | Unspecified |
| 1542 | </dt> |
| 1543 | <dd> |
| 1544 | <p> |
| 1545 | By default, this uses the same built-in 3-way merge |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1546 | driver as is the case when the <code>merge</code> attribute is set. |
| 1547 | However, the <code>merge.default</code> configuration variable can name |
Junio C Hamano | fa28cb1 | 2011-03-19 01:35:35 | [diff] [blame] | 1548 | different merge driver to be used with paths for which the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1549 | <code>merge</code> attribute is unspecified. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1550 | </p> |
| 1551 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1552 | <dt class="hdlist1"> |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 1553 | String |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1554 | </dt> |
| 1555 | <dd> |
| 1556 | <p> |
| 1557 | 3-way merge is performed using the specified custom |
| 1558 | merge driver. The built-in 3-way merge driver can be |
| 1559 | explicitly specified by asking for "text" driver; the |
| 1560 | built-in "take the current branch" driver can be |
Junio C Hamano | 22572e7 | 2007-04-25 05:59:25 | [diff] [blame] | 1561 | requested with "binary". |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1562 | </p> |
| 1563 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1564 | </dl></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1565 | </div> |
| 1566 | <div class="sect3"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1567 | <h4 id="_built_in_merge_drivers">Built-in merge drivers</h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1568 | <div class="paragraph"><p>There are a few built-in low-level merge drivers defined that |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1569 | can be asked for via the <code>merge</code> attribute.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1570 | <div class="dlist"><dl> |
| 1571 | <dt class="hdlist1"> |
Junio C Hamano | f556fc2 | 2007-12-23 08:16:38 | [diff] [blame] | 1572 | text |
| 1573 | </dt> |
| 1574 | <dd> |
| 1575 | <p> |
| 1576 | Usual 3-way file level merge for text files. Conflicted |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1577 | regions are marked with conflict markers <code><<<<<<<</code>, |
| 1578 | <code>=======</code> and <code>>>>>>>></code>. The version from your branch |
| 1579 | appears before the <code>=======</code> marker, and the version |
| 1580 | from the merged branch appears after the <code>=======</code> |
Junio C Hamano | f556fc2 | 2007-12-23 08:16:38 | [diff] [blame] | 1581 | marker. |
| 1582 | </p> |
| 1583 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1584 | <dt class="hdlist1"> |
Junio C Hamano | f556fc2 | 2007-12-23 08:16:38 | [diff] [blame] | 1585 | binary |
| 1586 | </dt> |
| 1587 | <dd> |
| 1588 | <p> |
| 1589 | Keep the version from your branch in the work tree, but |
| 1590 | leave the path in the conflicted state for the user to |
| 1591 | sort out. |
| 1592 | </p> |
| 1593 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1594 | <dt class="hdlist1"> |
Junio C Hamano | f556fc2 | 2007-12-23 08:16:38 | [diff] [blame] | 1595 | union |
| 1596 | </dt> |
| 1597 | <dd> |
| 1598 | <p> |
| 1599 | Run 3-way file level merge for text files, but take |
| 1600 | lines from both versions, instead of leaving conflict |
| 1601 | markers. This tends to leave the added lines in the |
| 1602 | resulting file in random order and the user should |
| 1603 | verify the result. Do not use this if you do not |
| 1604 | understand the implications. |
| 1605 | </p> |
| 1606 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1607 | </dl></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1608 | </div> |
| 1609 | <div class="sect3"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1610 | <h4 id="_defining_a_custom_merge_driver">Defining a custom merge driver</h4> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1611 | <div class="paragraph"><p>The definition of a merge driver is done in the <code>.git/config</code> |
| 1612 | file, not in the <code>gitattributes</code> file, so strictly speaking this |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1613 | manual page is a wrong place to talk about it. However…</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1614 | <div class="paragraph"><p>To define a custom merge driver <code>filfre</code>, add a section to your |
| 1615 | <code>$GIT_DIR/config</code> file (or <code>$HOME/.gitconfig</code> file) like this:</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1616 | <div class="listingblock"> |
| 1617 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1618 | <pre><code>[merge "filfre"] |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1619 | name = feel-free merge driver |
Junio C Hamano | df5384b | 2015-06-24 21:12:12 | [diff] [blame] | 1620 | driver = filfre %O %A %B %L %P |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1621 | recursive = binary</code></pre> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1622 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1623 | <div class="paragraph"><p>The <code>merge.*.name</code> variable gives the driver a human-readable |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1624 | name.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1625 | <div class="paragraph"><p>The ‘merge.*.driver` variable’s value is used to construct a |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1626 | command to run to merge ancestor’s version (<code>%O</code>), current |
| 1627 | version (<code>%A</code>) and the other branches’ version (<code>%B</code>). These |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1628 | three tokens are replaced with the names of temporary files that |
| 1629 | hold the contents of these versions when the command line is |
Junio C Hamano | 86660db | 2010-02-24 01:12:54 | [diff] [blame] | 1630 | built. Additionally, %L will be replaced with the conflict marker |
| 1631 | size (see below).</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1632 | <div class="paragraph"><p>The merge driver is expected to leave the result of the merge in |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1633 | the file named with <code>%A</code> by overwriting it, and exit with zero |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1634 | 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] | 1635 | were conflicts.</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1636 | <div class="paragraph"><p>The <code>merge.*.recursive</code> variable specifies what other merge |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1637 | driver to use when the merge driver is called for an internal |
| 1638 | merge between common ancestors, when there are more than one. |
| 1639 | When left unspecified, the driver itself is used for both |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1640 | internal merge and the final merge.</p></div> |
Junio C Hamano | df5384b | 2015-06-24 21:12:12 | [diff] [blame] | 1641 | <div class="paragraph"><p>The merge driver can learn the pathname in which the merged result |
| 1642 | will be stored via placeholder <code>%P</code>.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1643 | </div> |
| 1644 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1645 | <h4 id="_code_conflict_marker_size_code"><code>conflict-marker-size</code></h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1646 | <div class="paragraph"><p>This attribute controls the length of conflict markers left in |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1647 | the work tree file during a conflicted merge. Only setting to |
| 1648 | the value to a positive integer has any meaningful effect.</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1649 | <div class="paragraph"><p>For example, this line in <code>.gitattributes</code> can be used to tell the merge |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1650 | machinery to leave much longer (instead of the usual 7-character-long) |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1651 | conflict markers when merging the file <code>Documentation/git-merge.txt</code> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1652 | results in a conflict.</p></div> |
| 1653 | <div class="listingblock"> |
| 1654 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1655 | <pre><code>Documentation/git-merge.txt conflict-marker-size=32</code></pre> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1656 | </div></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1657 | </div> |
| 1658 | </div> |
| 1659 | <div class="sect2"> |
| 1660 | <h3 id="_checking_whitespace_errors">Checking whitespace errors</h3> |
| 1661 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1662 | <h4 id="_code_whitespace_code"><code>whitespace</code></h4> |
| 1663 | <div class="paragraph"><p>The <code>core.whitespace</code> configuration variable allows you to define what |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1664 | <em>diff</em> and <em>apply</em> should consider whitespace errors for all paths in |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1665 | 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] | 1666 | control per path.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1667 | <div class="dlist"><dl> |
| 1668 | <dt class="hdlist1"> |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1669 | Set |
| 1670 | </dt> |
| 1671 | <dd> |
| 1672 | <p> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1673 | Notice all types of potential whitespace errors known to Git. |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1674 | The tab width is taken from the value of the <code>core.whitespace</code> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1675 | configuration variable. |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1676 | </p> |
| 1677 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1678 | <dt class="hdlist1"> |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1679 | Unset |
| 1680 | </dt> |
| 1681 | <dd> |
| 1682 | <p> |
| 1683 | Do not notice anything as error. |
| 1684 | </p> |
| 1685 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1686 | <dt class="hdlist1"> |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1687 | Unspecified |
| 1688 | </dt> |
| 1689 | <dd> |
| 1690 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1691 | Use the value of the <code>core.whitespace</code> configuration variable to |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1692 | decide what to notice as error. |
| 1693 | </p> |
| 1694 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1695 | <dt class="hdlist1"> |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1696 | String |
| 1697 | </dt> |
| 1698 | <dd> |
| 1699 | <p> |
| 1700 | Specify a comma separate list of common whitespace problems to |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1701 | notice in the same format as the <code>core.whitespace</code> configuration |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1702 | variable. |
| 1703 | </p> |
| 1704 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1705 | </dl></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1706 | </div> |
| 1707 | </div> |
| 1708 | <div class="sect2"> |
| 1709 | <h3 id="_creating_an_archive">Creating an archive</h3> |
| 1710 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1711 | <h4 id="_code_export_ignore_code"><code>export-ignore</code></h4> |
| 1712 | <div class="paragraph"><p>Files and directories with the attribute <code>export-ignore</code> won’t be added to |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1713 | archive files.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1714 | </div> |
| 1715 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1716 | <h4 id="_code_export_subst_code"><code>export-subst</code></h4> |
| 1717 | <div class="paragraph"><p>If the attribute <code>export-subst</code> is set for a file then Git will expand |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1718 | several placeholders when adding this file to an archive. The |
| 1719 | expansion depends on the availability of a commit ID, i.e., if |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1720 | <a href="git-archive.html">git-archive(1)</a> has been given a tree instead of a commit or a |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1721 | tag then no replacement will be done. The placeholders are the same |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1722 | as those for the option <code>--pretty=format:</code> of <a href="git-log.html">git-log(1)</a>, |
| 1723 | except that they need to be wrapped like this: <code>$Format:PLACEHOLDERS$</code> |
| 1724 | in the file. E.g. the string <code>$Format:%H$</code> will be replaced by the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1725 | commit hash.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1726 | </div> |
| 1727 | </div> |
| 1728 | <div class="sect2"> |
| 1729 | <h3 id="_packing_objects">Packing objects</h3> |
| 1730 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1731 | <h4 id="_code_delta_code"><code>delta</code></h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1732 | <div class="paragraph"><p>Delta compression will not be attempted for blobs for paths with the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1733 | attribute <code>delta</code> set to false.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1734 | </div> |
| 1735 | </div> |
| 1736 | <div class="sect2"> |
| 1737 | <h3 id="_viewing_files_in_gui_tools">Viewing files in GUI tools</h3> |
| 1738 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1739 | <h4 id="_code_encoding_code"><code>encoding</code></h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1740 | <div class="paragraph"><p>The value of this attribute specifies the character encoding that should |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1741 | be 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 Hamano | d3452a0 | 2008-11-15 08:07:55 | [diff] [blame] | 1742 | display the contents of the relevant file. Note that due to performance |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1743 | considerations <a href="gitk.html">gitk(1)</a> does not use this attribute unless you |
Junio C Hamano | d3452a0 | 2008-11-15 08:07:55 | [diff] [blame] | 1744 | manually enable per-file encodings in its options.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1745 | <div class="paragraph"><p>If this attribute is not set or has an invalid value, the value of the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1746 | <code>gui.encoding</code> configuration variable is used instead |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1747 | (See <a href="git-config.html">git-config(1)</a>).</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1748 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1749 | </div> |
| 1750 | </div> |
| 1751 | </div> |
| 1752 | <div class="sect1"> |
Junio C Hamano | 86d8436 | 2011-08-04 00:21:51 | [diff] [blame] | 1753 | <h2 id="_using_macro_attributes">USING MACRO ATTRIBUTES</h2> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 1754 | <div class="sectionbody"> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1755 | <div class="paragraph"><p>You do not want any end-of-line conversions applied to, nor textual diffs |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 1756 | produced for, any binary file you track. You would need to specify e.g.</p></div> |
| 1757 | <div class="listingblock"> |
| 1758 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1759 | <pre><code>*.jpg -text -diff</code></pre> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 1760 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1761 | <div class="paragraph"><p>but that may become cumbersome, when you have many attributes. Using |
Junio C Hamano | 86d8436 | 2011-08-04 00:21:51 | [diff] [blame] | 1762 | macro attributes, you can define an attribute that, when set, also |
| 1763 | sets or unsets a number of other attributes at the same time. The |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1764 | system knows a built-in macro attribute, <code>binary</code>:</p></div> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 1765 | <div class="listingblock"> |
| 1766 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1767 | <pre><code>*.jpg binary</code></pre> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 1768 | </div></div> |
Junio C Hamano | 86d8436 | 2011-08-04 00:21:51 | [diff] [blame] | 1769 | <div class="paragraph"><p>Setting the "binary" attribute also unsets the "text" and "diff" |
| 1770 | attributes as above. Note that macro attributes can only be "Set", |
| 1771 | though setting one might have the effect of setting or unsetting other |
| 1772 | attributes or even returning other attributes to the "Unspecified" |
| 1773 | state.</p></div> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 1774 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1775 | </div> |
| 1776 | <div class="sect1"> |
Junio C Hamano | 86d8436 | 2011-08-04 00:21:51 | [diff] [blame] | 1777 | <h2 id="_defining_macro_attributes">DEFINING MACRO ATTRIBUTES</h2> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 1778 | <div class="sectionbody"> |
Junio C Hamano | c5bd79e | 2014-01-27 21:31:26 | [diff] [blame] | 1779 | <div class="paragraph"><p>Custom macro attributes can be defined only in top-level gitattributes |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1780 | files (<code>$GIT_DIR/info/attributes</code>, the <code>.gitattributes</code> file at the |
Junio C Hamano | c5bd79e | 2014-01-27 21:31:26 | [diff] [blame] | 1781 | top level of the working tree, or the global or system-wide |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1782 | gitattributes files), not in <code>.gitattributes</code> files in working tree |
Junio C Hamano | c5bd79e | 2014-01-27 21:31:26 | [diff] [blame] | 1783 | subdirectories. The built-in macro attribute "binary" is equivalent |
| 1784 | to:</p></div> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 1785 | <div class="listingblock"> |
| 1786 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1787 | <pre><code>[attr]binary -diff -merge -text</code></pre> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 1788 | </div></div> |
| 1789 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1790 | </div> |
| 1791 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1792 | <h2 id="_example">EXAMPLE</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1793 | <div class="sectionbody"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1794 | <div class="paragraph"><p>If you have these three <code>gitattributes</code> file:</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1795 | <div class="listingblock"> |
| 1796 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1797 | <pre><code>(in $GIT_DIR/info/attributes) |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1798 | |
| 1799 | a* foo !bar -baz |
| 1800 | |
| 1801 | (in .gitattributes) |
| 1802 | abc foo bar baz |
| 1803 | |
| 1804 | (in t/.gitattributes) |
| 1805 | ab* merge=filfre |
| 1806 | abc -foo -bar |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1807 | *.c frotz</code></pre> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1808 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1809 | <div class="paragraph"><p>the attributes given to path <code>t/abc</code> are computed as follows:</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1810 | <div class="olist arabic"><ol class="arabic"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1811 | <li> |
| 1812 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1813 | By examining <code>t/.gitattributes</code> (which is in the same |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1814 | directory as the path in question), Git finds that the first |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1815 | line matches. <code>merge</code> attribute is set. It also finds that |
| 1816 | the second line matches, and attributes <code>foo</code> and <code>bar</code> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1817 | are unset. |
| 1818 | </p> |
| 1819 | </li> |
| 1820 | <li> |
| 1821 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1822 | Then it examines <code>.gitattributes</code> (which is in the parent |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1823 | directory), and finds that the first line matches, but |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1824 | <code>t/.gitattributes</code> file already decided how <code>merge</code>, <code>foo</code> |
| 1825 | and <code>bar</code> attributes should be given to this path, so it |
| 1826 | leaves <code>foo</code> and <code>bar</code> unset. Attribute <code>baz</code> is set. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1827 | </p> |
| 1828 | </li> |
| 1829 | <li> |
| 1830 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1831 | Finally it examines <code>$GIT_DIR/info/attributes</code>. This file |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1832 | is used to override the in-tree settings. The first line is |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1833 | a match, and <code>foo</code> is set, <code>bar</code> is reverted to unspecified |
| 1834 | state, and <code>baz</code> is unset. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1835 | </p> |
| 1836 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1837 | </ol></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1838 | <div class="paragraph"><p>As the result, the attributes assignment to <code>t/abc</code> becomes:</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1839 | <div class="listingblock"> |
| 1840 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1841 | <pre><code>foo set to true |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1842 | bar unspecified |
| 1843 | baz set to false |
| 1844 | merge set to string value "filfre" |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1845 | frotz unspecified</code></pre> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1846 | </div></div> |
| 1847 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1848 | </div> |
| 1849 | <div class="sect1"> |
Junio C Hamano | f727901 | 2011-08-18 06:13:13 | [diff] [blame] | 1850 | <h2 id="_see_also">SEE ALSO</h2> |
| 1851 | <div class="sectionbody"> |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1852 | <div class="paragraph"><p><a href="git-check-attr.html">git-check-attr(1)</a>.</p></div> |
Junio C Hamano | f727901 | 2011-08-18 06:13:13 | [diff] [blame] | 1853 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1854 | </div> |
| 1855 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1856 | <h2 id="_git">GIT</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1857 | <div class="sectionbody"> |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1858 | <div class="paragraph"><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] | 1859 | </div> |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 1860 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1861 | </div> |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 1862 | <div id="footnotes"><hr /></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1863 | <div id="footer"> |
| 1864 | <div id="footer-text"> |
Junio C Hamano | d7ed404 | 2015-08-03 19:43:00 | [diff] [blame] | 1865 | Last updated 2015-08-03 12:41:59 PDT |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1866 | </div> |
| 1867 | </div> |
| 1868 | </body> |
| 1869 | </html> |