A sheaf-theoretic characterization of commutative hereditary rings