diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-12-14 22:45:09 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-12-15 10:15:46 +0100 |
commit | 83f90a274cc8629caadb7ee3a1838be5e5c12b33 (patch) | |
tree | 7a11f22b727cb3389a4692592a2a2428ea9d9f75 /org.eclipse.jgit | |
parent | 57f22d6db1e76720fffaafe0db6c1c3964f8b9a1 (diff) | |
download | jgit-83f90a274cc8629caadb7ee3a1838be5e5c12b33.tar.gz jgit-83f90a274cc8629caadb7ee3a1838be5e5c12b33.zip |
Set config "extensions" option when converting ref storage format
When converting to reftable format the option extensions.refStorage must
be set to "reftable" [1]. When converting back to refdir format this
config option needs to be removed.
Introduce constants for refStorage config options, also for the
"reftree" format.
[1] https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/master/Documentation/technical/reftable.md#Version-1
Change-Id: I190222fa5edc1ad7309daa9be17ca934ff7971e3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java | 18 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java | 25 |
2 files changed, 39 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java index 92d5d24d0b..ff9b32c1cf 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java @@ -205,12 +205,15 @@ public class FileRepository extends Repository { ConfigConstants.CONFIG_KEY_REPO_FORMAT_VERSION, 0); String reftype = repoConfig.getString( - "extensions", null, "refStorage"); //$NON-NLS-1$ //$NON-NLS-2$ + ConfigConstants.CONFIG_EXTENSIONS_SECTION, null, + ConfigConstants.CONFIG_KEY_REFSTORAGE); if (repositoryFormatVersion >= 1 && reftype != null) { - if (StringUtils.equalsIgnoreCase(reftype, "reftable")) { //$NON-NLS-1$ + if (StringUtils.equalsIgnoreCase(reftype, + ConfigConstants.CONFIG_REFSTORAGE_REFTABLE)) { refs = new FileReftableDatabase(this, new File(getDirectory(), "refs")); //$NON-NLS-1$ - } else if (StringUtils.equalsIgnoreCase(reftype, "reftree")) { //$NON-NLS-1$ + } else if (StringUtils.equalsIgnoreCase(reftype, + ConfigConstants.CONFIG_REFSTORAGE_REFTREE)) { refs = new RefTreeDatabase(this, new RefDirectory(this)); } else { throw new IOException(JGitText.get().unknownRepositoryFormat); @@ -721,6 +724,10 @@ public class FileRepository extends Repository { FileUtils.delete(reftableDir, FileUtils.RECURSIVE | FileUtils.IGNORE_ERRORS); } + + repoConfig.unset(ConfigConstants.CONFIG_EXTENSIONS_SECTION, null, + ConfigConstants.CONFIG_KEY_REFSTORAGE); + repoConfig.save(); } @SuppressWarnings("nls") @@ -774,6 +781,11 @@ public class FileRepository extends Repository { refs.close(); refs = new FileReftableDatabase(this, refsFile); + + repoConfig.setString(ConfigConstants.CONFIG_EXTENSIONS_SECTION, null, + ConfigConstants.CONFIG_KEY_REFSTORAGE, + ConfigConstants.CONFIG_REFSTORAGE_REFTABLE); + repoConfig.save(); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java index e0bd592194..b6ffb84796 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java @@ -503,8 +503,31 @@ public final class ConfigConstants { /** * The "minRacyThreshold" key - * * @since 5.1.9 */ public static final String CONFIG_KEY_MIN_RACY_THRESHOLD = "minRacyThreshold"; + + /** + * The "extensions" section + * @since 5.7 + */ + public static final String CONFIG_EXTENSIONS_SECTION = "extensions"; + + /** + * The extensions.refStorage key + * @since 5.7 + */ + public static final String CONFIG_KEY_REFSTORAGE = "refStorage"; + + /** + * The "reftable" refStorage format + * @since 5.7 + */ + public static final String CONFIG_REFSTORAGE_REFTABLE = "reftable"; + + /** + * The "reftree" refStorage format + * @since 5.7 + */ + public static final String CONFIG_REFSTORAGE_REFTREE = "reftree"; } |