]> git.ipfire.org Git - thirdparty/git.git/commit - t/t4013-diff-various.sh
2.36 show regression fix
authorJunio C Hamano <gitster@pobox.com>
Sat, 30 Apr 2022 05:29:51 +0000 (22:29 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 30 Apr 2022 05:31:17 +0000 (22:31 -0700)
commit5cdb38458ee5b53daada9cb767ae51a08650bd6a
tree6ea2af874599acf6a29892ad241de340c19e5d8b
parent362f869ff2dbc389234ecd8c4b996a9e507c39d7
2.36 show regression fix

This only surfaced as a regression after 2.36 release, but the
breakage was already there with us for at least a year.

e900d494 (diff: add an API for deferred freeing, 2021-02-11)
introduced a mechanism to delay freeing resources held in
diff_options struct that need to be kept as long as the struct will
be reused to compute diff.  "git log -p" was taught to utilize the
mechanism but it was done with an incorrect assumption that the
underlying helper function, cmd_log_walk(), is called only once,
and it is OK to do the freeing at the end of it.

Alas, for "git show A B", the function is called once for each
commit given, so it is not OK to free the resources until we finish
calling it for all the commits given from the command line.

During 2.36 release cycle, we started clearing the <pathspec> as
part of this freeing, which made the bug a lot more visible.

Fix this breakage by tweaking how cmd_log_walk() frees the resources
at the end and using a variant of it that does not immediately free
the resources to show each commit object from the command line in
"git show".

Protect the fix with a few new tests.

Reported-by: Daniel Li <dan@danielyli.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c
t/t4013-diff-various.sh