checkout: fix bug with --to and relative HEAD