blob: 469390da0223d4e03105bcc2eab06dc115d9faad [file] [log] [blame]
Junio C Hamanob33fb4f2006-04-18 21:30:511<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamanoba4b9282008-07-06 05:20:316<meta name="generator" content="AsciiDoc 8.2.5" />
Junio C Hamanob33fb4f2006-04-18 21:30:517<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
Junio C Hamanoba4b9282008-07-06 05:20:3119a {
20 color: blue;
21 text-decoration: underline;
22}
23a:visited {
24 color: fuchsia;
25}
Junio C Hamanob33fb4f2006-04-18 21:30:5126
27em {
28 font-style: italic;
29}
30
31strong {
32 font-weight: bold;
33}
34
35tt {
36 color: navy;
37}
38
39h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
45}
46
Junio C Hamanoba4b9282008-07-06 05:20:3147h1, h2, h3 {
Junio C Hamanob33fb4f2006-04-18 21:30:5148 border-bottom: 2px solid silver;
49}
50h2 {
Junio C Hamanob33fb4f2006-04-18 21:30:5151 padding-top: 0.5em;
52}
Junio C Hamanoba4b9282008-07-06 05:20:3153h3 {
54 float: left;
55}
56h3 + * {
57 clear: left;
58}
Junio C Hamanob33fb4f2006-04-18 21:30:5159
60div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
63}
64
65hr {
66 border: 1px solid silver;
67}
68
69p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
72}
73
74pre {
75 padding: 0;
76 margin: 0;
77}
78
79span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3183 font-size: 1.1em;
Junio C Hamanob33fb4f2006-04-18 21:30:5184}
85span#email {
86}
87span#revision {
88 font-family: sans-serif;
89}
90
91div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
97}
98div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
101}
102div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
105}
106
107div#preamble,
108div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
114}
115div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
118}
119
120div.content { /* Block element content. */
121 padding: 0;
122}
123
124/* Block element titles. */
125div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
131}
132div.title + * {
133 margin-top: 0;
134}
135
136td div.title:first-child {
137 margin-top: 0.0em;
138}
139div.content div.title:first-child {
140 margin-top: 0.0em;
141}
142div.content + div.title {
143 margin-top: 0.0em;
144}
145
146div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
150}
151
Junio C Hamanoba4b9282008-07-06 05:20:31152div.listingblock {
153 margin-right: 0%;
154}
Junio C Hamanob33fb4f2006-04-18 21:30:51155div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
159}
160
161div.quoteblock > div.content {
162 padding-left: 2.0em;
163}
Junio C Hamanoba4b9282008-07-06 05:20:31164
165div.attribution {
Junio C Hamanob33fb4f2006-04-18 21:30:51166 text-align: right;
167}
Junio C Hamanoba4b9282008-07-06 05:20:31168div.verseblock + div.attribution {
169 text-align: left;
170}
Junio C Hamanob33fb4f2006-04-18 21:30:51171
172div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
179}
180div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
183}
184
185div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
188}
189
190div.verseblock div.content {
191 white-space: pre;
192}
193
194div.imageblock div.content { padding-left: 0; }
195div.imageblock img { border: 1px solid silver; }
196span.image img { border-style: none; }
197
198dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
201}
202dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
206}
207dd > *:first-child {
208 margin-top: 0;
209}
210
211ul, ol {
212 list-style-position: outside;
213}
Junio C Hamanoba4b9282008-07-06 05:20:31214div.olist2 ol {
Junio C Hamanob33fb4f2006-04-18 21:30:51215 list-style-type: lower-alpha;
216}
217
218div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31219 border: 3px solid #527bbd;
Junio C Hamanob33fb4f2006-04-18 21:30:51220}
221thead {
222 font-family: sans-serif;
223 font-weight: bold;
224}
225tfoot {
226 font-weight: bold;
227}
228
229div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
232}
Junio C Hamanoba4b9282008-07-06 05:20:31233div.hlist td {
234 padding-bottom: 5px;
235}
Junio C Hamanob33fb4f2006-04-18 21:30:51236td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
240}
241td.hlist2 {
242 vertical-align: top;
243}
244
245@media print {
246 div#footer-badges { display: none; }
247}
Junio C Hamanoba4b9282008-07-06 05:20:31248
249div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
256}
257
258div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
261}
262div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
265}
266div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
269}
270div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
273}
274include1::./stylesheets/xhtml11-manpage.css[]
Junio C Hamanob33fb4f2006-04-18 21:30:51275/* Workarounds for IE6's broken and incomplete CSS2. */
276
277div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
281}
282div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
287}
288
289div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
293}
294
295div.quoteblock-content {
296 padding-left: 2.0em;
297}
298
299div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
302}
Junio C Hamanoba4b9282008-07-06 05:20:31303
304/* IE6 sets dynamically generated links as visited. */
305div#toc a:visited { color: blue; }
Junio C Hamanob33fb4f2006-04-18 21:30:51306</style>
307<title>git-blame(1)</title>
308</head>
309<body>
310<div id="header">
311<h1>
312git-blame(1) Manual Page
313</h1>
314<h2>NAME</h2>
315<div class="sectionbody">
316<p>git-blame -
Junio C Hamano6b2cee12006-08-26 08:43:31317 Show what revision and author last modified each line of a file
Junio C Hamanob33fb4f2006-04-18 21:30:51318</p>
319</div>
320</div>
321<h2>SYNOPSIS</h2>
322<div class="sectionbody">
Junio C Hamanoe1aa7472006-11-09 07:37:50323<div class="verseblock">
Junio C Hamanofce7c7e2008-07-02 03:06:38324<div class="content"><em>git blame</em> [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]
Junio C Hamano0e3cb532007-04-17 08:28:11325 [-S &lt;revs-file&gt;] [-M] [-C] [-C] [--since=&lt;date&gt;]
Junio C Hamanoa6455f62009-02-20 08:33:08326 [&lt;rev&gt; | --contents &lt;file&gt; | --reverse &lt;rev&gt;] [--] &lt;file&gt;</div></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51327</div>
Junio C Hamanoba4b9282008-07-06 05:20:31328<h2 id="_description">DESCRIPTION</h2>
Junio C Hamanob33fb4f2006-04-18 21:30:51329<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31330<div class="para"><p>Annotates each line in the given file with information from the revision which
331last modified the line. Optionally, start annotating from the given revision.</p></div>
332<div class="para"><p>Also it can limit the range of lines annotated.</p></div>
333<div class="para"><p>This report doesn't tell you anything about lines which have been deleted or
334replaced; you need to use a tool such as <em>git-diff</em> or the "pickaxe"
335interface briefly mentioned in the following paragraph.</p></div>
336<div class="para"><p>Apart from supporting file annotation, git also supports searching the
Junio C Hamanof9771f62007-01-17 17:42:30337development history for when a code snippet occurred in a change. This makes it
Junio C Hamano6b2cee12006-08-26 08:43:31338possible to track when a code snippet was added to a file, moved or copied
339between files, and eventually deleted or replaced. It works by searching for
Junio C Hamanoba4b9282008-07-06 05:20:31340a text string in the diff. A small example:</p></div>
Junio C Hamano6b2cee12006-08-26 08:43:31341<div class="listingblock">
342<div class="content">
343<pre><tt>$ git log --pretty=oneline -S'blame_usage'
3445040f17eba15504bad66b14a645bddd9b015ebb7 blame -S &lt;ancestry-file&gt;
345ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output</tt></pre>
346</div></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51347</div>
Junio C Hamanoba4b9282008-07-06 05:20:31348<h2 id="_options">OPTIONS</h2>
Junio C Hamanob33fb4f2006-04-18 21:30:51349<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31350<div class="vlist"><dl>
Junio C Hamanob33fb4f2006-04-18 21:30:51351<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11352-b
Junio C Hamanob33fb4f2006-04-18 21:30:51353</dt>
354<dd>
355<p>
Junio C Hamano0e3cb532007-04-17 08:28:11356 Show blank SHA-1 for boundary commits. This can also
357 be controlled via the <tt>blame.blankboundary</tt> config option.
358</p>
359</dd>
360<dt>
361--root
362</dt>
363<dd>
364<p>
365 Do not treat root commits as boundaries. This can also be
366 controlled via the <tt>blame.showroot</tt> config option.
367</p>
368</dd>
369<dt>
370--show-stats
371</dt>
372<dd>
373<p>
374 Include additional statistics at the end of blame output.
Junio C Hamanob33fb4f2006-04-18 21:30:51375</p>
376</dd>
377<dt>
Junio C Hamano9882a522007-04-27 08:22:22378-L &lt;start&gt;,&lt;end&gt;
Junio C Hamanoe1aa7472006-11-09 07:37:50379</dt>
380<dd>
381<p>
Junio C Hamano9882a522007-04-27 08:22:22382 Annotate only the given line range. &lt;start&gt; and &lt;end&gt; can take
383 one of these forms:
Junio C Hamanoe1aa7472006-11-09 07:37:50384</p>
Junio C Hamanoba4b9282008-07-06 05:20:31385<div class="ilist"><ul>
Junio C Hamano9882a522007-04-27 08:22:22386<li>
387<p>
388number
389</p>
Junio C Hamanoba4b9282008-07-06 05:20:31390<div class="para"><p>If &lt;start&gt; or &lt;end&gt; is a number, it specifies an
391absolute line number (lines count from 1).</p></div>
Junio C Hamano9882a522007-04-27 08:22:22392</li>
393<li>
394<p>
395/regex/
396</p>
Junio C Hamanoba4b9282008-07-06 05:20:31397<div class="para"><p>This form will use the first line matching the given
Junio C Hamano9882a522007-04-27 08:22:22398POSIX regex. If &lt;end&gt; is a regex, it will search
Junio C Hamanoba4b9282008-07-06 05:20:31399starting at the line given by &lt;start&gt;.</p></div>
Junio C Hamano9882a522007-04-27 08:22:22400</li>
401<li>
402<p>
403+offset or -offset
404</p>
Junio C Hamanoba4b9282008-07-06 05:20:31405<div class="para"><p>This is only valid for &lt;end&gt; and will specify a number
406of lines before or after the line given by &lt;start&gt;.</p></div>
Junio C Hamano9882a522007-04-27 08:22:22407</li>
Junio C Hamanoba4b9282008-07-06 05:20:31408</ul></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50409</dd>
410<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11411-l
Junio C Hamanob33fb4f2006-04-18 21:30:51412</dt>
413<dd>
414<p>
Junio C Hamano3fd90c82006-06-18 00:22:01415 Show long rev (Default: off).
416</p>
417</dd>
418<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11419-t
Junio C Hamano3fd90c82006-06-18 00:22:01420</dt>
421<dd>
422<p>
423 Show raw timestamp (Default: off).
Junio C Hamanob33fb4f2006-04-18 21:30:51424</p>
425</dd>
426<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11427-S &lt;revs-file&gt;
Junio C Hamanob33fb4f2006-04-18 21:30:51428</dt>
429<dd>
430<p>
Junio C Hamano6b2cee12006-08-26 08:43:31431 Use revs from revs-file instead of calling <a href="git-rev-list.html">git-rev-list(1)</a>.
Junio C Hamanob33fb4f2006-04-18 21:30:51432</p>
433</dd>
434<dt>
Junio C Hamanoa6455f62009-02-20 08:33:08435--reverse
436</dt>
437<dd>
438<p>
439 Walk history forward instead of backward. Instead of showing
440 the revision in which a line appeared, this shows the last
441 revision in which a line has existed. This requires a range of
442 revision like START..END where the path to blame exists in
443 START.
444</p>
445</dd>
446<dt>
Junio C Hamanoeb415992008-06-08 22:49:47447-p
448</dt>
449<dt>
450--porcelain
Junio C Hamanoff4b4312006-10-25 22:55:31451</dt>
452<dd>
453<p>
454 Show in a format designed for machine consumption.
455</p>
456</dd>
457<dt>
Junio C Hamano5a702332007-01-28 20:55:22458--incremental
459</dt>
460<dd>
461<p>
462 Show the result incrementally in a format designed for
463 machine consumption.
464</p>
465</dd>
466<dt>
Junio C Hamanoaa17c7c2008-11-03 04:36:58467--encoding=&lt;encoding&gt;
468</dt>
469<dd>
470<p>
471 Specifies the encoding used to output author names
472 and commit summaries. Setting it to <tt>none</tt> makes blame
473 output unconverted data. For more information see the
474 discussion about encoding in the <a href="git-log.html">git-log(1)</a>
475 manual page.
476</p>
477</dd>
478<dt>
Junio C Hamano42f855f2007-02-06 00:09:38479--contents &lt;file&gt;
480</dt>
481<dd>
482<p>
483 When &lt;rev&gt; is not specified, the command annotates the
484 changes starting backwards from the working tree copy.
485 This flag makes the command pretend as if the working
Junio C Hamano49dccaf2008-02-10 10:48:01486 tree copy has the contents of the named file (specify
Junio C Hamano42f855f2007-02-06 00:09:38487 <tt>-</tt> to make the command read from the standard input).
488</p>
489</dd>
490<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11491-M|&lt;num&gt;|
Junio C Hamanoe1aa7472006-11-09 07:37:50492</dt>
493<dd>
494<p>
495 Detect moving lines in the file as well. When a commit
496 moves a block of lines in a file (e.g. the original file
497 has A and then B, and the commit changes it to B and
Junio C Hamano7924d5e2009-03-03 08:28:48498 then A), the traditional <em>blame</em> algorithm typically blames
Junio C Hamanoe1aa7472006-11-09 07:37:50499 the lines that were moved up (i.e. B) to the parent and
500 assigns blame to the lines that were moved down (i.e. A)
Junio C Hamano0e3cb532007-04-17 08:28:11501 to the child commit. With this option, both groups of lines
502 are blamed on the parent.
Junio C Hamanoe1aa7472006-11-09 07:37:50503</p>
Junio C Hamanoba4b9282008-07-06 05:20:31504<div class="para"><p>&lt;num&gt; is optional but it is the lower bound on the number of
Junio C Hamano0e3cb532007-04-17 08:28:11505alphanumeric characters that git must detect as moving
506within a file for it to associate those lines with the parent
Junio C Hamanoba4b9282008-07-06 05:20:31507commit.</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50508</dd>
509<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11510-C|&lt;num&gt;|
Junio C Hamanoe1aa7472006-11-09 07:37:50511</dt>
512<dd>
513<p>
514 In addition to <tt>-M</tt>, detect lines copied from other
515 files that were modified in the same commit. This is
516 useful when you reorganize your program and move code
517 around across files. When this option is given twice,
Junio C Hamano7924d5e2009-03-03 08:28:48518 the command additionally looks for copies from all other
519 files in the parent for the commit that creates the file.
Junio C Hamanoe1aa7472006-11-09 07:37:50520</p>
Junio C Hamanoba4b9282008-07-06 05:20:31521<div class="para"><p>&lt;num&gt; is optional but it is the lower bound on the number of
Junio C Hamano0e3cb532007-04-17 08:28:11522alphanumeric characters that git must detect as moving
523between files for it to associate those lines with the parent
Junio C Hamanoba4b9282008-07-06 05:20:31524commit.</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50525</dd>
526<dt>
Junio C Hamanoeb415992008-06-08 22:49:47527-h
528</dt>
529<dt>
530--help
Junio C Hamanob33fb4f2006-04-18 21:30:51531</dt>
532<dd>
533<p>
534 Show help message.
535</p>
536</dd>
Junio C Hamano0e3cb532007-04-17 08:28:11537<dt>
538-c
539</dt>
540<dd>
541<p>
542 Use the same output mode as <a href="git-annotate.html">git-annotate(1)</a> (Default: off).
543</p>
544</dd>
545<dt>
546--score-debug
547</dt>
548<dd>
549<p>
550 Include debugging information related to the movement of
551 lines between files (see <tt>-C</tt>) and lines moved within a
552 file (see <tt>-M</tt>). The first number listed is the score.
553 This is the number of alphanumeric characters detected
554 to be moved between or within files. This must be above
Junio C Hamanoba4b9282008-07-06 05:20:31555 a certain threshold for <em>git-blame</em> to consider those lines
Junio C Hamano0e3cb532007-04-17 08:28:11556 of code to have been moved.
557</p>
558</dd>
559<dt>
Junio C Hamanoeb415992008-06-08 22:49:47560-f
561</dt>
562<dt>
563--show-name
Junio C Hamano0e3cb532007-04-17 08:28:11564</dt>
565<dd>
566<p>
567 Show filename in the original commit. By default
568 filename is shown if there is any line that came from a
569 file with different name, due to rename detection.
570</p>
571</dd>
572<dt>
Junio C Hamanoeb415992008-06-08 22:49:47573-n
574</dt>
575<dt>
576--show-number
Junio C Hamano0e3cb532007-04-17 08:28:11577</dt>
578<dd>
579<p>
580 Show line number in the original commit (Default: off).
581</p>
582</dd>
Junio C Hamano469d60e2007-04-29 18:30:34583<dt>
584-s
585</dt>
586<dd>
587<p>
588 Suppress author name and timestamp from the output.
589</p>
590</dd>
Junio C Hamano9e52d4e2007-06-13 08:29:33591<dt>
592-w
593</dt>
594<dd>
595<p>
596 Ignore whitespace when comparing parent's version and
597 child's to find where the lines came from.
598</p>
599</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31600</dl></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51601</div>
Junio C Hamanoba4b9282008-07-06 05:20:31602<h2 id="_the_porcelain_format">THE PORCELAIN FORMAT</h2>
Junio C Hamanoff4b4312006-10-25 22:55:31603<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31604<div class="para"><p>In this format, each line is output after a header; the
605header at the minimum has the first line which has:</p></div>
606<div class="ilist"><ul>
Junio C Hamanoff4b4312006-10-25 22:55:31607<li>
608<p>
60940-byte SHA-1 of the commit the line is attributed to;
610</p>
611</li>
612<li>
613<p>
614the line number of the line in the original file;
615</p>
616</li>
617<li>
618<p>
619the line number of the line in the final file;
620</p>
621</li>
622<li>
623<p>
624on a line that starts a group of line from a different
625 commit than the previous one, the number of lines in this
626 group. On subsequent lines this field is absent.
627</p>
628</li>
Junio C Hamanoba4b9282008-07-06 05:20:31629</ul></div>
630<div class="para"><p>This header line is followed by the following information
631at least once for each commit:</p></div>
632<div class="ilist"><ul>
Junio C Hamanoff4b4312006-10-25 22:55:31633<li>
634<p>
635author name ("author"), email ("author-mail"), time
636 ("author-time"), and timezone ("author-tz"); similarly
637 for committer.
638</p>
639</li>
640<li>
641<p>
642filename in the commit the line is attributed to.
643</p>
644</li>
645<li>
646<p>
647the first line of the commit log message ("summary").
648</p>
649</li>
Junio C Hamanoba4b9282008-07-06 05:20:31650</ul></div>
651<div class="para"><p>The contents of the actual line is output after the above
Junio C Hamanoff4b4312006-10-25 22:55:31652header, prefixed by a TAB. This is to allow adding more
Junio C Hamanoba4b9282008-07-06 05:20:31653header elements later.</p></div>
Junio C Hamanoff4b4312006-10-25 22:55:31654</div>
Junio C Hamanoba4b9282008-07-06 05:20:31655<h2 id="_specifying_ranges">SPECIFYING RANGES</h2>
Junio C Hamanoe1aa7472006-11-09 07:37:50656<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31657<div class="para"><p>Unlike <em>git-blame</em> and <em>git-annotate</em> in older git, the extent
Junio C Hamanoe1aa7472006-11-09 07:37:50658of annotation can be limited to both line ranges and revision
659ranges. When you are interested in finding the origin for
Junio C Hamanoe58607f2007-01-17 23:27:45660ll. 40-60 for file <tt>foo</tt>, you can use <tt>-L</tt> option like these
661(they mean the same thing &#8212; both ask for 21 lines starting at
Junio C Hamanoba4b9282008-07-06 05:20:31662line 40):</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50663<div class="literalblock">
664<div class="content">
Junio C Hamanoe58607f2007-01-17 23:27:45665<pre><tt>git blame -L 40,60 foo
666git blame -L 40,+21 foo</tt></pre>
Junio C Hamanoe1aa7472006-11-09 07:37:50667</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31668<div class="para"><p>Also you can use regular expression to specify the line range.</p></div>
Junio C Hamano4a345d22006-11-09 18:45:32669<div class="literalblock">
670<div class="content">
671<pre><tt>git blame -L '/^sub hello {/,/^}$/' foo</tt></pre>
672</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31673<div class="para"><p>would limit the annotation to the body of <tt>hello</tt> subroutine.</p></div>
674<div class="para"><p>When you are not interested in changes older than the version
Junio C Hamanoe1aa7472006-11-09 07:37:50675v2.6.18, or changes older than 3 weeks, you can use revision
Junio C Hamanoba4b9282008-07-06 05:20:31676range specifiers similar to <em>git-rev-list</em>:</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50677<div class="literalblock">
678<div class="content">
679<pre><tt>git blame v2.6.18.. -- foo
680git blame --since=3.weeks -- foo</tt></pre>
681</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31682<div class="para"><p>When revision range specifiers are used to limit the annotation,
Junio C Hamanoe1aa7472006-11-09 07:37:50683lines that have not changed since the range boundary (either the
684commit v2.6.18 or the most recent commit that is more than 3
685weeks old in the above example) are blamed for that range
Junio C Hamanoba4b9282008-07-06 05:20:31686boundary commit.</p></div>
687<div class="para"><p>A particularly useful way is to see if an added file have lines
Junio C Hamanoe1aa7472006-11-09 07:37:50688created by copy-and-paste from existing files. Sometimes this
689indicates that the developer was being sloppy and did not
690refactor the code properly. You can first find the commit that
Junio C Hamanoba4b9282008-07-06 05:20:31691introduced the file with:</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50692<div class="literalblock">
693<div class="content">
694<pre><tt>git log --diff-filter=A --pretty=short -- foo</tt></pre>
695</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31696<div class="para"><p>and then annotate the change between the commit and its
697parents, using <tt>commit&#94;!</tt> notation:</p></div>
Junio C Hamanoe1aa7472006-11-09 07:37:50698<div class="literalblock">
699<div class="content">
700<pre><tt>git blame -C -C -f $commit^! -- foo</tt></pre>
701</div></div>
702</div>
Junio C Hamanoba4b9282008-07-06 05:20:31703<h2 id="_incremental_output">INCREMENTAL OUTPUT</h2>
Junio C Hamano5a702332007-01-28 20:55:22704<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31705<div class="para"><p>When called with <tt>--incremental</tt> option, the command outputs the
Junio C Hamano5a702332007-01-28 20:55:22706result as it is built. The output generally will talk about
707lines touched by more recent commits first (i.e. the lines will
708be annotated out of order) and is meant to be used by
Junio C Hamanoba4b9282008-07-06 05:20:31709interactive viewers.</p></div>
710<div class="para"><p>The output format is similar to the Porcelain format, but it
Junio C Hamano5a702332007-01-28 20:55:22711does not contain the actual lines from the file that is being
Junio C Hamanoba4b9282008-07-06 05:20:31712annotated.</p></div>
713<div class="olist"><ol>
Junio C Hamano5a702332007-01-28 20:55:22714<li>
715<p>
716Each blame entry always starts with a line of:
717</p>
718<div class="literalblock">
719<div class="content">
720<pre><tt>&lt;40-byte hex sha1&gt; &lt;sourceline&gt; &lt;resultline&gt; &lt;num_lines&gt;</tt></pre>
721</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31722<div class="para"><p>Line numbers count from 1.</p></div>
Junio C Hamano5a702332007-01-28 20:55:22723</li>
724<li>
725<p>
726The first time that commit shows up in the stream, it has various
727 other information about it printed out with a one-word tag at the
728 beginning of each line about that "extended commit info" (author,
729 email, committer, dates, summary etc).
730</p>
731</li>
732<li>
733<p>
734Unlike Porcelain format, the filename information is always
735 given and terminates the entry:
736</p>
737<div class="literalblock">
738<div class="content">
739<pre><tt>"filename" &lt;whitespace-quoted-filename-goes-here&gt;</tt></pre>
740</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31741<div class="para"><p>and thus it's really quite easy to parse for some line- and word-oriented
742parser (which should be quite natural for most scripting languages).</p></div>
Junio C Hamano5a702332007-01-28 20:55:22743<div class="admonitionblock">
744<table><tr>
745<td class="icon">
746<div class="title">Note</div>
747</td>
748<td class="content">For people who do parsing: to make it more robust, just ignore any
749lines in between the first and last one ("&lt;sha1&gt;" and "filename" lines)
750where you don't recognize the tag-words (or care about that particular
751one) at the beginning of the "extended information" lines. That way, if
752there is ever added information (like the commit encoding or extended
753commit commentary), a blame viewer won't ever care.</td>
754</tr></table>
755</div>
756</li>
Junio C Hamanoba4b9282008-07-06 05:20:31757</ol></div>
Junio C Hamano5a702332007-01-28 20:55:22758</div>
Junio C Hamano8bc410e2009-02-15 10:38:19759<h2 id="_mapping_authors">MAPPING AUTHORS</h2>
760<div class="sectionbody">
761<div class="para"><p>If the file <tt>.mailmap</tt> exists at the toplevel of the repository, or at
762the location pointed to by the mailmap.file configuration option, it
763is used to map author and committer names and email addresses to
764canonical real names and email addresses.</p></div>
765<div class="para"><p>In the simple form, each line in the file consists of the canonical
766real name of an author, whitespace, and an email address used in the
767commit (enclosed by <em>&lt;</em> and <em>&gt;</em>) to map to the name. Thus, looks like
768this</p></div>
769<div class="literalblock">
770<div class="content">
771<pre><tt>Proper Name &lt;commit@email.xx&gt;</tt></pre>
772</div></div>
773<div class="para"><p>The more complex forms are</p></div>
774<div class="literalblock">
775<div class="content">
776<pre><tt>&lt;proper@email.xx&gt; &lt;commit@email.xx&gt;</tt></pre>
777</div></div>
778<div class="para"><p>which allows mailmap to replace only the email part of a commit, and</p></div>
779<div class="literalblock">
780<div class="content">
781<pre><tt>Proper Name &lt;proper@email.xx&gt; &lt;commit@email.xx&gt;</tt></pre>
782</div></div>
783<div class="para"><p>which allows mailmap to replace both the name and the email of a
784commit matching the specified commit email address, and</p></div>
785<div class="literalblock">
786<div class="content">
787<pre><tt>Proper Name &lt;proper@email.xx&gt; Commit Name &lt;commit@email.xx&gt;</tt></pre>
788</div></div>
789<div class="para"><p>which allows mailmap to replace both the name and the email of a
790commit matching both the specified commit name and email address.</p></div>
791<div class="para"><p>Example 1: Your history contains commits by two authors, Jane
792and Joe, whose names appear in the repository under several forms:</p></div>
793<div class="listingblock">
794<div class="content">
795<pre><tt>Joe Developer &lt;joe@example.com&gt;
796Joe R. Developer &lt;joe@example.com&gt;
797Jane Doe &lt;jane@example.com&gt;
798Jane Doe &lt;jane@laptop.(none)&gt;
799Jane D. &lt;jane@desktop.(none)&gt;</tt></pre>
800</div></div>
801<div class="para"><p>Now suppose that Joe wants his middle name initial used, and Jane
802prefers her family name fully spelled out. A proper <tt>.mailmap</tt> file
803would look like:</p></div>
804<div class="listingblock">
805<div class="content">
806<pre><tt>Jane Doe &lt;jane@desktop.(none)&gt;
807Joe R. Developer &lt;joe@example.com&gt;</tt></pre>
808</div></div>
809<div class="para"><p>Note how we don't need an entry for &lt;jane@laptop.(none)&gt;, because the
810real name of that author is correct already.</p></div>
811<div class="para"><p>Example 2: Your repository contains commits from the following
812authors:</p></div>
813<div class="listingblock">
814<div class="content">
815<pre><tt>nick1 &lt;bugs@company.xx&gt;
816nick2 &lt;bugs@company.xx&gt;
817nick2 &lt;nick2@company.xx&gt;
818santa &lt;me@company.xx&gt;
819claus &lt;me@company.xx&gt;
820CTO &lt;cto@coompany.xx&gt;</tt></pre>
821</div></div>
822<div class="para"><p>Then, you might want a <tt>.mailmap</tt> file looking like:</p></div>
823<div class="listingblock">
824<div class="content">
825<pre><tt>&lt;cto@company.xx&gt; &lt;cto@coompany.xx&gt;
826Some Dude &lt;some@dude.xx&gt; nick1 &lt;bugs@company.xx&gt;
827Other Author &lt;other@author.xx&gt; nick2 &lt;bugs@company.xx&gt;
828Other Author &lt;other@author.xx&gt; &lt;nick2@company.xx&gt;
829Santa Claus &lt;santa.claus@northpole.xx&gt; &lt;me@company.xx&gt;</tt></pre>
830</div></div>
831<div class="para"><p>Use hash <em>#</em> for comments that are either on their own line, or after
832the email address.</p></div>
833</div>
Junio C Hamanoba4b9282008-07-06 05:20:31834<h2 id="_see_also">SEE ALSO</h2>
Junio C Hamanob33fb4f2006-04-18 21:30:51835<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31836<div class="para"><p><a href="git-annotate.html">git-annotate(1)</a></p></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51837</div>
Junio C Hamanoba4b9282008-07-06 05:20:31838<h2 id="_author">AUTHOR</h2>
Junio C Hamanob33fb4f2006-04-18 21:30:51839<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:44840<div class="para"><p>Written by Junio C Hamano &lt;gitster@pobox.com&gt;</p></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51841</div>
Junio C Hamanoba4b9282008-07-06 05:20:31842<h2 id="_git">GIT</h2>
Junio C Hamanob33fb4f2006-04-18 21:30:51843<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31844<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamanob33fb4f2006-04-18 21:30:51845</div>
846<div id="footer">
847<div id="footer-text">
Junio C Hamano7924d5e2009-03-03 08:28:48848Last updated 2009-03-03 08:28:31 UTC
Junio C Hamanob33fb4f2006-04-18 21:30:51849</div>
850</div>
851</body>
852</html>