From b171dc19ec37692d0791bc0d84866399fc42da94 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Tue, 16 Oct 2007 22:52:12 +0200 Subject: [PATCH] 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 --- git-clone.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/git-clone.sh b/git-clone.sh index cb6f2daef0..0154a4a381 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -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