Geodesics and horizontal-path spaces in sub-Riemannian geometry