diff options
author | Ronald Bhuleskar <funronald@google.com> | 2022-08-03 17:16:34 -0400 |
---|---|---|
committer | Ronald Bhuleskar <funronald@google.com> | 2022-08-03 17:16:34 -0400 |
commit | e5e46bc53637f1e1227e81863d403e9fbb84aa19 (patch) | |
tree | 2d54f051bcb0c735de3a167d2896c2de74690ddb /org.eclipse.jgit/src/org/eclipse/jgit | |
parent | ceb51a5e0e9db166e572ea7cd362795b4662b0cd (diff) | |
download | jgit-e5e46bc53637f1e1227e81863d403e9fbb84aa19.tar.gz jgit-e5e46bc53637f1e1227e81863d403e9fbb84aa19.zip |
Revert "Adds FilteredRevCommit that can overwrites its parents in the DAG."
This reverts commit ceb51a5e0e9db166e572ea7cd362795b4662b0cd.
Reason for revert: The change in https://git.eclipse.org/r/c/jgit/jgit/+/194354 broke the egit test [1]. Calling c.getShortMessage() causes an NPE.
[1] https://ci.eclipse.org/egit/job/egit.gerrit/2711/
Change-Id: I411565b6eaa0bbb562cc1c8a355942ff09fd29bc
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FilteredRevCommit.java | 115 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java | 6 |
2 files changed, 3 insertions, 118 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FilteredRevCommit.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FilteredRevCommit.java deleted file mode 100644 index be6e57fd5f..0000000000 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FilteredRevCommit.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2022, Google LLC. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Distribution License v. 1.0 which is available at - * https://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -package org.eclipse.jgit.revwalk; - -import org.eclipse.jgit.lib.ObjectId; - -/** A filtered commit reference that overrides its parent in the DAG. */ -public class FilteredRevCommit extends RevCommit { - private RevCommit[] overriddenParents; - - /** - * Create a new commit reference for the given id. - * - * @param id - * object name for the commit. - */ - public FilteredRevCommit(ObjectId id) { - this(id, NO_PARENTS); - } - - /** - * Create a new commit reference wrapping an underlying commit reference. - * - * @param commit - * commit that is being wrapped - */ - public FilteredRevCommit(RevCommit commit) { - this(commit, NO_PARENTS); - } - - /** - * Create a new commit reference wrapping an underlying commit reference. - * - * @param commit - * commit that is being wrapped - * @param parents - * overridden parents for the commit - */ - public FilteredRevCommit(RevCommit commit, RevCommit... parents) { - this(commit.getId(), parents); - } - - /** - * Create a new commit reference wrapping an underlying commit reference. - * - * @param id - * object name for the commit. - * @param parents - * overridden parents for the commit - */ - public FilteredRevCommit(ObjectId id, RevCommit... parents) { - super(id); - this.overriddenParents = parents; - } - - /** - * Update parents on the commit - * - * @param overriddenParents - * parents to be overwritten - */ - public void setParents(RevCommit... overriddenParents) { - this.overriddenParents = overriddenParents; - } - - /** - * Get the number of parent commits listed in this commit. - * - * @return number of parents; always a positive value but can be 0 if it has - * no parents. - */ - @Override - public int getParentCount() { - return overriddenParents.length; - } - - /** - * Get the nth parent from this commit's parent list. - * - * @param nth - * parent index to obtain. Must be in the range 0 through - * {@link #getParentCount()}-1. - * @return the specified parent. - * @throws java.lang.ArrayIndexOutOfBoundsException - * an invalid parent index was specified. - */ - @Override - public RevCommit getParent(int nth) { - return overriddenParents[nth]; - } - - /** - * Obtain an array of all parents (<b>NOTE - THIS IS NOT A COPY</b>). - * - * <p> - * This method is exposed only to provide very fast, efficient access to - * this commit's parent list. Applications relying on this list should be - * very careful to ensure they do not modify its contents during their use - * of it. - * - * @return the array of parents. - */ - @Override - public RevCommit[] getParents() { - return overriddenParents; - } -} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java index 3318a97a3f..2c88bb872e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteGenerator.java @@ -79,9 +79,9 @@ class RewriteGenerator extends Generator { final RevCommit newp = rewrite(oldp); if (firstParent) { if (newp == null) { - c = new FilteredRevCommit(c.getId()); + c.parents = RevCommit.NO_PARENTS; } else { - c = new FilteredRevCommit(c.getId(), newp); + c.parents = new RevCommit[] { newp }; } return c; } @@ -91,7 +91,7 @@ class RewriteGenerator extends Generator { } } if (rewrote) { - c = new FilteredRevCommit(c.getId(), cleanup(pList)); + c.parents = cleanup(pList); } return c; } |