name-rev: restructure creating/updating 'struct rev_name' instances
authorSZEDER Gábor <redacted>
Tue, 12 Nov 2019 10:38:18 +0000 (11:38 +0100)
committerJunio C Hamano <redacted>
Fri, 6 Dec 2019 21:29:04 +0000 (13:29 -0800)
commit3a521503019de7ca0c550c3861619bb8881c388c
treee3195bafd13fdac1c8251a553af70a32bd694c12
parentdd432a6ecf022b40760dd04fe4e94fdfcb1b270d
name-rev: restructure creating/updating 'struct rev_name' instances

At the beginning of the recursive name_rev() function it creates a new
'struct rev_name' instance for each previously unvisited commit or, if
this visit results in better name for an already visited commit, then
updates the 'struct rev_name' instance attached to the commit, or
returns early.

Restructure this so it's caller creates or updates the 'struct
rev_name' instance associated with the commit to be passed as
parameter, i.e. both name_ref() before calling name_rev() and
name_rev() itself as it iterates over the parent commits.

This makes eliminating the recursion a bit easier to follow, and the
condition moved to name_ref() will be moved back to name_rev() after
the recursion is eliminated.

This change also plugs the memory leak that was temporarily unplugged
in the earlier "name-rev: pull out deref handling from the recursion"
patch in this series.

Signed-off-by: SZEDER Gábor <redacted>
Signed-off-by: Junio C Hamano <redacted>
builtin/name-rev.c
git clone https://git.99rst.org/PROJECT