apply: refactor read_file_or_gitlink()