diff options
author | Shawn Pearce <spearce@spearce.org> | 2016-01-09 12:51:14 -0800 |
---|---|---|
committer | Shawn Pearce <spearce@spearce.org> | 2016-01-11 15:27:07 -0800 |
commit | 088c2fc6e33737a406e69a99d75f06d3fbb05e30 (patch) | |
tree | 0c49965cf40a34752ff37e42e5f7b3e41d0758b4 /org.eclipse.jgit.pgm/src | |
parent | 48e245fc606f7033b9de017d3dcae7b8ea7cc91a (diff) | |
download | jgit-088c2fc6e33737a406e69a99d75f06d3fbb05e30.tar.gz jgit-088c2fc6e33737a406e69a99d75f06d3fbb05e30.zip |
FileRepository: Support extensions.refsBackendType = RefTree
This experimental code can be enabled in $GIT_DIR/config:
[core]
repositoryformatversion = 1
[extensions]
refsBackendType = RefTree
When these are set the repository will read references from the
RefTree rooted by the $GIT_DIR/refs/txn/committed reference.
Update debug-rebuild-ref-tree to rebuild refs/txn/committed only from
the bootstrap layer. This avoids misuse by rebuilding using packed-refs
and $GIT_DIR/refs tree.
Change-Id: Icf600e4a36b2f7867822a7ab1f1617d73c710a4b
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java | 29 |
1 files changed, 22 insertions, 7 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 6af4ce1dd1..78ca1a7128 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 @@ -48,6 +48,7 @@ import java.util.List; import java.util.Map; import org.eclipse.jgit.internal.storage.reftree.RefTree; +import org.eclipse.jgit.internal.storage.reftree.RefTreeDatabase; import org.eclipse.jgit.lib.CommitBuilder; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectInserter; @@ -59,12 +60,11 @@ import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.pgm.Command; import org.eclipse.jgit.pgm.TextBuiltin; import org.eclipse.jgit.revwalk.RevWalk; -import org.kohsuke.args4j.Argument; @Command(usage = "usage_RebuildRefTree") class RebuildRefTree extends TextBuiltin { - @Argument(index = 0, required = true, metaVar = "metaVar_ref", usage = "usage_updateRef") - String refName; + private String txnNamespace; + private String txnCommitted; @Override protected void run() throws Exception { @@ -72,10 +72,25 @@ class RebuildRefTree extends TextBuiltin { RevWalk rw = new RevWalk(reader); ObjectInserter inserter = db.newObjectInserter()) { RefDatabase refDb = db.getRefDatabase(); + if (refDb instanceof RefTreeDatabase) { + RefTreeDatabase d = (RefTreeDatabase) refDb; + refDb = d.getBootstrap(); + txnNamespace = d.getTxnNamespace(); + txnCommitted = d.getTxnCommitted(); + } else { + RefTreeDatabase d = new RefTreeDatabase(db, refDb); + txnNamespace = d.getTxnNamespace(); + txnCommitted = d.getTxnCommitted(); + } + + errw.format("Rebuilding %s from %s", //$NON-NLS-1$ + txnCommitted, refDb.getClass().getSimpleName()); + errw.println(); + errw.flush(); CommitBuilder b = new CommitBuilder(); - Ref ref = db.getRefDatabase().exactRef(refName); - RefUpdate update = db.updateRef(refName); + Ref ref = refDb.exactRef(txnCommitted); + RefUpdate update = refDb.newUpdate(txnCommitted, true); ObjectId oldTreeId; if (ref != null && ref.getObjectId() != null) { @@ -116,10 +131,10 @@ class RebuildRefTree extends TextBuiltin { = new ArrayList<>(); for (Ref r : refMap.values()) { - if (refName.equals(r.getName())) { + if (r.getName().equals(txnCommitted) + || r.getName().startsWith(txnNamespace)) { continue; } - cmds.add(new org.eclipse.jgit.internal.storage.reftree.Command( null, db.peel(r))); |