Merge pull request #6219 from apnadkarni/patch-2 Free parent and ref in lg2_commit before returning.