summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2018-06-08 17:45:00 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2018-06-09 01:20:13 +0200
commit62460b42b7a64513e3421aae17082fdc923faf95 (patch)
tree9a09ec56d6e9bd87c734d5606333bbd2298a5691 /org.eclipse.jgit.test/tst
parent5f27032fb85694a093f827581216d4ffb99db68b (diff)
downloadjgit-62460b42b7a64513e3421aae17082fdc923faf95.tar.gz
jgit-62460b42b7a64513e3421aae17082fdc923faf95.zip
Validate branch names on branch creation
Since v2.16.0-rc0~89^2~1 (branch: correctly reject refs/heads/{-dash,HEAD}, 2017-11-14), native git does not allow branch names - refs/heads/HEAD - starting with '-' Bug: 535655 Change-Id: Ib1c4ec9ea844073901a4ebe6a29ff6cc8ae58e93 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
index 2fe40b99ed..08f1fdfacf 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
@@ -191,6 +191,18 @@ public class BranchCommandTest extends RepositoryTestCase {
- allBefore);
}
+ @Test(expected = InvalidRefNameException.class)
+ public void testInvalidBranchHEAD() throws Exception {
+ git.branchCreate().setName("HEAD").call();
+ fail("Create branch with invalid ref name should fail");
+ }
+
+ @Test(expected = InvalidRefNameException.class)
+ public void testInvalidBranchDash() throws Exception {
+ git.branchCreate().setName("-x").call();
+ fail("Create branch with invalid ref name should fail");
+ }
+
@Test
public void testListAllBranchesShouldNotDie() throws Exception {
setUpRepoWithRemote().branchList().setListMode(ListMode.ALL).call();