Skip to content

Commit

Permalink
upload-pack: only accept commits from "shallow" line
Browse files Browse the repository at this point in the history
We only allow cuts at commits, not arbitrary objects. upload-pack will
fail eventually in register_shallow if a non-commit is given with a
generic error "Object %s is a %s, not a commit". Check it early and
give a more accurate error.

This should never show up in an ordinary session. It's for buggy
clients, or when the user manually edits .git/shallow.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Jan 8, 2013
1 parent 7e20105 commit 6293ded
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions upload-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ static void receive_needs(void)
object = parse_object(sha1);
if (!object)
die("did not find object for %s", line);
if (object->type != OBJ_COMMIT)
die("invalid shallow object %s", sha1_to_hex(sha1));
object->flags |= CLIENT_SHALLOW;
add_object_array(object, NULL, &shallows);
continue;
Expand Down

0 comments on commit 6293ded

Please sign in to comment.