From: Pavel Roskin <proski@gnu.org>
To: Petr Baudis <pasky@suse.cz>, git <git@vger.kernel.org>
Subject: [PATCH]: Use ARGS, not positional arguments
Date: Wed, 12 Oct 2005 01:57:28 -0400 [thread overview]
Message-ID: <1129096648.2427.47.camel@dv> (raw)
Some scripts need to be fixed to use ARGS properly.
Positional arguments are no longer preserved in cg-Xlib, so they may not
be used. cg-export uses standard option parsing now.
Signed-off-by: Pavel Roskin <proski@gnu.org>
diff --git a/cg-admin-lsobj b/cg-admin-lsobj
index 8899037..bf3413f 100755
--- a/cg-admin-lsobj
+++ b/cg-admin-lsobj
@@ -39,7 +39,7 @@ USAGE="cg-admin-lsobj [OBJECT_TYPE]"
. ${COGITO_LIB}cg-Xlib || exit 1
-target=$1
+target=${ARGS[0]}
subdir=$_git_objects
diff --git a/cg-branch-add b/cg-branch-add
index eb20598..c5462cf 100755
--- a/cg-branch-add
+++ b/cg-branch-add
@@ -63,8 +63,8 @@ USAGE="cg-branch-add BRANCH_NAME LOCATIO
. ${COGITO_LIB}cg-Xlib || exit 1
-name=$1
-location=$2
+name=${ARGS[0]}
+location=${ARGS[1]}
([ "$name" ] && [ "$location" ]) || usage
(echo $name | egrep -qv '[^a-zA-Z0-9_.@!:-]') || \
diff --git a/cg-branch-chg b/cg-branch-chg
index 6ac8d15..9c98f6b 100755
--- a/cg-branch-chg
+++ b/cg-branch-chg
@@ -9,8 +9,8 @@ USAGE="cg-branch-chg BRANCH_NAME NEW_LOC
. ${COGITO_LIB}cg-Xlib || exit 1
-name=$1
-location=$2
+name=${ARGS[0]}
+location=${ARGS[1]}
([ "$name" ] && [ "$location" ]) || usage
[ -s "$_git/branches/$name" ] || die "branch does not exist"
diff --git a/cg-export b/cg-export
index 594e225..ef9e7cc 100755
--- a/cg-export
+++ b/cg-export
@@ -15,17 +15,22 @@ _git_requires_root=1
. ${COGITO_LIB}cg-Xlib || exit 1
-if [ "$1" = "-r" ]; then
- shift
- # We do not resolve to tree id since git-tar-tree can utilize some commit
- # information.
- id="$(cg-object-id -c "$1" 2>/dev/null)" || id="$1"
- shift
-else
+id=
+while optparse; do
+ if optparse -r=; then
+ # We do not resolve to tree id since git-tar-tree can
+ # utilize some commit information.
+ id="$(cg-object-id -c "$OPTARG" 2>/dev/null)" || id="$OPTARG"
+ else
+ optfail
+ fi
+done
+
+if [ -z "$id" ]; then
id="$(cg-object-id -c)"
fi
-dest=$1
+dest=${ARGS[0]}
([ "$dest" ] && [ "$id" ]) || usage
diff --git a/cg-patch b/cg-patch
index 2aecd1a..153376e 100755
--- a/cg-patch
+++ b/cg-patch
@@ -70,7 +70,7 @@ redzone_border()
reverse=
-if [ "$1" = "-R" ]; then
+if [ "${ARGS[0]}" = "-R" ]; then
reverse=1
shift
fi
diff --git a/cg-reset b/cg-reset
index dbd69c6..38b7361 100755
--- a/cg-reset
+++ b/cg-reset
@@ -20,7 +20,7 @@ _git_requires_root=1
. ${COGITO_LIB}cg-Xlib || exit 1
deprecated_alias cg-reset cg-cancel
-[ "$1" ] && die "this command takes no parameters; use cg-restore to restore individual files"
+[ "${ARGS[0]}" ] && die "this command takes no parameters; use cg-restore to restore individual files"
if ! [ -s $_git/HEAD ]; then
rm -f $_git/HEAD
diff --git a/cg-seek b/cg-seek
index f07b90c..d2aeb0a 100755
--- a/cg-seek
+++ b/cg-seek
@@ -24,7 +24,7 @@ _git_requires_root=1
. ${COGITO_LIB}cg-Xlib || exit 1
-dstcommit=$1
+dstcommit=${ARGS[0]}
[ -s $_git/blocked ] && grep -vq '^seeked from ' $_git/blocked && die "action blocked: $(cat $_git/blocked)"
--
Regards,
Pavel Roskin
reply other threads:[~2005-10-12 5:57 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=1129096648.2427.47.camel@dv \
--to=proski@gnu.org \
--cc=git@vger.kernel.org \
--cc=pasky@suse.cz \
/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