Make hook work properly on initial commit

See [pre-commit.sample](https://github.com/git/git/blob/master/templates/hooks--pre-commit.sample#L10).