|
|
|
@ -51,6 +51,9 @@ import java.util.HashMap;
|
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
import org.eclipse.jgit.annotations.NonNull; |
|
|
|
|
import org.eclipse.jgit.annotations.Nullable; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Abstraction of name to {@link ObjectId} mapping. |
|
|
|
|
* <p> |
|
|
|
@ -132,6 +135,7 @@ public abstract class RefDatabase {
|
|
|
|
|
* @since 2.3 |
|
|
|
|
* @see #isNameConflicting(String) |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public Collection<String> getConflictingNames(String name) |
|
|
|
|
throws IOException { |
|
|
|
|
Map<String, Ref> allRefs = getRefs(ALL); |
|
|
|
@ -169,6 +173,7 @@ public abstract class RefDatabase {
|
|
|
|
|
* @throws IOException |
|
|
|
|
* the reference space cannot be accessed. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public abstract RefUpdate newUpdate(String name, boolean detach) |
|
|
|
|
throws IOException; |
|
|
|
|
|
|
|
|
@ -183,6 +188,7 @@ public abstract class RefDatabase {
|
|
|
|
|
* @throws IOException |
|
|
|
|
* the reference space cannot be accessed. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public abstract RefRename newRename(String fromName, String toName) |
|
|
|
|
throws IOException; |
|
|
|
|
|
|
|
|
@ -193,6 +199,7 @@ public abstract class RefDatabase {
|
|
|
|
|
* |
|
|
|
|
* @return a new batch update object. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public BatchRefUpdate newBatchUpdate() { |
|
|
|
|
return new BatchRefUpdate(this); |
|
|
|
|
} |
|
|
|
@ -223,6 +230,7 @@ public abstract class RefDatabase {
|
|
|
|
|
* @throws IOException |
|
|
|
|
* the reference space cannot be accessed. |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
public abstract Ref getRef(String name) throws IOException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -238,6 +246,7 @@ public abstract class RefDatabase {
|
|
|
|
|
* the reference space cannot be accessed. |
|
|
|
|
* @since 4.1 |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
public Ref exactRef(String name) throws IOException { |
|
|
|
|
Ref ref = getRef(name); |
|
|
|
|
if (ref == null || !name.equals(ref.getName())) { |
|
|
|
@ -261,6 +270,7 @@ public abstract class RefDatabase {
|
|
|
|
|
* the reference space cannot be accessed. |
|
|
|
|
* @since 4.1 |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public Map<String, Ref> exactRef(String... refs) throws IOException { |
|
|
|
|
Map<String, Ref> result = new HashMap<>(refs.length); |
|
|
|
|
for (String name : refs) { |
|
|
|
@ -285,6 +295,7 @@ public abstract class RefDatabase {
|
|
|
|
|
* the reference space cannot be accessed. |
|
|
|
|
* @since 4.1 |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
public Ref firstExactRef(String... refs) throws IOException { |
|
|
|
|
for (String name : refs) { |
|
|
|
|
Ref ref = exactRef(name); |
|
|
|
@ -308,6 +319,7 @@ public abstract class RefDatabase {
|
|
|
|
|
* @throws IOException |
|
|
|
|
* the reference space cannot be accessed. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public abstract Map<String, Ref> getRefs(String prefix) throws IOException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -322,6 +334,7 @@ public abstract class RefDatabase {
|
|
|
|
|
* @throws IOException |
|
|
|
|
* the reference space cannot be accessed. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public abstract List<Ref> getAdditionalRefs() throws IOException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -338,10 +351,11 @@ public abstract class RefDatabase {
|
|
|
|
|
* @return {@code ref} if {@code ref.isPeeled()} is true; otherwise a new |
|
|
|
|
* Ref object representing the same data as Ref, but isPeeled() will |
|
|
|
|
* be true and getPeeledObjectId() will contain the peeled object |
|
|
|
|
* (or null). |
|
|
|
|
* (or {@code null}). |
|
|
|
|
* @throws IOException |
|
|
|
|
* the reference space or object space cannot be accessed. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public abstract Ref peel(Ref ref) throws IOException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -365,9 +379,10 @@ public abstract class RefDatabase {
|
|
|
|
|
* @param name |
|
|
|
|
* short name of ref to find, e.g. "master" to find |
|
|
|
|
* "refs/heads/master" in map. |
|
|
|
|
* @return The first ref matching the name, or null if not found. |
|
|
|
|
* @return The first ref matching the name, or {@code null} if not found. |
|
|
|
|
* @since 3.4 |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
public static Ref findRef(Map<String, Ref> map, String name) { |
|
|
|
|
for (String prefix : SEARCH_PATH) { |
|
|
|
|
String fullname = prefix + name; |
|
|
|
|