summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2010-01-28 23:43:40 -0500
committerCode Review <codereview-daemon@eclipse.org>2010-01-28 23:43:40 -0500
commit94599930e75b941869b02d0ea1147d6be0cb4ab4 (patch)
tree0f2683e9a4ed2f47c192bf3b3829b1ec250c49c5
parentaa97c6e4499547c1e33b54a5630b03f2983828b4 (diff)
parent7c82df1114537fe221eeb2d8ac79b3eab9fa7225 (diff)
downloadjgit-94599930e75b941869b02d0ea1147d6be0cb4ab4.tar.gz
jgit-94599930e75b941869b02d0ea1147d6be0cb4ab4.zip
Merge "Relax ObjectChecker to permit missing tagger lines"
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java31
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java47
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java10
3 files changed, 54 insertions, 34 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java
index 7c2676bc7d..2e470b386b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, Google Inc.
+ * Copyright (C) 2008-2010, Google Inc.
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
* and other copyright owners as documented in the project's IP log.
*
@@ -868,26 +868,7 @@ public class ObjectCheckerTest extends TestCase {
}
}
- public void testInvalidTagNoTagHeader4() {
- final StringBuilder b = new StringBuilder();
-
- b.append("object ");
- b.append("be9bfa841874ccc9f2ef7c48d0c76226f89b7189");
- b.append('\n');
-
- b.append("type commit\n");
- b.append("tag foo");
-
- final byte[] data = Constants.encodeASCII(b.toString());
- try {
- checker.checkTag(data);
- fail("incorrectly accepted invalid tag");
- } catch (CorruptObjectException e) {
- assertEquals("no tagger header", e.getMessage());
- }
- }
-
- public void testInvalidTagNoTaggerHeader1() {
+ public void testValidTagHasNoTaggerHeader() throws CorruptObjectException {
final StringBuilder b = new StringBuilder();
b.append("object ");
@@ -897,13 +878,7 @@ public class ObjectCheckerTest extends TestCase {
b.append("type commit\n");
b.append("tag foo\n");
- final byte[] data = Constants.encodeASCII(b.toString());
- try {
- checker.checkTag(data);
- fail("incorrectly accepted invalid tag");
- } catch (CorruptObjectException e) {
- assertEquals("no tagger header", e.getMessage());
- }
+ checker.checkTag(Constants.encodeASCII(b.toString()));
}
public void testInvalidTagInvalidTaggerHeader1() {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java
index 8800536d27..b3e62f49e3 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2009, Google Inc.
+ * Copyright (C) 2008-2010, Google Inc.
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -140,6 +140,51 @@ public class RevTagParseTest extends RepositoryTestCase {
assertEquals(taggerEmail, cTagger.getEmailAddress());
}
+ public void testParseOldStyleNoTagger() throws Exception {
+ final ObjectId treeId = id("9788669ad918b6fcce64af8882fc9a81cb6aba67");
+ final String name = "v1.2.3.4.5";
+ final String message = "test\n" //
+ + "\n" //
+ + "-----BEGIN PGP SIGNATURE-----\n" //
+ + "Version: GnuPG v1.4.1 (GNU/Linux)\n" //
+ + "\n" //
+ + "iD8DBQBC0b9oF3Y\n" //
+ + "-----END PGP SIGNATURE------n";
+
+ final StringBuilder body = new StringBuilder();
+
+ body.append("object ");
+ body.append(treeId.name());
+ body.append("\n");
+
+ body.append("type tree\n");
+
+ body.append("tag ");
+ body.append(name);
+ body.append("\n");
+ body.append("\n");
+ body.append(message);
+
+ final RevWalk rw = new RevWalk(db);
+ final RevTag c;
+
+ c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
+ assertNull(c.getObject());
+ assertNull(c.getTagName());
+
+ c.parseCanonical(rw, body.toString().getBytes("UTF-8"));
+ assertNotNull(c.getObject());
+ assertEquals(treeId, c.getObject().getId());
+ assertSame(rw.lookupTree(treeId), c.getObject());
+
+ assertNotNull(c.getTagName());
+ assertEquals(name, c.getTagName());
+ assertEquals("test", c.getShortMessage());
+ assertEquals(message, c.getFullMessage());
+
+ assertNull(c.getTaggerIdent());
+ }
+
private RevTag create(final String msg) throws Exception {
final StringBuilder b = new StringBuilder();
b.append("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n");
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java
index 82a8c38257..5906802d18 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, Google Inc.
+ * Copyright (C) 2008-2010, Google Inc.
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
* and other copyright owners as documented in the project's IP log.
*
@@ -217,10 +217,10 @@ public class ObjectChecker {
throw new CorruptObjectException("no tag header");
ptr = nextLF(raw, ptr);
- if ((ptr = match(raw, ptr, tagger)) < 0)
- throw new CorruptObjectException("no tagger header");
- if ((ptr = personIdent(raw, ptr)) < 0 || raw[ptr++] != '\n')
- throw new CorruptObjectException("invalid tagger");
+ if ((ptr = match(raw, ptr, tagger)) > 0) {
+ if ((ptr = personIdent(raw, ptr)) < 0 || raw[ptr++] != '\n')
+ throw new CorruptObjectException("invalid tagger");
+ }
}
private static int lastPathChar(final int mode) {