Junio C Hamano | ccb8252 | 2018-05-08 07:52:09 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
| 3 | "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| 5 | <head> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 6 | <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> |
Junio C Hamano | eaa95f7 | 2020-04-14 17:39:35 | [diff] [blame] | 7 | <meta name="generator" content="AsciiDoc 9.0.0rc1" /> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 8 | <title>gitattributes(5)</title> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 9 | <style type="text/css"> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 10 | /* Shared CSS for AsciiDoc xhtml11 and html5 backends */ |
| 11 | |
| 12 | /* Default font. */ |
| 13 | body { |
| 14 | font-family: Georgia,serif; |
| 15 | } |
| 16 | |
| 17 | /* Title font. */ |
| 18 | h1, h2, h3, h4, h5, h6, |
| 19 | div.title, caption.title, |
| 20 | thead, p.table.header, |
| 21 | #toctitle, |
| 22 | #author, #revnumber, #revdate, #revremark, |
| 23 | #footer { |
| 24 | font-family: Arial,Helvetica,sans-serif; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | body { |
| 28 | margin: 1em 5% 1em 5%; |
| 29 | } |
| 30 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 31 | a { |
| 32 | color: blue; |
| 33 | text-decoration: underline; |
| 34 | } |
| 35 | a:visited { |
| 36 | color: fuchsia; |
| 37 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 38 | |
| 39 | em { |
| 40 | font-style: italic; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 41 | color: navy; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | strong { |
| 45 | font-weight: bold; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 46 | color: #083194; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 47 | } |
| 48 | |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 49 | h1, h2, h3, h4, h5, h6 { |
| 50 | color: #527bbd; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 51 | margin-top: 1.2em; |
| 52 | margin-bottom: 0.5em; |
| 53 | line-height: 1.3; |
| 54 | } |
| 55 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 56 | h1, h2, h3 { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 57 | border-bottom: 2px solid silver; |
| 58 | } |
| 59 | h2 { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 60 | padding-top: 0.5em; |
| 61 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 62 | h3 { |
| 63 | float: left; |
| 64 | } |
| 65 | h3 + * { |
| 66 | clear: left; |
| 67 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 68 | h5 { |
| 69 | font-size: 1.0em; |
| 70 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 71 | |
| 72 | div.sectionbody { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 73 | margin-left: 0; |
| 74 | } |
| 75 | |
| 76 | hr { |
| 77 | border: 1px solid silver; |
| 78 | } |
| 79 | |
| 80 | p { |
| 81 | margin-top: 0.5em; |
| 82 | margin-bottom: 0.5em; |
| 83 | } |
| 84 | |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 85 | ul, ol, li > p { |
| 86 | margin-top: 0; |
| 87 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 88 | ul > li { color: #aaa; } |
| 89 | ul > li > * { color: black; } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 90 | |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 91 | .monospaced, code, pre { |
| 92 | font-family: "Courier New", Courier, monospace; |
| 93 | font-size: inherit; |
| 94 | color: navy; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 95 | padding: 0; |
| 96 | margin: 0; |
| 97 | } |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 98 | pre { |
| 99 | white-space: pre-wrap; |
| 100 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 101 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 102 | #author { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 103 | color: #527bbd; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 104 | font-weight: bold; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 105 | font-size: 1.1em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 106 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 107 | #email { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 108 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 109 | #revnumber, #revdate, #revremark { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 110 | } |
| 111 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 112 | #footer { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 113 | font-size: small; |
| 114 | border-top: 2px solid silver; |
| 115 | padding-top: 0.5em; |
| 116 | margin-top: 4.0em; |
| 117 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 118 | #footer-text { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 119 | float: left; |
| 120 | padding-bottom: 0.5em; |
| 121 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 122 | #footer-badges { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 123 | float: right; |
| 124 | padding-bottom: 0.5em; |
| 125 | } |
| 126 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 127 | #preamble { |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 128 | margin-top: 1.5em; |
| 129 | margin-bottom: 1.5em; |
| 130 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 131 | div.imageblock, div.exampleblock, div.verseblock, |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 132 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 133 | div.admonitionblock { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 134 | margin-top: 1.0em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 135 | margin-bottom: 1.5em; |
| 136 | } |
| 137 | div.admonitionblock { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 138 | margin-top: 2.0em; |
| 139 | margin-bottom: 2.0em; |
| 140 | margin-right: 10%; |
| 141 | color: #606060; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | div.content { /* Block element content. */ |
| 145 | padding: 0; |
| 146 | } |
| 147 | |
| 148 | /* Block element titles. */ |
| 149 | div.title, caption.title { |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 150 | color: #527bbd; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 151 | font-weight: bold; |
| 152 | text-align: left; |
| 153 | margin-top: 1.0em; |
| 154 | margin-bottom: 0.5em; |
| 155 | } |
| 156 | div.title + * { |
| 157 | margin-top: 0; |
| 158 | } |
| 159 | |
| 160 | td div.title:first-child { |
| 161 | margin-top: 0.0em; |
| 162 | } |
| 163 | div.content div.title:first-child { |
| 164 | margin-top: 0.0em; |
| 165 | } |
| 166 | div.content + div.title { |
| 167 | margin-top: 0.0em; |
| 168 | } |
| 169 | |
| 170 | div.sidebarblock > div.content { |
| 171 | background: #ffffee; |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 172 | border: 1px solid #dddddd; |
| 173 | border-left: 4px solid #f0f0f0; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 174 | padding: 0.5em; |
| 175 | } |
| 176 | |
| 177 | div.listingblock > div.content { |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 178 | border: 1px solid #dddddd; |
| 179 | border-left: 5px solid #f0f0f0; |
| 180 | background: #f8f8f8; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 181 | padding: 0.5em; |
| 182 | } |
| 183 | |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 184 | div.quoteblock, div.verseblock { |
| 185 | padding-left: 1.0em; |
| 186 | margin-left: 1.0em; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 187 | margin-right: 10%; |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 188 | border-left: 5px solid #f0f0f0; |
| 189 | color: #888; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 190 | } |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 191 | |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 192 | div.quoteblock > div.attribution { |
| 193 | padding-top: 0.5em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 194 | text-align: right; |
| 195 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 196 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 197 | div.verseblock > pre.content { |
| 198 | font-family: inherit; |
| 199 | font-size: inherit; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 200 | } |
| 201 | div.verseblock > div.attribution { |
| 202 | padding-top: 0.75em; |
| 203 | text-align: left; |
| 204 | } |
| 205 | /* DEPRECATED: Pre version 8.2.7 verse style literal block. */ |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 206 | div.verseblock + div.attribution { |
| 207 | text-align: left; |
| 208 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 209 | |
| 210 | div.admonitionblock .icon { |
| 211 | vertical-align: top; |
| 212 | font-size: 1.1em; |
| 213 | font-weight: bold; |
| 214 | text-decoration: underline; |
| 215 | color: #527bbd; |
| 216 | padding-right: 0.5em; |
| 217 | } |
| 218 | div.admonitionblock td.content { |
| 219 | padding-left: 0.5em; |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 220 | border-left: 3px solid #dddddd; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | div.exampleblock > div.content { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 224 | border-left: 3px solid #dddddd; |
| 225 | padding-left: 0.5em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 226 | } |
| 227 | |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 228 | div.imageblock div.content { padding-left: 0; } |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 229 | span.image img { border-style: none; vertical-align: text-bottom; } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 230 | a.image:visited { color: white; } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 231 | |
| 232 | dl { |
| 233 | margin-top: 0.8em; |
| 234 | margin-bottom: 0.8em; |
| 235 | } |
| 236 | dt { |
| 237 | margin-top: 0.5em; |
| 238 | margin-bottom: 0; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 239 | font-style: normal; |
| 240 | color: navy; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 241 | } |
| 242 | dd > *:first-child { |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 243 | margin-top: 0.1em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | ul, ol { |
| 247 | list-style-position: outside; |
| 248 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 249 | ol.arabic { |
| 250 | list-style-type: decimal; |
| 251 | } |
| 252 | ol.loweralpha { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 253 | list-style-type: lower-alpha; |
| 254 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 255 | ol.upperalpha { |
| 256 | list-style-type: upper-alpha; |
| 257 | } |
| 258 | ol.lowerroman { |
| 259 | list-style-type: lower-roman; |
| 260 | } |
| 261 | ol.upperroman { |
| 262 | list-style-type: upper-roman; |
| 263 | } |
| 264 | |
| 265 | div.compact ul, div.compact ol, |
| 266 | div.compact p, div.compact p, |
| 267 | div.compact div, div.compact div { |
| 268 | margin-top: 0.1em; |
| 269 | margin-bottom: 0.1em; |
| 270 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 271 | |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 272 | tfoot { |
| 273 | font-weight: bold; |
| 274 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 275 | td > div.verse { |
| 276 | white-space: pre; |
| 277 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 278 | |
| 279 | div.hdlist { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 280 | margin-top: 0.8em; |
| 281 | margin-bottom: 0.8em; |
| 282 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 283 | div.hdlist tr { |
| 284 | padding-bottom: 15px; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 285 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 286 | dt.hdlist1.strong, td.hdlist1.strong { |
| 287 | font-weight: bold; |
| 288 | } |
| 289 | td.hdlist1 { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 290 | vertical-align: top; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 291 | font-style: normal; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 292 | padding-right: 0.8em; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 293 | color: navy; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 294 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 295 | td.hdlist2 { |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 296 | vertical-align: top; |
| 297 | } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 298 | div.hdlist.compact tr { |
| 299 | margin: 0; |
| 300 | padding-bottom: 0; |
| 301 | } |
| 302 | |
| 303 | .comment { |
| 304 | background: yellow; |
| 305 | } |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 306 | |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 307 | .footnote, .footnoteref { |
| 308 | font-size: 0.8em; |
| 309 | } |
| 310 | |
| 311 | span.footnote, span.footnoteref { |
| 312 | vertical-align: super; |
| 313 | } |
| 314 | |
| 315 | #footnotes { |
| 316 | margin: 20px 0 20px 0; |
| 317 | padding: 7px 0 0 0; |
| 318 | } |
| 319 | |
| 320 | #footnotes div.footnote { |
| 321 | margin: 0 0 5px 0; |
| 322 | } |
| 323 | |
| 324 | #footnotes hr { |
| 325 | border: none; |
| 326 | border-top: 1px solid silver; |
| 327 | height: 1px; |
| 328 | text-align: left; |
| 329 | margin-left: 0; |
| 330 | width: 20%; |
| 331 | min-width: 100px; |
| 332 | } |
| 333 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 334 | div.colist td { |
| 335 | padding-right: 0.5em; |
| 336 | padding-bottom: 0.3em; |
| 337 | vertical-align: top; |
| 338 | } |
| 339 | div.colist td img { |
| 340 | margin-top: 0.3em; |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 341 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 342 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 343 | @media print { |
| 344 | #footer-badges { display: none; } |
| 345 | } |
| 346 | |
| 347 | #toc { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 348 | margin-bottom: 2.5em; |
| 349 | } |
| 350 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 351 | #toctitle { |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 352 | color: #527bbd; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 353 | font-size: 1.1em; |
| 354 | font-weight: bold; |
| 355 | margin-top: 1.0em; |
| 356 | margin-bottom: 0.1em; |
| 357 | } |
| 358 | |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 359 | div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 360 | margin-top: 0; |
| 361 | margin-bottom: 0; |
| 362 | } |
| 363 | div.toclevel2 { |
| 364 | margin-left: 2em; |
| 365 | font-size: 0.9em; |
| 366 | } |
| 367 | div.toclevel3 { |
| 368 | margin-left: 4em; |
| 369 | font-size: 0.9em; |
| 370 | } |
| 371 | div.toclevel4 { |
| 372 | margin-left: 6em; |
| 373 | font-size: 0.9em; |
| 374 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 375 | |
| 376 | span.aqua { color: aqua; } |
| 377 | span.black { color: black; } |
| 378 | span.blue { color: blue; } |
| 379 | span.fuchsia { color: fuchsia; } |
| 380 | span.gray { color: gray; } |
| 381 | span.green { color: green; } |
| 382 | span.lime { color: lime; } |
| 383 | span.maroon { color: maroon; } |
| 384 | span.navy { color: navy; } |
| 385 | span.olive { color: olive; } |
| 386 | span.purple { color: purple; } |
| 387 | span.red { color: red; } |
| 388 | span.silver { color: silver; } |
| 389 | span.teal { color: teal; } |
| 390 | span.white { color: white; } |
| 391 | span.yellow { color: yellow; } |
| 392 | |
| 393 | span.aqua-background { background: aqua; } |
| 394 | span.black-background { background: black; } |
| 395 | span.blue-background { background: blue; } |
| 396 | span.fuchsia-background { background: fuchsia; } |
| 397 | span.gray-background { background: gray; } |
| 398 | span.green-background { background: green; } |
| 399 | span.lime-background { background: lime; } |
| 400 | span.maroon-background { background: maroon; } |
| 401 | span.navy-background { background: navy; } |
| 402 | span.olive-background { background: olive; } |
| 403 | span.purple-background { background: purple; } |
| 404 | span.red-background { background: red; } |
| 405 | span.silver-background { background: silver; } |
| 406 | span.teal-background { background: teal; } |
| 407 | span.white-background { background: white; } |
| 408 | span.yellow-background { background: yellow; } |
| 409 | |
| 410 | span.big { font-size: 2em; } |
| 411 | span.small { font-size: 0.6em; } |
| 412 | |
| 413 | span.underline { text-decoration: underline; } |
| 414 | span.overline { text-decoration: overline; } |
| 415 | span.line-through { text-decoration: line-through; } |
| 416 | |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 417 | div.unbreakable { page-break-inside: avoid; } |
| 418 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 419 | |
| 420 | /* |
| 421 | * xhtml11 specific |
| 422 | * |
| 423 | * */ |
| 424 | |
| 425 | div.tableblock { |
| 426 | margin-top: 1.0em; |
| 427 | margin-bottom: 1.5em; |
| 428 | } |
| 429 | div.tableblock > table { |
| 430 | border: 3px solid #527bbd; |
| 431 | } |
| 432 | thead, p.table.header { |
| 433 | font-weight: bold; |
| 434 | color: #527bbd; |
| 435 | } |
| 436 | p.table { |
| 437 | margin-top: 0; |
| 438 | } |
Junio C Hamano | 725b0da | 2020-01-22 22:02:40 | [diff] [blame] | 439 | /* Because the table frame attribute is overridden by CSS in most browsers. */ |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 440 | div.tableblock > table[frame="void"] { |
| 441 | border-style: none; |
| 442 | } |
| 443 | div.tableblock > table[frame="hsides"] { |
| 444 | border-left-style: none; |
| 445 | border-right-style: none; |
| 446 | } |
| 447 | div.tableblock > table[frame="vsides"] { |
| 448 | border-top-style: none; |
| 449 | border-bottom-style: none; |
| 450 | } |
| 451 | |
| 452 | |
| 453 | /* |
| 454 | * html5 specific |
| 455 | * |
| 456 | * */ |
| 457 | |
| 458 | table.tableblock { |
| 459 | margin-top: 1.0em; |
| 460 | margin-bottom: 1.5em; |
| 461 | } |
| 462 | thead, p.tableblock.header { |
| 463 | font-weight: bold; |
| 464 | color: #527bbd; |
| 465 | } |
| 466 | p.tableblock { |
| 467 | margin-top: 0; |
| 468 | } |
| 469 | table.tableblock { |
| 470 | border-width: 3px; |
| 471 | border-spacing: 0px; |
| 472 | border-style: solid; |
| 473 | border-color: #527bbd; |
| 474 | border-collapse: collapse; |
| 475 | } |
| 476 | th.tableblock, td.tableblock { |
| 477 | border-width: 1px; |
| 478 | padding: 4px; |
| 479 | border-style: solid; |
| 480 | border-color: #527bbd; |
| 481 | } |
| 482 | |
| 483 | table.tableblock.frame-topbot { |
| 484 | border-left-style: hidden; |
| 485 | border-right-style: hidden; |
| 486 | } |
| 487 | table.tableblock.frame-sides { |
| 488 | border-top-style: hidden; |
| 489 | border-bottom-style: hidden; |
| 490 | } |
| 491 | table.tableblock.frame-none { |
| 492 | border-style: hidden; |
| 493 | } |
| 494 | |
| 495 | th.tableblock.halign-left, td.tableblock.halign-left { |
| 496 | text-align: left; |
| 497 | } |
| 498 | th.tableblock.halign-center, td.tableblock.halign-center { |
| 499 | text-align: center; |
| 500 | } |
| 501 | th.tableblock.halign-right, td.tableblock.halign-right { |
| 502 | text-align: right; |
| 503 | } |
| 504 | |
| 505 | th.tableblock.valign-top, td.tableblock.valign-top { |
| 506 | vertical-align: top; |
| 507 | } |
| 508 | th.tableblock.valign-middle, td.tableblock.valign-middle { |
| 509 | vertical-align: middle; |
| 510 | } |
| 511 | th.tableblock.valign-bottom, td.tableblock.valign-bottom { |
| 512 | vertical-align: bottom; |
| 513 | } |
| 514 | |
| 515 | |
| 516 | /* |
| 517 | * manpage specific |
| 518 | * |
| 519 | * */ |
| 520 | |
| 521 | body.manpage h1 { |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 522 | padding-top: 0.5em; |
| 523 | padding-bottom: 0.5em; |
| 524 | border-top: 2px solid silver; |
| 525 | border-bottom: 2px solid silver; |
| 526 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 527 | body.manpage h2 { |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 528 | border-style: none; |
| 529 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 530 | body.manpage div.sectionbody { |
| 531 | margin-left: 3em; |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | @media print { |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 535 | body.manpage div#toc { display: none; } |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 536 | } |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 537 | |
| 538 | |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 539 | </style> |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 540 | <script type="text/javascript"> |
| 541 | /*<![CDATA[*/ |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 542 | var asciidoc = { // Namespace. |
| 543 | |
| 544 | ///////////////////////////////////////////////////////////////////// |
| 545 | // Table Of Contents generator |
| 546 | ///////////////////////////////////////////////////////////////////// |
| 547 | |
| 548 | /* Author: Mihai Bazon, September 2002 |
| 549 | * http://students.infoiasi.ro/~mishoo |
| 550 | * |
| 551 | * Table Of Content generator |
| 552 | * Version: 0.4 |
| 553 | * |
| 554 | * Feel free to use this script under the terms of the GNU General Public |
| 555 | * License, as long as you do not remove or alter this notice. |
| 556 | */ |
| 557 | |
| 558 | /* modified by Troy D. Hanson, September 2006. License: GPL */ |
| 559 | /* modified by Stuart Rackham, 2006, 2009. License: GPL */ |
| 560 | |
| 561 | // toclevels = 1..4. |
| 562 | toc: function (toclevels) { |
| 563 | |
| 564 | function getText(el) { |
| 565 | var text = ""; |
| 566 | for (var i = el.firstChild; i != null; i = i.nextSibling) { |
| 567 | if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants. |
| 568 | text += i.data; |
| 569 | else if (i.firstChild != null) |
| 570 | text += getText(i); |
| 571 | } |
| 572 | return text; |
| 573 | } |
| 574 | |
| 575 | function TocEntry(el, text, toclevel) { |
| 576 | this.element = el; |
| 577 | this.text = text; |
| 578 | this.toclevel = toclevel; |
| 579 | } |
| 580 | |
| 581 | function tocEntries(el, toclevels) { |
| 582 | var result = new Array; |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 583 | var re = new RegExp('[hH]([1-'+(toclevels+1)+'])'); |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 584 | // Function that scans the DOM tree for header elements (the DOM2 |
| 585 | // nodeIterator API would be a better technique but not supported by all |
| 586 | // browsers). |
| 587 | var iterate = function (el) { |
| 588 | for (var i = el.firstChild; i != null; i = i.nextSibling) { |
| 589 | if (i.nodeType == 1 /* Node.ELEMENT_NODE */) { |
| 590 | var mo = re.exec(i.tagName); |
| 591 | if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") { |
| 592 | result[result.length] = new TocEntry(i, getText(i), mo[1]-1); |
| 593 | } |
| 594 | iterate(i); |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | iterate(el); |
| 599 | return result; |
| 600 | } |
| 601 | |
| 602 | var toc = document.getElementById("toc"); |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 603 | if (!toc) { |
| 604 | return; |
| 605 | } |
| 606 | |
| 607 | // Delete existing TOC entries in case we're reloading the TOC. |
| 608 | var tocEntriesToRemove = []; |
| 609 | var i; |
| 610 | for (i = 0; i < toc.childNodes.length; i++) { |
| 611 | var entry = toc.childNodes[i]; |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 612 | if (entry.nodeName.toLowerCase() == 'div' |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 613 | && entry.getAttribute("class") |
| 614 | && entry.getAttribute("class").match(/^toclevel/)) |
| 615 | tocEntriesToRemove.push(entry); |
| 616 | } |
| 617 | for (i = 0; i < tocEntriesToRemove.length; i++) { |
| 618 | toc.removeChild(tocEntriesToRemove[i]); |
| 619 | } |
| 620 | |
| 621 | // Rebuild TOC entries. |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 622 | var entries = tocEntries(document.getElementById("content"), toclevels); |
| 623 | for (var i = 0; i < entries.length; ++i) { |
| 624 | var entry = entries[i]; |
| 625 | if (entry.element.id == "") |
| 626 | entry.element.id = "_toc_" + i; |
| 627 | var a = document.createElement("a"); |
| 628 | a.href = "#" + entry.element.id; |
| 629 | a.appendChild(document.createTextNode(entry.text)); |
| 630 | var div = document.createElement("div"); |
| 631 | div.appendChild(a); |
| 632 | div.className = "toclevel" + entry.toclevel; |
| 633 | toc.appendChild(div); |
| 634 | } |
| 635 | if (entries.length == 0) |
| 636 | toc.parentNode.removeChild(toc); |
| 637 | }, |
| 638 | |
| 639 | |
| 640 | ///////////////////////////////////////////////////////////////////// |
| 641 | // Footnotes generator |
| 642 | ///////////////////////////////////////////////////////////////////// |
| 643 | |
| 644 | /* Based on footnote generation code from: |
| 645 | * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html |
| 646 | */ |
| 647 | |
| 648 | footnotes: function () { |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 649 | // Delete existing footnote entries in case we're reloading the footnodes. |
| 650 | var i; |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 651 | var noteholder = document.getElementById("footnotes"); |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 652 | if (!noteholder) { |
| 653 | return; |
| 654 | } |
| 655 | var entriesToRemove = []; |
| 656 | for (i = 0; i < noteholder.childNodes.length; i++) { |
| 657 | var entry = noteholder.childNodes[i]; |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 658 | if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote") |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 659 | entriesToRemove.push(entry); |
| 660 | } |
| 661 | for (i = 0; i < entriesToRemove.length; i++) { |
| 662 | noteholder.removeChild(entriesToRemove[i]); |
| 663 | } |
| 664 | |
| 665 | // Rebuild footnote entries. |
| 666 | var cont = document.getElementById("content"); |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 667 | var spans = cont.getElementsByTagName("span"); |
| 668 | var refs = {}; |
| 669 | var n = 0; |
| 670 | for (i=0; i<spans.length; i++) { |
| 671 | if (spans[i].className == "footnote") { |
| 672 | n++; |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 673 | var note = spans[i].getAttribute("data-note"); |
| 674 | if (!note) { |
| 675 | // Use [\s\S] in place of . so multi-line matches work. |
| 676 | // Because JavaScript has no s (dotall) regex flag. |
| 677 | note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1]; |
| 678 | spans[i].innerHTML = |
| 679 | "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n + |
| 680 | "' title='View footnote' class='footnote'>" + n + "</a>]"; |
| 681 | spans[i].setAttribute("data-note", note); |
| 682 | } |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 683 | noteholder.innerHTML += |
| 684 | "<div class='footnote' id='_footnote_" + n + "'>" + |
| 685 | "<a href='#_footnoteref_" + n + "' title='Return to text'>" + |
| 686 | n + "</a>. " + note + "</div>"; |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 687 | var id =spans[i].getAttribute("id"); |
| 688 | if (id != null) refs["#"+id] = n; |
| 689 | } |
| 690 | } |
| 691 | if (n == 0) |
| 692 | noteholder.parentNode.removeChild(noteholder); |
| 693 | else { |
| 694 | // Process footnoterefs. |
| 695 | for (i=0; i<spans.length; i++) { |
| 696 | if (spans[i].className == "footnoteref") { |
| 697 | var href = spans[i].getElementsByTagName("a")[0].getAttribute("href"); |
| 698 | href = href.match(/#.*/)[0]; // Because IE return full URL. |
| 699 | n = refs[href]; |
| 700 | spans[i].innerHTML = |
| 701 | "[<a href='#_footnote_" + n + |
| 702 | "' title='View footnote' class='footnote'>" + n + "</a>]"; |
| 703 | } |
| 704 | } |
| 705 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 706 | }, |
| 707 | |
| 708 | install: function(toclevels) { |
| 709 | var timerId; |
| 710 | |
| 711 | function reinstall() { |
| 712 | asciidoc.footnotes(); |
| 713 | if (toclevels) { |
| 714 | asciidoc.toc(toclevels); |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | function reinstallAndRemoveTimer() { |
| 719 | clearInterval(timerId); |
| 720 | reinstall(); |
| 721 | } |
| 722 | |
| 723 | timerId = setInterval(reinstall, 500); |
| 724 | if (document.addEventListener) |
| 725 | document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false); |
| 726 | else |
| 727 | window.onload = reinstallAndRemoveTimer; |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 731 | asciidoc.install(); |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 732 | /*]]>*/ |
| 733 | </script> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 734 | </head> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 735 | <body class="manpage"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 736 | <div id="header"> |
| 737 | <h1> |
| 738 | gitattributes(5) Manual Page |
| 739 | </h1> |
| 740 | <h2>NAME</h2> |
| 741 | <div class="sectionbody"> |
| 742 | <p>gitattributes - |
Junio C Hamano | c9cb517 | 2018-06-01 07:13:44 | [diff] [blame] | 743 | Defining attributes per path |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 744 | </p> |
| 745 | </div> |
| 746 | </div> |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 747 | <div id="content"> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 748 | <div class="sect1"> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 749 | <h2 id="_synopsis">SYNOPSIS</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 750 | <div class="sectionbody"> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 751 | <div class="paragraph"><p>$GIT_DIR/info/attributes, .gitattributes</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 752 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 753 | </div> |
| 754 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 755 | <h2 id="_description">DESCRIPTION</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 756 | <div class="sectionbody"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 757 | <div class="paragraph"><p>A <code>gitattributes</code> file is a simple text file that gives |
| 758 | <code>attributes</code> to pathnames.</p></div> |
| 759 | <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] | 760 | <div class="literalblock"> |
| 761 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 762 | <pre><code>pattern attr1 attr2 ...</code></pre> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 763 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 764 | <div class="paragraph"><p>That is, a pattern followed by an attributes list, |
Junio C Hamano | cbe0eb2 | 2017-02-27 23:37:49 | [diff] [blame] | 765 | separated by whitespaces. Leading and trailing whitespaces are |
| 766 | ignored. Lines that begin with <em>#</em> are ignored. Patterns |
| 767 | that begin with a double quote are quoted in C style. |
| 768 | When the pattern matches the path in question, the attributes |
| 769 | listed on the line are given to the path.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 770 | <div class="paragraph"><p>Each attribute can be in one of these states for a given path:</p></div> |
| 771 | <div class="dlist"><dl> |
| 772 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 773 | Set |
| 774 | </dt> |
| 775 | <dd> |
| 776 | <p> |
| 777 | The path has the attribute with special value "true"; |
| 778 | this is specified by listing only the name of the |
| 779 | attribute in the attribute list. |
| 780 | </p> |
| 781 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 782 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 783 | Unset |
| 784 | </dt> |
| 785 | <dd> |
| 786 | <p> |
| 787 | The path has the attribute with special value "false"; |
| 788 | this is specified by listing the name of the attribute |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 789 | prefixed with a dash <code>-</code> in the attribute list. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 790 | </p> |
| 791 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 792 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 793 | Set to a value |
| 794 | </dt> |
| 795 | <dd> |
| 796 | <p> |
| 797 | The path has the attribute with specified string value; |
| 798 | this is specified by listing the name of the attribute |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 799 | followed by an equal sign <code>=</code> and its value in the |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 800 | attribute list. |
| 801 | </p> |
| 802 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 803 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 804 | Unspecified |
| 805 | </dt> |
| 806 | <dd> |
| 807 | <p> |
Junio C Hamano | d533bdb | 2009-02-25 09:56:58 | [diff] [blame] | 808 | No pattern matches the path, and nothing says if |
Junio C Hamano | 22572e7 | 2007-04-25 05:59:25 | [diff] [blame] | 809 | the path has or does not have the attribute, the |
| 810 | attribute for the path is said to be Unspecified. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 811 | </p> |
| 812 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 813 | </dl></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 814 | <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] | 815 | overrides an earlier line. This overriding is done per |
Junio C Hamano | 8100016 | 2018-03-21 19:54:50 | [diff] [blame] | 816 | attribute.</p></div> |
| 817 | <div class="paragraph"><p>The rules by which the pattern matches paths are the same as in |
| 818 | <code>.gitignore</code> files (see <a href="gitignore.html">gitignore(5)</a>), with a few exceptions:</p></div> |
| 819 | <div class="ulist"><ul> |
| 820 | <li> |
| 821 | <p> |
| 822 | negative patterns are forbidden |
| 823 | </p> |
| 824 | </li> |
| 825 | <li> |
| 826 | <p> |
| 827 | patterns that match a directory do not recursively match paths |
| 828 | inside that directory (so using the trailing-slash <code>path/</code> syntax is |
| 829 | pointless in an attributes file; use <code>path/**</code> instead) |
| 830 | </p> |
| 831 | </li> |
| 832 | </ul></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 833 | <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] | 834 | consults <code>$GIT_DIR/info/attributes</code> file (which has the highest |
| 835 | precedence), <code>.gitattributes</code> file in the same directory as the |
Junio C Hamano | b4a9ede | 2009-04-08 07:36:32 | [diff] [blame] | 836 | 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] | 837 | work tree (the further the directory that contains <code>.gitattributes</code> |
Junio C Hamano | 3b4609d | 2010-09-30 00:04:34 | [diff] [blame] | 838 | is from the path in question, the lower its precedence). Finally |
| 839 | global and system-wide files are considered (they have the lowest |
| 840 | precedence).</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 841 | <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] | 842 | 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] | 843 | <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] | 844 | working tree is used as a fall-back.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 845 | <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] | 846 | attributes to files that are particular to |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 847 | one user’s workflow for that repository), then |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 848 | 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] | 849 | Attributes which should be version-controlled and distributed to other |
| 850 | repositories (i.e., attributes of interest to all users) should go into |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 851 | <code>.gitattributes</code> files. Attributes that should affect all repositories |
Junio C Hamano | 3b4609d | 2010-09-30 00:04:34 | [diff] [blame] | 852 | 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] | 853 | <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] | 854 | Its default value is $XDG_CONFIG_HOME/git/attributes. If $XDG_CONFIG_HOME |
| 855 | 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] | 856 | Attributes for all users on a system should be placed in the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 857 | <code>$(prefix)/etc/gitattributes</code> file.</p></div> |
Junio C Hamano | cbe0eb2 | 2017-02-27 23:37:49 | [diff] [blame] | 858 | <div class="paragraph"><p>Sometimes you would need to override a setting of an attribute |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 859 | for a path to <code>Unspecified</code> state. This can be done by listing |
| 860 | 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] | 861 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 862 | </div> |
| 863 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 864 | <h2 id="_effects">EFFECTS</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 865 | <div class="sectionbody"> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 866 | <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] | 867 | particular attributes to a path. Currently, the following |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 868 | operations are attributes-aware.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 869 | <div class="sect2"> |
| 870 | <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] | 871 | <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] | 872 | repository are copied to the working tree files when commands |
Junio C Hamano | c9f11c2 | 2019-07-10 02:54:04 | [diff] [blame] | 873 | such as <em>git switch</em>, <em>git checkout</em> and <em>git merge</em> run. |
| 874 | They also affect how |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 875 | Git stores the contents you prepare in the working tree in the |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 876 | 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] | 877 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 878 | <h4 id="_code_text_code"><code>text</code></h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 879 | <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] | 880 | text file is normalized, its line endings are converted to LF in the |
| 881 | repository. To control what line ending style is used in the working |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 882 | directory, use the <code>eol</code> attribute for a single file and the |
Junio C Hamano | eed15af | 2016-07-25 22:49:42 | [diff] [blame] | 883 | <code>core.eol</code> configuration variable for all text files. |
Junio C Hamano | 23168ef | 2019-02-07 07:20:47 | [diff] [blame] | 884 | Note that setting <code>core.autocrlf</code> to <code>true</code> or <code>input</code> overrides |
| 885 | <code>core.eol</code> (see the definitions of those options in |
| 886 | <a href="git-config.html">git-config(1)</a>).</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 887 | <div class="dlist"><dl> |
| 888 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 889 | Set |
| 890 | </dt> |
| 891 | <dd> |
| 892 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 893 | 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] | 894 | normalization and marks the path as a text file. End-of-line |
| 895 | conversion takes place without guessing the content type. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 896 | </p> |
| 897 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 898 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 899 | Unset |
| 900 | </dt> |
| 901 | <dd> |
| 902 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 903 | 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] | 904 | attempt any end-of-line conversion upon checkin or checkout. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 905 | </p> |
| 906 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 907 | <dt class="hdlist1"> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 908 | Set to string value "auto" |
| 909 | </dt> |
| 910 | <dd> |
| 911 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 912 | When <code>text</code> is set to "auto", the path is marked for automatic |
Junio C Hamano | eed15af | 2016-07-25 22:49:42 | [diff] [blame] | 913 | end-of-line conversion. If Git decides that the content is |
| 914 | text, its line endings are converted to LF on checkin. |
Junio C Hamano | 0f1d17c | 2016-08-12 19:42:26 | [diff] [blame] | 915 | When the file has been committed with CRLF, no conversion is done. |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 916 | </p> |
| 917 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 918 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 919 | Unspecified |
| 920 | </dt> |
| 921 | <dd> |
| 922 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 923 | If the <code>text</code> attribute is unspecified, Git uses the |
| 924 | <code>core.autocrlf</code> configuration variable to determine if the |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 925 | file should be converted. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 926 | </p> |
| 927 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 928 | </dl></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 929 | <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] | 930 | unspecified.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 931 | </div> |
| 932 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 933 | <h4 id="_code_eol_code"><code>eol</code></h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 934 | <div class="paragraph"><p>This attribute sets a specific line-ending style to be used in the |
Junio C Hamano | eed15af | 2016-07-25 22:49:42 | [diff] [blame] | 935 | working directory. It enables end-of-line conversion without any |
Junio C Hamano | 8d57fa9 | 2017-09-19 05:01:08 | [diff] [blame] | 936 | content checks, effectively setting the <code>text</code> attribute. Note that |
| 937 | setting this attribute on paths which are in the index with CRLF line |
| 938 | endings may make the paths to be considered dirty. Adding the path to |
| 939 | the index again will normalize the line endings in the index.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 940 | <div class="dlist"><dl> |
| 941 | <dt class="hdlist1"> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 942 | Set to string value "crlf" |
| 943 | </dt> |
| 944 | <dd> |
| 945 | <p> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 946 | This setting forces Git to normalize line endings for this |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 947 | file on checkin and convert them to CRLF when the file is |
| 948 | checked out. |
| 949 | </p> |
| 950 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 951 | <dt class="hdlist1"> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 952 | Set to string value "lf" |
| 953 | </dt> |
| 954 | <dd> |
| 955 | <p> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 956 | This setting forces Git to normalize line endings to LF on |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 957 | checkin and prevents conversion to CRLF when the file is |
| 958 | checked out. |
| 959 | </p> |
| 960 | </dd> |
| 961 | </dl></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 962 | </div> |
| 963 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 964 | <h4 id="_backwards_compatibility_with_code_crlf_code_attribute">Backwards compatibility with <code>crlf</code> attribute</h4> |
| 965 | <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] | 966 | follows:</p></div> |
| 967 | <div class="listingblock"> |
| 968 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 969 | <pre><code>crlf text |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 970 | -crlf -text |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 971 | crlf=input eol=lf</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 972 | </div></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 973 | </div> |
| 974 | <div class="sect3"> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 975 | <h4 id="_end_of_line_conversion">End-of-line conversion</h4> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 976 | <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] | 977 | normalize line endings to LF in the repository and, optionally, to |
| 978 | convert them to CRLF when files are checked out.</p></div> |
Junio C Hamano | e7808d7 | 2016-08-26 21:48:01 | [diff] [blame] | 979 | <div class="paragraph"><p>If you simply want to have CRLF line endings in your working directory |
| 980 | regardless of the repository you are working with, you can set the |
| 981 | config variable "core.autocrlf" without using any attributes.</p></div> |
| 982 | <div class="listingblock"> |
| 983 | <div class="content"> |
| 984 | <pre><code>[core] |
| 985 | autocrlf = true</code></pre> |
| 986 | </div></div> |
| 987 | <div class="paragraph"><p>This does not force normalization of text files, but does ensure |
| 988 | that text files that you introduce to the repository have their line |
| 989 | endings normalized to LF when they are added, and that files that are |
| 990 | already normalized in the repository stay normalized.</p></div> |
| 991 | <div class="paragraph"><p>If you want to ensure that text files that any contributor introduces to |
| 992 | the repository have their line endings normalized, you can set the |
| 993 | <code>text</code> attribute to "auto" for <em>all</em> files.</p></div> |
| 994 | <div class="listingblock"> |
| 995 | <div class="content"> |
| 996 | <pre><code>* text=auto</code></pre> |
| 997 | </div></div> |
| 998 | <div class="paragraph"><p>The attributes allow a fine-grained control, how the line endings |
| 999 | are converted. |
| 1000 | 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] | 1001 | files, ensure that .vcproj files have CRLF and .sh files have LF in |
| 1002 | the working directory, and prevent .jpg files from being normalized |
| 1003 | regardless of their content.</p></div> |
| 1004 | <div class="listingblock"> |
| 1005 | <div class="content"> |
Junio C Hamano | eed15af | 2016-07-25 22:49:42 | [diff] [blame] | 1006 | <pre><code>* text=auto |
| 1007 | *.txt text |
| 1008 | *.vcproj text eol=crlf |
| 1009 | *.sh text eol=lf |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1010 | *.jpg -text</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1011 | </div></div> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1012 | <div class="admonitionblock"> |
| 1013 | <table><tr> |
| 1014 | <td class="icon"> |
| 1015 | <div class="title">Note</div> |
| 1016 | </td> |
Junio C Hamano | e7808d7 | 2016-08-26 21:48:01 | [diff] [blame] | 1017 | <td class="content">When <code>text=auto</code> conversion is enabled in a cross-platform |
| 1018 | project using push and pull to a central repository the text files |
| 1019 | containing CRLFs should be normalized.</td> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1020 | </tr></table> |
| 1021 | </div> |
Junio C Hamano | e7808d7 | 2016-08-26 21:48:01 | [diff] [blame] | 1022 | <div class="paragraph"><p>From a clean working directory:</p></div> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1023 | <div class="listingblock"> |
| 1024 | <div class="content"> |
Junio C Hamano | e7808d7 | 2016-08-26 21:48:01 | [diff] [blame] | 1025 | <pre><code>$ echo "* text=auto" >.gitattributes |
Junio C Hamano | 4886c77 | 2017-11-27 03:33:28 | [diff] [blame] | 1026 | $ git add --renormalize . |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1027 | $ git status # Show files that will be normalized |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1028 | $ git commit -m "Introduce end-of-line normalization"</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1029 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1030 | <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] | 1031 | 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] | 1032 | <div class="listingblock"> |
| 1033 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1034 | <pre><code>manual.pdf -text</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1035 | </div></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1036 | <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] | 1037 | enabled manually.</p></div> |
| 1038 | <div class="listingblock"> |
| 1039 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1040 | <pre><code>weirdchars.txt text</code></pre> |
Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1041 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1042 | <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] | 1043 | the conversion is reversible for the current setting of |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1044 | <code>core.autocrlf</code>. For "true", Git rejects irreversible |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1045 | conversions; for "warn", Git only prints a warning but accepts |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 1046 | an irreversible conversion. The safety triggers to prevent such |
| 1047 | 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] | 1048 | few exceptions. Even though…</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1049 | <div class="ulist"><ul> |
Junio C Hamano | 26e590a | 2008-02-17 03:53:51 | [diff] [blame] | 1050 | <li> |
| 1051 | <p> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1052 | <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] | 1053 | next checkout would, so the safety triggers; |
| 1054 | </p> |
| 1055 | </li> |
| 1056 | <li> |
| 1057 | <p> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1058 | <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] | 1059 | in the work tree, but the operation is about text files and CRLF |
| 1060 | conversion is about fixing the line ending inconsistencies, so the |
| 1061 | safety does not trigger; |
| 1062 | </p> |
| 1063 | </li> |
| 1064 | <li> |
| 1065 | <p> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1066 | <em>git diff</em> itself does not touch the files in the work tree, it is |
| 1067 | 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] | 1068 | catch potential problems early, safety triggers. |
| 1069 | </p> |
| 1070 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1071 | </ul></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1072 | </div> |
| 1073 | <div class="sect3"> |
Junio C Hamano | ccb8252 | 2018-05-08 07:52:09 | [diff] [blame] | 1074 | <h4 id="_code_working_tree_encoding_code"><code>working-tree-encoding</code></h4> |
| 1075 | <div class="paragraph"><p>Git recognizes files encoded in ASCII or one of its supersets (e.g. |
| 1076 | UTF-8, ISO-8859-1, …) as text files. Files encoded in certain other |
| 1077 | encodings (e.g. UTF-16) are interpreted as binary and consequently |
| 1078 | built-in Git text processing tools (e.g. <em>git diff</em>) as well as most Git |
| 1079 | web front ends do not visualize the contents of these files by default.</p></div> |
| 1080 | <div class="paragraph"><p>In these cases you can tell Git the encoding of a file in the working |
| 1081 | directory with the <code>working-tree-encoding</code> attribute. If a file with this |
Junio C Hamano | 8ef91f3 | 2019-12-01 22:58:27 | [diff] [blame] | 1082 | attribute is added to Git, then Git re-encodes the content from the |
Junio C Hamano | ccb8252 | 2018-05-08 07:52:09 | [diff] [blame] | 1083 | specified encoding to UTF-8. Finally, Git stores the UTF-8 encoded |
| 1084 | content in its internal data structure (called "the index"). On checkout |
Junio C Hamano | 8ef91f3 | 2019-12-01 22:58:27 | [diff] [blame] | 1085 | the content is re-encoded back to the specified encoding.</p></div> |
Junio C Hamano | ccb8252 | 2018-05-08 07:52:09 | [diff] [blame] | 1086 | <div class="paragraph"><p>Please note that using the <code>working-tree-encoding</code> attribute may have a |
| 1087 | number of pitfalls:</p></div> |
| 1088 | <div class="ulist"><ul> |
| 1089 | <li> |
| 1090 | <p> |
| 1091 | Alternative Git implementations (e.g. JGit or libgit2) and older Git |
| 1092 | versions (as of March 2018) do not support the <code>working-tree-encoding</code> |
| 1093 | attribute. If you decide to use the <code>working-tree-encoding</code> attribute |
| 1094 | in your repository, then it is strongly recommended to ensure that all |
| 1095 | clients working with the repository support it. |
| 1096 | </p> |
Junio C Hamano | 94d00a5 | 2018-10-30 07:34:40 | [diff] [blame] | 1097 | <div class="paragraph"><p>For example, Microsoft Visual Studio resources files (<code>*.rc</code>) or |
| 1098 | PowerShell script files (<code>*.ps1</code>) are sometimes encoded in UTF-16. |
| 1099 | If you declare <code>*.ps1</code> as files as UTF-16 and you add <code>foo.ps1</code> with |
| 1100 | a <code>working-tree-encoding</code> enabled Git client, then <code>foo.ps1</code> will be |
| 1101 | stored as UTF-8 internally. A client without <code>working-tree-encoding</code> |
| 1102 | support will checkout <code>foo.ps1</code> as UTF-8 encoded file. This will |
| 1103 | typically cause trouble for the users of this file.</p></div> |
Junio C Hamano | 6b7d215 | 2019-04-16 12:51:15 | [diff] [blame] | 1104 | <div class="paragraph"><p>If a Git client that does not support the <code>working-tree-encoding</code> |
| 1105 | attribute adds a new file <code>bar.ps1</code>, then <code>bar.ps1</code> will be |
Junio C Hamano | ccb8252 | 2018-05-08 07:52:09 | [diff] [blame] | 1106 | stored "as-is" internally (in this example probably as UTF-16). |
Junio C Hamano | 94d00a5 | 2018-10-30 07:34:40 | [diff] [blame] | 1107 | A client with <code>working-tree-encoding</code> support will interpret the |
Junio C Hamano | ccb8252 | 2018-05-08 07:52:09 | [diff] [blame] | 1108 | internal contents as UTF-8 and try to convert it to UTF-16 on checkout. |
Junio C Hamano | 94d00a5 | 2018-10-30 07:34:40 | [diff] [blame] | 1109 | That operation will fail and cause an error.</p></div> |
Junio C Hamano | ccb8252 | 2018-05-08 07:52:09 | [diff] [blame] | 1110 | </li> |
| 1111 | <li> |
| 1112 | <p> |
| 1113 | Reencoding content to non-UTF encodings can cause errors as the |
| 1114 | conversion might not be UTF-8 round trip safe. If you suspect your |
| 1115 | encoding to not be round trip safe, then add it to |
| 1116 | <code>core.checkRoundtripEncoding</code> to make Git check the round trip |
| 1117 | encoding (see <a href="git-config.html">git-config(1)</a>). SHIFT-JIS (Japanese character |
| 1118 | set) is known to have round trip issues with UTF-8 and is checked by |
| 1119 | default. |
| 1120 | </p> |
| 1121 | </li> |
| 1122 | <li> |
| 1123 | <p> |
| 1124 | Reencoding content requires resources that might slow down certain |
| 1125 | Git operations (e.g <em>git checkout</em> or <em>git add</em>). |
| 1126 | </p> |
| 1127 | </li> |
| 1128 | </ul></div> |
| 1129 | <div class="paragraph"><p>Use the <code>working-tree-encoding</code> attribute only if you cannot store a file |
| 1130 | in UTF-8 encoding and if you want Git to be able to process the content |
| 1131 | as text.</p></div> |
| 1132 | <div class="paragraph"><p>As an example, use the following attributes if your <em>*.ps1</em> files are |
| 1133 | UTF-16 encoded with byte order mark (BOM) and you want Git to perform |
| 1134 | automatic line ending conversion based on your platform.</p></div> |
| 1135 | <div class="listingblock"> |
| 1136 | <div class="content"> |
| 1137 | <pre><code>*.ps1 text working-tree-encoding=UTF-16</code></pre> |
| 1138 | </div></div> |
| 1139 | <div class="paragraph"><p>Use the following attributes if your <em>*.ps1</em> files are UTF-16 little |
| 1140 | endian encoded without BOM and you want Git to use Windows line endings |
Junio C Hamano | decc731 | 2019-03-11 09:02:54 | [diff] [blame] | 1141 | in the working directory (use <code>UTF-16LE-BOM</code> instead of <code>UTF-16LE</code> if |
Junio C Hamano | 23168ef | 2019-02-07 07:20:47 | [diff] [blame] | 1142 | you want UTF-16 little endian with BOM). |
| 1143 | Please note, it is highly recommended to |
Junio C Hamano | ccb8252 | 2018-05-08 07:52:09 | [diff] [blame] | 1144 | explicitly define the line endings with <code>eol</code> if the <code>working-tree-encoding</code> |
| 1145 | attribute is used to avoid ambiguity.</p></div> |
| 1146 | <div class="listingblock"> |
| 1147 | <div class="content"> |
| 1148 | <pre><code>*.ps1 text working-tree-encoding=UTF-16LE eol=CRLF</code></pre> |
| 1149 | </div></div> |
| 1150 | <div class="paragraph"><p>You can get a list of all available encodings on your platform with the |
| 1151 | following command:</p></div> |
| 1152 | <div class="listingblock"> |
| 1153 | <div class="content"> |
| 1154 | <pre><code>iconv --list</code></pre> |
| 1155 | </div></div> |
| 1156 | <div class="paragraph"><p>If you do not know the encoding of a file, then you can use the <code>file</code> |
| 1157 | command to guess the encoding:</p></div> |
| 1158 | <div class="listingblock"> |
| 1159 | <div class="content"> |
| 1160 | <pre><code>file foo.ps1</code></pre> |
| 1161 | </div></div> |
| 1162 | </div> |
| 1163 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1164 | <h4 id="_code_ident_code"><code>ident</code></h4> |
| 1165 | <div class="paragraph"><p>When the attribute <code>ident</code> is set for a path, Git replaces |
| 1166 | <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] | 1167 | 40-character hexadecimal blob object name, followed by a dollar |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1168 | sign <code>$</code> upon checkout. Any byte sequence that begins with |
| 1169 | <code>$Id:</code> and ends with <code>$</code> in the worktree file is replaced |
| 1170 | with <code>$Id$</code> upon check-in.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1171 | </div> |
| 1172 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1173 | <h4 id="_code_filter_code"><code>filter</code></h4> |
| 1174 | <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] | 1175 | filter driver specified in the configuration.</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1176 | <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] | 1177 | command, either of which can be left unspecified. Upon |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1178 | checkout, when the <code>smudge</code> command is specified, the command is |
Junio C Hamano | 361c133 | 2007-11-14 12:17:22 | [diff] [blame] | 1179 | fed the blob object from its standard input, and its standard |
| 1180 | output is used to update the worktree file. Similarly, the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1181 | <code>clean</code> command is used to convert the contents of worktree file |
Junio C Hamano | f2f28b1 | 2016-10-31 21:41:58 | [diff] [blame] | 1182 | upon checkin. By default these commands process only a single |
| 1183 | blob and terminate. If a long running <code>process</code> filter is used |
| 1184 | in place of <code>clean</code> and/or <code>smudge</code> filters, then Git can process |
| 1185 | all blobs with a single filter command invocation for the entire |
| 1186 | life of a single Git command, for example <code>git add --all</code>. If a |
| 1187 | long running <code>process</code> filter is configured then it always takes |
| 1188 | precedence over a configured single blob filter. See section |
| 1189 | below for the description of the protocol used to communicate with |
| 1190 | a <code>process</code> filter.</p></div> |
Junio C Hamano | 90a5b7b | 2012-02-28 23:40:31 | [diff] [blame] | 1191 | <div class="paragraph"><p>One use of the content filtering is to massage the content into a shape |
| 1192 | that is more convenient for the platform, filesystem, and the user to use. |
| 1193 | For this mode of operation, the key phrase here is "more convenient" and |
| 1194 | not "turning something unusable into usable". In other words, the intent |
| 1195 | is that if someone unsets the filter driver definition, or does not have |
| 1196 | the appropriate filter program, the project should still be usable.</p></div> |
| 1197 | <div class="paragraph"><p>Another use of the content filtering is to store the content that cannot |
| 1198 | 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] | 1199 | 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] | 1200 | usable form upon checkout (e.g. download the external content, or decrypt |
| 1201 | the encrypted content).</p></div> |
| 1202 | <div class="paragraph"><p>These two filters behave differently, and by default, a filter is taken as |
| 1203 | the former, massaging the contents into more convenient shape. A missing |
| 1204 | filter driver definition in the config, or a filter driver that exits with |
| 1205 | a non-zero status, is not an error but makes the filter a no-op passthru.</p></div> |
| 1206 | <div class="paragraph"><p>You can declare that a filter turns a content that by itself is unusable |
| 1207 | into a usable content by setting the filter.<driver>.required configuration |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1208 | variable to <code>true</code>.</p></div> |
Junio C Hamano | 4886c77 | 2017-11-27 03:33:28 | [diff] [blame] | 1209 | <div class="paragraph"><p>Note: Whenever the clean filter is changed, the repo should be renormalized: |
| 1210 | $ git add --renormalize .</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1211 | <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] | 1212 | attribute for paths.</p></div> |
| 1213 | <div class="listingblock"> |
| 1214 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1215 | <pre><code>*.c filter=indent</code></pre> |
Junio C Hamano | 6a548ef | 2009-12-17 00:16:20 | [diff] [blame] | 1216 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1217 | <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] | 1218 | configuration in your .git/config to specify a pair of commands to |
| 1219 | modify the contents of C programs when the source files are checked |
| 1220 | in ("clean" is run) and checked out (no change is made because the |
| 1221 | command is "cat").</p></div> |
| 1222 | <div class="listingblock"> |
| 1223 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1224 | <pre><code>[filter "indent"] |
Junio C Hamano | 6a548ef | 2009-12-17 00:16:20 | [diff] [blame] | 1225 | clean = indent |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1226 | smudge = cat</code></pre> |
Junio C Hamano | 6a548ef | 2009-12-17 00:16:20 | [diff] [blame] | 1227 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1228 | <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] | 1229 | run twice ("clean→clean" should be equivalent to "clean"), and |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1230 | 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] | 1231 | ("smudge→smudge→clean" should be equivalent to "clean"). See the |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 1232 | section on merging below.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1233 | <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] | 1234 | 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] | 1235 | 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] | 1236 | without modifying it.</p></div> |
Junio C Hamano | 90a5b7b | 2012-02-28 23:40:31 | [diff] [blame] | 1237 | <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] | 1238 | 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] | 1239 | <div class="listingblock"> |
| 1240 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1241 | <pre><code>[filter "crypt"] |
Junio C Hamano | 90a5b7b | 2012-02-28 23:40:31 | [diff] [blame] | 1242 | clean = openssl enc ... |
| 1243 | smudge = openssl enc -d ... |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1244 | required</code></pre> |
Junio C Hamano | 90a5b7b | 2012-02-28 23:40:31 | [diff] [blame] | 1245 | </div></div> |
Junio C Hamano | e0552e4 | 2011-01-06 00:34:47 | [diff] [blame] | 1246 | <div class="paragraph"><p>Sequence "%f" on the filter command line is replaced with the name of |
| 1247 | the file the filter is working on. A filter might use this in keyword |
| 1248 | substitution. For example:</p></div> |
| 1249 | <div class="listingblock"> |
| 1250 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1251 | <pre><code>[filter "p4"] |
Junio C Hamano | e0552e4 | 2011-01-06 00:34:47 | [diff] [blame] | 1252 | clean = git-p4-filter --clean %f |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1253 | smudge = git-p4-filter --smudge %f</code></pre> |
Junio C Hamano | e0552e4 | 2011-01-06 00:34:47 | [diff] [blame] | 1254 | </div></div> |
Junio C Hamano | e548d1b | 2016-08-08 22:26:49 | [diff] [blame] | 1255 | <div class="paragraph"><p>Note that "%f" is the name of the path that is being worked on. Depending |
| 1256 | on the version that is being filtered, the corresponding file on disk may |
| 1257 | not exist, or may have different contents. So, smudge and clean commands |
| 1258 | should not try to access the file on disk, but only act as filters on the |
| 1259 | content provided to them on standard input.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1260 | </div> |
| 1261 | <div class="sect3"> |
Junio C Hamano | f2f28b1 | 2016-10-31 21:41:58 | [diff] [blame] | 1262 | <h4 id="_long_running_filter_process">Long Running Filter Process</h4> |
| 1263 | <div class="paragraph"><p>If the filter command (a string value) is defined via |
| 1264 | <code>filter.<driver>.process</code> then Git can process all blobs with a |
| 1265 | single filter invocation for the entire life of a single Git |
Junio C Hamano | 640779d | 2018-02-14 01:29:14 | [diff] [blame] | 1266 | command. This is achieved by using the long-running process protocol |
| 1267 | (described in technical/long-running-process-protocol.txt).</p></div> |
| 1268 | <div class="paragraph"><p>When Git encounters the first file that needs to be cleaned or smudged, |
| 1269 | it starts the filter and performs the handshake. In the handshake, the |
| 1270 | welcome message sent by Git is "git-filter-client", only version 2 is |
Junio C Hamano | 8ef91f3 | 2019-12-01 22:58:27 | [diff] [blame] | 1271 | supported, and the supported capabilities are "clean", "smudge", and |
Junio C Hamano | 640779d | 2018-02-14 01:29:14 | [diff] [blame] | 1272 | "delay".</p></div> |
Junio C Hamano | f2f28b1 | 2016-10-31 21:41:58 | [diff] [blame] | 1273 | <div class="paragraph"><p>Afterwards Git sends a list of "key=value" pairs terminated with |
| 1274 | a flush packet. The list will contain at least the filter command |
| 1275 | (based on the supported capabilities) and the pathname of the file |
| 1276 | to filter relative to the repository root. Right after the flush packet |
| 1277 | Git sends the content split in zero or more pkt-line packets and a |
| 1278 | flush packet to terminate content. Please note, that the filter |
| 1279 | must not send any response before it received the content and the |
Junio C Hamano | 9e35abf | 2016-12-27 22:37:27 | [diff] [blame] | 1280 | final flush packet. Also note that the "value" of a "key=value" pair |
| 1281 | can contain the "=" character whereas the key would never contain |
| 1282 | that character.</p></div> |
Junio C Hamano | f2f28b1 | 2016-10-31 21:41:58 | [diff] [blame] | 1283 | <div class="listingblock"> |
| 1284 | <div class="content"> |
| 1285 | <pre><code>packet: git> command=smudge |
| 1286 | packet: git> pathname=path/testfile.dat |
| 1287 | packet: git> 0000 |
| 1288 | packet: git> CONTENT |
| 1289 | packet: git> 0000</code></pre> |
| 1290 | </div></div> |
| 1291 | <div class="paragraph"><p>The filter is expected to respond with a list of "key=value" pairs |
| 1292 | terminated with a flush packet. If the filter does not experience |
| 1293 | problems then the list must contain a "success" status. Right after |
| 1294 | these packets the filter is expected to send the content in zero |
| 1295 | or more pkt-line packets and a flush packet at the end. Finally, a |
| 1296 | second list of "key=value" pairs terminated with a flush packet |
| 1297 | is expected. The filter can change the status in the second list |
| 1298 | or keep the status as is with an empty list. Please note that the |
| 1299 | empty list must be terminated with a flush packet regardless.</p></div> |
| 1300 | <div class="listingblock"> |
| 1301 | <div class="content"> |
| 1302 | <pre><code>packet: git< status=success |
| 1303 | packet: git< 0000 |
| 1304 | packet: git< SMUDGED_CONTENT |
| 1305 | packet: git< 0000 |
| 1306 | packet: git< 0000 # empty list, keep "status=success" unchanged!</code></pre> |
| 1307 | </div></div> |
| 1308 | <div class="paragraph"><p>If the result content is empty then the filter is expected to respond |
| 1309 | with a "success" status and a flush packet to signal the empty content.</p></div> |
| 1310 | <div class="listingblock"> |
| 1311 | <div class="content"> |
| 1312 | <pre><code>packet: git< status=success |
| 1313 | packet: git< 0000 |
| 1314 | packet: git< 0000 # empty content! |
| 1315 | packet: git< 0000 # empty list, keep "status=success" unchanged!</code></pre> |
| 1316 | </div></div> |
| 1317 | <div class="paragraph"><p>In case the filter cannot or does not want to process the content, |
| 1318 | it is expected to respond with an "error" status.</p></div> |
| 1319 | <div class="listingblock"> |
| 1320 | <div class="content"> |
| 1321 | <pre><code>packet: git< status=error |
| 1322 | packet: git< 0000</code></pre> |
| 1323 | </div></div> |
| 1324 | <div class="paragraph"><p>If the filter experiences an error during processing, then it can |
| 1325 | send the status "error" after the content was (partially or |
| 1326 | completely) sent.</p></div> |
| 1327 | <div class="listingblock"> |
| 1328 | <div class="content"> |
| 1329 | <pre><code>packet: git< status=success |
| 1330 | packet: git< 0000 |
| 1331 | packet: git< HALF_WRITTEN_ERRONEOUS_CONTENT |
| 1332 | packet: git< 0000 |
| 1333 | packet: git< status=error |
| 1334 | packet: git< 0000</code></pre> |
| 1335 | </div></div> |
| 1336 | <div class="paragraph"><p>In case the filter cannot or does not want to process the content |
| 1337 | as well as any future content for the lifetime of the Git process, |
| 1338 | then it is expected to respond with an "abort" status at any point |
| 1339 | in the protocol.</p></div> |
| 1340 | <div class="listingblock"> |
| 1341 | <div class="content"> |
| 1342 | <pre><code>packet: git< status=abort |
| 1343 | packet: git< 0000</code></pre> |
| 1344 | </div></div> |
| 1345 | <div class="paragraph"><p>Git neither stops nor restarts the filter process in case the |
| 1346 | "error"/"abort" status is set. However, Git sets its exit code |
| 1347 | according to the <code>filter.<driver>.required</code> flag, mimicking the |
| 1348 | behavior of the <code>filter.<driver>.clean</code> / <code>filter.<driver>.smudge</code> |
| 1349 | mechanism.</p></div> |
| 1350 | <div class="paragraph"><p>If the filter dies during the communication or does not adhere to |
| 1351 | the protocol then Git will stop the filter process and restart it |
| 1352 | with the next file that needs to be processed. Depending on the |
| 1353 | <code>filter.<driver>.required</code> flag Git will interpret that as error.</p></div> |
Junio C Hamano | 4b2a6c1 | 2017-08-22 18:32:37 | [diff] [blame] | 1354 | </div> |
| 1355 | <div class="sect3"> |
| 1356 | <h4 id="_delay">Delay</h4> |
| 1357 | <div class="paragraph"><p>If the filter supports the "delay" capability, then Git can send the |
| 1358 | flag "can-delay" after the filter command and pathname. This flag |
| 1359 | denotes that the filter can delay filtering the current blob (e.g. to |
| 1360 | compensate network latencies) by responding with no content but with |
| 1361 | the status "delayed" and a flush packet.</p></div> |
| 1362 | <div class="listingblock"> |
| 1363 | <div class="content"> |
| 1364 | <pre><code>packet: git> command=smudge |
| 1365 | packet: git> pathname=path/testfile.dat |
| 1366 | packet: git> can-delay=1 |
| 1367 | packet: git> 0000 |
| 1368 | packet: git> CONTENT |
| 1369 | packet: git> 0000 |
| 1370 | packet: git< status=delayed |
| 1371 | packet: git< 0000</code></pre> |
| 1372 | </div></div> |
| 1373 | <div class="paragraph"><p>If the filter supports the "delay" capability then it must support the |
| 1374 | "list_available_blobs" command. If Git sends this command, then the |
| 1375 | filter is expected to return a list of pathnames representing blobs |
| 1376 | that have been delayed earlier and are now available. |
| 1377 | The list must be terminated with a flush packet followed |
| 1378 | by a "success" status that is also terminated with a flush packet. If |
| 1379 | no blobs for the delayed paths are available, yet, then the filter is |
| 1380 | expected to block the response until at least one blob becomes |
| 1381 | available. The filter can tell Git that it has no more delayed blobs |
| 1382 | by sending an empty list. As soon as the filter responds with an empty |
| 1383 | list, Git stops asking. All blobs that Git has not received at this |
| 1384 | point are considered missing and will result in an error.</p></div> |
| 1385 | <div class="listingblock"> |
| 1386 | <div class="content"> |
| 1387 | <pre><code>packet: git> command=list_available_blobs |
| 1388 | packet: git> 0000 |
| 1389 | packet: git< pathname=path/testfile.dat |
| 1390 | packet: git< pathname=path/otherfile.dat |
| 1391 | packet: git< 0000 |
| 1392 | packet: git< status=success |
| 1393 | packet: git< 0000</code></pre> |
| 1394 | </div></div> |
| 1395 | <div class="paragraph"><p>After Git received the pathnames, it will request the corresponding |
| 1396 | blobs again. These requests contain a pathname and an empty content |
| 1397 | section. The filter is expected to respond with the smudged content |
| 1398 | in the usual way as explained above.</p></div> |
| 1399 | <div class="listingblock"> |
| 1400 | <div class="content"> |
| 1401 | <pre><code>packet: git> command=smudge |
| 1402 | packet: git> pathname=path/testfile.dat |
| 1403 | packet: git> 0000 |
| 1404 | packet: git> 0000 # empty content! |
| 1405 | packet: git< status=success |
| 1406 | packet: git< 0000 |
| 1407 | packet: git< SMUDGED_CONTENT |
| 1408 | packet: git< 0000 |
| 1409 | packet: git< 0000 # empty list, keep "status=success" unchanged!</code></pre> |
| 1410 | </div></div> |
| 1411 | </div> |
| 1412 | <div class="sect3"> |
| 1413 | <h4 id="_example">Example</h4> |
Junio C Hamano | f2f28b1 | 2016-10-31 21:41:58 | [diff] [blame] | 1414 | <div class="paragraph"><p>A long running filter demo implementation can be found in |
| 1415 | <code>contrib/long-running-filter/example.pl</code> located in the Git |
| 1416 | core repository. If you develop your own long running filter |
| 1417 | process then the <code>GIT_TRACE_PACKET</code> environment variables can be |
| 1418 | very helpful for debugging (see <a href="git.html">git(1)</a>).</p></div> |
| 1419 | <div class="paragraph"><p>Please note that you cannot use an existing <code>filter.<driver>.clean</code> |
| 1420 | or <code>filter.<driver>.smudge</code> command with <code>filter.<driver>.process</code> |
| 1421 | because the former two use a different inter process communication |
| 1422 | protocol than the latter one.</p></div> |
| 1423 | </div> |
| 1424 | <div class="sect3"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1425 | <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] | 1426 | <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] | 1427 | with <code>filter</code> driver (if specified and corresponding driver |
| 1428 | defined), then the result is processed with <code>ident</code> (if |
| 1429 | specified), and then finally with <code>text</code> (again, if specified |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1430 | and applicable).</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1431 | <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] | 1432 | 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] | 1433 | </div> |
| 1434 | <div class="sect3"> |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 1435 | <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] | 1436 | <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] | 1437 | repository format for that file to change, such as adding a |
| 1438 | clean/smudge filter or text/eol/ident attributes, merging anything |
| 1439 | where the attribute is not in place would normally cause merge |
| 1440 | conflicts.</p></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1441 | <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] | 1442 | 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] | 1443 | resolving a three-way merge by setting the <code>merge.renormalize</code> |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 1444 | configuration variable. This prevents changes caused by check-in |
| 1445 | conversion from causing spurious merge conflicts when a converted file |
| 1446 | is merged with an unconverted file.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1447 | <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] | 1448 | even on files that are already smudged, this strategy will |
| 1449 | automatically resolve all filter-related conflicts. Filters that do |
| 1450 | not act in this way may cause additional merge conflicts that must be |
| 1451 | resolved manually.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1452 | </div> |
| 1453 | </div> |
| 1454 | <div class="sect2"> |
| 1455 | <h3 id="_generating_diff_text">Generating diff text</h3> |
| 1456 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1457 | <h4 id="_code_diff_code"><code>diff</code></h4> |
| 1458 | <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] | 1459 | 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] | 1460 | 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] | 1461 | 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] | 1462 | external command to generate the diff, or ask Git to convert binary |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1463 | files to a text format before generating the diff.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1464 | <div class="dlist"><dl> |
| 1465 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1466 | Set |
| 1467 | </dt> |
| 1468 | <dd> |
| 1469 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1470 | 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] | 1471 | as text, even when they contain byte values that |
| 1472 | normally never appear in text files, such as NUL. |
| 1473 | </p> |
| 1474 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1475 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1476 | Unset |
| 1477 | </dt> |
| 1478 | <dd> |
| 1479 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1480 | A path to which the <code>diff</code> attribute is unset will |
| 1481 | generate <code>Binary files differ</code> (or a binary patch, if |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1482 | binary patches are enabled). |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1483 | </p> |
| 1484 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1485 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1486 | Unspecified |
| 1487 | </dt> |
| 1488 | <dd> |
| 1489 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1490 | A path to which the <code>diff</code> attribute is unspecified |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1491 | first gets its contents inspected, and if it looks like |
Junio C Hamano | 8e61f1f | 2014-09-11 21:53:45 | [diff] [blame] | 1492 | text and is smaller than core.bigFileThreshold, it is treated |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1493 | as text. Otherwise it would generate <code>Binary files differ</code>. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1494 | </p> |
| 1495 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1496 | <dt class="hdlist1"> |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 1497 | String |
| 1498 | </dt> |
| 1499 | <dd> |
| 1500 | <p> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1501 | Diff is shown using the specified diff driver. Each driver may |
| 1502 | specify one or more options, as described in the following |
| 1503 | section. The options for the diff driver "foo" are defined |
| 1504 | by the configuration variables in the "diff.foo" section of the |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1505 | Git config file. |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 1506 | </p> |
| 1507 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1508 | </dl></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1509 | </div> |
| 1510 | <div class="sect3"> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1511 | <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] | 1512 | <div class="paragraph"><p>The definition of a diff driver is done in <code>gitconfig</code>, not |
| 1513 | <code>gitattributes</code> file, so strictly speaking this manual page is a |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1514 | wrong place to talk about it. However…</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1515 | <div class="paragraph"><p>To define an external diff driver <code>jcdiff</code>, add a section to your |
| 1516 | <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] | 1517 | <div class="listingblock"> |
| 1518 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1519 | <pre><code>[diff "jcdiff"] |
| 1520 | command = j-c-diff</code></pre> |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 1521 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1522 | <div class="paragraph"><p>When Git needs to show you a diff for the path with <code>diff</code> |
| 1523 | attribute set to <code>jcdiff</code>, it calls the command you specified |
| 1524 | with the above configuration, i.e. <code>j-c-diff</code>, with 7 |
| 1525 | parameters, just like <code>GIT_EXTERNAL_DIFF</code> program is called. |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1526 | See <a href="git.html">git(1)</a> for details.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1527 | </div> |
| 1528 | <div class="sect3"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1529 | <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] | 1530 | <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] | 1531 | is prefixed with a line of the form:</p></div> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1532 | <div class="literalblock"> |
| 1533 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1534 | <pre><code>@@ -k,l +n,m @@ TEXT</code></pre> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1535 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1536 | <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] | 1537 | that begins with an alphabet, an underscore or a dollar sign; this |
| 1538 | matches what GNU <em>diff -p</em> output uses. This default selection however |
| 1539 | is not suited for some contents, and you can use a customized pattern |
| 1540 | to make a selection.</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1541 | <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] | 1542 | for paths.</p></div> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1543 | <div class="listingblock"> |
| 1544 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1545 | <pre><code>*.tex diff=tex</code></pre> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1546 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1547 | <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] | 1548 | specify a regular expression that matches a line that you would |
Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 1549 | 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] | 1550 | <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] | 1551 | <div class="listingblock"> |
| 1552 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1553 | <pre><code>[diff "tex"] |
| 1554 | xfuncname = "^(\\\\(sub)*section\\{.*)$"</code></pre> |
Junio C Hamano | 2a8f6dc | 2007-07-09 08:48:38 | [diff] [blame] | 1555 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1556 | <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] | 1557 | configuration file parser, so you would need to double the |
| 1558 | backslashes; the pattern above picks a line that begins with a |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1559 | backslash, and zero or more occurrences of <code>sub</code> followed by |
| 1560 | <code>section</code> followed by open brace, to the end of line.</p></div> |
| 1561 | <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] | 1562 | is one of them, so you do not have to write the above in your |
| 1563 | configuration file (you still need to enable this with the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1564 | attribute mechanism, via <code>.gitattributes</code>). The following built in |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1565 | patterns are available:</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1566 | <div class="ulist"><ul> |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1567 | <li> |
| 1568 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1569 | <code>ada</code> suitable for source code in the Ada language. |
Junio C Hamano | 4f07aec | 2012-09-25 19:08:44 | [diff] [blame] | 1570 | </p> |
| 1571 | </li> |
| 1572 | <li> |
| 1573 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1574 | <code>bibtex</code> suitable for files with BibTeX coded references. |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1575 | </p> |
| 1576 | </li> |
| 1577 | <li> |
| 1578 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1579 | <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] | 1580 | </p> |
| 1581 | </li> |
| 1582 | <li> |
| 1583 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1584 | <code>csharp</code> suitable for source code in the C# language. |
Junio C Hamano | 53ba6d0 | 2010-08-22 07:25:12 | [diff] [blame] | 1585 | </p> |
| 1586 | </li> |
| 1587 | <li> |
| 1588 | <p> |
Junio C Hamano | fedb1b4 | 2016-06-20 21:23:40 | [diff] [blame] | 1589 | <code>css</code> suitable for cascading style sheets. |
| 1590 | </p> |
| 1591 | </li> |
| 1592 | <li> |
| 1593 | <p> |
Junio C Hamano | cb70539 | 2019-09-18 19:30:01 | [diff] [blame] | 1594 | <code>dts</code> suitable for devicetree (DTS) files. |
| 1595 | </p> |
| 1596 | </li> |
| 1597 | <li> |
| 1598 | <p> |
Junio C Hamano | 8ef91f3 | 2019-12-01 22:58:27 | [diff] [blame] | 1599 | <code>elixir</code> suitable for source code in the Elixir language. |
| 1600 | </p> |
| 1601 | </li> |
| 1602 | <li> |
| 1603 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1604 | <code>fortran</code> suitable for source code in the Fortran language. |
Junio C Hamano | 3b4609d | 2010-09-30 00:04:34 | [diff] [blame] | 1605 | </p> |
| 1606 | </li> |
| 1607 | <li> |
| 1608 | <p> |
Junio C Hamano | d7ed404 | 2015-08-03 19:43:00 | [diff] [blame] | 1609 | <code>fountain</code> suitable for Fountain documents. |
| 1610 | </p> |
| 1611 | </li> |
| 1612 | <li> |
| 1613 | <p> |
Junio C Hamano | a25ccc4 | 2018-03-08 21:36:14 | [diff] [blame] | 1614 | <code>golang</code> suitable for source code in the Go language. |
| 1615 | </p> |
| 1616 | </li> |
| 1617 | <li> |
| 1618 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1619 | <code>html</code> suitable for HTML/XHTML documents. |
Junio C Hamano | f24b806 | 2008-09-09 01:34:39 | [diff] [blame] | 1620 | </p> |
| 1621 | </li> |
| 1622 | <li> |
| 1623 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1624 | <code>java</code> suitable for source code in the Java language. |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1625 | </p> |
| 1626 | </li> |
| 1627 | <li> |
| 1628 | <p> |
Junio C Hamano | 73c6486 | 2019-06-18 03:24:20 | [diff] [blame] | 1629 | <code>matlab</code> suitable for source code in the MATLAB and Octave languages. |
Junio C Hamano | 92887a3 | 2011-12-07 00:26:29 | [diff] [blame] | 1630 | </p> |
| 1631 | </li> |
| 1632 | <li> |
| 1633 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1634 | <code>objc</code> suitable for source code in the Objective-C language. |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 1635 | </p> |
| 1636 | </li> |
| 1637 | <li> |
| 1638 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1639 | <code>pascal</code> suitable for source code in the Pascal/Delphi language. |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1640 | </p> |
| 1641 | </li> |
| 1642 | <li> |
| 1643 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1644 | <code>perl</code> suitable for source code in the Perl language. |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1645 | </p> |
| 1646 | </li> |
| 1647 | <li> |
| 1648 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1649 | <code>php</code> suitable for source code in the PHP language. |
Junio C Hamano | f24b806 | 2008-09-09 01:34:39 | [diff] [blame] | 1650 | </p> |
| 1651 | </li> |
| 1652 | <li> |
| 1653 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1654 | <code>python</code> suitable for source code in the Python language. |
Junio C Hamano | 3f2f6e5 | 2008-08-21 10:34:22 | [diff] [blame] | 1655 | </p> |
| 1656 | </li> |
| 1657 | <li> |
| 1658 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1659 | <code>ruby</code> suitable for source code in the Ruby language. |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1660 | </p> |
| 1661 | </li> |
| 1662 | <li> |
| 1663 | <p> |
Junio C Hamano | d0a9940 | 2019-06-21 18:58:41 | [diff] [blame] | 1664 | <code>rust</code> suitable for source code in the Rust language. |
| 1665 | </p> |
| 1666 | </li> |
| 1667 | <li> |
| 1668 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1669 | <code>tex</code> suitable for source code for LaTeX documents. |
Junio C Hamano | a76cb0d | 2008-08-13 20:04:10 | [diff] [blame] | 1670 | </p> |
| 1671 | </li> |
| 1672 | </ul></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1673 | </div> |
| 1674 | <div class="sect3"> |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 1675 | <h4 id="_customizing_word_diff">Customizing word diff</h4> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1676 | <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] | 1677 | split words in a line, by specifying an appropriate regular expression |
| 1678 | in the "diff.*.wordRegex" configuration variable. For example, in TeX |
| 1679 | a backslash followed by a sequence of letters forms a command, but |
| 1680 | several such commands can be run together without intervening |
Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 1681 | whitespace. To separate them, use a regular expression in your |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1682 | <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] | 1683 | <div class="listingblock"> |
| 1684 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1685 | <pre><code>[diff "tex"] |
| 1686 | wordRegex = "\\\\[a-zA-Z]+|[{}]|\\\\.|[^\\{}[:space:]]+"</code></pre> |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 1687 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1688 | <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] | 1689 | previous section.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1690 | </div> |
| 1691 | <div class="sect3"> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1692 | <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] | 1693 | <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] | 1694 | version of some binary files. For example, a word processor |
| 1695 | document can be converted to an ASCII text representation, and |
| 1696 | the diff of the text shown. Even though this conversion loses |
| 1697 | some information, the resulting diff is useful for human |
| 1698 | viewing (but cannot be applied directly).</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1699 | <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] | 1700 | performing such a conversion. The program should take a single |
| 1701 | argument, the name of a file to convert, and produce the |
| 1702 | resulting text on stdout.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1703 | <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] | 1704 | file instead of the binary information (assuming you have the |
Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 1705 | exif tool installed), add the following section to your |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1706 | <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] | 1707 | <div class="listingblock"> |
| 1708 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1709 | <pre><code>[diff "jpg"] |
| 1710 | textconv = exif</code></pre> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1711 | </div></div> |
| 1712 | <div class="admonitionblock"> |
| 1713 | <table><tr> |
| 1714 | <td class="icon"> |
| 1715 | <div class="title">Note</div> |
| 1716 | </td> |
| 1717 | <td class="content">The text conversion is generally a one-way conversion; |
| 1718 | in this example, we lose the actual image contents and focus |
| 1719 | just on the text data. This means that diffs generated by |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1720 | textconv are <em>not</em> suitable for applying. For this reason, |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1721 | only <code>git diff</code> and the <code>git log</code> family of commands (i.e., |
| 1722 | log, whatchanged, show) will perform text conversion. <code>git |
| 1723 | format-patch</code> will never generate this output. If you want to |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1724 | send somebody a text-converted diff of a binary file (e.g., |
| 1725 | because it quickly conveys the changes you have made), you |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1726 | should generate it separately and send it as a comment <em>in |
| 1727 | addition to</em> the usual binary diff that you might send.</td> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 1728 | </tr></table> |
| 1729 | </div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1730 | <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] | 1731 | 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] | 1732 | to cache the output and use it in future diffs. To enable |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1733 | caching, set the "cachetextconv" variable in your diff driver’s |
Junio C Hamano | cb39aea | 2010-05-09 07:24:48 | [diff] [blame] | 1734 | config. For example:</p></div> |
| 1735 | <div class="listingblock"> |
| 1736 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1737 | <pre><code>[diff "jpg"] |
Junio C Hamano | cb39aea | 2010-05-09 07:24:48 | [diff] [blame] | 1738 | textconv = exif |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1739 | cachetextconv = true</code></pre> |
Junio C Hamano | cb39aea | 2010-05-09 07:24:48 | [diff] [blame] | 1740 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1741 | <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] | 1742 | indefinitely. If you change the textconv config variable for a |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1743 | diff driver, Git will automatically invalidate the cache entries |
Junio C Hamano | cb39aea | 2010-05-09 07:24:48 | [diff] [blame] | 1744 | and re-run the textconv filter. If you want to invalidate the |
| 1745 | cache manually (e.g., because your version of "exif" was updated |
| 1746 | and now produces better output), you can remove the cache |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1747 | 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] | 1748 | "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] | 1749 | </div> |
| 1750 | <div class="sect3"> |
Junio C Hamano | f93530e | 2011-05-25 23:59:59 | [diff] [blame] | 1751 | <h4 id="_choosing_textconv_versus_external_diff">Choosing textconv versus external diff</h4> |
| 1752 | <div class="paragraph"><p>If you want to show differences between binary or specially-formatted |
| 1753 | blobs in your repository, you can choose to use either an external diff |
| 1754 | command, or to use textconv to convert them to a diff-able text format. |
| 1755 | Which method you choose depends on your exact situation.</p></div> |
| 1756 | <div class="paragraph"><p>The advantage of using an external diff command is flexibility. You are |
| 1757 | not bound to find line-oriented changes, nor is it necessary for the |
| 1758 | output to resemble unified diff. You are free to locate and report |
| 1759 | changes in the most appropriate way for your data format.</p></div> |
| 1760 | <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] | 1761 | transformation of the data into a line-oriented text format, and Git |
Junio C Hamano | f93530e | 2011-05-25 23:59:59 | [diff] [blame] | 1762 | uses its regular diff tools to generate the output. There are several |
| 1763 | advantages to choosing this method:</p></div> |
| 1764 | <div class="olist arabic"><ol class="arabic"> |
| 1765 | <li> |
| 1766 | <p> |
| 1767 | Ease of use. It is often much simpler to write a binary to text |
| 1768 | transformation than it is to perform your own diff. In many cases, |
| 1769 | existing programs can be used as textconv filters (e.g., exif, |
| 1770 | odt2txt). |
| 1771 | </p> |
| 1772 | </li> |
| 1773 | <li> |
| 1774 | <p> |
| 1775 | Git diff features. By performing only the transformation step |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1776 | yourself, you can still utilize many of Git’s diff features, |
Junio C Hamano | f93530e | 2011-05-25 23:59:59 | [diff] [blame] | 1777 | including colorization, word-diff, and combined diffs for merges. |
| 1778 | </p> |
| 1779 | </li> |
| 1780 | <li> |
| 1781 | <p> |
| 1782 | Caching. Textconv caching can speed up repeated diffs, such as those |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1783 | you might trigger by running <code>git log -p</code>. |
Junio C Hamano | f93530e | 2011-05-25 23:59:59 | [diff] [blame] | 1784 | </p> |
| 1785 | </li> |
| 1786 | </ol></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1787 | </div> |
| 1788 | <div class="sect3"> |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1789 | <h4 id="_marking_files_as_binary">Marking files as binary</h4> |
| 1790 | <div class="paragraph"><p>Git usually guesses correctly whether a blob contains text or binary |
| 1791 | data by examining the beginning of the contents. However, sometimes you |
| 1792 | may want to override its decision, either because a blob contains binary |
| 1793 | data later in the file, or because the content, while technically |
| 1794 | composed of text characters, is opaque to a human reader. For example, |
Junio C Hamano | fb5ffde | 2014-11-04 22:38:56 | [diff] [blame] | 1795 | many postscript files contain only ASCII characters, but produce noisy |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1796 | and meaningless diffs.</p></div> |
| 1797 | <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] | 1798 | attribute in the <code>.gitattributes</code> file:</p></div> |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1799 | <div class="listingblock"> |
| 1800 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1801 | <pre><code>*.ps -diff</code></pre> |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1802 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1803 | <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] | 1804 | patch, if binary patches are enabled) instead of a regular diff.</p></div> |
| 1805 | <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] | 1806 | 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] | 1807 | an ASCII representation for human viewing, but otherwise treat them as |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1808 | binary files. You cannot specify both <code>-diff</code> and <code>diff=ps</code> attributes. |
| 1809 | 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] | 1810 | <div class="listingblock"> |
| 1811 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1812 | <pre><code>[diff "ps"] |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1813 | textconv = ps2ascii |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1814 | binary = true</code></pre> |
Junio C Hamano | 9b6fafe | 2011-01-14 00:43:22 | [diff] [blame] | 1815 | </div></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1816 | </div> |
| 1817 | </div> |
| 1818 | <div class="sect2"> |
| 1819 | <h3 id="_performing_a_three_way_merge">Performing a three-way merge</h3> |
| 1820 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1821 | <h4 id="_code_merge_code"><code>merge</code></h4> |
| 1822 | <div class="paragraph"><p>The attribute <code>merge</code> affects how three versions of a file are |
| 1823 | merged when a file-level merge is necessary during <code>git merge</code>, |
| 1824 | 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] | 1825 | <div class="dlist"><dl> |
| 1826 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1827 | Set |
| 1828 | </dt> |
| 1829 | <dd> |
| 1830 | <p> |
| 1831 | Built-in 3-way merge driver is used to merge the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1832 | 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] | 1833 | suite. This is suitable for ordinary text files. |
| 1834 | </p> |
| 1835 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1836 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1837 | Unset |
| 1838 | </dt> |
| 1839 | <dd> |
| 1840 | <p> |
| 1841 | Take the version from the current branch as the |
| 1842 | tentative merge result, and declare that the merge has |
Junio C Hamano | fa28cb1 | 2011-03-19 01:35:35 | [diff] [blame] | 1843 | conflicts. This is suitable for binary files that do |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1844 | not have a well-defined merge semantics. |
| 1845 | </p> |
| 1846 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1847 | <dt class="hdlist1"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1848 | Unspecified |
| 1849 | </dt> |
| 1850 | <dd> |
| 1851 | <p> |
| 1852 | By default, this uses the same built-in 3-way merge |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1853 | driver as is the case when the <code>merge</code> attribute is set. |
| 1854 | However, the <code>merge.default</code> configuration variable can name |
Junio C Hamano | fa28cb1 | 2011-03-19 01:35:35 | [diff] [blame] | 1855 | different merge driver to be used with paths for which the |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1856 | <code>merge</code> attribute is unspecified. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1857 | </p> |
| 1858 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1859 | <dt class="hdlist1"> |
Junio C Hamano | 9db95ca | 2007-04-23 07:27:05 | [diff] [blame] | 1860 | String |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1861 | </dt> |
| 1862 | <dd> |
| 1863 | <p> |
| 1864 | 3-way merge is performed using the specified custom |
| 1865 | merge driver. The built-in 3-way merge driver can be |
| 1866 | explicitly specified by asking for "text" driver; the |
| 1867 | built-in "take the current branch" driver can be |
Junio C Hamano | 22572e7 | 2007-04-25 05:59:25 | [diff] [blame] | 1868 | requested with "binary". |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1869 | </p> |
| 1870 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1871 | </dl></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1872 | </div> |
| 1873 | <div class="sect3"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1874 | <h4 id="_built_in_merge_drivers">Built-in merge drivers</h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1875 | <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] | 1876 | can be asked for via the <code>merge</code> attribute.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1877 | <div class="dlist"><dl> |
| 1878 | <dt class="hdlist1"> |
Junio C Hamano | f556fc2 | 2007-12-23 08:16:38 | [diff] [blame] | 1879 | text |
| 1880 | </dt> |
| 1881 | <dd> |
| 1882 | <p> |
| 1883 | Usual 3-way file level merge for text files. Conflicted |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1884 | regions are marked with conflict markers <code><<<<<<<</code>, |
| 1885 | <code>=======</code> and <code>>>>>>>></code>. The version from your branch |
| 1886 | appears before the <code>=======</code> marker, and the version |
| 1887 | from the merged branch appears after the <code>=======</code> |
Junio C Hamano | f556fc2 | 2007-12-23 08:16:38 | [diff] [blame] | 1888 | marker. |
| 1889 | </p> |
| 1890 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1891 | <dt class="hdlist1"> |
Junio C Hamano | f556fc2 | 2007-12-23 08:16:38 | [diff] [blame] | 1892 | binary |
| 1893 | </dt> |
| 1894 | <dd> |
| 1895 | <p> |
| 1896 | Keep the version from your branch in the work tree, but |
| 1897 | leave the path in the conflicted state for the user to |
| 1898 | sort out. |
| 1899 | </p> |
| 1900 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1901 | <dt class="hdlist1"> |
Junio C Hamano | f556fc2 | 2007-12-23 08:16:38 | [diff] [blame] | 1902 | union |
| 1903 | </dt> |
| 1904 | <dd> |
| 1905 | <p> |
| 1906 | Run 3-way file level merge for text files, but take |
| 1907 | lines from both versions, instead of leaving conflict |
| 1908 | markers. This tends to leave the added lines in the |
| 1909 | resulting file in random order and the user should |
| 1910 | verify the result. Do not use this if you do not |
| 1911 | understand the implications. |
| 1912 | </p> |
| 1913 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1914 | </dl></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1915 | </div> |
| 1916 | <div class="sect3"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1917 | <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] | 1918 | <div class="paragraph"><p>The definition of a merge driver is done in the <code>.git/config</code> |
| 1919 | file, not in the <code>gitattributes</code> file, so strictly speaking this |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1920 | 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] | 1921 | <div class="paragraph"><p>To define a custom merge driver <code>filfre</code>, add a section to your |
| 1922 | <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] | 1923 | <div class="listingblock"> |
| 1924 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1925 | <pre><code>[merge "filfre"] |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1926 | name = feel-free merge driver |
Junio C Hamano | df5384b | 2015-06-24 21:12:12 | [diff] [blame] | 1927 | driver = filfre %O %A %B %L %P |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1928 | recursive = binary</code></pre> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 1929 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1930 | <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] | 1931 | name.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1932 | <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] | 1933 | command to run to merge ancestor’s version (<code>%O</code>), current |
| 1934 | 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] | 1935 | three tokens are replaced with the names of temporary files that |
| 1936 | hold the contents of these versions when the command line is |
Junio C Hamano | 86660db | 2010-02-24 01:12:54 | [diff] [blame] | 1937 | built. Additionally, %L will be replaced with the conflict marker |
| 1938 | size (see below).</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1939 | <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] | 1940 | 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] | 1941 | 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] | 1942 | were conflicts.</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1943 | <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] | 1944 | driver to use when the merge driver is called for an internal |
| 1945 | merge between common ancestors, when there are more than one. |
| 1946 | When left unspecified, the driver itself is used for both |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1947 | internal merge and the final merge.</p></div> |
Junio C Hamano | df5384b | 2015-06-24 21:12:12 | [diff] [blame] | 1948 | <div class="paragraph"><p>The merge driver can learn the pathname in which the merged result |
| 1949 | will be stored via placeholder <code>%P</code>.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1950 | </div> |
| 1951 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1952 | <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] | 1953 | <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] | 1954 | the work tree file during a conflicted merge. Only setting to |
| 1955 | the value to a positive integer has any meaningful effect.</p></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1956 | <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] | 1957 | machinery to leave much longer (instead of the usual 7-character-long) |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1958 | conflict markers when merging the file <code>Documentation/git-merge.txt</code> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1959 | results in a conflict.</p></div> |
| 1960 | <div class="listingblock"> |
| 1961 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1962 | <pre><code>Documentation/git-merge.txt conflict-marker-size=32</code></pre> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1963 | </div></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1964 | </div> |
| 1965 | </div> |
| 1966 | <div class="sect2"> |
| 1967 | <h3 id="_checking_whitespace_errors">Checking whitespace errors</h3> |
| 1968 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1969 | <h4 id="_code_whitespace_code"><code>whitespace</code></h4> |
| 1970 | <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] | 1971 | <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] | 1972 | 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] | 1973 | control per path.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1974 | <div class="dlist"><dl> |
| 1975 | <dt class="hdlist1"> |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1976 | Set |
| 1977 | </dt> |
| 1978 | <dd> |
| 1979 | <p> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1980 | Notice all types of potential whitespace errors known to Git. |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1981 | 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] | 1982 | configuration variable. |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1983 | </p> |
| 1984 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1985 | <dt class="hdlist1"> |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1986 | Unset |
| 1987 | </dt> |
| 1988 | <dd> |
| 1989 | <p> |
| 1990 | Do not notice anything as error. |
| 1991 | </p> |
| 1992 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 1993 | <dt class="hdlist1"> |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1994 | Unspecified |
| 1995 | </dt> |
| 1996 | <dd> |
| 1997 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1998 | Use the value of the <code>core.whitespace</code> configuration variable to |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 1999 | decide what to notice as error. |
| 2000 | </p> |
| 2001 | </dd> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 2002 | <dt class="hdlist1"> |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 2003 | String |
| 2004 | </dt> |
| 2005 | <dd> |
| 2006 | <p> |
| 2007 | Specify a comma separate list of common whitespace problems to |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2008 | notice in the same format as the <code>core.whitespace</code> configuration |
Junio C Hamano | 942b35e | 2007-12-09 10:19:33 | [diff] [blame] | 2009 | variable. |
| 2010 | </p> |
| 2011 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 2012 | </dl></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 2013 | </div> |
| 2014 | </div> |
| 2015 | <div class="sect2"> |
| 2016 | <h3 id="_creating_an_archive">Creating an archive</h3> |
| 2017 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2018 | <h4 id="_code_export_ignore_code"><code>export-ignore</code></h4> |
| 2019 | <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] | 2020 | archive files.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 2021 | </div> |
| 2022 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2023 | <h4 id="_code_export_subst_code"><code>export-subst</code></h4> |
| 2024 | <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] | 2025 | several placeholders when adding this file to an archive. The |
| 2026 | expansion depends on the availability of a commit ID, i.e., if |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 2027 | <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] | 2028 | tag then no replacement will be done. The placeholders are the same |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2029 | as those for the option <code>--pretty=format:</code> of <a href="git-log.html">git-log(1)</a>, |
| 2030 | except that they need to be wrapped like this: <code>$Format:PLACEHOLDERS$</code> |
| 2031 | 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] | 2032 | commit hash.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 2033 | </div> |
| 2034 | </div> |
| 2035 | <div class="sect2"> |
| 2036 | <h3 id="_packing_objects">Packing objects</h3> |
| 2037 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2038 | <h4 id="_code_delta_code"><code>delta</code></h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 2039 | <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] | 2040 | attribute <code>delta</code> set to false.</p></div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 2041 | </div> |
| 2042 | </div> |
| 2043 | <div class="sect2"> |
| 2044 | <h3 id="_viewing_files_in_gui_tools">Viewing files in GUI tools</h3> |
| 2045 | <div class="sect3"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2046 | <h4 id="_code_encoding_code"><code>encoding</code></h4> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 2047 | <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] | 2048 | 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] | 2049 | display the contents of the relevant file. Note that due to performance |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 2050 | 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] | 2051 | manually enable per-file encodings in its options.</p></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 2052 | <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] | 2053 | <code>gui.encoding</code> configuration variable is used instead |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 2054 | (See <a href="git-config.html">git-config(1)</a>).</p></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2055 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 2056 | </div> |
| 2057 | </div> |
| 2058 | </div> |
| 2059 | <div class="sect1"> |
Junio C Hamano | 86d8436 | 2011-08-04 00:21:51 | [diff] [blame] | 2060 | <h2 id="_using_macro_attributes">USING MACRO ATTRIBUTES</h2> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 2061 | <div class="sectionbody"> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 2062 | <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] | 2063 | produced for, any binary file you track. You would need to specify e.g.</p></div> |
| 2064 | <div class="listingblock"> |
| 2065 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2066 | <pre><code>*.jpg -text -diff</code></pre> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 2067 | </div></div> |
Junio C Hamano | eef01fe | 2010-12-13 08:31:58 | [diff] [blame] | 2068 | <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] | 2069 | macro attributes, you can define an attribute that, when set, also |
| 2070 | 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] | 2071 | system knows a built-in macro attribute, <code>binary</code>:</p></div> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 2072 | <div class="listingblock"> |
| 2073 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2074 | <pre><code>*.jpg binary</code></pre> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 2075 | </div></div> |
Junio C Hamano | 86d8436 | 2011-08-04 00:21:51 | [diff] [blame] | 2076 | <div class="paragraph"><p>Setting the "binary" attribute also unsets the "text" and "diff" |
| 2077 | attributes as above. Note that macro attributes can only be "Set", |
| 2078 | though setting one might have the effect of setting or unsetting other |
| 2079 | attributes or even returning other attributes to the "Unspecified" |
| 2080 | state.</p></div> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 2081 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 2082 | </div> |
| 2083 | <div class="sect1"> |
Junio C Hamano | 86d8436 | 2011-08-04 00:21:51 | [diff] [blame] | 2084 | <h2 id="_defining_macro_attributes">DEFINING MACRO ATTRIBUTES</h2> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 2085 | <div class="sectionbody"> |
Junio C Hamano | c5bd79e | 2014-01-27 21:31:26 | [diff] [blame] | 2086 | <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] | 2087 | 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] | 2088 | top level of the working tree, or the global or system-wide |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2089 | gitattributes files), not in <code>.gitattributes</code> files in working tree |
Junio C Hamano | c5bd79e | 2014-01-27 21:31:26 | [diff] [blame] | 2090 | subdirectories. The built-in macro attribute "binary" is equivalent |
| 2091 | to:</p></div> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 2092 | <div class="listingblock"> |
| 2093 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2094 | <pre><code>[attr]binary -diff -merge -text</code></pre> |
Junio C Hamano | fcb740a | 2008-08-31 06:32:05 | [diff] [blame] | 2095 | </div></div> |
| 2096 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 2097 | </div> |
| 2098 | <div class="sect1"> |
Junio C Hamano | b9d9d90 | 2018-05-23 07:07:42 | [diff] [blame] | 2099 | <h2 id="_examples">EXAMPLES</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2100 | <div class="sectionbody"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2101 | <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] | 2102 | <div class="listingblock"> |
| 2103 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2104 | <pre><code>(in $GIT_DIR/info/attributes) |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2105 | |
| 2106 | a* foo !bar -baz |
| 2107 | |
| 2108 | (in .gitattributes) |
| 2109 | abc foo bar baz |
| 2110 | |
| 2111 | (in t/.gitattributes) |
| 2112 | ab* merge=filfre |
| 2113 | abc -foo -bar |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2114 | *.c frotz</code></pre> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2115 | </div></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2116 | <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] | 2117 | <div class="olist arabic"><ol class="arabic"> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2118 | <li> |
| 2119 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2120 | By examining <code>t/.gitattributes</code> (which is in the same |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 2121 | directory as the path in question), Git finds that the first |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2122 | line matches. <code>merge</code> attribute is set. It also finds that |
| 2123 | 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] | 2124 | are unset. |
| 2125 | </p> |
| 2126 | </li> |
| 2127 | <li> |
| 2128 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2129 | Then it examines <code>.gitattributes</code> (which is in the parent |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2130 | directory), and finds that the first line matches, but |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2131 | <code>t/.gitattributes</code> file already decided how <code>merge</code>, <code>foo</code> |
| 2132 | and <code>bar</code> attributes should be given to this path, so it |
| 2133 | 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] | 2134 | </p> |
| 2135 | </li> |
| 2136 | <li> |
| 2137 | <p> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2138 | Finally it examines <code>$GIT_DIR/info/attributes</code>. This file |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2139 | is used to override the in-tree settings. The first line is |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2140 | a match, and <code>foo</code> is set, <code>bar</code> is reverted to unspecified |
| 2141 | state, and <code>baz</code> is unset. |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2142 | </p> |
| 2143 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 2144 | </ol></div> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2145 | <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] | 2146 | <div class="listingblock"> |
| 2147 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2148 | <pre><code>foo set to true |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2149 | bar unspecified |
| 2150 | baz set to false |
| 2151 | merge set to string value "filfre" |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 2152 | frotz unspecified</code></pre> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2153 | </div></div> |
| 2154 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 2155 | </div> |
| 2156 | <div class="sect1"> |
Junio C Hamano | f727901 | 2011-08-18 06:13:13 | [diff] [blame] | 2157 | <h2 id="_see_also">SEE ALSO</h2> |
| 2158 | <div class="sectionbody"> |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 2159 | <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] | 2160 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 2161 | </div> |
| 2162 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 2163 | <h2 id="_git">GIT</h2> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2164 | <div class="sectionbody"> |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 2165 | <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] | 2166 | </div> |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 2167 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 2168 | </div> |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 2169 | <div id="footnotes"><hr /></div> |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2170 | <div id="footer"> |
| 2171 | <div id="footer-text"> |
Junio C Hamano | 2ef0ba3 | 2018-01-26 23:13:53 | [diff] [blame] | 2172 | Last updated |
Junio C Hamano | 7a46cd6 | 2020-03-15 21:57:10 | [diff] [blame] | 2173 | 2020-03-10 08:03:13 PDT |
Junio C Hamano | e90436a | 2007-04-22 07:22:13 | [diff] [blame] | 2174 | </div> |
| 2175 | </div> |
| 2176 | </body> |
| 2177 | </html> |