[PATCH 2/3] Refactor git-branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This moves the code used to display local branches into a
separate function.

Signed-off-by: Lars Hjemli <hjemli@xxxxxxxxx>
---
 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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]