From: "Lars Hjemli" <hjemli@gmail.com>
To: git@vger.kernel.org
Subject: Re: [PATCH 3/3] Teach git-branch -v and -w options
Date: Sun, 22 Oct 2006 21:55:52 +0200 [thread overview]
Message-ID: <8c5c35580610221255n521e84e2u8594016297c6cf87@mail.gmail.com> (raw)
In-Reply-To: <7vmz7o5eki.fsf@assigned-by-dhcp.cox.net>
On 10/22/06, Junio C Hamano <junkio@cox.net> wrote:
> If you are going in this direction, probably you would want to
> refactor 2/3 a bit differently, so that you do not have to
> duplicate the same printf for local and remote cases?
>
I actually did, but then abandoned it since it would change the output
for remote branches (two spaces indent). I didn't want to cause any
regressions :-)
But if that's ok, my abandoned patch contained this:
@@ -48,14 +48,35 @@ 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
-}
-+width=20
+sedmatch="^refs/heads/"
+sedsubst=
+verbose=
force=
create_log=
+
+ls_refs () {
+ git-rev-parse --symbolic --all |
+ sed -ne "s|$sedmatch|$sedsubst|p" |
+ 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 %-*s %s\n" "$pfx" "$width" "$ref" "$log"
+ else
+ echo "$pfx $ref"
+ fi
+ done
+}
+
while case "$#,$1" in 0,*) break ;; *,-*) ;; *) break ;; esac
do
case "$1" in
@@ -64,8 +85,8 @@ do
exit
;;
-r)
- ls_remote_branches
- exit
+ sedmatch="^refs/\(remotes/\)"
+ sedsubst="\1"
;;
-f)
force="$1"
@@ -73,6 +94,13 @@ do
-l)
create_log="yes"
;;
+ -v)
+ verbose="yes"
+ ;;
+ -w)
+ shift
+ width=$1
+ ;;
--)
shift
break
@@ -86,18 +114,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_refs
exit 0 ;;
1)
head=HEAD ;;
And then I added -a and -t (for "all" and "tags", obviously), and felt
I went over the top :-)
Btw: in the meantime, Kristian Høgsberg pointed me to an earlier
thread regarding making git-branch a builtin, which I'm going to look
at tonight.
So many options, so little time :-)
I'm open for suggestions/preferences etc...
--
larsh
next prev parent reply other threads:[~2006-10-22 19:56 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
[not found] ` <5245bfe3982f5c23841229af9f548f982b9c60c3.1161516129.git.hjemli@gmail.com>
2006-10-22 11:30 ` [PATCH 1/3] Fix usagestring for git-branch Lars Hjemli
[not found] ` <00a2e5d38382cea6ff991f60c42923092e1d4dfc.1161516129.git.hjemli@gmail.com>
2006-10-22 11:30 ` [PATCH 2/3] Refactor git-branch Lars Hjemli
[not found] ` <18d62bea290e360a4b5b44df9f23265c5e77964e.1161516129.git.hjemli@gmail.com>
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 [this message]
[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=8c5c35580610221255n521e84e2u8594016297c6cf87@mail.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).