From 8b75b9d8c4d90241bfaaa32058000418afa801a7 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 7 Mar 2006 03:04:20 -0500 Subject: [PATCH] Don't write a tree unless any symbolic links referenced within it are already in the object repository. We just don't support them in Java right now but we shouldn't omit them from the tree or write a corrupt tree because of them. Patch: Initial-Files --- src/org/spearce/jgit/lib/WriteTree.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/org/spearce/jgit/lib/WriteTree.java b/src/org/spearce/jgit/lib/WriteTree.java index 8f9ddd26..1de0b891 100644 --- a/src/org/spearce/jgit/lib/WriteTree.java +++ b/src/org/spearce/jgit/lib/WriteTree.java @@ -69,6 +69,11 @@ public class WriteTree extends TreeVisitor { protected void visitSymlink(final SymlinkTreeEntry s) throws IOException { super.visitSymlink(s); + + if (!objdb.checkObject(s.getId())) { + throw new CorruptObjectException("Missing symlink blob " + + s.getId()); + } } protected void visitTree(final Tree t) throws IOException { @@ -102,6 +107,7 @@ public class WriteTree extends TreeVisitor { while (i.hasNext()) { final TreeEntry e = (TreeEntry) i.next(); final byte[] mode; + if (e instanceof Tree) { mode = TREE_MODE; } else if (e instanceof SymlinkTreeEntry) { -- 2.11.4.GIT