Bump JGit to stable-6.10 HtmlDiffFormatter is updated to override the new 'writeHunkHeader' method which adds function names to the hunk headers. $ git log --oneline --no-merges --no-decorate 692ccfc0c...2c86ef242 469928898 Add numberOfObjectsSinceBitmap to RepoStatistics 4b3c5194a Support built-in diff drivers for hunk header function names 592a75800 Don't fail when trying to prune pack which is already gone f7a4dd035 Rename numberOfPackFilesAfterBitmap to numberOfPackFilesSinceBitmap d34f8b523 Replace custom encoder Constants#encodeASCII by JDK implementation e8c414b9c Replace custom encoder `Constants#encode` by JDK implementation 93ede18ff Add `numberOfPackFilesAfterBitmap` to RepoStatistics 958d05392 Enhance CommitBuilder#parent to tolerate null parent 3a7a9cb0e ResolveMerger: Allow setting the TreeWalk AttributesNodeProvider 4f48a5b1e Add Union merge strategy support eeccc5a92 Update Apache sshd to 2.14.0 ed0835856 LfsConnectionFactoryTest: remove unnecessary cast 72652ff65 JSchSshProtocol2Test: remove unnecessary cast a2e477296 ApacheSshProtocol2Test: remove unnecessary cast 9e1cd8aec NoteMapMerger: remove unnecessary cast 56a5db65b AdvertisedRequestValidator: fix WantNotValidException caused by race Release-Notes: Hunk headers will now show function names for supported built-in diff drivers Change-Id: I186730a06bbcd9fe67c576380d5d14de3d41dab3
diff --git a/java/com/google/gitiles/HtmlDiffFormatter.java b/java/com/google/gitiles/HtmlDiffFormatter.java index 76df04c..5d5a3b8 100644 --- a/java/com/google/gitiles/HtmlDiffFormatter.java +++ b/java/com/google/gitiles/HtmlDiffFormatter.java
@@ -25,6 +25,7 @@ import java.util.List; import java.util.Map; import org.apache.commons.text.StringEscapeUtils; +import org.eclipse.jgit.diff.DiffDriver; import org.eclipse.jgit.diff.DiffEntry; import org.eclipse.jgit.diff.DiffEntry.ChangeType; import org.eclipse.jgit.diff.DiffFormatter; @@ -68,6 +69,12 @@ @Override public void format(FileHeader hdr, RawText a, RawText b) throws IOException { + format(hdr, a, b, null); + } + + @Override + public void format(FileHeader hdr, RawText a, RawText b, DiffDriver diffDriver) + throws IOException { int start = hdr.getStartOffset(); int end = hdr.getEndOffset(); if (!hdr.getHunks().isEmpty()) { @@ -77,7 +84,7 @@ if (hdr.getPatchType() == PatchType.UNIFIED) { getOutputStream().write(DIFF_BEGIN); - format(hdr.toEditList(), a, b); + format(hdr.toEditList(), a, b, diffDriver); getOutputStream().write(DIFF_END); } } @@ -129,9 +136,16 @@ @Override protected void writeHunkHeader(int aStartLine, int aEndLine, int bStartLine, int bEndLine) throws IOException { + writeHunkHeader(aStartLine, aEndLine, bStartLine, bEndLine, null); + } + + @Override + protected void writeHunkHeader( + int aStartLine, int aEndLine, int bStartLine, int bEndLine, String funcName) + throws IOException { getOutputStream().write(HUNK_BEGIN); - // TODO(sop): If hunk header starts including method names, escape it. - super.writeHunkHeader(aStartLine, aEndLine, bStartLine, bEndLine); + super.writeHunkHeader( + aStartLine, aEndLine, bStartLine, bEndLine, StringEscapeUtils.escapeHtml4(funcName)); getOutputStream().write(HUNK_END); }
diff --git a/modules/jgit b/modules/jgit index 692ccfc..2c86ef2 160000 --- a/modules/jgit +++ b/modules/jgit
@@ -1 +1 @@ -Subproject commit 692ccfc0c29d53afc7a0b82f41efcd999ed217b0 +Subproject commit 2c86ef2427ad3c65bfa4dee90311408255869638