move definitions of functions and variables used for log washing
magit-mode-setup: abort if not inside a repository

Previously we ended up setting `default-directory' to nil in
`magit-mode-init'.  While doing that is always a bad idea in this
case the result was fatal; for some reason it caused Emacs to enter
an endless loop and neither C-g nor ESC where able to break it.

Close #1255.