]> git.ipfire.org Git - thirdparty/git.git/commit
cache-tree: implement cache_tree_find_path()
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 23 May 2022 13:48:41 +0000 (13:48 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 May 2022 18:08:21 +0000 (11:08 -0700)
commit080ab56a46ad65068201a768a04464341117fe81
tree535123b9ca0e48b8be43a14ba4917d8e4f65e647
parent9fadb373dd4a670e761776560d3c40f6fcc80360
cache-tree: implement cache_tree_find_path()

Given a 'struct cache_tree', it may be beneficial to navigate directly
to a node within that corresponds to a given path name. Create
cache_tree_find_path() for this function. It returns NULL when no such
path exists.

The implementation is adapted from do_invalidate_path() which does a
similar search but also modifies the nodes it finds along the way. The
method could be implemented simply using tail-recursion, but this while
loop does the same thing.

This new method is not currently used, but will be in an upcoming
change.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache-tree.c
cache-tree.h