diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java index 51de8abd0..1c5e7ec59 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitFilter.java @@ -248,13 +248,13 @@ public class GitFilter extends MetaFilter { .through(enabled)// .with(new TextFileServlet(Constants.HEAD)); - final String info_alternates = "objects/info/alternates"; + final String info_alternates = Constants.OBJECTS + "/" + Constants.INFO_ALTERNATES; serve("*/" + info_alternates)// .through(mustBeLocal)// .through(enabled)// .with(new TextFileServlet(info_alternates)); - final String http_alternates = "objects/info/http-alternates"; + final String http_alternates = Constants.OBJECTS + "/" + Constants.INFO_HTTP_ALTERNATES; serve("*/" + http_alternates)// .through(mustBeLocal)// .through(enabled)// diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/Lfs.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/Lfs.java index 4c46bbd23..8dba09cb5 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/Lfs.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/Lfs.java @@ -42,6 +42,8 @@ */ package org.eclipse.jgit.lfs; +import static org.eclipse.jgit.lib.Constants.OBJECTS; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -104,7 +106,7 @@ public class Lfs { */ public Path getLfsObjDir() { if (objDir == null) { - objDir = root.resolve("objects"); //$NON-NLS-1$ + objDir = root.resolve(OBJECTS); } return objDir; } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/AlternatesTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/AlternatesTest.java index b09db03ea..2306e0bbb 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/AlternatesTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/AlternatesTest.java @@ -42,6 +42,7 @@ */ package org.eclipse.jgit.internal.storage.file; +import static org.eclipse.jgit.lib.Constants.INFO_ALTERNATES; import static org.junit.Assert.assertTrue; import java.io.File; @@ -76,7 +77,7 @@ public class AlternatesTest extends SampleDataRepositoryTestCase { private void setAlternate(FileRepository from, FileRepository to) throws IOException { File alt = new File(from.getObjectDatabase().getDirectory(), - "info/alternates"); + INFO_ALTERNATES); alt.getParentFile().mkdirs(); File fromDir = from.getObjectDatabase().getDirectory(); File toDir = to.getObjectDatabase().getDirectory(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java index 5d0a7e2a0..1e2341b6a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.internal.storage.file; import static org.eclipse.jgit.internal.storage.pack.PackWriter.NONE; +import static org.eclipse.jgit.lib.Constants.INFO_ALTERNATES; import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -138,7 +139,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { config = new PackConfig(db); dst = createBareRepository(); - File alt = new File(dst.getObjectDatabase().getDirectory(), "info/alternates"); + File alt = new File(dst.getObjectDatabase().getDirectory(), INFO_ALTERNATES); alt.getParentFile().mkdirs(); write(alt, db.getObjectDatabase().getDirectory().getAbsolutePath() + "\n"); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java index c6138495f..825d15b18 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java @@ -96,7 +96,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { public void test001_Initalize() { final File gitdir = new File(trash, Constants.DOT_GIT); final File hooks = new File(gitdir, "hooks"); - final File objects = new File(gitdir, "objects"); + final File objects = new File(gitdir, Constants.OBJECTS); final File objects_pack = new File(objects, "pack"); final File objects_info = new File(objects, "info"); final File refs = new File(gitdir, "refs"); @@ -148,7 +148,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { assertEqualsPath(theDir, r.getDirectory()); assertEqualsPath(repo1Parent, r.getWorkTree()); assertEqualsPath(new File(theDir, "index"), r.getIndexFile()); - assertEqualsPath(new File(theDir, "objects"), r.getObjectDatabase() + assertEqualsPath(new File(theDir, Constants.OBJECTS), r.getObjectDatabase() .getDirectory()); } @@ -174,7 +174,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { assertEqualsPath(theDir, r.getDirectory()); assertEqualsPath(repo1Parent.getParentFile(), r.getWorkTree()); assertEqualsPath(new File(theDir, "index"), r.getIndexFile()); - assertEqualsPath(new File(theDir, "objects"), r.getObjectDatabase() + assertEqualsPath(new File(theDir, Constants.OBJECTS), r.getObjectDatabase() .getDirectory()); } @@ -198,7 +198,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { assertEqualsPath(theDir, r.getDirectory()); assertEqualsPath(repo1Parent, r.getWorkTree()); assertEqualsPath(new File(theDir, "index"), r.getIndexFile()); - assertEqualsPath(new File(theDir, "objects"), r.getObjectDatabase() + assertEqualsPath(new File(theDir, Constants.OBJECTS), r.getObjectDatabase() .getDirectory()); } @@ -227,7 +227,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { assertEqualsPath(theDir, r.getDirectory()); assertEqualsPath(workdir, r.getWorkTree()); assertEqualsPath(new File(theDir, "index"), r.getIndexFile()); - assertEqualsPath(new File(theDir, "objects"), r.getObjectDatabase() + assertEqualsPath(new File(theDir, Constants.OBJECTS), r.getObjectDatabase() .getDirectory()); } @@ -256,7 +256,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { assertEqualsPath(theDir, r.getDirectory()); assertEqualsPath(workdir, r.getWorkTree()); assertEqualsPath(new File(theDir, "index"), r.getIndexFile()); - assertEqualsPath(new File(theDir, "objects"), r.getObjectDatabase() + assertEqualsPath(new File(theDir, Constants.OBJECTS), r.getObjectDatabase() .getDirectory()); } @@ -312,7 +312,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { } final File o = new File(new File(new File(newdb.getDirectory(), - "objects"), "4b"), "825dc642cb6eb9a060e54bf8d69288fbee4904"); + Constants.OBJECTS), "4b"), "825dc642cb6eb9a060e54bf8d69288fbee4904"); assertTrue("Exists " + o, o.isFile()); assertTrue("Read-only " + o, !o.canWrite()); } @@ -324,7 +324,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { final ObjectId treeId = insertTree(new TreeFormatter()); assertEquals("4b825dc642cb6eb9a060e54bf8d69288fbee4904", treeId.name()); final File o = new File(new File( - new File(db.getDirectory(), "objects"), "4b"), + new File(db.getDirectory(), Constants.OBJECTS), "4b"), "825dc642cb6eb9a060e54bf8d69288fbee4904"); assertFalse("Exists " + o, o.isFile()); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java index 258cceebe..968ade670 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java @@ -171,7 +171,7 @@ public class ObjectDirectory extends FileObjectDatabase { infoDirectory = new File(objects, "info"); //$NON-NLS-1$ packDirectory = new File(objects, "pack"); //$NON-NLS-1$ preservedDirectory = new File(packDirectory, "preserved"); //$NON-NLS-1$ - alternatesFile = new File(infoDirectory, "alternates"); //$NON-NLS-1$ + alternatesFile = new File(objects, Constants.INFO_ALTERNATES); packList = new AtomicReference<>(NO_PACKS); unpackedObjectCache = new UnpackedObjectCache(); this.fs = fs; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java index d1cf1cd9a..96e50667b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java @@ -681,7 +681,7 @@ public class BaseRepositoryBuilder getAlternates() throws IOException { try { - return readAlternates(INFO_ALTERNATES); + return readAlternates(Constants.INFO_ALTERNATES); } catch (FileNotFoundException err) { // Fall through. } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java index 27ab87951..d5b06c1f6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java @@ -48,6 +48,8 @@ package org.eclipse.jgit.transport; import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.lib.Constants.HEAD; +import static org.eclipse.jgit.lib.Constants.INFO_ALTERNATES; +import static org.eclipse.jgit.lib.Constants.INFO_HTTP_ALTERNATES; import static org.eclipse.jgit.util.HttpSupport.ENCODING_GZIP; import static org.eclipse.jgit.util.HttpSupport.ENCODING_X_GZIP; import static org.eclipse.jgit.util.HttpSupport.HDR_ACCEPT; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportSftp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportSftp.java index 5c68308f9..8d91c6098 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportSftp.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportSftp.java @@ -43,7 +43,9 @@ package org.eclipse.jgit.transport; +import static org.eclipse.jgit.lib.Constants.INFO_ALTERNATES; import static org.eclipse.jgit.lib.Constants.LOCK_SUFFIX; +import static org.eclipse.jgit.lib.Constants.OBJECTS; import java.io.BufferedReader; import java.io.FileNotFoundException; @@ -172,7 +174,7 @@ public class TransportSftp extends SshTransport implements WalkTransport { try { ftp = newSftp(); ftp.cd(path); - ftp.cd("objects"); //$NON-NLS-1$ + ftp.cd(OBJECTS); objectsPath = ftp.pwd(); } catch (FtpChannel.FtpException f) { throw new TransportException(MessageFormat.format( diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkRemoteObjectDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkRemoteObjectDatabase.java index 5c67253cf..4862d676e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkRemoteObjectDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkRemoteObjectDatabase.java @@ -82,10 +82,6 @@ abstract class WalkRemoteObjectDatabase { static final String INFO_PACKS = "info/packs"; //$NON-NLS-1$ - static final String INFO_ALTERNATES = "info/alternates"; //$NON-NLS-1$ - - static final String INFO_HTTP_ALTERNATES = "info/http-alternates"; //$NON-NLS-1$ - static final String INFO_REFS = ROOT_DIR + Constants.INFO_REFS; abstract URIish getURI(); @@ -107,8 +103,10 @@ abstract class WalkRemoteObjectDatabase { /** * Obtain alternate connections to alternate object databases (if any). *

- * Alternates are typically read from the file {@link #INFO_ALTERNATES} or - * {@link #INFO_HTTP_ALTERNATES}. The content of each line must be resolved + * Alternates are typically read from the file + * {@link org.eclipse.jgit.lib.Constants#INFO_ALTERNATES} or + * {@link org.eclipse.jgit.lib.Constants#INFO_HTTP_ALTERNATES}. + * The content of each line must be resolved * by the implementation and a new database reference should be returned to * represent the additional location. *