Due to the way a Git tree is organized the standard
org. won't easily find a D/F conflict
when merging two or more trees together. In the standard TreeWalk the file
will be returned first, and then much later the directory will be returned.
This makes it impossible for the application to efficiently detect and handle
the conflict.
Using this walk implementation causes the directory to report earlier than usual, at the same time as the non-directory entry. This permits the application to handle the D/F conflict in a single step. The directory is returned only once, so it does not get returned later in the iteration.
When a D/F conflict is detected
org. will return true and
org. will recurse into
the subtree, no matter which iterator originally supplied the subtree.
Because conflicted directories report early, using this walk implementation
to populate a org. may cause the
automatic resorting to run and fix the entry ordering.
This walk implementation requires more CPU to implement a look-ahead and a look-behind to merge a D/F pair together, or to skip a previously reported directory. In typical Git repositories the look-ahead cost is 0 and the look-behind doesn't trigger, as users tend not to create trees which contain both "foo" as a directory and "foo.c" as a file.
In the worst-case however several thousand look-ahead steps per walk step may be necessary, making the overhead quite significant. Since this worst-case should never happen this walk implementation has made the time/space tradeoff in favor of more-time/less-space, as that better suits the typical case.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | allTreesNamesMatchFastMinRef
True if all |
| private AbstractTreeIterator | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public | NameConflictTreeWalk(Repository
the repository the walker will obtain data from. repo)Create a new tree walker for a given repository. |
| public | NameConflictTreeWalk(Repository
the repository the walker will obtain data from. repo, ObjectReader the reader the walker will obtain tree data from. or)Create a new tree walker for a given repository. |
| public | NameConflictTreeWalk(ObjectReader
the reader the walker will obtain tree data from. or)Create a new tree walker for a given repository. |
| Modifier and Type | Method and Description |
|---|---|
| private AbstractTreeIterator | |
| private AbstractTreeIterator | |
| private int | |
| public boolean | Returns: true if the current entry is covered by a
directory/file conflict, false otherwiseTrue if the current entry is covered by a directory/file conflict. |
| private boolean | |
| private static boolean | |
| pack-priv AbstractTreeIterator | min()
Overrides org. Returns an AbstractTreeIterator from |
| private static boolean | |
| private boolean | |
| pack-priv void | |
| pack-priv void | |
| private boolean | |
| pack-priv void | stopWalk()
Overrides org. Notify iterators the walk is aborting. |
| allTreesNamesMatchFastMinRef | back to summary |
|---|---|
| private boolean allTreesNamesMatchFastMinRef True if all Note if all iterators reached end of trees, the value is true. | |
| dfConflict | back to summary |
|---|---|
| private AbstractTreeIterator dfConflict | |
| TREE_MODE | back to summary |
|---|---|
| private static final int TREE_MODE | |
| NameConflictTreeWalk | back to summary |
|---|---|
| public NameConflictTreeWalk(Repository repo) Create a new tree walker for a given repository.
| |
| NameConflictTreeWalk | back to summary |
|---|---|
| public NameConflictTreeWalk(Repository repo, ObjectReader or) Create a new tree walker for a given repository.
| |
| NameConflictTreeWalk | back to summary |
|---|---|
| public NameConflictTreeWalk(ObjectReader or) Create a new tree walker for a given repository.
| |
| combineDF | back to summary |
|---|---|
| private AbstractTreeIterator combineDF(AbstractTreeIterator minRef) throws CorruptObjectException | |
| fastMin | back to summary |
|---|---|
| private AbstractTreeIterator fastMin() | |
| getFirstNonEofTreeIndex | back to summary |
|---|---|
| private int getFirstNonEofTreeIndex() | |
| isDirectoryFileConflict | back to summary |
|---|---|
| public boolean isDirectoryFileConflict() True if the current entry is covered by a directory/file conflict. This means that for some prefix of the current entry's path, this walk has detected a directory/file conflict. Also true if the current entry itself is a directory/file conflict. Example: If this TreeWalk points to foo/bar/a.txt and this method returns true then you know that either for path foo or for path foo/bar files and folders were detected.
| |
| isGitlink | back to summary |
|---|---|
| private boolean isGitlink(AbstractTreeIterator p) | |
| isTree | back to summary |
|---|---|
| private static boolean isTree(AbstractTreeIterator p) | |
| min | back to summary |
|---|---|
| pack-priv AbstractTreeIterator min() throws CorruptObjectException Overrides org. Doc from org. Returns an AbstractTreeIterator from
| |
| nameEqual | back to summary |
|---|---|
| private static boolean nameEqual(final AbstractTreeIterator a, final AbstractTreeIterator b) | |
| needsStopWalk | back to summary |
|---|---|
| private boolean needsStopWalk() | |
| popEntriesEqual | back to summary |
|---|---|
| pack-priv void popEntriesEqual() throws CorruptObjectException Overrides org.
| |
| skipEntriesEqual | back to summary |
|---|---|
| pack-priv void skipEntriesEqual() throws CorruptObjectException Overrides org.
| |
| skipEntry | back to summary |
|---|---|
| private boolean skipEntry(AbstractTreeIterator minRef) throws CorruptObjectException | |
| stopWalk | back to summary |
|---|---|
| pack-priv void stopWalk() throws IOException Overrides org. Doc from org. Notify iterators the walk is aborting.
Primarily to notify
| |