From: Lars Hjemli Date: Sun, 22 Oct 2006 11:30:25 GMT Subject: [PATCH 2/3] Refactor git-branch Message-ID: <11615166272930-git-send-email-hjemli@gmail.com> In-Reply-To: <1161516626749-git-send-email-hjemli@gmail.com> This moves the code used to display local branches into a separate function. Signed-off-by: Lars Hjemli --- git-branch.sh | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-) diff --git a/git-branch.sh b/git-branch.sh index b80bcda..1f628a4 100755 --- a/git-branch.sh +++ b/git-branch.sh @@ -54,6 +54,21 @@ ls_remote_branches () { sort } +ls_local_branches () { + git-rev-parse --symbolic --branches | + sort | + while read ref + do + if test "$headref" = "$ref" + then + pfx='*' + else + pfx=' ' + fi + echo "$pfx $ref" + done +} + force= create_log= while case "$#,$1" in 0,*) break ;; *,-*) ;; *) break ;; esac @@ -86,18 +101,7 @@ done case "$#" in 0) - git-rev-parse --symbolic --branches | - sort | - while read ref - do - if test "$headref" = "$ref" - then - pfx='*' - else - pfx=' ' - fi - echo "$pfx $ref" - done + ls_local_branches exit 0 ;; 1) head=HEAD ;; -- 1.4.3.1.g1688