{"thread":{"id":"37058","subject":"git fetch sha1","startedAt":"2014-07-04T17:51:10Z","lastAt":"2014-07-05T16:30:07Z","messageCount":3,"participants":["Allan Gardner","Shawn Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"245409","messageId":"CABo2x6A_cA8KoFbe4Hcg0SJw+gOGeOFun3VDM1gx3ZVWK8wy3Q@mail.gmail.com","threadId":"37058","inReplyTo":null,"subject":"git fetch sha1","fromName":"Allan Gardner","fromEmail":"allanegardner@gmail.com","sentAt":"2014-07-04T17:51:10Z","receivedAt":"2014-07-04T17:51:10Z","isPatch":false,"sender":{"key":"allanegardner@gmail.com","avatar":null},"body":"Currently fetching a sha1 fails on git.kernel.org:\n\n$ git --version && uname -a\ngit version 1.9.4\nLinux nixos 3.12.23 #1-NixOS SMP Thu Jan 1 00:00:01 UTC 1970 x86_64 GNU/Linux\n\n$ rm -rf test && mkdir test && cd test && git init\nInitialized empty Git repository in ~/test/.git/\n\n$ git fetch --depth 1 https://git.kernel.org/pub/scm/git/git.git\n782735203c316041df120748e5e88c1787cdf4da\nerror: no such remote ref 782735203c316041df120748e5e88c1787cdf4da\n\nI tried with head, same error. However, if I clone the full repository\nand then manually execute git upload-pack, it successfully fetches the\ncommit:\n\n$ git fetch https://git.kernel.org/pub/scm/git/git.git master\n<wait an hour>\n$ git checkout -b sha1 782735203c316041df120748e5e88c1787cdf4da\n$ printf \"0045want %s multi_ack_detailed\\n000Ddeepen\n1\\n00000009done\\n0000\" \"782735203c316041df120748e5e88c1787cdf4da\"\n>input\n$ cat input | git upload-pack --stateless-rpc . > output\n$ sed -z \"s/.*0008NAK\\n//\" < output > output.pack\n$ git index-pack output.pack && git verify-pack -v output.pack | grep commit\nf239687a5dbbd1bbb761d09edec582418c66c297\n782735203c316041df120748e5e88c1787cdf4da commit 374 234 12\n\nSo theoretically this is supported server-side. Unfortunately\nkernel.org does not agree:\n\n$ curl --data-binary @input --header \"Content-Type:\napplication/x-git-upload-pack-request\" --header \"Accept-Encoding:\ngzip\" --header \"Accept: application/x-git-upload-pack-result\" --header\n\"Expect:\" https://git.kernel.org/pub/scm/git/git.git/git-upload-pack >\noutput\n$ wc -c output\n0 output\n\nWhy is there a discrepancy between git.kernel.org and upload-pack\n--stateless-rpc?\n\n-- Allan Gardner\n"},{"id":"245412","messageId":"CAJo=hJvjg0G+DiRhyh=9jnRTPjWma7zQv90VsW8Bx1WyvsQTLg@mail.gmail.com","threadId":"37058","inReplyTo":"CABo2x6A_cA8KoFbe4Hcg0SJw+gOGeOFun3VDM1gx3ZVWK8wy3Q@mail.gmail.com","subject":"Re: git fetch sha1","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2014-07-04T20:41:11Z","receivedAt":"2014-07-04T20:41:11Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"On Fri, Jul 4, 2014 at 10:51 AM, Allan Gardner <allanegardner@gmail.com> wrote:\n> Currently fetching a sha1 fails on git.kernel.org:\n>\n> $ git --version && uname -a\n> git version 1.9.4\n> Linux nixos 3.12.23 #1-NixOS SMP Thu Jan 1 00:00:01 UTC 1970 x86_64 GNU/Linux\n>\n> $ rm -rf test && mkdir test && cd test && git init\n> Initialized empty Git repository in ~/test/.git/\n>\n> $ git fetch --depth 1 https://git.kernel.org/pub/scm/git/git.git\n> 782735203c316041df120748e5e88c1787cdf4da\n> error: no such remote ref 782735203c316041df120748e5e88c1787cdf4da\n>\n> I tried with head, same error. However, if I clone the full repository\n> and then manually execute git upload-pack, it successfully fetches the\n> commit:\n>\n> $ git fetch https://git.kernel.org/pub/scm/git/git.git master\n> <wait an hour>\n> $ git checkout -b sha1 782735203c316041df120748e5e88c1787cdf4da\n> $ printf \"0045want %s multi_ack_detailed\\n000Ddeepen\n> 1\\n00000009done\\n0000\" \"782735203c316041df120748e5e88c1787cdf4da\"\n>>input\n> $ cat input | git upload-pack --stateless-rpc . > output\n> $ sed -z \"s/.*0008NAK\\n//\" < output > output.pack\n> $ git index-pack output.pack && git verify-pack -v output.pack | grep commit\n> f239687a5dbbd1bbb761d09edec582418c66c297\n> 782735203c316041df120748e5e88c1787cdf4da commit 374 234 12\n>\n> So theoretically this is supported server-side. Unfortunately\n> kernel.org does not agree:\n\nNo, it is not supported server side. Your test didn't even test what\nyou think it tested.\n\n$ curl https://git.kernel.org/pub/scm/git/git.git/info/refs?service=git-upload-pack\n2>/dev/null | head -n 2\n001e# service=git-upload-pack\n0000009b6f92e5ff3cdc813de8ef5327fd4bad492fb7d6c9 HEADmulti_ack\nthin-pack side-band side-band-64k ofs-delta shallow no-progress\ninclude-tag multi_ack_detailed\n\nThe capability you are asking about is allow-tip-sha1-in-want which\ndoes not appear in the server advertisement. So its not supported on\nthis server.\n"},{"id":"245426","messageId":"CAJo=hJubkP-D0qnHQYdRC+bjt_2oTNNzgbgPqVG-DursARLrAw@mail.gmail.com","threadId":"37058","inReplyTo":"CABo2x6CJz6PSFCDfn47cVQi44-J0oHsGqzSiyBe8Kt5NgWibog@mail.gmail.com","subject":"Re: git fetch sha1","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2014-07-05T16:30:07Z","receivedAt":"2014-07-05T16:30:07Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"On Sat, Jul 5, 2014 at 6:05 AM, Allan Gardner <allanegardner@gmail.com> wrote:\n> On Fri, Jul 4, 2014 at 10:41 PM, Shawn Pearce <spearce@spearce.org> wrote:\n>>\n>> On Fri, Jul 4, 2014 at 10:51 AM, Allan Gardner <allanegardner@gmail.com> wrote:\n>> > Currently fetching a sha1 fails on git.kernel.org:\n>> >\n>> > $ git --version && uname -a\n>> > git version 1.9.4\n>> > Linux nixos 3.12.23 #1-NixOS SMP Thu Jan 1 00:00:01 UTC 1970 x86_64 GNU/Linux\n>> >\n>> > $ rm -rf test && mkdir test && cd test && git init\n>> > Initialized empty Git repository in ~/test/.git/\n>> >\n>> > $ git fetch --depth 1 https://git.kernel.org/pub/scm/git/git.git\n>> > 782735203c316041df120748e5e88c1787cdf4da\n>> > error: no such remote ref 782735203c316041df120748e5e88c1787cdf4da\n>> >\n>> > I tried with head, same error. However, if I clone the full repository\n>> > and then manually execute git upload-pack, it successfully fetches the\n>> > commit:\n>> >\n>> > $ git fetch https://git.kernel.org/pub/scm/git/git.git master\n>> > <wait an hour>\n>> > $ git checkout -b sha1 782735203c316041df120748e5e88c1787cdf4da\n>> > $ printf \"0045want %s multi_ack_detailed\\n000Ddeepen\n>> > 1\\n00000009done\\n0000\" \"782735203c316041df120748e5e88c1787cdf4da\"\n>> >>input\n>> > $ cat input | git upload-pack --stateless-rpc . > output\n>> > $ sed -z \"s/.*0008NAK\\n//\" < output > output.pack\n>> > $ git index-pack output.pack && git verify-pack -v output.pack | grep commit\n>> > f239687a5dbbd1bbb761d09edec582418c66c297\n>> > 782735203c316041df120748e5e88c1787cdf4da commit 374 234 12\n>> >\n>> > So theoretically this is supported server-side. Unfortunately\n>> > kernel.org does not agree:\n>>\n>> No, it is not supported server side. Your test didn't even test what\n>> you think it tested.\n>>\n>> $ curl https://git.kernel.org/pub/scm/git/git.git/info/refs?service=git-upload-pack\n>> 2>/dev/null | head -n 2\n>> 001e# service=git-upload-pack\n>> 0000009b6f92e5ff3cdc813de8ef5327fd4bad492fb7d6c9 HEADmulti_ack\n>> thin-pack side-band side-band-64k ofs-delta shallow no-progress\n>> include-tag multi_ack_detailed\n>>\n>> The capability you are asking about is allow-tip-sha1-in-want which\n>> does not appear in the server advertisement. So its not supported on\n>> this server.\n>\n> $ git upload-pack --advertise-refs --stateless-rpc .\n> 00d16f92e5ff3cdc813de8ef5327fd4bad492fb7d6c9 HEADmulti_ack thin-pack\n> side-band side-band-64k ofs-delta shallow no-progress include-tag\n> multi_ack_detailed no-done symref=HEAD:refs/heads/master\n> agent=git/1.9.4\n>\n> I did not ask about allow-tip-sha1-in-want,\n\nI think you did. You asked about passing a random SHA-1 to `git\nfetch`. The client will only send this SHA-1 to the server if an\nadvertised ref exactly matches or the server advertised\nallow-tip-sha1-in-want. Otherwise, it errors out.\n\n> and it is not enabled by\n> default. It appears that the server must advertise no-done though,\n> which indeed git.kernel.org does not.\n\nno-done is unrelated to passing a SHA-1 on the fetch line. The two\nconcepts have nothing to do with each other. I seriously doubt anyone\npiggybacked additional features onto no-done years after it was\nintroduced.\n\n> So my next question is how\n> git.kernel.org can set up the smart HTTP protocol without using\n> --stateless-rpc; I guess I will have to ask them.\n\nHaha!\n\nGood luck with that. Current implementation requires --stateless-rpc\nto run smart HTTP.\n"}]}