From 1ce61dbfbc5153a835d81d517b64445c55a8fa06 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 13 Feb 2010 11:12:15 -0800 Subject: [PATCH] Skip gitlink modes as we can't get a content difference A gitlink mode doesn't have a blob file contents, which means we can't get its hunk edit list to store in the cache, and we most certainly can't read its target as though it were a blob with lines. Currently we are reading a 1 line delta on these files coming back from git-diff-tree because git-diff-tree is doing a pretty-printing that looks like this: diff --git a/modules/parser b/modules/parser -Subproject 88dde83e6f7c09e44f5a03420fcff44145d89b2 +Subproject dabca1dfbedb13a105003a8adcbb777fe87883b This is bogus, and not what we want. So jump out early and cache an empty edit list, since there isnt't really a text line being replaced in this path name. Bug: issue 438 Change-Id: I966de5e6623d32201c6bbd42f388c875a8fc209e Signed-off-by: Shawn O. Pearce --- .../google/gerrit/server/patch/PatchListCacheImpl.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListCacheImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListCacheImpl.java index fa75f42716..8048bdf488 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListCacheImpl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListCacheImpl.java @@ -38,6 +38,7 @@ import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectLoader; import org.eclipse.jgit.lib.ObjectWriter; @@ -191,6 +192,13 @@ public class PatchListCacheImpl implements PatchListCache { return new PatchListEntry(fileHeader, Collections. emptyList()); } + final FileMode oldMode = fileHeader.getOldMode(); + final FileMode newMode = fileHeader.getNewMode(); + + if (oldMode == FileMode.GITLINK || newMode == FileMode.GITLINK) { + return new PatchListEntry(fileHeader, Collections. emptyList()); + } + List edits = fileHeader.toEditList(); // Bypass the longer task of looking for replacement edits if