archive: handle commits with an empty tree
[git/jnareb-git.git] / Documentation / install-doc-quick.sh
blob327f69bcf5a20c7cf33a712b08bed9d4ccfe9d2e
1 #!/bin/sh
2 # This requires git-manpages and/or git-htmldocs repositories
4 repository=${1?repository}
5 destdir=${2?destination}
7 head=master GIT_DIR=
8 for d in "$repository/.git" "$repository"
9 do
10 if GIT_DIR="$d" git rev-parse refs/heads/master >/dev/null 2>&1
11 then
12 GIT_DIR="$d"
13 export GIT_DIR
14 break
16 done
18 if test -z "$GIT_DIR"
19 then
20 echo >&2 "Neither $repository nor $repository/.git is a repository"
21 exit 1
24 GIT_WORK_TREE=$(pwd)
25 GIT_INDEX_FILE=$(pwd)/.quick-doc.$$
26 export GIT_INDEX_FILE GIT_WORK_TREE
27 rm -f "$GIT_INDEX_FILE"
28 trap 'rm -f "$GIT_INDEX_FILE"' 0
30 git read-tree $head
31 git checkout-index -a -f --prefix="$destdir"/
33 if test -n "$GZ"
34 then
35 git ls-tree -r --name-only $head |
36 xargs printf "$destdir/%s\n" |
37 xargs gzip -f
39 rm -f "$GIT_INDEX_FILE"