diff --git a/plugins/git4idea/src/git4idea/annotate/GitAnnotationProvider.java b/plugins/git4idea/src/git4idea/annotate/GitAnnotationProvider.java index a073950ed4d3..5ffad8449488 100644 --- a/plugins/git4idea/src/git4idea/annotate/GitAnnotationProvider.java +++ b/plugins/git4idea/src/git4idea/annotate/GitAnnotationProvider.java @@ -270,10 +270,10 @@ public final class GitAnnotationProvider implements AnnotationProviderEx, Cachea if (commitHash.equals(GitRevisionNumber.NOT_COMMITTED_HASH)) { commitHash = null; } - s.spaceToken(); // skip revision line number - String s1 = s.spaceToken(); - int lineNum = Integer.parseInt(s1); - s.nextLine(); + int originalLineNumber = Integer.parseInt(s.spaceToken()); + int lineNumber = Integer.parseInt(s.spaceToken()); + s.nextLine(); // skip number of lines in this group (if present) + // parse commit information LineInfo commit = commits.get(commitHash); if (commit != null || commitHash == null) { @@ -325,7 +325,7 @@ public final class GitAnnotationProvider implements AnnotationProviderEx, Cachea } if (authorDate == null || committerDate == null || filePath == null || authorName == null || authorEmail == null || subject == null) { - throw new VcsException("Output for line " + lineNum + " lacks necessary data"); + throw new VcsException("Output for line " + lineNumber + " lacks necessary data"); } GitRevisionNumber revisionNumber = new GitRevisionNumber(commitHash); @@ -337,14 +337,14 @@ public final class GitAnnotationProvider implements AnnotationProviderEx, Cachea if (previousFilePath != null) previousFilePath = pathInterner.intern(previousFilePath); commit = new LineInfo(myProject, revisionNumber, filePath, committerDate, authorDate, author, subject, - previousRevisionNumber, previousFilePath); + previousRevisionNumber, previousFilePath, lineNumber, originalLineNumber); commits.put(commitHash, commit); } s.nextLine(); int expectedLineNum = lines.size() + 1; - if (lineNum != expectedLineNum) { - throw new VcsException("Adding for info for line " + lineNum + " but we are expecting it to be for " + expectedLineNum); + if (lineNumber != expectedLineNum) { + throw new VcsException("Adding for info for line " + lineNumber + " but we are expecting it to be for " + expectedLineNum); } lines.add(commit); diff --git a/plugins/git4idea/src/git4idea/annotate/GitFileAnnotation.java b/plugins/git4idea/src/git4idea/annotate/GitFileAnnotation.java index cd0be09f9180..994fcdbc8622 100644 --- a/plugins/git4idea/src/git4idea/annotate/GitFileAnnotation.java +++ b/plugins/git4idea/src/git4idea/annotate/GitFileAnnotation.java @@ -270,7 +270,7 @@ public class GitFileAnnotation extends FileAnnotation { } } - static class LineInfo { + public static class LineInfo { @NotNull private final Project myProject; @NotNull private final GitRevisionNumber myRevision; @NotNull private final FilePath myFilePath; @@ -280,16 +280,20 @@ public class GitFileAnnotation extends FileAnnotation { @NotNull private final Date myAuthorDate; @NotNull private final VcsUser myAuthor; @NotNull private final String mySubject; + private final int myLineNumber; + private final int myOriginalLineNumber; LineInfo(@NotNull Project project, - @NotNull GitRevisionNumber revision, - @NotNull FilePath path, - @NotNull Date committerDate, - @NotNull Date authorDate, - @NotNull VcsUser author, - @NotNull String subject, - @Nullable GitRevisionNumber previousRevision, - @Nullable FilePath previousPath) { + @NotNull GitRevisionNumber revision, + @NotNull FilePath path, + @NotNull Date committerDate, + @NotNull Date authorDate, + @NotNull VcsUser author, + @NotNull String subject, + @Nullable GitRevisionNumber previousRevision, + @Nullable FilePath previousPath, + int lineNumber, + int originalLineNumber) { myProject = project; myRevision = revision; myFilePath = path; @@ -299,6 +303,8 @@ public class GitFileAnnotation extends FileAnnotation { myAuthorDate = authorDate; myAuthor = author; mySubject = subject; + myLineNumber = lineNumber; + myOriginalLineNumber = originalLineNumber; } @NotNull @@ -341,6 +347,14 @@ public class GitFileAnnotation extends FileAnnotation { public String getSubject() { return mySubject; } + + public int getLineNumber() { + return myLineNumber; + } + + public int getOriginalLineNumber() { + return myOriginalLineNumber; + } } @NotNull