refspec: consolidate ref-prefix generation logic