blob: 1e6711aad28ac5600698060bdf604dc820ab9de0 [file] [log] [blame]
Junio C Hamano04495a12022-08-18 21:13:081<?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 */
11
12/* Default font. */
13body {
14 font-family: Georgia,serif;
15}
16
17/* Title font. */
18h1, h2, h3, h4, h5, h6,
19div.title, caption.title,
20thead, p.table.header,
21#toctitle,
22#author, #revnumber, #revdate, #revremark,
23#footer {
24 font-family: Arial,Helvetica,sans-serif;
25}
26
27body {
28 margin: 1em 5% 1em 5%;
29}
30
31a {
32 color: blue;
33 text-decoration: underline;
34}
35a:visited {
36 color: fuchsia;
37}
38
39em {
40 font-style: italic;
41 color: navy;
42}
43
44strong {
45 font-weight: bold;
46 color: #083194;
47}
48
49h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
51 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
54}
55
56h1, h2, h3 {
57 border-bottom: 2px solid silver;
58}
59h2 {
60 padding-top: 0.5em;
61}
62h3 {
63 float: left;
64}
65h3 + * {
66 clear: left;
67}
68h5 {
69 font-size: 1.0em;
70}
71
72div.sectionbody {
73 margin-left: 0;
74}
75
76hr {
77 border: 1px solid silver;
78}
79
80p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
83}
84
85ul, ol, li > p {
86 margin-top: 0;
87}
88ul > li { color: #aaa; }
89ul > li > * { color: black; }
90
91.monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
97}
98pre {
99 white-space: pre-wrap;
100}
101
102#author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
106}
107#email {
108}
109#revnumber, #revdate, #revremark {
110}
111
112#footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
117}
118#footer-text {
119 float: left;
120 padding-bottom: 0.5em;
121}
122#footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
125}
126
127#preamble {
128 margin-top: 1.5em;
129 margin-bottom: 1.5em;
130}
131div.imageblock, div.exampleblock, div.verseblock,
132div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133div.admonitionblock {
134 margin-top: 1.0em;
135 margin-bottom: 1.5em;
136}
137div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
142}
143
144div.content { /* Block element content. */
145 padding: 0;
146}
147
148/* Block element titles. */
149div.title, caption.title {
150 color: #527bbd;
151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
155}
156div.title + * {
157 margin-top: 0;
158}
159
160td div.title:first-child {
161 margin-top: 0.0em;
162}
163div.content div.title:first-child {
164 margin-top: 0.0em;
165}
166div.content + div.title {
167 margin-top: 0.0em;
168}
169
170div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
175}
176
177div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
182}
183
184div.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;
190}
191
192div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
195}
196
197div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
200}
201div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
204}
205/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206div.verseblock + div.attribution {
207 text-align: left;
208}
209
210div.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;
217}
218div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
221}
222
223div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
226}
227
228div.imageblock div.content { padding-left: 0; }
229span.image img { border-style: none; vertical-align: text-bottom; }
230a.image:visited { color: white; }
231
232dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
235}
236dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
241}
242dd > *:first-child {
243 margin-top: 0.1em;
244}
245
246ul, ol {
247 list-style-position: outside;
248}
249ol.arabic {
250 list-style-type: decimal;
251}
252ol.loweralpha {
253 list-style-type: lower-alpha;
254}
255ol.upperalpha {
256 list-style-type: upper-alpha;
257}
258ol.lowerroman {
259 list-style-type: lower-roman;
260}
261ol.upperroman {
262 list-style-type: upper-roman;
263}
264
265div.compact ul, div.compact ol,
266div.compact p, div.compact p,
267div.compact div, div.compact div {
268 margin-top: 0.1em;
269 margin-bottom: 0.1em;
270}
271
272tfoot {
273 font-weight: bold;
274}
275td > div.verse {
276 white-space: pre;
277}
278
279div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
282}
283div.hdlist tr {
284 padding-bottom: 15px;
285}
286dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
288}
289td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
294}
295td.hdlist2 {
296 vertical-align: top;
297}
298div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
301}
302
303.comment {
304 background: yellow;
305}
306
307.footnote, .footnoteref {
308 font-size: 0.8em;
309}
310
311span.footnote, span.footnoteref {
312 vertical-align: super;
313}
314
315#footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
318}
319
320#footnotes div.footnote {
321 margin: 0 0 5px 0;
322}
323
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;
332}
333
334div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
338}
339div.colist td img {
340 margin-top: 0.3em;
341}
342
343@media print {
344 #footer-badges { display: none; }
345}
346
347#toc {
348 margin-bottom: 2.5em;
349}
350
351#toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
357}
358
359div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
362}
363div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
366}
367div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
370}
371div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
374}
375
376span.aqua { color: aqua; }
377span.black { color: black; }
378span.blue { color: blue; }
379span.fuchsia { color: fuchsia; }
380span.gray { color: gray; }
381span.green { color: green; }
382span.lime { color: lime; }
383span.maroon { color: maroon; }
384span.navy { color: navy; }
385span.olive { color: olive; }
386span.purple { color: purple; }
387span.red { color: red; }
388span.silver { color: silver; }
389span.teal { color: teal; }
390span.white { color: white; }
391span.yellow { color: yellow; }
392
393span.aqua-background { background: aqua; }
394span.black-background { background: black; }
395span.blue-background { background: blue; }
396span.fuchsia-background { background: fuchsia; }
397span.gray-background { background: gray; }
398span.green-background { background: green; }
399span.lime-background { background: lime; }
400span.maroon-background { background: maroon; }
401span.navy-background { background: navy; }
402span.olive-background { background: olive; }
403span.purple-background { background: purple; }
404span.red-background { background: red; }
405span.silver-background { background: silver; }
406span.teal-background { background: teal; }
407span.white-background { background: white; }
408span.yellow-background { background: yellow; }
409
410span.big { font-size: 2em; }
411span.small { font-size: 0.6em; }
412
413span.underline { text-decoration: underline; }
414span.overline { text-decoration: overline; }
415span.line-through { text-decoration: line-through; }
416
417div.unbreakable { page-break-inside: avoid; }
418
419
420/*
421 * xhtml11 specific
422 *
423 * */
424
425div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
428}
429div.tableblock > table {
430 border: 3px solid #527bbd;
431}
432thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
435}
436p.table {
437 margin-top: 0;
438}
439/* Because the table frame attribute is overridden by CSS in most browsers. */
440div.tableblock > table[frame="void"] {
441 border-style: none;
442}
443div.tableblock > table[frame="hsides"] {
444 border-left-style: none;
445 border-right-style: none;
446}
447div.tableblock > table[frame="vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
450}
451
452
453/*
454 * html5 specific
455 *
456 * */
457
458table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
461}
462thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
465}
466p.tableblock {
467 margin-top: 0;
468}
469table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
475}
476th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
480 border-color: #527bbd;
481}
482
483table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
486}
487table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
490}
491table.tableblock.frame-none {
492 border-style: hidden;
493}
494
495th.tableblock.halign-left, td.tableblock.halign-left {
496 text-align: left;
497}
498th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
500}
501th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
503}
504
505th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: top;
507}
508th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
510}
511th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
513}
514
515
516/*
517 * manpage specific
518 *
519 * */
520
521body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
526}
527body.manpage h2 {
528 border-style: none;
529}
530body.manpage div.sectionbody {
531 margin-left: 3em;
532}
533
534@media print {
535 body.manpage div#toc { display: none; }
536}
537
538
539</style>
540<script type="text/javascript">
541/*<![CDATA[*/
542var asciidoc = { // Namespace.
543
544/////////////////////////////////////////////////////////////////////
545// Table Of Contents generator
546/////////////////////////////////////////////////////////////////////
547
548/* Author: Mihai Bazon, September 2002
549 * http://students.infoiasi.ro/~mishoo
550 *
551 * Table Of Content generator
552 * Version: 0.4
553 *
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.
556 */
557
558 /* modified by Troy D. Hanson, September 2006. License: GPL */
559 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
560
561// toclevels = 1..4.
562toc: function (toclevels) {
563
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);
571 }
572 return text;
573 }
574
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
578 this.toclevel = toclevel;
579 }
580
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);
593 }
594 iterate(i);
595 }
596 }
597 }
598 iterate(el);
599 return result;
600 }
601
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
605 }
606
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);
616 }
617 for (i = 0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
619 }
620
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);
634 }
635 if (entries.length == 0)
636 toc.parentNode.removeChild(toc);
637},
638
639
640/////////////////////////////////////////////////////////////////////
641// Footnotes generator
642/////////////////////////////////////////////////////////////////////
643
644/* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
646 */
647
648footnotes: 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;
654 }
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);
660 }
661 for (i = 0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
663 }
664
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);
682 }
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;
689 }
690 }
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>]";
703 }
704 }
705 }
706},
707
708install: function(toclevels) {
709 var timerId;
710
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
715 }
716 }
717
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
721 }
722
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
728}
729
730}
731asciidoc.install();
732/*]]>*/
733</script>
734</head>
735<body class="manpage">
736<div id="header">
737<h1>
738gitprotocol-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
761which requires only a standard HTTP server on the server end of the
762connection, 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"
765protocol URLs to smart URLs. This permits all users to have the
766same published URL, and the peers automatically select the most
767efficient 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
774URL 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
780the 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
782both the "smart" and "dumb" HTTP protocols used by Git operate
783by appending additional path components onto the end of the user
784supplied <code>$GIT_URL</code> string.</p></div>
785<div class="paragraph"><p>An example of a dumb client requesting for 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
789URL 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=
795URL 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
801URL 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
805in 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
813to access a repository, and MAY be configured and enforced by the
814HTTP server software.</p></div>
815<div class="paragraph"><p>Because Git repositories are accessed by standard path components
816server administrators MAY use directory based permissions within
817their HTTP server to control repository access.</p></div>
818<div class="paragraph"><p>Clients SHOULD support Basic authentication as described by RFC 2617.
819Servers SHOULD support Basic authentication by relying upon the
820HTTP 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
822authentication or access control.</p></div>
823<div class="paragraph"><p>Clients and servers MAY support other common forms of HTTP based
824authentication, 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
831passwords 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
838from the perspective of the HTTP server side. All state MUST be
839retained and managed by the client process. This permits simple
840round-robin load-balancing on the server side, without needing to
841worry about state management.</p></div>
842<div class="paragraph"><p>Clients MUST NOT require state management on the server side in
843order to function correctly.</p></div>
844<div class="paragraph"><p>Servers MUST NOT require HTTP cookies in order to function correctly.
845Clients MAY store and forward HTTP cookies during request processing
846as described by RFC 2616 (HTTP/1.1). Servers SHOULD ignore any
847cookies 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
854by both client and server. This includes (but is not necessarily
855limited 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
857location matching <code>$GIT_URL</code> does not exist, the server MUST NOT respond
858with <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
860which 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
862permitted, the server MUST respond with the <code>403 Forbidden</code> HTTP
863status code.</p></div>
864<div class="paragraph"><p>Servers SHOULD support both HTTP 1.0 and HTTP 1.1.
865Servers SHOULD support chunked encoding for both request and response
866bodies.</p></div>
867<div class="paragraph"><p>Clients SHOULD support both HTTP 1.0 and HTTP 1.1.
868Clients SHOULD support chunked encoding for both request and response
869bodies.</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
872and/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
874in 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
877Cache-Control and/or Expires header permits caching. Clients and
878servers 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
885discovering 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
889references by making a request for the special info/refs file of
890the 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>,
892without 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
900S:
901S: 95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint
902S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master
903S: 2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0
904S: 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.
908Clients MUST NOT attempt to validate the returned Content-Type.
909Dumb 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
912returned entity.</p></div>
913<div class="paragraph"><p>When examining the response clients SHOULD only examine the HTTP
914status 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
916each ref and its known value. The file SHOULD be sorted by name
917according to the C locale ordering. The file SHOULD NOT include
918the default ref named <code>HEAD</code>.</p></div>
919<div class="literalblock">
920<div class="content">
921<pre><code>info_refs = *( ref_record )
922ref_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
927peeled_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
935a 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
938name the client wishes to contact to complete the operation.
939The 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
948S:
949S: 95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint
950S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master
951S: 2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0
952S: 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
958S: Content-Type: application/x-git-upload-pack-advertisement
959S: Cache-Control: no-cache
960S:
961S: 001e# service=git-upload-pack\n
962S: 0000
963S: 004895dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint\0multi_ack\n
964S: 003fd049f6c27a2244e12041955e262a404c7faba355 refs/heads/master\n
965S: 003c2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0\n
966S: 003fa3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}\n
967S: 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
971in 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
978description 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
983requested service name has been disabled by the server administrator,
984the 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
986format for the requested service name.</p></div>
987<div class="paragraph"><p>Cache-Control headers SHOULD be used to disable caching of the
988returned entity.</p></div>
989<div class="paragraph"><p>The Content-Type MUST be <code>application/x-$servicename-advertisement</code>.
990Clients SHOULD fall back to the dumb protocol if another content
991type is returned. When falling back to the dumb protocol clients
992SHOULD NOT make an additional request to <code>$GIT_URL/info/refs</code>, but
993instead SHOULD use the response already in hand. Clients MUST NOT
994continue 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
998matches the regex <code>^[0-9a-f]{4}#</code>. If this test fails, clients
999MUST NOT continue.</p></div>
1000<div class="paragraph"><p>Clients MUST parse the entire response as a sequence of pkt-line
1001records.</p></div>
1002<div class="paragraph"><p>Clients MUST verify the first pkt-line is <code># service=$servicename</code>.
1003Servers MUST set $servicename to be the request parameter value.
1004Servers SHOULD include an LF at the end of this line.
1005Clients 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
1007pkt-line marker.</p></div>
1008<div class="paragraph"><p>The returned response is a pkt-line stream describing each ref and
1009its known value. The stream SHOULD be sorted by name according to
1010the C locale ordering. The stream SHOULD include the default ref
1011named <code>HEAD</code> as the first ref. The stream MUST include capability
1012declarations 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
1014Extra 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"
1022ref_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)
1036capability = 1*(LC_ALPHA / DIGIT / "-" / "_")
1037LC_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
1042any_ref = PKT-LINE(obj-id SP name LF)
1043peeled_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
1059C: Content-Type: application/x-git-upload-pack-request
1060C:
1061C: 0032want 0a53e9ddeaddad63ad106860237bbf53411d11a7\n
1062C: 0032have 441b40d833fdfa93eb2908e52742248faf0ee993\n
1063C: 0000</code></pre>
1064</div></div>
1065<div class="literalblock">
1066<div class="content">
1067<pre><code>S: 200 OK
1068S: Content-Type: application/x-git-upload-pack-result
1069S: Cache-Control: no-cache
1070S:
1071S: ....ACK %s, continue
1072S: ....NAK</code></pre>
1073</div></div>
1074<div class="paragraph"><p>Clients MUST NOT reuse or revalidate a cached response.
1075Servers MUST include sufficient Cache-Control headers
1076to 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.
1079Clients MUST NOT reference an id in a "want" command which did not
1080appear in the response obtained through ref discovery unless the
1081server 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
1088request_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)
1094want_pkt = PKT-LINE(want LF)
1095want = "want" SP id
1096cap_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> 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;...............................
1123C: 0032want &lt;want #2&gt;...............................
1124....
1125C: 0032have &lt;common #1&gt;.............................
1126C: 0032have &lt;common #2&gt;.............................
1127....
1128C: 0032have &lt;have #1&gt;...............................
1129C: 0032have &lt;have #2&gt;...............................
1130....
1131C: 0000</code></pre>
1132</div></div>
1133<div class="paragraph"><p>The stream is organized into "commands", with each command
1134appearing by itself in a pkt-line. Within a command line,
1135the text leading up to the first space is the command name,
1136and the remainder of the line to the first LF is the value.
1137Command lines are terminated with an LF as the last byte of
1138the pkt-line value.</p></div>
1139<div class="paragraph"><p>Commands MUST appear in the following order, if they appear
1140at all in the request stream:</p></div>
1141<div class="ulist"><ul>
1142<li>
1143<p>
1144"want"
1145</p>
1146</li>
1147<li>
1148<p>
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
1155object name as its value. Multiple object names MUST be sent by sending
1156multiple commands. Object names MUST be given using the object format
1157negotiated 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
1159from <code>c_pending</code>. Less 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
1161received one of those back from <code>s_common</code>, or the client has
1162emptied <code>c_pending</code> it SHOULD include a "done" command to let
1163the 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
1171the reflog to permit slightly stale requests.</p></div>
1172<div class="paragraph"><p>If no "want" objects are received, send an error:
1173TODO: 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:
1175TODO: 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
1180a ref, add it to <code>s_common</code>. If a commit is added to <code>s_common</code>,
1181do 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
1184request ends with "done", it replies with the pack.
1185TODO: 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
1191by the git-upload-pack service, and the pack is embedded into
1192stream 1. Progress messages from the server side MAY appear
1193in stream 2.</p></div>
1194<div class="paragraph"><p>Here a "closed set of objects" is defined to have at least
1195one 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
1197status continue response:
1198TODO: 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
1214C: Content-Type: application/x-git-receive-pack-request
1215C:
1216C: ....0a53e9ddeaddad63ad106860237bbf53411d11a7 441b40d833fdfa93eb2908e52742248faf0ee993 refs/heads/maint\0 report-status
1217C: 0000
1218C: PACK....</code></pre>
1219</div></div>
1220<div class="literalblock">
1221<div class="content">
1222<pre><code>S: 200 OK
1223S: Content-Type: application/x-git-receive-pack-result
1224S: Cache-Control: no-cache
1225S:
1226S: ....</code></pre>
1227</div></div>
1228<div class="paragraph"><p>Clients MUST NOT reuse or revalidate a cached response.
1229Servers MUST include sufficient Cache-Control headers
1230to 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.
1233Within the command portion of the request body clients SHOULD send
1234the 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)
1244command_pkt = PKT-LINE(command LF)
1245cap_list = *(SP capability) SP</code></pre>
1246</div></div>
1247<div class="literalblock">
1248<div class="content">
1249<pre><code>command = create / delete / update
1250create = zero-id SP new_id SP name
1251delete = old_id SP zero-id SP name
1252update = 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="http://www.ietf.org/rfc/rfc1738.txt">RFC 1738: Uniform Resource Locators (URL)</a>
1261<a href="http://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">
1281Last updated
Junio C Hamanocb582ca2022-11-21 06:55:271282 2022-08-19 06:11:07 JST
Junio C Hamano04495a12022-08-18 21:13:081283</div>
1284</div>
1285</body>
1286</html>