diff options
author | Ronald Bhuleskar <funronald@google.com> | 2023-07-19 14:25:46 -0700 |
---|---|---|
committer | Ronald Bhuleskar <funronald@google.com> | 2023-07-24 19:42:51 -0400 |
commit | ec3d919aa5ae891edc3d5e7eafe09cf272801878 (patch) | |
tree | b1d883198f8e0caeaca5af98b0500ce73c5a474a /org.eclipse.jgit | |
parent | 3b77e33ad8f8206ff30a66ea2d15c3e1f1b731b2 (diff) | |
download | jgit-ec3d919aa5ae891edc3d5e7eafe09cf272801878.tar.gz jgit-ec3d919aa5ae891edc3d5e7eafe09cf272801878.zip |
Identify a commit that generates a diffEntry on a rename Event.
When using FollowFilter's rename callback, a callback is generated with the diff. The caller that is interested in the renames knows what the diff's are but have no idea what commit generated that diff.
This will allow FollowFilter's rename callback to track diffEntry for a given commit.
Change-Id: If1e63ccd19fdcb9c58c59137110fe24e0ce023d2
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RenameCallback.java | 22 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java | 8 |
2 files changed, 27 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RenameCallback.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RenameCallback.java index ba3399ce9f..9856f2c252 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RenameCallback.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RenameCallback.java @@ -23,8 +23,30 @@ public abstract class RenameCallback { * Called whenever a diff was found that is actually a rename or copy of a * file. * + * <p>Subclass of this class have to override this to receive diffEntry for + * the rename. + * * @param entry * the entry representing the rename/copy */ public abstract void renamed(DiffEntry entry); + + /** + * Called whenever a diff was found that is actually a rename or copy of a + * file along with the commit that caused it. + * + * <p>Subclass of this class have an option to override this if it wants to + * know what commit generated the diffEntry. Otherwise defaults to the + * {@link RenameCallback#renamed(DiffEntry)} function. + * + * @param entry + * the entry representing the rename/copy + * @param commit + * commit at which callback occurred + * + * @since 6.7 + */ + public void renamed(DiffEntry entry, RevCommit commit) { + renamed(entry); + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java index 017a825ac6..410c36b16a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java @@ -185,7 +185,8 @@ public class TreeRevFilter extends RevFilter { // commit. We need to update our filter to its older // name, if we can discover it. Find out what that is. // - updateFollowFilter(trees, ((FollowFilter) tw.getFilter()).cfg); + updateFollowFilter(trees, ((FollowFilter) tw.getFilter()).cfg, + c); } return true; } else if (nParents == 0) { @@ -313,7 +314,8 @@ public class TreeRevFilter extends RevFilter { return changedPathFilterNegative; } - private void updateFollowFilter(ObjectId[] trees, DiffConfig cfg) + private void updateFollowFilter(ObjectId[] trees, DiffConfig cfg, + RevCommit commit) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { TreeWalk tw = pathFilter; @@ -332,7 +334,7 @@ public class TreeRevFilter extends RevFilter { newFilter = FollowFilter.create(ent.getOldPath(), cfg); RenameCallback callback = oldFilter.getRenameCallback(); if (callback != null) { - callback.renamed(ent); + callback.renamed(ent, commit); // forward the callback to the new follow filter ((FollowFilter) newFilter).setRenameCallback(callback); } |