1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.diff;
11
12 import java.io.IOException;
13 import java.io.OutputStream;
14 import java.security.DigestOutputStream;
15 import java.security.MessageDigest;
16
17 import org.eclipse.jgit.lib.Constants;
18 import org.eclipse.jgit.lib.ObjectId;
19 import org.eclipse.jgit.util.io.NullOutputStream;
20
21
22
23
24 public class PatchIdDiffFormatter extends DiffFormatter {
25
26 private final MessageDigest digest;
27
28
29
30
31 public PatchIdDiffFormatter() {
32 super(new DigestOutputStream(NullOutputStream.INSTANCE,
33 Constants.newMessageDigest()));
34 digest = ((DigestOutputStream) getOutputStream()).getMessageDigest();
35 }
36
37
38
39
40
41
42 public ObjectId getCalulatedPatchId() {
43 return ObjectId.fromRaw(digest.digest());
44 }
45
46
47 @Override
48 protected void writeHunkHeader(int aStartLine, int aEndLine,
49 int bStartLine, int bEndLine) throws IOException {
50
51 }
52
53
54 @Override
55 protected void formatIndexLine(OutputStream o, DiffEntry ent)
56 throws IOException {
57
58 }
59 }