Defensive check for gists with no history.

It is possible to have a gist with no history. This should
prevent the server from going down if such a gist is
accessed.
Tweak check for history-less gists.