diff: use mks_tempfile_dt()
commit8af759374ec174372b841d2f8bc24edcba385418
authorRené Scharfe <l.s.r@web.de>
Wed, 20 Apr 2022 20:30:10 +0000 (20 22:30 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Apr 2022 23:17:35 +0000 (20 16:17 -0700)
treef22e47f7cf9a51e16b851ee1c737931dc5545b34
parent2c2db194bd9e2f2dda7f1a47d26a1f86b3dd635a
diff: use mks_tempfile_dt()

Git uses temporary files to pass the contents of blobs to external diff
programs and textconv filters.  It calls mks_tempfile_ts() to create
them, which puts them all in the same directory.  This requires adding
a random name prefix.

Use mks_tempfile_dt() instead, which allows the files to have arbitrary
names, each in their own separate temporary directory.  This way they
can have the same basename as the original blob, which looks nicer in
graphical diff programs.

The test in t4020 to check the prettiness of the temporary paths was
neutered by 5476bdf0e8 (diff tests: don't ignore "git diff" exit code in
"read" loop, 2022-03-07), which removed its grep check without replacing
it with an equivalent test_cmp check.  Add one that only checks the
basename of the temporary file and nothing else.

And make the test more robust while at it, by using test_when_finished
to get rid of the added file even if the test fails.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
t/t4020-diff-external.sh