Thread (4 messages) flat view 4 messages, 1 author, 2016-06-15
DORMANTno replies

[PATCH 2/3] Refactor git-branch

From: Lars Hjemli <hidden>
Date: 2016-06-15 22:42:45
Subsystem: the rest · Maintainer: Linus Torvalds

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

Signed-off-by: Lars Hjemli <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help