mirror of
https://github.com/git/git.git
synced 2026-03-13 10:23:30 +01:00
Add a cpio emulation script based on GNU tar.
This commit is contained in:
3
Makefile
3
Makefile
@@ -177,7 +177,8 @@ SCRIPT_SH = \
|
||||
git-applymbox.sh git-applypatch.sh git-am.sh \
|
||||
git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
|
||||
git-merge-resolve.sh git-merge-ours.sh \
|
||||
git-lost-found.sh git-quiltimport.sh
|
||||
git-lost-found.sh git-quiltimport.sh \
|
||||
cpio.sh
|
||||
|
||||
SCRIPT_PERL = \
|
||||
git-add--interactive.perl \
|
||||
|
||||
45
cpio.sh
Normal file
45
cpio.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Emulates some cpio behavior using GNU tar
|
||||
|
||||
die() {
|
||||
echo >&2 "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
tr0=cat
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-0) tr0="tr '\0' ' '";;
|
||||
-o) mode=o;;
|
||||
-iuv) ;;
|
||||
-pumd|-pumdl)
|
||||
mode=p
|
||||
dir="$2"
|
||||
shift
|
||||
;;
|
||||
*) die "cpio emulation supports only -0, -o, -iuv, -pumdl";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
case $mode in
|
||||
o)
|
||||
files=.cpiofiles$$
|
||||
$tr0 > $files
|
||||
tar --create --file=- --files-from=$files --exclude=$files
|
||||
rc=$?
|
||||
rm -f $files
|
||||
exit $rc
|
||||
;;
|
||||
p)
|
||||
files=.cpiofiles$$
|
||||
$tr0 > $files
|
||||
tar --create --file=- --files-from=$files --exclude=$files |
|
||||
tar --extract --directory="$dir" --file=-
|
||||
rm -f $files
|
||||
;;
|
||||
*)
|
||||
tar xvf - || exit
|
||||
esac
|
||||
Reference in New Issue
Block a user