org.eclipse.jgit.dircache.DirCache by supplying discrete
edit commands.
An editor updates a DirCache by taking a list of
org. commands and
executing them against the entries of the destination cache to produce a new
cache. This edit style allows applications to insert a few commands and then
have the editor compute the proper entry indexes necessary to perform an
efficient in-order update of the index records. This can be easier to use
than org..
DirCacheBuilder
| Modifier and Type | Class and Description |
|---|---|
| public static class | DirCacheEditor.
Deletes a single file entry from the index. |
| public static class | DirCacheEditor.
Recursively deletes all paths under a subtree. |
| public abstract static class | DirCacheEditor.
Any index record update. |
| Modifier and Type | Field and Description |
|---|---|
| private static final Comparator | |
| private int | |
| private final List |
| Access | Constructor and Description |
|---|---|
| protected | DirCacheEditor(DirCache
the cache this editor will eventually update. dc, int estimated number of entries the editor will have upon
completion. This sizes the initial entry table. ecnt)Construct a new editor. |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(DirCacheEditor.
another edit command. editAppend one edit command to the list of commands to be applied. |
| private void | |
| public boolean | commit()
Overrides org. Finish, write, commit this change, and release the index lock. |
| private int | |
| private int | |
| public void | finish()
Implements abstract org. Finish this builder and update the destination
|
| private static boolean | |
| private void | |
| private static int |
| EDIT_CMP | back to summary |
|---|---|
| private static final Comparator<DirCacheEditor. | |
| editIdx | back to summary |
|---|---|
| private int editIdx | |
| edits | back to summary |
|---|---|
| private final List<DirCacheEditor. | |
| DirCacheEditor | back to summary |
|---|---|
| protected DirCacheEditor(DirCache dc, int ecnt) Construct a new editor.
| |
| add | back to summary |
|---|---|
| public void add(DirCacheEditor. Append one edit command to the list of commands to be applied. Edit commands may be added in any order chosen by the application. They are automatically rearranged by the builder to provide the most efficient update possible.
| |
| applyEdits | back to summary |
|---|---|
| private void applyEdits() | |
| commit | back to summary |
|---|---|
| public boolean commit() throws IOException Overrides org. Doc from org. Finish, write, commit this change, and release the index lock. If this method fails (returns false) the lock is still released. This is a utility method for applications as the finish-write-commit pattern is very common after using a builder to update entries.
| |
| deleteOverlappingSubtree | back to summary |
|---|---|
| private int deleteOverlappingSubtree(DirCacheEntry ent, int eIdx) | |
| findEntry | back to summary |
|---|---|
| private int findEntry(byte[] p, int pLen) | |
| finish | back to summary |
|---|---|
| public void finish() Implements abstract org. Doc from org. Finish this builder and update the destination
When this method completes this builder instance is no longer usable by the calling application. A new builder must be created to make additional changes to the index entries.
After completion the DirCache returned by
Note to implementors: Make sure
| |
| inDir | back to summary |
|---|---|
| private static boolean inDir(DirCacheEntry e, byte[] path, int pLen) | |
| insertEdit | back to summary |
|---|---|
| private void insertEdit(DirCacheEditor. | |
| pdir | back to summary |
|---|---|
| private static int pdir(byte[] path, int e) | |
This deletion command removes only a single file at the given location,
but removes multiple stages (if present) for that path. To remove a
complete subtree use DeleteTree instead.
DeleteTree
| Access | Constructor and Description |
|---|---|
| public | DeletePath(String
path of the file within the repository. entryPath)Create a new deletion command by path name. |
| public | DeletePath(DirCacheEntry
entry instance to remove. Only the path of this entry is
actually considered during command evaluation. ent)Create a new deletion command for an existing entry instance. |
| Modifier and Type | Method and Description |
|---|---|
| public void | apply(DirCacheEntry
the entry being processed. All fields are zeroed out if
the path is a new path in the index. ent)Implements abstract org. Apply the update to a single cache entry matching the path. |
| DeletePath | back to summary |
|---|---|
| public DeletePath(String entryPath) Create a new deletion command by path name.
| |
| DeletePath | back to summary |
|---|---|
| public DeletePath(DirCacheEntry ent) Create a new deletion command for an existing entry instance.
| |
| apply | back to summary |
|---|---|
| public void apply(DirCacheEntry ent) Implements abstract org. Doc from org. Apply the update to a single cache entry matching the path. After apply is invoked the entry is added to the output table, and will be included in the new index.
| |
This deletion command is more generic than DeletePath as it can
remove all records which appear recursively under the same subtree.
Multiple stages are removed (if present) for any deleted entry.
This command will not remove a single file entry. To remove a single file
use DeletePath.
DeletePath
| Access | Constructor and Description |
|---|---|
| public | DeleteTree(String
path of the subtree within the repository. If the path
does not end with "/" a "/" is implicitly added to ensure
only the subtree's contents are matched by the command.
The special case "" (not "/"!) deletes all entries. entryPath)Create a new tree deletion command by path name. |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private static byte[] | |
| public void | apply(DirCacheEntry
the entry being processed. All fields are zeroed out if
the path is a new path in the index. ent)Implements abstract org. Apply the update to a single cache entry matching the path. |
| DeleteTree | back to summary |
|---|---|
| public DeleteTree(String entryPath) Create a new tree deletion command by path name.
| |
| DeleteTree | back to summary |
|---|---|
| pack-priv DeleteTree(byte[] path) | |
| appendSlash | back to summary |
|---|---|
| private static byte[] appendSlash(byte[] path) | |
| apply | back to summary |
|---|---|
| public void apply(DirCacheEntry ent) Implements abstract org. Doc from org. Apply the update to a single cache entry matching the path. After apply is invoked the entry is added to the output table, and will be included in the new index.
| |
Applications should subclass and provide their own implementation for the
apply(DirCacheEntry) method. The editor will invoke apply once
for each record in the index which matches the path name. If there are
multiple records (for example in stages 1, 2 and 3), the edit instance
will be called multiple times, once for each stage. If any of these calls
resets the stage to 0, only this entry will be taken and entries for
other stages are discarded.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final byte[] | |
| pack-priv boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| pack-priv | |
| public | PathEdit(DirCacheEntry
entry instance to match path of. Only the path of this
entry is actually considered during command evaluation. ent)Create a new update command for an existing entry instance. |
| Modifier and Type | Method and Description |
|---|---|
| public abstract void | apply(DirCacheEntry
the entry being processed. All fields are zeroed out if
the path is a new path in the index. ent)Apply the update to a single cache entry matching the path. |
| public DirCacheEditor. | Returns: thisif true a file can replace a directory, or a directory can
replace a file. ok)Configure if a file can replace a directory (or vice versa). |
| public String |
| path | back to summary |
|---|---|
| pack-priv final byte[] path | |
| replace | back to summary |
|---|---|
| pack-priv boolean replace | |
| PathEdit | back to summary |
|---|---|
| public PathEdit(String entryPath) Create a new update command by path name.
| |
| PathEdit | back to summary |
|---|---|
| pack-priv PathEdit(byte[] path) | |
| PathEdit | back to summary |
|---|---|
| public PathEdit(DirCacheEntry ent) Create a new update command for an existing entry instance.
| |
| apply | back to summary |
|---|---|
| public abstract void apply(DirCacheEntry ent) Apply the update to a single cache entry matching the path. After apply is invoked the entry is added to the output table, and will be included in the new index.
| |
| setReplace | back to summary |
|---|---|
| public DirCacheEditor. Configure if a file can replace a directory (or vice versa).
Default is
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |