]> source.dussan.org Git - jgit.git/commitdiff
Allow '@' as last character of ref 42/121042/1
authorChristian Halstrick <christian.halstrick@sap.com>
Thu, 12 Apr 2018 06:39:29 +0000 (08:39 +0200)
committerChristian Halstrick <christian.halstrick@sap.com>
Thu, 12 Apr 2018 07:37:42 +0000 (09:37 +0200)
Previously @ was allowed e.g. in branch names, but not as the last
character. The case that @ is the last character was not handled.

Change-Id: Ic33870b22236f7a5ec7b54007f1b0cefd9354bfb

org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

index 1d2a4e9ab744ce62005a028813e10d9518603d2f..05b78ea195e18c1b3b3012869ad7787066d2ade8 100644 (file)
@@ -324,6 +324,8 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase {
                assertFalse(Repository.isValidRefName("x/a\\b"));
                assertFalse(Repository.isValidRefName("x/a\u0000"));
 
+               db.resolve("x/a@");
+
                assertUnparseable(".");
                assertUnparseable("x@{3");
                assertUnparseable("x[b");
index c43037ea0ed05cc72a36e552050f047999e4ce87..3d85ee4e472fe1d0105d35de8032bead790a5c2b 100644 (file)
@@ -686,6 +686,8 @@ public abstract class Repository implements AutoCloseable {
                        case '@':
                                if (rev != null)
                                        throw new RevisionSyntaxException(revstr);
+                               if (i + 1 == revChars.length)
+                                       continue;
                                if (i + 1 < revChars.length && revChars[i + 1] != '{')
                                        continue;
                                int m;