mirror of
https://github.com/git/git.git
synced 2026-03-13 18:33:25 +01:00
Under certain circumstances (I did not find out the complete details, but it happens when running the tests), the filterdirs() function in cpio outputs CR/LF. Since tar does not like that, the command failed. So strip out all CRs when filtering the directories. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
54 lines
757 B
Bash
54 lines
757 B
Bash
#!/bin/sh
|
|
#
|
|
# Emulates some cpio behavior using GNU tar
|
|
|
|
die() {
|
|
echo >&2 "$@"
|
|
exit 1
|
|
}
|
|
|
|
null=
|
|
|
|
while test $# -gt 0; do
|
|
case "$1" in
|
|
-0) null=--null;;
|
|
-o) mode=o;;
|
|
-iuv) ;;
|
|
-pumd|-pumdl)
|
|
mode=p
|
|
dir="$2"
|
|
shift
|
|
;;
|
|
*) die "cpio emulation supports only -0, -o, -iuv, -pumdl";;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
filterdirs() {
|
|
while read f; do
|
|
if test -d "$f"; then
|
|
# list only empty directories
|
|
if test -z "$(ls -A "$f")"; then
|
|
echo "$f"
|
|
fi
|
|
else
|
|
echo "$f"
|
|
fi
|
|
done
|
|
}
|
|
|
|
case $mode in
|
|
o)
|
|
tar --create --file=- $null --files-from=-
|
|
;;
|
|
p)
|
|
test -z "$null" || die "cpio: cannot use -0 in pass-through mode"
|
|
filterdirs |
|
|
tr -d '\r' |
|
|
tar --create --file=- --files-from=- |
|
|
tar --extract --directory="$dir" --file=-
|
|
;;
|
|
*)
|
|
tar xvf -
|
|
esac
|