Factor out rev-parse --verify calls to new ref_exists() function