Rewrite documentation hook
authorJunio C Hamano <junkio@cox.net>
Tue, 27 Dec 2005 08:04:15 +0000 (00:04 -0800)
committerJunio C Hamano <junkio@cox.net>
Tue, 27 Dec 2005 08:04:15 +0000 (00:04 -0800)
R [deleted file]
dodoc.sh [new file with mode: 0755]

diff --git a/R b/R
deleted file mode 100755 (executable)
index 146ad70..0000000
--- a/R
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-m=$(git-rev-parse "master^0")
-for branch
-do
-       b=$(git-rev-parse "$branch^0")
-       case "$(git-merge-base --all "$b" "$m")" in
-       "$m")
-               echo >&2 "$branch: up to date"
-               continue
-               ;;
-       esac
-       git-show-branch "$branch" master
-       while :
-       do
-               echo -n >&2 "Rebase $branch [Y/n]? "
-               read ans
-               case "$ans" in
-               [Yy]*)
-                       git rebase master "$branch" || exit
-                       break
-                       ;;
-               [Nn]*)
-                       echo >&2 "Not rebasing $branch"
-                       break
-                       ;;
-               *)
-                       echo >&2 "Sorry, I could not hear you"
-                       ;;
-               esac
-       done
-done
diff --git a/dodoc.sh b/dodoc.sh
new file mode 100755 (executable)
index 0000000..2bb0880
--- /dev/null
+++ b/dodoc.sh
@@ -0,0 +1,104 @@
+#!/bin/sh
+#
+# This script is called from the post-update hook, and when
+# the master branch is updated, run in $HOME/doc-git, like
+# this:
+: <<\END_OF_COMMENTARY
+
+$ cat >hooks/post-update
+#!/bin/sh
+case " $* " in
+*' refs/heads/master '*)
+        echo $HOME/git-doc/dodoc.sh | at now
+        ;;
+esac
+exec git-update-server-info
+$ chmod +x hooks/post-update
+
+END_OF_COMMENTARY
+
+# $HOME/doc-git is a clone of the git.git repository and
+# has the master branch checkd out.  We update the working
+# tree and build pre-formatted documentation pages, install
+# in doc-htmlpages and doc-manapges subdirectory here.
+# These two are their own git repository, and when they are
+# updated the updates are pushed back into their own branches
+# in git.git repository.
+
+ID=`git-rev-parse --verify refs/heads/master` || exit $?
+
+unset GIT_DIR
+
+PUBLIC=/pub/software/scm/git/docs &&
+MASTERREPO=`pwd` &&
+DOCREPO=`dirname "$0"` &&
+test "$DOCREPO" != "" &&
+cd "$DOCREPO" || exit $?
+
+git pull "$MASTERREPO" master &&
+test $(git-rev-parse --verify refs/heads/master) == "$ID" ||  exit $?
+
+# Set up subrepositories
+test -d doc-htmlpages || (
+       mkdir doc-htmlpages &&
+       cd doc-htmlpages &&
+       git init-db || exit $?
+
+       if ID=$(git fetch-pack "$MASTERREPO" html)
+       then
+               git update-ref HEAD `expr "$ID" : '\(.*\) .*'` &&
+               git checkout || exit $?
+       fi
+)
+test -d doc-manpages || (
+       mkdir doc-manpages &&
+       cd doc-manpages &&
+       git init-db || exit $?
+
+       if ID=$(git fetch-pack "$MASTERREPO" man)
+       then
+               git update-ref HEAD `expr "$ID" : '\(.*\) .*'` &&
+               git checkout || exit $?
+       fi
+)
+find doc-htmlpages doc-manpages -type d -name '.git' -prune -o \
+       -type f -print0 | xargs -0 rm -f
+
+cd Documentation &&
+make WEBDOC_DEST="$DOCREPO/doc-htmlpages" install-webdoc >../:html.log 2>&1 &&
+
+if test -d $PUBLIC
+then
+       make WEBDOC_DEST="$PUBLIC" install-webdoc >>../:html.log 2>&1
+else
+       echo "* No public html at $PUBLIC"
+fi || exit $?
+
+cd ../doc-htmlpages &&
+    git add . &&
+    if git commit -a -m "Autogenerated HTML docs for $ID"
+    then
+       git-send-pack "$MASTERREPO" master:refs/heads/html || {
+           echo "* HTML failure"
+           exit 1
+       }
+    else
+       echo "* No changes in html docs"
+    fi
+
+cd ../Documentation &&
+make man1="$DOCREPO/doc-manpages/man1" man7="$DOCREPO/doc-manpages/man7" \
+       install >../:man.log 2>&1 &&
+
+cd ../doc-manpages &&
+    git add . &&
+    if git commit -a -m "Autogenerated man pages for $ID"
+    then
+       git-send-pack "$MASTERREPO" master:refs/heads/man || {
+           echo "* man failure"
+           exit 1
+        }
+    else
+       echo "* No changes in manual pages"
+    fi
+