Browse Source

Merge changes I85470d1d,I43711486,Ie6ade781,Ic9ab2b6e,Iebe50933,Id6fac253,Ia6becf30,I2af8b0ac

* changes:
  Use absolute paths for file:// URIs in tests
  Use getPath() in FileResolverTest
  Extract protocol constants to a common class
  Move repeat() to utility class for tests
  Remove hardcoded target/trash from test cases
  Remove dependency on StatusCommandTest
  Remove dependency on DiffFormatterReflowTest
  Remove unnecessary import of BaseConnection in MessageWriter
stable-3.2
Shawn Pearce 11 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
b8eac43c0f
  1. 4
      org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java
  2. 6
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java
  3. 2
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java
  4. 2
      org.eclipse.jgit.java7.test/pom.xml
  5. 8
      org.eclipse.jgit.java7.test/src/org/eclipse/jgit/util/FSJava7Test.java
  6. 13
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java
  7. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
  8. 36
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
  9. 12
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java
  10. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
  11. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
  12. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
  13. 56
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/Sets.java
  14. 33
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java
  15. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
  16. 9
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java
  17. 11
      org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java
  18. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java
  19. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java
  20. 7
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java
  21. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java
  22. 12
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java
  23. 55
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/Strings.java
  24. 27
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
  25. 8
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java
  26. 8
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
  27. 166
      org.eclipse.jgit/src/org/eclipse/jgit/transport/GitProtocolConstants.java
  28. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
  29. 35
      org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
  30. 3
      org.eclipse.jgit/src/org/eclipse/jgit/util/io/MessageWriter.java

4
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 { public void shouldCloneAValidGitRepository() throws Exception {
Repository repo = createBareRepository(); Repository repo = createBareRepository();
File directory = repo.getDirectory(); File directory = repo.getDirectory();
task.setUri("file://" + directory); task.setUri("file://" + directory.getAbsolutePath());
task.execute(); task.execute();
assertTrue(RepositoryCache.FileKey.isGitRepository(new File(dest, ".git"), FS.DETECTED)); assertTrue(RepositoryCache.FileKey.isGitRepository(new File(dest, ".git"), FS.DETECTED));
@ -111,7 +111,7 @@ public class GitCloneTaskTest extends LocalDiskRepositoryTestCase {
public void shouldCreateABareCloneOfAValidGitRepository() throws Exception { public void shouldCreateABareCloneOfAValidGitRepository() throws Exception {
Repository repo = createBareRepository(); Repository repo = createBareRepository();
File directory = repo.getDirectory(); File directory = repo.getDirectory();
task.setUri("file://" + directory); task.setUri("file://" + directory.getAbsolutePath());
task.setBare(true); task.setBare(true);
task.execute(); task.execute();

6
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java

@ -44,9 +44,9 @@
package org.eclipse.jgit.http.server; package org.eclipse.jgit.http.server;
import static org.eclipse.jgit.http.server.ServletUtils.ATTRIBUTE_HANDLER; 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.GitProtocolConstants.OPTION_SIDE_BAND;
import static org.eclipse.jgit.transport.BasePackFetchConnection.OPTION_SIDE_BAND_64K; import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_SIDE_BAND_64K;
import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_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.CH_ERROR;
import static org.eclipse.jgit.transport.SideBandOutputStream.SMALL_BUF; import static org.eclipse.jgit.transport.SideBandOutputStream.SMALL_BUF;
import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN; import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;

2
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(); Throwable why = e.getCause();
assertNotNull("has cause", why); assertNotNull("has cause", why);
assertEquals("repository not found: " assertEquals("repository not found: "
+ new File(base, name).getAbsolutePath(), why.getMessage()); + new File(base, name).getPath(), why.getMessage());
} }
} }
} }

2
org.eclipse.jgit.java7.test/pom.xml

@ -118,7 +118,7 @@
<plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <configuration>
<argLine>-Xmx256m -Dfile.encoding=UTF-8</argLine> <argLine>-Xmx256m -Dfile.encoding=UTF-8 -Djava.io.tmpdir=${project.build.directory}</argLine>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

8
org.eclipse.jgit.java7.test/src/org/eclipse/jgit/util/FSJava7Test.java

@ -58,13 +58,13 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class FSJava7Test { public class FSJava7Test {
private File trash;
private final File trash = new File(new File("target"), "trash");
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
FileUtils.delete(trash, FileUtils.RECURSIVE | FileUtils.RETRY | FileUtils.SKIP_MISSING); trash = File.createTempFile("tmp_", "");
assertTrue(trash.mkdirs()); trash.delete();
assertTrue("mkdir " + trash, trash.mkdir());
} }
@After @After

13
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.PatchApplyException;
import org.eclipse.jgit.api.errors.PatchFormatException; import org.eclipse.jgit.api.errors.PatchFormatException;
import org.eclipse.jgit.diff.DiffFormatterReflowTest;
import org.eclipse.jgit.diff.RawText; import org.eclipse.jgit.diff.RawText;
import org.eclipse.jgit.junit.RepositoryTestCase; import org.eclipse.jgit.junit.RepositoryTestCase;
import org.junit.Test; import org.junit.Test;
@ -86,9 +85,7 @@ public class ApplyCommandTest extends RepositoryTestCase {
return git return git
.apply() .apply()
.setPatch( .setPatch(getTestResource(name + ".patch")).call();
DiffFormatterReflowTest.class.getResourceAsStream(name
+ ".patch")).call();
} }
@Test @Test
@ -189,8 +186,7 @@ public class ApplyCommandTest extends RepositoryTestCase {
} }
private static byte[] readFile(final String patchFile) throws IOException { private static byte[] readFile(final String patchFile) throws IOException {
final InputStream in = DiffFormatterReflowTest.class final InputStream in = getTestResource(patchFile);
.getResourceAsStream(patchFile);
if (in == null) { if (in == null) {
fail("No " + patchFile + " test vector"); fail("No " + patchFile + " test vector");
return null; // Never happens return null; // Never happens
@ -206,4 +202,9 @@ public class ApplyCommandTest extends RepositoryTestCase {
in.close(); in.close();
} }
} }
private static InputStream getTestResource(final String patchFile) {
return ApplyCommandTest.class.getClassLoader()
.getResourceAsStream("org/eclipse/jgit/diff/" + patchFile);
}
} }

2
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); Git localGit = new Git(localRepository);
StoredConfig config = localRepository.getConfig(); StoredConfig config = localRepository.getConfig();
RemoteConfig rc = new RemoteConfig(config, "origin"); 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.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
rc.update(config); rc.update(config);
config.save(); config.save();

36
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java

@ -110,7 +110,7 @@ public class CloneCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testCloneRepository"); File directory = createTempDirectory("testCloneRepository");
CloneCommand command = Git.cloneRepository(); CloneCommand command = Git.cloneRepository();
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
Git git2 = command.call(); Git git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
assertNotNull(git2); assertNotNull(git2);
@ -142,7 +142,7 @@ public class CloneCommandTest extends RepositoryTestCase {
CloneCommand command = Git.cloneRepository(); CloneCommand command = Git.cloneRepository();
command.setBare(true); command.setBare(true);
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
Git git2 = command.call(); Git git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
assertEquals(new RefSpec("+refs/heads/*:refs/heads/*"), assertEquals(new RefSpec("+refs/heads/*:refs/heads/*"),
@ -162,7 +162,7 @@ public class CloneCommandTest extends RepositoryTestCase {
CloneCommand command = Git.cloneRepository(); CloneCommand command = Git.cloneRepository();
command.setBranch("refs/heads/master"); command.setBranch("refs/heads/master");
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
Git git2 = command.call(); Git git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
@ -177,7 +177,7 @@ public class CloneCommandTest extends RepositoryTestCase {
command = Git.cloneRepository(); command = Git.cloneRepository();
command.setBranch("refs/heads/master"); command.setBranch("refs/heads/master");
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
command.setNoCheckout(true); command.setNoCheckout(true);
git2 = command.call(); git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
@ -192,7 +192,7 @@ public class CloneCommandTest extends RepositoryTestCase {
command = Git.cloneRepository(); command = Git.cloneRepository();
command.setBranch("refs/heads/master"); command.setBranch("refs/heads/master");
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
command.setBare(true); command.setBare(true);
git2 = command.call(); git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
@ -209,7 +209,7 @@ public class CloneCommandTest extends RepositoryTestCase {
CloneCommand command = Git.cloneRepository(); CloneCommand command = Git.cloneRepository();
command.setBranch("test"); command.setBranch("test");
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
Git git2 = command.call(); Git git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
@ -223,7 +223,7 @@ public class CloneCommandTest extends RepositoryTestCase {
CloneCommand command = Git.cloneRepository(); CloneCommand command = Git.cloneRepository();
command.setBranch("tag-initial"); command.setBranch("tag-initial");
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
Git git2 = command.call(); Git git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
@ -242,7 +242,7 @@ public class CloneCommandTest extends RepositoryTestCase {
command.setBranchesToClone(Collections command.setBranchesToClone(Collections
.singletonList("refs/heads/master")); .singletonList("refs/heads/master"));
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
Git git2 = command.call(); Git git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
assertNotNull(git2); assertNotNull(git2);
@ -257,7 +257,7 @@ public class CloneCommandTest extends RepositoryTestCase {
command.setBranchesToClone(Collections command.setBranchesToClone(Collections
.singletonList("refs/heads/master")); .singletonList("refs/heads/master"));
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
command.setBare(true); command.setBare(true);
git2 = command.call(); git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
@ -284,14 +284,14 @@ public class CloneCommandTest extends RepositoryTestCase {
File directory = createTempDirectory(dirName); File directory = createTempDirectory(dirName);
CloneCommand command = Git.cloneRepository(); CloneCommand command = Git.cloneRepository();
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
Git git2 = command.call(); Git git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
assertNotNull(git2); assertNotNull(git2);
// clone again // clone again
command = Git.cloneRepository(); command = Git.cloneRepository();
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
try { try {
git2 = command.call(); git2 = command.call();
// we shouldn't get here // we shouldn't get here
@ -310,7 +310,7 @@ public class CloneCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testCloneRepositoryWithMultipleHeadBranches"); File directory = createTempDirectory("testCloneRepositoryWithMultipleHeadBranches");
CloneCommand clone = Git.cloneRepository(); CloneCommand clone = Git.cloneRepository();
clone.setDirectory(directory); clone.setDirectory(directory);
clone.setURI("file://" + git.getRepository().getWorkTree().getPath()); clone.setURI(fileUri());
Git git2 = clone.call(); Git git2 = clone.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
assertNotNull(git2); assertNotNull(git2);
@ -343,7 +343,7 @@ public class CloneCommandTest extends RepositoryTestCase {
CloneCommand clone = Git.cloneRepository(); CloneCommand clone = Git.cloneRepository();
clone.setDirectory(directory); clone.setDirectory(directory);
clone.setCloneSubmodules(true); clone.setCloneSubmodules(true);
clone.setURI("file://" + git.getRepository().getWorkTree().getPath()); clone.setURI(fileUri());
Git git2 = clone.call(); Git git2 = clone.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
assertNotNull(git2); assertNotNull(git2);
@ -458,7 +458,7 @@ public class CloneCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testCloneRepository1"); File directory = createTempDirectory("testCloneRepository1");
CloneCommand command = Git.cloneRepository(); CloneCommand command = Git.cloneRepository();
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
Git git2 = command.call(); Git git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
assertFalse(git2 assertFalse(git2
@ -476,7 +476,7 @@ public class CloneCommandTest extends RepositoryTestCase {
directory = createTempDirectory("testCloneRepository2"); directory = createTempDirectory("testCloneRepository2");
command = Git.cloneRepository(); command = Git.cloneRepository();
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
git2 = command.call(); git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
assertTrue(git2 assertTrue(git2
@ -492,7 +492,7 @@ public class CloneCommandTest extends RepositoryTestCase {
directory = createTempDirectory("testCloneRepository2"); directory = createTempDirectory("testCloneRepository2");
command = Git.cloneRepository(); command = Git.cloneRepository();
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
git2 = command.call(); git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
assertTrue(git2 assertTrue(git2
@ -502,4 +502,8 @@ public class CloneCommandTest extends RepositoryTestCase {
ConfigConstants.CONFIG_KEY_REBASE, false)); ConfigConstants.CONFIG_KEY_REBASE, false));
} }
private String fileUri() {
return "file://" + git.getRepository().getWorkTree().getAbsolutePath();
}
} }

12
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java

@ -82,7 +82,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testRepository"); File directory = createTempDirectory("testRepository");
CloneCommand command = Git.cloneRepository(); CloneCommand command = Git.cloneRepository();
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
command.setCloneAllBranches(true); command.setCloneAllBranches(true);
Git git2 = command.call(); Git git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
@ -99,7 +99,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testRepository"); File directory = createTempDirectory("testRepository");
CloneCommand command = Git.cloneRepository(); CloneCommand command = Git.cloneRepository();
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
command.setCloneAllBranches(true); command.setCloneAllBranches(true);
Git git2 = command.call(); Git git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
@ -116,7 +116,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testRepository"); File directory = createTempDirectory("testRepository");
CloneCommand command = Git.cloneRepository(); CloneCommand command = Git.cloneRepository();
command.setDirectory(directory); command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath()); command.setURI(fileUri());
command.setCloneAllBranches(true); command.setCloneAllBranches(true);
Git git2 = command.call(); Git git2 = command.call();
addRepoToClose(git2.getRepository()); addRepoToClose(git2.getRepository());
@ -130,10 +130,14 @@ public class LsRemoteCommandTest extends RepositoryTestCase {
@Test @Test
public void testLsRemoteWithoutLocalRepository() throws Exception { public void testLsRemoteWithoutLocalRepository() throws Exception {
String uri = "file://" + git.getRepository().getWorkTree().getPath(); String uri = fileUri();
Collection<Ref> refs = Git.lsRemoteRepository().setRemote(uri).setHeads(true).call(); Collection<Ref> refs = Git.lsRemoteRepository().setRemote(uri).setHeads(true).call();
assertNotNull(refs); assertNotNull(refs);
assertEquals(2, refs.size()); assertEquals(2, refs.size());
} }
private String fileUri() {
return "file://" + git.getRepository().getWorkTree().getAbsolutePath();
}
} }

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java

@ -1340,7 +1340,7 @@ public class MergeCommandTest extends RepositoryTestCase {
assertNull(db.readMergeCommitMsg()); assertNull(db.readMergeCommitMsg());
Status stat = git.status().call(); Status stat = git.status().call();
assertEquals(StatusCommandTest.set("file2", "file3"), stat.getAdded()); assertEquals(Sets.of("file2", "file3"), stat.getAdded());
} }
@Test @Test
@ -1396,7 +1396,7 @@ public class MergeCommandTest extends RepositoryTestCase {
assertNull(db.readMergeCommitMsg()); assertNull(db.readMergeCommitMsg());
Status stat = git.status().call(); Status stat = git.status().call();
assertEquals(StatusCommandTest.set("file3"), stat.getAdded()); assertEquals(Sets.of("file3"), stat.getAdded());
} }
@Test @Test
@ -1450,7 +1450,7 @@ public class MergeCommandTest extends RepositoryTestCase {
assertEquals("\nConflicts:\n\tfile2\n", db.readMergeCommitMsg()); assertEquals("\nConflicts:\n\tfile2\n", db.readMergeCommitMsg());
Status stat = git.status().call(); Status stat = git.status().call();
assertEquals(StatusCommandTest.set("file2"), stat.getConflicting()); assertEquals(Sets.of("file2"), stat.getConflicting());
} }
@Test @Test

5
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]); assertEquals(sourceCommit.getId(), mergedCommits[1]);
RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult
.getNewHead()); .getNewHead());
String message = "Merge branch 'master' of " + db.getWorkTree(); String message = "Merge branch 'master' of "
+ db.getWorkTree().getAbsolutePath();
assertEquals(message, mergeCommit.getShortMessage()); assertEquals(message, mergeCommit.getShortMessage());
} }
@ -255,7 +256,7 @@ public class PullCommandTest extends RepositoryTestCase {
config config
.addURI(new URIish(source.getRepository().getWorkTree() .addURI(new URIish(source.getRepository().getWorkTree()
.getPath())); .getAbsolutePath()));
config.addFetchRefSpec(new RefSpec( config.addFetchRefSpec(new RefSpec(
"+refs/heads/*:refs/remotes/origin/*")); "+refs/heads/*:refs/remotes/origin/*"));
config.update(targetConfig); config.update(targetConfig);

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java

@ -319,7 +319,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase {
config config
.addURI(new URIish(source.getRepository().getWorkTree() .addURI(new URIish(source.getRepository().getWorkTree()
.getPath())); .getAbsolutePath()));
config.addFetchRefSpec(new RefSpec( config.addFetchRefSpec(new RefSpec(
"+refs/heads/*:refs/remotes/origin/*")); "+refs/heads/*:refs/remotes/origin/*"));
config.update(targetConfig); config.update(targetConfig);

56
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/Sets.java

@ -0,0 +1,56 @@
/*
* Copyright (C) 2011, Christian Halstrick <christian.halstrick@sap.com>
* 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 <T> Set<T> of(T... elements) {
Set<T> ret = new HashSet<T>();
for (T element : elements)
ret.add(element);
return ret;
}
}

33
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.File;
import java.io.IOException; 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.GitAPIException;
import org.eclipse.jgit.api.errors.NoFilepatternException; import org.eclipse.jgit.api.errors.NoFilepatternException;
@ -82,12 +80,12 @@ public class StatusCommandTest extends RepositoryTestCase {
writeTrashFile("c", "content of c"); writeTrashFile("c", "content of c");
git.add().addFilepattern("a").addFilepattern("b").call(); git.add().addFilepattern("a").addFilepattern("b").call();
Status stat = git.status().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.getChanged().size());
assertEquals(0, stat.getMissing().size()); assertEquals(0, stat.getMissing().size());
assertEquals(0, stat.getModified().size()); assertEquals(0, stat.getModified().size());
assertEquals(0, stat.getRemoved().size()); assertEquals(0, stat.getRemoved().size());
assertEquals(set("c"), stat.getUntracked()); assertEquals(Sets.of("c"), stat.getUntracked());
git.commit().setMessage("initial").call(); git.commit().setMessage("initial").call();
writeTrashFile("a", "modified content of a"); writeTrashFile("a", "modified content of a");
@ -96,12 +94,12 @@ public class StatusCommandTest extends RepositoryTestCase {
git.add().addFilepattern("a").addFilepattern("d").call(); git.add().addFilepattern("a").addFilepattern("d").call();
writeTrashFile("a", "again modified content of a"); writeTrashFile("a", "again modified content of a");
stat = git.status().call(); stat = git.status().call();
assertEquals(set("d"), stat.getAdded()); assertEquals(Sets.of("d"), stat.getAdded());
assertEquals(set("a"), stat.getChanged()); assertEquals(Sets.of("a"), stat.getChanged());
assertEquals(0, stat.getMissing().size()); assertEquals(0, stat.getMissing().size());
assertEquals(set("b", "a"), stat.getModified()); assertEquals(Sets.of("b", "a"), stat.getModified());
assertEquals(0, stat.getRemoved().size()); assertEquals(0, stat.getRemoved().size());
assertEquals(set("c"), stat.getUntracked()); assertEquals(Sets.of("c"), stat.getUntracked());
git.add().addFilepattern(".").call(); git.add().addFilepattern(".").call();
git.commit().setMessage("second").call(); git.commit().setMessage("second").call();
@ -122,8 +120,8 @@ public class StatusCommandTest extends RepositoryTestCase {
assertEquals(0, stat.getChanged().size()); assertEquals(0, stat.getChanged().size());
assertEquals(0, stat.getMissing().size()); assertEquals(0, stat.getMissing().size());
assertEquals(0, stat.getModified().size()); assertEquals(0, stat.getModified().size());
assertEquals(set("a"), stat.getRemoved()); assertEquals(Sets.of("a"), stat.getRemoved());
assertEquals(set("a"), stat.getUntracked()); assertEquals(Sets.of("a"), stat.getUntracked());
git.commit().setMessage("t").call(); git.commit().setMessage("t").call();
writeTrashFile("sub/a", "sub-file"); writeTrashFile("sub/a", "sub-file");
@ -153,25 +151,18 @@ public class StatusCommandTest extends RepositoryTestCase {
// filter on an existing file // filter on an existing file
stat = git.status().addPath("a").call(); stat = git.status().addPath("a").call();
assertEquals(set("a"), stat.getModified()); assertEquals(Sets.of("a"), stat.getModified());
// filter on an existing folder // filter on an existing folder
stat = git.status().addPath("D").call(); 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 // filter on an existing folder and file
stat = git.status().addPath("D/D").addPath("a").call(); 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 // do not filter at all
stat = git.status().call(); stat = git.status().call();
assertEquals(set("a", "D/b", "D/D/d"), stat.getModified()); assertEquals(Sets.of("a", "D/b", "D/D/d"), stat.getModified());
}
public static Set<String> set(String... elements) {
Set<String> ret = new HashSet<String>();
for (String element : elements)
ret.add(element);
return ret;
} }
} }

6
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); builder.setMustExist(true);
Repository repo2 = builder.build(); Repository repo2 = builder.build();
assertEquals(repo1.getDirectory(), repo2.getDirectory()); assertEquals(repo1.getDirectory().getAbsolutePath(), repo2
.getDirectory().getAbsolutePath());
assertEquals(dir, repo2.getWorkTree()); assertEquals(dir, repo2.getWorkTree());
} }
@ -167,7 +168,8 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
builder.setWorkTree(dir); builder.setWorkTree(dir);
builder.findGitDir(dir); builder.findGitDir(dir);
assertEquals(repo1.getDirectory(), builder.getGitDir()); assertEquals(repo1.getDirectory().getAbsolutePath(), builder
.getGitDir().getAbsolutePath());
builder.setMustExist(true); builder.setMustExist(true);
Repository repo2 = builder.build(); Repository repo2 = builder.build();

9
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java

@ -61,7 +61,14 @@ public class FileSnapshotTest {
private List<File> files = new ArrayList<File>(); private List<File> files = new ArrayList<File>();
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 @Before
@After @After

11
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.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; 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.FileUtils;
import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.IO;
import org.junit.After; import org.junit.After;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class FileBasedConfigTest { public class FileBasedConfigTest {
@ -73,7 +75,14 @@ public class FileBasedConfigTest {
private static final String CONTENT2 = "[" + USER + "]\n\t" + NAME + " = " private static final String CONTENT2 = "[" + USER + "]\n\t" + NAME + " = "
+ BOB + "\n"; + 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 @After
public void tearDown() throws Exception { public void tearDown() throws Exception {

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java

@ -171,8 +171,10 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
Repository subRepo = gen.getRepository(); Repository subRepo = gen.getRepository();
addRepoToClose(subRepo); addRepoToClose(subRepo);
assertNotNull(subRepo); assertNotNull(subRepo);
assertEquals(modulesGitDir, subRepo.getDirectory()); assertEquals(modulesGitDir.getAbsolutePath(),
assertEquals(new File(db.getWorkTree(), path), subRepo.getWorkTree()); subRepo.getDirectory().getAbsolutePath());
assertEquals(new File(db.getWorkTree(), path).getAbsolutePath(),
subRepo.getWorkTree().getAbsolutePath());
assertFalse(gen.next()); assertFalse(gen.next());
} }

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java

@ -231,7 +231,7 @@ public class TransportTest extends SampleDataRepositoryTestCase {
@Test @Test
public void testLocalTransportFetchWithoutLocalRepository() public void testLocalTransportFetchWithoutLocalRepository()
throws Exception { throws Exception {
URIish uri = new URIish("file://" + db.getWorkTree().getPath()); URIish uri = new URIish("file://" + db.getWorkTree().getAbsolutePath());
transport = Transport.open(uri); transport = Transport.open(uri);
FetchConnection fetchConnection = transport.openFetch(); FetchConnection fetchConnection = transport.openFetch();
try { try {

7
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java

@ -57,12 +57,13 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class FileUtilTest { public class FileUtilTest {
private File trash;
private final File trash = new File(new File("target"), "trash");
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
assertTrue(trash.mkdirs()); trash = File.createTempFile("tmp_", "");
trash.delete();
assertTrue("mkdir " + trash, trash.mkdir());
} }
@After @After

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java

@ -70,9 +70,9 @@ public class AutoCRLFInputStreamTest {
@Test @Test
public void testBoundary() throws IOException { public void testBoundary() throws IOException {
for (int i = AutoCRLFInputStream.BUFFER_SIZE - 10; i < AutoCRLFInputStream.BUFFER_SIZE + 10; i++) { 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); assertNoCrLf(s1, s1);
String s2 = AutoCRLFOutputStreamTest.repeat("\0", i); String s2 = Strings.repeat("\0", i);
assertNoCrLf(s2, s2); assertNoCrLf(s2, s2);
} }
} }

12
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java

@ -72,21 +72,13 @@ public class AutoCRLFOutputStreamTest {
@Test @Test
public void testBoundary() throws IOException { public void testBoundary() throws IOException {
for (int i = AutoCRLFOutputStream.BUFFER_SIZE - 10; i < AutoCRLFOutputStream.BUFFER_SIZE + 10; i++) { 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); assertNoCrLf(s1, s1);
String s2 = repeat("\0", i); String s2 = Strings.repeat("\0", i);
assertNoCrLf(s2, s2); 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 { private void assertNoCrLf(String string, String string2) throws IOException {
assertNoCrLfHelper(string, string2); assertNoCrLfHelper(string, string2);
// \u00e5 = LATIN SMALL LETTER A WITH RING ABOVE // \u00e5 = LATIN SMALL LETTER A WITH RING ABOVE

55
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;
}
}

27
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.ObjectInserter;
import org.eclipse.jgit.lib.ProgressMonitor; import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.transport.GitProtocolConstants.MultiAck;
import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevCommitList; import org.eclipse.jgit.revwalk.RevCommitList;
import org.eclipse.jgit.revwalk.RevFlag; 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. * Include tags if we are also including the referenced objects.
* @since 2.0 * @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. * Mutli-ACK support for improved negotiation.
* @since 2.0 * @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. * Mutli-ACK detailed support for improved negotiation.
* @since 2.0 * @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. * The client supports packs with deltas but not their bases.
* @since 2.0 * @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. * The client supports using the side-band for progress messages.
* @since 2.0 * @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. * The client supports using the 64K side-band for progress messages.
* @since 2.0 * @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. * The client supports packs with OFS deltas.
* @since 2.0 * @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. * The client supports shallow fetches.
* @since 2.0 * @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. * The client does not want progress messages and will ignore them.
* @since 2.0 * @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". * The client supports receiving a pack before it has sent "done".
* @since 2.0 * @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 * The client supports fetching objects at the tip of any ref, even if not
* advertised. * advertised.
* @since 3.1 * @since 3.1
*/ */
public static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = "allow-tip-sha1-in-want"; //$NON-NLS-1$ public static final String OPTION_ALLOW_TIP_SHA1_IN_WANT = GitProtocolConstants.OPTION_ALLOW_TIP_SHA1_IN_WANT;
static enum MultiAck {
OFF, CONTINUE, DETAILED;
}
private final RevWalk walk; private final RevWalk walk;

8
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. * The client expects a status report after the server processes the pack.
* @since 2.0 * @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. * The server supports deleting refs.
* @since 2.0 * @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. * The server supports packs with OFS deltas.
* @since 2.0 * @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. * The client supports using the 64K side-band for progress messages.
* @since 2.0 * @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; private final boolean thinPack;

8
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java

@ -43,10 +43,10 @@
package org.eclipse.jgit.transport; package org.eclipse.jgit.transport;
import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_DELETE_REFS; import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_DELETE_REFS;
import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_OFS_DELTA; import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_OFS_DELTA;
import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_REPORT_STATUS; import static org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_REPORT_STATUS;
import static org.eclipse.jgit.transport.BasePackPushConnection.CAPABILITY_SIDE_BAND_64K; 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_DATA;
import static org.eclipse.jgit.transport.SideBandOutputStream.CH_PROGRESS; import static org.eclipse.jgit.transport.SideBandOutputStream.CH_PROGRESS;
import static org.eclipse.jgit.transport.SideBandOutputStream.MAX_BUF; import static org.eclipse.jgit.transport.SideBandOutputStream.MAX_BUF;

166
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 <robin.rosenberg@dewire.com>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
* 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() {
}
}

2
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

@ -43,7 +43,7 @@
package org.eclipse.jgit.transport; 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.IOException;
import java.io.InputStream; import java.io.InputStream;

35
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

@ -44,6 +44,17 @@
package org.eclipse.jgit.transport; package org.eclipse.jgit.transport;
import static org.eclipse.jgit.lib.RefDatabase.ALL; 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.EOFException;
import java.io.IOException; 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.RevWalk;
import org.eclipse.jgit.revwalk.filter.CommitTimeRevFilter; import org.eclipse.jgit.revwalk.filter.CommitTimeRevFilter;
import org.eclipse.jgit.storage.pack.PackConfig; 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.transport.RefAdvertiser.PacketLineOutRefAdvertiser;
import org.eclipse.jgit.util.io.InterruptTimer; import org.eclipse.jgit.util.io.InterruptTimer;
import org.eclipse.jgit.util.io.NullOutputStream; 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. * Implements the server side of a fetch connection, transmitting objects.
*/ */
public class UploadPack { 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 */ /** Policy the server uses to validate client requests */
public static enum RequestPolicy { public static enum RequestPolicy {
/** Client may only ask for objects the server advertised a reference for. */ /** Client may only ask for objects the server advertised a reference for. */

3
org.eclipse.jgit/src/org/eclipse/jgit/util/io/MessageWriter.java

@ -50,13 +50,12 @@ import java.io.OutputStreamWriter;
import java.io.Writer; import java.io.Writer;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.transport.BaseConnection;
import org.eclipse.jgit.util.RawParseUtils; import org.eclipse.jgit.util.RawParseUtils;
/** /**
* Combines messages from an OutputStream (hopefully in UTF-8) and a Writer. * Combines messages from an OutputStream (hopefully in UTF-8) and a Writer.
* <p> * <p>
* 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 * 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 * side-band channel, need to be combined together into a buffer to represent
* the complete set of messages from a remote repository. * the complete set of messages from a remote repository.

Loading…
Cancel
Save