reflog-walk: don't segfault on non-commit sha1's in the reflog
commitaecad374ae7492cc7b2add5fa416d43e1f68c18e
authorDennis Kaarsemaker <dennis@kaarsemaker.net>
Tue, 5 Jan 2016 21:12:10 +0000 (5 22:12 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Jan 2016 21:41:06 +0000 (5 13:41 -0800)
tree0803b378a4b228e46f6e8c83730590ac345dc694
parent1ff88560c8d22bcdb528a6629239d638f927cb96
reflog-walk: don't segfault on non-commit sha1's in the reflog

git reflog (ab)uses the log machinery to display its list of log
entries. To do so it must fake commit parent information for the log
walker.

For refs in refs/heads this is no problem, as they should only ever
point to commits. Tags and other refs however can point to anything,
thus their reflog may contain non-commit objects.

To avoid segfaulting, we check whether reflog entries are commits before
feeding them to the log walker and skip any non-commits. This means that
git reflog output will be incomplete for such refs, but that's one step
up from segfaulting. A more complete solution would be to decouple git
reflog from the log walker machinery.

Signed-off-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>
Helped-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reflog-walk.c
t/t1410-reflog.sh