tg.sh: fix recurse_deps pre-order traversal with remotes enabled
Although there are currently no clients that use recurse_deps in
pre-order mode without also setting no_remotes, fix the output
in that case to be correct anyway.
And, as a result, add a tiny optimization that avoids calling
has_remote on non-tgish deps as it does not make sense to output
a dependency on remotes/<remote>/top-bases/<name> if <name> is
not a TopGit-controlled (and therefore tgish) branch.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>