From: Lars Hjemli <hjemli@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 3/3] Teach git-branch -v and -w options
Date: Sun, 22 Oct 2006 13:30:26 +0200
Date: Sun, 22 Oct 2006 13:20:34 +0200 [thread overview]
Message-ID: <11615166273819-git-send-email-hjemli@gmail.com> (raw)
Message-ID: <18d62bea290e360a4b5b44df9f23265c5e77964e.1161516129.git.hjemli@gmail.com> (raw)
In-Reply-To: <1161516626749-git-send-email-hjemli@gmail.com>
In-Reply-To: <5245bfe3982f5c23841229af9f548f982b9c60c3.1161516129.git.hjemli@gmail.com>
This makes git-branch display sha1 and first line of commit
message for each branch.
Additionaly, the -w option may be used to specify columnwidth
for branchname (default is 20 characters)
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
Documentation/git-branch.txt | 8 ++++++-
git-branch.sh | 47 ++++++++++++++++++++++++++++++++++++-----
2 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index d43ef1d..efbab61 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -8,7 +8,7 @@ git-branch - List, create, or delete bra
SYNOPSIS
--------
[verse]
-'git-branch' [-r]
+'git-branch' [-r] [-v [-w width]]
'git-branch' [-l] [-f] <branchname> [<start-point>]
'git-branch' (-d | -D) <branchname>...
@@ -47,6 +47,12 @@ OPTIONS
-r::
List only the "remote" branches.
+-v::
+ Show sha1 and first line of commit message for each branch
+
+-w <width>::
+ Set columnwidth for branchname display
+
<branchname>::
The name of the branch to create or delete.
The new branch name must pass all checks defined by
diff --git a/git-branch.sh b/git-branch.sh
index 1f628a4..73839b4 100755
--- a/git-branch.sh
+++ b/git-branch.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-USAGE=' [-l] [-f] <branchname> [<start-point>] | (-d | -D) <branchname> | [-r]'
+USAGE=' [-l] [-f] <branchname> [<start-point>] | (-d | -D) <branchname> | [-r] [-v [-w width]]'
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>.'
@@ -49,12 +49,26 @@ If you are sure you want to delete it, r
}
ls_remote_branches () {
+ verbose="$1"
+ width="$2"
git-rev-parse --symbolic --all |
sed -ne 's|^refs/\(remotes/\)|\1|p' |
- sort
+ sort |
+ while read ref
+ do
+ if test "$verbose" = "yes"
+ then
+ log=$(git-log --pretty=oneline --max-count=1 "$ref")
+ printf "%-*s %s\n" "$width" "$ref" "$log"
+ else
+ echo "$ref"
+ fi
+ done
}
ls_local_branches () {
+ verbose="$1"
+ width="$2"
git-rev-parse --symbolic --branches |
sort |
while read ref
@@ -65,12 +79,22 @@ ls_local_branches () {
else
pfx=' '
fi
- echo "$pfx $ref"
+ if test "$verbose" = "yes"
+ then
+ log=$(git-log --pretty=oneline --max-count=1 "$ref")
+ printf "%s %-*s %s\n" "$pfx" "$width" "$ref" "$log"
+ else
+ echo "$pfx $ref"
+ fi
done
}
force=
create_log=
+remotes=
+verbose=
+width=20
+
while case "$#,$1" in 0,*) break ;; *,-*) ;; *) break ;; esac
do
case "$1" in
@@ -79,8 +103,14 @@ do
exit
;;
-r)
- ls_remote_branches
- exit
+ remotes="yes"
+ ;;
+ -v)
+ verbose="yes"
+ ;;
+ -w)
+ shift
+ width="$1"
;;
-f)
force="$1"
@@ -101,7 +131,12 @@ done
case "$#" in
0)
- ls_local_branches
+ if test "$remotes" = "yes"
+ then
+ ls_remote_branches "$verbose" "$width"
+ else
+ ls_local_branches "$verbose" "$width"
+ fi
exit 0 ;;
1)
head=HEAD ;;
--
1.4.3.1.g1688
next prev parent reply other threads:[~2006-10-22 11:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-22 11:30 [PATCH 0/3] Add -v and -w options to git-branch Lars Hjemli
2006-10-22 11:30 ` [PATCH 1/3] Fix usagestring for git-branch Lars Hjemli
2006-10-22 11:30 ` Lars Hjemli
2006-10-22 11:30 ` [PATCH 2/3] Refactor git-branch Lars Hjemli
2006-10-22 11:30 ` Lars Hjemli
2006-10-22 11:30 ` Lars Hjemli [this message]
2006-10-22 11:30 ` [PATCH 3/3] Teach git-branch -v and -w options Lars Hjemli
2006-10-22 19:35 ` Junio C Hamano
2006-10-22 19:55 ` Lars Hjemli
[not found] ` <8c5c35580610221254r7a5a009cg7ee9a9d5821f5e99@mail.gmail.com>
[not found] ` <7vy7r83x9f.fsf@assigned-by-dhcp.cox.net>
2006-10-22 20:50 ` 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=11615166273819-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.