blob: 17231d8e5959a9b16753b4c4a617e8c2decf5171 [file] [log] [blame]
Eric Wong6538d1e2006-12-23 08:26:09 -08001#!/bin/sh
Junio C Hamanofcbebfd2011-11-08 10:17:40 -08002# This requires git-manpages and/or git-htmldocs repositories
Eric Wong6538d1e2006-12-23 08:26:09 -08003
Junio C Hamanofcbebfd2011-11-08 10:17:40 -08004repository=${1?repository}
5destdir=${2?destination}
Randall S. Becker65289e92017-12-09 17:07:57 -05006GIT_MAN_REF=${3?master}
Junio C Hamanofcbebfd2011-11-08 10:17:40 -08007
Randall S. Becker65289e92017-12-09 17:07:57 -05008GIT_DIR=
Junio C Hamanofcbebfd2011-11-08 10:17:40 -08009for d in "$repository/.git" "$repository"
10do
Randall S. Becker65289e92017-12-09 17:07:57 -050011 if GIT_DIR="$d" git rev-parse "$GIT_MAN_REF" >/dev/null 2>&1
Junio C Hamanofcbebfd2011-11-08 10:17:40 -080012 then
13 GIT_DIR="$d"
14 export GIT_DIR
15 break
16 fi
17done
18
19if test -z "$GIT_DIR"
20then
21 echo >&2 "Neither $repository nor $repository/.git is a repository"
22 exit 1
Eric Wong6538d1e2006-12-23 08:26:09 -080023fi
24
Junio C Hamanofcbebfd2011-11-08 10:17:40 -080025GIT_WORK_TREE=$(pwd)
26GIT_INDEX_FILE=$(pwd)/.quick-doc.$$
27export GIT_INDEX_FILE GIT_WORK_TREE
Eric Wong6538d1e2006-12-23 08:26:09 -080028rm -f "$GIT_INDEX_FILE"
Junio C Hamano00d8c512007-08-04 23:48:27 -070029trap 'rm -f "$GIT_INDEX_FILE"' 0
30
Randall S. Becker65289e92017-12-09 17:07:57 -050031git read-tree "$GIT_MAN_REF"
Junio C Hamanofcbebfd2011-11-08 10:17:40 -080032git checkout-index -a -f --prefix="$destdir"/
Eric Wong6538d1e2006-12-23 08:26:09 -080033
Junio C Hamanofcbebfd2011-11-08 10:17:40 -080034if test -n "$GZ"
35then
Randall S. Becker65289e92017-12-09 17:07:57 -050036 git ls-tree -r --name-only "$GIT_MAN_REF" |
Junio C Hamanofcbebfd2011-11-08 10:17:40 -080037 xargs printf "$destdir/%s\n" |
Junio C Hamano87027ae2007-08-06 21:15:15 -070038 xargs gzip -f
Eric Wong6538d1e2006-12-23 08:26:09 -080039fi
40rm -f "$GIT_INDEX_FILE"