3 # Ensures that the working tree is clean, and Documentation/ is up to
4 # date, and then commits Documentation/*.1 to the man branch, and
5 # Documentation/*.html to the html branch.
11 # Must be full ref name, i.e. refs/heads/man, etc.
15 git diff-index --quiet HEAD -- # no uncommitted changes
16 git rev-parse --verify "$man_ref"
17 git rev-parse --verify "$html_ref"
18 echo "$man_ref" | grep -qE '^refs/heads'
19 echo "$html_ref" | grep -qE '^refs/heads'
23 tmpdir="$(mktemp -d "t/tmp/update-doc-branches-XXXXXX")"
24 trap "$(printf 'rm -rf %q' "$tmpdir")" EXIT
25 tmpidx="$tmpdir/git-index.tmp"
27 for fmt in man html; do
29 for f in $(git ls-files 'Documentation/*.md'); do
30 base="$(basename "$f" .md)"
31 if test "$fmt" = man; then
33 GIT_INDEX_FILE="$tmpidx" git add -f "Documentation/$base.1"
36 GIT_INDEX_FILE="$tmpidx" git add -f "Documentation/$base.html"
39 msg="Update $fmt pages for $(git describe --always)"
40 tree=$(GIT_INDEX_FILE="$tmpidx" git write-tree --prefix=Documentation)
41 commit=$(echo "$msg" | git commit-tree "$tree" -p refs/heads/"$fmt")
42 git update-ref "$ref" "$commit"