title: Programmatically check if HEAD is detached?
body: <p>I want to know whether I'm in a "HEAD detached" state in a script.</p>
  
  <p>Currently I parse the output of <code>git status</code> but I dislike doing so because I've heard that it's a bad practice to parse Git output that's meant for human - I want a program-friendly interface to tell me whether HEAD is detached. I also don't want to manually look into <code>.git/HEAD</code> or parse <code>git description</code> or <code>git branch</code>.</p>
  
  <p>Any ideas?</p>