`magit-guess-branch': use new func `magit-get-previous-branch'

Instead of depending on git-log(1)'s "--grep-reflog" flag (which
was only added in Git v1.8.0 [1]) and potentially doing a whole
bunch of string matching, use git-rev-parse(1) with the @{-N}
construct, which is supported since Git v1.6.2 [2].

As an added benefit, we now return nil instead of an invalid
refname when the previously checked out branch no longer exists.

[1] git/git@72fd13f7
[2] git/git@d18ba221

Signed-off-by: Pieter Praet <pieter@praet.org>
Merge pull request #793 from praet/get-prev-branch

`magit-guess-branch': use new func `magit-get-previous-branch'
Some better use of with-current buffer

  (save-current-buffer
    (set-buffer (process-buffer proc))
    ...)

is the same than with-current-buffer,
and when using with-current-buffer, one do not need to set the buffer a
second time.
Merge pull request #796 from vanicat/t/some-cleanup

Some better use of with-current buffer
set $GIT_EDITOR from scratch, add client-less fallback

Add new variable `magit-emacsclient-executable'.  Its default value is
set by searching for an executable in the same directory the executable
of the running Emacs instance is located in or if it cannot be found
there anywhere on `exec-path'.  This should virtually always return
something usable.  If it doesn't then something is seriously wrong with
the Emacs installation.

We first limit the search to the directory containing the invoked Emacs
executable because multiple Emacs version might be installed and the
emacsclient earliest on the `exec-path' might not be compatible with
the running Emacs.

No longer base the $GIT_EDITOR that is eventually used by Magit when
calling git on $GIT_EDITOR or $EDITOR as set in the environment of the
running Emacs.  Instead of detecting and fixing bad values optained that
way always set $GIT_EDITOR from scratch.

Add alternative code paths to `magit-commit' and `magit-tag' that do not
require a working client/server interaction.  When using tramp and when
no window system is available also use these fallbacks.

This can still be improved a lot.  But at least we are no longer set on
a path that forces us add one kludge after another on top of the
existing kludges.

`magit-interactive-rebase' most likely cannot be implemented without the
use of emacsclient so that command now refuses to run if the client
cannot be used.

Remove `magit-git-editor' in favor of `magit-emacsclient-excecutable'.
Rename `magit-with-git-editor' to `magit-with-emacsclient'.
Add `magit-use-emacsclient-p' and `magit-assert-emacsclient'.
magit-commit-internal: use new git-commit-commit-hook
Merge branch 'sane-client'
fix previous commit
fix previous two commits
further improve magit-with-emacsclient
magit-commit-internal: when tagging use TAG_EDITMSG