diff options
author | Derrick Stolee <stolee@gmail.com> | 2024-12-20 16:21:15 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-12-20 08:37:05 -0800 |
commit | 71edf6c3c8161a2f102b69ca318ca1784ba29a58 (patch) | |
tree | 30fa53859df6de0f915a30767c83d44a4ab319f9 /builtin/commit.c | |
parent | 6333e7ae0bb1027b3299d482be5a4a0937116ab0 (diff) |
path-walk: reorder object visits
The path-walk API currently uses a stack-based approach to recursing
through the list of paths within the repository. This guarantees that
after a tree path is explored, all paths contained within that tree path
will be explored before continuing to explore siblings of that tree
path.
The initial motivation of this depth-first approach was to minimize
memory pressure while exploring the repository. A breadth-first approach
would have too many "active" paths being stored in the paths_to_lists
map.
We can take this approach one step further by making sure that blob
paths are visited before tree paths. This allows the API to free the
memory for these blob objects before continuing to perform the
depth-first search. This modifies the order in which we visit siblings,
but does not change the fact that we are performing depth-first search.
To achieve this goal, use a priority queue with a custom sorting method.
The sort needs to handle tags, blobs, and trees (commits are handled
slightly differently). When objects share a type, we can sort by path
name. This will keep children of the latest path to leave the stack be
preferred over the rest of the paths in the stack, since they agree in
prefix up to and including a directory separator. When the types are
different, we can prefer tags over other types and blobs over trees.
This causes significant adjustments to t6601-path-walk.sh to rearrange
the order of the visited paths.
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
0 files changed, 0 insertions, 0 deletions