X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-branch.sh;h=134e68cf7f0389d73af000c4303c4dda27f89d57;hb=51ce34b9923d9b119ac53414584f80e05520abea;hp=6ac961e6d18b8419abdaa5ed57a55ef58f7bc0fb;hpb=8fedb83c05d4b3d877a220d614e8b9d40f02709d;p=git.git diff --git a/git-branch.sh b/git-branch.sh index 6ac961e6..134e68cf 100755 --- a/git-branch.sh +++ b/git-branch.sh @@ -1,6 +1,6 @@ #!/bin/sh -USAGE='[(-d | -D) ] | [[-f] []]' +USAGE='[(-d | -D) ] | [[-f] []] | -r' LONG_USAGE='If no arguments, show available branches and mark current branch with a star. If one argument, create a new branch based off of current HEAD. If two arguments, create a new branch based off of .' @@ -48,6 +48,12 @@ If you are sure you want to delete it, run 'git branch -D $branch_name'." exit 0 } +ls_remote_branches () { + git-rev-parse --symbolic --all | + sed -ne 's|^refs/\(remotes/\)|\1|p' | + sort +} + force= while case "$#,$1" in 0,*) break ;; *,-*) ;; *) break ;; esac do @@ -56,6 +62,10 @@ do delete_branch "$@" exit ;; + -r) + ls_remote_branches + exit + ;; -f) force="$1" ;; @@ -72,8 +82,7 @@ done case "$#" in 0) - git-rev-parse --symbolic --all | - sed -ne 's|^refs/heads/||p' | + git-rev-parse --symbolic --branches | sort | while read ref do