Merge branch 'stable-5.6'
* stable-5.6:
Silence API errors introduced by 093fbbd1
Bump Bazel version to 2.2.0
Expose FileStoreAttributes.setBackground()
Update reftable storage repo layout
Change-Id: I237eaaed7991e8bbd56a7624f47bbba985330026
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
commit
fb0858e9c9
|
@ -1 +1 @@
|
||||||
2.1.0
|
2.2.0
|
||||||
|
|
|
@ -91,11 +91,6 @@ public void testRacyReload() throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void additionalRefsAreRemoved() {
|
|
||||||
assertFalse(new File(db.getDirectory(), Constants.HEAD).exists());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompactFully() throws Exception {
|
public void testCompactFully() throws Exception {
|
||||||
ObjectId c1 = db.resolve("master^^");
|
ObjectId c1 = db.resolve("master^^");
|
||||||
|
@ -108,9 +103,16 @@ public void testCompactFully() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
File tableDir = new File(db.getDirectory(), Constants.REFTABLE);
|
File tableDir = new File(db.getDirectory(), Constants.REFTABLE);
|
||||||
assertTrue(tableDir.listFiles().length > 1);
|
assertTrue(tableDir.listFiles().length > 2);
|
||||||
((FileReftableDatabase)db.getRefDatabase()).compactFully();
|
((FileReftableDatabase)db.getRefDatabase()).compactFully();
|
||||||
assertEquals(tableDir.listFiles().length,1);
|
assertEquals(tableDir.listFiles().length,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOpenConvert() throws Exception {
|
||||||
|
try (FileRepository repo = new FileRepository(db.getDirectory())) {
|
||||||
|
assertTrue(repo.getRefDatabase() instanceof FileReftableDatabase);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -129,7 +131,7 @@ public void testConvert() throws Exception {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConvertToRefdir() throws Exception {
|
public void testConvertToRefdir() throws Exception {
|
||||||
db.convertToPackedRefs(false);
|
db.convertToPackedRefs(false, false);
|
||||||
assertTrue(db.getRefDatabase() instanceof RefDirectory);
|
assertTrue(db.getRefDatabase() instanceof RefDirectory);
|
||||||
Ref h = db.exactRef("HEAD");
|
Ref h = db.exactRef("HEAD");
|
||||||
assertTrue(h.isSymbolic());
|
assertTrue(h.isSymbolic());
|
||||||
|
@ -143,6 +145,30 @@ public void testConvertToRefdir() throws Exception {
|
||||||
assertFalse(db.getRefDatabase().hasFastTipsWithSha1());
|
assertFalse(db.getRefDatabase().hasFastTipsWithSha1());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConvertToRefdirReflog() throws Exception {
|
||||||
|
Ref a = db.exactRef("refs/heads/a");
|
||||||
|
String aCommit = a.getObjectId().getName();
|
||||||
|
RefUpdate u = db.updateRef("refs/heads/master");
|
||||||
|
u.setForceUpdate(true);
|
||||||
|
u.setNewObjectId(ObjectId.fromString(aCommit));
|
||||||
|
u.setForceRefLog(true);
|
||||||
|
u.setRefLogMessage("apple", false);
|
||||||
|
u.update();
|
||||||
|
|
||||||
|
RefUpdate v = db.updateRef("refs/heads/master");
|
||||||
|
v.setForceUpdate(true);
|
||||||
|
v.setNewObjectId(ObjectId.fromString(bCommit));
|
||||||
|
v.setForceRefLog(true);
|
||||||
|
v.setRefLogMessage("banana", false);
|
||||||
|
v.update();
|
||||||
|
|
||||||
|
db.convertToPackedRefs(true, false);
|
||||||
|
List<ReflogEntry> logs = db.getReflogReader("refs/heads/master").getReverseEntries(2);
|
||||||
|
assertEquals(logs.get(0).getComment(), "banana");
|
||||||
|
assertEquals(logs.get(1).getComment(), "apple");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBatchrefUpdate() throws Exception {
|
public void testBatchrefUpdate() throws Exception {
|
||||||
ObjectId cur = db.resolve("master");
|
ObjectId cur = db.resolve("master");
|
||||||
|
|
|
@ -37,6 +37,26 @@
|
||||||
<message_argument value="CONFIG_KEY_PACKED_GIT_WINDOWSIZE"/>
|
<message_argument value="CONFIG_KEY_PACKED_GIT_WINDOWSIZE"/>
|
||||||
</message_arguments>
|
</message_arguments>
|
||||||
</filter>
|
</filter>
|
||||||
|
<filter id="1142947843">
|
||||||
|
<message_arguments>
|
||||||
|
<message_argument value="5.6.2"/>
|
||||||
|
<message_argument value="CONFIG_EXTENSIONS_SECTION"/>
|
||||||
|
</message_arguments>
|
||||||
|
</filter>
|
||||||
|
<filter id="1142947843">
|
||||||
|
<message_arguments>
|
||||||
|
<message_argument value="5.6.2"/>
|
||||||
|
<message_argument value="CONFIG_KEY_REF_STORAGE"/>
|
||||||
|
</message_arguments>
|
||||||
|
</filter>
|
||||||
|
</resource>
|
||||||
|
<resource path="src/org/eclipse/jgit/lib/Constants.java" type="org.eclipse.jgit.lib.Constants">
|
||||||
|
<filter id="1142947843">
|
||||||
|
<message_arguments>
|
||||||
|
<message_argument value="5.6.2"/>
|
||||||
|
<message_argument value="TABLES_LIST"/>
|
||||||
|
</message_arguments>
|
||||||
|
</filter>
|
||||||
</resource>
|
</resource>
|
||||||
<resource path="src/org/eclipse/jgit/storage/file/WindowCacheConfig.java" type="org.eclipse.jgit.storage.file.WindowCacheConfig">
|
<resource path="src/org/eclipse/jgit/storage/file/WindowCacheConfig.java" type="org.eclipse.jgit.storage.file.WindowCacheConfig">
|
||||||
<filter id="1142947843">
|
<filter id="1142947843">
|
||||||
|
@ -69,6 +89,14 @@
|
||||||
</message_arguments>
|
</message_arguments>
|
||||||
</filter>
|
</filter>
|
||||||
</resource>
|
</resource>
|
||||||
|
<resource path="src/org/eclipse/jgit/util/FS.java" type="org.eclipse.jgit.util.FS$FileStoreAttributes">
|
||||||
|
<filter id="1226833923">
|
||||||
|
<message_arguments>
|
||||||
|
<message_argument value="5.6.2"/>
|
||||||
|
<message_argument value="setBackground(boolean)"/>
|
||||||
|
</message_arguments>
|
||||||
|
</filter>
|
||||||
|
</resource>
|
||||||
<resource path="src/org/eclipse/jgit/util/Monitoring.java" type="org.eclipse.jgit.util.Monitoring">
|
<resource path="src/org/eclipse/jgit/util/Monitoring.java" type="org.eclipse.jgit.util.Monitoring">
|
||||||
<filter id="1109393411">
|
<filter id="1109393411">
|
||||||
<message_arguments>
|
<message_arguments>
|
||||||
|
|
|
@ -64,6 +64,11 @@ public class FileReftableDatabase extends RefDatabase {
|
||||||
|
|
||||||
private final FileReftableStack reftableStack;
|
private final FileReftableStack reftableStack;
|
||||||
|
|
||||||
|
FileReftableDatabase(FileRepository repo) throws IOException {
|
||||||
|
this(repo, new File(new File(repo.getDirectory(), Constants.REFTABLE),
|
||||||
|
Constants.TABLES_LIST));
|
||||||
|
}
|
||||||
|
|
||||||
FileReftableDatabase(FileRepository repo, File refstackName) throws IOException {
|
FileReftableDatabase(FileRepository repo, File refstackName) throws IOException {
|
||||||
this.fileRepository = repo;
|
this.fileRepository = repo;
|
||||||
this.reftableStack = new FileReftableStack(refstackName,
|
this.reftableStack = new FileReftableStack(refstackName,
|
||||||
|
@ -88,8 +93,7 @@ ReflogReader getReflogReader(String refname) throws IOException {
|
||||||
* @return whether the given repo uses reftable for refdb storage.
|
* @return whether the given repo uses reftable for refdb storage.
|
||||||
*/
|
*/
|
||||||
public static boolean isReftable(File repoDir) {
|
public static boolean isReftable(File repoDir) {
|
||||||
return new File(repoDir, "refs").isFile() //$NON-NLS-1$
|
return new File(repoDir, Constants.REFTABLE).isDirectory();
|
||||||
&& new File(repoDir, Constants.REFTABLE).isDirectory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
@ -593,8 +597,6 @@ private static Ref refForWrite(RevWalk rw, Ref r) throws IOException {
|
||||||
/**
|
/**
|
||||||
* @param repo
|
* @param repo
|
||||||
* the repository
|
* the repository
|
||||||
* @param refstackName
|
|
||||||
* the filename for the stack
|
|
||||||
* @param writeLogs
|
* @param writeLogs
|
||||||
* whether to write reflogs
|
* whether to write reflogs
|
||||||
* @return a reftable based RefDB from an existing repository.
|
* @return a reftable based RefDB from an existing repository.
|
||||||
|
@ -602,22 +604,25 @@ private static Ref refForWrite(RevWalk rw, Ref r) throws IOException {
|
||||||
* on IO error
|
* on IO error
|
||||||
*/
|
*/
|
||||||
public static FileReftableDatabase convertFrom(FileRepository repo,
|
public static FileReftableDatabase convertFrom(FileRepository repo,
|
||||||
File refstackName, boolean writeLogs) throws IOException {
|
boolean writeLogs) throws IOException {
|
||||||
FileReftableDatabase newDb = null;
|
FileReftableDatabase newDb = null;
|
||||||
|
File reftableList = null;
|
||||||
try {
|
try {
|
||||||
File reftableDir = new File(repo.getDirectory(), Constants.REFTABLE);
|
File reftableDir = new File(repo.getDirectory(),
|
||||||
|
Constants.REFTABLE);
|
||||||
|
reftableList = new File(reftableDir, Constants.TABLES_LIST);
|
||||||
if (!reftableDir.isDirectory()) {
|
if (!reftableDir.isDirectory()) {
|
||||||
reftableDir.mkdir();
|
reftableDir.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
try (FileReftableStack stack = new FileReftableStack(refstackName,
|
try (FileReftableStack stack = new FileReftableStack(reftableList,
|
||||||
reftableDir, null, () -> repo.getConfig())) {
|
reftableDir, null, () -> repo.getConfig())) {
|
||||||
stack.addReftable(rw -> writeConvertTable(repo, rw, writeLogs));
|
stack.addReftable(rw -> writeConvertTable(repo, rw, writeLogs));
|
||||||
}
|
}
|
||||||
refstackName = null;
|
reftableList = null;
|
||||||
} finally {
|
} finally {
|
||||||
if (refstackName != null) {
|
if (reftableList != null) {
|
||||||
refstackName.delete();
|
reftableList.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newDb;
|
return newDb;
|
||||||
|
|
|
@ -18,10 +18,13 @@
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -50,6 +53,7 @@
|
||||||
import org.eclipse.jgit.lib.Ref;
|
import org.eclipse.jgit.lib.Ref;
|
||||||
import org.eclipse.jgit.lib.RefDatabase;
|
import org.eclipse.jgit.lib.RefDatabase;
|
||||||
import org.eclipse.jgit.lib.RefUpdate;
|
import org.eclipse.jgit.lib.RefUpdate;
|
||||||
|
import org.eclipse.jgit.lib.ReflogEntry;
|
||||||
import org.eclipse.jgit.lib.ReflogReader;
|
import org.eclipse.jgit.lib.ReflogReader;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.eclipse.jgit.lib.StoredConfig;
|
import org.eclipse.jgit.lib.StoredConfig;
|
||||||
|
@ -173,20 +177,17 @@ public FileRepository(BaseRepositoryBuilder options) throws IOException {
|
||||||
|
|
||||||
String reftype = repoConfig.getString(
|
String reftype = repoConfig.getString(
|
||||||
ConfigConstants.CONFIG_EXTENSIONS_SECTION, null,
|
ConfigConstants.CONFIG_EXTENSIONS_SECTION, null,
|
||||||
ConfigConstants.CONFIG_KEY_REFSTORAGE);
|
ConfigConstants.CONFIG_KEY_REF_STORAGE);
|
||||||
if (repositoryFormatVersion >= 1 && reftype != null) {
|
if (repositoryFormatVersion >= 1 && reftype != null) {
|
||||||
if (StringUtils.equalsIgnoreCase(reftype,
|
if (StringUtils.equalsIgnoreCase(reftype,
|
||||||
ConfigConstants.CONFIG_REFSTORAGE_REFTABLE)) {
|
ConfigConstants.CONFIG_REF_STORAGE_REFTABLE)) {
|
||||||
refs = new FileReftableDatabase(this,
|
refs = new FileReftableDatabase(this);
|
||||||
new File(getDirectory(), "refs")); //$NON-NLS-1$
|
|
||||||
} else if (StringUtils.equalsIgnoreCase(reftype,
|
} else if (StringUtils.equalsIgnoreCase(reftype,
|
||||||
ConfigConstants.CONFIG_REFSTORAGE_REFTREE)) {
|
ConfigConstants.CONFIG_REFSTORAGE_REFTREE)) {
|
||||||
refs = new RefTreeDatabase(this, new RefDirectory(this));
|
refs = new RefTreeDatabase(this, new RefDirectory(this));
|
||||||
} else {
|
} else {
|
||||||
throw new IOException(JGitText.get().unknownRepositoryFormat);
|
throw new IOException(JGitText.get().unknownRepositoryFormat);
|
||||||
}
|
}
|
||||||
} else if (FileReftableDatabase.isReftable(getDirectory())) {
|
|
||||||
refs = new FileReftableDatabase(this, new File(getDirectory(), "refs")); //$NON-NLS-1$
|
|
||||||
} else {
|
} else {
|
||||||
refs = new RefDirectory(this);
|
refs = new RefDirectory(this);
|
||||||
}
|
}
|
||||||
|
@ -610,15 +611,18 @@ public void autoGC(ProgressMonitor monitor) {
|
||||||
* Converts the RefDatabase from reftable to RefDirectory. This operation is
|
* Converts the RefDatabase from reftable to RefDirectory. This operation is
|
||||||
* not atomic.
|
* not atomic.
|
||||||
*
|
*
|
||||||
|
* @param writeLogs
|
||||||
|
* whether to write reflogs
|
||||||
* @param backup
|
* @param backup
|
||||||
* whether to rename or delete the old storage files. If set to
|
* whether to rename or delete the old storage files. If set to
|
||||||
* true, the reftable list is left in "refs.old", and the
|
* {@code true}, the reftable list is left in {@code refs.old},
|
||||||
* reftable/ dir is left alone. If set to false, the reftable/
|
* and the {@code reftable/} dir is left alone. If set to
|
||||||
* dir is removed, and "refs" file is removed.
|
* {@code false}, the {@code reftable/} dir is removed, and
|
||||||
|
* {@code refs} file is removed.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* on IO problem
|
* on IO problem
|
||||||
*/
|
*/
|
||||||
void convertToPackedRefs(boolean backup) throws IOException {
|
void convertToPackedRefs(boolean writeLogs, boolean backup) throws IOException {
|
||||||
List<Ref> all = refs.getRefs();
|
List<Ref> all = refs.getRefs();
|
||||||
File packedRefs = new File(getDirectory(), Constants.PACKED_REFS);
|
File packedRefs = new File(getDirectory(), Constants.PACKED_REFS);
|
||||||
if (packedRefs.exists()) {
|
if (packedRefs.exists()) {
|
||||||
|
@ -627,26 +631,26 @@ void convertToPackedRefs(boolean backup) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
File refsFile = new File(getDirectory(), "refs"); //$NON-NLS-1$
|
File refsFile = new File(getDirectory(), "refs"); //$NON-NLS-1$
|
||||||
|
File refsHeadsFile = new File(refsFile, "heads");//$NON-NLS-1$
|
||||||
|
File headFile = new File(getDirectory(), Constants.HEAD);
|
||||||
|
FileReftableDatabase oldDb = (FileReftableDatabase) refs;
|
||||||
|
|
||||||
refs.close();
|
// Remove the dummy files that ensure compatibility with older git
|
||||||
|
// versions (see convertToReftable). First make room for refs/heads/
|
||||||
if (backup) {
|
refsHeadsFile.delete();
|
||||||
File refsOld = new File(getDirectory(), "refs.old"); //$NON-NLS-1$
|
// RefDirectory wants to create the refs/ directory from scratch, so
|
||||||
if (refsOld.exists()) {
|
// remove that too.
|
||||||
throw new IOException(MessageFormat.format(
|
refsFile.delete();
|
||||||
JGitText.get().fileAlreadyExists,
|
// remove HEAD so its previous invalid value doesn't cause issues.
|
||||||
"refs.old")); //$NON-NLS-1$
|
headFile.delete();
|
||||||
}
|
|
||||||
FileUtils.rename(refsFile, refsOld);
|
|
||||||
} else {
|
|
||||||
refsFile.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is not atomic, but there is no way to instantiate a RefDirectory
|
// This is not atomic, but there is no way to instantiate a RefDirectory
|
||||||
// that is disconnected from the current repo.
|
// that is disconnected from the current repo.
|
||||||
refs = new RefDirectory(this);
|
RefDirectory refDir = new RefDirectory(this);
|
||||||
|
refs = refDir;
|
||||||
refs.create();
|
refs.create();
|
||||||
|
|
||||||
|
ReflogWriter logWriter = refDir.newLogWriter(true);
|
||||||
List<Ref> symrefs = new ArrayList<>();
|
List<Ref> symrefs = new ArrayList<>();
|
||||||
BatchRefUpdate bru = refs.newBatchUpdate();
|
BatchRefUpdate bru = refs.newBatchUpdate();
|
||||||
for (Ref r : all) {
|
for (Ref r : all) {
|
||||||
|
@ -656,6 +660,15 @@ void convertToPackedRefs(boolean backup) throws IOException {
|
||||||
bru.addCommand(new ReceiveCommand(ObjectId.zeroId(),
|
bru.addCommand(new ReceiveCommand(ObjectId.zeroId(),
|
||||||
r.getObjectId(), r.getName()));
|
r.getObjectId(), r.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (writeLogs) {
|
||||||
|
List<ReflogEntry> logs = oldDb.getReflogReader(r.getName())
|
||||||
|
.getReverseEntries();
|
||||||
|
Collections.reverse(logs);
|
||||||
|
for (ReflogEntry e : logs) {
|
||||||
|
logWriter.log(r.getName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try (RevWalk rw = new RevWalk(this)) {
|
try (RevWalk rw = new RevWalk(this)) {
|
||||||
|
@ -691,24 +704,39 @@ void convertToPackedRefs(boolean backup) throws IOException {
|
||||||
FileUtils.delete(reftableDir,
|
FileUtils.delete(reftableDir,
|
||||||
FileUtils.RECURSIVE | FileUtils.IGNORE_ERRORS);
|
FileUtils.RECURSIVE | FileUtils.IGNORE_ERRORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
repoConfig.unset(ConfigConstants.CONFIG_EXTENSIONS_SECTION, null,
|
repoConfig.unset(ConfigConstants.CONFIG_EXTENSIONS_SECTION, null,
|
||||||
ConfigConstants.CONFIG_KEY_REFSTORAGE);
|
ConfigConstants.CONFIG_KEY_REF_STORAGE);
|
||||||
repoConfig.save();
|
repoConfig.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the RefDatabase from RefDirectory to reftable. This operation is
|
||||||
|
* not atomic.
|
||||||
|
*
|
||||||
|
* @param writeLogs
|
||||||
|
* whether to write reflogs
|
||||||
|
* @param backup
|
||||||
|
* whether to rename or delete the old storage files. If set to
|
||||||
|
* {@code true}, the loose refs are left in {@code refs.old}, the
|
||||||
|
* packed-refs in {@code packed-refs.old} and reflogs in
|
||||||
|
* {@code refs.old/}. HEAD is left in {@code HEAD.old} and also
|
||||||
|
* {@code .log} is appended to additional refs. If set to
|
||||||
|
* {@code false}, the {@code refs/} and {@code logs/} directories
|
||||||
|
* and {@code HEAD} and additional symbolic refs are removed.
|
||||||
|
* @throws IOException
|
||||||
|
* on IO problem
|
||||||
|
*/
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
void convertToReftable(boolean writeLogs, boolean backup)
|
void convertToReftable(boolean writeLogs, boolean backup)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
File newRefs = new File(getDirectory(), "refs.new");
|
|
||||||
File reftableDir = new File(getDirectory(), Constants.REFTABLE);
|
File reftableDir = new File(getDirectory(), Constants.REFTABLE);
|
||||||
|
File headFile = new File(getDirectory(), Constants.HEAD);
|
||||||
if (reftableDir.exists() && reftableDir.listFiles().length > 0) {
|
if (reftableDir.exists() && reftableDir.listFiles().length > 0) {
|
||||||
throw new IOException(JGitText.get().reftableDirExists);
|
throw new IOException(JGitText.get().reftableDirExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore return value, as it is tied to temporary newRefs file.
|
// Ignore return value, as it is tied to temporary newRefs file.
|
||||||
FileReftableDatabase.convertFrom(this, newRefs, writeLogs);
|
FileReftableDatabase.convertFrom(this, writeLogs);
|
||||||
|
|
||||||
File refsFile = new File(getDirectory(), "refs");
|
File refsFile = new File(getDirectory(), "refs");
|
||||||
|
|
||||||
|
@ -716,7 +744,6 @@ void convertToReftable(boolean writeLogs, boolean backup)
|
||||||
File packedRefs = new File(getDirectory(), Constants.PACKED_REFS);
|
File packedRefs = new File(getDirectory(), Constants.PACKED_REFS);
|
||||||
File logsDir = new File(getDirectory(), Constants.LOGS);
|
File logsDir = new File(getDirectory(), Constants.LOGS);
|
||||||
|
|
||||||
|
|
||||||
List<String> additional = getRefDatabase().getAdditionalRefs().stream()
|
List<String> additional = getRefDatabase().getAdditionalRefs().stream()
|
||||||
.map(Ref::getName).collect(toList());
|
.map(Ref::getName).collect(toList());
|
||||||
additional.add(Constants.HEAD);
|
additional.add(Constants.HEAD);
|
||||||
|
@ -735,7 +762,8 @@ void convertToReftable(boolean writeLogs, boolean backup)
|
||||||
new File(getDirectory(), r + ".old"));
|
new File(getDirectory(), r + ".old"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
packedRefs.delete(); // ignore return value.
|
FileUtils.delete(packedRefs, FileUtils.SKIP_MISSING);
|
||||||
|
FileUtils.delete(headFile);
|
||||||
FileUtils.delete(logsDir, FileUtils.RECURSIVE);
|
FileUtils.delete(logsDir, FileUtils.RECURSIVE);
|
||||||
FileUtils.delete(refsFile, FileUtils.RECURSIVE);
|
FileUtils.delete(refsFile, FileUtils.RECURSIVE);
|
||||||
for (String r : additional) {
|
for (String r : additional) {
|
||||||
|
@ -743,16 +771,26 @@ void convertToReftable(boolean writeLogs, boolean backup)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put new data.
|
FileUtils.mkdir(refsFile, true);
|
||||||
FileUtils.rename(newRefs, refsFile);
|
|
||||||
|
|
||||||
refs.close();
|
// By putting in a dummy HEAD, old versions of Git still detect a repo
|
||||||
refs = new FileReftableDatabase(this, refsFile);
|
// (that they can't read)
|
||||||
|
try (OutputStream os = new FileOutputStream(headFile)) {
|
||||||
|
os.write(Constants.encodeASCII("ref: refs/heads/.invalid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some tools might write directly into .git/refs/heads/BRANCH. By
|
||||||
|
// putting a file here, this fails spectacularly.
|
||||||
|
FileUtils.createNewFile(new File(refsFile, "heads"));
|
||||||
|
|
||||||
repoConfig.setString(ConfigConstants.CONFIG_EXTENSIONS_SECTION, null,
|
repoConfig.setString(ConfigConstants.CONFIG_EXTENSIONS_SECTION, null,
|
||||||
ConfigConstants.CONFIG_KEY_REFSTORAGE,
|
ConfigConstants.CONFIG_KEY_REF_STORAGE,
|
||||||
ConfigConstants.CONFIG_REFSTORAGE_REFTABLE);
|
ConfigConstants.CONFIG_REF_STORAGE_REFTABLE);
|
||||||
|
repoConfig.setLong(ConfigConstants.CONFIG_CORE_SECTION, null,
|
||||||
|
ConfigConstants.CONFIG_KEY_REPO_FORMAT_VERSION, 1);
|
||||||
repoConfig.save();
|
repoConfig.save();
|
||||||
|
refs.close();
|
||||||
|
refs = new FileReftableDatabase(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -775,7 +813,7 @@ public void convertRefStorage(String format, boolean writeLogs,
|
||||||
}
|
}
|
||||||
} else if (format.equals("refdir")) {//$NON-NLS-1$
|
} else if (format.equals("refdir")) {//$NON-NLS-1$
|
||||||
if (refs instanceof FileReftableDatabase) {
|
if (refs instanceof FileReftableDatabase) {
|
||||||
convertToPackedRefs(backup);
|
convertToPackedRefs(writeLogs, backup);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new IOException(MessageFormat
|
throw new IOException(MessageFormat
|
||||||
|
|
|
@ -504,9 +504,18 @@ public final class ConfigConstants {
|
||||||
*/
|
*/
|
||||||
public static final String CONFIG_KEY_MIN_RACY_THRESHOLD = "minRacyThreshold";
|
public static final String CONFIG_KEY_MIN_RACY_THRESHOLD = "minRacyThreshold";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "refStorage" key
|
||||||
|
*
|
||||||
|
* @since 5.6.2
|
||||||
|
*/
|
||||||
|
public static final String CONFIG_KEY_REF_STORAGE = "refStorage";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "extensions" section
|
* The "extensions" section
|
||||||
* @since 5.7
|
*
|
||||||
|
* @since 5.6.2
|
||||||
*/
|
*/
|
||||||
public static final String CONFIG_EXTENSIONS_SECTION = "extensions";
|
public static final String CONFIG_EXTENSIONS_SECTION = "extensions";
|
||||||
|
|
||||||
|
@ -520,7 +529,7 @@ public final class ConfigConstants {
|
||||||
* The "reftable" refStorage format
|
* The "reftable" refStorage format
|
||||||
* @since 5.7
|
* @since 5.7
|
||||||
*/
|
*/
|
||||||
public static final String CONFIG_REFSTORAGE_REFTABLE = "reftable";
|
public static final String CONFIG_REF_STORAGE_REFTABLE = "reftable";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "reftree" refStorage format
|
* The "reftree" refStorage format
|
||||||
|
|
|
@ -254,6 +254,12 @@ public final class Constants {
|
||||||
*/
|
*/
|
||||||
public static final String REFTABLE = "reftable";
|
public static final String REFTABLE = "reftable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reftable table list name.
|
||||||
|
* @since 5.6.2
|
||||||
|
*/
|
||||||
|
public static final String TABLES_LIST = "tables.list";
|
||||||
|
|
||||||
/** Info refs folder */
|
/** Info refs folder */
|
||||||
public static final String INFO_REFS = "info/refs";
|
public static final String INFO_REFS = "info/refs";
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,16 @@ public static final class FileStoreAttributes {
|
||||||
return t;
|
return t;
|
||||||
});
|
});
|
||||||
|
|
||||||
private static void setBackground(boolean async) {
|
/**
|
||||||
|
* Whether FileStore attributes should be determined asynchronously
|
||||||
|
*
|
||||||
|
* @param async
|
||||||
|
* whether FileStore attributes should be determined
|
||||||
|
* asynchronously. If false access to cached attributes may block
|
||||||
|
* for some seconds for the first call per FileStore
|
||||||
|
* @since 5.6.2
|
||||||
|
*/
|
||||||
|
public static void setBackground(boolean async) {
|
||||||
background.set(async);
|
background.set(async);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,7 +718,9 @@ public static FS detect() {
|
||||||
* asynchronously. If false access to cached attributes may block
|
* asynchronously. If false access to cached attributes may block
|
||||||
* for some seconds for the first call per FileStore
|
* for some seconds for the first call per FileStore
|
||||||
* @since 5.1.9
|
* @since 5.1.9
|
||||||
|
* @deprecated Use {@link FileStoreAttributes#setBackground} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void setAsyncFileStoreAttributes(boolean asynch) {
|
public static void setAsyncFileStoreAttributes(boolean asynch) {
|
||||||
FileStoreAttributes.setBackground(asynch);
|
FileStoreAttributes.setBackground(asynch);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue