Why can't we commit on a detached HEAD?  Its supposed in C Git just fine.

I think you really just need to check that head != null here.  If its null, we're unable to continue and should throw.  But if its non-null we're OK and keep going.