Fix mkpath abuse in dwim_ref and dwim_log of sha1_name.c