tg.sh: ensure ensure_clean_tree works on unborn branches
The ensure_clean_tree function checks, among other things, to see
whether or not there are any changes sitting in the index that have
yet to be committed.
This can definitely still be the case (or not) for an unborn branch,
but it's not possible to detect it by diff'ing against 'HEAD' in
such a case since there is no valid HEAD yet.
Instead, when HEAD is not yet valid (i.e. it's an unborn branch),
diff against the empty tree.
Since Git v1.5.5 it's not even necessary for the empty tree to
actually be a real object in the repository for it to be used as a
diff target.
Update the setup_hashalgo_vars function to make "$mttree" available
as the appropriate empty tree hash to use for the current repository
and update ensure_clean_tree to use that whenever HEAD is not yet
valid. This ensures that ensure_clean_tree gets the correct result
even when dealing with unborn branches.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>