From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGIT PATCH] stg-gitk: allow passing args to gitk; add --help.
Date: Thu, 22 Nov 2007 22:23:34 +0100 [thread overview]
Message-ID: <20071122212334.3351.4777.stgit@gandelf.nowhere.earth> (raw)
Quite handy to further limit the commits to be shown.
---
contrib/stg-gitk | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/contrib/stg-gitk b/contrib/stg-gitk
index 6ddcfb1..cb264e5 100755
--- a/contrib/stg-gitk
+++ b/contrib/stg-gitk
@@ -12,25 +12,31 @@ set -e
# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
# Subject to the GNU GPL, version 2.
+helptext="Usage: $(basename $0) [--refs] [<branches>|--all] [-- <gitk args>]"
+
usage()
{
- echo "Usage: $(basename $0) [<branches>|--all]"
+ echo >&2 "$helptext"
exit 1
}
allbranches=0
refsonly=0
+branches=''
while [ "$#" -gt 0 ]; do
case "$1" in
--refs) refsonly=1 ;;
--all) allbranches=1 ;;
+ --help) echo "$helptext"; exit 0 ;;
+ --) shift; break ;;
--*) usage ;;
- *) break ;;
+ *) branches="$branches $1" ;;
esac
shift
done
+# Now any remaining stuff in $@ are additional options for gitk
-if [ $allbranches = 1 ] && [ "$#" -gt 0 ]; then
+if [ $allbranches = 1 ] && [ "$branches" != "" ]; then
usage
fi
@@ -41,11 +47,17 @@ refdirs=''
if [ $allbranches = 1 ]; then
refdirs="$GIT_DIR/refs"
else
- if [ "$#" = 0 ]; then
- set -- "$(stg branch)"
+ # default to current branch
+ if [ "$branches" == "" ]; then
+ branches="$(stg branch)"
+ fi
+ if [ "$branches" == "" ]; then
+ echo >&2 "ERROR: cannot find current branch."
+ exit 1
fi
- for b in "$@"; do
+ # expand patches for each named branch
+ for b in $branches; do
if [ -e "$GIT_DIR/refs/patches/$b" ]; then
# StGIT branch: show all patches
refdirs="$refdirs $GIT_DIR/refs/heads/$b $GIT_DIR/refs/patches/$b"
@@ -73,11 +85,11 @@ elif grep -q -- --argscmd $(which gitk); then
# This gitk supports --argscmd.
# Let's use a hack to pass --all, which was consumed during command-line parsing
if [ $allbranches = 1 ]; then
- gitk --argscmd="$0 --refs --all"
+ gitk --argscmd="$0 --refs --all" "$@"
else
- gitk --argscmd="$0 --refs $*"
+ gitk --argscmd="$0 --refs $branches" "$@"
fi
else
# This gitk does not support --argscmd, just compute refs onces
- gitk $(printrefs)
+ gitk $(printrefs) "$@"
fi
reply other threads:[~2007-11-22 21:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20071122212334.3351.4777.stgit@gandelf.nowhere.earth \
--to=ydirson@altern.org \
--cc=catalin.marinas@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