Skip to content

Commit af04fa2

Browse files
Michael Heemskerkgitster
authored andcommitted
upload-pack: ignore 'shallow' lines with unknown obj-ids
When the client sends a 'shallow' line for an object that the server does not have, the server currently dies with the error: "did not find object for shallow <obj-id>". The client may have truncated the history at the commit by fetching shallowly from a different server, or the commit may have been garbage collected by the server. In either case, this unknown commit is not relevant for calculating the pack that is to be sent and can be safely ignored, and it is not used when recomputing where the updated history of the client is cauterised. The documentation in technical/pack-protocol.txt has been updated to remove the restriction that "Clients MUST NOT mention an obj-id which it does not know exists on the server". This requirement is not realistic because clients cannot know whether an object has been garbage collected by the server. Signed-off-by: Michael Heemskerk <[email protected]> Reviewed-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b75cdfa commit af04fa2

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

Documentation/technical/pack-protocol.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ obtained through ref discovery.
228228
The client MUST write all obj-ids which it only has shallow copies
229229
of (meaning that it does not have the parents of a commit) as
230230
'shallow' lines so that the server is aware of the limitations of
231-
the client's history. Clients MUST NOT mention an obj-id which
232-
it does not know exists on the server.
231+
the client's history.
233232

234233
The client now sends the maximum commit history depth it wants for
235234
this transaction, which is the number of commits it wants from the

upload-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ static void receive_needs(void)
592592
die("invalid shallow line: %s", line);
593593
object = parse_object(sha1);
594594
if (!object)
595-
die("did not find object for %s", line);
595+
continue;
596596
if (object->type != OBJ_COMMIT)
597597
die("invalid shallow object %s", sha1_to_hex(sha1));
598598
if (!(object->flags & CLIENT_SHALLOW)) {

0 commit comments

Comments
 (0)