Correct error catching for new commit object

Creating a new commit object attempts to read res.sha before catching an error.