blob: 9bddaed6807dc69c128a809ab108ad414750978f [file] [log] [blame]
Junio C Hamano944ce252018-05-30 22:25:261<?xml version="1.0" encoding="UTF-8"?>
Junio C Hamanoc5bd79e2014-01-27 21:31:262<!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" />
Junio C Hamano944ce252018-05-30 22:25:267<meta name="generator" content="AsciiDoc 8.6.10" />
Junio C Hamanoc5bd79e2014-01-27 21:31:268<title>HTTP transfer protocols</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
Junio C Hamanoc14e6ad2014-10-31 20:25:5391.monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
Junio C Hamanoc5bd79e2014-01-27 21:31:2695 padding: 0;
96 margin: 0;
97}
Junio C Hamanoc14e6ad2014-10-31 20:25:5398pre {
99 white-space: pre-wrap;
100}
Junio C Hamanoc5bd79e2014-01-27 21:31:26101
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; }
Junio C Hamanoc14e6ad2014-10-31 20:25:53229span.image img { border-style: none; vertical-align: text-bottom; }
Junio C Hamanoc5bd79e2014-01-27 21:31:26230a.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
Junio C Hamanoc14e6ad2014-10-31 20:25:53359div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
Junio C Hamanoc5bd79e2014-01-27 21:31:26360 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
Junio C Hamanoc14e6ad2014-10-31 20:25:53417div.unbreakable { page-break-inside: avoid; }
418
Junio C Hamanoc5bd79e2014-01-27 21:31:26419
420/*
421 * xhtml11 specific
422 *
423 * */
424
Junio C Hamanoc5bd79e2014-01-27 21:31:26425div.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 overriden 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
Junio C Hamanoc5bd79e2014-01-27 21:31:26458table.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}
Junio C Hamanoc14e6ad2014-10-31 20:25:53537
538
Junio C Hamanoc5bd79e2014-01-27 21:31:26539</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;
Junio C Hamanoc14e6ad2014-10-31 20:25:53583 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
Junio C Hamanoc5bd79e2014-01-27 21:31:26584 // 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];
Junio C Hamanoc14e6ad2014-10-31 20:25:53612 if (entry.nodeName.toLowerCase() == 'div'
Junio C Hamanoc5bd79e2014-01-27 21:31:26613 && 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];
Junio C Hamanoc14e6ad2014-10-31 20:25:53658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
Junio C Hamanoc5bd79e2014-01-27 21:31:26659 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="article">
736<div id="header">
737<h1>HTTP transfer protocols</h1>
738</div>
739<div id="content">
740<div id="preamble">
741<div class="sectionbody">
742<div class="paragraph"><p>Git supports two HTTP based transfer protocols. A "dumb" protocol
743which requires only a standard HTTP server on the server end of the
744connection, and a "smart" protocol which requires a Git aware CGI
745(or server module). This document describes both protocols.</p></div>
746<div class="paragraph"><p>As a design feature smart clients can automatically upgrade "dumb"
747protocol URLs to smart URLs. This permits all users to have the
748same published URL, and the peers automatically select the most
749efficient transport available to them.</p></div>
750</div>
751</div>
752<div class="sect1">
753<h2 id="_url_format">URL Format</h2>
754<div class="sectionbody">
755<div class="paragraph"><p>URLs for Git repositories accessed by HTTP use the standard HTTP
756URL syntax documented by RFC 1738, so they are of the form:</p></div>
757<div class="literalblock">
758<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53759<pre><code>http://&lt;host&gt;:&lt;port&gt;/&lt;path&gt;?&lt;searchpart&gt;</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:26760</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53761<div class="paragraph"><p>Within this documentation the placeholder <code>$GIT_URL</code> will stand for
Junio C Hamanoc5bd79e2014-01-27 21:31:26762the http:// repository URL entered by the end-user.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53763<div class="paragraph"><p>Servers SHOULD handle all requests to locations matching <code>$GIT_URL</code>, as
Junio C Hamanoc5bd79e2014-01-27 21:31:26764both the "smart" and "dumb" HTTP protocols used by Git operate
765by appending additional path components onto the end of the user
Junio C Hamanoc14e6ad2014-10-31 20:25:53766supplied <code>$GIT_URL</code> string.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:26767<div class="paragraph"><p>An example of a dumb client requesting for a loose object:</p></div>
768<div class="literalblock">
769<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53770<pre><code>$GIT_URL: http://example.com:8080/git/repo.git
771URL request: http://example.com:8080/git/repo.git/objects/d0/49f6c27a2244e12041955e262a404c7faba355</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:26772</div></div>
773<div class="paragraph"><p>An example of a smart request to a catch-all gateway:</p></div>
774<div class="literalblock">
775<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53776<pre><code>$GIT_URL: http://example.com/daemon.cgi?svc=git&amp;q=
777URL request: http://example.com/daemon.cgi?svc=git&amp;q=/info/refs&amp;service=git-receive-pack</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:26778</div></div>
779<div class="paragraph"><p>An example of a request to a submodule:</p></div>
780<div class="literalblock">
781<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53782<pre><code>$GIT_URL: http://example.com/git/repo.git/path/submodule.git
783URL request: http://example.com/git/repo.git/path/submodule.git/info/refs</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:26784</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53785<div class="paragraph"><p>Clients MUST strip a trailing <code>/</code>, if present, from the user supplied
786<code>$GIT_URL</code> string to prevent empty path tokens (<code>//</code>) from appearing
Junio C Hamanoc5bd79e2014-01-27 21:31:26787in any URL sent to a server. Compatible clients MUST expand
Junio C Hamanoc14e6ad2014-10-31 20:25:53788<code>$GIT_URL/info/refs</code> as <code>foo/info/refs</code> and not <code>foo//info/refs</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:26789</div>
790</div>
791<div class="sect1">
792<h2 id="_authentication">Authentication</h2>
793<div class="sectionbody">
794<div class="paragraph"><p>Standard HTTP authentication is used if authentication is required
795to access a repository, and MAY be configured and enforced by the
796HTTP server software.</p></div>
797<div class="paragraph"><p>Because Git repositories are accessed by standard path components
798server administrators MAY use directory based permissions within
799their HTTP server to control repository access.</p></div>
Junio C Hamano38d02532014-06-26 21:48:50800<div class="paragraph"><p>Clients SHOULD support Basic authentication as described by RFC 2617.
Junio C Hamanoc5bd79e2014-01-27 21:31:26801Servers SHOULD support Basic authentication by relying upon the
802HTTP server placed in front of the Git server software.</p></div>
803<div class="paragraph"><p>Servers SHOULD NOT require HTTP cookies for the purposes of
804authentication or access control.</p></div>
805<div class="paragraph"><p>Clients and servers MAY support other common forms of HTTP based
806authentication, such as Digest authentication.</p></div>
807</div>
808</div>
809<div class="sect1">
810<h2 id="_ssl">SSL</h2>
811<div class="sectionbody">
812<div class="paragraph"><p>Clients and servers SHOULD support SSL, particularly to protect
813passwords when relying on Basic HTTP authentication.</p></div>
814</div>
815</div>
816<div class="sect1">
817<h2 id="_session_state">Session State</h2>
818<div class="sectionbody">
819<div class="paragraph"><p>The Git over HTTP protocol (much like HTTP itself) is stateless
820from the perspective of the HTTP server side. All state MUST be
821retained and managed by the client process. This permits simple
822round-robin load-balancing on the server side, without needing to
823worry about state management.</p></div>
824<div class="paragraph"><p>Clients MUST NOT require state management on the server side in
825order to function correctly.</p></div>
826<div class="paragraph"><p>Servers MUST NOT require HTTP cookies in order to function correctly.
827Clients MAY store and forward HTTP cookies during request processing
828as described by RFC 2616 (HTTP/1.1). Servers SHOULD ignore any
829cookies sent by a client.</p></div>
830</div>
831</div>
832<div class="sect1">
833<h2 id="_general_request_processing">General Request Processing</h2>
834<div class="sectionbody">
835<div class="paragraph"><p>Except where noted, all standard HTTP behavior SHOULD be assumed
836by both client and server. This includes (but is not necessarily
837limited to):</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53838<div class="paragraph"><p>If there is no repository at <code>$GIT_URL</code>, or the resource pointed to by a
839location matching <code>$GIT_URL</code> does not exist, the server MUST NOT respond
840with <code>200 OK</code> response. A server SHOULD respond with
841<code>404 Not Found</code>, <code>410 Gone</code>, or any other suitable HTTP status code
Junio C Hamanoc5bd79e2014-01-27 21:31:26842which does not imply the resource exists as requested.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53843<div class="paragraph"><p>If there is a repository at <code>$GIT_URL</code>, but access is not currently
844permitted, the server MUST respond with the <code>403 Forbidden</code> HTTP
Junio C Hamanoc5bd79e2014-01-27 21:31:26845status code.</p></div>
846<div class="paragraph"><p>Servers SHOULD support both HTTP 1.0 and HTTP 1.1.
847Servers SHOULD support chunked encoding for both request and response
848bodies.</p></div>
849<div class="paragraph"><p>Clients SHOULD support both HTTP 1.0 and HTTP 1.1.
850Clients SHOULD support chunked encoding for both request and response
851bodies.</p></div>
852<div class="paragraph"><p>Servers MAY return ETag and/or Last-Modified headers.</p></div>
853<div class="paragraph"><p>Clients MAY revalidate cached entities by including If-Modified-Since
854and/or If-None-Match request headers.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53855<div class="paragraph"><p>Servers MAY return <code>304 Not Modified</code> if the relevant headers appear
Junio C Hamanoc5bd79e2014-01-27 21:31:26856in the request and the entity has not changed. Clients MUST treat
Junio C Hamanoc14e6ad2014-10-31 20:25:53857<code>304 Not Modified</code> identical to <code>200 OK</code> by reusing the cached entity.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:26858<div class="paragraph"><p>Clients MAY reuse a cached entity without revalidation if the
859Cache-Control and/or Expires header permits caching. Clients and
860servers MUST follow RFC 2616 for cache controls.</p></div>
861</div>
862</div>
863<div class="sect1">
864<h2 id="_discovering_references">Discovering References</h2>
865<div class="sectionbody">
866<div class="paragraph"><p>All HTTP clients MUST begin either a fetch or a push exchange by
867discovering the references available on the remote repository.</p></div>
868<div class="sect2">
869<h3 id="_dumb_clients">Dumb Clients</h3>
870<div class="paragraph"><p>HTTP clients that only support the "dumb" protocol MUST discover
871references by making a request for the special info/refs file of
872the repository.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53873<div class="paragraph"><p>Dumb HTTP clients MUST make a <code>GET</code> request to <code>$GIT_URL/info/refs</code>,
Junio C Hamanoc5bd79e2014-01-27 21:31:26874without any search/query parameters.</p></div>
875<div class="literalblock">
876<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53877<pre><code>C: GET $GIT_URL/info/refs HTTP/1.0</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:26878</div></div>
879<div class="literalblock">
880<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53881<pre><code>S: 200 OK
Junio C Hamanoc5bd79e2014-01-27 21:31:26882S:
883S: 95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint
884S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master
885S: 2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0
Junio C Hamanoc14e6ad2014-10-31 20:25:53886S: a3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:26887</div></div>
888<div class="paragraph"><p>The Content-Type of the returned info/refs entity SHOULD be
Junio C Hamanoc14e6ad2014-10-31 20:25:53889<code>text/plain; charset=utf-8</code>, but MAY be any content type.
Junio C Hamanoc5bd79e2014-01-27 21:31:26890Clients MUST NOT attempt to validate the returned Content-Type.
891Dumb servers MUST NOT return a return type starting with
Junio C Hamanoc14e6ad2014-10-31 20:25:53892<code>application/x-git-</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:26893<div class="paragraph"><p>Cache-Control headers MAY be returned to disable caching of the
894returned entity.</p></div>
895<div class="paragraph"><p>When examining the response clients SHOULD only examine the HTTP
Junio C Hamanoc14e6ad2014-10-31 20:25:53896status code. Valid responses are <code>200 OK</code>, or <code>304 Not Modified</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:26897<div class="paragraph"><p>The returned content is a UNIX formatted text file describing
898each ref and its known value. The file SHOULD be sorted by name
899according to the C locale ordering. The file SHOULD NOT include
Junio C Hamanoc14e6ad2014-10-31 20:25:53900the default ref named <code>HEAD</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:26901<div class="literalblock">
902<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53903<pre><code>info_refs = *( ref_record )
904ref_record = any_ref / peeled_ref</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:26905</div></div>
906<div class="literalblock">
907<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53908<pre><code>any_ref = obj-id HTAB refname LF
Junio C Hamanoc5bd79e2014-01-27 21:31:26909peeled_ref = obj-id HTAB refname LF
Junio C Hamanoc14e6ad2014-10-31 20:25:53910 obj-id HTAB refname "^{}" LF</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:26911</div></div>
912</div>
913<div class="sect2">
914<h3 id="_smart_clients">Smart Clients</h3>
915<div class="paragraph"><p>HTTP clients that support the "smart" protocol (or both the
916"smart" and "dumb" protocols) MUST discover references by making
917a parameterized request for the info/refs file of the repository.</p></div>
918<div class="paragraph"><p>The request MUST contain exactly one query parameter,
Junio C Hamanoc14e6ad2014-10-31 20:25:53919<code>service=$servicename</code>, where <code>$servicename</code> MUST be the service
Junio C Hamanoc5bd79e2014-01-27 21:31:26920name the client wishes to contact to complete the operation.
921The request MUST NOT contain additional query parameters.</p></div>
922<div class="literalblock">
923<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53924<pre><code>C: GET $GIT_URL/info/refs?service=git-upload-pack HTTP/1.0</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:26925</div></div>
926<div class="paragraph"><p>dumb server reply:</p></div>
927<div class="literalblock">
928<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53929<pre><code>S: 200 OK
Junio C Hamanoc5bd79e2014-01-27 21:31:26930S:
931S: 95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint
932S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master
933S: 2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0
Junio C Hamanoc14e6ad2014-10-31 20:25:53934S: a3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:26935</div></div>
936<div class="paragraph"><p>smart server reply:</p></div>
937<div class="literalblock">
938<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53939<pre><code>S: 200 OK
Junio C Hamanoc5bd79e2014-01-27 21:31:26940S: Content-Type: application/x-git-upload-pack-advertisement
941S: Cache-Control: no-cache
942S:
943S: 001e# service=git-upload-pack\n
Junio C Hamano45badf02018-03-14 21:56:41944S: 0000
Junio C Hamanoc5bd79e2014-01-27 21:31:26945S: 004895dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint\0multi_ack\n
946S: 0042d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master\n
947S: 003c2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0\n
Junio C Hamano45badf02018-03-14 21:56:41948S: 003fa3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}\n
949S: 0000</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:26950</div></div>
Junio C Hamano912712b2017-12-06 18:04:01951<div class="paragraph"><p>The client may send Extra Parameters (see
952Documentation/technical/pack-protocol.txt) as a colon-separated string
953in the Git-Protocol HTTP header.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:26954<div class="sect3">
955<h4 id="_dumb_server_response">Dumb Server Response</h4>
956<div class="paragraph"><p>Dumb servers MUST respond with the dumb server reply format.</p></div>
957<div class="paragraph"><p>See the prior section under dumb clients for a more detailed
958description of the dumb server response.</p></div>
959</div>
960<div class="sect3">
961<h4 id="_smart_server_response">Smart Server Response</h4>
962<div class="paragraph"><p>If the server does not recognize the requested service name, or the
963requested service name has been disabled by the server administrator,
Junio C Hamanoc14e6ad2014-10-31 20:25:53964the server MUST respond with the <code>403 Forbidden</code> HTTP status code.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:26965<div class="paragraph"><p>Otherwise, smart servers MUST respond with the smart server reply
966format for the requested service name.</p></div>
967<div class="paragraph"><p>Cache-Control headers SHOULD be used to disable caching of the
968returned entity.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53969<div class="paragraph"><p>The Content-Type MUST be <code>application/x-$servicename-advertisement</code>.
Junio C Hamanoc5bd79e2014-01-27 21:31:26970Clients SHOULD fall back to the dumb protocol if another content
971type is returned. When falling back to the dumb protocol clients
Junio C Hamanoc14e6ad2014-10-31 20:25:53972SHOULD NOT make an additional request to <code>$GIT_URL/info/refs</code>, but
Junio C Hamanoc5bd79e2014-01-27 21:31:26973instead SHOULD use the response already in hand. Clients MUST NOT
974continue if they do not support the dumb protocol.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53975<div class="paragraph"><p>Clients MUST validate the status code is either <code>200 OK</code> or
976<code>304 Not Modified</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:26977<div class="paragraph"><p>Clients MUST validate the first five bytes of the response entity
Junio C Hamanoc14e6ad2014-10-31 20:25:53978matches the regex <code>^[0-9a-f]{4}#</code>. If this test fails, clients
Junio C Hamanoc5bd79e2014-01-27 21:31:26979MUST NOT continue.</p></div>
980<div class="paragraph"><p>Clients MUST parse the entire response as a sequence of pkt-line
981records.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53982<div class="paragraph"><p>Clients MUST verify the first pkt-line is <code># service=$servicename</code>.
Junio C Hamanoc5bd79e2014-01-27 21:31:26983Servers MUST set $servicename to be the request parameter value.
984Servers SHOULD include an LF at the end of this line.
985Clients MUST ignore an LF at the end of the line.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:53986<div class="paragraph"><p>Servers MUST terminate the response with the magic <code>0000</code> end
Junio C Hamanoc5bd79e2014-01-27 21:31:26987pkt-line marker.</p></div>
988<div class="paragraph"><p>The returned response is a pkt-line stream describing each ref and
989its known value. The stream SHOULD be sorted by name according to
990the C locale ordering. The stream SHOULD include the default ref
Junio C Hamanoc14e6ad2014-10-31 20:25:53991named <code>HEAD</code> as the first ref. The stream MUST include capability
Junio C Hamanoc5bd79e2014-01-27 21:31:26992declarations behind a NUL on the first ref.</p></div>
Junio C Hamano912712b2017-12-06 18:04:01993<div class="paragraph"><p>The returned response contains "version 1" if "version=1" was sent as an
994Extra Parameter.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:26995<div class="literalblock">
996<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53997<pre><code>smart_reply = PKT-LINE("# service=$servicename" LF)
Junio C Hamano45badf02018-03-14 21:56:41998 "0000"
Junio C Hamano912712b2017-12-06 18:04:01999 *1("version 1")
Junio C Hamanoc5bd79e2014-01-27 21:31:261000 ref_list
1001 "0000"
Junio C Hamanoc14e6ad2014-10-31 20:25:531002ref_list = empty_list / non_empty_list</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261003</div></div>
1004<div class="literalblock">
1005<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531006<pre><code>empty_list = PKT-LINE(zero-id SP "capabilities^{}" NUL cap-list LF)</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261007</div></div>
1008<div class="literalblock">
1009<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531010<pre><code>non_empty_list = PKT-LINE(obj-id SP name NUL cap_list LF)
1011 *ref_record</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261012</div></div>
1013<div class="literalblock">
1014<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531015<pre><code>cap-list = capability *(SP capability)
Junio C Hamanoc5bd79e2014-01-27 21:31:261016capability = 1*(LC_ALPHA / DIGIT / "-" / "_")
Junio C Hamanoc14e6ad2014-10-31 20:25:531017LC_ALPHA = %x61-7A</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261018</div></div>
1019<div class="literalblock">
1020<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531021<pre><code>ref_record = any_ref / peeled_ref
Junio C Hamanoc5bd79e2014-01-27 21:31:261022any_ref = PKT-LINE(obj-id SP name LF)
1023peeled_ref = PKT-LINE(obj-id SP name LF)
Junio C Hamanoc14e6ad2014-10-31 20:25:531024 PKT-LINE(obj-id SP name "^{}" LF</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261025</div></div>
1026</div>
1027</div>
1028</div>
1029</div>
1030<div class="sect1">
1031<h2 id="_smart_service_git_upload_pack">Smart Service git-upload-pack</h2>
1032<div class="sectionbody">
Junio C Hamanoc14e6ad2014-10-31 20:25:531033<div class="paragraph"><p>This service reads from the repository pointed to by <code>$GIT_URL</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:261034<div class="paragraph"><p>Clients MUST first perform ref discovery with
Junio C Hamanoc14e6ad2014-10-31 20:25:531035<code>$GIT_URL/info/refs?service=git-upload-pack</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:261036<div class="literalblock">
1037<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531038<pre><code>C: POST $GIT_URL/git-upload-pack HTTP/1.0
Junio C Hamanoc5bd79e2014-01-27 21:31:261039C: Content-Type: application/x-git-upload-pack-request
1040C:
1041C: 0032want 0a53e9ddeaddad63ad106860237bbf53411d11a7\n
1042C: 0032have 441b40d833fdfa93eb2908e52742248faf0ee993\n
Junio C Hamanoc14e6ad2014-10-31 20:25:531043C: 0000</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261044</div></div>
1045<div class="literalblock">
1046<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531047<pre><code>S: 200 OK
Junio C Hamanoc5bd79e2014-01-27 21:31:261048S: Content-Type: application/x-git-upload-pack-result
1049S: Cache-Control: no-cache
1050S:
1051S: ....ACK %s, continue
Junio C Hamanoc14e6ad2014-10-31 20:25:531052S: ....NAK</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261053</div></div>
1054<div class="paragraph"><p>Clients MUST NOT reuse or revalidate a cached response.
1055Servers MUST include sufficient Cache-Control headers
1056to prevent caching of the response.</p></div>
1057<div class="paragraph"><p>Servers SHOULD support all capabilities defined here.</p></div>
1058<div class="paragraph"><p>Clients MUST send at least one "want" command in the request body.
1059Clients MUST NOT reference an id in a "want" command which did not
1060appear in the response obtained through ref discovery unless the
Junio C Hamano85f1fde2015-06-01 20:37:321061server advertises capability <code>allow-tip-sha1-in-want</code> or
1062<code>allow-reachable-sha1-in-want</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:261063<div class="literalblock">
1064<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531065<pre><code>compute_request = want_list
Junio C Hamanoc5bd79e2014-01-27 21:31:261066 have_list
1067 request_end
Junio C Hamanoc14e6ad2014-10-31 20:25:531068request_end = "0000" / "done"</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261069</div></div>
1070<div class="literalblock">
1071<div class="content">
Junio C Hamanobfd91f42018-08-17 22:21:161072<pre><code>want_list = PKT-LINE(want SP cap_list LF)
Junio C Hamanoc5bd79e2014-01-27 21:31:261073 *(want_pkt)
1074want_pkt = PKT-LINE(want LF)
1075want = "want" SP id
Junio C Hamanobfd91f42018-08-17 22:21:161076cap_list = capability *(SP capability)</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261077</div></div>
1078<div class="literalblock">
1079<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531080<pre><code>have_list = *PKT-LINE("have" SP id LF)</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261081</div></div>
1082<div class="paragraph"><p>TODO: Document this further.</p></div>
1083<div class="sect2">
1084<h3 id="_the_negotiation_algorithm">The Negotiation Algorithm</h3>
1085<div class="paragraph"><p>The computation to select the minimal pack proceeds as follows
1086(C = client, S = server):</p></div>
1087<div class="paragraph"><p><em>init step:</em></p></div>
1088<div class="paragraph"><p>C: Use ref discovery to obtain the advertised refs.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531089<div class="paragraph"><p>C: Place any object seen into set <code>advertised</code>.</p></div>
1090<div class="paragraph"><p>C: Build an empty set, <code>common</code>, to hold the objects that are later
Junio C Hamanoc5bd79e2014-01-27 21:31:261091 determined to be on both ends.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531092<div class="paragraph"><p>C: Build a set, <code>want</code>, of the objects from <code>advertised</code> the client
Junio C Hamanoc5bd79e2014-01-27 21:31:261093 wants to fetch, based on what it saw during ref discovery.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531094<div class="paragraph"><p>C: Start a queue, <code>c_pending</code>, ordered by commit time (popping newest
Junio C Hamanoc5bd79e2014-01-27 21:31:261095 first). Add all client refs. When a commit is popped from
1096 the queue its parents SHOULD be automatically inserted back.
1097 Commits MUST only enter the queue once.</p></div>
1098<div class="paragraph"><p><em>one compute step:</em></p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531099<div class="paragraph"><p>C: Send one <code>$GIT_URL/git-upload-pack</code> request:</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:261100<div class="literalblock">
1101<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531102<pre><code>C: 0032want &lt;want #1&gt;...............................
Junio C Hamanoc5bd79e2014-01-27 21:31:261103C: 0032want &lt;want #2&gt;...............................
1104....
1105C: 0032have &lt;common #1&gt;.............................
1106C: 0032have &lt;common #2&gt;.............................
1107....
1108C: 0032have &lt;have #1&gt;...............................
1109C: 0032have &lt;have #2&gt;...............................
1110....
Junio C Hamanoc14e6ad2014-10-31 20:25:531111C: 0000</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261112</div></div>
1113<div class="paragraph"><p>The stream is organized into "commands", with each command
Junio C Hamanoe1aeb5e2014-06-06 19:16:291114appearing by itself in a pkt-line. Within a command line,
Junio C Hamanoc5bd79e2014-01-27 21:31:261115the text leading up to the first space is the command name,
1116and the remainder of the line to the first LF is the value.
1117Command lines are terminated with an LF as the last byte of
1118the pkt-line value.</p></div>
1119<div class="paragraph"><p>Commands MUST appear in the following order, if they appear
1120at all in the request stream:</p></div>
1121<div class="ulist"><ul>
1122<li>
1123<p>
1124"want"
1125</p>
1126</li>
1127<li>
1128<p>
1129"have"
1130</p>
1131</li>
1132</ul></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531133<div class="paragraph"><p>The stream is terminated by a pkt-line flush (<code>0000</code>).</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:261134<div class="paragraph"><p>A single "want" or "have" command MUST have one hex formatted
1135SHA-1 as its value. Multiple SHA-1s MUST be sent by sending
1136multiple commands.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531137<div class="paragraph"><p>The <code>have</code> list is created by popping the first 32 commits
1138from <code>c_pending</code>. Less can be supplied if <code>c_pending</code> empties.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:261139<div class="paragraph"><p>If the client has sent 256 "have" commits and has not yet
Junio C Hamanoc14e6ad2014-10-31 20:25:531140received one of those back from <code>s_common</code>, or the client has
1141emptied <code>c_pending</code> it SHOULD include a "done" command to let
Junio C Hamanoc5bd79e2014-01-27 21:31:261142the server know it won&#8217;t proceed:</p></div>
1143<div class="literalblock">
1144<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531145<pre><code>C: 0009done</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261146</div></div>
1147<div class="paragraph"><p>S: Parse the git-upload-pack request:</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531148<div class="paragraph"><p>Verify all objects in <code>want</code> are directly reachable from refs.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:261149<div class="paragraph"><p>The server MAY walk backwards through history or through
1150the reflog to permit slightly stale requests.</p></div>
1151<div class="paragraph"><p>If no "want" objects are received, send an error:
1152TODO: Define error if no "want" lines are requested.</p></div>
1153<div class="paragraph"><p>If any "want" object is not reachable, send an error:
1154TODO: Define error if an invalid "want" is requested.</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531155<div class="paragraph"><p>Create an empty list, <code>s_common</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:261156<div class="paragraph"><p>If "have" was sent:</p></div>
1157<div class="paragraph"><p>Loop through the objects in the order supplied by the client.</p></div>
1158<div class="paragraph"><p>For each object, if the server has the object reachable from
Junio C Hamanoc14e6ad2014-10-31 20:25:531159a ref, add it to <code>s_common</code>. If a commit is added to <code>s_common</code>,
1160do not add any ancestors, even if they also appear in <code>have</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:261161<div class="paragraph"><p>S: Send the git-upload-pack response:</p></div>
1162<div class="paragraph"><p>If the server has found a closed set of objects to pack or the
1163request ends with "done", it replies with the pack.
1164TODO: Document the pack based response</p></div>
1165<div class="literalblock">
1166<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531167<pre><code>S: PACK...</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261168</div></div>
1169<div class="paragraph"><p>The returned stream is the side-band-64k protocol supported
1170by the git-upload-pack service, and the pack is embedded into
1171stream 1. Progress messages from the server side MAY appear
1172in stream 2.</p></div>
1173<div class="paragraph"><p>Here a "closed set of objects" is defined to have at least
1174one path from every "want" to at least one "common" object.</p></div>
1175<div class="paragraph"><p>If the server needs more information, it replies with a
1176status continue response:
1177TODO: Document the non-pack response</p></div>
1178<div class="paragraph"><p>C: Parse the upload-pack response:
1179 TODO: Document parsing response</p></div>
1180<div class="paragraph"><p><em>Do another compute step.</em></p></div>
1181</div>
1182</div>
1183</div>
1184<div class="sect1">
1185<h2 id="_smart_service_git_receive_pack">Smart Service git-receive-pack</h2>
1186<div class="sectionbody">
Junio C Hamanoc14e6ad2014-10-31 20:25:531187<div class="paragraph"><p>This service reads from the repository pointed to by <code>$GIT_URL</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:261188<div class="paragraph"><p>Clients MUST first perform ref discovery with
Junio C Hamanoc14e6ad2014-10-31 20:25:531189<code>$GIT_URL/info/refs?service=git-receive-pack</code>.</p></div>
Junio C Hamanoc5bd79e2014-01-27 21:31:261190<div class="literalblock">
1191<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531192<pre><code>C: POST $GIT_URL/git-receive-pack HTTP/1.0
Junio C Hamanoc5bd79e2014-01-27 21:31:261193C: Content-Type: application/x-git-receive-pack-request
1194C:
1195C: ....0a53e9ddeaddad63ad106860237bbf53411d11a7 441b40d833fdfa93eb2908e52742248faf0ee993 refs/heads/maint\0 report-status
1196C: 0000
Junio C Hamanoc14e6ad2014-10-31 20:25:531197C: PACK....</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261198</div></div>
1199<div class="literalblock">
1200<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531201<pre><code>S: 200 OK
Junio C Hamanoc5bd79e2014-01-27 21:31:261202S: Content-Type: application/x-git-receive-pack-result
1203S: Cache-Control: no-cache
1204S:
Junio C Hamanoc14e6ad2014-10-31 20:25:531205S: ....</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261206</div></div>
1207<div class="paragraph"><p>Clients MUST NOT reuse or revalidate a cached response.
1208Servers MUST include sufficient Cache-Control headers
1209to prevent caching of the response.</p></div>
1210<div class="paragraph"><p>Servers SHOULD support all capabilities defined here.</p></div>
1211<div class="paragraph"><p>Clients MUST send at least one command in the request body.
1212Within the command portion of the request body clients SHOULD send
1213the id obtained through ref discovery as old_id.</p></div>
1214<div class="literalblock">
1215<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531216<pre><code>update_request = command_list
1217 "PACK" &lt;binary data&gt;</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261218</div></div>
1219<div class="literalblock">
1220<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531221<pre><code>command_list = PKT-LINE(command NUL cap_list LF)
Junio C Hamanoc5bd79e2014-01-27 21:31:261222 *(command_pkt)
1223command_pkt = PKT-LINE(command LF)
Junio C Hamanoc14e6ad2014-10-31 20:25:531224cap_list = *(SP capability) SP</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261225</div></div>
1226<div class="literalblock">
1227<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531228<pre><code>command = create / delete / update
Junio C Hamanoc5bd79e2014-01-27 21:31:261229create = zero-id SP new_id SP name
1230delete = old_id SP zero-id SP name
Junio C Hamanoc14e6ad2014-10-31 20:25:531231update = old_id SP new_id SP name</code></pre>
Junio C Hamanoc5bd79e2014-01-27 21:31:261232</div></div>
1233<div class="paragraph"><p>TODO: Document this further.</p></div>
1234</div>
1235</div>
1236<div class="sect1">
1237<h2 id="_references">References</h2>
1238<div class="sectionbody">
1239<div class="paragraph"><p><a href="http://www.ietf.org/rfc/rfc1738.txt">RFC 1738: Uniform Resource Locators (URL)</a>
1240<a href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616: Hypertext Transfer Protocol&#8201;&#8212;&#8201;HTTP/1.1</a>
1241link:technical/pack-protocol.html
1242link:technical/protocol-capabilities.html</p></div>
1243</div>
1244</div>
1245</div>
1246<div id="footnotes"><hr /></div>
1247<div id="footer">
1248<div id="footer-text">
Junio C Hamano2ef0ba32018-01-26 23:13:531249Last updated
Junio C Hamanocf731002019-01-29 21:19:521250 2018-08-17 15:20:20 PDT
Junio C Hamanoc5bd79e2014-01-27 21:31:261251</div>
1252</div>
1253</body>
1254</html>