checkout: notice when the switched branch is behind or forked
When you are switching to a branch that is marked to merge from
somewhere else, e.g. when you have:
[branch "next"]
remote = upstream
merge = refs/heads/next
[remote "upstream"]
url = ...
fetch = refs/heads/*:refs/remotes/linus/*
and you say "git checkout next", the branch you checked out
may be behind, and you may want to update from the upstream
before continuing to work.
This patch makes the command to check the upstream (in this
example, "refs/remotes/linus/next") and our branch "next", and:
(1) if they match, nothing happens;
(2) if you are ahead (i.e. the upstream is a strict ancestor
of you), one line message tells you so;
(3) otherwise, you are either behind or you and the upstream
have forked. One line message will tell you which and
then you will see a "log --pretty=oneline --left-right".
We could enhance this with an option that tells the command to
check if there is no local change, and automatically fast
forward when you are truly behind. But I ripped out that change
because I was unsure what the right way should be to allow users
to control it (issues include that checkout should not become
automatically interactive).
Signed-off-by: Junio C Hamano <gitster@pobox.com>