summaryrefslogtreecommitdiff
path: root/upload-pack.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-01-08 18:32:36 +0700
committerJunio C Hamano <gitster@pobox.com>2013-01-08 09:28:00 -0800
commit6293ded348a918e5644d286dcd8b05044097c27d (patch)
treec5e4b749f9bc8de68616d6aa29620127eba580e1 /upload-pack.c
parent7e2010537e96d0a1144520222f20ba1dc3d61441 (diff)
downloadgit-6293ded348a918e5644d286dcd8b05044097c27d.tar.gz
upload-pack: only accept commits from "shallow" line
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>
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 2e90ccb74f..8c715354e7 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -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;