Page MenuHomePhabricator

Git protocol proxy can not parse protocol frames if repository on disk is a shallow clone
Closed, ResolvedPublic

Description

See https://discourse.phabricator-community.org/t/how-to-have-a-shallow-git-mirror/2805/.

If you manually put a shallow clone in place on disk, git fetch fails when proxied:

# Cleared to fetch on cluster host "local.phacility.net".
Exception: Unexpected "git upload-pack" protocol frame: expected "<hash> <name>\n", got "shallow 0ce1722b1687c260b923e0acb2ecc37721cfe180
".
fatal: Could not read from remote repository.

There is no legitimate way to get a shallow clone on disk and hosting shallow clones is not supported, but we should still parse the frames.

Event Timeline

epriestley triaged this task as Wishlist priority.Jun 13 2019, 10:42 PM
epriestley created this task.

To reproduce this, you can:

$ cd /var/repo
$ mv 123 123-full-repository
$ git clone --depth 1 file:///var/repo/123-full-repository 123

Then git clone <uri> the repository.

Here's what goes over the wire:

< Write [1,432 bytes]
<  30313032 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20484541  01020ce1722b1687c260b923e0acb2ecc37721cfe180 HEA
<  44006d75 6c74695f 61636b20 7468696e 2d706163 6b207369 64652d62 616e6420 73696465 2d62616e 642d3634 6b206f66  D.multi_ack thin-pack side-band side-band-64k of
<  732d6465 6c746120 7368616c 6c6f7720 64656570 656e2d73 696e6365 20646565 70656e2d 6e6f7420 64656570 656e2d72  s-delta shallow deepen-since deepen-not deepen-r
<  656c6174 69766520 6e6f2d70 726f6772 65737320 696e636c 7564652d 74616720 6d756c74 695f6163 6b5f6465 7461696c  elative no-progress include-tag multi_ack_detail
<  65642073 796d7265 663d4845 41443a72 6566732f 68656164 732f6d61 73746572 20616765 6e743d67 69742f32 2e32302e  ed symref=HEAD:refs/heads/master agent=git/2.20.
<  312e2841 70706c65 2e476974 2d313137 290a                                                                     1.(Apple.Git-117).
<  30303366 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  003f0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f6865 6164732f 6d617374 65720a                                                                            s/heads/master.
<  30303436 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  00460ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7265 6d6f7465 732f6f72 6967696e 2f484541 440a                                                            s/remotes/origin/HEAD.
<  30303438 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  00480ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7265 6d6f7465 732f6f72 6967696e 2f6d6173 7465720a                                                        s/remotes/origin/master.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3137360a                                               s/tags/phabricator/base/176.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3137370a                                               s/tags/phabricator/base/177.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3138330a                                               s/tags/phabricator/base/183.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3138340a                                               s/tags/phabricator/base/184.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3138350a                                               s/tags/phabricator/base/185.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3138360a                                               s/tags/phabricator/base/186.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3138370a                                               s/tags/phabricator/base/187.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3138390a                                               s/tags/phabricator/base/189.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3139310a                                               s/tags/phabricator/base/191.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3139330a                                               s/tags/phabricator/base/193.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3139350a                                               s/tags/phabricator/base/195.
<  30303463 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366 65313830 20726566  004c0ce1722b1687c260b923e0acb2ecc37721cfe180 ref
<  732f7461 67732f70 68616272 69636174 6f722f62 6173652f 3139380a                                               s/tags/phabricator/base/198.
<  30303335 7368616c 6c6f7720 30636531 37323262 31363837 63323630 62393233 65306163 62326563 63333737 32316366  0035shallow 0ce1722b1687c260b923e0acb2ecc37721cf
<  65313830 0a                                                                                                  e180.
<  30303030                                                                                                     0000

The shallow <hash> frames can not advertise capabilities.

You can create a repository with only "shallow" frames by cloning a repository with --depth, then deleting all the refs. In this case, the wire will include only "shallow" frames with no capabilities advertisement:

< Write [57 bytes]
<  30303335 7368616c 6c6f7720 64623764 63393933 64346662 30646439 61366233 37653332 65376263 37653138 63373132  0035shallow db7dc993d4fb0dd9a6b37e32e7bc7e18c712
<  32313035 0a                                                                                                  2105.
<  30303030                                                                                                     0000