blob: a1e471e5585a34cca20bcf2a129de2c11995e38d [file] [log] [blame]
Junio C Hamanoe0238c22012-02-23 22:45:501<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
Junio C Hamano9d971152012-12-19 00:43:115<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
Junio C Hamano61525f92014-01-17 22:46:496<meta name="generator" content="AsciiDoc 8.6.6" />
Junio C Hamanoe0238c22012-02-23 22:45:507<title>config API</title>
8<style type="text/css">
Junio C Hamano9d971152012-12-19 00:43:119/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
10
11/* Default font. */
12body {
13 font-family: Georgia,serif;
14}
15
16/* Title font. */
17h1, h2, h3, h4, h5, h6,
18div.title, caption.title,
19thead, p.table.header,
20#toctitle,
21#author, #revnumber, #revdate, #revremark,
22#footer {
23 font-family: Arial,Helvetica,sans-serif;
Junio C Hamanoe0238c22012-02-23 22:45:5024}
25
26body {
27 margin: 1em 5% 1em 5%;
28}
29
30a {
31 color: blue;
32 text-decoration: underline;
33}
34a:visited {
35 color: fuchsia;
36}
37
38em {
39 font-style: italic;
40 color: navy;
41}
42
43strong {
44 font-weight: bold;
45 color: #083194;
46}
47
Junio C Hamanoe0238c22012-02-23 22:45:5048h1, h2, h3, h4, h5, h6 {
49 color: #527bbd;
Junio C Hamanoe0238c22012-02-23 22:45:5050 margin-top: 1.2em;
51 margin-bottom: 0.5em;
52 line-height: 1.3;
53}
54
55h1, h2, h3 {
56 border-bottom: 2px solid silver;
57}
58h2 {
59 padding-top: 0.5em;
60}
61h3 {
62 float: left;
63}
64h3 + * {
65 clear: left;
66}
Junio C Hamano9d971152012-12-19 00:43:1167h5 {
68 font-size: 1.0em;
69}
Junio C Hamanoe0238c22012-02-23 22:45:5070
71div.sectionbody {
Junio C Hamanoe0238c22012-02-23 22:45:5072 margin-left: 0;
73}
74
75hr {
76 border: 1px solid silver;
77}
78
79p {
80 margin-top: 0.5em;
81 margin-bottom: 0.5em;
82}
83
84ul, ol, li > p {
85 margin-top: 0;
86}
Junio C Hamano9d971152012-12-19 00:43:1187ul > li { color: #aaa; }
88ul > li > * { color: black; }
Junio C Hamanoe0238c22012-02-23 22:45:5089
Junio C Hamano61525f92014-01-17 22:46:4990pre {
Junio C Hamanoe0238c22012-02-23 22:45:5091 padding: 0;
92 margin: 0;
93}
94
Junio C Hamano9d971152012-12-19 00:43:1195#author {
Junio C Hamanoe0238c22012-02-23 22:45:5096 color: #527bbd;
Junio C Hamanoe0238c22012-02-23 22:45:5097 font-weight: bold;
98 font-size: 1.1em;
99}
Junio C Hamano9d971152012-12-19 00:43:11100#email {
Junio C Hamanoe0238c22012-02-23 22:45:50101}
Junio C Hamano9d971152012-12-19 00:43:11102#revnumber, #revdate, #revremark {
Junio C Hamanoe0238c22012-02-23 22:45:50103}
104
Junio C Hamano9d971152012-12-19 00:43:11105#footer {
Junio C Hamanoe0238c22012-02-23 22:45:50106 font-size: small;
107 border-top: 2px solid silver;
108 padding-top: 0.5em;
109 margin-top: 4.0em;
110}
Junio C Hamano9d971152012-12-19 00:43:11111#footer-text {
Junio C Hamanoe0238c22012-02-23 22:45:50112 float: left;
113 padding-bottom: 0.5em;
114}
Junio C Hamano9d971152012-12-19 00:43:11115#footer-badges {
Junio C Hamanoe0238c22012-02-23 22:45:50116 float: right;
117 padding-bottom: 0.5em;
118}
119
Junio C Hamano9d971152012-12-19 00:43:11120#preamble {
Junio C Hamanoe0238c22012-02-23 22:45:50121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
123}
Junio C Hamano9d971152012-12-19 00:43:11124div.imageblock, div.exampleblock, div.verseblock,
Junio C Hamanoe0238c22012-02-23 22:45:50125div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
126div.admonitionblock {
127 margin-top: 1.0em;
128 margin-bottom: 1.5em;
129}
130div.admonitionblock {
131 margin-top: 2.0em;
132 margin-bottom: 2.0em;
133 margin-right: 10%;
134 color: #606060;
135}
136
137div.content { /* Block element content. */
138 padding: 0;
139}
140
141/* Block element titles. */
142div.title, caption.title {
143 color: #527bbd;
Junio C Hamanoe0238c22012-02-23 22:45:50144 font-weight: bold;
145 text-align: left;
146 margin-top: 1.0em;
147 margin-bottom: 0.5em;
148}
149div.title + * {
150 margin-top: 0;
151}
152
153td div.title:first-child {
154 margin-top: 0.0em;
155}
156div.content div.title:first-child {
157 margin-top: 0.0em;
158}
159div.content + div.title {
160 margin-top: 0.0em;
161}
162
163div.sidebarblock > div.content {
164 background: #ffffee;
Junio C Hamano9d971152012-12-19 00:43:11165 border: 1px solid #dddddd;
166 border-left: 4px solid #f0f0f0;
Junio C Hamanoe0238c22012-02-23 22:45:50167 padding: 0.5em;
168}
169
170div.listingblock > div.content {
Junio C Hamano9d971152012-12-19 00:43:11171 border: 1px solid #dddddd;
172 border-left: 5px solid #f0f0f0;
173 background: #f8f8f8;
Junio C Hamanoe0238c22012-02-23 22:45:50174 padding: 0.5em;
175}
176
177div.quoteblock, div.verseblock {
178 padding-left: 1.0em;
179 margin-left: 1.0em;
180 margin-right: 10%;
Junio C Hamano9d971152012-12-19 00:43:11181 border-left: 5px solid #f0f0f0;
182 color: #888;
Junio C Hamanoe0238c22012-02-23 22:45:50183}
184
185div.quoteblock > div.attribution {
186 padding-top: 0.5em;
187 text-align: right;
188}
189
Junio C Hamano9d971152012-12-19 00:43:11190div.verseblock > pre.content {
191 font-family: inherit;
192 font-size: inherit;
Junio C Hamanoe0238c22012-02-23 22:45:50193}
194div.verseblock > div.attribution {
195 padding-top: 0.75em;
196 text-align: left;
197}
198/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
199div.verseblock + div.attribution {
200 text-align: left;
201}
202
203div.admonitionblock .icon {
204 vertical-align: top;
205 font-size: 1.1em;
206 font-weight: bold;
207 text-decoration: underline;
208 color: #527bbd;
209 padding-right: 0.5em;
210}
211div.admonitionblock td.content {
212 padding-left: 0.5em;
213 border-left: 3px solid #dddddd;
214}
215
216div.exampleblock > div.content {
217 border-left: 3px solid #dddddd;
218 padding-left: 0.5em;
219}
220
221div.imageblock div.content { padding-left: 0; }
222span.image img { border-style: none; }
223a.image:visited { color: white; }
224
225dl {
226 margin-top: 0.8em;
227 margin-bottom: 0.8em;
228}
229dt {
230 margin-top: 0.5em;
231 margin-bottom: 0;
232 font-style: normal;
233 color: navy;
234}
235dd > *:first-child {
236 margin-top: 0.1em;
237}
238
239ul, ol {
240 list-style-position: outside;
241}
242ol.arabic {
243 list-style-type: decimal;
244}
245ol.loweralpha {
246 list-style-type: lower-alpha;
247}
248ol.upperalpha {
249 list-style-type: upper-alpha;
250}
251ol.lowerroman {
252 list-style-type: lower-roman;
253}
254ol.upperroman {
255 list-style-type: upper-roman;
256}
257
258div.compact ul, div.compact ol,
259div.compact p, div.compact p,
260div.compact div, div.compact div {
261 margin-top: 0.1em;
262 margin-bottom: 0.1em;
263}
264
Junio C Hamanoe0238c22012-02-23 22:45:50265tfoot {
266 font-weight: bold;
267}
268td > div.verse {
269 white-space: pre;
270}
Junio C Hamanoe0238c22012-02-23 22:45:50271
272div.hdlist {
273 margin-top: 0.8em;
274 margin-bottom: 0.8em;
275}
276div.hdlist tr {
277 padding-bottom: 15px;
278}
279dt.hdlist1.strong, td.hdlist1.strong {
280 font-weight: bold;
281}
282td.hdlist1 {
283 vertical-align: top;
284 font-style: normal;
285 padding-right: 0.8em;
286 color: navy;
287}
288td.hdlist2 {
289 vertical-align: top;
290}
291div.hdlist.compact tr {
292 margin: 0;
293 padding-bottom: 0;
294}
295
296.comment {
297 background: yellow;
298}
299
300.footnote, .footnoteref {
301 font-size: 0.8em;
302}
303
304span.footnote, span.footnoteref {
305 vertical-align: super;
306}
307
308#footnotes {
309 margin: 20px 0 20px 0;
310 padding: 7px 0 0 0;
311}
312
313#footnotes div.footnote {
314 margin: 0 0 5px 0;
315}
316
317#footnotes hr {
318 border: none;
319 border-top: 1px solid silver;
320 height: 1px;
321 text-align: left;
322 margin-left: 0;
323 width: 20%;
324 min-width: 100px;
325}
326
Junio C Hamano9d971152012-12-19 00:43:11327div.colist td {
328 padding-right: 0.5em;
329 padding-bottom: 0.3em;
330 vertical-align: top;
331}
332div.colist td img {
333 margin-top: 0.3em;
Junio C Hamanoe0238c22012-02-23 22:45:50334}
335
Junio C Hamano9d971152012-12-19 00:43:11336@media print {
337 #footer-badges { display: none; }
338}
339
340#toc {
Junio C Hamanoe0238c22012-02-23 22:45:50341 margin-bottom: 2.5em;
342}
343
Junio C Hamano9d971152012-12-19 00:43:11344#toctitle {
Junio C Hamanoe0238c22012-02-23 22:45:50345 color: #527bbd;
Junio C Hamanoe0238c22012-02-23 22:45:50346 font-size: 1.1em;
347 font-weight: bold;
348 margin-top: 1.0em;
349 margin-bottom: 0.1em;
350}
351
Junio C Hamano61525f92014-01-17 22:46:49352div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
Junio C Hamanoe0238c22012-02-23 22:45:50353 margin-top: 0;
354 margin-bottom: 0;
355}
356div.toclevel2 {
357 margin-left: 2em;
358 font-size: 0.9em;
359}
360div.toclevel3 {
361 margin-left: 4em;
362 font-size: 0.9em;
363}
364div.toclevel4 {
365 margin-left: 6em;
366 font-size: 0.9em;
367}
Junio C Hamanoe0238c22012-02-23 22:45:50368
Junio C Hamano9d971152012-12-19 00:43:11369span.aqua { color: aqua; }
370span.black { color: black; }
371span.blue { color: blue; }
372span.fuchsia { color: fuchsia; }
373span.gray { color: gray; }
374span.green { color: green; }
375span.lime { color: lime; }
376span.maroon { color: maroon; }
377span.navy { color: navy; }
378span.olive { color: olive; }
379span.purple { color: purple; }
380span.red { color: red; }
381span.silver { color: silver; }
382span.teal { color: teal; }
383span.white { color: white; }
384span.yellow { color: yellow; }
385
386span.aqua-background { background: aqua; }
387span.black-background { background: black; }
388span.blue-background { background: blue; }
389span.fuchsia-background { background: fuchsia; }
390span.gray-background { background: gray; }
391span.green-background { background: green; }
392span.lime-background { background: lime; }
393span.maroon-background { background: maroon; }
394span.navy-background { background: navy; }
395span.olive-background { background: olive; }
396span.purple-background { background: purple; }
397span.red-background { background: red; }
398span.silver-background { background: silver; }
399span.teal-background { background: teal; }
400span.white-background { background: white; }
401span.yellow-background { background: yellow; }
402
403span.big { font-size: 2em; }
404span.small { font-size: 0.6em; }
405
406span.underline { text-decoration: underline; }
407span.overline { text-decoration: overline; }
408span.line-through { text-decoration: line-through; }
409
Junio C Hamano9d971152012-12-19 00:43:11410
411/*
412 * xhtml11 specific
413 *
414 * */
415
Junio C Hamano61525f92014-01-17 22:46:49416tt {
417 font-family: monospace;
418 font-size: inherit;
419 color: navy;
420}
421
Junio C Hamano9d971152012-12-19 00:43:11422div.tableblock {
423 margin-top: 1.0em;
424 margin-bottom: 1.5em;
Junio C Hamanoe0238c22012-02-23 22:45:50425}
Junio C Hamano9d971152012-12-19 00:43:11426div.tableblock > table {
427 border: 3px solid #527bbd;
428}
429thead, p.table.header {
Junio C Hamanoe0238c22012-02-23 22:45:50430 font-weight: bold;
Junio C Hamano9d971152012-12-19 00:43:11431 color: #527bbd;
432}
433p.table {
434 margin-top: 0;
435}
436/* Because the table frame attribute is overriden by CSS in most browsers. */
437div.tableblock > table[frame="void"] {
438 border-style: none;
439}
440div.tableblock > table[frame="hsides"] {
441 border-left-style: none;
442 border-right-style: none;
443}
444div.tableblock > table[frame="vsides"] {
445 border-top-style: none;
446 border-bottom-style: none;
Junio C Hamanoe0238c22012-02-23 22:45:50447}
448
Junio C Hamano9d971152012-12-19 00:43:11449
450/*
451 * html5 specific
452 *
453 * */
454
Junio C Hamano61525f92014-01-17 22:46:49455.monospaced {
456 font-family: monospace;
457 font-size: inherit;
458 color: navy;
459}
460
Junio C Hamano9d971152012-12-19 00:43:11461table.tableblock {
462 margin-top: 1.0em;
463 margin-bottom: 1.5em;
464}
465thead, p.tableblock.header {
466 font-weight: bold;
467 color: #527bbd;
468}
469p.tableblock {
470 margin-top: 0;
471}
472table.tableblock {
473 border-width: 3px;
474 border-spacing: 0px;
475 border-style: solid;
476 border-color: #527bbd;
477 border-collapse: collapse;
478}
479th.tableblock, td.tableblock {
480 border-width: 1px;
481 padding: 4px;
482 border-style: solid;
483 border-color: #527bbd;
Junio C Hamanoe0238c22012-02-23 22:45:50484}
485
Junio C Hamano9d971152012-12-19 00:43:11486table.tableblock.frame-topbot {
487 border-left-style: hidden;
488 border-right-style: hidden;
489}
490table.tableblock.frame-sides {
491 border-top-style: hidden;
492 border-bottom-style: hidden;
493}
494table.tableblock.frame-none {
495 border-style: hidden;
496}
497
498th.tableblock.halign-left, td.tableblock.halign-left {
499 text-align: left;
500}
501th.tableblock.halign-center, td.tableblock.halign-center {
502 text-align: center;
503}
504th.tableblock.halign-right, td.tableblock.halign-right {
Junio C Hamanoe0238c22012-02-23 22:45:50505 text-align: right;
506}
507
Junio C Hamano9d971152012-12-19 00:43:11508th.tableblock.valign-top, td.tableblock.valign-top {
509 vertical-align: top;
Junio C Hamanoe0238c22012-02-23 22:45:50510}
Junio C Hamano9d971152012-12-19 00:43:11511th.tableblock.valign-middle, td.tableblock.valign-middle {
512 vertical-align: middle;
513}
514th.tableblock.valign-bottom, td.tableblock.valign-bottom {
515 vertical-align: bottom;
Junio C Hamanoe0238c22012-02-23 22:45:50516}
517
Junio C Hamano9d971152012-12-19 00:43:11518
519/*
520 * manpage specific
521 *
522 * */
523
524body.manpage h1 {
525 padding-top: 0.5em;
526 padding-bottom: 0.5em;
527 border-top: 2px solid silver;
528 border-bottom: 2px solid silver;
529}
530body.manpage h2 {
531 border-style: none;
532}
533body.manpage div.sectionbody {
534 margin-left: 3em;
Junio C Hamanoe0238c22012-02-23 22:45:50535}
536
Junio C Hamano9d971152012-12-19 00:43:11537@media print {
538 body.manpage div#toc { display: none; }
539}
Junio C Hamanoe0238c22012-02-23 22:45:50540</style>
541<script type="text/javascript">
542/*<![CDATA[*/
Junio C Hamanoe0238c22012-02-23 22:45:50543var asciidoc = { // Namespace.
544
545/////////////////////////////////////////////////////////////////////
546// Table Of Contents generator
547/////////////////////////////////////////////////////////////////////
548
549/* Author: Mihai Bazon, September 2002
550 * http://students.infoiasi.ro/~mishoo
551 *
552 * Table Of Content generator
553 * Version: 0.4
554 *
555 * Feel free to use this script under the terms of the GNU General Public
556 * License, as long as you do not remove or alter this notice.
557 */
558
559 /* modified by Troy D. Hanson, September 2006. License: GPL */
560 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
561
562// toclevels = 1..4.
563toc: function (toclevels) {
564
565 function getText(el) {
566 var text = "";
567 for (var i = el.firstChild; i != null; i = i.nextSibling) {
568 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
569 text += i.data;
570 else if (i.firstChild != null)
571 text += getText(i);
572 }
573 return text;
574 }
575
576 function TocEntry(el, text, toclevel) {
577 this.element = el;
578 this.text = text;
579 this.toclevel = toclevel;
580 }
581
582 function tocEntries(el, toclevels) {
583 var result = new Array;
Junio C Hamano61525f92014-01-17 22:46:49584 var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
Junio C Hamanoe0238c22012-02-23 22:45:50585 // Function that scans the DOM tree for header elements (the DOM2
586 // nodeIterator API would be a better technique but not supported by all
587 // browsers).
588 var iterate = function (el) {
589 for (var i = el.firstChild; i != null; i = i.nextSibling) {
590 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
591 var mo = re.exec(i.tagName);
592 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
593 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
594 }
595 iterate(i);
596 }
597 }
598 }
599 iterate(el);
600 return result;
601 }
602
603 var toc = document.getElementById("toc");
Junio C Hamano9d971152012-12-19 00:43:11604 if (!toc) {
605 return;
606 }
607
608 // Delete existing TOC entries in case we're reloading the TOC.
609 var tocEntriesToRemove = [];
610 var i;
611 for (i = 0; i < toc.childNodes.length; i++) {
612 var entry = toc.childNodes[i];
Junio C Hamano61525f92014-01-17 22:46:49613 if (entry.nodeName == 'div'
Junio C Hamano9d971152012-12-19 00:43:11614 && entry.getAttribute("class")
615 && entry.getAttribute("class").match(/^toclevel/))
616 tocEntriesToRemove.push(entry);
617 }
618 for (i = 0; i < tocEntriesToRemove.length; i++) {
619 toc.removeChild(tocEntriesToRemove[i]);
620 }
621
622 // Rebuild TOC entries.
Junio C Hamanoe0238c22012-02-23 22:45:50623 var entries = tocEntries(document.getElementById("content"), toclevels);
624 for (var i = 0; i < entries.length; ++i) {
625 var entry = entries[i];
626 if (entry.element.id == "")
627 entry.element.id = "_toc_" + i;
628 var a = document.createElement("a");
629 a.href = "#" + entry.element.id;
630 a.appendChild(document.createTextNode(entry.text));
631 var div = document.createElement("div");
632 div.appendChild(a);
633 div.className = "toclevel" + entry.toclevel;
634 toc.appendChild(div);
635 }
636 if (entries.length == 0)
637 toc.parentNode.removeChild(toc);
638},
639
640
641/////////////////////////////////////////////////////////////////////
642// Footnotes generator
643/////////////////////////////////////////////////////////////////////
644
645/* Based on footnote generation code from:
646 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
647 */
648
649footnotes: function () {
Junio C Hamano9d971152012-12-19 00:43:11650 // Delete existing footnote entries in case we're reloading the footnodes.
651 var i;
Junio C Hamanoe0238c22012-02-23 22:45:50652 var noteholder = document.getElementById("footnotes");
Junio C Hamano9d971152012-12-19 00:43:11653 if (!noteholder) {
654 return;
655 }
656 var entriesToRemove = [];
657 for (i = 0; i < noteholder.childNodes.length; i++) {
658 var entry = noteholder.childNodes[i];
Junio C Hamano61525f92014-01-17 22:46:49659 if (entry.nodeName == 'div' && entry.getAttribute("class") == "footnote")
Junio C Hamano9d971152012-12-19 00:43:11660 entriesToRemove.push(entry);
661 }
662 for (i = 0; i < entriesToRemove.length; i++) {
663 noteholder.removeChild(entriesToRemove[i]);
664 }
665
666 // Rebuild footnote entries.
667 var cont = document.getElementById("content");
Junio C Hamanoe0238c22012-02-23 22:45:50668 var spans = cont.getElementsByTagName("span");
669 var refs = {};
670 var n = 0;
671 for (i=0; i<spans.length; i++) {
672 if (spans[i].className == "footnote") {
673 n++;
Junio C Hamano9d971152012-12-19 00:43:11674 var note = spans[i].getAttribute("data-note");
675 if (!note) {
676 // Use [\s\S] in place of . so multi-line matches work.
677 // Because JavaScript has no s (dotall) regex flag.
678 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
679 spans[i].innerHTML =
680 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
681 "' title='View footnote' class='footnote'>" + n + "</a>]";
682 spans[i].setAttribute("data-note", note);
683 }
Junio C Hamanoe0238c22012-02-23 22:45:50684 noteholder.innerHTML +=
685 "<div class='footnote' id='_footnote_" + n + "'>" +
686 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
687 n + "</a>. " + note + "</div>";
Junio C Hamanoe0238c22012-02-23 22:45:50688 var id =spans[i].getAttribute("id");
689 if (id != null) refs["#"+id] = n;
690 }
691 }
692 if (n == 0)
693 noteholder.parentNode.removeChild(noteholder);
694 else {
695 // Process footnoterefs.
696 for (i=0; i<spans.length; i++) {
697 if (spans[i].className == "footnoteref") {
698 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
699 href = href.match(/#.*/)[0]; // Because IE return full URL.
700 n = refs[href];
701 spans[i].innerHTML =
702 "[<a href='#_footnote_" + n +
703 "' title='View footnote' class='footnote'>" + n + "</a>]";
704 }
705 }
706 }
Junio C Hamano9d971152012-12-19 00:43:11707},
708
709install: function(toclevels) {
710 var timerId;
711
712 function reinstall() {
713 asciidoc.footnotes();
714 if (toclevels) {
715 asciidoc.toc(toclevels);
716 }
717 }
718
719 function reinstallAndRemoveTimer() {
720 clearInterval(timerId);
721 reinstall();
722 }
723
724 timerId = setInterval(reinstall, 500);
725 if (document.addEventListener)
726 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
727 else
728 window.onload = reinstallAndRemoveTimer;
Junio C Hamanoe0238c22012-02-23 22:45:50729}
730
731}
Junio C Hamano9d971152012-12-19 00:43:11732asciidoc.install();
Junio C Hamanoe0238c22012-02-23 22:45:50733/*]]>*/
734</script>
735</head>
Junio C Hamano9d971152012-12-19 00:43:11736<body class="article">
Junio C Hamanoe0238c22012-02-23 22:45:50737<div id="header">
738<h1>config API</h1>
739</div>
740<div id="content">
741<div id="preamble">
742<div class="sectionbody">
Junio C Hamano076ffcc2013-02-06 05:13:21743<div class="paragraph"><p>The config API gives callers a way to access Git configuration files
Junio C Hamano719b8a32012-06-08 18:40:53744(and files which have the same syntax). See <a href="../git-config.html">git-config(1)</a> for a
Junio C Hamanoe0238c22012-02-23 22:45:50745discussion of the config file syntax.</p></div>
746</div>
747</div>
Junio C Hamano9d971152012-12-19 00:43:11748<div class="sect1">
Junio C Hamanoe0238c22012-02-23 22:45:50749<h2 id="_general_usage">General Usage</h2>
750<div class="sectionbody">
751<div class="paragraph"><p>Config files are parsed linearly, and each variable found is passed to a
752caller-provided callback function. The callback function is responsible
753for any actions to be taken on the config option, and is free to ignore
754some options. It is not uncommon for the configuration to be parsed
Junio C Hamano076ffcc2013-02-06 05:13:21755several times during the run of a Git program, with different callbacks
Junio C Hamanoe0238c22012-02-23 22:45:50756picking out different variables useful to themselves.</p></div>
757<div class="paragraph"><p>A config callback function takes three parameters:</p></div>
758<div class="ulist"><ul>
759<li>
760<p>
761the name of the parsed variable. This is in canonical "flat" form: the
762 section, subsection, and variable segments will be separated by dots,
763 and the section and variable segments will be all lowercase. E.g.,
Junio C Hamano61525f92014-01-17 22:46:49764 <tt>core.ignorecase</tt>, <tt>diff.SomeType.textconv</tt>.
Junio C Hamanoe0238c22012-02-23 22:45:50765</p>
766</li>
767<li>
768<p>
769the value of the found variable, as a string. If the variable had no
770 value specified, the value will be NULL (typically this means it
771 should be interpreted as boolean true).
772</p>
773</li>
774<li>
775<p>
776a void pointer passed in by the caller of the config API; this can
777 contain callback-specific data
778</p>
779</li>
780</ul></div>
781<div class="paragraph"><p>A config callback should return 0 for success, or -1 if the variable
782could not be parsed properly.</p></div>
783</div>
Junio C Hamano9d971152012-12-19 00:43:11784</div>
785<div class="sect1">
Junio C Hamanoe0238c22012-02-23 22:45:50786<h2 id="_basic_config_querying">Basic Config Querying</h2>
787<div class="sectionbody">
788<div class="paragraph"><p>Most programs will simply want to look up variables in all config files
Junio C Hamano076ffcc2013-02-06 05:13:21789that Git knows about, using the normal precedence rules. To do this,
Junio C Hamano61525f92014-01-17 22:46:49790call <tt>git_config</tt> with a callback function and void data pointer.</p></div>
791<div class="paragraph"><p><tt>git_config</tt> will read all config sources in order of increasing
Junio C Hamanoe0238c22012-02-23 22:45:50792priority. Thus a callback should typically overwrite previously-seen
Junio C Hamano61525f92014-01-17 22:46:49793entries with new ones (e.g., if both the user-wide <tt>~/.gitconfig</tt> and
794repo-specific <tt>.git/config</tt> contain <tt>color.ui</tt>, the config machinery
Junio C Hamanoe0238c22012-02-23 22:45:50795will first feed the user-wide one to the callback, and then the
796repo-specific one; by overwriting, the higher-priority repo-specific
797value is left at the end).</p></div>
Junio C Hamano61525f92014-01-17 22:46:49798<div class="paragraph"><p>The <tt>git_config_with_options</tt> function lets the caller examine config
799while adjusting some of the default behavior of <tt>git_config</tt>. It should
Junio C Hamano076ffcc2013-02-06 05:13:21800almost never be used by "regular" Git code that is looking up
Junio C Hamanoe0238c22012-02-23 22:45:50801configuration variables. It is intended for advanced callers like
Junio C Hamano61525f92014-01-17 22:46:49802<tt>git-config</tt>, which are intentionally tweaking the normal config-lookup
Junio C Hamanoe0238c22012-02-23 22:45:50803process. It takes two extra parameters:</p></div>
804<div class="dlist"><dl>
805<dt class="hdlist1">
Junio C Hamano61525f92014-01-17 22:46:49806<tt>filename</tt>
Junio C Hamanoe0238c22012-02-23 22:45:50807</dt>
808<dd>
809<p>
810If this parameter is non-NULL, it specifies the name of a file to
811parse for configuration, rather than looking in the usual files. Regular
Junio C Hamano61525f92014-01-17 22:46:49812<tt>git_config</tt> defaults to <tt>NULL</tt>.
Junio C Hamanoe0238c22012-02-23 22:45:50813</p>
814</dd>
815<dt class="hdlist1">
Junio C Hamano61525f92014-01-17 22:46:49816<tt>respect_includes</tt>
Junio C Hamanoe0238c22012-02-23 22:45:50817</dt>
818<dd>
819<p>
820Specify whether include directives should be followed in parsed files.
Junio C Hamano61525f92014-01-17 22:46:49821Regular <tt>git_config</tt> defaults to <tt>1</tt>.
Junio C Hamanoe0238c22012-02-23 22:45:50822</p>
823</dd>
824</dl></div>
Junio C Hamano61525f92014-01-17 22:46:49825<div class="paragraph"><p>There is a special version of <tt>git_config</tt> called <tt>git_config_early</tt>.
Junio C Hamanoe0238c22012-02-23 22:45:50826This version takes an additional parameter to specify the repository
Junio C Hamano61525f92014-01-17 22:46:49827config, instead of having it looked up via <tt>git_path</tt>. This is useful
Junio C Hamano076ffcc2013-02-06 05:13:21828early in a Git program before the repository has been found. Unless
Junio C Hamanoe0238c22012-02-23 22:45:50829you&#8217;re working with early setup code, you probably don&#8217;t want to use
830this.</p></div>
831</div>
Junio C Hamano9d971152012-12-19 00:43:11832</div>
833<div class="sect1">
Junio C Hamanoe0238c22012-02-23 22:45:50834<h2 id="_reading_specific_files">Reading Specific Files</h2>
835<div class="sectionbody">
836<div class="paragraph"><p>To read a specific file in git-config format, use
Junio C Hamano61525f92014-01-17 22:46:49837<tt>git_config_from_file</tt>. This takes the same callback and data parameters
838as <tt>git_config</tt>.</p></div>
Junio C Hamanoe0238c22012-02-23 22:45:50839</div>
Junio C Hamano9d971152012-12-19 00:43:11840</div>
841<div class="sect1">
Junio C Hamanoe0238c22012-02-23 22:45:50842<h2 id="_value_parsing_helpers">Value Parsing Helpers</h2>
843<div class="sectionbody">
844<div class="paragraph"><p>To aid in parsing string values, the config API provides callbacks with
845a number of helper functions, including:</p></div>
846<div class="dlist"><dl>
847<dt class="hdlist1">
Junio C Hamano61525f92014-01-17 22:46:49848<tt>git_config_int</tt>
Junio C Hamanoe0238c22012-02-23 22:45:50849</dt>
850<dd>
851<p>
852Parse the string to an integer, including unit factors. Dies on error;
853otherwise, returns the parsed result.
854</p>
855</dd>
856<dt class="hdlist1">
Junio C Hamano61525f92014-01-17 22:46:49857<tt>git_config_ulong</tt>
Junio C Hamanoe0238c22012-02-23 22:45:50858</dt>
859<dd>
860<p>
Junio C Hamano61525f92014-01-17 22:46:49861Identical to <tt>git_config_int</tt>, but for unsigned longs.
Junio C Hamanoe0238c22012-02-23 22:45:50862</p>
863</dd>
864<dt class="hdlist1">
Junio C Hamano61525f92014-01-17 22:46:49865<tt>git_config_bool</tt>
Junio C Hamanoe0238c22012-02-23 22:45:50866</dt>
867<dd>
868<p>
869Parse a string into a boolean value, respecting keywords like "true" and
870"false". Integer values are converted into true/false values (when they
871are non-zero or zero, respectively). Other values cause a die(). If
872parsing is successful, the return value is the result.
873</p>
874</dd>
875<dt class="hdlist1">
Junio C Hamano61525f92014-01-17 22:46:49876<tt>git_config_bool_or_int</tt>
Junio C Hamanoe0238c22012-02-23 22:45:50877</dt>
878<dd>
879<p>
Junio C Hamano61525f92014-01-17 22:46:49880Same as <tt>git_config_bool</tt>, except that integers are returned as-is, and
881an <tt>is_bool</tt> flag is unset.
Junio C Hamanoe0238c22012-02-23 22:45:50882</p>
883</dd>
884<dt class="hdlist1">
Junio C Hamano61525f92014-01-17 22:46:49885<tt>git_config_maybe_bool</tt>
Junio C Hamanoe0238c22012-02-23 22:45:50886</dt>
887<dd>
888<p>
Junio C Hamano61525f92014-01-17 22:46:49889Same as <tt>git_config_bool</tt>, except that it returns -1 on error rather
Junio C Hamanoe0238c22012-02-23 22:45:50890than dying.
891</p>
892</dd>
893<dt class="hdlist1">
Junio C Hamano61525f92014-01-17 22:46:49894<tt>git_config_string</tt>
Junio C Hamanoe0238c22012-02-23 22:45:50895</dt>
896<dd>
897<p>
Junio C Hamano61525f92014-01-17 22:46:49898Allocates and copies the value string into the <tt>dest</tt> parameter; if no
Junio C Hamanoe0238c22012-02-23 22:45:50899string is given, prints an error message and returns -1.
900</p>
901</dd>
902<dt class="hdlist1">
Junio C Hamano61525f92014-01-17 22:46:49903<tt>git_config_pathname</tt>
Junio C Hamanoe0238c22012-02-23 22:45:50904</dt>
905<dd>
906<p>
Junio C Hamano61525f92014-01-17 22:46:49907Similar to <tt>git_config_string</tt>, but expands <tt>~</tt> or <tt>~user</tt> into the
Junio C Hamanoe0238c22012-02-23 22:45:50908user&#8217;s home directory when found at the beginning of the path.
909</p>
910</dd>
911</dl></div>
912</div>
Junio C Hamano9d971152012-12-19 00:43:11913</div>
914<div class="sect1">
Junio C Hamanoe0238c22012-02-23 22:45:50915<h2 id="_include_directives">Include Directives</h2>
916<div class="sectionbody">
917<div class="paragraph"><p>By default, the config parser does not respect include directives.
Junio C Hamano61525f92014-01-17 22:46:49918However, a caller can use the special <tt>git_config_include</tt> wrapper
Junio C Hamanoe0238c22012-02-23 22:45:50919callback to support them. To do so, you simply wrap your "real" callback
Junio C Hamano61525f92014-01-17 22:46:49920function and data pointer in a <tt>struct config_include_data</tt>, and pass
Junio C Hamanoe0238c22012-02-23 22:45:50921the wrapper to the regular config-reading functions. For example:</p></div>
922<div class="listingblock">
923<div class="content">
Junio C Hamano61525f92014-01-17 22:46:49924<pre><tt>int read_file_with_include(const char *file, config_fn_t fn, void *data)
Junio C Hamanoe0238c22012-02-23 22:45:50925{
926 struct config_include_data inc = CONFIG_INCLUDE_INIT;
927 inc.fn = fn;
928 inc.data = data;
929 return git_config_from_file(git_config_include, file, &amp;inc);
Junio C Hamano61525f92014-01-17 22:46:49930}</tt></pre>
Junio C Hamanoe0238c22012-02-23 22:45:50931</div></div>
Junio C Hamano61525f92014-01-17 22:46:49932<div class="paragraph"><p><tt>git_config</tt> respects includes automatically. The lower-level
933<tt>git_config_from_file</tt> does not.</p></div>
Junio C Hamanoe0238c22012-02-23 22:45:50934</div>
Junio C Hamano9d971152012-12-19 00:43:11935</div>
936<div class="sect1">
Junio C Hamanoe0238c22012-02-23 22:45:50937<h2 id="_writing_config_files">Writing Config Files</h2>
938<div class="sectionbody">
Junio C Hamanofc1cf4a2014-08-04 21:40:55939<div class="paragraph"><p>Git gives multiple entry points in the Config API to write config values to
940files namely <tt>git_config_set_in_file</tt> and <tt>git_config_set</tt>, which write to
941a specific config file or to <tt>.git/config</tt> respectively. They both take a
942key/value pair as parameter.
943In the end they both call <tt>git_config_set_multivar_in_file</tt> which takes four
944parameters:</p></div>
945<div class="ulist"><ul>
946<li>
947<p>
948the name of the file, as a string, to which key/value pairs will be written.
949</p>
950</li>
951<li>
952<p>
953the name of key, as a string. This is in canonical "flat" form: the section,
954 subsection, and variable segments will be separated by dots, and the section
955 and variable segments will be all lowercase.
956 E.g., <tt>core.ignorecase</tt>, <tt>diff.SomeType.textconv</tt>.
957</p>
958</li>
959<li>
960<p>
961the value of the variable, as a string. If value is equal to NULL, it will
962 remove the matching key from the config file.
963</p>
964</li>
965<li>
966<p>
967the value regex, as a string. It will disregard key/value pairs where value
968 does not match.
969</p>
970</li>
971<li>
972<p>
973a multi_replace value, as an int. If value is equal to zero, nothing or only
974 one matching key/value is replaced, else all matching key/values (regardless
975 how many) are removed, before the new pair is written.
976</p>
977</li>
978</ul></div>
979<div class="paragraph"><p>It returns 0 on success.</p></div>
980<div class="paragraph"><p>Also, there are functions <tt>git_config_rename_section</tt> and
981<tt>git_config_rename_section_in_file</tt> with parameters <tt>old_name</tt> and <tt>new_name</tt>
982for renaming or removing sections in the config files. If NULL is passed
983through <tt>new_name</tt> parameter, the section will be removed from the config file.</p></div>
Junio C Hamanoe0238c22012-02-23 22:45:50984</div>
985</div>
Junio C Hamano9d971152012-12-19 00:43:11986</div>
Junio C Hamanoe0238c22012-02-23 22:45:50987<div id="footnotes"><hr /></div>
988<div id="footer">
989<div id="footer-text">
Junio C Hamanofc1cf4a2014-08-04 21:40:55990Last updated 2014-08-04 14:37:24 PDT
Junio C Hamanoe0238c22012-02-23 22:45:50991</div>
992</div>
993</body>
994</html>