]> git.ipfire.org Git - thirdparty/git.git/commit
tree-diff: use the name "tail" to refer to list tail
authorJeff King <peff@peff.net>
Thu, 9 Jan 2025 08:53:09 +0000 (03:53 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Jan 2025 20:24:26 +0000 (12:24 -0800)
commitd8baf083c5a1a3e8dd27fe73e6000c5f6dddf1ca
treefd0d731b6a29311dd186c25a6ebcaa58495d86a8
parenta5c4e31af9b8b8fb362472ce3a1ec404df0da032
tree-diff: use the name "tail" to refer to list tail

The ll_diff_tree_paths() function and its helpers all append to a
running list by taking in a pointer to the old tail and returning the
new tail. But they just call this argument "p", which is not very
descriptive.

It gets particularly confusing in emit_path(), where we actually add to
the list, because "p" does double-duty: it is the tail of the list, but
it is also the entry which we add. Except that in some cases we _don't_
add a new entry (or we might even add it and roll it back) if the path
isn't interesting. At first glance, this makes it look like a bug that
we pass "p" on to ll_diff_tree_paths() to recurse; sometimes it is
getting the new entry we made and sometimes not!

But it's not a bug, because ll_diff_tree_paths() does not care about the
entry itself at all. It is only using its "next" pointer as the tail of
the list.

Let's swap out "p" for "tail" to make this obvious. And then in
emit_path() we'll continue to use "p" for our newly allocated entry.

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