diff options
author | Dave Borowitz <dborowitz@google.com> | 2013-05-03 11:18:53 -0700 |
---|---|---|
committer | Shawn Pearce <spearce@spearce.org> | 2013-05-05 08:41:09 -0700 |
commit | 0bdf030b26248c77806ababd757dad58f1344e57 (patch) | |
tree | 8427e323090a976f41196cf8705a05259233354e /org.eclipse.jgit.pgm/src | |
parent | b8e763fc19fd20d1c846bf538532907cf542ce46 (diff) | |
download | jgit-0bdf030b26248c77806ababd757dad58f1344e57.tar.gz jgit-0bdf030b26248c77806ababd757dad58f1344e57.zip |
Require a DiffConfig when creating a FollowFilter
The various rename detection options are an inherent part of the
filter, similar to the path being followed.
This fixes a potential NPE when a RevWalk with a FollowFilter is
created without a Repository, since the old code path tried to get
the DiffConfig from the RevWalk's possibly-missing repository.
Change-Id: Idb273d5a92849b42935ac14eed73b796b80aad50
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java index 8543dcb916..92a22b00b3 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java @@ -50,6 +50,7 @@ import java.util.List; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; +import org.eclipse.jgit.diff.DiffConfig; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; @@ -117,9 +118,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { } @Option(name = "--follow", metaVar = "metaVar_path") - void follow(final String path) { - pathFilter = FollowFilter.create(path); - } + private String followPath; @Argument(index = 0, metaVar = "metaVar_commitish") private final List<RevCommit> commits = new ArrayList<RevCommit>(); @@ -150,11 +149,14 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { for (final RevSort s : sorting) walk.sort(s, true); - if (pathFilter instanceof FollowFilter) - walk.setTreeFilter(pathFilter); - else if (pathFilter != TreeFilter.ALL) + if (pathFilter == TreeFilter.ALL) { + if (followPath != null) + walk.setTreeFilter(FollowFilter.create(followPath, + db.getConfig().get(DiffConfig.KEY))); + } else if (pathFilter != TreeFilter.ALL) { walk.setTreeFilter(AndTreeFilter.create(pathFilter, TreeFilter.ANY_DIFF)); + } if (revLimiter.size() == 1) walk.setRevFilter(revLimiter.get(0)); |