mirror of
https://github.com/git/git.git
synced 2026-03-13 10:23:30 +01:00
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:
27
git-clone.sh
27
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user