magit-diff-visit-file: use magit-find-file when appropriate

When visiting a committed change and the commit isn't the HEAD commit
then visit the file using `magit-find-file-noselect' instead of visiting
the working tree.

This partially implements #1566.
magit-{,branch-or-}commit-at-point: in rev buffers return shown rev

In `magit-revision-mode' buffers `magit-branch-or-commit-at-point' and
`magit-commit-at-point' now return the commit shown in that buffer.
magit-diff-dwim: bugfix
magit-section-set-visibility-hook: new variable

Add new hook variable `magit-section-set-visibility-hook'.  Run it
in `magit-insert-section' to set the visibility of a section, before
all the other approaches used to decide whether the section should
be shown or not.  Hook functions have to return nil if they don't
care, else `hide' or `show'.
preserve visibility of files in revision buffer

Moving point in the log buffer automatically updates the revision
buffer.  In that buffer file sections (and most other sections) start
out expanded, but if the user collapses a section then it stays that
way when displaying another commit.  Except that it doesn't always,
e.g. if commits A and C modify foo, but B only modifies bar, then
hiding foo in A will be forgotten in B and once C is displayed it is
expanded again.

Counter that by keeping a buffer-local list of files that are to be
hidden again the next time they are encountered.
magit-diff-visit-file: bugfix
rename magit-read-top-dir to magit-read-repository
magit-read-repository: rename argument

Rename `magit-read-repository's argument DIR to the more descriptive
READ-DIRECTORY-NAME and make it optional, and remove the incomplete
doc-string.
magit-{status,init}: fix and improve

When `magit-init' or `magit-status' is used to create a new repository,
then directory chosen by the user likely does not exist.  In that case
we cannot use `magit-get-top-dir' because that only works in existing
directories.  Create `magit-toplevel-safe' to use when it is unknown
whether the directory in question exists.

In `magit-status' cleanly separate the "initialize" special case from
the rest, previously it was not possible to create a new repository
inside another using this command.  As a result this command is no
longer suitable for non-interactive use and `magit-status-internal'
has to be factored out.

In `magit-init' create its parent directory before creating the new
repository.  Refactor some more.

Improve the doc-string.
Merge branch 'n/fix-init' into next
rename magit-list-repos* to magit-list-repos-1
magit-list-repos-1: cosmetics
magit-diff-wash-revision: properly deal with empty message
magit-diff-wash-revision: don't insert any buttons

There are many sections for which it could potentially be useful to turn
them into buttons.  That's a long time goal.  There is no good reason to
use buttons for the "merged commit" sections insert by this function,
when we don't do the same elsewhere too.
magit-list-{contained,merged}-branches: new functions
magit-diff-wash-revision: insert parents, related branches, tags
rename magit-insert-{status-tags-line => tags-header}
Merge branch 'n/revision-headers' into next