reset.c: extract function for updating {ORIG_,}HEAD