Autogenerated HTML docs for v1.7.7-419-g87009
[git/jnareb-git.git] / git-blame.html
blob24b8df29a6fc25e92b295a0c900927c215eea780
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.5.2" />
7 <title>git-blame(1)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.0em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.0em;
126 margin-bottom: 2.0em;
127 margin-right: 10%;
128 color: #606060;
131 div.content { /* Block element content. */
132 padding: 0;
135 /* Block element titles. */
136 div.title, caption.title {
137 color: #527bbd;
138 font-family: sans-serif;
139 font-weight: bold;
140 text-align: left;
141 margin-top: 1.0em;
142 margin-bottom: 0.5em;
144 div.title + * {
145 margin-top: 0;
148 td div.title:first-child {
149 margin-top: 0.0em;
151 div.content div.title:first-child {
152 margin-top: 0.0em;
154 div.content + div.title {
155 margin-top: 0.0em;
158 div.sidebarblock > div.content {
159 background: #ffffee;
160 border: 1px solid silver;
161 padding: 0.5em;
164 div.listingblock > div.content {
165 border: 1px solid silver;
166 background: #f4f4f4;
167 padding: 0.5em;
170 div.quoteblock, div.verseblock {
171 padding-left: 1.0em;
172 margin-left: 1.0em;
173 margin-right: 10%;
174 border-left: 5px solid #dddddd;
175 color: #777777;
178 div.quoteblock > div.attribution {
179 padding-top: 0.5em;
180 text-align: right;
183 div.verseblock > div.content {
184 white-space: pre;
186 div.verseblock > div.attribution {
187 padding-top: 0.75em;
188 text-align: left;
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div.verseblock + div.attribution {
192 text-align: left;
195 div.admonitionblock .icon {
196 vertical-align: top;
197 font-size: 1.1em;
198 font-weight: bold;
199 text-decoration: underline;
200 color: #527bbd;
201 padding-right: 0.5em;
203 div.admonitionblock td.content {
204 padding-left: 0.5em;
205 border-left: 3px solid #dddddd;
208 div.exampleblock > div.content {
209 border-left: 3px solid #dddddd;
210 padding-left: 0.5em;
213 div.imageblock div.content { padding-left: 0; }
214 span.image img { border-style: none; }
215 a.image:visited { color: white; }
217 dl {
218 margin-top: 0.8em;
219 margin-bottom: 0.8em;
221 dt {
222 margin-top: 0.5em;
223 margin-bottom: 0;
224 font-style: normal;
225 color: navy;
227 dd > *:first-child {
228 margin-top: 0.1em;
231 ul, ol {
232 list-style-position: outside;
234 ol.arabic {
235 list-style-type: decimal;
237 ol.loweralpha {
238 list-style-type: lower-alpha;
240 ol.upperalpha {
241 list-style-type: upper-alpha;
243 ol.lowerroman {
244 list-style-type: lower-roman;
246 ol.upperroman {
247 list-style-type: upper-roman;
250 div.compact ul, div.compact ol,
251 div.compact p, div.compact p,
252 div.compact div, div.compact div {
253 margin-top: 0.1em;
254 margin-bottom: 0.1em;
257 div.tableblock > table {
258 border: 3px solid #527bbd;
260 thead, p.table.header {
261 font-family: sans-serif;
262 font-weight: bold;
264 tfoot {
265 font-weight: bold;
267 td > div.verse {
268 white-space: pre;
270 p.table {
271 margin-top: 0;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div.tableblock > table[frame="void"] {
275 border-style: none;
277 div.tableblock > table[frame="hsides"] {
278 border-left-style: none;
279 border-right-style: none;
281 div.tableblock > table[frame="vsides"] {
282 border-top-style: none;
283 border-bottom-style: none;
287 div.hdlist {
288 margin-top: 0.8em;
289 margin-bottom: 0.8em;
291 div.hdlist tr {
292 padding-bottom: 15px;
294 dt.hdlist1.strong, td.hdlist1.strong {
295 font-weight: bold;
297 td.hdlist1 {
298 vertical-align: top;
299 font-style: normal;
300 padding-right: 0.8em;
301 color: navy;
303 td.hdlist2 {
304 vertical-align: top;
306 div.hdlist.compact tr {
307 margin: 0;
308 padding-bottom: 0;
311 .comment {
312 background: yellow;
315 .footnote, .footnoteref {
316 font-size: 0.8em;
319 span.footnote, span.footnoteref {
320 vertical-align: super;
323 #footnotes {
324 margin: 20px 0 20px 0;
325 padding: 7px 0 0 0;
328 #footnotes div.footnote {
329 margin: 0 0 5px 0;
332 #footnotes hr {
333 border: none;
334 border-top: 1px solid silver;
335 height: 1px;
336 text-align: left;
337 margin-left: 0;
338 width: 20%;
339 min-width: 100px;
343 @media print {
344 div#footer-badges { display: none; }
347 div#toc {
348 margin-bottom: 2.5em;
351 div#toctitle {
352 color: #527bbd;
353 font-family: sans-serif;
354 font-size: 1.1em;
355 font-weight: bold;
356 margin-top: 1.0em;
357 margin-bottom: 0.1em;
360 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
361 margin-top: 0;
362 margin-bottom: 0;
364 div.toclevel2 {
365 margin-left: 2em;
366 font-size: 0.9em;
368 div.toclevel3 {
369 margin-left: 4em;
370 font-size: 0.9em;
372 div.toclevel4 {
373 margin-left: 6em;
374 font-size: 0.9em;
376 /* Overrides for manpage documents */
377 h1 {
378 padding-top: 0.5em;
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver;
381 border-bottom: 2px solid silver;
383 h2 {
384 border-style: none;
386 div.sectionbody {
387 margin-left: 5%;
390 @media print {
391 div#toc { display: none; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div.sidebar-content {
397 background: #ffffee;
398 border: 1px solid silver;
399 padding: 0.5em;
401 div.sidebar-title, div.image-title {
402 color: #527bbd;
403 font-family: sans-serif;
404 font-weight: bold;
405 margin-top: 0.0em;
406 margin-bottom: 0.5em;
409 div.listingblock div.content {
410 border: 1px solid silver;
411 background: #f4f4f4;
412 padding: 0.5em;
415 div.quoteblock-attribution {
416 padding-top: 0.5em;
417 text-align: right;
420 div.verseblock-content {
421 white-space: pre;
423 div.verseblock-attribution {
424 padding-top: 0.75em;
425 text-align: left;
428 div.exampleblock-content {
429 border-left: 3px solid #dddddd;
430 padding-left: 0.5em;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc a:visited { color: blue; }
435 </style>
436 <script type="text/javascript">
437 /*<![CDATA[*/
438 window.onload = function(){asciidoc.footnotes();}
439 var asciidoc = { // Namespace.
441 /////////////////////////////////////////////////////////////////////
442 // Table Of Contents generator
443 /////////////////////////////////////////////////////////////////////
445 /* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
448 * Table Of Content generator
449 * Version: 0.4
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
458 // toclevels = 1..4.
459 toc: function (toclevels) {
461 function getText(el) {
462 var text = "";
463 for (var i = el.firstChild; i != null; i = i.nextSibling) {
464 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
465 text += i.data;
466 else if (i.firstChild != null)
467 text += getText(i);
469 return text;
472 function TocEntry(el, text, toclevel) {
473 this.element = el;
474 this.text = text;
475 this.toclevel = toclevel;
478 function tocEntries(el, toclevels) {
479 var result = new Array;
480 var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
483 // browsers).
484 var iterate = function (el) {
485 for (var i = el.firstChild; i != null; i = i.nextSibling) {
486 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
487 var mo = re.exec(i.tagName);
488 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
489 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
491 iterate(i);
495 iterate(el);
496 return result;
499 var toc = document.getElementById("toc");
500 var entries = tocEntries(document.getElementById("content"), toclevels);
501 for (var i = 0; i < entries.length; ++i) {
502 var entry = entries[i];
503 if (entry.element.id == "")
504 entry.element.id = "_toc_" + i;
505 var a = document.createElement("a");
506 a.href = "#" + entry.element.id;
507 a.appendChild(document.createTextNode(entry.text));
508 var div = document.createElement("div");
509 div.appendChild(a);
510 div.className = "toclevel" + entry.toclevel;
511 toc.appendChild(div);
513 if (entries.length == 0)
514 toc.parentNode.removeChild(toc);
518 /////////////////////////////////////////////////////////////////////
519 // Footnotes generator
520 /////////////////////////////////////////////////////////////////////
522 /* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
526 footnotes: function () {
527 var cont = document.getElementById("content");
528 var noteholder = document.getElementById("footnotes");
529 var spans = cont.getElementsByTagName("span");
530 var refs = {};
531 var n = 0;
532 for (i=0; i<spans.length; i++) {
533 if (spans[i].className == "footnote") {
534 n++;
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder.innerHTML +=
539 "<div class='footnote' id='_footnote_" + n + "'>" +
540 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
541 n + "</a>. " + note + "</div>";
542 spans[i].innerHTML =
543 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
544 "' title='View footnote' class='footnote'>" + n + "</a>]";
545 var id =spans[i].getAttribute("id");
546 if (id != null) refs["#"+id] = n;
549 if (n == 0)
550 noteholder.parentNode.removeChild(noteholder);
551 else {
552 // Process footnoterefs.
553 for (i=0; i<spans.length; i++) {
554 if (spans[i].className == "footnoteref") {
555 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
556 href = href.match(/#.*/)[0]; // Because IE return full URL.
557 n = refs[href];
558 spans[i].innerHTML =
559 "[<a href='#_footnote_" + n +
560 "' title='View footnote' class='footnote'>" + n + "</a>]";
567 /*]]>*/
568 </script>
569 </head>
570 <body>
571 <div id="header">
572 <h1>
573 git-blame(1) Manual Page
574 </h1>
575 <h2>NAME</h2>
576 <div class="sectionbody">
577 <p>git-blame -
578 Show what revision and author last modified each line of a file
579 </p>
580 </div>
581 </div>
582 <div id="content">
583 <h2 id="_synopsis">SYNOPSIS</h2>
584 <div class="sectionbody">
585 <div class="verseblock">
586 <div class="verseblock-content"><em>git blame</em> [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w] [--incremental] [-L n,m]
587 [-S &lt;revs-file&gt;] [-M] [-C] [-C] [-C] [--since=&lt;date&gt;] [--abbrev=&lt;n&gt;]
588 [&lt;rev&gt; | --contents &lt;file&gt; | --reverse &lt;rev&gt;] [--] &lt;file&gt;</div>
589 <div class="verseblock-attribution">
590 </div></div>
591 </div>
592 <h2 id="_description">DESCRIPTION</h2>
593 <div class="sectionbody">
594 <div class="paragraph"><p>Annotates each line in the given file with information from the revision which
595 last modified the line. Optionally, start annotating from the given revision.</p></div>
596 <div class="paragraph"><p>The command can also limit the range of lines annotated.</p></div>
597 <div class="paragraph"><p>The report does not tell you anything about lines which have been deleted or
598 replaced; you need to use a tool such as <em>git diff</em> or the "pickaxe"
599 interface briefly mentioned in the following paragraph.</p></div>
600 <div class="paragraph"><p>Apart from supporting file annotation, git also supports searching the
601 development history for when a code snippet occurred in a change. This makes it
602 possible to track when a code snippet was added to a file, moved or copied
603 between files, and eventually deleted or replaced. It works by searching for
604 a text string in the diff. A small example:</p></div>
605 <div class="listingblock">
606 <div class="content">
607 <pre><tt>$ git log --pretty=oneline -S'blame_usage'
608 5040f17eba15504bad66b14a645bddd9b015ebb7 blame -S &lt;ancestry-file&gt;
609 ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output</tt></pre>
610 </div></div>
611 </div>
612 <h2 id="_options">OPTIONS</h2>
613 <div class="sectionbody">
614 <div class="dlist"><dl>
615 <dt class="hdlist1">
617 </dt>
618 <dd>
620 Show blank SHA-1 for boundary commits. This can also
621 be controlled via the <tt>blame.blankboundary</tt> config option.
622 </p>
623 </dd>
624 <dt class="hdlist1">
625 --root
626 </dt>
627 <dd>
629 Do not treat root commits as boundaries. This can also be
630 controlled via the <tt>blame.showroot</tt> config option.
631 </p>
632 </dd>
633 <dt class="hdlist1">
634 --show-stats
635 </dt>
636 <dd>
638 Include additional statistics at the end of blame output.
639 </p>
640 </dd>
641 <dt class="hdlist1">
642 -L &lt;start&gt;,&lt;end&gt;
643 </dt>
644 <dd>
646 Annotate only the given line range. &lt;start&gt; and &lt;end&gt; can take
647 one of these forms:
648 </p>
649 <div class="ulist"><ul>
650 <li>
652 number
653 </p>
654 <div class="paragraph"><p>If &lt;start&gt; or &lt;end&gt; is a number, it specifies an
655 absolute line number (lines count from 1).</p></div>
656 </li>
657 <li>
659 /regex/
660 </p>
661 <div class="paragraph"><p>This form will use the first line matching the given
662 POSIX regex. If &lt;end&gt; is a regex, it will search
663 starting at the line given by &lt;start&gt;.</p></div>
664 </li>
665 <li>
667 +offset or -offset
668 </p>
669 <div class="paragraph"><p>This is only valid for &lt;end&gt; and will specify a number
670 of lines before or after the line given by &lt;start&gt;.</p></div>
671 </li>
672 </ul></div>
673 </dd>
674 <dt class="hdlist1">
676 </dt>
677 <dd>
679 Show long rev (Default: off).
680 </p>
681 </dd>
682 <dt class="hdlist1">
684 </dt>
685 <dd>
687 Show raw timestamp (Default: off).
688 </p>
689 </dd>
690 <dt class="hdlist1">
691 -S &lt;revs-file&gt;
692 </dt>
693 <dd>
695 Use revisions from revs-file instead of calling <a href="git-rev-list.html">git-rev-list(1)</a>.
696 </p>
697 </dd>
698 <dt class="hdlist1">
699 --reverse
700 </dt>
701 <dd>
703 Walk history forward instead of backward. Instead of showing
704 the revision in which a line appeared, this shows the last
705 revision in which a line has existed. This requires a range of
706 revision like START..END where the path to blame exists in
707 START.
708 </p>
709 </dd>
710 <dt class="hdlist1">
712 </dt>
713 <dt class="hdlist1">
714 --porcelain
715 </dt>
716 <dd>
718 Show in a format designed for machine consumption.
719 </p>
720 </dd>
721 <dt class="hdlist1">
722 --line-porcelain
723 </dt>
724 <dd>
726 Show the porcelain format, but output commit information for
727 each line, not just the first time a commit is referenced.
728 Implies --porcelain.
729 </p>
730 </dd>
731 <dt class="hdlist1">
732 --incremental
733 </dt>
734 <dd>
736 Show the result incrementally in a format designed for
737 machine consumption.
738 </p>
739 </dd>
740 <dt class="hdlist1">
741 --encoding=&lt;encoding&gt;
742 </dt>
743 <dd>
745 Specifies the encoding used to output author names
746 and commit summaries. Setting it to <tt>none</tt> makes blame
747 output unconverted data. For more information see the
748 discussion about encoding in the <a href="git-log.html">git-log(1)</a>
749 manual page.
750 </p>
751 </dd>
752 <dt class="hdlist1">
753 --contents &lt;file&gt;
754 </dt>
755 <dd>
757 When &lt;rev&gt; is not specified, the command annotates the
758 changes starting backwards from the working tree copy.
759 This flag makes the command pretend as if the working
760 tree copy has the contents of the named file (specify
761 <tt>-</tt> to make the command read from the standard input).
762 </p>
763 </dd>
764 <dt class="hdlist1">
765 --date &lt;format&gt;
766 </dt>
767 <dd>
769 The value is one of the following alternatives:
770 {relative,local,default,iso,rfc,short}. If --date is not
771 provided, the value of the blame.date config variable is
772 used. If the blame.date config variable is also not set, the
773 iso format is used. For more information, See the discussion
774 of the --date option at <a href="git-log.html">git-log(1)</a>.
775 </p>
776 </dd>
777 <dt class="hdlist1">
778 -M|&lt;num&gt;|
779 </dt>
780 <dd>
782 Detect moved or copied lines within a file. When a commit
783 moves or copies a block of lines (e.g. the original file
784 has A and then B, and the commit changes it to B and then
785 A), the traditional <em>blame</em> algorithm notices only half of
786 the movement and typically blames the lines that were moved
787 up (i.e. B) to the parent and assigns blame to the lines that
788 were moved down (i.e. A) to the child commit. With this
789 option, both groups of lines are blamed on the parent by
790 running extra passes of inspection.
791 </p>
792 <div class="paragraph"><p>&lt;num&gt; is optional but it is the lower bound on the number of
793 alphanumeric characters that git must detect as moving/copying
794 within a file for it to associate those lines with the parent
795 commit. The default value is 20.</p></div>
796 </dd>
797 <dt class="hdlist1">
798 -C|&lt;num&gt;|
799 </dt>
800 <dd>
802 In addition to <tt>-M</tt>, detect lines moved or copied from other
803 files that were modified in the same commit. This is
804 useful when you reorganize your program and move code
805 around across files. When this option is given twice,
806 the command additionally looks for copies from other
807 files in the commit that creates the file. When this
808 option is given three times, the command additionally
809 looks for copies from other files in any commit.
810 </p>
811 <div class="paragraph"><p>&lt;num&gt; is optional but it is the lower bound on the number of
812 alphanumeric characters that git must detect as moving/copying
813 between files for it to associate those lines with the parent
814 commit. And the default value is 40. If there are more than one
815 <tt>-C</tt> options given, the &lt;num&gt; argument of the last <tt>-C</tt> will
816 take effect.</p></div>
817 </dd>
818 <dt class="hdlist1">
820 </dt>
821 <dd>
823 Show help message.
824 </p>
825 </dd>
826 <dt class="hdlist1">
828 </dt>
829 <dd>
831 Use the same output mode as <a href="git-annotate.html">git-annotate(1)</a> (Default: off).
832 </p>
833 </dd>
834 <dt class="hdlist1">
835 --score-debug
836 </dt>
837 <dd>
839 Include debugging information related to the movement of
840 lines between files (see <tt>-C</tt>) and lines moved within a
841 file (see <tt>-M</tt>). The first number listed is the score.
842 This is the number of alphanumeric characters detected
843 as having been moved between or within files. This must be above
844 a certain threshold for <em>git blame</em> to consider those lines
845 of code to have been moved.
846 </p>
847 </dd>
848 <dt class="hdlist1">
850 </dt>
851 <dt class="hdlist1">
852 --show-name
853 </dt>
854 <dd>
856 Show the filename in the original commit. By default
857 the filename is shown if there is any line that came from a
858 file with a different name, due to rename detection.
859 </p>
860 </dd>
861 <dt class="hdlist1">
863 </dt>
864 <dt class="hdlist1">
865 --show-number
866 </dt>
867 <dd>
869 Show the line number in the original commit (Default: off).
870 </p>
871 </dd>
872 <dt class="hdlist1">
874 </dt>
875 <dd>
877 Suppress the author name and timestamp from the output.
878 </p>
879 </dd>
880 <dt class="hdlist1">
882 </dt>
883 <dt class="hdlist1">
884 --show-email
885 </dt>
886 <dd>
888 Show the author email instead of author name (Default: off).
889 </p>
890 </dd>
891 <dt class="hdlist1">
893 </dt>
894 <dd>
896 Ignore whitespace when comparing the parent&#8217;s version and
897 the child&#8217;s to find where the lines came from.
898 </p>
899 </dd>
900 <dt class="hdlist1">
901 --abbrev=&lt;n&gt;
902 </dt>
903 <dd>
905 Instead of using the default 7+1 hexadecimal digits as the
906 abbreviated object name, use &lt;n&gt;+1 digits. Note that 1 column
907 is used for a caret to mark the boundary commit.
908 </p>
909 </dd>
910 </dl></div>
911 </div>
912 <h2 id="_the_porcelain_format">THE PORCELAIN FORMAT</h2>
913 <div class="sectionbody">
914 <div class="paragraph"><p>In this format, each line is output after a header; the
915 header at the minimum has the first line which has:</p></div>
916 <div class="ulist"><ul>
917 <li>
919 40-byte SHA-1 of the commit the line is attributed to;
920 </p>
921 </li>
922 <li>
924 the line number of the line in the original file;
925 </p>
926 </li>
927 <li>
929 the line number of the line in the final file;
930 </p>
931 </li>
932 <li>
934 on a line that starts a group of lines from a different
935 commit than the previous one, the number of lines in this
936 group. On subsequent lines this field is absent.
937 </p>
938 </li>
939 </ul></div>
940 <div class="paragraph"><p>This header line is followed by the following information
941 at least once for each commit:</p></div>
942 <div class="ulist"><ul>
943 <li>
945 the author name ("author"), email ("author-mail"), time
946 ("author-time"), and timezone ("author-tz"); similarly
947 for committer.
948 </p>
949 </li>
950 <li>
952 the filename in the commit that the line is attributed to.
953 </p>
954 </li>
955 <li>
957 the first line of the commit log message ("summary").
958 </p>
959 </li>
960 </ul></div>
961 <div class="paragraph"><p>The contents of the actual line is output after the above
962 header, prefixed by a TAB. This is to allow adding more
963 header elements later.</p></div>
964 <div class="paragraph"><p>The porcelain format generally suppresses commit information that has
965 already been seen. For example, two lines that are blamed to the same
966 commit will both be shown, but the details for that commit will be shown
967 only once. This is more efficient, but may require more state be kept by
968 the reader. The <tt>--line-porcelain</tt> option can be used to output full
969 commit information for each line, allowing simpler (but less efficient)
970 usage like:</p></div>
971 <div class="literalblock">
972 <div class="content">
973 <pre><tt># count the number of lines attributed to each author
974 git blame --line-porcelain file |
975 sed -n 's/^author //p' |
976 sort | uniq -c | sort -rn</tt></pre>
977 </div></div>
978 </div>
979 <h2 id="_specifying_ranges">SPECIFYING RANGES</h2>
980 <div class="sectionbody">
981 <div class="paragraph"><p>Unlike <em>git blame</em> and <em>git annotate</em> in older versions of git, the extent
982 of the annotation can be limited to both line ranges and revision
983 ranges. When you are interested in finding the origin for
984 lines 40-60 for file <tt>foo</tt>, you can use the <tt>-L</tt> option like so
985 (they mean the same thing&#8201;&#8212;&#8201;both ask for 21 lines starting at
986 line 40):</p></div>
987 <div class="literalblock">
988 <div class="content">
989 <pre><tt>git blame -L 40,60 foo
990 git blame -L 40,+21 foo</tt></pre>
991 </div></div>
992 <div class="paragraph"><p>Also you can use a regular expression to specify the line range:</p></div>
993 <div class="literalblock">
994 <div class="content">
995 <pre><tt>git blame -L '/^sub hello {/,/^}$/' foo</tt></pre>
996 </div></div>
997 <div class="paragraph"><p>which limits the annotation to the body of the <tt>hello</tt> subroutine.</p></div>
998 <div class="paragraph"><p>When you are not interested in changes older than version
999 v2.6.18, or changes older than 3 weeks, you can use revision
1000 range specifiers similar to <em>git rev-list</em>:</p></div>
1001 <div class="literalblock">
1002 <div class="content">
1003 <pre><tt>git blame v2.6.18.. -- foo
1004 git blame --since=3.weeks -- foo</tt></pre>
1005 </div></div>
1006 <div class="paragraph"><p>When revision range specifiers are used to limit the annotation,
1007 lines that have not changed since the range boundary (either the
1008 commit v2.6.18 or the most recent commit that is more than 3
1009 weeks old in the above example) are blamed for that range
1010 boundary commit.</p></div>
1011 <div class="paragraph"><p>A particularly useful way is to see if an added file has lines
1012 created by copy-and-paste from existing files. Sometimes this
1013 indicates that the developer was being sloppy and did not
1014 refactor the code properly. You can first find the commit that
1015 introduced the file with:</p></div>
1016 <div class="literalblock">
1017 <div class="content">
1018 <pre><tt>git log --diff-filter=A --pretty=short -- foo</tt></pre>
1019 </div></div>
1020 <div class="paragraph"><p>and then annotate the change between the commit and its
1021 parents, using <tt>commit&#94;!</tt> notation:</p></div>
1022 <div class="literalblock">
1023 <div class="content">
1024 <pre><tt>git blame -C -C -f $commit^! -- foo</tt></pre>
1025 </div></div>
1026 </div>
1027 <h2 id="_incremental_output">INCREMENTAL OUTPUT</h2>
1028 <div class="sectionbody">
1029 <div class="paragraph"><p>When called with <tt>--incremental</tt> option, the command outputs the
1030 result as it is built. The output generally will talk about
1031 lines touched by more recent commits first (i.e. the lines will
1032 be annotated out of order) and is meant to be used by
1033 interactive viewers.</p></div>
1034 <div class="paragraph"><p>The output format is similar to the Porcelain format, but it
1035 does not contain the actual lines from the file that is being
1036 annotated.</p></div>
1037 <div class="olist arabic"><ol class="arabic">
1038 <li>
1040 Each blame entry always starts with a line of:
1041 </p>
1042 <div class="literalblock">
1043 <div class="content">
1044 <pre><tt>&lt;40-byte hex sha1&gt; &lt;sourceline&gt; &lt;resultline&gt; &lt;num_lines&gt;</tt></pre>
1045 </div></div>
1046 <div class="paragraph"><p>Line numbers count from 1.</p></div>
1047 </li>
1048 <li>
1050 The first time that a commit shows up in the stream, it has various
1051 other information about it printed out with a one-word tag at the
1052 beginning of each line describing the extra commit information (author,
1053 email, committer, dates, summary, etc.).
1054 </p>
1055 </li>
1056 <li>
1058 Unlike the Porcelain format, the filename information is always
1059 given and terminates the entry:
1060 </p>
1061 <div class="literalblock">
1062 <div class="content">
1063 <pre><tt>"filename" &lt;whitespace-quoted-filename-goes-here&gt;</tt></pre>
1064 </div></div>
1065 <div class="paragraph"><p>and thus it is really quite easy to parse for some line- and word-oriented
1066 parser (which should be quite natural for most scripting languages).</p></div>
1067 <div class="admonitionblock">
1068 <table><tr>
1069 <td class="icon">
1070 <div class="title">Note</div>
1071 </td>
1072 <td class="content">For people who do parsing: to make it more robust, just ignore any
1073 lines between the first and last one ("&lt;sha1&gt;" and "filename" lines)
1074 where you do not recognize the tag words (or care about that particular
1075 one) at the beginning of the "extended information" lines. That way, if
1076 there is ever added information (like the commit encoding or extended
1077 commit commentary), a blame viewer will not care.</td>
1078 </tr></table>
1079 </div>
1080 </li>
1081 </ol></div>
1082 </div>
1083 <h2 id="_mapping_authors">MAPPING AUTHORS</h2>
1084 <div class="sectionbody">
1085 <div class="paragraph"><p>If the file <tt>.mailmap</tt> exists at the toplevel of the repository, or at
1086 the location pointed to by the mailmap.file configuration option, it
1087 is used to map author and committer names and email addresses to
1088 canonical real names and email addresses.</p></div>
1089 <div class="paragraph"><p>In the simple form, each line in the file consists of the canonical
1090 real name of an author, whitespace, and an email address used in the
1091 commit (enclosed by <em>&lt;</em> and <em>&gt;</em>) to map to the name. For example:</p></div>
1092 <div class="literalblock">
1093 <div class="content">
1094 <pre><tt>Proper Name &lt;commit@email.xx&gt;</tt></pre>
1095 </div></div>
1096 <div class="paragraph"><p>The more complex forms are:</p></div>
1097 <div class="literalblock">
1098 <div class="content">
1099 <pre><tt>&lt;proper@email.xx&gt; &lt;commit@email.xx&gt;</tt></pre>
1100 </div></div>
1101 <div class="paragraph"><p>which allows mailmap to replace only the email part of a commit, and:</p></div>
1102 <div class="literalblock">
1103 <div class="content">
1104 <pre><tt>Proper Name &lt;proper@email.xx&gt; &lt;commit@email.xx&gt;</tt></pre>
1105 </div></div>
1106 <div class="paragraph"><p>which allows mailmap to replace both the name and the email of a
1107 commit matching the specified commit email address, and:</p></div>
1108 <div class="literalblock">
1109 <div class="content">
1110 <pre><tt>Proper Name &lt;proper@email.xx&gt; Commit Name &lt;commit@email.xx&gt;</tt></pre>
1111 </div></div>
1112 <div class="paragraph"><p>which allows mailmap to replace both the name and the email of a
1113 commit matching both the specified commit name and email address.</p></div>
1114 <div class="paragraph"><p>Example 1: Your history contains commits by two authors, Jane
1115 and Joe, whose names appear in the repository under several forms:</p></div>
1116 <div class="listingblock">
1117 <div class="content">
1118 <pre><tt>Joe Developer &lt;joe@example.com&gt;
1119 Joe R. Developer &lt;joe@example.com&gt;
1120 Jane Doe &lt;jane@example.com&gt;
1121 Jane Doe &lt;jane@laptop.(none)&gt;
1122 Jane D. &lt;jane@desktop.(none)&gt;</tt></pre>
1123 </div></div>
1124 <div class="paragraph"><p>Now suppose that Joe wants his middle name initial used, and Jane
1125 prefers her family name fully spelled out. A proper <tt>.mailmap</tt> file
1126 would look like:</p></div>
1127 <div class="listingblock">
1128 <div class="content">
1129 <pre><tt>Jane Doe &lt;jane@desktop.(none)&gt;
1130 Joe R. Developer &lt;joe@example.com&gt;</tt></pre>
1131 </div></div>
1132 <div class="paragraph"><p>Note how there is no need for an entry for &lt;<a href="mailto:jane@laptop">jane@laptop</a>.(none)&gt;, because the
1133 real name of that author is already correct.</p></div>
1134 <div class="paragraph"><p>Example 2: Your repository contains commits from the following
1135 authors:</p></div>
1136 <div class="listingblock">
1137 <div class="content">
1138 <pre><tt>nick1 &lt;bugs@company.xx&gt;
1139 nick2 &lt;bugs@company.xx&gt;
1140 nick2 &lt;nick2@company.xx&gt;
1141 santa &lt;me@company.xx&gt;
1142 claus &lt;me@company.xx&gt;
1143 CTO &lt;cto@coompany.xx&gt;</tt></pre>
1144 </div></div>
1145 <div class="paragraph"><p>Then you might want a <tt>.mailmap</tt> file that looks like:</p></div>
1146 <div class="listingblock">
1147 <div class="content">
1148 <pre><tt>&lt;cto@company.xx&gt; &lt;cto@coompany.xx&gt;
1149 Some Dude &lt;some@dude.xx&gt; nick1 &lt;bugs@company.xx&gt;
1150 Other Author &lt;other@author.xx&gt; nick2 &lt;bugs@company.xx&gt;
1151 Other Author &lt;other@author.xx&gt; &lt;nick2@company.xx&gt;
1152 Santa Claus &lt;santa.claus@northpole.xx&gt; &lt;me@company.xx&gt;</tt></pre>
1153 </div></div>
1154 <div class="paragraph"><p>Use hash <em>#</em> for comments that are either on their own line, or after
1155 the email address.</p></div>
1156 </div>
1157 <h2 id="_see_also">SEE ALSO</h2>
1158 <div class="sectionbody">
1159 <div class="paragraph"><p><a href="git-annotate.html">git-annotate(1)</a></p></div>
1160 </div>
1161 <h2 id="_git">GIT</h2>
1162 <div class="sectionbody">
1163 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1164 </div>
1165 </div>
1166 <div id="footnotes"><hr /></div>
1167 <div id="footer">
1168 <div id="footer-text">
1169 Last updated 2011-09-21 23:01:14 PDT
1170 </div>
1171 </div>
1172 </body>
1173 </html>