1
2
3
4
5
6
7
8
9
10
11
12
13 package org.eclipse.jgit.transport;
14
15 import static org.eclipse.jgit.lib.Constants.R_HEADS;
16 import static org.eclipse.jgit.lib.Constants.R_REMOTES;
17 import static org.eclipse.jgit.lib.Constants.R_TAGS;
18
19 import java.io.IOException;
20 import java.io.Writer;
21
22 import org.eclipse.jgit.lib.ObjectId;
23
24 class FetchHeadRecord {
25 ObjectId newValue;
26
27 boolean notForMerge;
28
29 String sourceName;
30
31 URIish sourceURI;
32
33 void write(Writer pw) throws IOException {
34 final String type;
35 final String name;
36 if (sourceName.startsWith(R_HEADS)) {
37 type = "branch";
38 name = sourceName.substring(R_HEADS.length());
39 } else if (sourceName.startsWith(R_TAGS)) {
40 type = "tag";
41 name = sourceName.substring(R_TAGS.length());
42 } else if (sourceName.startsWith(R_REMOTES)) {
43 type = "remote branch";
44 name = sourceName.substring(R_REMOTES.length());
45 } else {
46 type = "";
47 name = sourceName;
48 }
49
50 pw.write(newValue.name());
51 pw.write('\t');
52 if (notForMerge)
53 pw.write("not-for-merge");
54 pw.write('\t');
55 pw.write(type);
56 pw.write(" '");
57 pw.write(name);
58 pw.write("' of ");
59 pw.write(sourceURI.toString());
60 pw.write("\n");
61 }
62 }