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

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

 



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

-
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]