git-trunk: Address review issues

Put a few comments into the code to make it more clear what it is doing and a
few other thingies related to error handling.

Change-Id: 6506349030
Story-Id: 78913390