9 echo "usage: $0 [-c] [UPSTREAM BUILDABLE]"
17 ## Parse the command-line.
18 bogusp=nil createp=nil
20 while getopts "ch" opt; do
27 shift $(( $OPTIND - 1 ))
28 case $# in 0) ;; 1) bogusp=t ;; *) head=$1 new=$2; shift 2 ;; esac
29 case $# in 0) ;; *) bogusp=t ;; esac
30 case $bogusp in nil) ;; *) fail_usage ;; esac
32 ## Get the current branch name.
36 head=$(git symbolic-ref HEAD)
38 refs/heads/*) head=${head#refs/heads/} ;;
39 *) fail "HEAD is not at a branch head" ;;
42 buildable/*) fail "upstream is already a buildable branch" ;;
47 ## Get the output branch name.
56 if git rev-parse $new -- >/dev/null 2>&1; then
57 fail "branch $new already exists"
59 old=0000000000000000000000000000000000000000
62 old=$(git rev-parse $new --)
66 ## Make a temporary place.
67 git=$(git rev-parse --git-dir)
70 trap "cd; rm -rf \"$dir\"" EXIT INT TERM
74 ## Make a nice clean checkout.
75 GIT_INDEX_FILE=$dir/idx; export GIT_INDEX_FILE
76 GIT_DIR=$git; export GIT_DIR
77 GIT_WORK_TREE=$dir/work; export GIT_WORK_TREE
78 git read-tree "$head^{}"
79 git checkout-index --all
81 ## Go in, and set stuff up. The business with `RELEASE' is kinda scungy.
84 if ! ver=$(git describe --abbrev=4 "$head^{}" 2>/dev/null); then
89 rm -rf autom4te.cache/ RELEASE
91 ## Pick through newly added symlinks and snap them to real files.
92 git ls-files -o | while read f; do
99 ## Add the new files to the tree.
103 t) git commit-tree -p "$head^{}" "$@" $tree ;;
104 nil) git commit-tree -p "$new" -p "$head^{}" "$@" $tree ;;
107 git ls-files -oz | xargs -0r git add -f
108 tree=$(git write-tree)
109 commit=$(commit $tree -m "Update automatically managed build utilities.")
110 git update-ref "refs/heads/$new" $commit $old