clone: use dir-iterator to avoid explicit dir traversal
authorMatheus Tavares <matheus.bernardino@usp.br>
Wed, 10 Jul 2019 23:59:03 +0000 (20:59 -0300)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Jul 2019 20:52:16 +0000 (13:52 -0700)
commitff7ccc8c9a6e61a7225c161c743a49ac079f1425
treee80c49f77a3d2c299decb7218ca78ca7d4e79664
parent14954b799f0bac76e500593c95d1f274cf0636e5
clone: use dir-iterator to avoid explicit dir traversal

Replace usage of opendir/readdir/closedir API to traverse directories
recursively, at copy_or_link_directory function, by the dir-iterator
API. This simplifies the code and avoids recursive calls to
copy_or_link_directory.

This process also makes copy_or_link_directory call die() in case of an
error on readdir or stat inside dir_iterator_advance. Previously it
would just print a warning for errors on stat and ignore errors on
readdir, which isn't nice because a local git clone could succeed even
though the .git/objects copy didn't fully succeed.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/clone.c