From b46c4463959f45b32e471e4c10b5ddc71232949e Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Mon, 14 Sep 2015 12:18:20 -0700 Subject: UploadPack: Verify clients send only commits for shallow lines If a client mistakenly tries to send a tag object as a shallow line JGit blindly assumes this is a commit and tries to parse the tag buffer using the commit parser. This can cause an obtuse error like: InvalidObjectIdException: Invalid id: t c0ff331234... The "t" comes from the "object c0ff331234..." line of the tag tring to be parsed as though it where the "tree" line of a commit. Run any client supplied shallow lines through the RevWalk to lookup the object types. Fail fast with a protocol exception if any of them are non-commit. Skip objects not known to this repository. This matches behavior with git-core's upload-pack, which sliently skips over any shallow line object named by the client but not known by the server. Change-Id: Ic6c57a90a42813164ce65c2244705fc42e84d700 --- org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/revwalk') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java index afb208ecf9..1176d958b0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java @@ -1406,6 +1406,8 @@ public class RevWalk implements Iterable, AutoCloseable { /** * Assume additional commits are shallow (have no parents). + *

+ * This method is a No-op if the collection is empty. * * @param ids * commits that should be treated as shallow commits, in addition -- cgit v1.2.3