I have some tests in my pre-commit hook which require the hash of the previous commit to work.
By previous commit I mean the one that will become the parent of the commit that's being created right now.
Normally, I can just use git rev-parse HEAD.
However, during an --amend commit, the HEAD points to the commit which will be deleted and replaced, so what I really need is HEAD^.
I also a little concerned about rebasing. I have no idea what weird things can happen then.
How can I reliably get the parent commit's hash (as described) in the pre-commit hook?