{"thread":{"id":"33701","subject":"[PATCH v2] upload-pack: ignore 'shallow' lines with unknown obj-ids","startedAt":"2013-05-02T14:56:07Z","lastAt":"2013-05-02T17:05:13Z","messageCount":3,"participants":["Michael Heemskerk","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"216263","messageId":"1367506567-36828-1-git-send-email-mheemskerk@atlassian.com","threadId":"33701","inReplyTo":null,"subject":"[PATCH v2] upload-pack: ignore 'shallow' lines with unknown obj-ids","fromName":"Michael Heemskerk","fromEmail":"mheemskerk@atlassian.com","sentAt":"2013-05-02T14:56:07Z","receivedAt":"2013-05-02T14:56:07Z","isPatch":true,"sender":{"key":"mheemskerk@atlassian.com","avatar":"https://gravatar.com/avatar/c3ebe086c3c55529246291e9879e5ef7af3c0ffcadbd81b5508b5fcdf66aa065?d=mp&s=160"},"body":"When the client sends a 'shallow' line for an object that the server does\nnot have, the server currently dies with the error: \"did not find object\nfor shallow <obj-id>\".  The client may have truncated the history at\nthe commit by fetching shallowly from a different server, or the commit\nmay have been garbage collected by the server. In either case, this\nunknown commit is not relevant for calculating the pack that is to be\nsent and can be safely ignored, and it is not used when recomputing where\nthe updated history of the client is cauterised.\n\nThe documentation in technical/pack-protocol.txt has been updated to\nremove the restriction that \"Clients MUST NOT mention an obj-id which it\ndoes not know exists on the server\". This requirement is not realistic\nbecause clients cannot know whether an object has been garbage collected\nby the server.\n\nSigned-off-by: Michael Heemskerk <mheemskerk@atlassian.com>\nReviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/technical/pack-protocol.txt |  3 +--\n t/t5500-fetch-pack.sh                     | 13 +++++++++++++\n upload-pack.c                             |  2 +-\n 3 files changed, 15 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/technical/pack-protocol.txt b/Documentation/technical/pack-protocol.txt\nindex f1a51ed..b898e97 100644\n--- a/Documentation/technical/pack-protocol.txt\n+++ b/Documentation/technical/pack-protocol.txt\n@@ -228,8 +228,7 @@ obtained through ref discovery.\n The client MUST write all obj-ids which it only has shallow copies\n of (meaning that it does not have the parents of a commit) as\n 'shallow' lines so that the server is aware of the limitations of\n-the client's history. Clients MUST NOT mention an obj-id which\n-it does not know exists on the server.\n+the client's history.\n \n The client now sends the maximum commit history depth it wants for\n this transaction, which is the number of commits it wants from the\ndiff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh\nindex d574085..3f0ca10 100755\n--- a/t/t5500-fetch-pack.sh\n+++ b/t/t5500-fetch-pack.sh\n@@ -373,6 +373,19 @@ test_expect_success 'clone shallow with packed refs' '\n \ttest_cmp count8.expected count8.actual\n '\n \n+test_expect_success 'fetch in shallow repo unreachable shallow objects' '\n+\t(\n+\t\tgit clone --bare --branch B --single-branch \"file://$(pwd)/.\" no-reflog &&\n+\t\tgit clone --depth 1 \"file://$(pwd)/no-reflog\" shallow9 &&\n+\t\tcd no-reflog &&\n+\t\tgit tag -d TAGB1 TAGB2 &&\n+\t\tgit update-ref refs/heads/B B~~ &&\n+\t\tgit gc --prune=now &&\n+\t\tcd ../shallow9 &&\n+\t\tgit fetch origin\n+\t)\n+'\n+\n test_expect_success 'setup tests for the --stdin parameter' '\n \tfor head in C D E F\n \tdo\ndiff --git a/upload-pack.c b/upload-pack.c\nindex bfa6279..127e59a 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -592,7 +592,7 @@ static void receive_needs(void)\n \t\t\t\tdie(\"invalid shallow line: %s\", line);\n \t\t\tobject = parse_object(sha1);\n \t\t\tif (!object)\n-\t\t\t\tdie(\"did not find object for %s\", line);\n+\t\t\t\tcontinue;\n \t\t\tif (object->type != OBJ_COMMIT)\n \t\t\t\tdie(\"invalid shallow object %s\", sha1_to_hex(sha1));\n \t\t\tif (!(object->flags & CLIENT_SHALLOW)) {\n-- \n1.8.0.2\n"},{"id":"216274","messageId":"7vk3nh1fwx.fsf@alter.siamese.dyndns.org","threadId":"33701","inReplyTo":"1367506567-36828-1-git-send-email-mheemskerk@atlassian.com","subject":"Re: [PATCH v2] upload-pack: ignore 'shallow' lines with unknown obj-ids","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-02T16:54:06Z","receivedAt":"2013-05-02T16:54:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Heemskerk <mheemskerk@atlassian.com> writes:\n\n> When the client sends a 'shallow' line for an object that the server does\n> not have, the server currently dies with the error: \"did not find object\n> ...\n>  Documentation/technical/pack-protocol.txt |  3 +--\n>  t/t5500-fetch-pack.sh                     | 13 +++++++++++++\n>  upload-pack.c                             |  2 +-\n>  3 files changed, 15 insertions(+), 3 deletions(-)\n\nThanks.\n\nThe previous one (without the test) is already in 'next' so I'll\npick only the test part and queue it as an update to the series.\n\n> diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh\n> index d574085..3f0ca10 100755\n> --- a/t/t5500-fetch-pack.sh\n> +++ b/t/t5500-fetch-pack.sh\n> @@ -373,6 +373,19 @@ test_expect_success 'clone shallow with packed refs' '\n>  \ttest_cmp count8.expected count8.actual\n>  '\n>  \n> +test_expect_success 'fetch in shallow repo unreachable shallow objects' '\n> +\t(\n> +\t\tgit clone --bare --branch B --single-branch \"file://$(pwd)/.\" no-reflog &&\n> +\t\tgit clone --depth 1 \"file://$(pwd)/no-reflog\" shallow9 &&\n> +\t\tcd no-reflog &&\n> +\t\tgit tag -d TAGB1 TAGB2 &&\n> +\t\tgit update-ref refs/heads/B B~~ &&\n> +\t\tgit gc --prune=now &&\n> +\t\tcd ../shallow9 &&\n> +\t\tgit fetch origin\n> +\t)\n> +'\n> +\n>  test_expect_success 'setup tests for the --stdin parameter' '\n>  \tfor head in C D E F\n>  \tdo\n"},{"id":"216279","messageId":"7vehdp1fee.fsf@alter.siamese.dyndns.org","threadId":"33701","inReplyTo":"7vk3nh1fwx.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] upload-pack: ignore 'shallow' lines with unknown obj-ids","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-02T17:05:13Z","receivedAt":"2013-05-02T17:05:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Michael Heemskerk <mheemskerk@atlassian.com> writes:\n>\n>> When the client sends a 'shallow' line for an object that the server does\n>> not have, the server currently dies with the error: \"did not find object\n>> ...\n>>  Documentation/technical/pack-protocol.txt |  3 +--\n>>  t/t5500-fetch-pack.sh                     | 13 +++++++++++++\n>>  upload-pack.c                             |  2 +-\n>>  3 files changed, 15 insertions(+), 3 deletions(-)\n>\n> Thanks.\n>\n> The previous one (without the test) is already in 'next' so I'll\n> pick only the test part and queue it as an update to the series.\n>\n>> diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh\n>> index d574085..3f0ca10 100755\n>> --- a/t/t5500-fetch-pack.sh\n>> +++ b/t/t5500-fetch-pack.sh\n>> @@ -373,6 +373,19 @@ test_expect_success 'clone shallow with packed refs' '\n>>  \ttest_cmp count8.expected count8.actual\n>>  '\n>>  \n>> +test_expect_success 'fetch in shallow repo unreachable shallow objects' '\n>> +\t(\n>> +\t\tgit clone --bare --branch B --single-branch \"file://$(pwd)/.\" no-reflog &&\n>> +\t\tgit clone --depth 1 \"file://$(pwd)/no-reflog\" shallow9 &&\n>> +\t\tcd no-reflog &&\n>> +\t\tgit tag -d TAGB1 TAGB2 &&\n>> +\t\tgit update-ref refs/heads/B B~~ &&\n>> +\t\tgit gc --prune=now &&\n>> +\t\tcd ../shallow9 &&\n>> +\t\tgit fetch origin\n>> +\t)\n>> +'\n\nIt would also be good to make sure that shallow9 does not lose the\nshallow history boundary that the origin does not know about after\nthis fetch, so I'll further squash this in.\n\n t/t5500-fetch-pack.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh\nindex 3f0ca10..6133d9e 100755\n--- a/t/t5500-fetch-pack.sh\n+++ b/t/t5500-fetch-pack.sh\n@@ -382,7 +382,8 @@ test_expect_success 'fetch in shallow repo unreachable shallow objects' '\n \t\tgit update-ref refs/heads/B B~~ &&\n \t\tgit gc --prune=now &&\n \t\tcd ../shallow9 &&\n-\t\tgit fetch origin\n+\t\tgit fetch origin &&\n+\t\tgit fsck --no-dangling\n \t)\n '\n \n"}]}