The UK government has agreed a post-Brexit deal on Gibraltar, unpicking another issue it’s negotiations with the bloc.