Autogenerated HTML docs for v2.45.1-204-gd8ab1
[git-htmldocs.git] / gitprotocol-http.html
blobf02bc77920c33d6591865accfcb5d7b2dc025573
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>gitprotocol-http(5)</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 gitprotocol-http(5) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>gitprotocol-http -
743 Git HTTP-based protocols
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">&lt;over-the-wire-protocol&gt;</pre>
753 <div class="attribution">
754 </div></div>
755 </div>
756 </div>
757 <div class="sect1">
758 <h2 id="_description">DESCRIPTION</h2>
759 <div class="sectionbody">
760 <div class="paragraph"><p>Git supports two HTTP based transfer protocols. A "dumb" protocol
761 which requires only a standard HTTP server on the server end of the
762 connection, and a "smart" protocol which requires a Git aware CGI
763 (or server module). This document describes both protocols.</p></div>
764 <div class="paragraph"><p>As a design feature smart clients can automatically upgrade "dumb"
765 protocol URLs to smart URLs. This permits all users to have the
766 same published URL, and the peers automatically select the most
767 efficient transport available to them.</p></div>
768 </div>
769 </div>
770 <div class="sect1">
771 <h2 id="_url_format">URL Format</h2>
772 <div class="sectionbody">
773 <div class="paragraph"><p>URLs for Git repositories accessed by HTTP use the standard HTTP
774 URL syntax documented by RFC 1738, so they are of the form:</p></div>
775 <div class="literalblock">
776 <div class="content">
777 <pre><code>http://&lt;host&gt;:&lt;port&gt;/&lt;path&gt;?&lt;searchpart&gt;</code></pre>
778 </div></div>
779 <div class="paragraph"><p>Within this documentation the placeholder <code>$GIT_URL</code> will stand for
780 the http:// repository URL entered by the end-user.</p></div>
781 <div class="paragraph"><p>Servers SHOULD handle all requests to locations matching <code>$GIT_URL</code>, as
782 both the "smart" and "dumb" HTTP protocols used by Git operate
783 by appending additional path components onto the end of the user
784 supplied <code>$GIT_URL</code> string.</p></div>
785 <div class="paragraph"><p>An example of a dumb client requesting a loose object:</p></div>
786 <div class="literalblock">
787 <div class="content">
788 <pre><code>$GIT_URL: http://example.com:8080/git/repo.git
789 URL request: http://example.com:8080/git/repo.git/objects/d0/49f6c27a2244e12041955e262a404c7faba355</code></pre>
790 </div></div>
791 <div class="paragraph"><p>An example of a smart request to a catch-all gateway:</p></div>
792 <div class="literalblock">
793 <div class="content">
794 <pre><code>$GIT_URL: http://example.com/daemon.cgi?svc=git&amp;q=
795 URL request: http://example.com/daemon.cgi?svc=git&amp;q=/info/refs&amp;service=git-receive-pack</code></pre>
796 </div></div>
797 <div class="paragraph"><p>An example of a request to a submodule:</p></div>
798 <div class="literalblock">
799 <div class="content">
800 <pre><code>$GIT_URL: http://example.com/git/repo.git/path/submodule.git
801 URL request: http://example.com/git/repo.git/path/submodule.git/info/refs</code></pre>
802 </div></div>
803 <div class="paragraph"><p>Clients MUST strip a trailing <code>/</code>, if present, from the user supplied
804 <code>$GIT_URL</code> string to prevent empty path tokens (<code>//</code>) from appearing
805 in any URL sent to a server. Compatible clients MUST expand
806 <code>$GIT_URL/info/refs</code> as <code>foo/info/refs</code> and not <code>foo//info/refs</code>.</p></div>
807 </div>
808 </div>
809 <div class="sect1">
810 <h2 id="_authentication">Authentication</h2>
811 <div class="sectionbody">
812 <div class="paragraph"><p>Standard HTTP authentication is used if authentication is required
813 to access a repository, and MAY be configured and enforced by the
814 HTTP server software.</p></div>
815 <div class="paragraph"><p>Because Git repositories are accessed by standard path components
816 server administrators MAY use directory based permissions within
817 their HTTP server to control repository access.</p></div>
818 <div class="paragraph"><p>Clients SHOULD support Basic authentication as described by RFC 2617.
819 Servers SHOULD support Basic authentication by relying upon the
820 HTTP server placed in front of the Git server software.</p></div>
821 <div class="paragraph"><p>Servers SHOULD NOT require HTTP cookies for the purposes of
822 authentication or access control.</p></div>
823 <div class="paragraph"><p>Clients and servers MAY support other common forms of HTTP based
824 authentication, such as Digest authentication.</p></div>
825 </div>
826 </div>
827 <div class="sect1">
828 <h2 id="_ssl">SSL</h2>
829 <div class="sectionbody">
830 <div class="paragraph"><p>Clients and servers SHOULD support SSL, particularly to protect
831 passwords when relying on Basic HTTP authentication.</p></div>
832 </div>
833 </div>
834 <div class="sect1">
835 <h2 id="_session_state">Session State</h2>
836 <div class="sectionbody">
837 <div class="paragraph"><p>The Git over HTTP protocol (much like HTTP itself) is stateless
838 from the perspective of the HTTP server side. All state MUST be
839 retained and managed by the client process. This permits simple
840 round-robin load-balancing on the server side, without needing to
841 worry about state management.</p></div>
842 <div class="paragraph"><p>Clients MUST NOT require state management on the server side in
843 order to function correctly.</p></div>
844 <div class="paragraph"><p>Servers MUST NOT require HTTP cookies in order to function correctly.
845 Clients MAY store and forward HTTP cookies during request processing
846 as described by RFC 2616 (HTTP/1.1). Servers SHOULD ignore any
847 cookies sent by a client.</p></div>
848 </div>
849 </div>
850 <div class="sect1">
851 <h2 id="_general_request_processing">General Request Processing</h2>
852 <div class="sectionbody">
853 <div class="paragraph"><p>Except where noted, all standard HTTP behavior SHOULD be assumed
854 by both client and server. This includes (but is not necessarily
855 limited to):</p></div>
856 <div class="paragraph"><p>If there is no repository at <code>$GIT_URL</code>, or the resource pointed to by a
857 location matching <code>$GIT_URL</code> does not exist, the server MUST NOT respond
858 with <code>200 OK</code> response. A server SHOULD respond with
859 <code>404 Not Found</code>, <code>410 Gone</code>, or any other suitable HTTP status code
860 which does not imply the resource exists as requested.</p></div>
861 <div class="paragraph"><p>If there is a repository at <code>$GIT_URL</code>, but access is not currently
862 permitted, the server MUST respond with the <code>403 Forbidden</code> HTTP
863 status code.</p></div>
864 <div class="paragraph"><p>Servers SHOULD support both HTTP 1.0 and HTTP 1.1.
865 Servers SHOULD support chunked encoding for both request and response
866 bodies.</p></div>
867 <div class="paragraph"><p>Clients SHOULD support both HTTP 1.0 and HTTP 1.1.
868 Clients SHOULD support chunked encoding for both request and response
869 bodies.</p></div>
870 <div class="paragraph"><p>Servers MAY return ETag and/or Last-Modified headers.</p></div>
871 <div class="paragraph"><p>Clients MAY revalidate cached entities by including If-Modified-Since
872 and/or If-None-Match request headers.</p></div>
873 <div class="paragraph"><p>Servers MAY return <code>304 Not Modified</code> if the relevant headers appear
874 in the request and the entity has not changed. Clients MUST treat
875 <code>304 Not Modified</code> identical to <code>200 OK</code> by reusing the cached entity.</p></div>
876 <div class="paragraph"><p>Clients MAY reuse a cached entity without revalidation if the
877 Cache-Control and/or Expires header permits caching. Clients and
878 servers MUST follow RFC 2616 for cache controls.</p></div>
879 </div>
880 </div>
881 <div class="sect1">
882 <h2 id="_discovering_references">Discovering References</h2>
883 <div class="sectionbody">
884 <div class="paragraph"><p>All HTTP clients MUST begin either a fetch or a push exchange by
885 discovering the references available on the remote repository.</p></div>
886 <div class="sect2">
887 <h3 id="_dumb_clients">Dumb Clients</h3>
888 <div class="paragraph"><p>HTTP clients that only support the "dumb" protocol MUST discover
889 references by making a request for the special info/refs file of
890 the repository.</p></div>
891 <div class="paragraph"><p>Dumb HTTP clients MUST make a <code>GET</code> request to <code>$GIT_URL/info/refs</code>,
892 without any search/query parameters.</p></div>
893 <div class="literalblock">
894 <div class="content">
895 <pre><code>C: GET $GIT_URL/info/refs HTTP/1.0</code></pre>
896 </div></div>
897 <div class="literalblock">
898 <div class="content">
899 <pre><code>S: 200 OK
901 S: 95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint
902 S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master
903 S: 2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0
904 S: a3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}</code></pre>
905 </div></div>
906 <div class="paragraph"><p>The Content-Type of the returned info/refs entity SHOULD be
907 <code>text/plain; charset=utf-8</code>, but MAY be any content type.
908 Clients MUST NOT attempt to validate the returned Content-Type.
909 Dumb servers MUST NOT return a return type starting with
910 <code>application/x-git-</code>.</p></div>
911 <div class="paragraph"><p>Cache-Control headers MAY be returned to disable caching of the
912 returned entity.</p></div>
913 <div class="paragraph"><p>When examining the response clients SHOULD only examine the HTTP
914 status code. Valid responses are <code>200 OK</code>, or <code>304 Not Modified</code>.</p></div>
915 <div class="paragraph"><p>The returned content is a UNIX formatted text file describing
916 each ref and its known value. The file SHOULD be sorted by name
917 according to the C locale ordering. The file SHOULD NOT include
918 the default ref named <code>HEAD</code>.</p></div>
919 <div class="literalblock">
920 <div class="content">
921 <pre><code>info_refs = *( ref_record )
922 ref_record = any_ref / peeled_ref</code></pre>
923 </div></div>
924 <div class="literalblock">
925 <div class="content">
926 <pre><code>any_ref = obj-id HTAB refname LF
927 peeled_ref = obj-id HTAB refname LF
928 obj-id HTAB refname "^{}" LF</code></pre>
929 </div></div>
930 </div>
931 <div class="sect2">
932 <h3 id="_smart_clients">Smart Clients</h3>
933 <div class="paragraph"><p>HTTP clients that support the "smart" protocol (or both the
934 "smart" and "dumb" protocols) MUST discover references by making
935 a parameterized request for the info/refs file of the repository.</p></div>
936 <div class="paragraph"><p>The request MUST contain exactly one query parameter,
937 <code>service=$servicename</code>, where <code>$servicename</code> MUST be the service
938 name the client wishes to contact to complete the operation.
939 The request MUST NOT contain additional query parameters.</p></div>
940 <div class="literalblock">
941 <div class="content">
942 <pre><code>C: GET $GIT_URL/info/refs?service=git-upload-pack HTTP/1.0</code></pre>
943 </div></div>
944 <div class="paragraph"><p>dumb server reply:</p></div>
945 <div class="literalblock">
946 <div class="content">
947 <pre><code>S: 200 OK
949 S: 95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint
950 S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master
951 S: 2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0
952 S: a3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}</code></pre>
953 </div></div>
954 <div class="paragraph"><p>smart server reply:</p></div>
955 <div class="literalblock">
956 <div class="content">
957 <pre><code>S: 200 OK
958 S: Content-Type: application/x-git-upload-pack-advertisement
959 S: Cache-Control: no-cache
961 S: 001e# service=git-upload-pack\n
962 S: 0000
963 S: 004895dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint\0multi_ack\n
964 S: 003fd049f6c27a2244e12041955e262a404c7faba355 refs/heads/master\n
965 S: 003c2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0\n
966 S: 003fa3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}\n
967 S: 0000</code></pre>
968 </div></div>
969 <div class="paragraph"><p>The client may send Extra Parameters (see
970 <a href="gitprotocol-pack.html">gitprotocol-pack(5)</a>) as a colon-separated string
971 in the Git-Protocol HTTP header.</p></div>
972 <div class="paragraph"><p>Uses the <code>--http-backend-info-refs</code> option to
973 <a href="git-upload-pack.html">git-upload-pack(1)</a>.</p></div>
974 <div class="sect3">
975 <h4 id="_dumb_server_response">Dumb Server Response</h4>
976 <div class="paragraph"><p>Dumb servers MUST respond with the dumb server reply format.</p></div>
977 <div class="paragraph"><p>See the prior section under dumb clients for a more detailed
978 description of the dumb server response.</p></div>
979 </div>
980 <div class="sect3">
981 <h4 id="_smart_server_response">Smart Server Response</h4>
982 <div class="paragraph"><p>If the server does not recognize the requested service name, or the
983 requested service name has been disabled by the server administrator,
984 the server MUST respond with the <code>403 Forbidden</code> HTTP status code.</p></div>
985 <div class="paragraph"><p>Otherwise, smart servers MUST respond with the smart server reply
986 format for the requested service name.</p></div>
987 <div class="paragraph"><p>Cache-Control headers SHOULD be used to disable caching of the
988 returned entity.</p></div>
989 <div class="paragraph"><p>The Content-Type MUST be <code>application/x-$servicename-advertisement</code>.
990 Clients SHOULD fall back to the dumb protocol if another content
991 type is returned. When falling back to the dumb protocol clients
992 SHOULD NOT make an additional request to <code>$GIT_URL/info/refs</code>, but
993 instead SHOULD use the response already in hand. Clients MUST NOT
994 continue if they do not support the dumb protocol.</p></div>
995 <div class="paragraph"><p>Clients MUST validate the status code is either <code>200 OK</code> or
996 <code>304 Not Modified</code>.</p></div>
997 <div class="paragraph"><p>Clients MUST validate the first five bytes of the response entity
998 matches the regex <code>^[0-9a-f]{4}#</code>. If this test fails, clients
999 MUST NOT continue.</p></div>
1000 <div class="paragraph"><p>Clients MUST parse the entire response as a sequence of pkt-line
1001 records.</p></div>
1002 <div class="paragraph"><p>Clients MUST verify the first pkt-line is <code># service=$servicename</code>.
1003 Servers MUST set $servicename to be the request parameter value.
1004 Servers SHOULD include an LF at the end of this line.
1005 Clients MUST ignore an LF at the end of the line.</p></div>
1006 <div class="paragraph"><p>Servers MUST terminate the response with the magic <code>0000</code> end
1007 pkt-line marker.</p></div>
1008 <div class="paragraph"><p>The returned response is a pkt-line stream describing each ref and
1009 its known value. The stream SHOULD be sorted by name according to
1010 the C locale ordering. The stream SHOULD include the default ref
1011 named <code>HEAD</code> as the first ref. The stream MUST include capability
1012 declarations behind a NUL on the first ref.</p></div>
1013 <div class="paragraph"><p>The returned response contains "version 1" if "version=1" was sent as an
1014 Extra Parameter.</p></div>
1015 <div class="literalblock">
1016 <div class="content">
1017 <pre><code>smart_reply = PKT-LINE("# service=$servicename" LF)
1018 "0000"
1019 *1("version 1")
1020 ref_list
1021 "0000"
1022 ref_list = empty_list / non_empty_list</code></pre>
1023 </div></div>
1024 <div class="literalblock">
1025 <div class="content">
1026 <pre><code>empty_list = PKT-LINE(zero-id SP "capabilities^{}" NUL cap-list LF)</code></pre>
1027 </div></div>
1028 <div class="literalblock">
1029 <div class="content">
1030 <pre><code>non_empty_list = PKT-LINE(obj-id SP name NUL cap_list LF)
1031 *ref_record</code></pre>
1032 </div></div>
1033 <div class="literalblock">
1034 <div class="content">
1035 <pre><code>cap-list = capability *(SP capability)
1036 capability = 1*(LC_ALPHA / DIGIT / "-" / "_")
1037 LC_ALPHA = %x61-7A</code></pre>
1038 </div></div>
1039 <div class="literalblock">
1040 <div class="content">
1041 <pre><code>ref_record = any_ref / peeled_ref
1042 any_ref = PKT-LINE(obj-id SP name LF)
1043 peeled_ref = PKT-LINE(obj-id SP name LF)
1044 PKT-LINE(obj-id SP name "^{}" LF</code></pre>
1045 </div></div>
1046 </div>
1047 </div>
1048 </div>
1049 </div>
1050 <div class="sect1">
1051 <h2 id="_smart_service_git_upload_pack">Smart Service git-upload-pack</h2>
1052 <div class="sectionbody">
1053 <div class="paragraph"><p>This service reads from the repository pointed to by <code>$GIT_URL</code>.</p></div>
1054 <div class="paragraph"><p>Clients MUST first perform ref discovery with
1055 <code>$GIT_URL/info/refs?service=git-upload-pack</code>.</p></div>
1056 <div class="literalblock">
1057 <div class="content">
1058 <pre><code>C: POST $GIT_URL/git-upload-pack HTTP/1.0
1059 C: Content-Type: application/x-git-upload-pack-request
1061 C: 0032want 0a53e9ddeaddad63ad106860237bbf53411d11a7\n
1062 C: 0032have 441b40d833fdfa93eb2908e52742248faf0ee993\n
1063 C: 0000</code></pre>
1064 </div></div>
1065 <div class="literalblock">
1066 <div class="content">
1067 <pre><code>S: 200 OK
1068 S: Content-Type: application/x-git-upload-pack-result
1069 S: Cache-Control: no-cache
1071 S: ....ACK %s, continue
1072 S: ....NAK</code></pre>
1073 </div></div>
1074 <div class="paragraph"><p>Clients MUST NOT reuse or revalidate a cached response.
1075 Servers MUST include sufficient Cache-Control headers
1076 to prevent caching of the response.</p></div>
1077 <div class="paragraph"><p>Servers SHOULD support all capabilities defined here.</p></div>
1078 <div class="paragraph"><p>Clients MUST send at least one "want" command in the request body.
1079 Clients MUST NOT reference an id in a "want" command which did not
1080 appear in the response obtained through ref discovery unless the
1081 server advertises capability <code>allow-tip-sha1-in-want</code> or
1082 <code>allow-reachable-sha1-in-want</code>.</p></div>
1083 <div class="literalblock">
1084 <div class="content">
1085 <pre><code>compute_request = want_list
1086 have_list
1087 request_end
1088 request_end = "0000" / "done"</code></pre>
1089 </div></div>
1090 <div class="literalblock">
1091 <div class="content">
1092 <pre><code>want_list = PKT-LINE(want SP cap_list LF)
1093 *(want_pkt)
1094 want_pkt = PKT-LINE(want LF)
1095 want = "want" SP id
1096 cap_list = capability *(SP capability)</code></pre>
1097 </div></div>
1098 <div class="literalblock">
1099 <div class="content">
1100 <pre><code>have_list = *PKT-LINE("have" SP id LF)</code></pre>
1101 </div></div>
1102 <div class="paragraph"><p>TODO: Document this further.</p></div>
1103 <div class="sect2">
1104 <h3 id="_the_negotiation_algorithm">The Negotiation Algorithm</h3>
1105 <div class="paragraph"><p>The computation to select the minimal pack proceeds as follows
1106 (C = client, S = server):</p></div>
1107 <div class="paragraph"><p><em>init step:</em></p></div>
1108 <div class="paragraph"><p>C: Use ref discovery to obtain the advertised refs.</p></div>
1109 <div class="paragraph"><p>C: Place any object seen into set <code>advertised</code>.</p></div>
1110 <div class="paragraph"><p>C: Build an empty set, <code>common</code>, to hold the objects that are later
1111 determined to be on both ends.</p></div>
1112 <div class="paragraph"><p>C: Build a set, <code>want</code>, of the objects from <code>advertised</code> that the client
1113 wants to fetch, based on what it saw during ref discovery.</p></div>
1114 <div class="paragraph"><p>C: Start a queue, <code>c_pending</code>, ordered by commit time (popping newest
1115 first). Add all client refs. When a commit is popped from
1116 the queue its parents SHOULD be automatically inserted back.
1117 Commits MUST only enter the queue once.</p></div>
1118 <div class="paragraph"><p><em>one compute step:</em></p></div>
1119 <div class="paragraph"><p>C: Send one <code>$GIT_URL/git-upload-pack</code> request:</p></div>
1120 <div class="literalblock">
1121 <div class="content">
1122 <pre><code>C: 0032want &lt;want-#1&gt;...............................
1123 C: 0032want &lt;want-#2&gt;...............................
1124 ....
1125 C: 0032have &lt;common-#1&gt;.............................
1126 C: 0032have &lt;common-#2&gt;.............................
1127 ....
1128 C: 0032have &lt;have-#1&gt;...............................
1129 C: 0032have &lt;have-#2&gt;...............................
1130 ....
1131 C: 0000</code></pre>
1132 </div></div>
1133 <div class="paragraph"><p>The stream is organized into "commands", with each command
1134 appearing by itself in a pkt-line. Within a command line,
1135 the text leading up to the first space is the command name,
1136 and the remainder of the line to the first LF is the value.
1137 Command lines are terminated with an LF as the last byte of
1138 the pkt-line value.</p></div>
1139 <div class="paragraph"><p>Commands MUST appear in the following order, if they appear
1140 at all in the request stream:</p></div>
1141 <div class="ulist"><ul>
1142 <li>
1144 "want"
1145 </p>
1146 </li>
1147 <li>
1149 "have"
1150 </p>
1151 </li>
1152 </ul></div>
1153 <div class="paragraph"><p>The stream is terminated by a pkt-line flush (<code>0000</code>).</p></div>
1154 <div class="paragraph"><p>A single "want" or "have" command MUST have one hex formatted
1155 object name as its value. Multiple object names MUST be sent by sending
1156 multiple commands. Object names MUST be given using the object format
1157 negotiated through the <code>object-format</code> capability (default SHA-1).</p></div>
1158 <div class="paragraph"><p>The <code>have</code> list is created by popping the first 32 commits
1159 from <code>c_pending</code>. Fewer can be supplied if <code>c_pending</code> empties.</p></div>
1160 <div class="paragraph"><p>If the client has sent 256 "have" commits and has not yet
1161 received one of those back from <code>s_common</code>, or the client has
1162 emptied <code>c_pending</code> it SHOULD include a "done" command to let
1163 the server know it won&#8217;t proceed:</p></div>
1164 <div class="literalblock">
1165 <div class="content">
1166 <pre><code>C: 0009done</code></pre>
1167 </div></div>
1168 <div class="paragraph"><p>S: Parse the git-upload-pack request:</p></div>
1169 <div class="paragraph"><p>Verify all objects in <code>want</code> are directly reachable from refs.</p></div>
1170 <div class="paragraph"><p>The server MAY walk backwards through history or through
1171 the reflog to permit slightly stale requests.</p></div>
1172 <div class="paragraph"><p>If no "want" objects are received, send an error:
1173 TODO: Define error if no "want" lines are requested.</p></div>
1174 <div class="paragraph"><p>If any "want" object is not reachable, send an error:
1175 TODO: Define error if an invalid "want" is requested.</p></div>
1176 <div class="paragraph"><p>Create an empty list, <code>s_common</code>.</p></div>
1177 <div class="paragraph"><p>If "have" was sent:</p></div>
1178 <div class="paragraph"><p>Loop through the objects in the order supplied by the client.</p></div>
1179 <div class="paragraph"><p>For each object, if the server has the object reachable from
1180 a ref, add it to <code>s_common</code>. If a commit is added to <code>s_common</code>,
1181 do not add any ancestors, even if they also appear in <code>have</code>.</p></div>
1182 <div class="paragraph"><p>S: Send the git-upload-pack response:</p></div>
1183 <div class="paragraph"><p>If the server has found a closed set of objects to pack or the
1184 request ends with "done", it replies with the pack.
1185 TODO: Document the pack based response</p></div>
1186 <div class="literalblock">
1187 <div class="content">
1188 <pre><code>S: PACK...</code></pre>
1189 </div></div>
1190 <div class="paragraph"><p>The returned stream is the side-band-64k protocol supported
1191 by the git-upload-pack service, and the pack is embedded into
1192 stream 1. Progress messages from the server side MAY appear
1193 in stream 2.</p></div>
1194 <div class="paragraph"><p>Here a "closed set of objects" is defined to have at least
1195 one path from every "want" to at least one "common" object.</p></div>
1196 <div class="paragraph"><p>If the server needs more information, it replies with a
1197 status continue response:
1198 TODO: Document the non-pack response</p></div>
1199 <div class="paragraph"><p>C: Parse the upload-pack response:
1200 TODO: Document parsing response</p></div>
1201 <div class="paragraph"><p><em>Do another compute step.</em></p></div>
1202 </div>
1203 </div>
1204 </div>
1205 <div class="sect1">
1206 <h2 id="_smart_service_git_receive_pack">Smart Service git-receive-pack</h2>
1207 <div class="sectionbody">
1208 <div class="paragraph"><p>This service reads from the repository pointed to by <code>$GIT_URL</code>.</p></div>
1209 <div class="paragraph"><p>Clients MUST first perform ref discovery with
1210 <code>$GIT_URL/info/refs?service=git-receive-pack</code>.</p></div>
1211 <div class="literalblock">
1212 <div class="content">
1213 <pre><code>C: POST $GIT_URL/git-receive-pack HTTP/1.0
1214 C: Content-Type: application/x-git-receive-pack-request
1216 C: ....0a53e9ddeaddad63ad106860237bbf53411d11a7 441b40d833fdfa93eb2908e52742248faf0ee993 refs/heads/maint\0 report-status
1217 C: 0000
1218 C: PACK....</code></pre>
1219 </div></div>
1220 <div class="literalblock">
1221 <div class="content">
1222 <pre><code>S: 200 OK
1223 S: Content-Type: application/x-git-receive-pack-result
1224 S: Cache-Control: no-cache
1226 S: ....</code></pre>
1227 </div></div>
1228 <div class="paragraph"><p>Clients MUST NOT reuse or revalidate a cached response.
1229 Servers MUST include sufficient Cache-Control headers
1230 to prevent caching of the response.</p></div>
1231 <div class="paragraph"><p>Servers SHOULD support all capabilities defined here.</p></div>
1232 <div class="paragraph"><p>Clients MUST send at least one command in the request body.
1233 Within the command portion of the request body clients SHOULD send
1234 the id obtained through ref discovery as old_id.</p></div>
1235 <div class="literalblock">
1236 <div class="content">
1237 <pre><code>update_request = command_list
1238 "PACK" &lt;binary-data&gt;</code></pre>
1239 </div></div>
1240 <div class="literalblock">
1241 <div class="content">
1242 <pre><code>command_list = PKT-LINE(command NUL cap_list LF)
1243 *(command_pkt)
1244 command_pkt = PKT-LINE(command LF)
1245 cap_list = *(SP capability) SP</code></pre>
1246 </div></div>
1247 <div class="literalblock">
1248 <div class="content">
1249 <pre><code>command = create / delete / update
1250 create = zero-id SP new_id SP name
1251 delete = old_id SP zero-id SP name
1252 update = old_id SP new_id SP name</code></pre>
1253 </div></div>
1254 <div class="paragraph"><p>TODO: Document this further.</p></div>
1255 </div>
1256 </div>
1257 <div class="sect1">
1258 <h2 id="_references">REFERENCES</h2>
1259 <div class="sectionbody">
1260 <div class="paragraph"><p><a href="https://www.ietf.org/rfc/rfc1738.txt">RFC 1738: Uniform Resource Locators (URL)</a>
1261 <a href="https://www.ietf.org/rfc/rfc2616.txt">RFC 2616: Hypertext Transfer Protocol&#8201;&#8212;&#8201;HTTP/1.1</a></p></div>
1262 </div>
1263 </div>
1264 <div class="sect1">
1265 <h2 id="_see_also">SEE ALSO</h2>
1266 <div class="sectionbody">
1267 <div class="paragraph"><p><a href="gitprotocol-pack.html">gitprotocol-pack(5)</a>
1268 <a href="gitprotocol-capabilities.html">gitprotocol-capabilities(5)</a></p></div>
1269 </div>
1270 </div>
1271 <div class="sect1">
1272 <h2 id="_git">GIT</h2>
1273 <div class="sectionbody">
1274 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1275 </div>
1276 </div>
1277 </div>
1278 <div id="footnotes"><hr /></div>
1279 <div id="footer">
1280 <div id="footer-text">
1281 Last updated
1282 2024-02-08 15:45:59 PST
1283 </div>
1284 </div>
1285 </body>
1286 </html>