Handle a tagged HEAD properly

Change-Id: I1945c446211eefdd5444a361b87560daf686a51e