Implement a cpio emulation inside git-clone.sh for Windows.

We use 'xargs cp' to emulate 'cpio -pumd'.

cpio is fed from the output of 'find --depth' without filtering out
directories. We don't need to copy directories except the empty ones, so
we need to filter out non-empty directories. Then we can use 'cp -r' and
it will not actually recurse anything.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
This commit is contained in:
Johannes Sixt
2007-10-16 22:52:12 +02:00
parent 9b77ca23c4
commit b171dc19ec

View File

@@ -20,6 +20,33 @@ case $(uname -s) in
find () {
/usr/bin/find "$@"
}
# need an emulation of cpio
cpio() {
case "$1" in
-pumd) cp_arg=-pr;;
-pumdl) cp_arg=-lr;;
*) die "cpio $1 unexpected";;
esac
# copy only files and empty directories
prev=
while read f; do
if test -d "$f"; then
# here we assume that directories are listed after
# its files (aka 'find -depth'), hence, a directory
# that is not empty will be a leading sub-string
# of the preceding entry
case "$prev" in
"$f"/* ) ;;
*) echo "$f";;
esac
else
echo "$f"
fi
prev="$f"
done |
xargs --no-run-if-empty \
cp $cp_arg --target-directory="$2" --parents
}
;;
esac