builtin-branch: improve output when displaying remote branches
When encountering a symref (typically refs/remotes/<remote>/HEAD),
display the ref target.
When displaying local and remote branches, prefix the remote branch
names with "remotes/" to make the remote branches clear from the local
branches. If displaying only the remote branches, the prefix is not
shown since it would be redundant.
Sample output:
$ git branch
foo -> master
* master
rather-long-branch-name
$ git branch -v
foo -> master
* master
51cecb2 initial
rather-long-branch-name
51cecb2 initial
$ git branch -v --no-abbrev
foo -> master
* master
51cecb2dbb1a1902bb4df79b543c8f951ee59d83 initial
rather-long-branch-name
51cecb2dbb1a1902bb4df79b543c8f951ee59d83 initial
$ git branch -r
frotz/HEAD -> frotz/master
frotz/master
origin/HEAD -> origin/master
origin/UNUSUAL -> refs/heads/master
origin/master
$ git branch -a
foo -> master
* master
rather-long-branch-name
remotes/frotz/HEAD -> frotz/master
remotes/frotz/master
remotes/origin/HEAD -> origin/master
remotes/origin/UNUSUAL -> refs/heads/master
remotes/origin/master
$ git branch -rv
frotz/HEAD -> frotz/master
frotz/master
e1d8130 added file2
origin/HEAD -> origin/master
origin/UNUSUAL -> refs/heads/master
origin/master
e1d8130 added file2
$ git branch -av
foo -> master
* master
51cecb2 initial
rather-long-branch-name
51cecb2 initial
remotes/frotz/HEAD -> frotz/master
remotes/frotz/master
e1d8130 added file2
remotes/origin/HEAD -> origin/master
remotes/origin/UNUSUAL -> refs/heads/master
remotes/origin/master
e1d8130 added file2
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>