  We prove the local invertibility, up to potential fields, and stability of
the geodesic X-ray transform on tensor fields of order 1 and 2 near a strictly
convex boundary point, on manifolds with boundary of dimension n>=3. We also
present an inversion formula. Under the condition that the manifold can be
foliated with a continuous family of strictly convex surfaces, we prove a
global result which also implies a lens rigidity result near such a metric. The
class of manifolds satisfying the foliation condition includes manifolds with
no focal points, and does not exclude existence of conjugate points.
