From 18bf4a4beafb904ab0ee2fcb3a59b7d95f42c9ef Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Wed, 24 Jan 2007 10:46:24 +0100 Subject: [PATCH] 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. --- cpio.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cpio.sh b/cpio.sh index 0b219fa729..2816e34851 100644 --- a/cpio.sh +++ b/cpio.sh @@ -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=- ;; *)