]> source.dussan.org Git - jgit.git/commitdiff
Do not retain commit body in RevWalk for reachability checks 31/138231/1
authorMinh Thai <mthai@google.com>
Wed, 6 Mar 2019 23:25:10 +0000 (15:25 -0800)
committerMinh Thai <mthai@google.com>
Wed, 6 Mar 2019 23:29:59 +0000 (15:29 -0800)
Commit body contains the message that is not needed for reachability checks, and
takes up memory unnecessarily.

Change-Id: I0c7f6da249bf9c4fda9dc9e62e809322c68effce
Signed-off-by: Minh Thai <mthai@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReftableDatabase.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java

index 83394bb92cf922f23059091965f053f0763b8ddd..384273dffc72ffabd2ae341794f430736a6b5eae 100644 (file)
@@ -315,6 +315,7 @@ public class DfsReftableDatabase extends DfsRefDatabase {
                        throws IOException {
                ReceiveCommand cmd = toCommand(oldRef, newRef);
                try (RevWalk rw = new RevWalk(getRepository())) {
+                       rw.setRetainBody(false);
                        newBatchUpdate().setAllowNonFastForwards(true).addCommand(cmd)
                                        .execute(rw, NullProgressMonitor.INSTANCE);
                }
index 1ce15283447f0404e4dcc60a1b331c93437983da..78416276667fc9c6f1eb3bbd6287a5b7d99ef571 100644 (file)
@@ -599,6 +599,7 @@ public abstract class RefUpdate {
         */
        public Result update() throws IOException {
                try (RevWalk rw = new RevWalk(getRepository())) {
+                       rw.setRetainBody(false);
                        return update(rw);
                }
        }
@@ -646,6 +647,7 @@ public abstract class RefUpdate {
         */
        public Result delete() throws IOException {
                try (RevWalk rw = new RevWalk(getRepository())) {
+                       rw.setRetainBody(false);
                        return delete(rw);
                }
        }
index a61897a652fc0471a07eb15f431dd6862b7a7431..625ddf101765ad80bc2bc2908b4bea76387383ff 100644 (file)
@@ -489,6 +489,7 @@ public abstract class Repository implements AutoCloseable {
                        throws AmbiguousObjectException, IncorrectObjectTypeException,
                        RevisionSyntaxException, IOException {
                try (RevWalk rw = new RevWalk(this)) {
+                       rw.setRetainBody(false);
                        Object resolved = resolve(rw, revstr);
                        if (resolved instanceof String) {
                                final Ref ref = findRef((String) resolved);
@@ -515,6 +516,7 @@ public abstract class Repository implements AutoCloseable {
        public String simplify(String revstr)
                        throws AmbiguousObjectException, IOException {
                try (RevWalk rw = new RevWalk(this)) {
+                       rw.setRetainBody(true);
                        Object resolved = resolve(rw, revstr);
                        if (resolved != null)
                                if (resolved instanceof String)
index ed7465c82ad977c0e6b2d66967004aef63bccbbf..d54ae10f699845dc3e3890c88c39955f27e21c80 100644 (file)
@@ -272,6 +272,7 @@ public abstract class BasePackFetchConnection extends BasePackConnection
 
                if (local != null) {
                        walk = new RevWalk(local);
+                       walk.setRetainBody(false);
                        reachableCommits = new RevCommitList<>();
                        REACHABLE = walk.newFlag("REACHABLE"); //$NON-NLS-1$
                        COMMON = walk.newFlag("COMMON"); //$NON-NLS-1$
index 6f17620d91a42e9302244d44020b4c5dc3e112ca..2946e9835748d2c4829b4dcb894f6001003ac96e 100644 (file)
@@ -314,6 +314,7 @@ public abstract class BaseReceivePack {
        protected BaseReceivePack(Repository into) {
                db = into;
                walk = new RevWalk(db);
+               walk.setRetainBody(false);
 
                TransferConfig tc = db.getConfig().get(TransferConfig.KEY);
                objectChecker = tc.newReceiveObjectChecker();
index 681ae125cbf7a7dbe5fb00fbdc4d452b7934849b..e584440b3f28651df089f6af2170b73368a83bfe 100644 (file)
@@ -200,6 +200,7 @@ class FetchProcess {
                                .setAllowNonFastForwards(true)
                                .setRefLogMessage("fetch", true); //$NON-NLS-1$
                try (RevWalk walk = new RevWalk(transport.local)) {
+                       walk.setRetainBody(false);
                        if (monitor instanceof BatchingProgressMonitor) {
                                ((BatchingProgressMonitor) monitor).setDelayStart(
                                                250, TimeUnit.MILLISECONDS);