Fix segfault bug when no log for HEAD

Might happen after git filter-branch or other commands