git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars Hjemli <hjemli@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 1/3] Make git-branch honor -v when showing remote branches
Date: Sun, 22 Oct 2006 00:33:22 +0200	[thread overview]
Message-ID: <11614700063520-git-send-email-hjemli@gmail.com> (raw)
In-Reply-To: <1161470004894-git-send-email-hjemli@gmail.com>

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 git-branch.sh |   74 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 47 insertions(+), 27 deletions(-)

diff --git a/git-branch.sh b/git-branch.sh
index ab58737..25abd4c 100755
--- a/git-branch.sh
+++ b/git-branch.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r | -v'
+USAGE='[-r] [-v] | (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>]'
 LONG_USAGE='If no arguments, show available branches and mark current branch with a star.
 If one argument, create a new branch <branchname> based off of current HEAD.
 If two arguments, create a new branch <branchname> based off of <start-point>.'
@@ -48,15 +48,48 @@ If you are sure you want to delete it, r
     exit 0
 }
 
-ls_remote_branches () {
-    git-rev-parse --symbolic --all |
-    sed -ne 's|^refs/\(remotes/\)|\1|p' |
-    sort
-}
-
 force=
 create_log=
 verbose=
+remotes=
+
+ls_remote_branches () {
+	git-rev-parse --symbolic --all |
+	sed -ne 's|^refs/\(remotes/\)|\1|p' |
+	sort |
+	while read ref
+	do
+		if test "$verbose" = "yes"
+		then
+			log=$(git-log --max-count=1 --pretty=oneline $ref)
+			printf "%-20s %s\n" "$ref" "$log"
+		else
+			echo "$ref"
+		fi
+	done
+}
+
+ls_local_branches() {
+	git-rev-parse --symbolic --branches |
+	sort |
+	while read ref
+	do
+		if test "$headref" = "$ref"
+		then
+			pfx='*'
+		else
+			pfx=' '
+		fi
+		if test "$verbose" = "yes"
+		then
+			log=$(git-log --max-count=1 --pretty=oneline $ref)
+			printf "%s %-20s %s\n" "$pfx" "$ref" "$log"
+		else
+			echo "$pfx $ref"
+		fi
+	done
+}
+
 while case "$#,$1" in 0,*) break ;; *,-*) ;; *) break ;; esac
 do
 	case "$1" in
@@ -65,8 +98,7 @@ do
 		exit
 		;;
 	-r)
-		ls_remote_branches
-		exit
+		remotes="yes"
 		;;
 	-f)
 		force="$1"
@@ -90,24 +122,12 @@ done
 
 case "$#" in
 0)
-	git-rev-parse --symbolic --branches |
-	sort |
-	while read ref
-	do
-		if test "$headref" = "$ref"
-		then
-			pfx='*'
-		else
-			pfx=' '
-		fi
-		if test "$verbose" = "yes"
-		then
-			log=$(git-log --max-count=1 --pretty=oneline $ref)
-			printf "%s %-20s %s\n" "$pfx" "$ref" "$log"
-		else
-			echo "$pfx $ref"
-		fi
-	done
+	if test "$remotes" = "yes"
+	then
+		ls_remote_branches
+	else
+		ls_local_branches
+	fi
 	exit 0 ;;
 1)
 	head=HEAD ;;
-- 
1.4.3.1

  reply	other threads:[~2006-10-21 22:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-21 22:33 [PATCH 0/3] Extend git-branch list output Lars Hjemli
2006-10-21 22:33 ` Lars Hjemli [this message]
2006-10-21 22:33 ` [PATCH 2/3] git-branch: Add -w option to adjust branchname column width Lars Hjemli
2006-10-21 22:33 ` [PATCH 3/3] Update documentation for git-branch Lars Hjemli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11614700063520-git-send-email-hjemli@gmail.com \
    --to=hjemli@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).