]> git.ipfire.org Git - thirdparty/git.git/commit - path.c
path.c: clarify trie_find()'s in-code comment
authorSZEDER Gábor <szeder.dev@gmail.com>
Mon, 21 Oct 2019 16:00:40 +0000 (18:00 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Oct 2019 03:53:51 +0000 (12:53 +0900)
commit7cb8c929d76c12750fdece2e5da75d207938d3b9
tree970c812bff7e89bedde466f473ef78622875774b
parente536b1fedf777ad8958a6f299d9d59db6299e697
path.c: clarify trie_find()'s in-code comment

A fairly long comment describes trie_find()'s behavior and shows
examples, but it's slightly incomplete/inaccurate.  Update this
comment to specify how trie_find() handles a negative return value
from the given match function.

Furthermore, update the list of examples to include not only two but
three levels of path components.  This makes the examples slightly
more complicated, but it can illustrate the behavior in more corner
cases.

Finally, basically everything refers to the data stored for a key as
"value", with two confusing exceptions:

  - The type definition of the match function calls its corresponding
    parameter 'data'.
    Rename that parameter to 'value'.  (check_common(), the only
    function of this type already calls it 'value').

  - The table of examples above trie_find() has a "val from node"
    column, which has nothing to do with the value stored in the trie:
    it's a "prefix of the key for which the trie contains a value"
    that led to that node.
    Rename that column header to "prefix to node".

Note that neither the original nor the updated description and
examples correspond 100% to the current implementation, because the
implementation is a bit buggy, but the comment describes the desired
behavior.  The bug will be fixed in the last patch of this series.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
path.c