Finding the shortest distance is certainly NOT a "topology" problem (distance is not a topological invariant) but this looks very much like a "calculus of variations" problem.
I posted a while ago about finding the shortest distance betwwen 2 points over a surface of varying curvature (ie free form surface).
I have received a suggestion from my thesis supervisor to try and fit a cubic equation by using the boundary conditions, ie start and end point, principle curvatures at these two points. Then integrate over the line to find what the length is to approximate the length. I can see how this would give a reasonable approximation of the length of the geodesic, but is it necessarily the shortest length?
I am interested to see if there are any other suggestions, and if not, how to construct a cubic equation using these boundary conditions.
Attached is the sort of surface I will need to apply this maths to.