tg.sh: avoid problems with special chars in repo path
When creating the temporary ref cache, a bunch of ref names
need to have a value prefixed to them that may contain a
space or other regexpy character without having it cause
problems.
Replace sed with awk, add tr and use xargs -0 to make sure
that none of these unfortunate characters cause problems.
Note that prior to 0.19.5 this would only have been an issue
when using a non-main worktree and the path to its --git-dir
contained any special character (including a space).
Prior to 0.19.4 non-main worktrees probably didn't work very
well with TopGit anyway.
However, with 0.19.5, the path to the temporary directory was
changed to a full path so even main worktrees became affected.
This fix therefore became more important at that point.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>