Cpio emulator: do not copy files repeatedly in pass-through mode.

Files were stored each time when they were mentioned in the file list
as well as for each of its directories and parent directories.
Now we filter out directory names because they are implied for the files
that they contain, but we do list empty directories.

The only case where this is relevant is the pass-through mode that
git clone of a local directory uses.
This commit is contained in:
Johannes Sixt
2007-01-24 10:46:24 +01:00
parent 28b06b3aab
commit 18bf4a4bea

17
cpio.sh
View File

@@ -24,12 +24,27 @@ while test $# -gt 0; do
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)
tar --create --file=- $null --files-from=- |
test -z "$null" || die "cpio: cannot use -0 in pass-through mode"
filterdirs |
tar --create --file=- --files-from=- |
tar --extract --directory="$dir" --file=-
;;
*)