mirror of
https://github.com/git/git.git
synced 2026-03-13 10:23:30 +01:00
Avoid spawning 'ls' for each directory that is passed to the cpio emulator.
We assume that the file names are passed in using find -depth so that a directory is listed after its contents.
This commit is contained in:
14
cpio.sh
14
cpio.sh
@@ -24,16 +24,24 @@ while test $# -gt 0; do
|
||||
shift
|
||||
done
|
||||
|
||||
prev=
|
||||
|
||||
filterdirs() {
|
||||
while read f; do
|
||||
if test -d "$f"; then
|
||||
# list only empty directories
|
||||
if test -z "$(ls -A "$f")"; then
|
||||
echo "$f"
|
||||
fi
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user