2006-12-24 00:26:09 +08:00
|
|
|
#!/bin/sh
|
2011-11-09 02:17:40 +08:00
|
|
|
# This requires git-manpages and/or git-htmldocs repositories
|
2006-12-24 00:26:09 +08:00
|
|
|
|
2011-11-09 02:17:40 +08:00
|
|
|
repository=${1?repository}
|
|
|
|
destdir=${2?destination}
|
2017-12-10 06:07:57 +08:00
|
|
|
GIT_MAN_REF=${3?master}
|
2011-11-09 02:17:40 +08:00
|
|
|
|
2017-12-10 06:07:57 +08:00
|
|
|
GIT_DIR=
|
2011-11-09 02:17:40 +08:00
|
|
|
for d in "$repository/.git" "$repository"
|
|
|
|
do
|
2017-12-10 06:07:57 +08:00
|
|
|
if GIT_DIR="$d" git rev-parse "$GIT_MAN_REF" >/dev/null 2>&1
|
2011-11-09 02:17:40 +08:00
|
|
|
then
|
|
|
|
GIT_DIR="$d"
|
|
|
|
export GIT_DIR
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -z "$GIT_DIR"
|
|
|
|
then
|
|
|
|
echo >&2 "Neither $repository nor $repository/.git is a repository"
|
|
|
|
exit 1
|
2006-12-24 00:26:09 +08:00
|
|
|
fi
|
|
|
|
|
2011-11-09 02:17:40 +08:00
|
|
|
GIT_WORK_TREE=$(pwd)
|
|
|
|
GIT_INDEX_FILE=$(pwd)/.quick-doc.$$
|
|
|
|
export GIT_INDEX_FILE GIT_WORK_TREE
|
2006-12-24 00:26:09 +08:00
|
|
|
rm -f "$GIT_INDEX_FILE"
|
2007-08-05 14:48:27 +08:00
|
|
|
trap 'rm -f "$GIT_INDEX_FILE"' 0
|
|
|
|
|
2017-12-10 06:07:57 +08:00
|
|
|
git read-tree "$GIT_MAN_REF"
|
2011-11-09 02:17:40 +08:00
|
|
|
git checkout-index -a -f --prefix="$destdir"/
|
2006-12-24 00:26:09 +08:00
|
|
|
|
2011-11-09 02:17:40 +08:00
|
|
|
if test -n "$GZ"
|
|
|
|
then
|
2017-12-10 06:07:57 +08:00
|
|
|
git ls-tree -r --name-only "$GIT_MAN_REF" |
|
2011-11-09 02:17:40 +08:00
|
|
|
xargs printf "$destdir/%s\n" |
|
2007-08-07 12:15:15 +08:00
|
|
|
xargs gzip -f
|
2006-12-24 00:26:09 +08:00
|
|
|
fi
|
|
|
|
rm -f "$GIT_INDEX_FILE"
|