kollerma/git-submodule-tools — pull request #1 by phord (2011-11-30 17:51:39+00:00)
Title: Fix scripts to work with gitfiles (pseudo-symlinks)

In git v1.5.4, gitfiles were born. These files are like symlinks
but are cross-platform. They're _not_ symlinks, and so they do
not actually link transparently to some remote directory. Instead
they are text files containing information about a remote directory.
They allow a .git directory to exist elsewhere rather than actually
in the workdir's ".git/" space.

Since git v1.7.8 gitfiles are used for all submodules. Therefore
things like "cat .git/HEAD" no longer work in submodules.

You can find the real gitdir like this:
` gitdir=$(git rev-parse --git-dir)`

But it looks like all three locations that are doing "cat .git/HEAD"
are really checking to see if HEAD is detatched. This can be tested
using this command instead:
` git symbolic-ref HEAD`

If we're on a detached head, this command returns an error.

So, update the scripts to test for detached head using a standard
git-icism instead of relying on foreknowledge of the .git directory
internals.