diff --git a/org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java b/org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java index 7cd5b7451..3ce066376 100644 --- a/org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java +++ b/org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java @@ -101,7 +101,7 @@ public class GitCloneTaskTest extends LocalDiskRepositoryTestCase { public void shouldCloneAValidGitRepository() throws Exception { Repository repo = createBareRepository(); File directory = repo.getDirectory(); - task.setUri("file://" + directory); + task.setUri("file://" + directory.getAbsolutePath()); task.execute(); assertTrue(RepositoryCache.FileKey.isGitRepository(new File(dest, ".git"), FS.DETECTED)); @@ -111,7 +111,7 @@ public class GitCloneTaskTest extends LocalDiskRepositoryTestCase { public void shouldCreateABareCloneOfAValidGitRepository() throws Exception { Repository repo = createBareRepository(); File directory = repo.getDirectory(); - task.setUri("file://" + directory); + task.setUri("file://" + directory.getAbsolutePath()); task.setBare(true); task.execute(); diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java index 92d575c2d..d8cd61df8 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java @@ -44,9 +44,9 @@ package org.eclipse.jgit.http.server; import static org.eclipse.jgit.http.server.ServletUtils.ATTRIBUTE_HANDLER; -import static org.eclipse.jgit.transport.BasePackFetchConnection.OPTION_SIDE_BAND; -import static org.eclipse.jgit.transport.BasePackFetchConnection.OPTION_SIDE_BAND_64K; -import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_SIDE_BAND_64K; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_SIDE_BAND; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_SIDE_BAND_64K; +import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_SIDE_BAND_64K; import static org.eclipse.jgit.transport.SideBandOutputStream.CH_ERROR; import static org.eclipse.jgit.transport.SideBandOutputStream.SMALL_BUF; import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN; diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java index 8d0ba964c..7c6d59151 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java @@ -153,7 +153,7 @@ public class FileResolverTest extends LocalDiskRepositoryTestCase { Throwable why = e.getCause(); assertNotNull("has cause", why); assertEquals("repository not found: " - + new File(base, name).getAbsolutePath(), why.getMessage()); + + new File(base, name).getPath(), why.getMessage()); } } } diff --git a/org.eclipse.jgit.java7.test/pom.xml b/org.eclipse.jgit.java7.test/pom.xml index 6c0dd33bc..3641f59ae 100644 --- a/org.eclipse.jgit.java7.test/pom.xml +++ b/org.eclipse.jgit.java7.test/pom.xml @@ -118,7 +118,7 @@ maven-surefire-plugin - -Xmx256m -Dfile.encoding=UTF-8 + -Xmx256m -Dfile.encoding=UTF-8 -Djava.io.tmpdir=${project.build.directory} diff --git a/org.eclipse.jgit.java7.test/src/org/eclipse/jgit/util/FSJava7Test.java b/org.eclipse.jgit.java7.test/src/org/eclipse/jgit/util/FSJava7Test.java index d735bd3ce..4b5fe5979 100644 --- a/org.eclipse.jgit.java7.test/src/org/eclipse/jgit/util/FSJava7Test.java +++ b/org.eclipse.jgit.java7.test/src/org/eclipse/jgit/util/FSJava7Test.java @@ -58,13 +58,13 @@ import org.junit.Before; import org.junit.Test; public class FSJava7Test { - - private final File trash = new File(new File("target"), "trash"); + private File trash; @Before public void setUp() throws Exception { - FileUtils.delete(trash, FileUtils.RECURSIVE | FileUtils.RETRY | FileUtils.SKIP_MISSING); - assertTrue(trash.mkdirs()); + trash = File.createTempFile("tmp_", ""); + trash.delete(); + assertTrue("mkdir " + trash, trash.mkdir()); } @After diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java index 910e3a958..ad3ff60a0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java @@ -53,7 +53,6 @@ import java.io.InputStream; import org.eclipse.jgit.api.errors.PatchApplyException; import org.eclipse.jgit.api.errors.PatchFormatException; -import org.eclipse.jgit.diff.DiffFormatterReflowTest; import org.eclipse.jgit.diff.RawText; import org.eclipse.jgit.junit.RepositoryTestCase; import org.junit.Test; @@ -86,9 +85,7 @@ public class ApplyCommandTest extends RepositoryTestCase { return git .apply() - .setPatch( - DiffFormatterReflowTest.class.getResourceAsStream(name - + ".patch")).call(); + .setPatch(getTestResource(name + ".patch")).call(); } @Test @@ -189,8 +186,7 @@ public class ApplyCommandTest extends RepositoryTestCase { } private static byte[] readFile(final String patchFile) throws IOException { - final InputStream in = DiffFormatterReflowTest.class - .getResourceAsStream(patchFile); + final InputStream in = getTestResource(patchFile); if (in == null) { fail("No " + patchFile + " test vector"); return null; // Never happens @@ -206,4 +202,9 @@ public class ApplyCommandTest extends RepositoryTestCase { in.close(); } } + + private static InputStream getTestResource(final String patchFile) { + return ApplyCommandTest.class.getClassLoader() + .getResourceAsStream("org/eclipse/jgit/diff/" + patchFile); + } } 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 c2c8317d9..91ced0a59 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 @@ -121,7 +121,7 @@ public class BranchCommandTest extends RepositoryTestCase { Git localGit = new Git(localRepository); StoredConfig config = localRepository.getConfig(); RemoteConfig rc = new RemoteConfig(config, "origin"); - rc.addURI(new URIish(remoteRepository.getDirectory().getPath())); + rc.addURI(new URIish(remoteRepository.getDirectory().getAbsolutePath())); rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*")); rc.update(config); config.save(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java index 31f909a5f..56c120176 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java @@ -110,7 +110,7 @@ public class CloneCommandTest extends RepositoryTestCase { File directory = createTempDirectory("testCloneRepository"); CloneCommand command = Git.cloneRepository(); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); Git git2 = command.call(); addRepoToClose(git2.getRepository()); assertNotNull(git2); @@ -142,7 +142,7 @@ public class CloneCommandTest extends RepositoryTestCase { CloneCommand command = Git.cloneRepository(); command.setBare(true); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); Git git2 = command.call(); addRepoToClose(git2.getRepository()); assertEquals(new RefSpec("+refs/heads/*:refs/heads/*"), @@ -162,7 +162,7 @@ public class CloneCommandTest extends RepositoryTestCase { CloneCommand command = Git.cloneRepository(); command.setBranch("refs/heads/master"); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); Git git2 = command.call(); addRepoToClose(git2.getRepository()); @@ -177,7 +177,7 @@ public class CloneCommandTest extends RepositoryTestCase { command = Git.cloneRepository(); command.setBranch("refs/heads/master"); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); command.setNoCheckout(true); git2 = command.call(); addRepoToClose(git2.getRepository()); @@ -192,7 +192,7 @@ public class CloneCommandTest extends RepositoryTestCase { command = Git.cloneRepository(); command.setBranch("refs/heads/master"); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); command.setBare(true); git2 = command.call(); addRepoToClose(git2.getRepository()); @@ -209,7 +209,7 @@ public class CloneCommandTest extends RepositoryTestCase { CloneCommand command = Git.cloneRepository(); command.setBranch("test"); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); Git git2 = command.call(); addRepoToClose(git2.getRepository()); @@ -223,7 +223,7 @@ public class CloneCommandTest extends RepositoryTestCase { CloneCommand command = Git.cloneRepository(); command.setBranch("tag-initial"); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); Git git2 = command.call(); addRepoToClose(git2.getRepository()); @@ -242,7 +242,7 @@ public class CloneCommandTest extends RepositoryTestCase { command.setBranchesToClone(Collections .singletonList("refs/heads/master")); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); Git git2 = command.call(); addRepoToClose(git2.getRepository()); assertNotNull(git2); @@ -257,7 +257,7 @@ public class CloneCommandTest extends RepositoryTestCase { command.setBranchesToClone(Collections .singletonList("refs/heads/master")); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); command.setBare(true); git2 = command.call(); addRepoToClose(git2.getRepository()); @@ -284,14 +284,14 @@ public class CloneCommandTest extends RepositoryTestCase { File directory = createTempDirectory(dirName); CloneCommand command = Git.cloneRepository(); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); Git git2 = command.call(); addRepoToClose(git2.getRepository()); assertNotNull(git2); // clone again command = Git.cloneRepository(); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); try { git2 = command.call(); // we shouldn't get here @@ -310,7 +310,7 @@ public class CloneCommandTest extends RepositoryTestCase { File directory = createTempDirectory("testCloneRepositoryWithMultipleHeadBranches"); CloneCommand clone = Git.cloneRepository(); clone.setDirectory(directory); - clone.setURI("file://" + git.getRepository().getWorkTree().getPath()); + clone.setURI(fileUri()); Git git2 = clone.call(); addRepoToClose(git2.getRepository()); assertNotNull(git2); @@ -343,7 +343,7 @@ public class CloneCommandTest extends RepositoryTestCase { CloneCommand clone = Git.cloneRepository(); clone.setDirectory(directory); clone.setCloneSubmodules(true); - clone.setURI("file://" + git.getRepository().getWorkTree().getPath()); + clone.setURI(fileUri()); Git git2 = clone.call(); addRepoToClose(git2.getRepository()); assertNotNull(git2); @@ -458,7 +458,7 @@ public class CloneCommandTest extends RepositoryTestCase { File directory = createTempDirectory("testCloneRepository1"); CloneCommand command = Git.cloneRepository(); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); Git git2 = command.call(); addRepoToClose(git2.getRepository()); assertFalse(git2 @@ -476,7 +476,7 @@ public class CloneCommandTest extends RepositoryTestCase { directory = createTempDirectory("testCloneRepository2"); command = Git.cloneRepository(); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); git2 = command.call(); addRepoToClose(git2.getRepository()); assertTrue(git2 @@ -492,7 +492,7 @@ public class CloneCommandTest extends RepositoryTestCase { directory = createTempDirectory("testCloneRepository2"); command = Git.cloneRepository(); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); git2 = command.call(); addRepoToClose(git2.getRepository()); assertTrue(git2 @@ -502,4 +502,8 @@ public class CloneCommandTest extends RepositoryTestCase { ConfigConstants.CONFIG_KEY_REBASE, false)); } + + private String fileUri() { + return "file://" + git.getRepository().getWorkTree().getAbsolutePath(); + } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java index f31276dee..a853d6ab8 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java @@ -82,7 +82,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase { File directory = createTempDirectory("testRepository"); CloneCommand command = Git.cloneRepository(); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); command.setCloneAllBranches(true); Git git2 = command.call(); addRepoToClose(git2.getRepository()); @@ -99,7 +99,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase { File directory = createTempDirectory("testRepository"); CloneCommand command = Git.cloneRepository(); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); command.setCloneAllBranches(true); Git git2 = command.call(); addRepoToClose(git2.getRepository()); @@ -116,7 +116,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase { File directory = createTempDirectory("testRepository"); CloneCommand command = Git.cloneRepository(); command.setDirectory(directory); - command.setURI("file://" + git.getRepository().getWorkTree().getPath()); + command.setURI(fileUri()); command.setCloneAllBranches(true); Git git2 = command.call(); addRepoToClose(git2.getRepository()); @@ -130,10 +130,14 @@ public class LsRemoteCommandTest extends RepositoryTestCase { @Test public void testLsRemoteWithoutLocalRepository() throws Exception { - String uri = "file://" + git.getRepository().getWorkTree().getPath(); + String uri = fileUri(); Collection refs = Git.lsRemoteRepository().setRemote(uri).setHeads(true).call(); assertNotNull(refs); assertEquals(2, refs.size()); } + private String fileUri() { + return "file://" + git.getRepository().getWorkTree().getAbsolutePath(); + } + } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java index 67e1879d3..29146dc58 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java @@ -1340,7 +1340,7 @@ public class MergeCommandTest extends RepositoryTestCase { assertNull(db.readMergeCommitMsg()); Status stat = git.status().call(); - assertEquals(StatusCommandTest.set("file2", "file3"), stat.getAdded()); + assertEquals(Sets.of("file2", "file3"), stat.getAdded()); } @Test @@ -1396,7 +1396,7 @@ public class MergeCommandTest extends RepositoryTestCase { assertNull(db.readMergeCommitMsg()); Status stat = git.status().call(); - assertEquals(StatusCommandTest.set("file3"), stat.getAdded()); + assertEquals(Sets.of("file3"), stat.getAdded()); } @Test @@ -1450,7 +1450,7 @@ public class MergeCommandTest extends RepositoryTestCase { assertEquals("\nConflicts:\n\tfile2\n", db.readMergeCommitMsg()); Status stat = git.status().call(); - assertEquals(StatusCommandTest.set("file2"), stat.getConflicting()); + assertEquals(Sets.of("file2"), stat.getConflicting()); } @Test diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java index 8d22a1b58..c03ced563 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java @@ -139,7 +139,8 @@ public class PullCommandTest extends RepositoryTestCase { assertEquals(sourceCommit.getId(), mergedCommits[1]); RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult .getNewHead()); - String message = "Merge branch 'master' of " + db.getWorkTree(); + String message = "Merge branch 'master' of " + + db.getWorkTree().getAbsolutePath(); assertEquals(message, mergeCommit.getShortMessage()); } @@ -255,7 +256,7 @@ public class PullCommandTest extends RepositoryTestCase { config .addURI(new URIish(source.getRepository().getWorkTree() - .getPath())); + .getAbsolutePath())); config.addFetchRefSpec(new RefSpec( "+refs/heads/*:refs/remotes/origin/*")); config.update(targetConfig); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java index 993e16f5e..25534fdda 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java @@ -319,7 +319,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase { config .addURI(new URIish(source.getRepository().getWorkTree() - .getPath())); + .getAbsolutePath())); config.addFetchRefSpec(new RefSpec( "+refs/heads/*:refs/remotes/origin/*")); config.update(targetConfig); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/Sets.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/Sets.java new file mode 100644 index 000000000..edfab551a --- /dev/null +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/Sets.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2011, Christian Halstrick + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * - Neither the name of the Eclipse Foundation, Inc. nor the + * names of its contributors may be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.eclipse.jgit.api; + +import java.util.HashSet; +import java.util.Set; + +class Sets { + static Set of(T... elements) { + Set ret = new HashSet(); + for (T element : elements) + ret.add(element); + return ret; + } +} diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java index 8b3e87f2d..47650232b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java @@ -48,8 +48,6 @@ import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; -import java.util.HashSet; -import java.util.Set; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.NoFilepatternException; @@ -82,12 +80,12 @@ public class StatusCommandTest extends RepositoryTestCase { writeTrashFile("c", "content of c"); git.add().addFilepattern("a").addFilepattern("b").call(); Status stat = git.status().call(); - assertEquals(set("a", "b"), stat.getAdded()); + assertEquals(Sets.of("a", "b"), stat.getAdded()); assertEquals(0, stat.getChanged().size()); assertEquals(0, stat.getMissing().size()); assertEquals(0, stat.getModified().size()); assertEquals(0, stat.getRemoved().size()); - assertEquals(set("c"), stat.getUntracked()); + assertEquals(Sets.of("c"), stat.getUntracked()); git.commit().setMessage("initial").call(); writeTrashFile("a", "modified content of a"); @@ -96,12 +94,12 @@ public class StatusCommandTest extends RepositoryTestCase { git.add().addFilepattern("a").addFilepattern("d").call(); writeTrashFile("a", "again modified content of a"); stat = git.status().call(); - assertEquals(set("d"), stat.getAdded()); - assertEquals(set("a"), stat.getChanged()); + assertEquals(Sets.of("d"), stat.getAdded()); + assertEquals(Sets.of("a"), stat.getChanged()); assertEquals(0, stat.getMissing().size()); - assertEquals(set("b", "a"), stat.getModified()); + assertEquals(Sets.of("b", "a"), stat.getModified()); assertEquals(0, stat.getRemoved().size()); - assertEquals(set("c"), stat.getUntracked()); + assertEquals(Sets.of("c"), stat.getUntracked()); git.add().addFilepattern(".").call(); git.commit().setMessage("second").call(); @@ -122,8 +120,8 @@ public class StatusCommandTest extends RepositoryTestCase { assertEquals(0, stat.getChanged().size()); assertEquals(0, stat.getMissing().size()); assertEquals(0, stat.getModified().size()); - assertEquals(set("a"), stat.getRemoved()); - assertEquals(set("a"), stat.getUntracked()); + assertEquals(Sets.of("a"), stat.getRemoved()); + assertEquals(Sets.of("a"), stat.getUntracked()); git.commit().setMessage("t").call(); writeTrashFile("sub/a", "sub-file"); @@ -153,25 +151,18 @@ public class StatusCommandTest extends RepositoryTestCase { // filter on an existing file stat = git.status().addPath("a").call(); - assertEquals(set("a"), stat.getModified()); + assertEquals(Sets.of("a"), stat.getModified()); // filter on an existing folder stat = git.status().addPath("D").call(); - assertEquals(set("D/b", "D/D/d"), stat.getModified()); + assertEquals(Sets.of("D/b", "D/D/d"), stat.getModified()); // filter on an existing folder and file stat = git.status().addPath("D/D").addPath("a").call(); - assertEquals(set("a", "D/D/d"), stat.getModified()); + assertEquals(Sets.of("a", "D/D/d"), stat.getModified()); // do not filter at all stat = git.status().call(); - assertEquals(set("a", "D/b", "D/D/d"), stat.getModified()); - } - - public static Set set(String... elements) { - Set ret = new HashSet(); - for (String element : elements) - ret.add(element); - return ret; + assertEquals(Sets.of("a", "D/b", "D/D/d"), stat.getModified()); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java index efdcfeb47..280d6040c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java @@ -129,7 +129,8 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase { builder.setMustExist(true); Repository repo2 = builder.build(); - assertEquals(repo1.getDirectory(), repo2.getDirectory()); + assertEquals(repo1.getDirectory().getAbsolutePath(), repo2 + .getDirectory().getAbsolutePath()); assertEquals(dir, repo2.getWorkTree()); } @@ -167,7 +168,8 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase { builder.setWorkTree(dir); builder.findGitDir(dir); - assertEquals(repo1.getDirectory(), builder.getGitDir()); + assertEquals(repo1.getDirectory().getAbsolutePath(), builder + .getGitDir().getAbsolutePath()); builder.setMustExist(true); Repository repo2 = builder.build(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java index 17c44dce8..902416bdf 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java @@ -61,7 +61,14 @@ public class FileSnapshotTest { private List files = new ArrayList(); - private final File trash = new File(new File("target"), "trash"); + private File trash; + + @Before + public void setUp() throws Exception { + trash = File.createTempFile("tmp_", ""); + trash.delete(); + assertTrue("mkdir " + trash, trash.mkdir()); + } @Before @After diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java index 31938b98b..ee845c532 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.storage.file; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.ByteArrayOutputStream; import java.io.File; @@ -55,6 +56,7 @@ import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.FileUtils; import org.eclipse.jgit.util.IO; import org.junit.After; +import org.junit.Before; import org.junit.Test; public class FileBasedConfigTest { @@ -73,7 +75,14 @@ public class FileBasedConfigTest { private static final String CONTENT2 = "[" + USER + "]\n\t" + NAME + " = " + BOB + "\n"; - private final File trash = new File(new File("target"), "trash"); + private File trash; + + @Before + public void setUp() throws Exception { + trash = File.createTempFile("tmp_", ""); + trash.delete(); + assertTrue("mkdir " + trash, trash.mkdir()); + } @After public void tearDown() throws Exception { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java index 2b9c10777..383ff5011 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java @@ -171,8 +171,10 @@ public class SubmoduleWalkTest extends RepositoryTestCase { Repository subRepo = gen.getRepository(); addRepoToClose(subRepo); assertNotNull(subRepo); - assertEquals(modulesGitDir, subRepo.getDirectory()); - assertEquals(new File(db.getWorkTree(), path), subRepo.getWorkTree()); + assertEquals(modulesGitDir.getAbsolutePath(), + subRepo.getDirectory().getAbsolutePath()); + assertEquals(new File(db.getWorkTree(), path).getAbsolutePath(), + subRepo.getWorkTree().getAbsolutePath()); assertFalse(gen.next()); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java index b9691836b..28a3f4428 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java @@ -231,7 +231,7 @@ public class TransportTest extends SampleDataRepositoryTestCase { @Test public void testLocalTransportFetchWithoutLocalRepository() throws Exception { - URIish uri = new URIish("file://" + db.getWorkTree().getPath()); + URIish uri = new URIish("file://" + db.getWorkTree().getAbsolutePath()); transport = Transport.open(uri); FetchConnection fetchConnection = transport.openFetch(); try { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java index df39f2b9d..7b1627854 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java @@ -57,12 +57,13 @@ import org.junit.Before; import org.junit.Test; public class FileUtilTest { - - private final File trash = new File(new File("target"), "trash"); + private File trash; @Before public void setUp() throws Exception { - assertTrue(trash.mkdirs()); + trash = File.createTempFile("tmp_", ""); + trash.delete(); + assertTrue("mkdir " + trash, trash.mkdir()); } @After diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java index 5975d3787..83a53b9a6 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java @@ -70,9 +70,9 @@ public class AutoCRLFInputStreamTest { @Test public void testBoundary() throws IOException { for (int i = AutoCRLFInputStream.BUFFER_SIZE - 10; i < AutoCRLFInputStream.BUFFER_SIZE + 10; i++) { - String s1 = AutoCRLFOutputStreamTest.repeat("a", i); + String s1 = Strings.repeat("a", i); assertNoCrLf(s1, s1); - String s2 = AutoCRLFOutputStreamTest.repeat("\0", i); + String s2 = Strings.repeat("\0", i); assertNoCrLf(s2, s2); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java index 6cb31050f..a72d33cd5 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java @@ -72,21 +72,13 @@ public class AutoCRLFOutputStreamTest { @Test public void testBoundary() throws IOException { for (int i = AutoCRLFOutputStream.BUFFER_SIZE - 10; i < AutoCRLFOutputStream.BUFFER_SIZE + 10; i++) { - String s1 = repeat("a", i); + String s1 = Strings.repeat("a", i); assertNoCrLf(s1, s1); - String s2 = repeat("\0", i); + String s2 = Strings.repeat("\0", i); assertNoCrLf(s2, s2); } } - public static String repeat(String input, int size) { - StringBuilder sb = new StringBuilder(input.length() * size); - for (int i = 0; i < size; i++) - sb.append(input); - String s = sb.toString(); - return s; - } - private void assertNoCrLf(String string, String string2) throws IOException { assertNoCrLfHelper(string, string2); // \u00e5 = LATIN SMALL LETTER A WITH RING ABOVE diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/Strings.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/Strings.java new file mode 100644 index 000000000..3d9b054ee --- /dev/null +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/Strings.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2011, 2013 Robin Rosenberg + * Copyright (C) 2013 Robin Stocker + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * - Neither the name of the Eclipse Foundation, Inc. nor the + * names of its contributors may be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.eclipse.jgit.util.io; + +class Strings { + static String repeat(String input, int size) { + StringBuilder sb = new StringBuilder(input.length() * size); + for (int i = 0; i < size; i++) + sb.append(input); + String s = sb.toString(); + return s; + } +} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java index 952515ded..e7e8af50a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java @@ -71,6 +71,7 @@ import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.ProgressMonitor; import org.eclipse.jgit.lib.Ref; +import org.eclipse.jgit.transport.GitProtocolConstants.MultiAck; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevCommitList; import org.eclipse.jgit.revwalk.RevFlag; @@ -129,72 +130,68 @@ public abstract class BasePackFetchConnection extends BasePackConnection * Include tags if we are also including the referenced objects. * @since 2.0 */ - public static final String OPTION_INCLUDE_TAG = "include-tag"; //$NON-NLS-1$ + public static final String OPTION_INCLUDE_TAG = GitProtocolConstants.OPTION_INCLUDE_TAG; /** * Mutli-ACK support for improved negotiation. * @since 2.0 */ - public static final String OPTION_MULTI_ACK = "multi_ack"; //$NON-NLS-1$ + public static final String OPTION_MULTI_ACK = GitProtocolConstants.OPTION_MULTI_ACK; /** * Mutli-ACK detailed support for improved negotiation. * @since 2.0 */ - public static final String OPTION_MULTI_ACK_DETAILED = "multi_ack_detailed"; //$NON-NLS-1$ + public static final String OPTION_MULTI_ACK_DETAILED = GitProtocolConstants.OPTION_MULTI_ACK_DETAILED; /** * The client supports packs with deltas but not their bases. * @since 2.0 */ - public static final String OPTION_THIN_PACK = "thin-pack"; //$NON-NLS-1$ + public static final String OPTION_THIN_PACK = GitProtocolConstants.OPTION_THIN_PACK; /** * The client supports using the side-band for progress messages. * @since 2.0 */ - public static final String OPTION_SIDE_BAND = "side-band"; //$NON-NLS-1$ + public static final String OPTION_SIDE_BAND = GitProtocolConstants.OPTION_SIDE_BAND; /** * The client supports using the 64K side-band for progress messages. * @since 2.0 */ - public static final String OPTION_SIDE_BAND_64K = "side-band-64k"; //$NON-NLS-1$ + public static final String OPTION_SIDE_BAND_64K = GitProtocolConstants.OPTION_SIDE_BAND_64K; /** * The client supports packs with OFS deltas. * @since 2.0 */ - public static final String OPTION_OFS_DELTA = "ofs-delta"; //$NON-NLS-1$ + public static final String OPTION_OFS_DELTA = GitProtocolConstants.OPTION_OFS_DELTA; /** * The client supports shallow fetches. * @since 2.0 */ - public static final String OPTION_SHALLOW = "shallow"; //$NON-NLS-1$ + public static final String OPTION_SHALLOW = GitProtocolConstants.OPTION_SHALLOW; /** * The client does not want progress messages and will ignore them. * @since 2.0 */ - public static final String OPTION_NO_PROGRESS = "no-progress"; //$NON-NLS-1$ + public static final String OPTION_NO_PROGRESS = GitProtocolConstants.OPTION_NO_PROGRESS; /** * The client supports receiving a pack before it has sent "done". * @since 2.0 */ - public static final String OPTION_NO_DONE = "no-done"; //$NON-NLS-1$ + public static final String OPTION_NO_DONE = GitProtocolConstants.OPTION_NO_DONE; /** * The client supports fetching objects at the tip of any ref, even if not * advertised. * @since 3.1 */ - public static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = "allow-tip-sha1-in-want"; //$NON-NLS-1$ - - static enum MultiAck { - OFF, CONTINUE, DETAILED; - } + public static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = GitProtocolConstants.OPTION_ALLOW_TIP_SHA1_IN_WANT; private final RevWalk walk; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java index 22b458c92..def6033b8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java @@ -88,25 +88,25 @@ public abstract class BasePackPushConnection extends BasePackConnection implemen * The client expects a status report after the server processes the pack. * @since 2.0 */ - public static final String CAPABILITY_REPORT_STATUS = "report-status"; //$NON-NLS-1$ + public static final String CAPABILITY_REPORT_STATUS = GitProtocolConstants.CAPABILITY_REPORT_STATUS; /** * The server supports deleting refs. * @since 2.0 */ - public static final String CAPABILITY_DELETE_REFS = "delete-refs"; //$NON-NLS-1$ + public static final String CAPABILITY_DELETE_REFS = GitProtocolConstants.CAPABILITY_DELETE_REFS; /** * The server supports packs with OFS deltas. * @since 2.0 */ - public static final String CAPABILITY_OFS_DELTA = "ofs-delta"; //$NON-NLS-1$ + public static final String CAPABILITY_OFS_DELTA = GitProtocolConstants.CAPABILITY_OFS_DELTA; /** * The client supports using the 64K side-band for progress messages. * @since 2.0 */ - public static final String CAPABILITY_SIDE_BAND_64K = "side-band-64k"; //$NON-NLS-1$ + public static final String CAPABILITY_SIDE_BAND_64K = GitProtocolConstants.CAPABILITY_SIDE_BAND_64K; private final boolean thinPack; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java index 1a87049fb..39e4aadc9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java @@ -43,10 +43,10 @@ package org.eclipse.jgit.transport; -import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_DELETE_REFS; -import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_OFS_DELTA; -import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_REPORT_STATUS; -import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_SIDE_BAND_64K; +import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_DELETE_REFS; +import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_OFS_DELTA; +import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_REPORT_STATUS; +import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_SIDE_BAND_64K; import static org.eclipse.jgit.transport.SideBandOutputStream.CH_DATA; import static org.eclipse.jgit.transport.SideBandOutputStream.CH_PROGRESS; import static org.eclipse.jgit.transport.SideBandOutputStream.MAX_BUF; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/GitProtocolConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/GitProtocolConstants.java new file mode 100644 index 000000000..c0a70d043 --- /dev/null +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/GitProtocolConstants.java @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2008-2013, Google Inc. + * Copyright (C) 2008, Robin Rosenberg + * Copyright (C) 2008, Shawn O. Pearce + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * - Neither the name of the Eclipse Foundation, Inc. nor the + * names of its contributors may be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.eclipse.jgit.transport; + +/** + * Wire constants for the native Git protocol. + * + * @since 3.2 + */ +public class GitProtocolConstants { + /** + * Include tags if we are also including the referenced objects. + * + * @since 3.2 + */ + public static final String OPTION_INCLUDE_TAG = "include-tag"; //$NON-NLS-1$ + + /** + * Mutli-ACK support for improved negotiation. + * + * @since 3.2 + */ + public static final String OPTION_MULTI_ACK = "multi_ack"; //$NON-NLS-1$ + + /** + * Mutli-ACK detailed support for improved negotiation. + * + * @since 3.2 + */ + public static final String OPTION_MULTI_ACK_DETAILED = "multi_ack_detailed"; //$NON-NLS-1$ + + /** + * The client supports packs with deltas but not their bases. + * + * @since 3.2 + */ + public static final String OPTION_THIN_PACK = "thin-pack"; //$NON-NLS-1$ + + /** + * The client supports using the side-band for progress messages. + * + * @since 3.2 + */ + public static final String OPTION_SIDE_BAND = "side-band"; //$NON-NLS-1$ + + /** + * The client supports using the 64K side-band for progress messages. + * + * @since 3.2 + */ + public static final String OPTION_SIDE_BAND_64K = "side-band-64k"; //$NON-NLS-1$ + + /** + * The client supports packs with OFS deltas. + * + * @since 3.2 + */ + public static final String OPTION_OFS_DELTA = "ofs-delta"; //$NON-NLS-1$ + + /** + * The client supports shallow fetches. + * + * @since 3.2 + */ + public static final String OPTION_SHALLOW = "shallow"; //$NON-NLS-1$ + + /** + * The client does not want progress messages and will ignore them. + * + * @since 3.2 + */ + public static final String OPTION_NO_PROGRESS = "no-progress"; //$NON-NLS-1$ + + /** + * The client supports receiving a pack before it has sent "done". + * + * @since 3.2 + */ + public static final String OPTION_NO_DONE = "no-done"; //$NON-NLS-1$ + + /** + * The client supports fetching objects at the tip of any ref, even if not + * advertised. + * + * @since 3.2 + */ + public static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = "allow-tip-sha1-in-want"; //$NON-NLS-1$ + + /** + * The client expects a status report after the server processes the pack. + * + * @since 3.2 + */ + public static final String CAPABILITY_REPORT_STATUS = "report-status"; //$NON-NLS-1$ + + /** + * The server supports deleting refs. + * + * @since 3.2 + */ + public static final String CAPABILITY_DELETE_REFS = "delete-refs"; //$NON-NLS-1$ + + /** + * The server supports packs with OFS deltas. + * + * @since 3.2 + */ + public static final String CAPABILITY_OFS_DELTA = "ofs-delta"; //$NON-NLS-1$ + + /** + * The client supports using the 64K side-band for progress messages. + * + * @since 3.2 + */ + public static final String CAPABILITY_SIDE_BAND_64K = "side-band-64k"; //$NON-NLS-1$ + + static enum MultiAck { + OFF, CONTINUE, DETAILED; + } + + private GitProtocolConstants() { + } +} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java index d17abf78c..4d931dd5d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java @@ -43,7 +43,7 @@ package org.eclipse.jgit.transport; -import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_REPORT_STATUS; +import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_REPORT_STATUS; import java.io.IOException; import java.io.InputStream; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java index 28962b7c4..0cc6946b1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -44,6 +44,17 @@ package org.eclipse.jgit.transport; import static org.eclipse.jgit.lib.RefDatabase.ALL; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_ALLOW_TIP_SHA1_IN_WANT; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_INCLUDE_TAG; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_MULTI_ACK; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_MULTI_ACK_DETAILED; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_NO_DONE; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_NO_PROGRESS; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_OFS_DELTA; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_SHALLOW; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_SIDE_BAND; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_SIDE_BAND_64K; +import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_THIN_PACK; import java.io.EOFException; import java.io.IOException; @@ -81,7 +92,7 @@ import org.eclipse.jgit.revwalk.RevTag; import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.revwalk.filter.CommitTimeRevFilter; import org.eclipse.jgit.storage.pack.PackConfig; -import org.eclipse.jgit.transport.BasePackFetchConnection.MultiAck; +import org.eclipse.jgit.transport.GitProtocolConstants.MultiAck; import org.eclipse.jgit.transport.RefAdvertiser.PacketLineOutRefAdvertiser; import org.eclipse.jgit.util.io.InterruptTimer; import org.eclipse.jgit.util.io.NullOutputStream; @@ -92,28 +103,6 @@ import org.eclipse.jgit.util.io.TimeoutOutputStream; * Implements the server side of a fetch connection, transmitting objects. */ public class UploadPack { - static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = BasePackFetchConnection.OPTION_ALLOW_TIP_SHA1_IN_WANT; - - static final String OPTION_INCLUDE_TAG = BasePackFetchConnection.OPTION_INCLUDE_TAG; - - static final String OPTION_MULTI_ACK = BasePackFetchConnection.OPTION_MULTI_ACK; - - static final String OPTION_MULTI_ACK_DETAILED = BasePackFetchConnection.OPTION_MULTI_ACK_DETAILED; - - static final String OPTION_THIN_PACK = BasePackFetchConnection.OPTION_THIN_PACK; - - static final String OPTION_SIDE_BAND = BasePackFetchConnection.OPTION_SIDE_BAND; - - static final String OPTION_SIDE_BAND_64K = BasePackFetchConnection.OPTION_SIDE_BAND_64K; - - static final String OPTION_OFS_DELTA = BasePackFetchConnection.OPTION_OFS_DELTA; - - static final String OPTION_NO_PROGRESS = BasePackFetchConnection.OPTION_NO_PROGRESS; - - static final String OPTION_NO_DONE = BasePackFetchConnection.OPTION_NO_DONE; - - static final String OPTION_SHALLOW = BasePackFetchConnection.OPTION_SHALLOW; - /** Policy the server uses to validate client requests */ public static enum RequestPolicy { /** Client may only ask for objects the server advertised a reference for. */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/MessageWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/MessageWriter.java index 22c3ce94e..a675360da 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/MessageWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/MessageWriter.java @@ -50,13 +50,12 @@ import java.io.OutputStreamWriter; import java.io.Writer; import org.eclipse.jgit.lib.Constants; -import org.eclipse.jgit.transport.BaseConnection; import org.eclipse.jgit.util.RawParseUtils; /** * Combines messages from an OutputStream (hopefully in UTF-8) and a Writer. *

- * This class is primarily meant for {@link BaseConnection} in contexts where a + * This class is primarily meant for {@code BaseConnection} in contexts where a * standard error stream from a command execution, as well as messages from a * side-band channel, need to be combined together into a buffer to represent * the complete set of messages from a remote repository.