mirror of
https://github.com/git/git.git
synced 2026-03-13 18:33:25 +01:00
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.
53 lines
743 B
Bash
53 lines
743 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 |
|
|
tar --create --file=- --files-from=- |
|
|
tar --extract --directory="$dir" --file=-
|
|
;;
|
|
*)
|
|
tar xvf -
|
|
esac
|