]> git.ipfire.org Git - thirdparty/git.git/commit
tree-diff: simplify emit_path() list management
authorJeff King <peff@peff.net>
Thu, 9 Jan 2025 08:54:05 +0000 (03:54 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Jan 2025 20:24:26 +0000 (12:24 -0800)
commit6632bcba514f4a195447eb77264f75fed3a768e6
tree4e68d7ec0fa561ec746e464fff0ee3d7613b6144
parentd8baf083c5a1a3e8dd27fe73e6000c5f6dddf1ca
tree-diff: simplify emit_path() list management

In emit_path() we may append a new combine_diff_path entry to our list,
decide that we don't want it (because opt->pathchange() told us so) and
then roll it back.

Between the addition and the rollback, it doesn't matter if it's in the
list or not (no functions can even tell, since it's a singly-linked list
and we pass around just the tail entry).

So it's much simpler to just wait until opt->pathchange() tells us
whether to keep it, and either attach it (or free it) then. We do still
have to allocate it up front since it's that struct itself which is
passed to the pathchange callback.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
tree-diff.c