Merge "Constants for objects and info/{http-,}alternates"
This commit is contained in:
commit
863c2687df
|
@ -248,13 +248,13 @@ public void init(FilterConfig filterConfig) throws ServletException {
|
|||
.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)//
|
||||
|
|
|
@ -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 Path getLfsTmpDir() {
|
|||
*/
|
||||
public Path getLfsObjDir() {
|
||||
if (objDir == null) {
|
||||
objDir = root.resolve("objects"); //$NON-NLS-1$
|
||||
objDir = root.resolve(OBJECTS);
|
||||
}
|
||||
return objDir;
|
||||
}
|
||||
|
|
|
@ -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 void setUp() throws Exception {
|
|||
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();
|
||||
|
|
|
@ -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 void setUp() throws Exception {
|
|||
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");
|
||||
}
|
||||
|
|
|
@ -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 void test000_openrepo_default_gitDirSet() throws IOException {
|
|||
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 void test000_openrepo_default_gitDirAndWorkTreeSet()
|
|||
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 void test000_openrepo_default_workDirSet() throws IOException {
|
|||
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 void test000_openrepo_default_absolute_workdirconfig()
|
|||
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 void test000_openrepo_default_relative_workdirconfig()
|
|||
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 void test002_WriteEmptyTree() throws IOException {
|
|||
}
|
||||
|
||||
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 void test002_WriteEmptyTree2() throws IOException {
|
|||
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());
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ public ObjectDirectory(final Config cfg, final File dir,
|
|||
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;
|
||||
|
|
|
@ -681,7 +681,7 @@ protected void setupWorkTree() throws IOException {
|
|||
*/
|
||||
protected void setupInternals() throws IOException {
|
||||
if (getObjectDirectory() == null && getGitDir() != null)
|
||||
setObjectDirectory(safeFS().resolve(getGitDir(), "objects")); //$NON-NLS-1$
|
||||
setObjectDirectory(safeFS().resolve(getGitDir(), Constants.OBJECTS));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -275,9 +275,27 @@ public final class Constants {
|
|||
/** Logs folder name */
|
||||
public static final String LOGS = "logs";
|
||||
|
||||
/**
|
||||
* Objects folder name
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final String OBJECTS = "objects";
|
||||
|
||||
/** Info refs folder */
|
||||
public static final String INFO_REFS = "info/refs";
|
||||
|
||||
/**
|
||||
* Info alternates file (goes under OBJECTS)
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final String INFO_ALTERNATES = "info/alternates";
|
||||
|
||||
/**
|
||||
* HTTP alternates file (goes under OBJECTS)
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final String INFO_HTTP_ALTERNATES = "info/http-alternates";
|
||||
|
||||
/** Packed refs file */
|
||||
public static final String PACKED_REFS = "packed-refs";
|
||||
|
||||
|
|
|
@ -474,7 +474,7 @@ public String toString() {
|
|||
* Git directory.
|
||||
*/
|
||||
public static boolean isGitRepository(File dir, FS fs) {
|
||||
return fs.resolve(dir, "objects").exists() //$NON-NLS-1$
|
||||
return fs.resolve(dir, Constants.OBJECTS).exists()
|
||||
&& fs.resolve(dir, "refs").exists() //$NON-NLS-1$
|
||||
&& isValidHead(new File(dir, Constants.HEAD));
|
||||
}
|
||||
|
|
|
@ -259,7 +259,7 @@ URIish getURI() {
|
|||
@Override
|
||||
Collection<WalkRemoteObjectDatabase> getAlternates() throws IOException {
|
||||
try {
|
||||
return readAlternates(INFO_ALTERNATES);
|
||||
return readAlternates(Constants.INFO_ALTERNATES);
|
||||
} catch (FileNotFoundException err) {
|
||||
// Fall through.
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
|
||||
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;
|
||||
|
|
|
@ -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 @@ class SftpObjectDB extends WalkRemoteObjectDatabase {
|
|||
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(
|
||||
|
|
|
@ -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).
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
|
|
Loading…
Reference in New Issue