Refactor reference building
Add optional ignoredErrorCodes on git_foreach