Fix getting ref name for upstream tracking