difftool: refactor dir-diff to write files using helper functions
commit2255c80c91da9ed7fa127dad3aa92eb9f448c88b
authorDavid Aguilar <davvid@gmail.com>
Fri, 1 Oct 2021 01:37:54 +0000 (30 18:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Oct 2021 01:48:51 +0000 (30 18:48 -0700)
treef4e5a9ee2656e80688523aee64b1ccd6934e949e
parent4ac9f15492b69ef3a0334ca66b1ef4be00c79b47
difftool: refactor dir-diff to write files using helper functions

Add a helpers function to handle the unlinking and writing
of the dir-diff submodule and symlink stand-in files.

Use the helpers to implement the guts of the hashmap loops.
This eliminate duplicate code and safeguards the submodules
hashmap loop against the symlink-chasing behavior that 5bafb3576a
(difftool: fix symlink-file writing in dir-diff mode, 2021-09-22)
addressed.

The submodules loop should not strictly require the unlink() call that
this is introducing to them, but it does not necessarily hurt them
either beyond the cost of the extra unlink().

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/difftool.c