git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] Refactor git-branch

From
LHLars Hjemli <hjemli@gmail.com>
Date
Oct 22, 2006, 11:30 UTC
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 <hjemli@gmail.com>
---
 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
Previous: Lars HjemliNext: Lars Hjemli
Message 3 of 7 in “Add -v and -w options to git-branch”
  1. 0/3 Add -v and -w options to git-branchLars Hjemli, Oct 22, 2006
  2. 1/3 Fix usagestring for git-branchLars Hjemli, Oct 22, 2006
  3. 2/3 Refactor git-branchLars Hjemli, Oct 22, 2006
  4. 3/3 Teach git-branch -v and -w optionsLars Hjemli, Oct 22, 2006
  5. Junio C HamanoOct 22, 2006
  6. Lars HjemliOct 22, 2006
  7. Lars HjemliOct 22, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.