BatchRefUpdate that uses the packed-refs
file to support atomically updating multiple refs.
The algorithm is designed to be compatible with traditional single ref updates operating on single refs only. Regardless of success or failure, the results are atomic: from the perspective of any reader, either all updates in the batch will be visible, or none will. In the case of process failure during any of the following steps, removal of stale lock files is always safe, and will never result in an inconsistent state, although the update may or may not have been applied.
The algorithm is:
refs/x (loose) and
a create of refs/x/y.RefDirectory#pack(Map)), without deleting them afterwards. This covers a
potential race where new loose refs were created after the initial packing
step. If no new loose refs were created during this race, this step does not
modify any files on disk. Keep the merged state in memory.packed-refs and commit by atomically
renaming the lock file.setAtomic(false). As an
optimization, an update containing a single ref update does not use the
packed-refs protocol.
| Modifier and Type | Field and Description |
|---|---|
| private RefDirectory | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private static RefList | |
| private boolean | |
| private boolean | |
| private boolean | |
| private static boolean | |
| public void | execute(RevWalk
a RevWalk to parse tags in case the storage system wants to
store them pre-peeled, a common performance optimization. walk, ProgressMonitor progress monitor to receive update status on. monitor, List<String> a list of option strings; set null to execute without options)Overrides org. Execute this batch update. |
| private static void | |
| private Map | Returns: map of ref name in the input commands to lock file. Always contains one entry for each ref in the input list. All locks are acquired before returning. If any lock was not able to be acquired: the return value is null; no locks are held; and all commands that were pending are set to fail withLOCK_FAILURE.commands that we intend to execute. commands)Lock loose refs corresponding to a list of commands. |
| private static Ref | |
| private static void | |
| private static void | |
| private String | |
| private static void | |
| private void |
| refdb | back to summary |
|---|---|
| private RefDirectory refdb | |
| shouldLockLooseRefs | back to summary |
|---|---|
| private boolean shouldLockLooseRefs | |
| PackedBatchRefUpdate | back to summary |
|---|---|
| pack-priv PackedBatchRefUpdate(RefDirectory refdb) | |
| PackedBatchRefUpdate | back to summary |
|---|---|
| pack-priv PackedBatchRefUpdate(RefDirectory refdb, boolean shouldLockLooseRefs) | |
| applyUpdates | back to summary |
|---|---|
| private static RefList | |
| checkConflictingNames | back to summary |
|---|---|
| private boolean checkConflictingNames(List<ReceiveCommand> commands) throws IOException | |
| checkNonFastForwards | back to summary |
|---|---|
| private boolean checkNonFastForwards(RevWalk walk, List<ReceiveCommand> commands) throws IOException | |
| checkObjectExistence | back to summary |
|---|---|
| private boolean checkObjectExistence(RevWalk walk, List<ReceiveCommand> commands) throws IOException | |
| containsSymrefs | back to summary |
|---|---|
| private static boolean containsSymrefs(List<ReceiveCommand> commands) | |
| execute | back to summary |
|---|---|
| public void execute(RevWalk walk, ProgressMonitor monitor, List<String> options) throws IOException Overrides org. Doc from org. Execute this batch update. The default implementation of this method performs a sequential reference update over each reference.
Implementations must respect the atomicity requirements of the underlying
database as described in
| |
| lockFailure | back to summary |
|---|---|
| private static void lockFailure(ReceiveCommand cmd, List<ReceiveCommand> commands) | |
| lockLooseRefs | back to summary |
|---|---|
| private Map Lock loose refs corresponding to a list of commands.
| |
| peeledRef | back to summary |
|---|---|
| private static Ref peeledRef(RevWalk walk, ReceiveCommand cmd) throws IOException | |
| reject | back to summary |
|---|---|
| private static void reject(ReceiveCommand cmd, ReceiveCommand. | |
| reject | back to summary |
|---|---|
| private static void reject(ReceiveCommand cmd, ReceiveCommand. | |
| toResultString | back to summary |
|---|---|
| private String toResultString(ReceiveCommand cmd) | |
| unlockAll | back to summary |
|---|---|
| private static void unlockAll(Map<?, LockFile> locks) | |
| writeReflog | back to summary |
|---|---|
| private void writeReflog(List<ReceiveCommand> commands) | |