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

[PATCH 2/3] git-branch: Add -w option to adjust branchname column width

From
LHLars Hjemli <hjemli@gmail.com>
Date
Oct 21, 2006, 22:33 UTC
Message-ID
<11614700063082-git-send-email-hjemli@gmail.com>
In-Reply-To
<1161470004894-git-send-email-hjemli@gmail.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 git-branch.sh |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/git-branch.sh b/git-branch.sh
index 25abd4c..0d9eb06 100755
--- a/git-branch.sh
+++ b/git-branch.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-USAGE='[-r] [-v] | (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>]'
+USAGE='[-r] [-v [-w <width>]] | (-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>.'
@@ -52,6 +52,7 @@ force=
 create_log=
 verbose=
 remotes=
+width=20
 
 ls_remote_branches () {
 	git-rev-parse --symbolic --all |
@@ -62,7 +63,7 @@ ls_remote_branches () {
 		if test "$verbose" = "yes"
 		then
 			log=$(git-log --max-count=1 --pretty=oneline $ref)
-			printf "%-20s %s\n" "$ref" "$log"
+			printf "%-*s %s\n" "$width" "$ref" "$log"
 		else
 			echo "$ref"
 		fi
@@ -83,7 +84,7 @@ ls_local_branches() {
 		if test "$verbose" = "yes"
 		then
 			log=$(git-log --max-count=1 --pretty=oneline $ref)
-			printf "%s %-20s %s\n" "$pfx" "$ref" "$log"
+			printf "%s %-*s %s\n" "$pfx" "$width" "$ref" "$log"
 		else
 			echo "$pfx $ref"
 		fi
@@ -108,6 +109,10 @@ do
 		;;
 	-v)
 		verbose="yes"
+		;;
+	-w)
+		shift
+		width="$1"
 		;;
 	--)
 		shift
-- 
1.4.3.1
Previous: Lars HjemliNext: Lars Hjemli
Message 3 of 4 in “Extend git-branch list output”
  1. 0/3 Extend git-branch list outputLars Hjemli, Oct 21, 2006
  2. 1/3 Make git-branch honor -v when showing remote branchesLars Hjemli, Oct 21, 2006
  3. 2/3 git-branch: Add -w option to adjust branchname column widthLars Hjemli, Oct 21, 2006
  4. 3/3 Update documentation for git-branchLars Hjemli, Oct 21, 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.