X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-branch.sh;h=134e68cf7f0389d73af000c4303c4dda27f89d57;hb=d177e584255aad351bbbff14aba8e73afc008c75;hp=b0e54ed2af9dbf06e79b7230a62029ee2ee8a269;hpb=c2f3bf071ee90b01f2d629921bb04c4f798f02fa;p=git.git diff --git a/git-branch.sh b/git-branch.sh index b0e54ed2..134e68cf 100755 --- a/git-branch.sh +++ b/git-branch.sh @@ -1,6 +1,6 @@ #!/bin/sh -USAGE='[-d ] | [[-f] [start-point]]' +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