summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src/org
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2014-04-23 16:33:16 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2014-04-23 16:33:16 -0400
commit62bbde33930226861c161a9719aaac66a7538d81 (patch)
treece44f24a5996baf12d003a070463d3a2e0fe576f /org.eclipse.jgit.pgm/src/org
parent616ebfc821f8637c54b60ba297f7be9d57cbf913 (diff)
parenta622451ac9e84fab150efb920f8e4ee9796be067 (diff)
downloadjgit-62bbde33930226861c161a9719aaac66a7538d81.tar.gz
jgit-62bbde33930226861c161a9719aaac66a7538d81.zip
Merge "blame: Format commit and author only once per range"
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java36
1 files changed, 23 insertions, 13 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java
index 307d947f39..271e934b45 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java
@@ -222,19 +222,29 @@ class Blame extends TextBuiltin {
String authorFmt = MessageFormat.format(" (%-{0}s %{1}s", //$NON-NLS-1$
valueOf(authorWidth), valueOf(dateWidth));
- for (int line = begin; line < end; line++) {
- outw.print(abbreviate(blame.getSourceCommit(line)));
- if (showSourcePath)
- outw.format(pathFmt, path(line));
- if (showSourceLine)
- outw.format(numFmt, valueOf(blame.getSourceLine(line) + 1));
- if (!noAuthor)
- outw.format(authorFmt, author(line), date(line));
- outw.format(lineFmt, valueOf(line + 1));
- outw.flush();
- blame.getResultContents().writeLine(outs, line);
- outs.flush();
- outw.print('\n');
+ for (int line = begin; line < end;) {
+ RevCommit c = blame.getSourceCommit(line);
+ String commit = abbreviate(c);
+ String author = null;
+ String date = null;
+ if (!noAuthor) {
+ author = author(line);
+ date = date(line);
+ }
+ do {
+ outw.print(commit);
+ if (showSourcePath)
+ outw.format(pathFmt, path(line));
+ if (showSourceLine)
+ outw.format(numFmt, valueOf(blame.getSourceLine(line) + 1));
+ if (!noAuthor)
+ outw.format(authorFmt, author, date);
+ outw.format(lineFmt, valueOf(line + 1));
+ outw.flush();
+ blame.getResultContents().writeLine(outs, line);
+ outs.flush();
+ outw.print('\n');
+ } while (++line < end && blame.getSourceCommit(line) == c);
}
} finally {
generator.release();