Autogenerated HTML docs for v2.45.0-rc0-3-g00e10e
[git-htmldocs.git] / git-interpret-trailers.html
blob231d24baaf9803cf727ba6fa27ed7054225c1592
1 <?xml version="1.0" encoding="UTF-8"?>
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>
6 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
7 <meta name="generator" content="AsciiDoc 10.2.0" />
8 <title>git-interpret-trailers(1)</title>
9 <style type="text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
12 /* Default font. */
13 body {
14 font-family: Georgia,serif;
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;
27 body {
28 margin: 1em 5% 1em 5%;
31 a {
32 color: blue;
33 text-decoration: underline;
35 a:visited {
36 color: fuchsia;
39 em {
40 font-style: italic;
41 color: navy;
44 strong {
45 font-weight: bold;
46 color: #083194;
49 h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
51 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
56 h1, h2, h3 {
57 border-bottom: 2px solid silver;
59 h2 {
60 padding-top: 0.5em;
62 h3 {
63 float: left;
65 h3 + * {
66 clear: left;
68 h5 {
69 font-size: 1.0em;
72 div.sectionbody {
73 margin-left: 0;
76 hr {
77 border: 1px solid silver;
80 p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
85 ul, ol, li > p {
86 margin-top: 0;
88 ul > li { color: #aaa; }
89 ul > li > * { color: black; }
91 .monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
98 pre {
99 white-space: pre-wrap;
102 #author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
107 #email {
109 #revnumber, #revdate, #revremark {
112 #footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
118 #footer-text {
119 float: left;
120 padding-bottom: 0.5em;
122 #footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
127 #preamble {
128 margin-top: 1.5em;
129 margin-bottom: 1.5em;
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
134 margin-top: 1.0em;
135 margin-bottom: 1.5em;
137 div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
144 div.content { /* Block element content. */
145 padding: 0;
148 /* Block element titles. */
149 div.title, caption.title {
150 color: #527bbd;
151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
156 div.title + * {
157 margin-top: 0;
160 td div.title:first-child {
161 margin-top: 0.0em;
163 div.content div.title:first-child {
164 margin-top: 0.0em;
166 div.content + div.title {
167 margin-top: 0.0em;
170 div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
177 div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
184 div.quoteblock, div.verseblock {
185 padding-left: 1.0em;
186 margin-left: 1.0em;
187 margin-right: 10%;
188 border-left: 5px solid #f0f0f0;
189 color: #888;
192 div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
197 div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
201 div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
207 text-align: left;
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;
218 div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
223 div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
228 div.imageblock div.content { padding-left: 0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
232 dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
236 dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
242 dd > *:first-child {
243 margin-top: 0.1em;
246 ul, ol {
247 list-style-position: outside;
249 ol.arabic {
250 list-style-type: decimal;
252 ol.loweralpha {
253 list-style-type: lower-alpha;
255 ol.upperalpha {
256 list-style-type: upper-alpha;
258 ol.lowerroman {
259 list-style-type: lower-roman;
261 ol.upperroman {
262 list-style-type: upper-roman;
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;
272 tfoot {
273 font-weight: bold;
275 td > div.verse {
276 white-space: pre;
279 div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
283 div.hdlist tr {
284 padding-bottom: 15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
289 td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
295 td.hdlist2 {
296 vertical-align: top;
298 div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
303 .comment {
304 background: yellow;
307 .footnote, .footnoteref {
308 font-size: 0.8em;
311 span.footnote, span.footnoteref {
312 vertical-align: super;
315 #footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
320 #footnotes div.footnote {
321 margin: 0 0 5px 0;
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;
334 div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
339 div.colist td img {
340 margin-top: 0.3em;
343 @media print {
344 #footer-badges { display: none; }
347 #toc {
348 margin-bottom: 2.5em;
351 #toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
363 div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
367 div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
371 div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
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; }
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; }
410 span.big { font-size: 2em; }
411 span.small { font-size: 0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
421 * xhtml11 specific
423 * */
425 div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
429 div.tableblock > table {
430 border: 3px solid #527bbd;
432 thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
436 p.table {
437 margin-top: 0;
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock > table[frame="void"] {
441 border-style: none;
443 div.tableblock > table[frame="hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock > table[frame="vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
454 * html5 specific
456 * */
458 table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
462 thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
466 p.tableblock {
467 margin-top: 0;
469 table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
480 border-color: #527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
496 text-align: left;
498 th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
501 th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
505 th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: top;
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
517 * manpage specific
519 * */
521 body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
527 body.manpage h2 {
528 border-style: none;
530 body.manpage div.sectionbody {
531 margin-left: 3em;
534 @media print {
535 body.manpage div#toc { display: none; }
539 </style>
540 <script type="text/javascript">
541 /*<![CDATA[*/
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September 2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
552 * Version: 0.4
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.
558 /* modified by Troy D. Hanson, September 2006. License: GPL */
559 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
561 // toclevels = 1..4.
562 toc: function (toclevels) {
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);
572 return text;
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
578 this.toclevel = toclevel;
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
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);
594 iterate(i);
598 iterate(el);
599 return result;
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
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];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute("class")
614 && entry.getAttribute("class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
617 for (i = 0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
621 // Rebuild TOC entries.
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);
635 if (entries.length == 0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
650 var i;
651 var noteholder = document.getElementById("footnotes");
652 if (!noteholder) {
653 return;
655 var entriesToRemove = [];
656 for (i = 0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
659 entriesToRemove.push(entry);
661 for (i = 0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
665 // Rebuild footnote entries.
666 var cont = document.getElementById("content");
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++;
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);
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n + "'>" +
685 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
686 n + "</a>. " + note + "</div>";
687 var id =spans[i].getAttribute("id");
688 if (id != null) refs["#"+id] = n;
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>]";
708 install: function(toclevels) {
709 var timerId;
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
731 asciidoc.install();
732 /*]]>*/
733 </script>
734 </head>
735 <body class="manpage">
736 <div id="header">
737 <h1>
738 git-interpret-trailers(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-interpret-trailers -
743 Add or parse structured information in commit messages
744 </p>
745 </div>
746 </div>
747 <div id="content">
748 <div class="sect1">
749 <h2 id="_synopsis">SYNOPSIS</h2>
750 <div class="sectionbody">
751 <div class="verseblock">
752 <pre class="content"><em>git interpret-trailers</em> [--in-place] [--trim-empty]
753 [(--trailer (&lt;key&gt;|&lt;key-alias&gt;)[(=|:)&lt;value&gt;])&#8230;]
754 [--parse] [&lt;file&gt;&#8230;]</pre>
755 <div class="attribution">
756 </div></div>
757 </div>
758 </div>
759 <div class="sect1">
760 <h2 id="_description">DESCRIPTION</h2>
761 <div class="sectionbody">
762 <div class="paragraph"><p>Add or parse <em>trailer</em> lines that look similar to RFC 822 e-mail
763 headers, at the end of the otherwise free-form part of a commit
764 message. For example, in the following commit message</p></div>
765 <div class="listingblock">
766 <div class="content">
767 <pre><code>subject
769 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
771 Signed-off-by: Alice &lt;alice@example.com&gt;
772 Signed-off-by: Bob &lt;bob@example.com&gt;</code></pre>
773 </div></div>
774 <div class="paragraph"><p>the last two lines starting with "Signed-off-by" are trailers.</p></div>
775 <div class="paragraph"><p>This command reads commit messages from either the
776 &lt;file&gt; arguments or the standard input if no &lt;file&gt; is specified.
777 If <code>--parse</code> is specified, the output consists of the parsed trailers
778 coming from the input, without influencing them with any command line
779 options or configuration variables.</p></div>
780 <div class="paragraph"><p>Otherwise, this command applies <code>trailer.*</code> configuration variables
781 (which could potentially add new trailers, as well as reposition them),
782 as well as any command line arguments that can override configuration
783 variables (such as <code>--trailer=...</code> which could also add new trailers),
784 to each input file. The result is emitted on the standard output.</p></div>
785 <div class="paragraph"><p>This command can also operate on the output of <a href="git-format-patch.html">git-format-patch(1)</a>,
786 which is more elaborate than a plain commit message. Namely, such output
787 includes a commit message (as above), a "---" divider line, and a patch part.
788 For these inputs, the divider and patch parts are not modified by
789 this command and are emitted as is on the output, unless
790 <code>--no-divider</code> is specified.</p></div>
791 <div class="paragraph"><p>Some configuration variables control the way the <code>--trailer</code> arguments
792 are applied to each input and the way any existing trailer in
793 the input is changed. They also make it possible to
794 automatically add some trailers.</p></div>
795 <div class="paragraph"><p>By default, a <em>&lt;key&gt;=&lt;value&gt;</em> or <em>&lt;key&gt;:&lt;value&gt;</em> argument given
796 using <code>--trailer</code> will be appended after the existing trailers only if
797 the last trailer has a different (&lt;key&gt;, &lt;value&gt;) pair (or if there
798 is no existing trailer). The &lt;key&gt; and &lt;value&gt; parts will be trimmed
799 to remove starting and trailing whitespace, and the resulting trimmed
800 &lt;key&gt; and &lt;value&gt; will appear in the output like this:</p></div>
801 <div class="listingblock">
802 <div class="content">
803 <pre><code>key: value</code></pre>
804 </div></div>
805 <div class="paragraph"><p>This means that the trimmed &lt;key&gt; and &lt;value&gt; will be separated by
806 <code>': '</code> (one colon followed by one space).</p></div>
807 <div class="paragraph"><p>For convenience, a &lt;key-alias&gt; can be configured to make using <code>--trailer</code>
808 shorter to type on the command line. This can be configured using the
809 <em>trailer.&lt;key-alias&gt;.key</em> configuration variable. The &lt;keyAlias&gt; must be a prefix
810 of the full &lt;key&gt; string, although case sensitivity does not matter. For
811 example, if you have</p></div>
812 <div class="listingblock">
813 <div class="content">
814 <pre><code>trailer.sign.key "Signed-off-by: "</code></pre>
815 </div></div>
816 <div class="paragraph"><p>in your configuration, you only need to specify <code>--trailer="sign: foo"</code>
817 on the command line instead of <code>--trailer="Signed-off-by: foo"</code>.</p></div>
818 <div class="paragraph"><p>By default the new trailer will appear at the end of all the existing
819 trailers. If there is no existing trailer, the new trailer will appear
820 at the end of the input. A blank line will be added before the new
821 trailer if there isn&#8217;t one already.</p></div>
822 <div class="paragraph"><p>Existing trailers are extracted from the input by looking for
823 a group of one or more lines that (i) is all trailers, or (ii) contains at
824 least one Git-generated or user-configured trailer and consists of at
825 least 25% trailers.
826 The group must be preceded by one or more empty (or whitespace-only) lines.
827 The group must either be at the end of the input or be the last
828 non-whitespace lines before a line that starts with <em>---</em> (followed by a
829 space or the end of the line).</p></div>
830 <div class="paragraph"><p>When reading trailers, there can be no whitespace before or inside the
831 &lt;key&gt;, but any number of regular space and tab characters are allowed
832 between the &lt;key&gt; and the separator. There can be whitespaces before,
833 inside or after the &lt;value&gt;. The &lt;value&gt; may be split over multiple lines
834 with each subsequent line starting with at least one whitespace, like
835 the "folding" in RFC 822. Example:</p></div>
836 <div class="listingblock">
837 <div class="content">
838 <pre><code>key: This is a very long value, with spaces and
839 newlines in it.</code></pre>
840 </div></div>
841 <div class="paragraph"><p>Note that trailers do not follow (nor are they intended to follow) many of the
842 rules for RFC 822 headers. For example they do not follow the encoding rule.</p></div>
843 </div>
844 </div>
845 <div class="sect1">
846 <h2 id="_options">OPTIONS</h2>
847 <div class="sectionbody">
848 <div class="dlist"><dl>
849 <dt class="hdlist1">
850 --in-place
851 </dt>
852 <dd>
854 Edit the files in place.
855 </p>
856 </dd>
857 <dt class="hdlist1">
858 --trim-empty
859 </dt>
860 <dd>
862 If the &lt;value&gt; part of any trailer contains only whitespace,
863 the whole trailer will be removed from the output.
864 This applies to existing trailers as well as new trailers.
865 </p>
866 </dd>
867 <dt class="hdlist1">
868 --trailer &lt;key&gt;[(=|:)&lt;value&gt;]
869 </dt>
870 <dd>
872 Specify a (&lt;key&gt;, &lt;value&gt;) pair that should be applied as a
873 trailer to the inputs. See the description of this
874 command.
875 </p>
876 </dd>
877 <dt class="hdlist1">
878 --where &lt;placement&gt;
879 </dt>
880 <dt class="hdlist1">
881 --no-where
882 </dt>
883 <dd>
885 Specify where all new trailers will be added. A setting
886 provided with <em>--where</em> overrides the <code>trailer.where</code> and any
887 applicable <code>trailer.&lt;keyAlias&gt;.where</code> configuration variables
888 and applies to all <em>--trailer</em> options until the next occurrence of
889 <em>--where</em> or <em>--no-where</em>. Upon encountering <em>--no-where</em>, clear the
890 effect of any previous use of <em>--where</em>, such that the relevant configuration
891 variables are no longer overridden. Possible placements are <code>after</code>,
892 <code>before</code>, <code>end</code> or <code>start</code>.
893 </p>
894 </dd>
895 <dt class="hdlist1">
896 --if-exists &lt;action&gt;
897 </dt>
898 <dt class="hdlist1">
899 --no-if-exists
900 </dt>
901 <dd>
903 Specify what action will be performed when there is already at
904 least one trailer with the same &lt;key&gt; in the input. A setting
905 provided with <em>--if-exists</em> overrides the <code>trailer.ifExists</code> and any
906 applicable <code>trailer.&lt;keyAlias&gt;.ifExists</code> configuration variables
907 and applies to all <em>--trailer</em> options until the next occurrence of
908 <em>--if-exists</em> or <em>--no-if-exists</em>. Upon encountering '--no-if-exists, clear the
909 effect of any previous use of '--if-exists, such that the relevant configuration
910 variables are no longer overridden. Possible actions are <code>addIfDifferent</code>,
911 <code>addIfDifferentNeighbor</code>, <code>add</code>, <code>replace</code> and <code>doNothing</code>.
912 </p>
913 </dd>
914 <dt class="hdlist1">
915 --if-missing &lt;action&gt;
916 </dt>
917 <dt class="hdlist1">
918 --no-if-missing
919 </dt>
920 <dd>
922 Specify what action will be performed when there is no other
923 trailer with the same &lt;key&gt; in the input. A setting
924 provided with <em>--if-missing</em> overrides the <code>trailer.ifMissing</code> and any
925 applicable <code>trailer.&lt;keyAlias&gt;.ifMissing</code> configuration variables
926 and applies to all <em>--trailer</em> options until the next occurrence of
927 <em>--if-missing</em> or <em>--no-if-missing</em>. Upon encountering '--no-if-missing,
928 clear the effect of any previous use of '--if-missing, such that the relevant
929 configuration variables are no longer overridden. Possible actions are <code>doNothing</code>
930 or <code>add</code>.
931 </p>
932 </dd>
933 <dt class="hdlist1">
934 --only-trailers
935 </dt>
936 <dd>
938 Output only the trailers, not any other parts of the input.
939 </p>
940 </dd>
941 <dt class="hdlist1">
942 --only-input
943 </dt>
944 <dd>
946 Output only trailers that exist in the input; do not add any
947 from the command-line or by applying <code>trailer.*</code> configuration
948 variables.
949 </p>
950 </dd>
951 <dt class="hdlist1">
952 --unfold
953 </dt>
954 <dd>
956 If a trailer has a value that runs over multiple lines (aka "folded"),
957 reformat the value into a single line.
958 </p>
959 </dd>
960 <dt class="hdlist1">
961 --parse
962 </dt>
963 <dd>
965 A convenience alias for <code>--only-trailers --only-input
966 --unfold</code>. This makes it easier to only see the trailers coming from the
967 input without influencing them with any command line options or
968 configuration variables, while also making the output machine-friendly with
969 --unfold.
970 </p>
971 </dd>
972 <dt class="hdlist1">
973 --no-divider
974 </dt>
975 <dd>
977 Do not treat <code>---</code> as the end of the commit message. Use this
978 when you know your input contains just the commit message itself
979 (and not an email or the output of <code>git format-patch</code>).
980 </p>
981 </dd>
982 </dl></div>
983 </div>
984 </div>
985 <div class="sect1">
986 <h2 id="_configuration_variables">CONFIGURATION VARIABLES</h2>
987 <div class="sectionbody">
988 <div class="dlist"><dl>
989 <dt class="hdlist1">
990 trailer.separators
991 </dt>
992 <dd>
994 This option tells which characters are recognized as trailer
995 separators. By default only <em>:</em> is recognized as a trailer
996 separator, except that <em>=</em> is always accepted on the command
997 line for compatibility with other git commands.
998 </p>
999 <div class="paragraph"><p>The first character given by this option will be the default character
1000 used when another separator is not specified in the config for this
1001 trailer.</p></div>
1002 <div class="paragraph"><p>For example, if the value for this option is "%=$", then only lines
1003 using the format <em>&lt;key&gt;&lt;sep&gt;&lt;value&gt;</em> with &lt;sep&gt; containing <em>%</em>, <em>=</em>
1004 or <em>$</em> and then spaces will be considered trailers. And <em>%</em> will be
1005 the default separator used, so by default trailers will appear like:
1006 <em>&lt;key&gt;% &lt;value&gt;</em> (one percent sign and one space will appear between
1007 the key and the value).</p></div>
1008 </dd>
1009 <dt class="hdlist1">
1010 trailer.where
1011 </dt>
1012 <dd>
1014 This option tells where a new trailer will be added.
1015 </p>
1016 <div class="paragraph"><p>This can be <code>end</code>, which is the default, <code>start</code>, <code>after</code> or <code>before</code>.</p></div>
1017 <div class="paragraph"><p>If it is <code>end</code>, then each new trailer will appear at the end of the
1018 existing trailers.</p></div>
1019 <div class="paragraph"><p>If it is <code>start</code>, then each new trailer will appear at the start,
1020 instead of the end, of the existing trailers.</p></div>
1021 <div class="paragraph"><p>If it is <code>after</code>, then each new trailer will appear just after the
1022 last trailer with the same &lt;key&gt;.</p></div>
1023 <div class="paragraph"><p>If it is <code>before</code>, then each new trailer will appear just before the
1024 first trailer with the same &lt;key&gt;.</p></div>
1025 </dd>
1026 <dt class="hdlist1">
1027 trailer.ifexists
1028 </dt>
1029 <dd>
1031 This option makes it possible to choose what action will be
1032 performed when there is already at least one trailer with the
1033 same &lt;key&gt; in the input.
1034 </p>
1035 <div class="paragraph"><p>The valid values for this option are: <code>addIfDifferentNeighbor</code> (this
1036 is the default), <code>addIfDifferent</code>, <code>add</code>, <code>replace</code> or <code>doNothing</code>.</p></div>
1037 <div class="paragraph"><p>With <code>addIfDifferentNeighbor</code>, a new trailer will be added only if no
1038 trailer with the same (&lt;key&gt;, &lt;value&gt;) pair is above or below the line
1039 where the new trailer will be added.</p></div>
1040 <div class="paragraph"><p>With <code>addIfDifferent</code>, a new trailer will be added only if no trailer
1041 with the same (&lt;key&gt;, &lt;value&gt;) pair is already in the input.</p></div>
1042 <div class="paragraph"><p>With <code>add</code>, a new trailer will be added, even if some trailers with
1043 the same (&lt;key&gt;, &lt;value&gt;) pair are already in the input.</p></div>
1044 <div class="paragraph"><p>With <code>replace</code>, an existing trailer with the same &lt;key&gt; will be
1045 deleted and the new trailer will be added. The deleted trailer will be
1046 the closest one (with the same &lt;key&gt;) to the place where the new one
1047 will be added.</p></div>
1048 <div class="paragraph"><p>With <code>doNothing</code>, nothing will be done; that is no new trailer will be
1049 added if there is already one with the same &lt;key&gt; in the input.</p></div>
1050 </dd>
1051 <dt class="hdlist1">
1052 trailer.ifmissing
1053 </dt>
1054 <dd>
1056 This option makes it possible to choose what action will be
1057 performed when there is not yet any trailer with the same
1058 &lt;key&gt; in the input.
1059 </p>
1060 <div class="paragraph"><p>The valid values for this option are: <code>add</code> (this is the default) and
1061 <code>doNothing</code>.</p></div>
1062 <div class="paragraph"><p>With <code>add</code>, a new trailer will be added.</p></div>
1063 <div class="paragraph"><p>With <code>doNothing</code>, nothing will be done.</p></div>
1064 </dd>
1065 <dt class="hdlist1">
1066 trailer.&lt;keyAlias&gt;.key
1067 </dt>
1068 <dd>
1070 Defines a &lt;keyAlias&gt; for the &lt;key&gt;. The &lt;keyAlias&gt; must be a
1071 prefix (case does not matter) of the &lt;key&gt;. For example, in <code>git
1072 config trailer.ack.key "Acked-by"</code> the "Acked-by" is the &lt;key&gt; and
1073 the "ack" is the &lt;keyAlias&gt;. This configuration allows the shorter
1074 <code>--trailer "ack:..."</code> invocation on the command line using the "ack"
1075 &lt;keyAlias&gt; instead of the longer <code>--trailer "Acked-by:..."</code>.
1076 </p>
1077 <div class="paragraph"><p>At the end of the &lt;key&gt;, a separator can appear and then some
1078 space characters. By default the only valid separator is <em>:</em>,
1079 but this can be changed using the <code>trailer.separators</code> config
1080 variable.</p></div>
1081 <div class="paragraph"><p>If there is a separator in the key, then it overrides the default
1082 separator when adding the trailer.</p></div>
1083 </dd>
1084 <dt class="hdlist1">
1085 trailer.&lt;keyAlias&gt;.where
1086 </dt>
1087 <dd>
1089 This option takes the same values as the <em>trailer.where</em>
1090 configuration variable and it overrides what is specified by
1091 that option for trailers with the specified &lt;keyAlias&gt;.
1092 </p>
1093 </dd>
1094 <dt class="hdlist1">
1095 trailer.&lt;keyAlias&gt;.ifexists
1096 </dt>
1097 <dd>
1099 This option takes the same values as the <em>trailer.ifexists</em>
1100 configuration variable and it overrides what is specified by
1101 that option for trailers with the specified &lt;keyAlias&gt;.
1102 </p>
1103 </dd>
1104 <dt class="hdlist1">
1105 trailer.&lt;keyAlias&gt;.ifmissing
1106 </dt>
1107 <dd>
1109 This option takes the same values as the <em>trailer.ifmissing</em>
1110 configuration variable and it overrides what is specified by
1111 that option for trailers with the specified &lt;keyAlias&gt;.
1112 </p>
1113 </dd>
1114 <dt class="hdlist1">
1115 trailer.&lt;keyAlias&gt;.command
1116 </dt>
1117 <dd>
1119 Deprecated in favor of <em>trailer.&lt;keyAlias&gt;.cmd</em>.
1120 This option behaves in the same way as <em>trailer.&lt;keyAlias&gt;.cmd</em>, except
1121 that it doesn&#8217;t pass anything as argument to the specified command.
1122 Instead the first occurrence of substring $ARG is replaced by the
1123 &lt;value&gt; that would be passed as argument.
1124 </p>
1125 <div class="paragraph"><p>Note that $ARG in the user&#8217;s command is
1126 only replaced once and that the original way of replacing $ARG is not safe.</p></div>
1127 <div class="paragraph"><p>When both <em>trailer.&lt;keyAlias&gt;.cmd</em> and <em>trailer.&lt;keyAlias&gt;.command</em> are given
1128 for the same &lt;keyAlias&gt;, <em>trailer.&lt;keyAlias&gt;.cmd</em> is used and
1129 <em>trailer.&lt;keyAlias&gt;.command</em> is ignored.</p></div>
1130 </dd>
1131 <dt class="hdlist1">
1132 trailer.&lt;keyAlias&gt;.cmd
1133 </dt>
1134 <dd>
1136 This option can be used to specify a shell command that will be called
1137 once to automatically add a trailer with the specified &lt;keyAlias&gt;, and then
1138 called each time a <em>--trailer &lt;keyAlias&gt;=&lt;value&gt;</em> argument is specified to
1139 modify the &lt;value&gt; of the trailer that this option would produce.
1140 </p>
1141 <div class="paragraph"><p>When the specified command is first called to add a trailer
1142 with the specified &lt;keyAlias&gt;, the behavior is as if a special
1143 <em>--trailer &lt;keyAlias&gt;=&lt;value&gt;</em> argument was added at the beginning
1144 of the "git interpret-trailers" command, where &lt;value&gt;
1145 is taken to be the standard output of the command with any
1146 leading and trailing whitespace trimmed off.</p></div>
1147 <div class="paragraph"><p>If some <em>--trailer &lt;keyAlias&gt;=&lt;value&gt;</em> arguments are also passed
1148 on the command line, the command is called again once for each
1149 of these arguments with the same &lt;keyAlias&gt;. And the &lt;value&gt; part
1150 of these arguments, if any, will be passed to the command as its
1151 first argument. This way the command can produce a &lt;value&gt; computed
1152 from the &lt;value&gt; passed in the <em>--trailer &lt;keyAlias&gt;=&lt;value&gt;</em> argument.</p></div>
1153 </dd>
1154 </dl></div>
1155 </div>
1156 </div>
1157 <div class="sect1">
1158 <h2 id="_examples">EXAMPLES</h2>
1159 <div class="sectionbody">
1160 <div class="ulist"><ul>
1161 <li>
1163 Configure a <em>sign</em> trailer with a <em>Signed-off-by</em> key, and then
1164 add two of these trailers to a commit message file:
1165 </p>
1166 <div class="listingblock">
1167 <div class="content">
1168 <pre><code>$ git config trailer.sign.key "Signed-off-by"
1169 $ cat msg.txt
1170 subject
1172 body text
1173 $ git interpret-trailers --trailer 'sign: Alice &lt;alice@example.com&gt;' --trailer 'sign: Bob &lt;bob@example.com&gt;' &lt;msg.txt
1174 subject
1176 body text
1178 Signed-off-by: Alice &lt;alice@example.com&gt;
1179 Signed-off-by: Bob &lt;bob@example.com&gt;</code></pre>
1180 </div></div>
1181 </li>
1182 <li>
1184 Use the <code>--in-place</code> option to edit a commit message file in place:
1185 </p>
1186 <div class="listingblock">
1187 <div class="content">
1188 <pre><code>$ cat msg.txt
1189 subject
1191 body text
1193 Signed-off-by: Bob &lt;bob@example.com&gt;
1194 $ git interpret-trailers --trailer 'Acked-by: Alice &lt;alice@example.com&gt;' --in-place msg.txt
1195 $ cat msg.txt
1196 subject
1198 body text
1200 Signed-off-by: Bob &lt;bob@example.com&gt;
1201 Acked-by: Alice &lt;alice@example.com&gt;</code></pre>
1202 </div></div>
1203 </li>
1204 <li>
1206 Extract the last commit as a patch, and add a <em>Cc</em> and a
1207 <em>Reviewed-by</em> trailer to it:
1208 </p>
1209 <div class="listingblock">
1210 <div class="content">
1211 <pre><code>$ git format-patch -1
1212 0001-foo.patch
1213 $ git interpret-trailers --trailer 'Cc: Alice &lt;alice@example.com&gt;' --trailer 'Reviewed-by: Bob &lt;bob@example.com&gt;' 0001-foo.patch &gt;0001-bar.patch</code></pre>
1214 </div></div>
1215 </li>
1216 <li>
1218 Configure a <em>sign</em> trailer with a command to automatically add a
1219 'Signed-off-by: ' with the author information only if there is no
1220 'Signed-off-by: ' already, and show how it works:
1221 </p>
1222 <div class="listingblock">
1223 <div class="content">
1224 <pre><code>$ cat msg1.txt
1225 subject
1227 body text
1228 $ git config trailer.sign.key "Signed-off-by: "
1229 $ git config trailer.sign.ifmissing add
1230 $ git config trailer.sign.ifexists doNothing
1231 $ git config trailer.sign.cmd 'echo "$(git config user.name) &lt;$(git config user.email)&gt;"'
1232 $ git interpret-trailers --trailer sign &lt;msg1.txt
1233 subject
1235 body text
1237 Signed-off-by: Bob &lt;bob@example.com&gt;
1238 $ cat msg2.txt
1239 subject
1241 body text
1243 Signed-off-by: Alice &lt;alice@example.com&gt;
1244 $ git interpret-trailers --trailer sign &lt;msg2.txt
1245 subject
1247 body text
1249 Signed-off-by: Alice &lt;alice@example.com&gt;</code></pre>
1250 </div></div>
1251 </li>
1252 <li>
1254 Configure a <em>fix</em> trailer with a key that contains a <em>#</em> and no
1255 space after this character, and show how it works:
1256 </p>
1257 <div class="listingblock">
1258 <div class="content">
1259 <pre><code>$ git config trailer.separators ":#"
1260 $ git config trailer.fix.key "Fix #"
1261 $ echo "subject" | git interpret-trailers --trailer fix=42
1262 subject
1264 Fix #42</code></pre>
1265 </div></div>
1266 </li>
1267 <li>
1269 Configure a <em>help</em> trailer with a cmd use a script <code>glog-find-author</code>
1270 which search specified author identity from git log in git repository
1271 and show how it works:
1272 </p>
1273 <div class="listingblock">
1274 <div class="content">
1275 <pre><code>$ cat ~/bin/glog-find-author
1276 #!/bin/sh
1277 test -n "$1" &amp;&amp; git log --author="$1" --pretty="%an &lt;%ae&gt;" -1 || true
1278 $ cat msg.txt
1279 subject
1281 body text
1282 $ git config trailer.help.key "Helped-by: "
1283 $ git config trailer.help.ifExists "addIfDifferentNeighbor"
1284 $ git config trailer.help.cmd "~/bin/glog-find-author"
1285 $ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" &lt;msg.txt
1286 subject
1288 body text
1290 Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
1291 Helped-by: Christian Couder &lt;christian.couder@gmail.com&gt;</code></pre>
1292 </div></div>
1293 </li>
1294 <li>
1296 Configure a <em>ref</em> trailer with a cmd use a script <code>glog-grep</code>
1297 to grep last relevant commit from git log in the git repository
1298 and show how it works:
1299 </p>
1300 <div class="listingblock">
1301 <div class="content">
1302 <pre><code>$ cat ~/bin/glog-grep
1303 #!/bin/sh
1304 test -n "$1" &amp;&amp; git log --grep "$1" --pretty=reference -1 || true
1305 $ cat msg.txt
1306 subject
1308 body text
1309 $ git config trailer.ref.key "Reference-to: "
1310 $ git config trailer.ref.ifExists "replace"
1311 $ git config trailer.ref.cmd "~/bin/glog-grep"
1312 $ git interpret-trailers --trailer="ref:Add copyright notices." &lt;msg.txt
1313 subject
1315 body text
1317 Reference-to: 8bc9a0c769 (Add copyright notices., 2005-04-07)</code></pre>
1318 </div></div>
1319 </li>
1320 <li>
1322 Configure a <em>see</em> trailer with a command to show the subject of a
1323 commit that is related, and show how it works:
1324 </p>
1325 <div class="listingblock">
1326 <div class="content">
1327 <pre><code>$ cat msg.txt
1328 subject
1330 body text
1332 see: HEAD~2
1333 $ cat ~/bin/glog-ref
1334 #!/bin/sh
1335 git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14
1336 $ git config trailer.see.key "See-also: "
1337 $ git config trailer.see.ifExists "replace"
1338 $ git config trailer.see.ifMissing "doNothing"
1339 $ git config trailer.see.cmd "glog-ref"
1340 $ git interpret-trailers --trailer=see &lt;msg.txt
1341 subject
1343 body text
1345 See-also: fe3187489d69c4 (subject of related commit)</code></pre>
1346 </div></div>
1347 </li>
1348 <li>
1350 Configure a commit template with some trailers with empty values
1351 (using sed to show and keep the trailing spaces at the end of the
1352 trailers), then configure a commit-msg hook that uses
1353 <em>git interpret-trailers</em> to remove trailers with empty values and
1354 to add a <em>git-version</em> trailer:
1355 </p>
1356 <div class="listingblock">
1357 <div class="content">
1358 <pre><code>$ cat temp.txt
1359 ***subject***
1361 ***message***
1363 Fixes: Z
1364 Cc: Z
1365 Reviewed-by: Z
1366 Signed-off-by: Z
1367 $ sed -e 's/ Z$/ /' temp.txt &gt; commit_template.txt
1368 $ git config commit.template commit_template.txt
1369 $ cat .git/hooks/commit-msg
1370 #!/bin/sh
1371 git interpret-trailers --trim-empty --trailer "git-version: \$(git describe)" "\$1" &gt; "\$1.new"
1372 mv "\$1.new" "\$1"
1373 $ chmod +x .git/hooks/commit-msg</code></pre>
1374 </div></div>
1375 </li>
1376 </ul></div>
1377 </div>
1378 </div>
1379 <div class="sect1">
1380 <h2 id="_see_also">SEE ALSO</h2>
1381 <div class="sectionbody">
1382 <div class="paragraph"><p><a href="git-commit.html">git-commit(1)</a>, <a href="git-format-patch.html">git-format-patch(1)</a>, <a href="git-config.html">git-config(1)</a></p></div>
1383 </div>
1384 </div>
1385 <div class="sect1">
1386 <h2 id="_git">GIT</h2>
1387 <div class="sectionbody">
1388 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1389 </div>
1390 </div>
1391 </div>
1392 <div id="footnotes"><hr /></div>
1393 <div id="footer">
1394 <div id="footer-text">
1395 Last updated
1396 2024-03-25 17:24:49 PDT
1397 </div>
1398 </div>
1399 </body>
1400 </html>