diff options
author | Jonathan Nieder <jrn@google.com> | 2014-06-02 12:03:45 -0700 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2014-06-04 10:26:01 -0400 |
commit | 9b46a47fb7eb68967f1a2550c5393f54d1e255ad (patch) | |
tree | b85b3cce65cafe0734258654da4265808ed639d0 | |
parent | 386dff22716ab33e724ceb9e2de287f43bd88447 (diff) | |
download | jgit-9b46a47fb7eb68967f1a2550c5393f54d1e255ad.tar.gz jgit-9b46a47fb7eb68967f1a2550c5393f54d1e255ad.zip |
blame: Un-break isFile check in tree walk
Originally, blame's walk to find a scapegoat to blame for a file
walking backward from a commit used the test
treeWalk.getFileMode(0).getObjectType() != OBJ_BLOB
to throw out gitlink (submodule) entries. Later, 52500d3264d2 (blame:
Micro optimize blob lookup in tree, 2014-04-17) changed that test to
(treeWalk.getRawMode(0) & TYPE_FILE) != TYPE_FILE
These checks are not the same, though: the older test accepts files
and symlinks, while the newer one accepts files, symlinks, and gitlink
(submodule) entries. This is particularly broken in the submodule
case --- trying to parse the referred-to commit as a blob produces
caught an exception: GET /gerrit/+blame/master/plugins/reviewnotes HTTP/1.1
org.eclipse.jgit.errors.MissingObjectException: Missing blob 61702414c046dd6b811c9137b765f9db422f83db
Stick to just (possibly executable) files instead. Symlinks are not
line-oriented data so blame on a symlink is not likely to be useful.
A quick grep for '& TYPE_' doesn't find any other instances of this
bug.
Change-Id: Iebcc91f1bee3c91adda51dccd6372e8302bf23fe
Signed-off-by: Jonathan Nieder <jrn@google.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java index 8961537ce5..e69cfa9d1c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.blame; import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; import static org.eclipse.jgit.lib.FileMode.TYPE_FILE; +import static org.eclipse.jgit.lib.FileMode.TYPE_MASK; import java.io.IOException; import java.util.Collection; @@ -955,7 +956,7 @@ public class BlameGenerator { } private static final boolean isFile(int rawMode) { - return (rawMode & TYPE_FILE) == TYPE_FILE; + return (rawMode & TYPE_MASK) == TYPE_FILE; } private DiffEntry findRename(RevCommit parent, RevCommit commit, |