|
|
|
@ -83,7 +83,6 @@ import org.eclipse.jgit.events.IndexChangedListener;
|
|
|
|
|
import org.eclipse.jgit.events.ListenerList; |
|
|
|
|
import org.eclipse.jgit.events.RepositoryEvent; |
|
|
|
|
import org.eclipse.jgit.internal.JGitText; |
|
|
|
|
import org.eclipse.jgit.internal.storage.file.GC; |
|
|
|
|
import org.eclipse.jgit.revwalk.RevBlob; |
|
|
|
|
import org.eclipse.jgit.revwalk.RevCommit; |
|
|
|
|
import org.eclipse.jgit.revwalk.RevObject; |
|
|
|
@ -106,9 +105,9 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
* A repository holds all objects and refs used for managing source code (could |
|
|
|
|
* be any type of file, but source code is what SCM's are typically used for). |
|
|
|
|
* <p> |
|
|
|
|
* The thread-safety of a {@link Repository} very much depends on the concrete |
|
|
|
|
* implementation. Applications working with a generic {@code Repository} type |
|
|
|
|
* must not assume the instance is thread-safe. |
|
|
|
|
* The thread-safety of a {@link org.eclipse.jgit.lib.Repository} very much |
|
|
|
|
* depends on the concrete implementation. Applications working with a generic |
|
|
|
|
* {@code Repository} type must not assume the instance is thread-safe. |
|
|
|
|
* <ul> |
|
|
|
|
* <li>{@code FileRepository} is thread-safe. |
|
|
|
|
* <li>{@code DfsRepository} thread-safety is determined by its subclass. |
|
|
|
@ -129,7 +128,11 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
"(^|/)(aux|com[1-9]|con|lpt[1-9]|nul|prn)(\\.[^/]*)?", //$NON-NLS-1$
|
|
|
|
|
Pattern.CASE_INSENSITIVE); |
|
|
|
|
|
|
|
|
|
/** @return the global listener list observing all events in this JVM. */ |
|
|
|
|
/** |
|
|
|
|
* Get the global listener list observing all events in this JVM. |
|
|
|
|
* |
|
|
|
|
* @return the global listener list observing all events in this JVM. |
|
|
|
|
*/ |
|
|
|
|
public static ListenerList getGlobalListenerList() { |
|
|
|
|
return globalListeners; |
|
|
|
|
} |
|
|
|
@ -166,7 +169,11 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
indexFile = options.getIndexFile(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @return listeners observing only events on this repository. */ |
|
|
|
|
/** |
|
|
|
|
* Get listeners observing only events on this repository. |
|
|
|
|
* |
|
|
|
|
* @return listeners observing only events on this repository. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public ListenerList getListenerList() { |
|
|
|
|
return myListeners; |
|
|
|
@ -193,7 +200,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* Repository with working tree is created using this method. This method is |
|
|
|
|
* the same as {@code create(false)}. |
|
|
|
|
* |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @see #create(boolean) |
|
|
|
|
*/ |
|
|
|
|
public void create() throws IOException { |
|
|
|
@ -207,12 +214,14 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @param bare |
|
|
|
|
* if true, a bare repository (a repository without a working |
|
|
|
|
* directory) is created. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* in case of IO problem |
|
|
|
|
*/ |
|
|
|
|
public abstract void create(boolean bare) throws IOException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get local metadata directory |
|
|
|
|
* |
|
|
|
|
* @return local metadata directory; {@code null} if repository isn't local. |
|
|
|
|
*/ |
|
|
|
|
/* |
|
|
|
@ -227,44 +236,64 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the object database which stores this repository's data. |
|
|
|
|
* |
|
|
|
|
* @return the object database which stores this repository's data. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public abstract ObjectDatabase getObjectDatabase(); |
|
|
|
|
|
|
|
|
|
/** @return a new inserter to create objects in {@link #getObjectDatabase()} */ |
|
|
|
|
/** |
|
|
|
|
* Create a new inserter to create objects in {@link #getObjectDatabase()}. |
|
|
|
|
* |
|
|
|
|
* @return a new inserter to create objects in {@link #getObjectDatabase()}. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public ObjectInserter newObjectInserter() { |
|
|
|
|
return getObjectDatabase().newInserter(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @return a new reader to read objects from {@link #getObjectDatabase()} */ |
|
|
|
|
/** |
|
|
|
|
* Create a new reader to read objects from {@link #getObjectDatabase()}. |
|
|
|
|
* |
|
|
|
|
* @return a new reader to read objects from {@link #getObjectDatabase()}. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public ObjectReader newObjectReader() { |
|
|
|
|
return getObjectDatabase().newReader(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @return the reference database which stores the reference namespace. */ |
|
|
|
|
/** |
|
|
|
|
* Get the reference database which stores the reference namespace. |
|
|
|
|
* |
|
|
|
|
* @return the reference database which stores the reference namespace. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public abstract RefDatabase getRefDatabase(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the configuration of this repository |
|
|
|
|
* Get the configuration of this repository. |
|
|
|
|
* |
|
|
|
|
* @return the configuration of this repository. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public abstract StoredConfig getConfig(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return a new {@link AttributesNodeProvider}. This |
|
|
|
|
* {@link AttributesNodeProvider} is lazy loaded only once. It means |
|
|
|
|
* that it will not be updated after loading. Prefer creating new |
|
|
|
|
* instance for each use. |
|
|
|
|
* Create a new {@link org.eclipse.jgit.attributes.AttributesNodeProvider}. |
|
|
|
|
* |
|
|
|
|
* @return a new {@link org.eclipse.jgit.attributes.AttributesNodeProvider}. |
|
|
|
|
* This {@link org.eclipse.jgit.attributes.AttributesNodeProvider} |
|
|
|
|
* is lazy loaded only once. It means that it will not be updated |
|
|
|
|
* after loading. Prefer creating new instance for each use. |
|
|
|
|
* @since 4.2 |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public abstract AttributesNodeProvider createAttributesNodeProvider(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the used file system abstraction. |
|
|
|
|
* |
|
|
|
|
* @return the used file system abstraction, or or {@code null} if |
|
|
|
|
* repository isn't local. |
|
|
|
|
*/ |
|
|
|
@ -280,7 +309,11 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Whether the specified object is stored in this repo or any of the known |
|
|
|
|
* shared repositories. |
|
|
|
|
* |
|
|
|
|
* @param objectId |
|
|
|
|
* a {@link org.eclipse.jgit.lib.AnyObjectId} object. |
|
|
|
|
* @return true if the specified object is stored in this repo or any of the |
|
|
|
|
* known shared repositories. |
|
|
|
|
*/ |
|
|
|
@ -301,10 +334,11 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* |
|
|
|
|
* @param objectId |
|
|
|
|
* identity of the object to open. |
|
|
|
|
* @return a {@link ObjectLoader} for accessing the object. |
|
|
|
|
* @throws MissingObjectException |
|
|
|
|
* @return a {@link org.eclipse.jgit.lib.ObjectLoader} for accessing the |
|
|
|
|
* object. |
|
|
|
|
* @throws org.eclipse.jgit.errors.MissingObjectException |
|
|
|
|
* the object does not exist. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* the object store cannot be accessed. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
@ -323,16 +357,17 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* identity of the object to open. |
|
|
|
|
* @param typeHint |
|
|
|
|
* hint about the type of object being requested, e.g. |
|
|
|
|
* {@link Constants#OBJ_BLOB}; {@link ObjectReader#OBJ_ANY} if |
|
|
|
|
* the object type is not known, or does not matter to the |
|
|
|
|
* caller. |
|
|
|
|
* @return a {@link ObjectLoader} for accessing the object. |
|
|
|
|
* @throws MissingObjectException |
|
|
|
|
* {@link org.eclipse.jgit.lib.Constants#OBJ_BLOB}; |
|
|
|
|
* {@link org.eclipse.jgit.lib.ObjectReader#OBJ_ANY} if the |
|
|
|
|
* object type is not known, or does not matter to the caller. |
|
|
|
|
* @return a {@link org.eclipse.jgit.lib.ObjectLoader} for accessing the |
|
|
|
|
* object. |
|
|
|
|
* @throws org.eclipse.jgit.errors.MissingObjectException |
|
|
|
|
* the object does not exist. |
|
|
|
|
* @throws IncorrectObjectTypeException |
|
|
|
|
* @throws org.eclipse.jgit.errors.IncorrectObjectTypeException |
|
|
|
|
* typeHint was not OBJ_ANY, and the object's actual type does |
|
|
|
|
* not match typeHint. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* the object store cannot be accessed. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
@ -350,7 +385,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @return an update command. The caller must finish populating this command |
|
|
|
|
* and then invoke one of the update methods to actually make a |
|
|
|
|
* change. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* a symbolic ref was passed in and could not be resolved back |
|
|
|
|
* to the base ref, as the symbolic ref could not be read. |
|
|
|
|
*/ |
|
|
|
@ -369,7 +404,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @return an update command. The caller must finish populating this command |
|
|
|
|
* and then invoke one of the update methods to actually make a |
|
|
|
|
* change. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* a symbolic ref was passed in and could not be resolved back |
|
|
|
|
* to the base ref, as the symbolic ref could not be read. |
|
|
|
|
*/ |
|
|
|
@ -386,9 +421,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @param toRef |
|
|
|
|
* name of ref to rename to |
|
|
|
|
* @return an update command that knows how to rename a branch to another. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* the rename could not be performed. |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public RefRename renameRef(final String fromRef, final String toRef) throws IOException { |
|
|
|
@ -432,17 +466,17 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* A git object references expression |
|
|
|
|
* @return an ObjectId or {@code null} if revstr can't be resolved to any |
|
|
|
|
* ObjectId |
|
|
|
|
* @throws AmbiguousObjectException |
|
|
|
|
* @throws org.eclipse.jgit.errors.AmbiguousObjectException |
|
|
|
|
* {@code revstr} contains an abbreviated ObjectId and this |
|
|
|
|
* repository contains more than one object which match to the |
|
|
|
|
* input abbreviation. |
|
|
|
|
* @throws IncorrectObjectTypeException |
|
|
|
|
* @throws org.eclipse.jgit.errors.IncorrectObjectTypeException |
|
|
|
|
* the id parsed does not meet the type required to finish |
|
|
|
|
* applying the operators in the expression. |
|
|
|
|
* @throws RevisionSyntaxException |
|
|
|
|
* @throws org.eclipse.jgit.errors.RevisionSyntaxException |
|
|
|
|
* the expression is not supported by this implementation, or |
|
|
|
|
* does not meet the standard syntax. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* on serious errors |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
@ -466,11 +500,11 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* Thus this method can be used to process an expression to a method that |
|
|
|
|
* expects a branch or revision id. |
|
|
|
|
* |
|
|
|
|
* @param revstr |
|
|
|
|
* @param revstr a {@link java.lang.String} object. |
|
|
|
|
* @return object id or ref name from resolved expression or {@code null} if |
|
|
|
|
* given expression cannot be resolved |
|
|
|
|
* @throws AmbiguousObjectException |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws org.eclipse.jgit.errors.AmbiguousObjectException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
public String simplify(final String revstr) |
|
|
|
@ -889,12 +923,18 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** Increment the use counter by one, requiring a matched {@link #close()}. */ |
|
|
|
|
/** |
|
|
|
|
* Increment the use counter by one, requiring a matched {@link #close()}. |
|
|
|
|
*/ |
|
|
|
|
public void incrementOpen() { |
|
|
|
|
useCnt.incrementAndGet(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** Decrement the use count, and maybe close resources. */ |
|
|
|
|
/** |
|
|
|
|
* {@inheritDoc} |
|
|
|
|
* <p> |
|
|
|
|
* Decrement the use count, and maybe close resources. |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void close() { |
|
|
|
|
int newCount = useCnt.decrementAndGet(); |
|
|
|
@ -930,6 +970,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
getRefDatabase().close(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
|
@Override |
|
|
|
|
@NonNull |
|
|
|
|
public String toString() { |
|
|
|
@ -959,7 +1000,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* an ObjectId in hex format if the current branch is detached, or |
|
|
|
|
* {@code null} if the repository is corrupt and has no HEAD |
|
|
|
|
* reference. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
public String getFullBranch() throws IOException { |
|
|
|
@ -987,7 +1028,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @return name of current branch (for example {@code master}), an ObjectId |
|
|
|
|
* in hex format if the current branch is detached, or {@code null} |
|
|
|
|
* if the repository is corrupt and has no HEAD reference. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
public String getBranch() throws IOException { |
|
|
|
@ -1020,7 +1061,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* "master" which is is automatically expanded to |
|
|
|
|
* "refs/heads/master" if "refs/heads/master" already exists. |
|
|
|
|
* @return the Ref with the given name, or {@code null} if it does not exist |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @deprecated Use {@link #exactRef(String)} or {@link #findRef(String)} |
|
|
|
|
* instead. |
|
|
|
|
*/ |
|
|
|
@ -1038,7 +1079,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* form; e.g., "master" is not automatically expanded to |
|
|
|
|
* "refs/heads/master". |
|
|
|
|
* @return the Ref with the given name, or {@code null} if it does not exist |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @since 4.2 |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
@ -1054,7 +1095,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* "master" which is is automatically expanded to |
|
|
|
|
* "refs/heads/master" if "refs/heads/master" already exists. |
|
|
|
|
* @return the Ref with the given name, or {@code null} if it does not exist |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @since 4.2 |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
@ -1063,6 +1104,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get mutable map of all known refs |
|
|
|
|
* |
|
|
|
|
* @return mutable map of all known refs (heads, tags, remotes). |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
@ -1075,6 +1118,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get mutable map of all tags |
|
|
|
|
* |
|
|
|
|
* @return mutable map of all tags; key is short tag name ("v1.0") and value |
|
|
|
|
* of the entry contains the ref with the full tag name |
|
|
|
|
* ("refs/tags/v1.0"). |
|
|
|
@ -1092,7 +1137,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* Peel a possibly unpeeled reference to an annotated tag. |
|
|
|
|
* <p> |
|
|
|
|
* If the ref cannot be peeled (as it does not refer to an annotated tag) |
|
|
|
|
* the peeled id stays null, but {@link Ref#isPeeled()} will be true. |
|
|
|
|
* the peeled id stays null, but {@link org.eclipse.jgit.lib.Ref#isPeeled()} |
|
|
|
|
* will be true. |
|
|
|
|
* |
|
|
|
|
* @param ref |
|
|
|
|
* The ref to peel |
|
|
|
@ -1114,6 +1160,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get a map with all objects referenced by a peeled ref. |
|
|
|
|
* |
|
|
|
|
* @return a map with all objects referenced by a peeled ref. |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
@ -1141,9 +1189,11 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the index file location or {@code null} if repository isn't local. |
|
|
|
|
* |
|
|
|
|
* @return the index file location or {@code null} if repository isn't |
|
|
|
|
* local. |
|
|
|
|
* @throws NoWorkTreeException |
|
|
|
|
* @throws org.eclipse.jgit.errors.NoWorkTreeException |
|
|
|
|
* if this is bare, which implies it has no working directory. |
|
|
|
|
* See {@link #isBare()}. |
|
|
|
|
*/ |
|
|
|
@ -1163,11 +1213,11 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @param id |
|
|
|
|
* name of the commit object. |
|
|
|
|
* @return reference to the commit object. Never null. |
|
|
|
|
* @throws MissingObjectException |
|
|
|
|
* @throws org.eclipse.jgit.errors.MissingObjectException |
|
|
|
|
* the supplied commit does not exist. |
|
|
|
|
* @throws IncorrectObjectTypeException |
|
|
|
|
* @throws org.eclipse.jgit.errors.IncorrectObjectTypeException |
|
|
|
|
* the supplied id is not a commit or an annotated tag. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* a pack file or loose object could not be read. |
|
|
|
|
* @since 4.8 |
|
|
|
|
*/ |
|
|
|
@ -1190,12 +1240,12 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* |
|
|
|
|
* @return a cache representing the contents of the specified index file (if |
|
|
|
|
* it exists) or an empty cache if the file does not exist. |
|
|
|
|
* @throws NoWorkTreeException |
|
|
|
|
* @throws org.eclipse.jgit.errors.NoWorkTreeException |
|
|
|
|
* if this is bare, which implies it has no working directory. |
|
|
|
|
* See {@link #isBare()}. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* the index file is present but could not be read. |
|
|
|
|
* @throws CorruptObjectException |
|
|
|
|
* @throws org.eclipse.jgit.errors.CorruptObjectException |
|
|
|
|
* the index file is using a format or extension that this |
|
|
|
|
* library does not support. |
|
|
|
|
*/ |
|
|
|
@ -1214,13 +1264,13 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* |
|
|
|
|
* @return a cache representing the contents of the specified index file (if |
|
|
|
|
* it exists) or an empty cache if the file does not exist. |
|
|
|
|
* @throws NoWorkTreeException |
|
|
|
|
* @throws org.eclipse.jgit.errors.NoWorkTreeException |
|
|
|
|
* if this is bare, which implies it has no working directory. |
|
|
|
|
* See {@link #isBare()}. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* the index file is present but could not be read, or the lock |
|
|
|
|
* could not be obtained. |
|
|
|
|
* @throws CorruptObjectException |
|
|
|
|
* @throws org.eclipse.jgit.errors.CorruptObjectException |
|
|
|
|
* the index file is using a format or extension that this |
|
|
|
|
* library does not support. |
|
|
|
|
*/ |
|
|
|
@ -1239,7 +1289,9 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return an important state |
|
|
|
|
* Get the repository state |
|
|
|
|
* |
|
|
|
|
* @return the repository state |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
|
public RepositoryState getRepositoryState() { |
|
|
|
@ -1320,8 +1372,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* |
|
|
|
|
* For portability reasons '\' is excluded |
|
|
|
|
* |
|
|
|
|
* @param refName |
|
|
|
|
* |
|
|
|
|
* @param refName a {@link java.lang.String} object. |
|
|
|
|
* @return true if refName is a valid ref name |
|
|
|
|
*/ |
|
|
|
|
public static boolean isValidRefName(final String refName) { |
|
|
|
@ -1392,7 +1443,6 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* |
|
|
|
|
* @param name |
|
|
|
|
* to normalize |
|
|
|
|
* |
|
|
|
|
* @return The normalized name or an empty String if it is {@code null} or |
|
|
|
|
* empty. |
|
|
|
|
* @since 4.7 |
|
|
|
@ -1499,6 +1549,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Whether this repository is bare |
|
|
|
|
* |
|
|
|
|
* @return true if this is bare, which implies it has no working directory. |
|
|
|
|
*/ |
|
|
|
|
public boolean isBare() { |
|
|
|
@ -1506,9 +1558,12 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the root directory of the working tree, where files are checked out |
|
|
|
|
* for viewing and editing. |
|
|
|
|
* |
|
|
|
|
* @return the root directory of the working tree, where files are checked |
|
|
|
|
* out for viewing and editing. |
|
|
|
|
* @throws NoWorkTreeException |
|
|
|
|
* @throws org.eclipse.jgit.errors.NoWorkTreeException |
|
|
|
|
* if this is bare, which implies it has no working directory. |
|
|
|
|
* See {@link #isBare()}. |
|
|
|
|
*/ |
|
|
|
@ -1522,7 +1577,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
/** |
|
|
|
|
* Force a scan for changed refs. |
|
|
|
|
* |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
public abstract void scanForRepoChanges() throws IOException; |
|
|
|
|
|
|
|
|
@ -1532,8 +1587,10 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
public abstract void notifyIndexChanged(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param refName |
|
|
|
|
* Get a shortened more user friendly ref name |
|
|
|
|
* |
|
|
|
|
* @param refName |
|
|
|
|
* a {@link java.lang.String} object. |
|
|
|
|
* @return a more user friendly ref name |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
@ -1548,7 +1605,10 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get a shortened more user friendly remote tracking branch name |
|
|
|
|
* |
|
|
|
|
* @param refName |
|
|
|
|
* a {@link java.lang.String} object. |
|
|
|
|
* @return the remote branch name part of <code>refName</code>, i.e. without |
|
|
|
|
* the <code>refs/remotes/<remote></code> prefix, if |
|
|
|
|
* <code>refName</code> represents a remote tracking branch; |
|
|
|
@ -1566,7 +1626,10 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get remote name |
|
|
|
|
* |
|
|
|
|
* @param refName |
|
|
|
|
* a {@link java.lang.String} object. |
|
|
|
|
* @return the remote name part of <code>refName</code>, i.e. without the |
|
|
|
|
* <code>refs/remotes/<remote></code> prefix, if |
|
|
|
|
* <code>refName</code> represents a remote tracking branch; |
|
|
|
@ -1587,7 +1650,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* Read the {@code GIT_DIR/description} file for gitweb. |
|
|
|
|
* |
|
|
|
|
* @return description text; null if no description has been configured. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* description cannot be accessed. |
|
|
|
|
* @since 4.6 |
|
|
|
|
*/ |
|
|
|
@ -1601,7 +1664,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* |
|
|
|
|
* @param description |
|
|
|
|
* new description; null to clear the description. |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* description cannot be persisted. |
|
|
|
|
* @since 4.6 |
|
|
|
|
*/ |
|
|
|
@ -1611,10 +1674,13 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the reflog reader |
|
|
|
|
* |
|
|
|
|
* @param refName |
|
|
|
|
* @return a {@link ReflogReader} for the supplied refname, or {@code null} |
|
|
|
|
* if the named ref does not exist. |
|
|
|
|
* @throws IOException |
|
|
|
|
* a {@link java.lang.String} object. |
|
|
|
|
* @return a {@link org.eclipse.jgit.lib.ReflogReader} for the supplied |
|
|
|
|
* refname, or {@code null} if the named ref does not exist. |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* the ref could not be accessed. |
|
|
|
|
* @since 3.0 |
|
|
|
|
*/ |
|
|
|
@ -1629,8 +1695,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* |
|
|
|
|
* @return a String containing the content of the MERGE_MSG file or |
|
|
|
|
* {@code null} if this file doesn't exist |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws NoWorkTreeException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @throws org.eclipse.jgit.errors.NoWorkTreeException |
|
|
|
|
* if this is bare, which implies it has no working directory. |
|
|
|
|
* See {@link #isBare()}. |
|
|
|
|
*/ |
|
|
|
@ -1648,8 +1714,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @param msg |
|
|
|
|
* the message which should be written or <code>null</code> to |
|
|
|
|
* delete the file |
|
|
|
|
* |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
public void writeMergeCommitMsg(String msg) throws IOException { |
|
|
|
|
File mergeMsgFile = new File(gitDir, Constants.MERGE_MSG); |
|
|
|
@ -1663,8 +1728,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* |
|
|
|
|
* @return a String containing the content of the COMMIT_EDITMSG file or |
|
|
|
|
* {@code null} if this file doesn't exist |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws NoWorkTreeException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @throws org.eclipse.jgit.errors.NoWorkTreeException |
|
|
|
|
* if this is bare, which implies it has no working directory. |
|
|
|
|
* See {@link #isBare()}. |
|
|
|
|
* @since 4.0 |
|
|
|
@ -1682,8 +1747,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @param msg |
|
|
|
|
* the message which should be written or {@code null} to delete |
|
|
|
|
* the file |
|
|
|
|
* |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @since 4.0 |
|
|
|
|
*/ |
|
|
|
|
public void writeCommitEditMsg(String msg) throws IOException { |
|
|
|
@ -1699,8 +1763,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @return a list of commits which IDs are listed in the MERGE_HEAD file or |
|
|
|
|
* {@code null} if this file doesn't exist. Also if the file exists |
|
|
|
|
* but is empty {@code null} will be returned |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws NoWorkTreeException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @throws org.eclipse.jgit.errors.NoWorkTreeException |
|
|
|
|
* if this is bare, which implies it has no working directory. |
|
|
|
|
* See {@link #isBare()}. |
|
|
|
|
*/ |
|
|
|
@ -1731,7 +1795,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @param heads |
|
|
|
|
* a list of commits which IDs should be written to |
|
|
|
|
* $GIT_DIR/MERGE_HEAD or <code>null</code> to delete the file |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
public void writeMergeHeads(List<? extends ObjectId> heads) throws IOException { |
|
|
|
|
writeHeadsFile(heads, Constants.MERGE_HEAD); |
|
|
|
@ -1743,8 +1807,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @return object id from CHERRY_PICK_HEAD file or {@code null} if this file |
|
|
|
|
* doesn't exist. Also if the file exists but is empty {@code null} |
|
|
|
|
* will be returned |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws NoWorkTreeException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @throws org.eclipse.jgit.errors.NoWorkTreeException |
|
|
|
|
* if this is bare, which implies it has no working directory. |
|
|
|
|
* See {@link #isBare()}. |
|
|
|
|
*/ |
|
|
|
@ -1767,8 +1831,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @return object id from REVERT_HEAD file or {@code null} if this file |
|
|
|
|
* doesn't exist. Also if the file exists but is empty {@code null} |
|
|
|
|
* will be returned |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws NoWorkTreeException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @throws org.eclipse.jgit.errors.NoWorkTreeException |
|
|
|
|
* if this is bare, which implies it has no working directory. |
|
|
|
|
* See {@link #isBare()}. |
|
|
|
|
*/ |
|
|
|
@ -1790,7 +1854,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @param head |
|
|
|
|
* an object id of the cherry commit or <code>null</code> to |
|
|
|
|
* delete the file |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
public void writeCherryPickHead(ObjectId head) throws IOException { |
|
|
|
|
List<ObjectId> heads = (head != null) ? Collections.singletonList(head) |
|
|
|
@ -1805,7 +1869,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @param head |
|
|
|
|
* an object id of the revert commit or <code>null</code> to |
|
|
|
|
* delete the file |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
public void writeRevertHead(ObjectId head) throws IOException { |
|
|
|
|
List<ObjectId> heads = (head != null) ? Collections.singletonList(head) |
|
|
|
@ -1819,7 +1883,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @param head |
|
|
|
|
* an object id of the original HEAD commit or <code>null</code> |
|
|
|
|
* to delete the file |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
public void writeOrigHead(ObjectId head) throws IOException { |
|
|
|
|
List<ObjectId> heads = head != null ? Collections.singletonList(head) |
|
|
|
@ -1833,8 +1897,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @return object id from ORIG_HEAD file or {@code null} if this file |
|
|
|
|
* doesn't exist. Also if the file exists but is empty {@code null} |
|
|
|
|
* will be returned |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws NoWorkTreeException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @throws org.eclipse.jgit.errors.NoWorkTreeException |
|
|
|
|
* if this is bare, which implies it has no working directory. |
|
|
|
|
* See {@link #isBare()}. |
|
|
|
|
*/ |
|
|
|
@ -1854,7 +1918,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* |
|
|
|
|
* @return a String containing the content of the SQUASH_MSG file or |
|
|
|
|
* {@code null} if this file doesn't exist |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @throws NoWorkTreeException |
|
|
|
|
* if this is bare, which implies it has no working directory. |
|
|
|
|
* See {@link #isBare()}. |
|
|
|
@ -1873,8 +1937,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @param msg |
|
|
|
|
* the message which should be written or <code>null</code> to |
|
|
|
|
* delete the file |
|
|
|
|
* |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
*/ |
|
|
|
|
public void writeSquashCommitMsg(String msg) throws IOException { |
|
|
|
|
File squashMsgFile = new File(gitDir, Constants.SQUASH_MSG); |
|
|
|
@ -1970,7 +2033,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* @param includeComments |
|
|
|
|
* <code>true</code> if also comments should be reported |
|
|
|
|
* @return the list of steps |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @since 3.2 |
|
|
|
|
*/ |
|
|
|
|
@NonNull |
|
|
|
@ -1990,7 +2053,7 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* the steps to be written |
|
|
|
|
* @param append |
|
|
|
|
* whether to append to an existing file or to write a new file |
|
|
|
|
* @throws IOException |
|
|
|
|
* @throws java.io.IOException |
|
|
|
|
* @since 3.2 |
|
|
|
|
*/ |
|
|
|
|
public void writeRebaseTodoFile(String path, List<RebaseTodoLine> steps, |
|
|
|
@ -2000,6 +2063,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the names of all known remotes |
|
|
|
|
* |
|
|
|
|
* @return the names of all known remotes |
|
|
|
|
* @since 3.4 |
|
|
|
|
*/ |
|
|
|
@ -2016,7 +2081,8 @@ public abstract class Repository implements AutoCloseable {
|
|
|
|
|
* objects. |
|
|
|
|
* <p/> |
|
|
|
|
* Currently this option is supported for repositories of type |
|
|
|
|
* {@code FileRepository} only. See {@link GC#setAuto(boolean)} for |
|
|
|
|
* {@code FileRepository} only. See |
|
|
|
|
* {@link org.eclipse.jgit.internal.storage.file.GC#setAuto(boolean)} for |
|
|
|
|
* configuration details. |
|
|
|
|
* |
|
|
|
|
* @param monitor |
|
|
|
|