salt.utils.gitfs: Fix Dulwich env detection and submodule handling
salt.utils.gitfs: Fix Dulwich env detection and submodule handling

I broke this in dae738f. I mistakenly thought I saw both head refs and
remote refs in the fetch results, so by consolidating the code that
resolves refnames into environment names I ensured that the head refs
which were fetched would never be seen as fileserver environments.

This commit fixes #29684 by converting the names of the fetched head
refs to remote refs. Corresponding changes were also made to the
get_tree() function (as the refnames are now different).

Additionally, I discovered that Dulwich does not track information about
submodules, resulting in a KeyError when compiling a list of files. This
is the same issue that also affected Pygit2 and was fixed in 8c4ea64.
I've made a similar fix for it here.

saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt