From 48fb876a7096341a3330be5e8cf09345436a0435 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Wed, 23 May 2007 23:34:29 +0200 Subject: [PATCH] Handle old tags with some missing fields There are tag objects without a tagger header in the kernel Signed-off-by: Robin Rosenberg --- org.spearce.jgit/src/org/spearce/jgit/lib/Tag.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Tag.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Tag.java index 3fdb976d..92c3e650 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/Tag.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Tag.java @@ -96,10 +96,16 @@ public class Tag { tag = n.substring("tag ".length()); n = br.readLine(); - if (n == null || !n.startsWith("tagger ")) { - throw new CorruptObjectException(tagId, "no tagger"); - } - tagger = new PersonIdent(n.substring("tagger ".length())); + // We should see a "tagger" header here, but some repos have tags + // without it. + if (n == null) + throw new CorruptObjectException(tagId, "no tagger header"); + + if (n.length()>0) + if (n.startsWith("tagger ")) + tagger = new PersonIdent(n.substring("tagger ".length())); + else + throw new CorruptObjectException(tagId, "no tagger/bad header"); // Message should start with an empty line, but StringBuffer tempMessage = new StringBuffer(); -- 2.11.4.GIT