Make git state compatible with numeric revisions. Fix #9718

I tried to add a test but could not execute the test suite.