commit: Split out file processing into helper function

There should be no logic change here, just reducing indentation.