1
2
3
4
5
6
7
8
9
10
11
12 package org.eclipse.jgit.merge;
13
14 import java.io.IOException;
15
16 import org.eclipse.jgit.lib.Config;
17 import org.eclipse.jgit.lib.ObjectId;
18 import org.eclipse.jgit.lib.ObjectInserter;
19 import org.eclipse.jgit.lib.Repository;
20
21
22
23
24
25
26
27
28 public class StrategyOneSided extends MergeStrategy {
29 private final String strategyName;
30
31 private final int treeIndex;
32
33
34
35
36
37
38
39
40
41 protected StrategyOneSided(String name, int index) {
42 strategyName = name;
43 treeIndex = index;
44 }
45
46
47 @Override
48 public String getName() {
49 return strategyName;
50 }
51
52
53 @Override
54 public Merger newMerger(Repository db) {
55 return new OneSide(db, treeIndex);
56 }
57
58
59 @Override
60 public Merger newMerger(Repository db, boolean inCore) {
61 return new OneSide(db, treeIndex);
62 }
63
64
65 @Override
66 public Merger newMerger(ObjectInserter inserter, Config config) {
67 return new OneSide(inserter, treeIndex);
68 }
69
70 static class OneSide extends Merger {
71 private final int treeIndex;
72
73 protected OneSide(Repository local, int index) {
74 super(local);
75 treeIndex = index;
76 }
77
78 protected OneSide(ObjectInserter inserter, int index) {
79 super(inserter);
80 treeIndex = index;
81 }
82
83 @Override
84 protected boolean mergeImpl() throws IOException {
85 return treeIndex < sourceTrees.length;
86 }
87
88 @Override
89 public ObjectId getResultTreeId() {
90 return sourceTrees[treeIndex];
91 }
92
93 @Override
94 public ObjectId getBaseCommitId() {
95 return null;
96 }
97 }
98 }