Update TO script, and also some UI issues.
[git.git] / dodoc.sh
1 #!/bin/sh
2 #
3 # This script is called from the post-update hook, and when
4 # the master branch is updated, run in $HOME/git-doc, like
5 # this:
6 : <<\END_OF_COMMENTARY
7
8 $ cat >hooks/post-update
9 #!/bin/sh
10 case " $* " in
11 *' refs/heads/master '*)
12         echo $HOME/git-doc/dodoc.sh | at now
13         ;;
14 esac
15 exec git-update-server-info
16 $ chmod +x hooks/post-update
17
18 END_OF_COMMENTARY
19
20 # $HOME/git-doc is a clone of the git.git repository and
21 # has the master branch checkd out.  We update the working
22 # tree and build pre-formatted documentation pages, install
23 # in doc-htmlpages and doc-manapges subdirectory here.
24 # These two are their own git repository, and when they are
25 # updated the updates are pushed back into their own branches
26 # in git.git repository.
27
28 ID=`git-rev-parse --verify refs/heads/master` || exit $?
29
30 unset GIT_DIR
31
32 PUBLIC=/pub/software/scm/git/docs &&
33 MASTERREPO=`pwd` &&
34 DOCREPO=`dirname "$0"` &&
35 test "$DOCREPO" != "" &&
36 cd "$DOCREPO" || exit $?
37
38 git pull "$MASTERREPO" master &&
39 test $(git-rev-parse --verify refs/heads/master) == "$ID" &&
40 NID=$(git-describe --abbrev=4 "$ID") &&
41 test '' != "$NID" ||  exit $?
42
43 # Set up subrepositories
44 test -d doc-htmlpages || (
45         mkdir doc-htmlpages &&
46         cd doc-htmlpages &&
47         git init-db || exit $?
48
49         if SID=$(git fetch-pack "$MASTERREPO" html)
50         then
51                 git update-ref HEAD `expr "$SID" : '\(.*\) .*'` &&
52                 git checkout || exit $?
53         fi
54 )
55 test -d doc-manpages || (
56         mkdir doc-manpages &&
57         cd doc-manpages &&
58         git init-db || exit $?
59
60         if SID=$(git fetch-pack "$MASTERREPO" man)
61         then
62                 git update-ref HEAD `expr "$SID" : '\(.*\) .*'` &&
63                 git checkout || exit $?
64         fi
65 )
66 find doc-htmlpages doc-manpages -type d -name '.git' -prune -o \
67         -type f -print0 | xargs -0 rm -f
68
69 cd Documentation &&
70 make WEBDOC_DEST="$DOCREPO/doc-htmlpages" install-webdoc >../:html.log 2>&1 &&
71
72 if test -d $PUBLIC
73 then
74         make WEBDOC_DEST="$PUBLIC" install-webdoc >>../:html.log 2>&1
75 else
76         echo "* No public html at $PUBLIC"
77 fi || exit $?
78
79 cd ../doc-htmlpages &&
80     git add . &&
81     if git commit -a -m "Autogenerated HTML docs for $NID"
82     then
83         git-send-pack "$MASTERREPO" master:refs/heads/html || {
84             echo "* HTML failure"
85             exit 1
86         }
87     else
88         echo "* No changes in html docs"
89     fi
90
91 cd ../Documentation &&
92 make man1="$DOCREPO/doc-manpages/man1" man7="$DOCREPO/doc-manpages/man7" \
93         install >../:man.log 2>&1 &&
94
95 cd ../doc-manpages &&
96     git add . &&
97     if git commit -a -m "Autogenerated man pages for $NID"
98     then
99         git-send-pack "$MASTERREPO" master:refs/heads/man || {
100             echo "* man failure"
101             exit 1
102         }
103     else
104         echo "* No changes in manual pages"
105     fi
106