summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2016-01-21 00:32:17 -0500
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2016-01-21 00:32:17 -0500
commit8fe9a8baf53ed5c45c697669808d04423702e496 (patch)
treec320dae4c98ed307dde372dfeef4a0f55b4a867d /org.eclipse.jgit.pgm
parent8d0551dd64d026c161a82ce4d9ed2222b5a4b4be (diff)
parent14dfa70520ddf06422df1d943c7bd955a23e46bc (diff)
downloadjgit-8fe9a8baf53ed5c45c697669808d04423702e496.tar.gz
jgit-8fe9a8baf53ed5c45c697669808d04423702e496.zip
Merge changes from topic 'reftree'
* changes: debug-rebuild-ref-tree: Copy HEAD into RefTree debug-rebuild-ref-tree: Add --enable flag to turn the database on RefTreeDatabase: Allow ORIG_HEAD, etc. on non-bare repositories RefTreeDatabase: Expose bootstrap refs in getAdditionalRefs
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java31
1 files changed, 27 insertions, 4 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java
index 78ca1a7128..fbd4672f28 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java
@@ -43,9 +43,11 @@
package org.eclipse.jgit.pgm.debug;
+import static org.eclipse.jgit.lib.Constants.HEAD;
+
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import org.eclipse.jgit.internal.storage.reftree.RefTree;
import org.eclipse.jgit.internal.storage.reftree.RefTreeDatabase;
@@ -57,12 +59,17 @@ import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefDatabase;
import org.eclipse.jgit.lib.RefUpdate;
+import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.pgm.Command;
import org.eclipse.jgit.pgm.TextBuiltin;
import org.eclipse.jgit.revwalk.RevWalk;
+import org.kohsuke.args4j.Option;
@Command(usage = "usage_RebuildRefTree")
class RebuildRefTree extends TextBuiltin {
+ @Option(name = "--enable", usage = "set extensions.refsStorage = reftree")
+ boolean enable;
+
private String txnNamespace;
private String txnCommitted;
@@ -103,7 +110,7 @@ class RebuildRefTree extends TextBuiltin {
oldTreeId = ObjectId.zeroId();
}
- RefTree tree = rebuild(refDb.getRefs(RefDatabase.ALL));
+ RefTree tree = rebuild(refDb);
b.setTreeId(tree.writeTree(inserter));
b.setAuthor(new PersonIdent(db));
b.setCommitter(b.getAuthor());
@@ -122,15 +129,31 @@ class RebuildRefTree extends TextBuiltin {
default:
throw die(String.format("%s: %s", update.getName(), result)); //$NON-NLS-1$
}
+
+ if (enable && !(db.getRefDatabase() instanceof RefTreeDatabase)) {
+ StoredConfig cfg = db.getConfig();
+ cfg.setInt("core", null, "repositoryformatversion", 1); //$NON-NLS-1$ //$NON-NLS-2$
+ cfg.setString("extensions", null, "refsStorage", "reftree"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ cfg.save();
+ errw.println("Enabled reftree."); //$NON-NLS-1$
+ errw.flush();
+ }
}
}
- private RefTree rebuild(Map<String, Ref> refMap) {
+ private RefTree rebuild(RefDatabase refdb) throws IOException {
RefTree tree = RefTree.newEmptyTree();
List<org.eclipse.jgit.internal.storage.reftree.Command> cmds
= new ArrayList<>();
- for (Ref r : refMap.values()) {
+ Ref head = refdb.exactRef(HEAD);
+ if (head != null) {
+ cmds.add(new org.eclipse.jgit.internal.storage.reftree.Command(
+ null,
+ head));
+ }
+
+ for (Ref r : refdb.getRefs(RefDatabase.ALL).values()) {
if (r.getName().equals(txnCommitted)
|| r.getName().startsWith(txnNamespace)) {
continue;