diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefSpecTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefSpecTest.java index 4f833509d..b14b0b334 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefSpecTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefSpecTest.java @@ -408,6 +408,16 @@ public class RefSpecTest { assertEquals("foo/head", c.getSource()); } + @Test(expected = IllegalArgumentException.class) + public void invalidWhenSourceEndsWithSlash() { + assertNotNull(new RefSpec("refs/heads/")); + } + + @Test(expected = IllegalArgumentException.class) + public void invalidWhenDestinationEndsWithSlash() { + assertNotNull(new RefSpec("refs/heads/master:refs/heads/")); + } + @Test(expected = IllegalArgumentException.class) public void invalidWhenSourceOnlyAndWildcard() { assertNotNull(new RefSpec("refs/heads/*")); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefSpec.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefSpec.java index 0e803bdaf..cbc6cc021 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefSpec.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RefSpec.java @@ -453,6 +453,8 @@ public class RefSpec implements Serializable { return false; if (s.contains("//")) //$NON-NLS-1$ return false; + if (s.endsWith("/")) //$NON-NLS-1$ + return false; int i = s.indexOf('*'); if (i != -1) { if (s.indexOf('*', i + 1) > i)