shell-common: fix detection of detached head

It appears more recent versions of Git implement show-ref differently
than in the past.  However, I should've been detecting this differently
anyways.  Use the same technique as earlier in the script for detecting
detached head.  This also fixes status reporting when your branch may be
ahead of master, when there is no upstream branch yet.