[PATCH] Check for valid branch when building

Werner Almesberger werner at openmoko.org
Fri Feb 20 03:11:32 CET 2009


Nelson Castillo wrote:
> * Print a nice message if we are not in a valid branch.

Good idea !

> +[[ `git-branch | head -1` =~ "* (no branch)" ]] && echo -e "\nThere is no branch in the local copy of the repository right now!\nHint: type git-branch, make sure you are in a valid branch and then try again" && exit 1
> +

Unfortnately, [[ doesn't exist in /bin/sh, so you'd have to use grep
and such.

The long line is also a bit hard to parse. Wouldn't something like

if ... | grep -q ...; then
    cat <<EOF 1>&2
There is no branch in the local copy of the repository right now!
Hint: type git-branch, make sure you are in a valid branch and then try again
EOF
    exit 1
fi

look nicer ?

Thanks,
- Werner



More information about the openmoko-kernel mailing list