1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
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 */
14 font-family: Georgia,serif;
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
22 #author, #revnumber, #revdate, #revremark,
24 font-family: Arial,Helvetica,sans-serif;
28 margin:
1em
5%
1em
5%;
33 text-decoration: underline;
49 h1, h2, h3, h4, h5, h6 {
57 border-bottom:
2px solid silver;
77 border:
1px solid silver;
88 ul
> li { color: #aaa; }
89 ul
> li
> * { color: black; }
91 .monospaced, code, pre {
92 font-family:
"Courier New", Courier, monospace;
99 white-space: pre-wrap;
109 #revnumber, #revdate, #revremark {
114 border-top:
2px solid silver;
120 padding-bottom:
0.5em;
124 padding-bottom:
0.5em;
129 margin-bottom:
1.5em;
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
135 margin-bottom:
1.5em;
137 div.admonitionblock {
139 margin-bottom:
2.0em;
144 div.content { /* Block element content. */
148 /* Block element titles. */
149 div.title, caption.title {
154 margin-bottom:
0.5em;
160 td div.title:first-child {
163 div.content div.title:first-child {
166 div.content + div.title {
170 div.sidebarblock
> div.content {
172 border:
1px solid #dddddd;
173 border-left:
4px solid #f0f0f0;
177 div.listingblock
> div.content {
178 border:
1px solid #dddddd;
179 border-left:
5px solid #f0f0f0;
184 div.quoteblock, div.verseblock {
188 border-left:
5px solid #f0f0f0;
192 div.quoteblock
> div.attribution {
197 div.verseblock
> pre.content {
198 font-family: inherit;
201 div.verseblock
> div.attribution {
205 /* DEPRECATED: Pre version
8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
210 div.admonitionblock .icon {
214 text-decoration: underline;
216 padding-right:
0.5em;
218 div.admonitionblock td.content {
220 border-left:
3px solid #dddddd;
223 div.exampleblock
> div.content {
224 border-left:
3px solid #dddddd;
228 div.imageblock div.content { padding-left:
0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
234 margin-bottom:
0.8em;
247 list-style-position: outside;
250 list-style-type: decimal;
253 list-style-type: lower-alpha;
256 list-style-type: upper-alpha;
259 list-style-type: lower-roman;
262 list-style-type: upper-roman;
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
269 margin-bottom:
0.1em;
281 margin-bottom:
0.8em;
284 padding-bottom:
15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
292 padding-right:
0.8em;
298 div.hdlist.compact tr {
307 .footnote, .footnoteref {
311 span.footnote, span.footnoteref {
312 vertical-align: super;
316 margin:
20px
0 20px
0;
320 #footnotes div.footnote {
326 border-top:
1px solid silver;
335 padding-right:
0.5em;
336 padding-bottom:
0.3em;
344 #footer-badges { display: none; }
348 margin-bottom:
2.5em;
356 margin-bottom:
0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
410 span.big { font-size:
2em; }
411 span.small { font-size:
0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
427 margin-bottom:
1.5em;
429 div.tableblock
> table {
430 border:
3px solid #
527bbd;
432 thead, p.table.header {
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock
> table[
frame=
"void"] {
443 div.tableblock
> table[
frame=
"hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock
> table[
frame=
"vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
460 margin-bottom:
1.5em;
462 thead, p.tableblock.header {
473 border-color: #
527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
480 border-color: #
527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
498 th.tableblock.halign-center, td.tableblock.halign-center {
501 th.tableblock.halign-right, td.tableblock.halign-right {
505 th.tableblock.valign-top, td.tableblock.valign-top {
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
523 padding-bottom:
0.5em;
524 border-top:
2px solid silver;
525 border-bottom:
2px solid silver;
530 body.manpage div.sectionbody {
535 body.manpage div#toc { display: none; }
540 <script type=
"text/javascript">
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September
2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
558 /* modified by Troy D. Hanson, September
2006. License: GPL */
559 /* modified by Stuart Rackham,
2006,
2009. License: GPL */
562 toc: function (toclevels) {
564 function getText(el) {
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType ==
3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
569 else if (i.firstChild != null)
575 function TocEntry(el, text, toclevel) {
578 this.toclevel = toclevel;
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([
1-'+(toclevels+
1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
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);
602 var toc = document.getElementById(
"toc");
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
610 for (i =
0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute(
"class")
614 && entry.getAttribute(
"class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
617 for (i =
0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById(
"content"), toclevels);
623 for (var i =
0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id ==
"")
626 entry.element.id =
"_toc_" + i;
627 var a = document.createElement(
"a");
628 a.href =
"#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement(
"div");
632 div.className =
"toclevel" + entry.toclevel;
633 toc.appendChild(div);
635 if (entries.length ==
0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/
2005/
07/format_footnote.html
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
651 var noteholder = document.getElementById(
"footnotes");
655 var entriesToRemove = [];
656 for (i =
0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute(
"class") ==
"footnote")
659 entriesToRemove.push(entry);
661 for (i =
0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
665 // Rebuild footnote entries.
666 var cont = document.getElementById(
"content");
667 var spans = cont.getElementsByTagName(
"span");
670 for (i=
0; i
<spans.length; i++) {
671 if (spans[i].className ==
"footnote") {
673 var note = spans[i].getAttribute(
"data-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];
679 "[<a id='_footnoteref_" + n +
"' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n +
"</a>]";
681 spans[i].setAttribute(
"data-note", note);
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n +
"'>" +
685 "<a href='#_footnoteref_" + n +
"' title='Return to text'>" +
686 n +
"</a>. " + note +
"</div>";
687 var id =spans[i].getAttribute(
"id");
688 if (id != null) refs[
"#"+id] = n;
692 noteholder.parentNode.removeChild(noteholder);
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.
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n +
"</a>]";
708 install: function(toclevels) {
711 function reinstall() {
712 asciidoc.footnotes();
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
723 timerId = setInterval(reinstall,
500);
724 if (document.addEventListener)
725 document.addEventListener(
"DOMContentLoaded", reinstallAndRemoveTimer, false);
727 window.onload = reinstallAndRemoveTimer;
735 <body class=
"manpage">
738 gitprotocol-http(
5) Manual Page
741 <div class=
"sectionbody">
742 <p>gitprotocol-http -
743 Git HTTP-based protocols
749 <h2 id=
"_synopsis">SYNOPSIS
</h2>
750 <div class=
"sectionbody">
751 <div class=
"verseblock">
752 <pre class=
"content"><over-the-wire-protocol
></pre>
753 <div class=
"attribution">
758 <h2 id=
"_description">DESCRIPTION
</h2>
759 <div class=
"sectionbody">
760 <div class=
"paragraph"><p>Git supports two HTTP based transfer protocols. A
"dumb" protocol
761 which requires only a standard HTTP server on the server end of the
762 connection, and a
"smart" protocol which requires a Git aware CGI
763 (or server module). This document describes both protocols.
</p></div>
764 <div class=
"paragraph"><p>As a design feature smart clients can automatically upgrade
"dumb"
765 protocol URLs to smart URLs. This permits all users to have the
766 same published URL, and the peers automatically select the most
767 efficient transport available to them.
</p></div>
771 <h2 id=
"_url_format">URL Format
</h2>
772 <div class=
"sectionbody">
773 <div class=
"paragraph"><p>URLs for Git repositories accessed by HTTP use the standard HTTP
774 URL syntax documented by RFC
1738, so they are of the form:
</p></div>
775 <div class=
"literalblock">
776 <div class=
"content">
777 <pre><code>http://
<host
>:
<port
>/
<path
>?
<searchpart
></code></pre>
779 <div class=
"paragraph"><p>Within this documentation the placeholder
<code>$GIT_URL
</code> will stand for
780 the http:// repository URL entered by the end-user.
</p></div>
781 <div class=
"paragraph"><p>Servers SHOULD handle all requests to locations matching
<code>$GIT_URL
</code>, as
782 both the
"smart" and
"dumb" HTTP protocols used by Git operate
783 by appending additional path components onto the end of the user
784 supplied
<code>$GIT_URL
</code> string.
</p></div>
785 <div class=
"paragraph"><p>An example of a dumb client requesting a loose object:
</p></div>
786 <div class=
"literalblock">
787 <div class=
"content">
788 <pre><code>$GIT_URL: http://example.com:
8080/git/repo.git
789 URL request: http://example.com:
8080/git/repo.git/objects/d0/
49f6c27a2244e12041955e262a404c7faba355
</code></pre>
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
&q=
795 URL request: http://example.com/daemon.cgi?svc=git
&q=/info/refs
&service=git-receive-pack
</code></pre>
797 <div class=
"paragraph"><p>An example of a request to a submodule:
</p></div>
798 <div class=
"literalblock">
799 <div class=
"content">
800 <pre><code>$GIT_URL: http://example.com/git/repo.git/path/submodule.git
801 URL request: http://example.com/git/repo.git/path/submodule.git/info/refs
</code></pre>
803 <div class=
"paragraph"><p>Clients MUST strip a trailing
<code>/
</code>, if present, from the user supplied
804 <code>$GIT_URL
</code> string to prevent empty path tokens (
<code>//
</code>) from appearing
805 in any URL sent to a server. Compatible clients MUST expand
806 <code>$GIT_URL/info/refs
</code> as
<code>foo/info/refs
</code> and not
<code>foo//info/refs
</code>.
</p></div>
810 <h2 id=
"_authentication">Authentication
</h2>
811 <div class=
"sectionbody">
812 <div class=
"paragraph"><p>Standard HTTP authentication is used if authentication is required
813 to access a repository, and MAY be configured and enforced by the
814 HTTP server software.
</p></div>
815 <div class=
"paragraph"><p>Because Git repositories are accessed by standard path components
816 server administrators MAY use directory based permissions within
817 their HTTP server to control repository access.
</p></div>
818 <div class=
"paragraph"><p>Clients SHOULD support Basic authentication as described by RFC
2617.
819 Servers SHOULD support Basic authentication by relying upon the
820 HTTP server placed in front of the Git server software.
</p></div>
821 <div class=
"paragraph"><p>Servers SHOULD NOT require HTTP cookies for the purposes of
822 authentication or access control.
</p></div>
823 <div class=
"paragraph"><p>Clients and servers MAY support other common forms of HTTP based
824 authentication, such as Digest authentication.
</p></div>
828 <h2 id=
"_ssl">SSL
</h2>
829 <div class=
"sectionbody">
830 <div class=
"paragraph"><p>Clients and servers SHOULD support SSL, particularly to protect
831 passwords when relying on Basic HTTP authentication.
</p></div>
835 <h2 id=
"_session_state">Session State
</h2>
836 <div class=
"sectionbody">
837 <div class=
"paragraph"><p>The Git over HTTP protocol (much like HTTP itself) is stateless
838 from the perspective of the HTTP server side. All state MUST be
839 retained and managed by the client process. This permits simple
840 round-robin load-balancing on the server side, without needing to
841 worry about state management.
</p></div>
842 <div class=
"paragraph"><p>Clients MUST NOT require state management on the server side in
843 order to function correctly.
</p></div>
844 <div class=
"paragraph"><p>Servers MUST NOT require HTTP cookies in order to function correctly.
845 Clients MAY store and forward HTTP cookies during request processing
846 as described by RFC
2616 (HTTP/
1.1). Servers SHOULD ignore any
847 cookies sent by a client.
</p></div>
851 <h2 id=
"_general_request_processing">General Request Processing
</h2>
852 <div class=
"sectionbody">
853 <div class=
"paragraph"><p>Except where noted, all standard HTTP behavior SHOULD be assumed
854 by both client and server. This includes (but is not necessarily
855 limited to):
</p></div>
856 <div class=
"paragraph"><p>If there is no repository at
<code>$GIT_URL
</code>, or the resource pointed to by a
857 location matching
<code>$GIT_URL
</code> does not exist, the server MUST NOT respond
858 with
<code>200 OK
</code> response. A server SHOULD respond with
859 <code>404 Not Found
</code>,
<code>410 Gone
</code>, or any other suitable HTTP status code
860 which does not imply the resource exists as requested.
</p></div>
861 <div class=
"paragraph"><p>If there is a repository at
<code>$GIT_URL
</code>, but access is not currently
862 permitted, the server MUST respond with the
<code>403 Forbidden
</code> HTTP
863 status code.
</p></div>
864 <div class=
"paragraph"><p>Servers SHOULD support both HTTP
1.0 and HTTP
1.1.
865 Servers SHOULD support chunked encoding for both request and response
867 <div class=
"paragraph"><p>Clients SHOULD support both HTTP
1.0 and HTTP
1.1.
868 Clients SHOULD support chunked encoding for both request and response
870 <div class=
"paragraph"><p>Servers MAY return ETag and/or Last-Modified headers.
</p></div>
871 <div class=
"paragraph"><p>Clients MAY revalidate cached entities by including If-Modified-Since
872 and/or If-None-Match request headers.
</p></div>
873 <div class=
"paragraph"><p>Servers MAY return
<code>304 Not Modified
</code> if the relevant headers appear
874 in the request and the entity has not changed. Clients MUST treat
875 <code>304 Not Modified
</code> identical to
<code>200 OK
</code> by reusing the cached entity.
</p></div>
876 <div class=
"paragraph"><p>Clients MAY reuse a cached entity without revalidation if the
877 Cache-Control and/or Expires header permits caching. Clients and
878 servers MUST follow RFC
2616 for cache controls.
</p></div>
882 <h2 id=
"_discovering_references">Discovering References
</h2>
883 <div class=
"sectionbody">
884 <div class=
"paragraph"><p>All HTTP clients MUST begin either a fetch or a push exchange by
885 discovering the references available on the remote repository.
</p></div>
887 <h3 id=
"_dumb_clients">Dumb Clients
</h3>
888 <div class=
"paragraph"><p>HTTP clients that only support the
"dumb" protocol MUST discover
889 references by making a request for the special info/refs file of
890 the repository.
</p></div>
891 <div class=
"paragraph"><p>Dumb HTTP clients MUST make a
<code>GET
</code> request to
<code>$GIT_URL/info/refs
</code>,
892 without any search/query parameters.
</p></div>
893 <div class=
"literalblock">
894 <div class=
"content">
895 <pre><code>C: GET $GIT_URL/info/refs HTTP/
1.0</code></pre>
897 <div class=
"literalblock">
898 <div class=
"content">
901 S:
95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint
902 S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master
903 S:
2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0
904 S: a3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}
</code></pre>
906 <div class=
"paragraph"><p>The Content-Type of the returned info/refs entity SHOULD be
907 <code>text/plain; charset=utf-
8</code>, but MAY be any content type.
908 Clients MUST NOT attempt to validate the returned Content-Type.
909 Dumb servers MUST NOT return a return type starting with
910 <code>application/x-git-
</code>.
</p></div>
911 <div class=
"paragraph"><p>Cache-Control headers MAY be returned to disable caching of the
912 returned entity.
</p></div>
913 <div class=
"paragraph"><p>When examining the response clients SHOULD only examine the HTTP
914 status code. Valid responses are
<code>200 OK
</code>, or
<code>304 Not Modified
</code>.
</p></div>
915 <div class=
"paragraph"><p>The returned content is a UNIX formatted text file describing
916 each ref and its known value. The file SHOULD be sorted by name
917 according to the C locale ordering. The file SHOULD NOT include
918 the default ref named
<code>HEAD
</code>.
</p></div>
919 <div class=
"literalblock">
920 <div class=
"content">
921 <pre><code>info_refs = *( ref_record )
922 ref_record = any_ref / peeled_ref
</code></pre>
924 <div class=
"literalblock">
925 <div class=
"content">
926 <pre><code>any_ref = obj-id HTAB refname LF
927 peeled_ref = obj-id HTAB refname LF
928 obj-id HTAB refname
"^{}" LF
</code></pre>
932 <h3 id=
"_smart_clients">Smart Clients
</h3>
933 <div class=
"paragraph"><p>HTTP clients that support the
"smart" protocol (or both the
934 "smart" and
"dumb" protocols) MUST discover references by making
935 a parameterized request for the info/refs file of the repository.
</p></div>
936 <div class=
"paragraph"><p>The request MUST contain exactly one query parameter,
937 <code>service=$servicename
</code>, where
<code>$servicename
</code> MUST be the service
938 name the client wishes to contact to complete the operation.
939 The request MUST NOT contain additional query parameters.
</p></div>
940 <div class=
"literalblock">
941 <div class=
"content">
942 <pre><code>C: GET $GIT_URL/info/refs?service=git-upload-pack HTTP/
1.0</code></pre>
944 <div class=
"paragraph"><p>dumb server reply:
</p></div>
945 <div class=
"literalblock">
946 <div class=
"content">
949 S:
95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint
950 S: d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master
951 S:
2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0
952 S: a3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}
</code></pre>
954 <div class=
"paragraph"><p>smart server reply:
</p></div>
955 <div class=
"literalblock">
956 <div class=
"content">
958 S: Content-Type: application/x-git-upload-pack-advertisement
959 S: Cache-Control: no-cache
961 S:
001e# service=git-upload-pack\n
963 S:
004895dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint\
0multi_ack\n
964 S:
003fd049f6c27a2244e12041955e262a404c7faba355 refs/heads/master\n
965 S:
003c2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0\n
966 S:
003fa3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}\n
969 <div class=
"paragraph"><p>The client may send Extra Parameters (see
970 <a href=
"gitprotocol-pack.html">gitprotocol-pack(
5)
</a>) as a colon-separated string
971 in the Git-Protocol HTTP header.
</p></div>
972 <div class=
"paragraph"><p>Uses the
<code>--http-backend-info-refs
</code> option to
973 <a href=
"git-upload-pack.html">git-upload-pack(
1)
</a>.
</p></div>
975 <h4 id=
"_dumb_server_response">Dumb Server Response
</h4>
976 <div class=
"paragraph"><p>Dumb servers MUST respond with the dumb server reply format.
</p></div>
977 <div class=
"paragraph"><p>See the prior section under dumb clients for a more detailed
978 description of the dumb server response.
</p></div>
981 <h4 id=
"_smart_server_response">Smart Server Response
</h4>
982 <div class=
"paragraph"><p>If the server does not recognize the requested service name, or the
983 requested service name has been disabled by the server administrator,
984 the server MUST respond with the
<code>403 Forbidden
</code> HTTP status code.
</p></div>
985 <div class=
"paragraph"><p>Otherwise, smart servers MUST respond with the smart server reply
986 format for the requested service name.
</p></div>
987 <div class=
"paragraph"><p>Cache-Control headers SHOULD be used to disable caching of the
988 returned entity.
</p></div>
989 <div class=
"paragraph"><p>The Content-Type MUST be
<code>application/x-$servicename-advertisement
</code>.
990 Clients SHOULD fall back to the dumb protocol if another content
991 type is returned. When falling back to the dumb protocol clients
992 SHOULD NOT make an additional request to
<code>$GIT_URL/info/refs
</code>, but
993 instead SHOULD use the response already in hand. Clients MUST NOT
994 continue if they do not support the dumb protocol.
</p></div>
995 <div class=
"paragraph"><p>Clients MUST validate the status code is either
<code>200 OK
</code> or
996 <code>304 Not Modified
</code>.
</p></div>
997 <div class=
"paragraph"><p>Clients MUST validate the first five bytes of the response entity
998 matches the regex
<code>^[
0-
9a-f]{
4}#
</code>. If this test fails, clients
999 MUST NOT continue.
</p></div>
1000 <div class=
"paragraph"><p>Clients MUST parse the entire response as a sequence of pkt-line
1002 <div class=
"paragraph"><p>Clients MUST verify the first pkt-line is
<code># service=$servicename
</code>.
1003 Servers MUST set $servicename to be the request parameter value.
1004 Servers SHOULD include an LF at the end of this line.
1005 Clients MUST ignore an LF at the end of the line.
</p></div>
1006 <div class=
"paragraph"><p>Servers MUST terminate the response with the magic
<code>0000</code> end
1007 pkt-line marker.
</p></div>
1008 <div class=
"paragraph"><p>The returned response is a pkt-line stream describing each ref and
1009 its known value. The stream SHOULD be sorted by name according to
1010 the C locale ordering. The stream SHOULD include the default ref
1011 named
<code>HEAD
</code> as the first ref. The stream MUST include capability
1012 declarations behind a NUL on the first ref.
</p></div>
1013 <div class=
"paragraph"><p>The returned response contains
"version 1" if
"version=1" was sent as an
1014 Extra Parameter.
</p></div>
1015 <div class=
"literalblock">
1016 <div class=
"content">
1017 <pre><code>smart_reply = PKT-LINE(
"# service=$servicename" LF)
1022 ref_list = empty_list / non_empty_list
</code></pre>
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>
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>
1033 <div class=
"literalblock">
1034 <div class=
"content">
1035 <pre><code>cap-list = capability *(SP capability)
1036 capability =
1*(LC_ALPHA / DIGIT /
"-" /
"_")
1037 LC_ALPHA = %x61-
7A
</code></pre>
1039 <div class=
"literalblock">
1040 <div class=
"content">
1041 <pre><code>ref_record = any_ref / peeled_ref
1042 any_ref = PKT-LINE(obj-id SP name LF)
1043 peeled_ref = PKT-LINE(obj-id SP name LF)
1044 PKT-LINE(obj-id SP name
"^{}" LF
</code></pre>
1051 <h2 id=
"_smart_service_git_upload_pack">Smart Service git-upload-pack
</h2>
1052 <div class=
"sectionbody">
1053 <div class=
"paragraph"><p>This service reads from the repository pointed to by
<code>$GIT_URL
</code>.
</p></div>
1054 <div class=
"paragraph"><p>Clients MUST first perform ref discovery with
1055 <code>$GIT_URL/info/refs?service=git-upload-pack
</code>.
</p></div>
1056 <div class=
"literalblock">
1057 <div class=
"content">
1058 <pre><code>C: POST $GIT_URL/git-upload-pack HTTP/
1.0
1059 C: Content-Type: application/x-git-upload-pack-request
1061 C:
0032want
0a53e9ddeaddad63ad106860237bbf53411d11a7\n
1062 C:
0032have
441b40d833fdfa93eb2908e52742248faf0ee993\n
1063 C:
0000</code></pre>
1065 <div class=
"literalblock">
1066 <div class=
"content">
1067 <pre><code>S:
200 OK
1068 S: Content-Type: application/x-git-upload-pack-result
1069 S: Cache-Control: no-cache
1071 S: ....ACK %s, continue
1072 S: ....NAK
</code></pre>
1074 <div class=
"paragraph"><p>Clients MUST NOT reuse or revalidate a cached response.
1075 Servers MUST include sufficient Cache-Control headers
1076 to prevent caching of the response.
</p></div>
1077 <div class=
"paragraph"><p>Servers SHOULD support all capabilities defined here.
</p></div>
1078 <div class=
"paragraph"><p>Clients MUST send at least one
"want" command in the request body.
1079 Clients MUST NOT reference an id in a
"want" command which did not
1080 appear in the response obtained through ref discovery unless the
1081 server advertises capability
<code>allow-tip-sha1-in-want
</code> or
1082 <code>allow-reachable-sha1-in-want
</code>.
</p></div>
1083 <div class=
"literalblock">
1084 <div class=
"content">
1085 <pre><code>compute_request = want_list
1088 request_end =
"0000" /
"done"</code></pre>
1090 <div class=
"literalblock">
1091 <div class=
"content">
1092 <pre><code>want_list = PKT-LINE(want SP cap_list LF)
1094 want_pkt = PKT-LINE(want LF)
1096 cap_list = capability *(SP capability)
</code></pre>
1098 <div class=
"literalblock">
1099 <div class=
"content">
1100 <pre><code>have_list = *PKT-LINE(
"have" SP id LF)
</code></pre>
1102 <div class=
"paragraph"><p>TODO: Document this further.
</p></div>
1104 <h3 id=
"_the_negotiation_algorithm">The Negotiation Algorithm
</h3>
1105 <div class=
"paragraph"><p>The computation to select the minimal pack proceeds as follows
1106 (C = client, S = server):
</p></div>
1107 <div class=
"paragraph"><p><em>init step:
</em></p></div>
1108 <div class=
"paragraph"><p>C: Use ref discovery to obtain the advertised refs.
</p></div>
1109 <div class=
"paragraph"><p>C: Place any object seen into set
<code>advertised
</code>.
</p></div>
1110 <div class=
"paragraph"><p>C: Build an empty set,
<code>common
</code>, to hold the objects that are later
1111 determined to be on both ends.
</p></div>
1112 <div class=
"paragraph"><p>C: Build a set,
<code>want
</code>, of the objects from
<code>advertised
</code> that the client
1113 wants to fetch, based on what it saw during ref discovery.
</p></div>
1114 <div class=
"paragraph"><p>C: Start a queue,
<code>c_pending
</code>, ordered by commit time (popping newest
1115 first). Add all client refs. When a commit is popped from
1116 the queue its parents SHOULD be automatically inserted back.
1117 Commits MUST only enter the queue once.
</p></div>
1118 <div class=
"paragraph"><p><em>one compute step:
</em></p></div>
1119 <div class=
"paragraph"><p>C: Send one
<code>$GIT_URL/git-upload-pack
</code> request:
</p></div>
1120 <div class=
"literalblock">
1121 <div class=
"content">
1122 <pre><code>C:
0032want
<want-#
1>...............................
1123 C:
0032want
<want-#
2>...............................
1125 C:
0032have
<common-#
1>.............................
1126 C:
0032have
<common-#
2>.............................
1128 C:
0032have
<have-#
1>...............................
1129 C:
0032have
<have-#
2>...............................
1131 C:
0000</code></pre>
1133 <div class=
"paragraph"><p>The stream is organized into
"commands", with each command
1134 appearing by itself in a pkt-line. Within a command line,
1135 the text leading up to the first space is the command name,
1136 and the remainder of the line to the first LF is the value.
1137 Command lines are terminated with an LF as the last byte of
1138 the pkt-line value.
</p></div>
1139 <div class=
"paragraph"><p>Commands MUST appear in the following order, if they appear
1140 at all in the request stream:
</p></div>
1141 <div class=
"ulist"><ul>
1153 <div class=
"paragraph"><p>The stream is terminated by a pkt-line flush (
<code>0000</code>).
</p></div>
1154 <div class=
"paragraph"><p>A single
"want" or
"have" command MUST have one hex formatted
1155 object name as its value. Multiple object names MUST be sent by sending
1156 multiple commands. Object names MUST be given using the object format
1157 negotiated through the
<code>object-format
</code> capability (default SHA-
1).
</p></div>
1158 <div class=
"paragraph"><p>The
<code>have
</code> list is created by popping the first
32 commits
1159 from
<code>c_pending
</code>. Fewer can be supplied if
<code>c_pending
</code> empties.
</p></div>
1160 <div class=
"paragraph"><p>If the client has sent
256 "have" commits and has not yet
1161 received one of those back from
<code>s_common
</code>, or the client has
1162 emptied
<code>c_pending
</code> it SHOULD include a
"done" command to let
1163 the server know it won
’t proceed:
</p></div>
1164 <div class=
"literalblock">
1165 <div class=
"content">
1166 <pre><code>C:
0009done
</code></pre>
1168 <div class=
"paragraph"><p>S: Parse the git-upload-pack request:
</p></div>
1169 <div class=
"paragraph"><p>Verify all objects in
<code>want
</code> are directly reachable from refs.
</p></div>
1170 <div class=
"paragraph"><p>The server MAY walk backwards through history or through
1171 the reflog to permit slightly stale requests.
</p></div>
1172 <div class=
"paragraph"><p>If no
"want" objects are received, send an error:
1173 TODO: Define error if no
"want" lines are requested.
</p></div>
1174 <div class=
"paragraph"><p>If any
"want" object is not reachable, send an error:
1175 TODO: Define error if an invalid
"want" is requested.
</p></div>
1176 <div class=
"paragraph"><p>Create an empty list,
<code>s_common
</code>.
</p></div>
1177 <div class=
"paragraph"><p>If
"have" was sent:
</p></div>
1178 <div class=
"paragraph"><p>Loop through the objects in the order supplied by the client.
</p></div>
1179 <div class=
"paragraph"><p>For each object, if the server has the object reachable from
1180 a ref, add it to
<code>s_common
</code>. If a commit is added to
<code>s_common
</code>,
1181 do not add any ancestors, even if they also appear in
<code>have
</code>.
</p></div>
1182 <div class=
"paragraph"><p>S: Send the git-upload-pack response:
</p></div>
1183 <div class=
"paragraph"><p>If the server has found a closed set of objects to pack or the
1184 request ends with
"done", it replies with the pack.
1185 TODO: Document the pack based response
</p></div>
1186 <div class=
"literalblock">
1187 <div class=
"content">
1188 <pre><code>S: PACK...
</code></pre>
1190 <div class=
"paragraph"><p>The returned stream is the side-band-
64k protocol supported
1191 by the git-upload-pack service, and the pack is embedded into
1192 stream
1. Progress messages from the server side MAY appear
1193 in stream
2.
</p></div>
1194 <div class=
"paragraph"><p>Here a
"closed set of objects" is defined to have at least
1195 one path from every
"want" to at least one
"common" object.
</p></div>
1196 <div class=
"paragraph"><p>If the server needs more information, it replies with a
1197 status continue response:
1198 TODO: Document the non-pack response
</p></div>
1199 <div class=
"paragraph"><p>C: Parse the upload-pack response:
1200 TODO: Document parsing response
</p></div>
1201 <div class=
"paragraph"><p><em>Do another compute step.
</em></p></div>
1206 <h2 id=
"_smart_service_git_receive_pack">Smart Service git-receive-pack
</h2>
1207 <div class=
"sectionbody">
1208 <div class=
"paragraph"><p>This service reads from the repository pointed to by
<code>$GIT_URL
</code>.
</p></div>
1209 <div class=
"paragraph"><p>Clients MUST first perform ref discovery with
1210 <code>$GIT_URL/info/refs?service=git-receive-pack
</code>.
</p></div>
1211 <div class=
"literalblock">
1212 <div class=
"content">
1213 <pre><code>C: POST $GIT_URL/git-receive-pack HTTP/
1.0
1214 C: Content-Type: application/x-git-receive-pack-request
1216 C: ...
.0a53e9ddeaddad63ad106860237bbf53411d11a7
441b40d833fdfa93eb2908e52742248faf0ee993 refs/heads/maint\
0 report-status
1218 C: PACK....
</code></pre>
1220 <div class=
"literalblock">
1221 <div class=
"content">
1222 <pre><code>S:
200 OK
1223 S: Content-Type: application/x-git-receive-pack-result
1224 S: Cache-Control: no-cache
1226 S: ....
</code></pre>
1228 <div class=
"paragraph"><p>Clients MUST NOT reuse or revalidate a cached response.
1229 Servers MUST include sufficient Cache-Control headers
1230 to prevent caching of the response.
</p></div>
1231 <div class=
"paragraph"><p>Servers SHOULD support all capabilities defined here.
</p></div>
1232 <div class=
"paragraph"><p>Clients MUST send at least one command in the request body.
1233 Within the command portion of the request body clients SHOULD send
1234 the id obtained through ref discovery as old_id.
</p></div>
1235 <div class=
"literalblock">
1236 <div class=
"content">
1237 <pre><code>update_request = command_list
1238 "PACK" <binary-data
></code></pre>
1240 <div class=
"literalblock">
1241 <div class=
"content">
1242 <pre><code>command_list = PKT-LINE(command NUL cap_list LF)
1244 command_pkt = PKT-LINE(command LF)
1245 cap_list = *(SP capability) SP
</code></pre>
1247 <div class=
"literalblock">
1248 <div class=
"content">
1249 <pre><code>command = create / delete / update
1250 create = zero-id SP new_id SP name
1251 delete = old_id SP zero-id SP name
1252 update = old_id SP new_id SP name
</code></pre>
1254 <div class=
"paragraph"><p>TODO: Document this further.
</p></div>
1258 <h2 id=
"_references">REFERENCES
</h2>
1259 <div class=
"sectionbody">
1260 <div class=
"paragraph"><p><a href=
"https://www.ietf.org/rfc/rfc1738.txt">RFC
1738: Uniform Resource Locators (URL)
</a>
1261 <a href=
"https://www.ietf.org/rfc/rfc2616.txt">RFC
2616: Hypertext Transfer Protocol
 — HTTP/
1.1</a></p></div>
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>
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>
1278 <div id=
"footnotes"><hr /></div>
1280 <div id=
"footer-text">
1282 2024-
02-
08 15:
45:
59 PST