1
2
3
4
5
6
7
8
9
10
11
12 package org.eclipse.jgit.internal.storage.file;
13
14 import java.io.IOException;
15 import java.io.OutputStream;
16
17 import org.eclipse.jgit.internal.JGitText;
18 import org.eclipse.jgit.transport.PackedObjectInfo;
19 import org.eclipse.jgit.util.NB;
20
21
22
23
24
25
26
27 class PackIndexWriterV1 extends PackIndexWriter {
28 static boolean canStore(PackedObjectInfo oe) {
29
30
31 return oe.getOffset() >>> 1 < Integer.MAX_VALUE;
32 }
33
34 PackIndexWriterV1(final OutputStream dst) {
35 super(dst);
36 }
37
38
39 @Override
40 protected void writeImpl() throws IOException {
41 writeFanOutTable();
42
43 for (PackedObjectInfo oe : entries) {
44 if (!canStore(oe))
45 throw new IOException(JGitText.get().packTooLargeForIndexVersion1);
46 NB.encodeInt32(tmp, 0, (int) oe.getOffset());
47 oe.copyRawTo(tmp, 4);
48 out.write(tmp);
49 }
50
51 writeChecksumFooter();
52 }
53 }