remote-curl: move ref-parsing code up in file